|
|
@@ -154,25 +154,39 @@ public class ERPServiceImpl implements ERPService {
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
- public ApiResult<String> syncProdInOutMakeGive(String data) {
|
|
|
+ public Map<String, Object> syncProdInOutMakeGive(String data) {
|
|
|
+ Map<String, Object> hashMap = new HashMap<>();
|
|
|
try {
|
|
|
Map<Object, Object> store = BaseUtil.parseFormStoreToMap(data);
|
|
|
String mesUser = tokenConfig.get("mesUser");
|
|
|
String mesPwd = MD5Util.encodeByMD5(tokenConfig.get("mesPwd"));
|
|
|
int flag = Integer.parseInt(StringUtil.nvl(store.get("flag"), "-1"));
|
|
|
- ProdInOutMakeGive prodInOutMakeGive = baseDao.getJdbcTemplate().queryForObject("select '"+mesUser+"' mesUser,'"+mesPwd+"' mesPwd,(select wm_concat(distinct pd_ordercode) from prodiodetail where pd_piid=pi_id) maCodes,pi_inoutno from prodinout where pi_id=?",
|
|
|
- new BeanPropertyRowMapper<ProdInOutMakeGive>(ProdInOutMakeGive.class), store.get("pi_id"));
|
|
|
-
|
|
|
- List<ProdInOutMakeGiveDetail> prodInOutMakeGiveDetails = baseDao.query("select pd_ordercode,mm_id,pd_prodcode,pd_outqty," +
|
|
|
- "'BYT' pi_cop,pi_recordman,to_char(pi_recorddate,'yyyy-MM-dd HH24:mi:ss') pi_recorddate,pi_updateman," +
|
|
|
- "case when pi_updatedate is not null then to_char(pi_updatedate,'yyyy-MM-dd HH24:mi:ss') else null end pi_updatedate,"+flag+" flag " +
|
|
|
- "from prodiodetail left join prodinout on pd_piid=pi_id left join product on pd_prodcode=pr_code left join customer on cu_shortname=pr_kh_user left join MakeMaterial on pd_ordercode=mm_code and pd_orderdetno=mm_detno where nvl(pd_outqty,0)>nvl((select sum(ba_remain) from batch where nvl(ba_macode,' ')=pd_ordercode and pd_prodcode=ba_prodcode and ba_whcode in (select wh_code from Warehouse where wh_statuscode='AUDITED' and wh_description like '%线边仓%') and nvl(ba_remain,0)>0),0) and pi_id=" + store.get("pi_id"), ProdInOutMakeGiveDetail.class);
|
|
|
- prodInOutMakeGive.setDetail(prodInOutMakeGiveDetails);
|
|
|
- return syncMES(JSON.toJSONString(prodInOutMakeGive, SerializerFeature.WriteMapNullValue).replace("null","\"\""),tokenConfig.get("syncProdInOutMakeGive"));
|
|
|
+ int piId = Integer.parseInt(StringUtil.nvl(store.get("pi_id"), "0"));
|
|
|
+ int count = baseDao.getCount("select count(1) from prodinout where pi_id="+piId);
|
|
|
+ if (count>0) {
|
|
|
+ ProdInOutMakeGive prodInOutMakeGive = baseDao.getJdbcTemplate().queryForObject("select '" + mesUser + "' mesUser,'" + mesPwd + "' mesPwd,(select wm_concat(distinct pd_ordercode) from prodiodetail where pd_piid=pi_id) prodNo,pi_inoutno,pi_id,(select wm_concat(distinct cd_varchar50_1) from customtable left join customtabledetail on cd_ctid=ct_id where ct_caller='MESWarehouse' and cd_varchar50_3=pi_whcode) pi_whcode,pi_departmentname,pi_recordman,pi_remark," + flag + " flag from prodinout where pi_id=?",
|
|
|
+ new BeanPropertyRowMapper<ProdInOutMakeGive>(ProdInOutMakeGive.class), piId);
|
|
|
+ List<ProdInOutMakeGiveDetail> prodInOutMakeGiveDetails = baseDao.query("select pd_prodcode,pd_outqty,pd_id,pd_orderdetno from prodiodetail where pd_piid=" + piId, ProdInOutMakeGiveDetail.class);
|
|
|
+ prodInOutMakeGive.setDetail(prodInOutMakeGiveDetails);
|
|
|
+ Map<String, Object> map = syncMESCheckBomItems(JSON.toJSONString(prodInOutMakeGive, SerializerFeature.WriteMapNullValue).replace("null", "\"\""), tokenConfig.get("syncInOutMakeGive"));
|
|
|
+ hashMap.put("code", -1);
|
|
|
+ hashMap.put("msg", "MES异常,请联系MES处理!");
|
|
|
+ if (map != null&&!map.isEmpty()) {
|
|
|
+ int code = Integer.parseInt(StringUtil.nvl(map.get("code"), "-1"));
|
|
|
+ hashMap.put("code", code);
|
|
|
+ hashMap.put("msg", map.get("msg"));
|
|
|
+ }
|
|
|
+ }else {
|
|
|
+ hashMap.put("code", -1);
|
|
|
+ hashMap.put("msg", "參數异常,请核对处理!");
|
|
|
+ }
|
|
|
+ return hashMap;
|
|
|
}catch (Exception e){
|
|
|
logger.error("同步补料单异常信息:"+e.getMessage());
|
|
|
+ hashMap.put("code", -1);
|
|
|
+ hashMap.put("msg",StringUtil.nvl(e.getMessage(),"接口返回空,请联系MES处理!").substring(0,200));
|
|
|
e.printStackTrace();
|
|
|
- return ApiResponse.failRsp("104",e.getMessage());
|
|
|
+ return hashMap;
|
|
|
}
|
|
|
}
|
|
|
|