|
|
@@ -33,11 +33,13 @@ public class ERPServiceImpl implements ERPService {
|
|
|
retMap.put("success",true);
|
|
|
logger.info("createSticker-Begin:master {} id {}",master,id);
|
|
|
SpObserver.putSp(master);
|
|
|
- SqlRowList docLoist = baseDao.queryForRowSet("select CD_CPN matnr,min(CD_DC) ztcnno,pr_capacity zzxsmount,pr_zxbzs zbzsmount,sum(CD_QTY) zmount " +
|
|
|
+ SqlRowList docLoist = baseDao.queryForRowSet("select CD_CPN matnr,min(CD_DC) ztcnno,pr_capacity zzbsmount,pr_zxbzs zzxsmount,pr_zxbzs zbzsmount" +
|
|
|
+ " ,sum(CD_QTY) zmount,cd_wflag zwidth,cd_remark zremark " +
|
|
|
"from CatlDocDetail left join product on pr_code = CD_PRCODE " +
|
|
|
- "where cd_caid = ? and CD_PANID is null group by CD_CPN,pr_capacity,pr_zxbzs order by min(cd_detno)",id);
|
|
|
+ "where cd_caid = ? and CD_PANID is null and nvl(pr_capacity,0)>0 " +
|
|
|
+ "group by CD_CPN,pr_capacity,pr_zxbzs,cd_wflag,cd_remark order by min(cd_detno)",id);
|
|
|
if(!docLoist.hasNext()){
|
|
|
- System.out.println("no docLoist!");
|
|
|
+// System.out.println("no docLoist!");
|
|
|
retMap.put("success",false);
|
|
|
retMap.put("message","没有需要对接的明细.");
|
|
|
logger.info("createSticker-F:master {} id {} no docLoist!",master,id);
|
|
|
@@ -63,18 +65,22 @@ public class ERPServiceImpl implements ERPService {
|
|
|
StringBuffer errMsg = new StringBuffer();
|
|
|
for (Map<String,Object> docMap: docLoist.getResultList()) {
|
|
|
try {
|
|
|
+ // CD_CPN,pr_capacity,pr_zxbzs,cd_wflag,cd_remark
|
|
|
String matnr = String.valueOf(docMap.get("matnr"));
|
|
|
+ String zwidth = StringUtil.nvl(docMap.get("zwidth"),"");
|
|
|
+ String zremark = StringUtil.nvl(docMap.get("zremark"),"");
|
|
|
+
|
|
|
Map<String,Object> paraMap=new HashMap<>();
|
|
|
paraMap.put("matnr",matnr);//物料号:客户料号
|
|
|
paraMap.put("ztcnno",docMap.get("ztcnno"));//制造日期: 取最小DC
|
|
|
paraMap.put("zzstz",matnr);//供应商批次: 用型号作为虚拟批次
|
|
|
// paraMap.put("zeiar",docMap.get("zeiar"));//版本
|
|
|
-// paraMap.put("zwidth",docMap.get("zwidth"));//宽度
|
|
|
+ paraMap.put("zwidth",zwidth);//宽度
|
|
|
paraMap.put("zmount",docMap.get("zmount"));//本次生产总数量
|
|
|
-// paraMap.put("zzbsmount",docMap.get("zzbsmount"));//栈板容量
|
|
|
+ paraMap.put("zzbsmount",docMap.get("zzbsmount"));//栈板容量
|
|
|
paraMap.put("zzxsmount",docMap.get("zzxsmount"));//纸箱容量
|
|
|
paraMap.put("zbzsmount",docMap.get("zbzsmount"));//包装袋容量
|
|
|
-// paraMap.put("zremark",docMap.get("zremark"));//备注
|
|
|
+ paraMap.put("zremark",zremark);//备注
|
|
|
paraMap.put("partner",vendcode);//供应商编码 固定值
|
|
|
HttpUtil.Response response = HttpUtil.doPost(url+action, JacksonUtil.toJson(paraMap), deipaaskeyauth,deipaasjwt);
|
|
|
if (response.getStatusCode() == HttpStatus.OK.value()){
|
|
|
@@ -84,28 +90,64 @@ public class ERPServiceImpl implements ERPService {
|
|
|
Map<String,Object> resData = JacksonUtil.fromJson(res);
|
|
|
if("S".equals(String.valueOf(resData.get("e_type")))){
|
|
|
List<Map<String,Object>> outdata = (List) resData.get("outdata");
|
|
|
-// List<Map<String,Object>> outdata = JacksonUtil.fromJsonArray(resData.get("outdata").toString());
|
|
|
- System.out.println("outdata.size:"+outdata.size());
|
|
|
- List<Map<String,Object>> idList = outdata.stream().filter(od->{
|
|
|
- return "1 ".equals(od.get("levels"));
|
|
|
+// System.out.println("outdata.size:"+outdata.size());
|
|
|
+ //栈ID
|
|
|
+// List<Map<String,Object>> palletIdList = outdata.stream().filter(od->{
|
|
|
+// return (Double.valueOf(od.get("levels").toString().trim()) == 0);
|
|
|
+// }).collect(Collectors.toList());
|
|
|
+ //箱ID
|
|
|
+ List<Map<String,Object>> boxIdList = outdata.stream().filter(od->{
|
|
|
+ return (Double.valueOf(od.get("levels").toString().trim()) == 1);
|
|
|
+ }).collect(Collectors.toList());
|
|
|
+ //袋ID
|
|
|
+ List<Map<String,Object>> panIdList = outdata.stream().filter(od->{
|
|
|
+ return (Double.valueOf(od.get("levels").toString().trim()) == 2);
|
|
|
}).collect(Collectors.toList());
|
|
|
- //更新条码ID、箱ID
|
|
|
+ //更新箱ID、袋ID
|
|
|
List<String> sqls = new ArrayList<>();
|
|
|
- SqlRowList updateList = baseDao.queryForRowSet("select cd_id,cd_lotno,cd_dc,nvl(cd_ed,to_char(to_date(cd_dc,'yyyymmdd')+365,'yyyymmdd')) cd_ed from CatlDocDetail where cd_caid = ? and CD_CPN = ? and CD_PANID is null order by cd_detno",id,matnr);
|
|
|
+ // CD_CPN,pr_capacity,pr_zxbzs,cd_wflag,cd_remark
|
|
|
+ // matnr,zwidth,zremark
|
|
|
+ SqlRowList updateList = baseDao.queryForRowSet("select cd_id,cd_lotno,cd_dc,nvl(cd_ed,to_char(to_date(cd_dc,'yyyymmdd')+365,'yyyymmdd')) cd_ed from CatlDocDetail " +
|
|
|
+ " where cd_caid = "+id+" and CD_PANID is null and CD_CPN = '"+matnr+"' " +
|
|
|
+ " and nvl(cd_wflag,' ') = '"+StringUtil.nvl(zwidth," ")+"'" +
|
|
|
+ " and nvl(cd_remark,' ') = '"+StringUtil.nvl(zremark," ")+"'" +
|
|
|
+ " order by cd_detno");
|
|
|
List<Map<String,Object>> updateStickerList = new ArrayList<>();
|
|
|
- if(idList.size() == updateList.getResultList().size()){
|
|
|
+ if(panIdList.size() == updateList.getResultList().size()){
|
|
|
for (int i = 0; i < updateList.getResultList().size(); i++) {
|
|
|
Map<String,Object> updateMap = updateList.getResultList().get(i);
|
|
|
- Map<String,Object> idMap = idList.get(i);
|
|
|
- sqls.add("update CatlDocDetail set CD_PANID='"+idMap.get("zalt_id")+"',CD_BOXID='"+idMap.get("zalt_id_upper")+"' where cd_id = "+updateMap.get("cd_id"));
|
|
|
- Map<String,Object> updateStickerMap = new HashMap<>();
|
|
|
- updateStickerMap.put("matnr",matnr);//物料号
|
|
|
- updateStickerMap.put("zalt_id",idMap.get("zalt_id"));//贴纸ID
|
|
|
- updateStickerMap.put("prtbatchid",updateMap.get("cd_lotno"));//供应商批次
|
|
|
- updateStickerMap.put("manufacturing_date",updateMap.get("cd_dc"));//生产日期
|
|
|
- updateStickerMap.put("atlyx",updateMap.get("cd_ed"));//有效日期
|
|
|
- updateStickerList.add(updateStickerMap);
|
|
|
+ Map<String,Object> idMap = panIdList.get(i);
|
|
|
+ String panId = idMap.get("zalt_id").toString();
|
|
|
+ String boxId = idMap.get("zalt_id_upper").toString();
|
|
|
+ //获取栈ID
|
|
|
+ String palletId = "";
|
|
|
+ Optional<Map<String,Object>> boxMsg = boxIdList.stream()
|
|
|
+ .filter(bMap -> bMap.get("zalt_id").equals(boxId))
|
|
|
+ .findFirst();
|
|
|
+ if(boxMsg.isPresent()&&!boxMsg.get().isEmpty()){
|
|
|
+ palletId = boxMsg.get().get("zalt_id_upper").toString();
|
|
|
+ }
|
|
|
+ sqls.add("update CatlDocDetail set cd_palletid='"+StringUtil.nvl(palletId,"")+"' ,CD_PANID='"+panId+"',CD_BOXID='"+boxId+"'" +
|
|
|
+ ",cd_batchid='"+idMap.get("batch_id")+"',cd_wbs='"+idMap.get("wbs")+"' " +
|
|
|
+ "where cd_id = "+updateMap.get("cd_id"));
|
|
|
+ if(!updateMap.get("cd_lotno").equals(idMap.get("prtbatchid"))){
|
|
|
+ Map<String,Object> updatePanMap = new HashMap<>();
|
|
|
+ updatePanMap.put("matnr",matnr);//物料号
|
|
|
+ updatePanMap.put("zalt_id",panId);//贴纸ID
|
|
|
+ updatePanMap.put("prtbatchid",updateMap.get("cd_lotno"));//供应商批次
|
|
|
+ updatePanMap.put("manufacturing_date",updateMap.get("cd_dc"));//生产日期
|
|
|
+ updatePanMap.put("atlyx",updateMap.get("cd_ed"));//有效日期
|
|
|
+ updateStickerList.add(updatePanMap);
|
|
|
+ Map<String,Object> updateBoxMap = new HashMap<>();
|
|
|
+ updateBoxMap.put("matnr",matnr);//物料号
|
|
|
+ updateBoxMap.put("zalt_id",boxId);//贴纸ID
|
|
|
+ updateBoxMap.put("prtbatchid",updateMap.get("cd_lotno"));//供应商批次
|
|
|
+ updateBoxMap.put("manufacturing_date",updateMap.get("cd_dc"));//生产日期
|
|
|
+ updateBoxMap.put("atlyx",updateMap.get("cd_ed"));//有效日期
|
|
|
+ updateStickerList.add(updateBoxMap);
|
|
|
+ }
|
|
|
}
|
|
|
+ // 更新栈ID、箱ID、袋ID
|
|
|
if(sqls.size()>0){
|
|
|
baseDao.execute(sqls);
|
|
|
//第二个接口 更新供应商批次
|
|
|
@@ -115,7 +157,7 @@ public class ERPServiceImpl implements ERPService {
|
|
|
}
|
|
|
}
|
|
|
}else {
|
|
|
- errMsg.append("条码创建数与实际不一致,型号:"+matnr).append("创建数:"+idList.size()+",待更新数量:"+updateList.getResultList().size()).append("</br>");
|
|
|
+ errMsg.append("条码创建数与实际不一致,型号:"+matnr).append("创建数:"+panIdList.size()+",待更新数量:"+updateList.getResultList().size()).append("</br>");
|
|
|
}
|
|
|
}else {
|
|
|
if(StringUtil.hasText(resData.get("e_message"))){
|
|
|
@@ -141,7 +183,7 @@ public class ERPServiceImpl implements ERPService {
|
|
|
}
|
|
|
}
|
|
|
if(errMsg.length()>0){
|
|
|
- System.out.println("errMsg:"+errMsg.toString());
|
|
|
+// System.out.println("errMsg:"+errMsg.toString());
|
|
|
retMap.put("success",false);
|
|
|
retMap.put("message","对接失败:</br>"+errMsg.toString());
|
|
|
}else {
|
|
|
@@ -195,6 +237,9 @@ public class ERPServiceImpl implements ERPService {
|
|
|
public Map<String, Object> updateStickerByList(String master, Integer id,Map<String, String> map,List<Map<String,Object>> updateLists) {
|
|
|
Map<String, Object> retMap = new HashMap<>();
|
|
|
retMap.put("success",true);
|
|
|
+ if(CollectionUtil.isEmpty(updateLists)){
|
|
|
+ return retMap;
|
|
|
+ }
|
|
|
String url = map.get("url");
|
|
|
String deipaaskeyauth = map.get("deipaaskeyauth");
|
|
|
String appKey = map.get("appKey");
|