Browse Source

工单BOM新增修改

koul 4 years ago
parent
commit
eb0c74144c

+ 13 - 6
src/main/java/com/uas/eis/service/Impl/MESServiceImpl.java

@@ -499,6 +499,7 @@ public class MESServiceImpl implements MESService {
         Object[] warehouses=null;
         Object[] warehouses2=null;
         int detno=1;
+        int det=1;
         for (int i = 0; i <array.size(); i++) {
             JSONObject object = JSON.parseObject(StringUtil.nvl(array.get(i), "{}"));
             Map<Object, Object> map = JSONUtil.toMap(StringUtil.valueOf(object.get("FItemID")));
@@ -547,6 +548,7 @@ public class MESServiceImpl implements MESService {
                         "pd_outqty,pd_whcode,pd_whname,pd_inwhcode,pd_inwhname,pd_macode,pd_madetno) " +
                         "values (PRODIODETAIL_SEQ.nextval," + bcpiid + ",'" + bccode + "','"+bcpiclass+"'," + detno + ",'" + itemNo +
                         "'," + qty + ",'" + warehouses2[0] + "','" + warehouses2[1] + "','" + warehouses[0] + "','" + warehouses[1] + "','"+ficmoBillNo+"',"+mmdetno+")");
+                detno++;
             }
             int count1 = baseDao.getCount("select count(1) from MakeMaterial where mm_prodcode='" + itemNo + "' and mm_id in (" + lineId + ")");
             if (count1>0) {
@@ -570,11 +572,13 @@ public class MESServiceImpl implements MESService {
                     }
                 }
             }
-            sqls.add("insert into prodiodetail (pd_id,pd_piid,pd_inoutno,pd_piclass,pd_pdno,pd_prodcode," +
-                    "pd_outqty,pd_whcode,pd_whname,pd_ordercode,pd_orderdetno,pd_macode,pd_madetno) " +
-                    "values (PRODIODETAIL_SEQ.nextval," + llpiid + ",'" + llcode + "','"+llpiclass+"'," + detno + ",'" + itemNo +
-                    "'," + qty + ",'" + warehouses[0] + "','" + warehouses[1] + "','"+ficmoBillNo+"',"+mmdetno+ ",'"+ficmoBillNo+"',"+mmdetno+")");
-            detno++;
+            if (qty>0) {
+                sqls.add("insert into prodiodetail (pd_id,pd_piid,pd_inoutno,pd_piclass,pd_pdno,pd_prodcode," +
+                        "pd_outqty,pd_whcode,pd_whname,pd_ordercode,pd_orderdetno,pd_macode,pd_madetno) " +
+                        "values (PRODIODETAIL_SEQ.nextval," + llpiid + ",'" + llcode + "','" + llpiclass + "'," + det + ",'" + itemNo +
+                        "'," + qty + ",'" + warehouses[0] + "','" + warehouses[1] + "','" + ficmoBillNo + "'," + mmdetno + ",'" + ficmoBillNo + "'," + mmdetno + ")");
+                det++;
+            }
         }
         if (warehouses2!=null){
             sqls.add("update prodinout set pi_whcode='"+warehouses2[0]+"',pi_whname='"+warehouses2[1]+"' where " + "pi_id="+bcpiid);
@@ -582,8 +586,11 @@ public class MESServiceImpl implements MESService {
         if (warehouses!=null){
             sqls.add("update prodinout set pi_purpose='"+warehouses[0]+"',pi_purposename='"+warehouses[1]+"' where pi_id="+bcpiid);
         }
-
         baseDao.execute(sqls);
+        int count = baseDao.getCount("select count(1) from prodiodetail where pi_id=" + llpiid);
+        if (count<=0){
+            baseDao.deleteById("prodinout","pi_id",llpiid);
+        }
         Employee employee = baseDao.getJdbcTemplate().queryForObject("select * from employee where em_code=?",
                 new BeanPropertyRowMapper<Employee>(Employee.class), "mes");
         String s = postProdInOut(bcpiid, bccaller, employee);

+ 29 - 7
src/main/java/com/uas/eis/service/Impl/ScheduleTaskServiceImpl.java

@@ -111,8 +111,20 @@ public class ScheduleTaskServiceImpl implements ScheduleTaskService {
                     if (code == 0) {
                         baseDao.updateByCondition("mes_makematerial", "status='D'", "status='W' and id=" + rs.getInt("id"));
                         } else {
-                            baseDao.updateByCondition("mes_makematerial", "status='F'", "status='W' and id=" + rs.getInt("id"));
-                            baseDao.execute("insert into meserrorlog (mel_id,mel_url,mel_error,mel_indate,mel_djcode,mel_djdetno,mel_type) values(MESERRORLOG_SEQ.NEXTVAL,'" + tokenConfig.get("syncMakeBaseDetail") + "','" + StringUtil.nvl(map.get("msg"), "") + "',sysdate,'" + rs.getGeneralString("mm_code") + "'," + rs.getInt("mm_detno") + ",'工单BOM')");
+                            baseDao.updateByCondition("mes_makematerial", "action='N',flag=0","status='W' and id=" + rs.getInt("id"));
+                            makeMaterial.setFlag(0);
+                            Map<String, Object> map1 = syncMES(JSON.toJSONString(makeMaterial,
+                                    SerializerFeature.WriteMapNullValue).replace("null", "\"\""), tokenConfig.get("syncMakeBaseDetail"));
+                            if (map1 != null) {
+                                int code1 = Integer.parseInt(StringUtil.nvl(map1.get("code"), "-1"));
+                                if (code1 == 0) {
+                                    baseDao.updateByCondition("mes_makematerial", "status='D'", "status='W' and id=" + rs.getInt("id"));
+                                }else {
+                                    baseDao.updateByCondition("mes_makematerial", "status='F'", "status='W' and id=" + rs.getInt("id"));
+                                    baseDao.execute("insert into meserrorlog (mel_id,mel_url,mel_error,mel_indate,mel_djcode,mel_djdetno,mel_type) values(MESERRORLOG_SEQ.NEXTVAL,'" + tokenConfig.get("syncMakeBaseDetail") + "','" + StringUtil.nvl(map.get("msg"), "") + "',sysdate,'" + rs.getGeneralString("mm_code") + "'," + rs.getInt("mm_detno") + ",'工单BOM')");
+                                }
+                            }
+
                         }
                     }
                 }
@@ -133,13 +145,23 @@ public class ScheduleTaskServiceImpl implements ScheduleTaskService {
                     Map<String, Object> map = syncMES(JSON.toJSONString(makeMaterial,
                             SerializerFeature.WriteMapNullValue).replace("null", "\"\""), tokenConfig.get("syncMakeBaseDetail"));
                     if (map != null) {
-                        int code1 = Integer.parseInt(StringUtil.nvl(map.get("code"), "-1"));
-                        if (code1 == 0) {
+                        int code = Integer.parseInt(StringUtil.nvl(map.get("code"), "-1"));
+                        if (code == 0) {
                             baseDao.updateByCondition("mes_makematerialreplace", "status='D'", "status='W' and id=" + rs.getInt("id"));
-
                         } else {
-                            baseDao.updateByCondition("mes_makematerialreplace", "status='F'", "status='W' and id=" + rs.getInt("id"));
-                            baseDao.execute("insert into meserrorlog (mel_id,mel_url,mel_error,mel_indate,mel_djcode,mel_djdetno,mel_type) values(MESERRORLOG_SEQ.NEXTVAL,'" + tokenConfig.get("syncMakeBaseDetail") + "','" + StringUtil.nvl(map.get("msg"), "") + "',sysdate,'" + rs.getGeneralString("mp_mmcode") + "'," + rs.getInt("mp_mmdetno") + ",'工单BOM替代料')");
+                            baseDao.updateByCondition("mes_makematerialreplace", "action='N',flag=0","status='W' and id=" + rs.getInt("id"));
+                            makeMaterial.setFlag(0);
+                            Map<String, Object> map1 = syncMES(JSON.toJSONString(makeMaterial,
+                                    SerializerFeature.WriteMapNullValue).replace("null", "\"\""), tokenConfig.get("syncMakeBaseDetail"));
+                            if (map1 != null) {
+                                int code1 = Integer.parseInt(StringUtil.nvl(map1.get("code"), "-1"));
+                                if (code1 == 0) {
+                                    baseDao.updateByCondition("mes_makematerialreplace", "status='D'", "status='W' and id=" + rs.getInt("id"));
+                                } else {
+                                    baseDao.updateByCondition("mes_makematerialreplace", "status='F'", "status='W' and id=" + rs.getInt("id"));
+                                    baseDao.execute("insert into meserrorlog (mel_id,mel_url,mel_error,mel_indate,mel_djcode,mel_djdetno,mel_type) values(MESERRORLOG_SEQ.NEXTVAL,'" + tokenConfig.get("syncMakeBaseDetail") + "','" + StringUtil.nvl(map.get("msg"), "") + "',sysdate,'" + rs.getGeneralString("mp_mmcode") + "'," + rs.getInt("mp_mmdetno") + ",'工单BOM替代料')");
+                                }
+                            }
                         }
                     }
                 }