Kaynağa Gözat

feature:品项信息修改不需要选择批次

yingjian.wu 3 ay önce
ebeveyn
işleme
be3e01930b

+ 33 - 5
src/main/java/com/qlm/controller/jinzai/ProdBatchController.java

@@ -236,7 +236,7 @@ public class ProdBatchController extends CommonController {
             endTime = endTime + " 23:59:59";
         }
         try {
-            String selectColumns = "select r.modify_type,r.reference_code,f.factory_name,w.workshop_name,bi.item_name as before_item_name,ai.item_name as after_item_name,r.modify_time,r.modify_user";
+            String selectColumns = "select r.modify_type,r.reference_code,f.factory_name,w.workshop_name,l.desc as lineName,bi.item_name as before_item_name,ai.item_name as after_item_name,r.modify_time,r.modify_user";
             StringBuilder fromSql = new StringBuilder(" from t_item_modify_record r");
             fromSql.append(" left join t_factory f on r.factory_id = f.id");
             fromSql.append(" left join t_workshop w on r.workshop_id = w.id");
@@ -265,6 +265,7 @@ public class ProdBatchController extends CommonController {
                 fromSql.append(" and r.modify_time <= ?");
                 params.add(endTime);
             }
+            fromSql.append(" order by modify_time desc");
             Page<Record> paginate = Db.paginate(pageNumber, pageSize, selectColumns, fromSql.toString(), params.toArray());
             if(paginate  == null){
                 renderJson(new PageResult<>(0, pageNumber, pageSize, new ArrayList<>()));
@@ -278,6 +279,7 @@ public class ProdBatchController extends CommonController {
                 itemModifyRecordVO.setReferenceCode(record.getStr("reference_code"));
                 itemModifyRecordVO.setFactoryName(record.getStr("factory_name"));
                 itemModifyRecordVO.setWorkshopName(record.getStr("workshop_name"));
+                itemModifyRecordVO.setLineName(record.getStr("lineName"));
                 itemModifyRecordVO.setBeforeItemName(record.getStr("before_item_name"));
                 itemModifyRecordVO.setAfterItemName(record.getStr("after_item_name"));
                 itemModifyRecordVO.setModifyTime(DateUtil.format(record.getDate("modify_time"), "yyyy-MM-dd HH:mm:ss"));
@@ -317,33 +319,38 @@ public class ProdBatchController extends CommonController {
         List<String> referenceCodes = itemModifyRecordDto.getReferenceCodes();
         //单号/箱码/托码 对应的修改之前的 品项sku
         Map<String,String> referenceCodeAndSku = new HashMap<>();
+        //单号/箱码/托码 对应的设备编号
+        Map<String,String> referenceCodeAndDeviceNo = new HashMap<>();
         if(modifyType.compareTo(1) == 0){
             Record first = Db.findFirst("select * from jinzai_upload_master where task_no = ?", referenceCodes.get(0));
             if(first == null){
                 return ApiResponse.error("单号不存在");
             }
             referenceCodeAndSku.put(referenceCodes.get(0),first.getStr("sku"));
+            referenceCodeAndDeviceNo.put(referenceCodes.get(0),first.getStr("device_no"));
         }else if(modifyType.compareTo(2) == 0){
             String codeList = referenceCodes.stream()
                     .map(code -> "'" + code + "'")
-                    .collect(java.util.stream.Collectors.joining(","));
+                    .collect(Collectors.joining(","));
             List<Record> masterRecords = Db.find("select * from jinzai_upload_master where id in(" + codeList + ")");
             if(masterRecords.size() != referenceCodes.size()){
                 return ApiResponse.error("有箱码不存在");
             }
             masterRecords.forEach(record -> {
                 referenceCodeAndSku.put(record.getStr("id"),record.getStr("sku"));
+                referenceCodeAndDeviceNo.put(record.getStr("id"),record.getStr("device_no"));
             });
         }else if(modifyType.compareTo(3) == 0){
             String codeList = referenceCodes.stream()
                     .map(code -> "'" + code + "'")
-                    .collect(java.util.stream.Collectors.joining(","));
+                    .collect(Collectors.joining(","));
             List<Record> duoRecords = Db.find("select * from jinzai_upload_master where duo_code in(" + codeList + ")");
             if(duoRecords.size() != referenceCodes.size()){
                 return ApiResponse.error("有托码不存在");
             }
             duoRecords.forEach(record -> {
                 referenceCodeAndSku.put(record.getStr("duo_code"),record.getStr("sku"));
+                referenceCodeAndDeviceNo.put(record.getStr("duo_code"),record.getStr("device_no"));
             });
         }
         boolean tx = Db.tx(() -> {
@@ -351,7 +358,7 @@ public class ProdBatchController extends CommonController {
                 //转成字符串,逗号拼接
                 String addReferenceCode = referenceCodes.stream()
                         .map(code -> "'" + code + "'")
-                        .collect(java.util.stream.Collectors.joining(","));
+                        .collect(Collectors.joining(","));
                 List<Record> itemList = Db.find("select * from t_jz_item");
                 Map<Integer, Record> itemMap = new HashMap<>();
                 Map<String,Record> itemSkuMap = new HashMap<>();
@@ -367,12 +374,33 @@ public class ProdBatchController extends CommonController {
                             (existing, replacement) -> existing
                     ));
                 }
+                List<Record> deviceList = Db.find("select * from t_jz_device");
+                Map<String, Record> deviceMap = new HashMap<>();
+                if (CollUtil.isNotEmpty(deviceList)) {
+                    deviceMap = deviceList.stream().collect(Collectors.toMap(
+                            record -> record.getStr("device_no"),
+                            record -> record,
+                            (existing, replacement) -> existing
+                    ));
+                }
                 Record itemRecord = itemMap.get(itemModifyRecordDto.getAfterItemId());
                 String itemName = itemRecord.getStr("item_name");
                 String itemKouWei = itemRecord.getStr("kouwei");
                 String sku = itemRecord.getStr("sku");
                 //批量插入品项更新记录
                 for (String referenceCode : referenceCodes) {
+                    //根据单号/箱码/托码 获取deviceNo
+                    String deviceNo = referenceCodeAndDeviceNo.get(referenceCode);
+                    if(StrKit.isBlank(deviceNo)){
+                        logger.error("单号/箱码/托码:{}未获取到产线编号", referenceCode);
+                        continue;
+                    }
+                    Record deviceRecord = deviceMap.get(deviceNo);
+                    Integer lineId = 0;
+                    if(deviceRecord != null){
+                        lineId = WxUtil.getInt("id", deviceRecord);
+                    }
+
                     //根据单号/箱码/托码 获取sku
                     String beforeSku = referenceCodeAndSku.get(referenceCode);
                     if(StrKit.isBlank(beforeSku)){
@@ -391,7 +419,7 @@ public class ProdBatchController extends CommonController {
                     record.set("reference_code", referenceCode);
                     record.set("factory_id", itemModifyRecordDto.getFactoryId());
                     record.set("workshop_id", itemModifyRecordDto.getWorkshopId());
-                    record.set("line_id", itemModifyRecordDto.getLineId());
+                    record.set("line_id", lineId);
                     record.set("before_item_id", WxUtil.getInt("id", beforeItemRecord));
                     record.set("after_item_id", itemModifyRecordDto.getAfterItemId());
                     record.set("modify_user", loginUser.getUsername());

+ 0 - 13
src/main/java/com/qlm/dto/ItemModifyRecordDto.java

@@ -34,11 +34,6 @@ public class ItemModifyRecordDto implements Serializable {
      */
     private Integer workshopId;
 
-    /**
-     * 产线ID
-     */
-    private Integer lineId;
-
     /**
      * 修改前品项ID
      */
@@ -81,14 +76,6 @@ public class ItemModifyRecordDto implements Serializable {
         this.workshopId = workshopId;
     }
 
-    public Integer getLineId() {
-        return lineId;
-    }
-
-    public void setLineId(Integer lineId) {
-        this.lineId = lineId;
-    }
-
     public Integer getBeforeItemId() {
         return beforeItemId;
     }

+ 15 - 0
src/main/java/com/qlm/dto/ItemModifyRecordVO.java

@@ -31,6 +31,11 @@ public class ItemModifyRecordVO implements Serializable {
      */
     private String workshopName;
 
+    /**
+     * 产线名称
+     */
+    private String lineName;
+
     /**
      * 修改前品项名称
      */
@@ -115,6 +120,15 @@ public class ItemModifyRecordVO implements Serializable {
         this.modifyUser = modifyUser;
     }
 
+    public String getLineName() {
+        return lineName;
+    }
+
+    public void setLineName(String lineName) {
+        this.lineName = lineName;
+    }
+
+
     @Override
     public String toString() {
         return "ItemModifyRecordVO{" +
@@ -122,6 +136,7 @@ public class ItemModifyRecordVO implements Serializable {
                 ", referenceCode='" + referenceCode + '\'' +
                 ", factoryName='" + factoryName + '\'' +
                 ", workshopName='" + workshopName + '\'' +
+                ", lineName='" + lineName + '\'' +
                 ", beforeItemName='" + beforeItemName + '\'' +
                 ", afterItemName='" + afterItemName + '\'' +
                 ", modifyTime='" + modifyTime + '\'' +

+ 5 - 53
src/main/webapp/page/jinzai/itemChangeRecord.jsp

@@ -165,13 +165,6 @@
                         </div>
 
                         <div class="row mb-4">
-                            <div class="col-md-6">
-                                <label for="modalProductionLineId" class="required control-label">产线</label>
-                                <select id="modalProductionLineId" class="form-control selectpicker" required>
-                                    <option value="">请选择产线</option>
-                                    <!-- 产线下拉框选项将通过JavaScript动态加载 -->
-                                </select>
-                            </div>
                             <div class="col-md-6">
                                 <label for="modalAfterItemId" class="required control-label">修改后品相</label>
                                 <select id="modalAfterItemId" class="form-control selectpicker" required>
@@ -245,8 +238,6 @@
             } else {
                 $('#modalWorkshopId').empty().append('<option value="">请选择车间</option>');
                 $('#modalWorkshopId').selectpicker('refresh');
-                $('#modalProductionLineId').empty().append('<option value="">请选择产线</option>');
-                $('#modalProductionLineId').selectpicker('refresh');
             }
         });
 
@@ -255,9 +246,6 @@
             const workshopId = $(this).val();
             if (workshopId) {
                 loadModalProductionLinesByWorkshopId(workshopId);
-            } else {
-                $('#modalProductionLineId').empty().append('<option value="">请选择产线</option>');
-                $('#modalProductionLineId').selectpicker('refresh');
             }
         });
 
@@ -500,7 +488,6 @@
         // 显式重置所有联动下拉框并刷新selectpicker
         $('#modalFactoryId').val('').selectpicker('refresh');
         $('#modalWorkshopId').val('').selectpicker('refresh');
-        $('#modalProductionLineId').val('').selectpicker('refresh');
         $('#modalAfterItemId').val('').selectpicker('refresh');
 
         // 重置修改值输入框
@@ -548,7 +535,6 @@
             referenceCodes: referenceCodesArray,
             factoryId: $('#modalFactoryId').val(),
             workshopId: $('#modalWorkshopId').val(),
-            lineId: $('#modalProductionLineId').val(),
             afterItemId: $('#modalAfterItemId').val()
         };
 
@@ -609,9 +595,6 @@
                     });
                 }
                 $('#modalWorkshopId').selectpicker('refresh');
-                // 清空并重置产线选择框
-                $('#modalProductionLineId').empty().append('<option value="">请选择产线</option>');
-                $('#modalProductionLineId').selectpicker('refresh');
             },
             error: function (xhr) {
                 $('#modalWorkshopId').empty().append('<option value="">加载失败</option>');
@@ -624,39 +607,6 @@
         });
     }
 
-    // 模态框中根据车间ID加载产线数据
-    function loadModalProductionLinesByWorkshopId(workshopId) {
-        $.ajax({
-            url: '${ctx}/lineProduct/getLineList',
-            type: 'POST',
-            data: {
-                workshopId: workshopId
-            },
-            dataType: 'json',
-            beforeSend: function () {
-                $('#modalProductionLineId').prop('disabled', true).selectpicker('refresh');
-            },
-            success: function (res) {
-                $('#modalProductionLineId').empty();
-                $('#modalProductionLineId').append('<option value="">请选择产线</option>');
-                if (res.data && res.data.length) {
-                    res.data.forEach(item => {
-                        $('#modalProductionLineId').append('<option value="' + item.id + '">' + item.lineName + '</option>');
-                    });
-                }
-                $('#modalProductionLineId').selectpicker('refresh');
-            },
-            error: function (xhr) {
-                $('#modalProductionLineId').empty().append('<option value="">加载失败</option>');
-                $('#modalProductionLineId').selectpicker('refresh');
-                layer.msg('获取产线数据失败: ' + xhr.statusText);
-            },
-            complete: function () {
-                $('#modalProductionLineId').prop('disabled', false).selectpicker('refresh');
-            }
-        });
-    }
-
     // 加载模态框中的品相数据
     function loadModalItems() {
         loadItems();
@@ -718,9 +668,6 @@
                 modalWorkshopId: {
                     required: '请选择车间'
                 },
-                modalProductionLineId: {
-                    required: '请选择产线'
-                },
                 modalAfterItemId: {
                     required: '请选择修改后品相'
                 }
@@ -801,6 +748,11 @@
                 align: 'center',
                 width: "10%"
             }, {
+                field: 'lineName',
+                title: '产线名称',
+                align: 'center',
+                width: "10%"
+            },{
                 field: 'beforeItemName',
                 title: '修改前品项名称',
                 align: 'center',

+ 58 - 53
src/main/webapp/page/jinzai/search.jsp

@@ -203,59 +203,64 @@
 	        columns: configList,
 	    });
 	}
-	
-	let configList = [
-	      	        {
-	    	            field: 'task_no',
-	    	            title: '单号',
-	    	            align: 'center',
-	    	            width:"5%"
-	    	        }
-	    	        ,{
-	    	            field: 'id',
-	    	            title: '箱码',
-	    	            align: 'center',
-	    	            width:"5%"
-	    	        }
-	    	        ,{
-	    	        	field:"duo_code",
-	    	            title: '垛码',
-	    	            align: 'center',
-	    	            width:"5%",
-	    	        }
-	    	        ,{
-	    	        	field:"guo_time",
-	    	            title: '绑定时间',
-	    	            align: 'center',
-	    	            width:"5%",
-	    	        }
-	    	        ,{
-	    	            field: 'pinxiang',
-	    	            title: '产品',
-	    	            align: 'center',
-	    	            width:"5%"
-	    	        }
-	    	        ,{
-	    	            field: 'kouwei',
-	    	            title: '口味',
-	    	            align: 'center',
-	    	            width:"5%"
-	    	        }
-	    	        
-	    	        ,{
-	    	            title: '发货信息',
-	    	            align: 'center',
-	    	            width:"5%",
-	    	            formatter:function(value,data){
-	    	            	debugger;
-	    	            	if(data.fahuoInfo){
-	    	            		return "发货单号:"+data.fahuoInfo.OrderNo+",客户:"+data.fahuoInfo.CustomerName;
-	    	            	}else{
-	    	            		return "未发货";
-	    	            	}
-	    	            }
-	    	        }
-	    	];
+
+    let configList = [
+        {
+            field: 'task_no',
+            title: '单号',
+            align: 'center',
+            width: "5%"
+        }
+        , {
+            field: 'id',
+            title: '箱码',
+            align: 'center',
+            width: "5%"
+        }
+        , {
+            field: "duo_code",
+            title: '垛码',
+            align: 'center',
+            width: "5%",
+        }
+        , {
+            field: "guo_time",
+            title: '绑定时间',
+            align: 'center',
+            width: "5%",
+        }
+        , {
+            field: 'pinxiang',
+            title: '产品',
+            align: 'center',
+            width: "5%"
+        }, {
+            field: 'device_no',
+            title: '产线编号',
+            align: 'center',
+            width: "5%"
+        }
+        , {
+            field: 'kouwei',
+            title: '口味',
+            align: 'center',
+            width: "5%"
+        }
+
+        , {
+            title: '发货信息',
+            align: 'center',
+            width: "5%",
+            formatter: function (value, data) {
+                debugger;
+                if (data.fahuoInfo) {
+                    return "发货单号:" + data.fahuoInfo.OrderNo + ",客户:" + data.fahuoInfo.CustomerName;
+                } else {
+                    return "未发货";
+                }
+            }
+        }
+    ];
 
    	</script>
 </body>