|
|
@@ -7,9 +7,7 @@ import com.fasterxml.jackson.databind.node.TextNode;
|
|
|
import com.uas.eis.core.support.TokenProperties;
|
|
|
import com.uas.eis.dao.BaseDao;
|
|
|
import com.uas.eis.sdk.converter.ObjectToMapConverter;
|
|
|
-import com.uas.eis.sdk.dto.PurchaseItem;
|
|
|
-import com.uas.eis.sdk.dto.PurchaseItemAmount;
|
|
|
-import com.uas.eis.sdk.dto.PurchaseMain;
|
|
|
+import com.uas.eis.sdk.dto.*;
|
|
|
import com.uas.eis.service.ERPService;
|
|
|
import com.uas.eis.utils.SqlUtil;
|
|
|
import com.uas.eis.utils.X5StringUtils;
|
|
|
@@ -158,6 +156,119 @@ public class ERPServiceImpl implements ERPService {
|
|
|
return result;
|
|
|
}
|
|
|
|
|
|
+ @Override
|
|
|
+ public Map<String, Object> closePurchase(String data) {
|
|
|
+ Map<String, Object> result = new HashMap<>();
|
|
|
+ Map<String, Object> header_result = new HashMap<>();
|
|
|
+ Map<String, Object> body_result = new HashMap<>();
|
|
|
+ Map<String, Object> it_return_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(data);
|
|
|
+ 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){
|
|
|
+ String item_guid = null;
|
|
|
+ String purord_item_num = null;
|
|
|
+ body = map.get("body") == null ? "" : map.get("body").toString();
|
|
|
+ PurchaseCloseMain purchaseCloseMain = objectMapper.readValue(body, PurchaseCloseMain.class);
|
|
|
+ String purord_num = purchaseCloseMain.getPURORD_NUM();
|
|
|
+ List<PurchaseCloseItem> et_close_item1 = purchaseCloseMain.getET_CLOSE_ITEM();
|
|
|
+ if(et_close_item1.size()>0){
|
|
|
+ purord_item_num = et_close_item1.get(0).getPURORD_ITEM_NUM();
|
|
|
+ }
|
|
|
+ String guid = purchaseCloseMain.getGUID();
|
|
|
+ resultSuccessMsg="采购订单:"+purord_num+",行号:"+purord_item_num+"执行成功,具体结果请查看IT_RETURN反馈明细表";
|
|
|
+ resultErrorMsg="采购订单:"+purord_num+",行号:"+purord_item_num+"执行失败,";
|
|
|
+ it_return_result.put("ITEM_GUID",guid);
|
|
|
+ it_return_result.put("PURORD_NUM",purord_num);
|
|
|
+ it_return_result.put("PURORD_ITEM_NUM",purord_item_num);
|
|
|
+ it_return_result.put("MSG_TYPE","S");
|
|
|
+ it_return_result.put("MESSAGE","处理成功");
|
|
|
+ body_result.put("IT_RETURN",it_return_result);
|
|
|
+ int count = baseDao.getCount("select * from PurchaseMainXM where PURORD_NUM='" + purord_num + "'");
|
|
|
+ if (count > 0){
|
|
|
+ //主表
|
|
|
+ Map<String, Object> purchaseCloseMain_map = ObjectToMapConverter.objectToMap(purchaseCloseMain);
|
|
|
+ purchaseCloseMain_map.remove("ET_CLOSE_ITEM");
|
|
|
+ purchaseCloseMain_map.put("pcxid", 0);
|
|
|
+ baseDao.execute(SqlUtil.getInsertSql(purchaseCloseMain_map,"purchaseCloseMainXM","pcxid"));
|
|
|
+ Object pcxid = baseDao.getFieldDataByCondition("purchaseCloseMainXM", "pcxid", "GUID='" + purchaseCloseMain_map.get("GUID")+"'");
|
|
|
+ //从表
|
|
|
+ List<PurchaseCloseItem> et_close_item = purchaseCloseMain.getET_CLOSE_ITEM();
|
|
|
+ for (PurchaseCloseItem purchaseCloseItem:et_close_item) {
|
|
|
+ //List<String> ItemSqls = new ArrayList<>();
|
|
|
+ Map<String, Object> purchaseCloseItem_map = ObjectToMapConverter.objectToMap(purchaseCloseItem);
|
|
|
+ purchaseCloseItem_map.remove("ET_ITEM_AMOUNT");
|
|
|
+ purchaseCloseItem_map.put("pcixid",0);
|
|
|
+ purchaseCloseItem_map.put("pcixpcxid",pcxid);
|
|
|
+ String insertItemSql = SqlUtil.getInsertSql(purchaseCloseItem_map, "PurchaseCloseItemXM", "pcixid");
|
|
|
+ //ItemSqls.add(insertItemSql);
|
|
|
+ baseDao.execute(insertItemSql);
|
|
|
+ item_guid = purchaseCloseItem.getITEM_GUID();
|
|
|
+ }
|
|
|
+ int DEAL_STATUS = baseDao.getCount("select * from PurchaseCloseItemXM where DEAL_STATUS=-1 and ITEM_GUID='" + item_guid + "'");
|
|
|
+ if(DEAL_STATUS == 0){
|
|
|
+ //关闭订单逻辑
|
|
|
+ }else{
|
|
|
+ header_result.put("code", "400");
|
|
|
+ header_result.put("desc", resultErrorMsg+"重复推送!");
|
|
|
+ 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;
|
|
|
+ }
|
|
|
+
|
|
|
+ header_result.put("code", "200");
|
|
|
+ header_result.put("desc", resultSuccessMsg);
|
|
|
+ result.put("header", header_result);
|
|
|
+ result.put("body",body_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("同步收料单异常信息:"+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+"未知错误!");
|
|
|
+ result.put("header", header_result);
|
|
|
+ return result;
|
|
|
+ }
|
|
|
+ return result;
|
|
|
+ }
|
|
|
+
|
|
|
public static String unescapeJsonWithJackson(String jsonString) {
|
|
|
try {
|
|
|
ObjectMapper mapper = new ObjectMapper();
|