Forráskód Böngészése

数据备份及一键生产任务

oyq28 1 éve
szülő
commit
659dbd6b83

A különbségek nem kerülnek megjelenítésre, a fájl túl nagy
+ 25 - 25
doc/20240425104725.sql


+ 1 - 1
src/main/java/com/imcs/admin/business/service/BusinessService.java

@@ -8,7 +8,7 @@ import java.util.Map;
 public interface BusinessService {
     public void salesProductionOrder(Long id);
 
-    void productionOrder(Long id);
+    Long productionOrder(Long id);
 
     void batchSplit(Map<String,Object> map);
 

+ 9 - 6
src/main/java/com/imcs/admin/business/service/impl/BusinessServiceImpl.java

@@ -92,7 +92,7 @@ public class BusinessServiceImpl implements BusinessService{
     }
 
     @Override
-    public void productionOrder(Long id) {
+    public Long productionOrder(Long id) {
         String sql="select * from a_production_order where id = ?";
         Map<String, Object> one = jdbcService.findOne(sql, id);
         String orderCode = one.get("orderCode").toString();
@@ -103,9 +103,9 @@ public class BusinessServiceImpl implements BusinessService{
         String productionOrderCode = one.get("productionOrderCode").toString();
         Long salesOrderId = Long.valueOf(one.get("salesOrderId").toString());
         String insertSql="INSERT INTO `imcs_platform`.`a_production_preparation_task` (`order_code`, `order_name`, `task_code`, `product_name`, `product_code`, `amount`,`status`, `created_at`,`production_order_code`, `production_order_id`,sales_order_id,is_design) VALUES ( ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?,?)";
-        jdbcService.insert("执行insert",insertSql,orderCode,orderName,generateSerial.generateSerialNumber("aProductionPreparationTask"),productName,productCode,planAmount,0,new Date(),productionOrderCode,id,salesOrderId,0);
+        Long insert = jdbcService.insert("执行insert", insertSql, orderCode, orderName, generateSerial.generateSerialNumber("aProductionPreparationTask"), productName, productCode, planAmount, 0, new Date(), productionOrderCode, id, salesOrderId, 0);
         jdbcService.update("update a_production_order set is_issue = 1 where id = ?",id);
-
+        return insert;
     }
 
     @Override
@@ -342,12 +342,15 @@ public class BusinessServiceImpl implements BusinessService{
     private void checkLastProcedure(Long recordId, Integer taskType,Long processProcedureId,String productionOrderCode) {
         //加工工序校验上道加工工序是否完成
         String sql = null;
-        if(taskType == 0){
+
+        //跳跃质检工序
+        /*if(taskType == 0){
              sql="select * from a_production_work_order where task_type  = 0 and production_order_code = ? order by seq ";
 
         }else{
             sql="select * from a_production_work_order where production_order_code = ? order by seq ";
-        }
+        }*/
+        sql="select * from a_production_work_order where production_order_code = ? order by seq ";
 
         List<Map<String, Object>> query = query(sql, new Object[]{productionOrderCode});
         Map<String, Object> lastProcedure = getLastProcedure(query, recordId);
@@ -409,7 +412,7 @@ public class BusinessServiceImpl implements BusinessService{
             Long materialId=Long.valueOf(item.get("materialId").toString());
             Integer amount=Integer.valueOf(item.get("amount").toString());
             String materialName = item.get("materialName").toString();
-            int update = jdbcService.update("update a_material_store set store_amount=store_amount - ? where parent_id = ? and store_amount - ? > 0", amount, materialId,amount);
+            int update = jdbcService.update("update a_material_store set store_amount=store_amount - ? where parent_id = ? and store_amount - ? >= 0", amount, materialId,amount);
             if(update <= 0){
                 throw new RuntimeException(materialName+"物料不足");
             }

+ 36 - 12
src/main/java/com/imcs/admin/business/service/impl/DevicMaintainServiceImpl.java

@@ -3,6 +3,7 @@ package com.imcs.admin.business.service.impl;
 
 import com.hankcs.hanlp.HanLP;
 import com.hankcs.hanlp.dictionary.py.Pinyin;
+import com.imcs.admin.business.service.BusinessService;
 import com.imcs.admin.business.service.DevicMaintainService;
 import com.imcs.admin.common.config.SessionContext;
 import com.imcs.admin.common.data.SysFile;
@@ -49,6 +50,9 @@ public class DevicMaintainServiceImpl  implements DevicMaintainService {
     @Resource
     private SysFileService sysFileService;
 
+    @Resource
+    private BusinessService businessService;
+
 
     @Override
     @Transactional(rollbackFor = Exception.class)
@@ -179,7 +183,7 @@ public class DevicMaintainServiceImpl  implements DevicMaintainService {
         try {
             FileInputStream fis = new FileInputStream(filePath);
             HWPFDocument document = new HWPFDocument(fis);
-            fis.close();
+
 
             // 遍历文档中的所有表格
             Range range = document.getRange();
@@ -276,15 +280,15 @@ public class DevicMaintainServiceImpl  implements DevicMaintainService {
                 }
             }
 
-            int wgSeq=0;
+            int y=0;
             for(int i =0;i<procedureList.size();i++){
                 List<String> item=procedureList.get(i);
                 if (!item.isEmpty() && isNumeric(item.get(0))) {
                     //int seq = Integer.parseInt(item.get(0));
-                    int seq=i+1;
-                    wgSeq=seq;
+                    //int seq=i+1;
+                    y=++y;
                     String procedureName = item.get(1);
-                    String procedureContent = item.get(2);
+                    String procedureContent = item.get(3);
                     String procedureCode = convertToPinyin(procedureName);
                     Map<String, Object> one = jdbcService.findOne("select * from a_procedure where procedure_code=? and procedure_name=? and procedure_content=?", procedureCode, procedureName, procedureContent);
                     Long procedureId=null;
@@ -293,14 +297,17 @@ public class DevicMaintainServiceImpl  implements DevicMaintainService {
                     }else{
                         procedureId = jdbcService.insert("insert", "INSERT INTO a_procedure (`procedure_code`, `procedure_name`, `procedure_content`) VALUES (?,?,?);", procedureCode, procedureName, procedureContent);
                     }
-                    jdbcService.insert("insert",insertProcessProcedure,processVersionId,procedureId,0,null,null,seq);
-                    if(containsTargetString && i != item.size()-1){
-                        jdbcService.insert("insert",insertProcessProcedure,processVersionId,15,1,null,1,seq+1);
+                    jdbcService.insert("insert",insertProcessProcedure,processVersionId,procedureId,0,null,null,y);
+                    if(containsTargetString && i != procedureList.size()-1){
+                        //过程检
+                        y=++y;
+                        jdbcService.insert("insert",insertProcessProcedure,processVersionId,15,1,null,1,y);
                     }
                 }
             }
-            if(wgSeq > 0 ){
-                jdbcService.insert("insert",insertProcessProcedure,processVersionId,14,2,null,2,wgSeq+1);
+            if(y > 0 ){
+                //完工检检
+                jdbcService.insert("insert",insertProcessProcedure,processVersionId,14,2,null,2,++y);
             }
 
             Map<String, Object> one = jdbcService.findOne("select value from dic_item where parent_id = (select id from dic where dic_code='autoGeneration') and label = '销售订单'");
@@ -309,12 +316,29 @@ public class DevicMaintainServiceImpl  implements DevicMaintainService {
             if(value){
                 //销售订单
                 Long salesOrderId = jdbcService.insert("insert", "INSERT INTO b_sales_order (order_code, order_name, deliver_date, apply_status, is_issue, created_at, status) VALUES (?,?,?,?,?,?,?);"
-                        , generateSerial.generateSerialNumber("bSalesOrder"), xsCode + "_" + result, new Date(), 0, 0, new Date(), 0);
+                        , generateSerial.generateSerialNumber("bSalesOrder"), xsCode + "_" + result, new Date(), 1, 0, new Date(), 0);
                 jdbcService.insert("insert","INSERT INTO a_sales_product (parent_id, product_id, sales_amount, seq) VALUES (?,?,?,?);",salesOrderId,productId,num,1);
-            }
 
+                businessService.salesProductionOrder(salesOrderId);
+                Map<String, Object> one1 = jdbcService.findOne("select id from a_production_order where sales_order_id=?", salesOrderId);
+                Long productionOrderId = Long.valueOf(one1.get("id").toString());
+                //设计分发id
+                Long productionPreparationTaskId = businessService.productionOrder(productionOrderId);
+                businessService.productionPreparationTask(productionPreparationTaskId);
+                //设计准备
+                jdbcService.update("update a_production_design_preparation_task set status=1 where production_preparation_task_id=?",productionPreparationTaskId);
+
+                //生产计划
+                jdbcService.update("update a_production_order set start_time=now(),end_time=now(),is_plan=1 where id=?",productionOrderId);
+                //生产排产
+                businessService.orderToProcedure(productionOrderId);
+                //生产任务下达
+                jdbcService.update("update a_production_work_order set apply_status=1 where production_order_id=?",productionOrderId);
+            }
+            fis.close();
             document.close();
         } catch (IOException e) {
+            log.error("上传工艺规格报错:{}",e);
             e.printStackTrace();
         }
     }

Nem az összes módosított fájl került megjelenítésre, mert túl sok fájl változott