You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
106 lines
3.9 KiB
106 lines
3.9 KiB
package com.dxhy.extend.controller;
|
|
|
|
import cn.hutool.http.HttpRequest;
|
|
import cn.hutool.json.JSONUtil;
|
|
import com.alibaba.fastjson.JSONObject;
|
|
import com.alibaba.nacos.common.http.HttpUtils;
|
|
import com.dxhy.common.constant.CommonConstants;
|
|
import com.dxhy.common.utils.R;
|
|
import com.dxhy.extend.model.SNSAPObject;
|
|
import com.dxhy.extend.service.bb.VouncherSyncService;
|
|
import lombok.extern.slf4j.Slf4j;
|
|
import org.springframework.http.ResponseEntity;
|
|
import org.springframework.stereotype.Controller;
|
|
import org.springframework.web.bind.annotation.PostMapping;
|
|
import org.springframework.web.bind.annotation.RequestBody;
|
|
import org.springframework.web.bind.annotation.RequestMapping;
|
|
|
|
import javax.annotation.Resource;
|
|
import java.util.HashMap;
|
|
import java.util.Map;
|
|
import java.util.UUID;
|
|
|
|
/**
|
|
* @Author wangzhikun
|
|
* @Date 2023/3/30 2023/3/30
|
|
*/
|
|
@Controller
|
|
@RequestMapping("vouncherSync")
|
|
@Slf4j
|
|
public class VouncherSyncController {
|
|
@Resource
|
|
private VouncherSyncService vouncherSyncService;
|
|
@PostMapping("getSapData")
|
|
public Object getSapData(@RequestBody Map<String,String> map){
|
|
//是否全量 X为全量推送,空为增量推送。
|
|
//全量推送逻辑为 查询出的符合条件的凭证全部推送,全量推送不再检查是否在自定义表中已传输。
|
|
//增量推送,已传输的凭证数据不再推送(检查传输记录表是否已传输成功)
|
|
String ifAll=map.get("ifAll");
|
|
//公司代码
|
|
String companyCode = map.get("companyCode");
|
|
//开始日期
|
|
String startTime= map.get("startTime");
|
|
//结束日期
|
|
String month=map.get("endTime");
|
|
SNSAPObject object = new SNSAPObject();
|
|
object.setSYSID("FPXT");
|
|
object.setIFYWID("FI842");
|
|
object.setBSKEY(UUID.randomUUID().toString().replace("-", ""));
|
|
//object.setSAPKEY("");
|
|
|
|
// object.setZFILED1("");
|
|
// object.setZFILED2("");
|
|
// object.setZFILED3("");
|
|
// object.setZFILED4("");
|
|
object.setZFILED5("200");
|
|
Map<String,String> requestMap = new HashMap<>();
|
|
requestMap.put("ZGSDM",companyCode);
|
|
requestMap.put("GJAHR","");
|
|
requestMap.put("MONAT",month);
|
|
requestMap.put("ZDATEF",startTime);
|
|
requestMap.put("ZFLAG",ifAll);
|
|
object.setZDATA(requestMap);
|
|
JSONObject request = new JSONObject();
|
|
request.put("IS_INPUT",object);
|
|
try{
|
|
String s = vouncherSyncService.sendPo(JSONObject.toJSONString(request));
|
|
Map map1 = JSONObject.parseObject(s, Map.class);
|
|
Map output = (Map)map1.get("ES_OUTPUT");
|
|
String ztype =(String) output.get("ZTYPE");
|
|
if(ztype.equals("S")){
|
|
return ResponseEntity.ok(R.ok().put("data","数据拉取成功"));
|
|
}else {
|
|
return ResponseEntity.ok(R.error(CommonConstants.MSG_ERR_DEFAULT));
|
|
}
|
|
|
|
}catch (Exception e ){
|
|
e.printStackTrace();
|
|
return ResponseEntity.ok(R.error(CommonConstants.MSG_ERR_DEFAULT));
|
|
}
|
|
}
|
|
|
|
|
|
public static void main(String[] args) {
|
|
SNSAPObject object = new SNSAPObject();
|
|
object.setSYSID("FPXT");
|
|
object.setIFYWID("FI842");
|
|
object.setBSKEY(UUID.randomUUID().toString().replace("-", ""));
|
|
//object.setSAPKEY("");
|
|
|
|
// object.setZFILED1("");
|
|
// object.setZFILED2("");
|
|
// object.setZFILED3("");
|
|
// object.setZFILED4("");
|
|
object.setZFILED5("200");
|
|
Map<String,String> requestMap = new HashMap<>();
|
|
requestMap.put("ZGSDM","123");
|
|
requestMap.put("GJAHR","");
|
|
requestMap.put("MONAT","");
|
|
requestMap.put("ZDATEF","2023");
|
|
requestMap.put("ZFLAG","X");
|
|
object.setZDATA(requestMap);
|
|
JSONObject request = new JSONObject();
|
|
request.put("IS_INPUT",object);
|
|
System.out.println(JSONObject.toJSONString(request));
|
|
}
|
|
}
|
|
|