Просмотр исходного кода

出货通知单上传MES及确认

koul 1 год назад
Родитель
Сommit
56a68c0c0b

+ 128 - 0
src/main/java/com/uas/eis/entity/SendNotify.java

@@ -0,0 +1,128 @@
+package com.uas.eis.entity;
+
+import com.alibaba.fastjson.annotation.JSONField;
+
+import java.io.Serializable;
+import java.util.List;
+
+public class SendNotify implements Serializable {
+    @JSONField(name = "snCode")
+    private String sn_code;
+    @JSONField(name = "custNo")
+    private String sn_custcode;
+    @JSONField(name = "isCheckOutFlag")
+    private int sn_isvmi;
+    @JSONField(name = "userName")
+    private String sn_sellername;
+    @JSONField(name = "remark1")
+    private String sn_remark;
+    @JSONField(name = "remark2")
+    private String sn_remark2;
+    @JSONField(name = "remark3")
+    private String sn_packingremark;
+    @JSONField(name = "companyNo")
+    private String sn_cop;
+    @JSONField(name = "mesUser")
+    private String mesUser;
+    @JSONField(name = "mesPwd")
+    private String mesPwd;
+    @JSONField(name = "flag")
+    private int flag;
+    private List<SendNotifyDetail> detailList;
+
+    public String getSn_code() {
+        return sn_code;
+    }
+
+    public void setSn_code(String sn_code) {
+        this.sn_code = sn_code;
+    }
+
+    public String getSn_custcode() {
+        return sn_custcode;
+    }
+
+    public void setSn_custcode(String sn_custcode) {
+        this.sn_custcode = sn_custcode;
+    }
+
+    public int getSn_isvmi() {
+        return sn_isvmi;
+    }
+
+    public void setSn_isvmi(int sn_isvmi) {
+        this.sn_isvmi = sn_isvmi;
+    }
+
+    public String getSn_sellername() {
+        return sn_sellername;
+    }
+
+    public void setSn_sellername(String sn_sellername) {
+        this.sn_sellername = sn_sellername;
+    }
+
+    public String getSn_remark() {
+        return sn_remark;
+    }
+
+    public void setSn_remark(String sn_remark) {
+        this.sn_remark = sn_remark;
+    }
+
+    public String getSn_remark2() {
+        return sn_remark2;
+    }
+
+    public void setSn_remark2(String sn_remark2) {
+        this.sn_remark2 = sn_remark2;
+    }
+
+    public String getSn_packingremark() {
+        return sn_packingremark;
+    }
+
+    public void setSn_packingremark(String sn_packingremark) {
+        this.sn_packingremark = sn_packingremark;
+    }
+
+    public String getSn_cop() {
+        return sn_cop;
+    }
+
+    public void setSn_cop(String sn_cop) {
+        this.sn_cop = sn_cop;
+    }
+
+    public String getMesUser() {
+        return mesUser;
+    }
+
+    public void setMesUser(String mesUser) {
+        this.mesUser = mesUser;
+    }
+
+    public String getMesPwd() {
+        return mesPwd;
+    }
+
+    public void setMesPwd(String mesPwd) {
+        this.mesPwd = mesPwd;
+    }
+
+    public int getFlag() {
+        return flag;
+    }
+
+    public void setFlag(int flag) {
+        this.flag = flag;
+    }
+
+    public List<SendNotifyDetail> getDetailList() {
+        return detailList;
+    }
+
+    public void setDetailList(List<SendNotifyDetail> detailList) {
+        this.detailList = detailList;
+    }
+}

+ 32 - 60
src/main/java/com/uas/eis/entity/SendNotifyDetail.java

@@ -2,52 +2,24 @@ package com.uas.eis.entity;
 
 import com.alibaba.fastjson.annotation.JSONField;
 
-public class SendNotifyDetail {
-    @JSONField(name = "scrapno")
-    private String sn_code;
-    @JSONField(name = "scrapid")
-    private String sn_id;
-    @JSONField(name = "scrapdetno")
-    private String snd_pdno;
-    @JSONField(name = "prodno")
+import java.io.Serializable;
+
+public class SendNotifyDetail implements Serializable {
+    @JSONField(name = "custOrder")
     private String snd_ordercode;
-    @JSONField(name = "proddetno")
-    private String snd_orderdetno;
-    @JSONField(name = "itemno")
+    @JSONField(name = "itemNo")
     private String snd_prodcode;
-    @JSONField(name = "qty")
-    private int snd_outqty;
-    @JSONField(name = "mesUser")
-    private String mesUser;
-    @JSONField(name = "mesPwd")
-    private String mesPwd;
-    @JSONField(name = "actionflag")
+    @JSONField(name = "smQty")
+    private Double snd_outqty;
+    @JSONField(name = "whNo")
+    private String snd_warehousecode;
+    @JSONField(name = "lineSeq")
+    private int snd_orderdetno;
+    @JSONField(name = "idNo")
+    private int snd_id;
+    @JSONField(name = "actionId")
     private String flag;
 
-    public String getSn_code() {
-        return sn_code;
-    }
-
-    public void setSn_code(String sn_code) {
-        this.sn_code = sn_code;
-    }
-
-    public String getSn_id() {
-        return sn_id;
-    }
-
-    public void setSn_id(String sn_id) {
-        this.sn_id = sn_id;
-    }
-
-    public String getSnd_pdno() {
-        return snd_pdno;
-    }
-
-    public void setSnd_pdno(String snd_pdno) {
-        this.snd_pdno = snd_pdno;
-    }
-
     public String getSnd_ordercode() {
         return snd_ordercode;
     }
@@ -56,14 +28,6 @@ public class SendNotifyDetail {
         this.snd_ordercode = snd_ordercode;
     }
 
-    public String getSnd_orderdetno() {
-        return snd_orderdetno;
-    }
-
-    public void setSnd_orderdetno(String snd_orderdetno) {
-        this.snd_orderdetno = snd_orderdetno;
-    }
-
     public String getSnd_prodcode() {
         return snd_prodcode;
     }
@@ -72,28 +36,36 @@ public class SendNotifyDetail {
         this.snd_prodcode = snd_prodcode;
     }
 
-    public int getSnd_outqty() {
+    public Double getSnd_outqty() {
         return snd_outqty;
     }
 
-    public void setSnd_outqty(int snd_outqty) {
+    public void setSnd_outqty(Double snd_outqty) {
         this.snd_outqty = snd_outqty;
     }
 
-    public String getMesUser() {
-        return mesUser;
+    public String getSnd_warehousecode() {
+        return snd_warehousecode;
     }
 
-    public void setMesUser(String mesUser) {
-        this.mesUser = mesUser;
+    public void setSnd_warehousecode(String snd_warehousecode) {
+        this.snd_warehousecode = snd_warehousecode;
+    }
+
+    public int getSnd_orderdetno() {
+        return snd_orderdetno;
+    }
+
+    public void setSnd_orderdetno(int snd_orderdetno) {
+        this.snd_orderdetno = snd_orderdetno;
     }
 
-    public String getMesPwd() {
-        return mesPwd;
+    public int getSnd_id() {
+        return snd_id;
     }
 
-    public void setMesPwd(String mesPwd) {
-        this.mesPwd = mesPwd;
+    public void setSnd_id(int snd_id) {
+        this.snd_id = snd_id;
     }
 
     public String getFlag() {

+ 22 - 9
src/main/java/com/uas/eis/service/Impl/ERPServiceImpl.java

@@ -1,6 +1,7 @@
 package com.uas.eis.service.Impl;
 
 import com.alibaba.fastjson.JSON;
+import com.alibaba.fastjson.JSONArray;
 import com.alibaba.fastjson.JSONObject;
 import com.alibaba.fastjson.serializer.SerializerFeature;
 import com.uas.eis.core.support.TokenProperties;
@@ -248,17 +249,17 @@ public class ERPServiceImpl implements ERPService {
     public Map<String, Object> syncSendNotify(String data) {
         Map<Object, Object> store = BaseUtil.parseFormStoreToMap(data);
         Object snId = store.get("sn_id");
-        String mesUser = tokenConfig.get("mesUser");
-        String mesPwd = MD5Util.encodeByMD5(tokenConfig.get("mesPwd"));
         int flag = Integer.parseInt(StringUtil.nvl(store.get("flag"), "-1"));
         Map<String, Object> hashMap = new HashMap<>();
         hashMap.put("code", 0);
         int count = baseDao.getCount("select count(1) from SendNotify where sn_id="+snId);
         if (count>0) {
-            List<SendNotifyDetail> sendNotifyDetail = baseDao.getJdbcTemplate().query("select sn_code,sn_id,snd_pdno,snd_ordercode,snd_orderdetno,snd_prodcode,snd_outqty,'"+mesUser+"' mesUser,'"+mesPwd+"' mesPwd,"+flag+" flag from SendNotify left join SendNotifyDetail on sn_id=snd_snid where sn_id="+ snId,new Object[]{},new BeanPropertyRowMapper<SendNotifyDetail>(SendNotifyDetail.class));
-            Map<String, Object> ma = new HashMap<>();
-            ma.put("data",sendNotifyDetail);
-            Map<String, Object> map = syncMESCheckBomItems(JSON.toJSONString(ma, SerializerFeature.WriteMapNullValue).replace("null", "\"\""), tokenConfig.get("syncSendNotify"));
+            SendNotify sendNotify = baseDao.getJdbcTemplate().queryForObject("select sn_code,sn_custcode,nvl(sn_isvmi,0) sn_isvmi,sn_sellername,sn_remark,sn_remark2,sn_packingremark,nvl(sn_cop,'BYT') sn_cop," + flag + " flag from SendNotify where sn_id=?", new BeanPropertyRowMapper<SendNotify>(SendNotify.class), snId);
+            sendNotify.setMesPwd(MD5Util.encodeByMD5(tokenConfig.get("mesPwd")));
+            sendNotify.setMesUser(tokenConfig.get("mesUser"));
+            List<SendNotifyDetail> sendNotifyDetails = baseDao.getJdbcTemplate().query("select snd_ordercode,snd_prodcode,snd_outqty,nvl(A.cd_varchar50_1,snd_warehousecode) snd_warehousecode,snd_orderdetno,snd_id,"+flag+" flag from SendNotifyDetail left join (select cd_varchar50_3,cd_varchar50_1 from customtable left join customtabledetail on ct_id=cd_ctid where ct_caller='MESWarehouse') A on A.cd_varchar50_3=snd_warehousecode where snd_snid="+ snId,new Object[]{},new BeanPropertyRowMapper<SendNotifyDetail>(SendNotifyDetail.class));
+            sendNotify.setDetailList(sendNotifyDetails);
+            Map<String, Object> map = syncMESCheckBomItems(JSON.toJSONString(sendNotify, SerializerFeature.WriteMapNullValue).replace("null", "\"\""), tokenConfig.get("syncSendNotify"));
             hashMap.put("code", -1);
             hashMap.put("msg", "MES异常,请联系MES处理!");
             if (map != null&&!map.isEmpty()) {
@@ -324,14 +325,26 @@ public class ERPServiceImpl implements ERPService {
         try {
             String post = PSHttpUtils.sendPost(tokenConfig.get("mesHttp") + url, params);
             logger.info("post:"+post);
-            JSONObject jsonObject = JSON.parseObject(post);
-            int code = jsonObject.getIntValue("msgId");
+            JSONObject jsonObject;
+            int code=0;
+            String msg="";
+            if (post.contains("MsgId")){
+                JSONArray objects = JSON.parseArray(post);
+                Object obj = objects.get(0);
+                jsonObject=JSON.parseObject(StringUtil.nvl(obj,"{}"));
+                code= jsonObject.getIntValue("MsgId");
+                msg=jsonObject.getString("MsgStr");
+            }else {
+                jsonObject = JSON.parseObject(post);
+                code= jsonObject.getIntValue("msgId");
+                msg=jsonObject.getString("msgStr");
+            }
             if (code==0){
                 map.put("code",code);
                 map.put("msg","同步MES成功");
             }else if(code==1){
                 map.put("code",code);
-                map.put("msg",jsonObject.getString("msgStr"));
+                map.put("msg",msg);
             }else {
                 map.put("msg","接口调用异常,错误代码:"+code+",请联系MES处理!");
             }

+ 109 - 96
src/main/java/com/uas/eis/service/Impl/MESServiceImpl.java

@@ -1762,62 +1762,56 @@ public class MESServiceImpl implements MESService {
     @Override
     public ApiResult<String> confirmSendNotify(HttpServletRequest request) {
         String requestId = request.getHeader("RequestId");
-        Map<String, JSONArray> data = getData(request);
-        if (data!=null&&!data.isEmpty()){
-            int snId=0;
-            JSONArray main = data.get("main");
-            if (main != null&&main.size()>0) {
-                JSONObject object = JSON.parseObject(StringUtil.nvl(main.get(0), "{}"));
-                snId = Integer.parseInt(StringUtil.nvl(object.get("snId"), "0"));
-                if (!baseDao.checkIf("SendNotify", "sn_id=" + snId)) {
-                    return ApiResponse.failRsp("10071", requestId, "出货通知单不存在,无法确认!");
-                }
-                if (!baseDao.checkIf("SendNotify", "sn_statuscode='AUDITED' and sn_id=" + snId)) {
-                    return ApiResponse.failRsp("10072", requestId, "出货通知单不是已审核状态,无法确认!");
-                }
-                if (baseDao.checkIf("SendNotify", "sn_sendstatus='已出库' and sn_id=" + snId)) {
-                    return ApiResponse.failRsp("10073", requestId, "出货通知单已出货,无需重新确认生成!");
-                }
-                if (baseDao.checkIf("ProdIODetail", "pd_piclass='出货单' and pd_snid=" + snId)) {
-                    return ApiResponse.failRsp("10074", requestId, "出货通知单已转出货单,无需重新确认生成!");
-                }
-                // 存在未审批变更单
-                String dets = baseDao.getJdbcTemplate().queryForObject("select wm_concat(snd_pdno) from sendnotifydetail where snd_snid=" + snId + " and exists (select 1 from SaleChangeDetail left join SaleChange on sc_id=scd_scid where scd_sacode=snd_ordercode and scd_sddetno=snd_orderdetno and sc_statuscode<>'AUDITED' )", String.class);
-                if (dets != null) {
-                    return ApiResponse.failRsp("10075", requestId, "存在待审批的销售变更单,不能进行转出操作!行号:" + dets);
-                }
-                dets = baseDao.getJdbcTemplate().queryForObject("select wm_concat(snd_pdno) from sendnotifydetail where snd_snid=" + snId + " and exists (select 1 from SendNotifyChange left join SendNotifyChangeDetail on sc_id=scd_scid where sc_sncode=snd_code and scd_snddetno=snd_pdno and sc_statuscode<>'AUDITED')", String.class);
-                if (dets != null) {
-                    return ApiResponse.failRsp("10076", requestId, "存在待审批的通知变更单,不能进行转出操作!行号:" + dets);
-                }
-                if (baseDao.isDBSetting("Sale", "zeroOutWhenHung")) {
-                    dets = baseDao.getJdbcTemplate().queryForObject("select distinct wm_concat('通知单号:'||sn_code||'客户:'||sn_custcode) from sendnotify left join SendNotifyDetail on snd_snid=sn_id where nvl(sn_custcode, ' ')<>' ' and snd_snid=" + snId + " and sn_custcode in (select cu_code from customer where cu_status='挂起') and not exists (select 1 from saledetail where sd_code=snd_ordercode and sd_detno=snd_orderdetno and nvl(sd_price,0)=0)", String.class);
+        List<Map<Object, Object>> maps = getJsonsData(request);
+        if (maps!=null&&!maps.isEmpty()){
+            List<Map<String, Object>> hashMaps = new ArrayList<>();
+            List<Key> keys = new ArrayList<>();
+            for (Map<Object, Object> map:maps) {
+                int sndId = Integer.parseInt(StringUtil.nvl(map.get("sndId"), "0"));
+                if (sndId>0){
+                    int snId = Integer.parseInt(StringUtil.nvl(baseDao.getFieldDataByCondition("SendNotifyDetail", "snd_snid", "snd_id=" + sndId), "0"));
+                    if (!baseDao.checkIf("SendNotifyDetail","snd_id="+sndId)){
+                        return ApiResponse.failRsp("10079", requestId, "明细行不存在,请核对!");
+                    }
+                    if (!baseDao.checkIf("SendNotify", "sn_id=" + snId)) {
+                        return ApiResponse.failRsp("10071", requestId, "出货通知单不存在,无法确认!");
+                    }
+                    if (!baseDao.checkIf("SendNotify", "sn_statuscode='AUDITED' and sn_id=" + snId)) {
+                        return ApiResponse.failRsp("10072", requestId, "出货通知单不是已审核状态,无法确认!");
+                    }
+                    if (baseDao.checkIf("SendNotify", "sn_sendstatus='已出库' and sn_id=" + snId)) {
+                        return ApiResponse.failRsp("10073", requestId, "出货通知单已出货,无需重新确认生成!");
+                    }
+                    if (baseDao.checkIf("ProdIODetail", "pd_piclass='出货单' and pd_orderid=" + sndId)) {
+                        return ApiResponse.failRsp("10074", requestId, "出货通知单已转出货单,无需重新确认生成!");
+                    }
+                    // 存在未审批变更单
+                    String dets = baseDao.getJdbcTemplate().queryForObject("select wm_concat(snd_pdno) from sendnotifydetail where snd_id=" + sndId + " and exists (select 1 from SaleChangeDetail left join SaleChange on sc_id=scd_scid where scd_sacode=snd_ordercode and scd_sddetno=snd_orderdetno and sc_statuscode<>'AUDITED' )", String.class);
                     if (dets != null) {
-                        return ApiResponse.failRsp("10077", requestId, "通知单客户已挂起,不能进行转出操作!" + dets);
+                        return ApiResponse.failRsp("10075", requestId, "存在待审批的销售变更单,不能进行转出操作!行号:" + dets);
                     }
-                } else {
-                    dets = baseDao.getJdbcTemplate().queryForObject("select distinct wm_concat('通知单号:'||sn_code||'客户:'||sn_custcode) from sendnotify left join SendNotifyDetail on snd_snid=sn_id where nvl(sn_custcode, ' ')<>' ' and snd_snid=" + snId + " and sn_custcode in (select cu_code from customer where cu_status='挂起')", String.class);
+                    dets = baseDao.getJdbcTemplate().queryForObject("select wm_concat(snd_pdno) from sendnotifydetail where snd_id=" + sndId + " and exists (select 1 from SendNotifyChange left join SendNotifyChangeDetail on sc_id=scd_scid where sc_sncode=snd_code and scd_snddetno=snd_pdno and sc_statuscode<>'AUDITED')", String.class);
                     if (dets != null) {
-                        return ApiResponse.failRsp("10078", requestId, "通知单客户已挂起,不能进行转出操作!" + dets);
+                        return ApiResponse.failRsp("10076", requestId, "存在待审批的通知变更单,不能进行转出操作!行号:" + dets);
                     }
-                }
-                dets = baseDao.getJdbcTemplate().queryForObject("select wm_concat(snd_pdno) from SendNotifyDetail where nvl(snd_statuscode, ' ')<>'AUDITED' and snd_snid=" + snId, String.class);
-                if (dets != null) {
-                    return ApiResponse.failRsp("10079", requestId, "明细行状态不等于已审核,不能进行转出操作!" + dets);
-                }
-            }
-            JSONArray detail = data.get("detail");
-            if (detail != null&&detail.size()>0&&snId>0) {
-                List<Map<Object, Object>> maps = new ArrayList<>();
-                for (int i = 0; i <detail.size(); i++) {
-                    JSONObject parseObject = JSON.parseObject(StringUtil.nvl(detail.get(i), "{}"));
-                    int sndId = Integer.parseInt(StringUtil.nvl(parseObject.get("sndId"), "0"));
-                    double tqty = Double.parseDouble(StringUtil.nvl(parseObject.get("tqty"), "0"));
-                    String prodCode = StringUtil.nvl(parseObject.get("prodCode"), "");
-                    String whCode = StringUtil.nvl(parseObject.get("whCode"), "");
-                    if (!baseDao.checkIf("SendNotifyDetail","snd_id="+sndId)){
-                        return ApiResponse.failRsp("10079", requestId, "明细行不存在,请核对!");
+                    if (baseDao.isDBSetting("Sale", "zeroOutWhenHung")) {
+                        dets = baseDao.getJdbcTemplate().queryForObject("select distinct wm_concat('通知单号:'||sn_code||'客户:'||sn_custcode) from sendnotify left join SendNotifyDetail on snd_snid=sn_id where nvl(sn_custcode, ' ')<>' ' and snd_id=" + sndId + " and sn_custcode in (select cu_code from customer where cu_status='挂起') and not exists (select 1 from saledetail where sd_code=snd_ordercode and sd_detno=snd_orderdetno and nvl(sd_price,0)=0)", String.class);
+                        if (dets != null) {
+                            return ApiResponse.failRsp("10077", requestId, "通知单客户已挂起,不能进行转出操作!" + dets);
+                        }
+                    } else {
+                        dets = baseDao.getJdbcTemplate().queryForObject("select distinct wm_concat('通知单号:'||sn_code||'客户:'||sn_custcode) from sendnotify left join SendNotifyDetail on snd_snid=sn_id where nvl(sn_custcode, ' ')<>' ' and snd_id=" + sndId + " and sn_custcode in (select cu_code from customer where cu_status='挂起')", String.class);
+                        if (dets != null) {
+                            return ApiResponse.failRsp("10078", requestId, "通知单客户已挂起,不能进行转出操作!" + dets);
+                        }
                     }
+                    dets = baseDao.getJdbcTemplate().queryForObject("select wm_concat(snd_pdno) from SendNotifyDetail where nvl(snd_statuscode, ' ')<>'AUDITED' and snd_id=" + sndId, String.class);
+                    if (dets != null) {
+                        return ApiResponse.failRsp("10079", requestId, "明细行状态不等于已审核,不能进行转出操作!" + dets);
+                    }
+                    double tqty = Double.parseDouble(StringUtil.nvl(map.get("tqty"), "0"));
+                    String prodCode = StringUtil.nvl(map.get("prodCode"), "");
+                    String whCode = StringUtil.nvl(map.get("whCode"), "");
                     if ("".equals(prodCode)){
                         return ApiResponse.failRsp("10063",requestId,"物料不能为空!");
                     }
@@ -1838,75 +1832,84 @@ public class MESServiceImpl implements MESService {
                     if (baseDao.checkIf("SendNotifyDetail","nvl(snd_yqty,0)+"+tqty+">nvl(snd_outqty,0) and snd_id="+sndId)){
                         return ApiResponse.failRsp("10063",requestId,"数量+已转出货数不能大于通知单数量!");
                     }
-                    Map<Object, Object> map = new HashMap<>();
-                    map.put("snd_id",sndId);
-                    map.put("snd_tqty",tqty);
-                    map.put("snd_warehousecode",wh[0]);
-                    map.put("snd_warehouse",wh[1]);
-                    maps.add(map);
+                    List<Map<String, Object>> mapList = baseDao.queryForList("select "+tqty+" snd_tqty,'"+wh[0]+"' snd_warehousecode,'"+wh[1]+"' snd_warehouse,sn_code,sn_custcode,snd_prodcode,sn_currency,sn_rate,sn_paymentscode,sn_shcustcode,sn_arcustcode,snd_id,sn_id from SendNotify left join SendNotifyDetail on sn_id=snd_snid left join Product on snd_prodcode=pr_code where snd_id=" + sndId);
+                    hashMaps.addAll(mapList);
                 }
-                Employee employee = baseDao.getJdbcTemplate().queryForObject("select * from employee where em_code=?", new BeanPropertyRowMapper<Employee>(Employee.class), "mes");
-                //生成出货单
-                Key key = transferRepository.transfer("ProdInOut!Sale", snId, employee);
+            }
+            List<Map<Object, Object>> mapList = BaseUtil.parseGridStoreToMaps(StringUtil.nvl(baseDao.changeKeyToLowerCase(hashMaps), "[{}]"));
+            Employee employee = baseDao.getJdbcTemplate().queryForObject("select * from employee where em_code=?", new BeanPropertyRowMapper<Employee>(Employee.class), "mes");
+            Map<Object, List<Map<Object, Object>>> groups = BaseUtil.groupsMap(mapList, new Object[] {"sn_custcode","sn_shcustcode","sn_currency","sn_arcustcode","sn_paymentscode"});
+            // 按客户分组的转入操作
+            Set<Object> mapSet = groups.keySet();
+            List<Map<Object, Object>> items;
+            for (Object s : mapSet) {
+                items = groups.get(s);
+                // 转入通知单主记录
+                Integer sn_id = baseDao.getFieldValue("SendNotifyDetail", "snd_snid", "snd_id=" + items.get(0).get("snd_id"),
+                        Integer.class);
+                Key key = transferRepository.transfer("ProdInOut!Sale", sn_id, employee);
                 if (key != null) {
+                    keys.add(key);
                     int pi_id = key.getId();
-                    // 转入出货单明细
-                    transferRepository.transfer("ProdInOut!Sale", maps, key, employee);
+                    // 转入明细
+                    transferRepository.transfer("ProdInOut!Sale", items, key, employee);
                     // 地址
                     baseDao.execute(
                             "update ProdInOut set pi_address=(select cu_add1 from customer where pi_cardcode=cu_code) where pi_id=? and nvl(pi_address,' ')=' '",
                             pi_id);
-                    baseDao.execute(
-                            "update ProdIODetail set (pd_whcode,pd_whname)=(select pr_whcode,wh_description from product left join warehouse on pr_whcode=wh_code where pd_prodcode=pr_code) where pd_piid=? and nvl(pd_whcode,' ')=' '",
-                            pi_id);
-                    baseDao.execute(
-                            "update prodinout set (pi_whcode,pi_whname)=(select pd_whcode,pd_whname from prodiodetail where pd_piid=pi_id and nvl(pd_whcode,' ')<>' ' and rownum<2) where nvl(pi_whcode,' ')=' ' and pi_id=?",
-                            pi_id);
                     baseDao.execute("update prodinout set (pi_purposename,pi_expresscode,pi_fax)=(select max(ca_person),max(ca_phone),max(ca_fax) from CustomerAddress left join customer on ca_cuid=cu_id where cu_code=pi_cardcode and ca_address=pi_address)  where pi_id="
                             + pi_id);
                     baseDao.execute(
-                            "update ProdInOut set pi_rate=nvl((select cm_crrate from currencysmonth where cm_yearmonth=to_char(pi_date,'yyyymm') and cm_crname=pi_currency),1) where pi_id=? and nvl(pi_currency,' ')<>' '",
+                            "update prodinout set (pi_whcode,pi_whname)=(select pd_whcode,pd_whname from prodiodetail where pd_piid=pi_id and nvl(pd_whcode,' ')<>' ' and rownum<2) where nvl(pi_whcode,' ')=' ' and pi_id=?",
                             pi_id);
                     baseDao.execute(
-                            "update ProdInOut set pi_total=(SELECT round(sum(nvl(pd_sendprice,0)*(nvl(pd_inqty,0)+nvl(pd_outqty,0))),2) FROM ProdIODetail WHERE pd_piid=pi_id) where pi_id=?",
+                            "update ProdIODetail set pd_taxtotal=round(pd_sendprice*(nvl(pd_inqty,0)+nvl(pd_outqty,0)),2), pd_nettotal=round(pd_netprice*(nvl(pd_inqty,0)+nvl(pd_outqty,0)),2) WHERE pd_piid=?",
                             pi_id);
+                    baseDao.execute("update ProdIODetail set pd_ordertotal=round(pd_outqty*pd_sendprice,2) where pd_piid=?", pi_id);
                     baseDao.updateByCondition(
                             "ProdIODetail",
                             "pd_netprice=round(pd_sendprice/(1+pd_taxrate/100),8),pd_nettotal=round(pd_sendprice*pd_outqty/(1+nvl(pd_taxrate,0)/100),2)",
                             "pd_piid=" + pi_id);
                     baseDao.execute(
-                            "update ProdIODetail set pd_taxtotal=round(pd_sendprice*(nvl(pd_inqty,0)+nvl(pd_outqty,0)),2), pd_nettotal=round(pd_netprice*(nvl(pd_inqty,0)+nvl(pd_outqty,0)),2) WHERE pd_piid=?",
+                            "update ProdInOut set pi_total=(SELECT round(sum(nvl(pd_sendprice,0)*(nvl(pd_inqty,0)+nvl(pd_outqty,0))),2) FROM ProdIODetail WHERE pd_piid=pi_id) where pi_id=?",
                             pi_id);
                     baseDao.updateByCondition("ProdInOut", "pi_totalupper=L2U(nvl(pi_total,0))", "pi_id=" + pi_id);
-                    // 修改出货通知单状态
-                    String statuscode = null, status = null;
-                    int count = baseDao.getCountByCondition("SendNotifyDetail", "snd_snid=" + snId);
-                    int yCount = baseDao.getCountByCondition("SendNotifyDetail", "snd_snid=" + snId + " and nvl(snd_yqty,0)=nvl(snd_outqty,0) and nvl(snd_yqty,0)>=0");
-                    int xCount = baseDao.getCountByCondition("SendNotifyDetail", "snd_snid=" + snId + " and nvl(snd_yqty,0)=0");
-                    statuscode = "PARTOUT";
-                    status = "部分出库";
-                    if (xCount == count) {
-                        statuscode = "";
-                        status = "";
-                    }
-                    if (yCount == count) {
-                        statuscode = "TURNOUT";
-                        status = "已出库";
-                    }
-                    baseDao.updateByCondition("SendNotify", "SN_SENDSTATUSCODE='" + statuscode + "',SN_SENDSTATUS='" + status + "'", "sn_id=" + snId);
-                    //过账出货单
-                    String s = postProdInOut(pi_id, "ProdInOut!Sale", employee);
-                    if (s!=null&&!"".equals(s)){
-                        return ApiResponse.successRsp("0", requestId, "出货单:" + key.getCode() + ",过账失败,请在ERP重新过账!");
-                    }
-                    // 记录操作
-                    baseDao.execute("INSERT INTO MessageLog(ml_id,ml_date,ml_man,ml_content,ml_result,ml_search) VALUES (MessageLog_seq.nextval,sysdate,'mes','确认操作','确认成功','SendNotify|sn_id=" + snId + "')");
                     return ApiResponse.successRsp("0", requestId, "出货单:" + key.getCode() + ",请在ERP查看!");
                 } else
                     return ApiResponse.failRsp("10080", requestId, "生成失败!");
+            }
+            // 修改出货通知单状态
+            Map<Object, List<Map<Object, Object>>> listMap = BaseUtil.groupsMap(mapList, new Object[]{"sn_id"});
+            // 按客户分组的转入操作
+            Set<Object> mSet = listMap.keySet();
+            for (Object obj : mSet) {
+                String statuscode = null, status = null;
+                int count = baseDao.getCountByCondition("SendNotifyDetail", "snd_snid=" + obj);
+                int yCount = baseDao.getCountByCondition("SendNotifyDetail", "snd_snid=" + obj + " and nvl(snd_yqty,0)=nvl(snd_outqty,0) and nvl(snd_yqty,0)>=0");
+                int xCount = baseDao.getCountByCondition("SendNotifyDetail", "snd_snid=" + obj + " and nvl(snd_yqty,0)=0");
+                statuscode = "PARTOUT";
+                status = "部分出库";
+                if (xCount == count) {
+                    statuscode = "";
+                    status = "";
+                }
+                if (yCount == count) {
+                    statuscode = "TURNOUT";
+                    status = "已出库";
+                }
+                baseDao.updateByCondition("SendNotify", "SN_SENDSTATUSCODE='" + statuscode + "',SN_SENDSTATUS='" + status + "'", "sn_id=" + obj);
+            }
+            if (keys!=null&&!keys.isEmpty()) {
+                String code="";
+                for (Key key:keys) {
+                    //过账出货单
+                    String s = postProdInOut(key.getId(), "ProdInOut!Sale", employee);
+                    code=code+key.getCode()+",";
+                }
+                return ApiResponse.successRsp("0", requestId, "出货单:" + code + ",请在ERP查看!");
             }else
-                return ApiResponse.failRsp("10081",requestId,"参数异常!");
-        }else
+                return ApiResponse.failRsp("10082",requestId,"生成失败!");
+        } else
             return ApiResponse.failRsp("10081",requestId,"参数异常!");
     }
 
@@ -1941,6 +1944,16 @@ public class MESServiceImpl implements MESService {
         }
         return jsonObject;
     }
+    private List<Map<Object, Object>> getJsonsData(HttpServletRequest request){
+        try {
+            String data = PSHttpUtils.readRaw(request.getInputStream());
+            return BaseUtil.parseGridStoreToMaps(data);
+        } catch (IOException e) {
+            logger.info("参数解析异常信息:"+e.getMessage());
+            e.printStackTrace();
+        }
+        return null;
+    }
 
     private ApiResult<String> checkMESCode(String requestId,String mesNo,String piclass){
         if ("".equals(mesNo)){

+ 28 - 0
src/main/java/com/uas/eis/utils/BaseUtil.java

@@ -177,5 +177,33 @@ public class BaseUtil {
 	public static String parseGridStore2Str(List<Map<String, Object>> list) {
 		return JacksonUtil.toJsonArray(list);
 	}
+
+	public static Map<Object, List<Map<Object, Object>>> groupsMap(List<Map<Object, Object>> maps, Object[] objects) {
+		Map<Object, List<Map<Object, Object>>> set = new HashMap<Object, List<Map<Object, Object>>>();
+		List<Map<Object, Object>> list = null;
+		String keyValue = null;
+		Object value = null;
+		for (Map<Object, Object> map : maps) {
+			keyValue = null;
+			for (Object field : objects) {
+				if (keyValue != null) {
+					keyValue += "#";
+				} else {
+					keyValue = "";
+				}
+				value = map.get(field);
+				keyValue += value == null ? "" : value;
+			}
+			// Object key = map.get(groupField);
+			if (keyValue != null && !keyValue.equals("") && set.containsKey(keyValue)) {
+				list = set.get(keyValue);
+			} else {
+				list = new ArrayList<Map<Object, Object>>();
+			}
+			list.add(map);
+			set.put(keyValue, list);
+		}
+		return set;
+	}
 	
 }

+ 1 - 1
src/main/resources/api_sign_key_mapping.properties

@@ -11,4 +11,4 @@ syncCustomer=webEditCustomer
 syncMakeMaterialCheck=checkProdBomItem
 updateChangeOrderByErp=updateChangeOrderByErp
 syncMakeScrap=updateScrappedItemByErp
-syncSendNotify=syncSendNotify
+syncSendNotify=updateErpShipment