Browse Source

生产报废单增加特殊逻辑

koul 3 năm trước cách đây
mục cha
commit
0bb0aa027b

+ 28 - 7
src/main/java/com/uas/eis/service/Impl/MESServiceImpl.java

@@ -444,6 +444,14 @@ public class MESServiceImpl implements MESService {
                 Object co = baseDao.getFieldDataByCondition("MakeScrap", "ms_code", "ms_class='" + msclass + "' and ms_mescode='" + fSelBillNo + "'");
                 Object co = baseDao.getFieldDataByCondition("MakeScrap", "ms_code", "ms_class='" + msclass + "' and ms_mescode='" + fSelBillNo + "'");
                 return ApiResponse.failRsp("10024",requestId,"MES单号:"+fSelBillNo+"已存在,请在ERP查看"+msclass+",单据编号:"+co);
                 return ApiResponse.failRsp("10024",requestId,"MES单号:"+fSelBillNo+"已存在,请在ERP查看"+msclass+",单据编号:"+co);
             }
             }
+            //临时逻辑  工单结案直接返回成功
+            if (baseDao.isDBSetting("MakeScrap","overSuccess")) {
+                int condition = baseDao.getCountByCondition("make", "ma_statuscode='FINISH' and ma_code='" + prodNo + "'");
+                if (condition > 0) {
+                    return ApiResponse.successRsp("0", requestId, "工单【" + prodNo + "】已结案,请在ERP查看!");
+                }
+            }
+
             id = baseDao.getSeqId("MAKESCRAP_SEQ");
             id = baseDao.getSeqId("MAKESCRAP_SEQ");
             code = baseDao.sGetMaxNumber(caller, 2);
             code = baseDao.sGetMaxNumber(caller, 2);
             String fdateTime = StringUtil.nvl(jsonObject.get("FdateTime"), DateUtil.format(new Date(), "yyyy-MM-dd HH:mm:ss"));
             String fdateTime = StringUtil.nvl(jsonObject.get("FdateTime"), DateUtil.format(new Date(), "yyyy-MM-dd HH:mm:ss"));
@@ -476,10 +484,18 @@ public class MESServiceImpl implements MESService {
             if ("".equals(itemNo)){
             if ("".equals(itemNo)){
                 return ApiResponse.failRsp("10024",requestId,"物料不能为空!");
                 return ApiResponse.failRsp("10024",requestId,"物料不能为空!");
             }
             }
-            String qty = StringUtil.nvl(object.get("qty"), "");
-            if ("".equals(qty)){
+            double qty = Double.parseDouble(StringUtil.nvl(object.get("qty"), "0"));
+            if (qty==0){
                 return ApiResponse.failRsp("10025",requestId,"报废数量不能为空!");
                 return ApiResponse.failRsp("10025",requestId,"报废数量不能为空!");
             }
             }
+            //临时逻辑 重新计算报废数量
+            if (baseDao.isDBSetting("MakeScrap","overQtySuccess")) {
+                double mmqty = Double.parseDouble(StringUtil.nvl(baseDao.getFieldDataByCondition("makematerial left join make on mm_maid=ma_id", "nvl(mm_havegetqty,0)-nvl(mm_returnmqty,0)+nvl(mm_addqty,0)+nvl(mm_scrapqty,0)-nvl(mm_oneuseqty,0)*nvl(ma_madeqty,0) AS mmqty", "mm_id=" + lineId), "0"));
+                if (mmqty < qty) {
+                    qty = mmqty;
+                }
+            }
+
             String reason = StringUtil.nvl(object.get("reason"), "");
             String reason = StringUtil.nvl(object.get("reason"), "");
             if ("".equals(reason)){
             if ("".equals(reason)){
                 return ApiResponse.failRsp("10026",requestId,"报废原因不能为空!");
                 return ApiResponse.failRsp("10026",requestId,"报废原因不能为空!");
@@ -495,9 +511,14 @@ public class MESServiceImpl implements MESService {
 
 
             String allScrapQty = StringUtil.nvl(object.get("AllScrapQty"), "0");
             String allScrapQty = StringUtil.nvl(object.get("AllScrapQty"), "0");
             String remark = StringUtil.nvl(object.get("remark"), "");
             String remark = StringUtil.nvl(object.get("remark"), "");
-            sqls.add("insert into MakeScrapdetail (md_id,md_msid,md_detno,md_mmid,md_mmcode,md_mmdetno,md_prodcode,md_qty,md_reason,md_department,md_departmentname,md_allscrapqty,md_remark) values " +
-                    "(MAKESCRAPDETAIL_SEQ.nextval,"+id+","+detno+","+lineId+",'"+prodNo+"',"+mmdetno+",'"+itemNo+ "',"+qty+",'"+reason+"','"+fDeptID+"','"+fDept+"',"+allScrapQty+",'"+remark+"')");
-            detno++;
+            if (qty>0) {
+                sqls.add("insert into MakeScrapdetail (md_id,md_msid,md_detno,md_mmid,md_mmcode,md_mmdetno,md_prodcode,md_qty,md_reason,md_department,md_departmentname,md_allscrapqty,md_remark) values " +
+                        "(MAKESCRAPDETAIL_SEQ.nextval," + id + "," + detno + "," + lineId + ",'" + prodNo + "'," + mmdetno + ",'" + itemNo + "'," + qty + ",'" + reason + "','" + fDeptID + "','" + fDept + "'," + allScrapQty + ",'" + remark + "')");
+                detno++;
+            }
+        }
+        if (detno==1) {
+            return ApiResponse.failRsp("10030",requestId,"没有可报废的用料!");
         }
         }
         baseDao.execute(sqls);
         baseDao.execute(sqls);
         Object[] status = baseDao.getFieldsDataByCondition("MakeScrap", new String[] { "ms_statuscode", "ms_indate","ms_date" }, "ms_id=" + id);
         Object[] status = baseDao.getFieldsDataByCondition("MakeScrap", new String[] { "ms_statuscode", "ms_indate","ms_date" }, "ms_id=" + id);
@@ -511,7 +532,7 @@ public class MESServiceImpl implements MESService {
         if (s!=null||s1!=null||s2!=null||s3!=null||s4!=null){
         if (s!=null||s1!=null||s2!=null||s3!=null||s4!=null){
             baseDao.deleteById("MakeScrapdetail","md_msid",id);
             baseDao.deleteById("MakeScrapdetail","md_msid",id);
             baseDao.deleteById("MakeScrap","ms_id",id);
             baseDao.deleteById("MakeScrap","ms_id",id);
-            return ApiResponse.failRsp("10029",requestId,s+s1+s2+s3+s4);
+            return ApiResponse.failRsp("10029",requestId,(s==null?"":s)+(s1==null?"":s1)+(s2==null?"":s2)+(s3==null?"":s3)+(s4==null?"":s4));
         }
         }
         baseDao.updateByCondition("MakeScrapdetail", "md_status=99", "md_msid=" + id);
         baseDao.updateByCondition("MakeScrapdetail", "md_status=99", "md_msid=" + id);
         List<Object[]> objects = baseDao.getFieldsDatasByCondition("MakeScrapdetail left join make on ma_code=md_mmcode ", new String[] {
         List<Object[]> objects = baseDao.getFieldsDatasByCondition("MakeScrapdetail left join make on ma_code=md_mmcode ", new String[] {
@@ -583,7 +604,7 @@ public class MESServiceImpl implements MESService {
         // 账期和工单状态检查
         // 账期和工单状态检查
         String s1 = ScrapCheckAll(msId, caller);
         String s1 = ScrapCheckAll(msId, caller);
         if (s!=null||s1!=null){
         if (s!=null||s1!=null){
-            return ApiResponse.failRsp("10029",requestId,s+s1);
+            return ApiResponse.failRsp("10029",requestId,(s==null?"":s)+(s1==null?"":s1));
         }
         }
         baseDao.deleteByCondition("applicationdetail","ad_apid in (select ap_id from application where ap_source='" + msclass + "' and ap_sourceid=" + msId+")");
         baseDao.deleteByCondition("applicationdetail","ad_apid in (select ap_id from application where ap_source='" + msclass + "' and ap_sourceid=" + msId+")");
         baseDao.deleteByCondition("Application","ap_source='" + msclass + "' and ap_sourceid=" + msId);
         baseDao.deleteByCondition("Application","ap_source='" + msclass + "' and ap_sourceid=" + msId);