|
|
@@ -21,6 +21,8 @@ import org.springframework.stereotype.Service;
|
|
|
import org.springframework.transaction.annotation.Transactional;
|
|
|
|
|
|
import javax.annotation.Resource;
|
|
|
+import java.net.URLDecoder;
|
|
|
+import java.nio.charset.StandardCharsets;
|
|
|
import java.text.SimpleDateFormat;
|
|
|
import java.util.*;
|
|
|
|
|
|
@@ -300,6 +302,111 @@ public class ERPServiceImpl implements ERPService {
|
|
|
return result;
|
|
|
}
|
|
|
|
|
|
+ @Override
|
|
|
+ public Map<String, Object> deliInstruction(String data) {
|
|
|
+ Map<String, Object> result = new HashMap<>();
|
|
|
+ Map<String, Object> header_result = new HashMap<>();
|
|
|
+ String resultSuccessMsg = "";
|
|
|
+ String resultErrorMsg = "";
|
|
|
+ String sign = null;
|
|
|
+ String body = null;
|
|
|
+ try {
|
|
|
+ ObjectMapper objectMapper = new ObjectMapper();
|
|
|
+ String decode = URLDecoder.decode(data, StandardCharsets.UTF_8.toString());
|
|
|
+ String jsonString = X5StringUtils.decodeBase64(decode);
|
|
|
+ Map<String, Object> map = objectMapper.readValue(jsonString, Map.class);
|
|
|
+ if(map.size()>0 && map.get("header")!=null ){
|
|
|
+ Map<String, Object> header_map = (Map<String, Object>) map.get("header");
|
|
|
+ sign = header_map.get("sign") == null ? "" : header_map.get("sign").toString();
|
|
|
+ }
|
|
|
+ boolean checkSign = X5StringUtils.checkSign(sign, "test", jsonString, "218A05A252469F5A62B0B3204F669E1D");
|
|
|
+ if(checkSign || true){
|
|
|
+ try {
|
|
|
+ if(map.get("body")!=null){
|
|
|
+ body = map.get("body") == null ? "" : map.get("body").toString();
|
|
|
+ DeliInstruction deliInstruction = objectMapper.readValue(body, DeliInstruction.class);
|
|
|
+ String deli_instru_no = deliInstruction.getDELI_INSTRU_NO();
|
|
|
+ String guid = deliInstruction.getGUID();
|
|
|
+ resultSuccessMsg="送货指令:"+deli_instru_no+"处理成功";
|
|
|
+ resultErrorMsg="送货指令:"+deli_instru_no+"处理失败,";
|
|
|
+
|
|
|
+ String operation_type = deliInstruction.getOPERATION_TYPE();
|
|
|
+ if("I".equals(operation_type) || "U".equals(operation_type)){
|
|
|
+ int count = baseDao.getCount("select * from deliInstructionXM where GUID='" + guid + "'");
|
|
|
+ if (count == 0){
|
|
|
+ //主表
|
|
|
+ Map<String, Object> deliInstruction_map = ObjectToMapConverter.objectToMap(deliInstruction);
|
|
|
+ deliInstruction_map.remove("ET_ITEM");
|
|
|
+ deliInstruction_map.put("DI_ID", 0);
|
|
|
+ baseDao.execute(SqlUtil.getInsertSql(deliInstruction_map,"deliInstructionXM","DI_ID"));
|
|
|
+ Object DI_ID = baseDao.getFieldDataByCondition("deliInstructionXM", "DI_ID", "GUID='" + guid+"'");
|
|
|
+ //从表
|
|
|
+ List<DeliInstructionItem> et_item = deliInstruction.getET_ITEM();
|
|
|
+ for (DeliInstructionItem deliInstructionItem:et_item) {
|
|
|
+ //List<String> ItemSqls = new ArrayList<>();
|
|
|
+ Map<String, Object> deliInstructionItem_map = ObjectToMapConverter.objectToMap(deliInstructionItem);
|
|
|
+ deliInstructionItem_map.remove("ET_ITEM_AMOUNT");
|
|
|
+ deliInstructionItem_map.put("DID_ID",0);
|
|
|
+ deliInstructionItem_map.put("DID_DIID",DI_ID);
|
|
|
+ String insertItemSql = SqlUtil.getInsertSql(deliInstructionItem_map, "deliInstructionDetailXM", "DID_ID");
|
|
|
+ baseDao.execute(insertItemSql);
|
|
|
+ }
|
|
|
+ }else{
|
|
|
+ //更新
|
|
|
+ header_result.put("code", "400");
|
|
|
+ header_result.put("desc", resultErrorMsg+"具体报错原因:重复推送,GUID已存在!");
|
|
|
+ result.put("header", header_result);
|
|
|
+ return result;
|
|
|
+ }
|
|
|
+ }else{
|
|
|
+ int count = baseDao.getCount("select * from deliInstructionXM where GUID='" + guid + "'");
|
|
|
+ if (count == 0){
|
|
|
+ //更新
|
|
|
+ header_result.put("code", "400");
|
|
|
+ header_result.put("desc", resultErrorMsg+"具体报错原因:采购单号不存在,不能执行更新操作!");
|
|
|
+ result.put("header", header_result);
|
|
|
+ return result;
|
|
|
+ }else{
|
|
|
+ //更新
|
|
|
+ header_result.put("code", "200");
|
|
|
+ header_result.put("desc", resultSuccessMsg+"执行更新操作中!");
|
|
|
+ result.put("header", header_result);
|
|
|
+ return result;
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ header_result.put("code", "200");
|
|
|
+ header_result.put("desc", resultSuccessMsg);
|
|
|
+ result.put("header", header_result);
|
|
|
+ }else{
|
|
|
+ header_result.put("code", "400");
|
|
|
+ header_result.put("desc", resultErrorMsg+"具体报错原因:body数据不存在!");
|
|
|
+ result.put("header", header_result);
|
|
|
+ return result;
|
|
|
+ }
|
|
|
+ }catch (Exception e){
|
|
|
+ logger.info("同步收料单异常信息:"+body);
|
|
|
+ header_result.put("code", "400");
|
|
|
+ header_result.put("desc", resultErrorMsg+"具体报错原因:解析body失败!");
|
|
|
+ result.put("header", header_result);
|
|
|
+ return result;
|
|
|
+ }
|
|
|
+ }else{
|
|
|
+ header_result.put("code", "400");
|
|
|
+ header_result.put("desc", resultErrorMsg+"具体报错原因:身份验证失败!");
|
|
|
+ result.put("header", header_result);
|
|
|
+ return result;
|
|
|
+ }
|
|
|
+ }catch (Exception e){
|
|
|
+ logger.info("同步收料单异常信息:"+e.getMessage());
|
|
|
+ header_result.put("code", "400");
|
|
|
+ header_result.put("desc", resultErrorMsg+"具体报错原因:JSON解析失败!!");
|
|
|
+ result.put("header", header_result);
|
|
|
+ return result;
|
|
|
+ }
|
|
|
+ return result;
|
|
|
+ }
|
|
|
+
|
|
|
public static String unescapeJsonWithJackson(String jsonString) {
|
|
|
try {
|
|
|
ObjectMapper mapper = new ObjectMapper();
|