Browse Source

OP105绑定 提交 OK 时补报 OP100沿用OP100入库时间,未入库则沿用 OP105 提交时间

wangxichen 5 days ago
parent
commit
8661a2d4be

+ 3 - 0
src/main/java/com/jeesite/modules/mes/dao/MesProductRecordDao.java

@@ -25,6 +25,9 @@ public interface MesProductRecordDao extends CrudDao<MesProductRecord> {
     Boolean updateDate(MesProductRecord mesProductRecord);
     Boolean updateDate(MesProductRecord mesProductRecord);
     int updateResultByCheckFirst(MesProductRecord mesProductRecord);
     int updateResultByCheckFirst(MesProductRecord mesProductRecord);
 
 
+    int completeBoundOp100(@Param("sn") String sn, @Param("lineSn") String lineSn,
+                           @Param("op105RecordId") String op105RecordId);
+
     List<MesProductRecord> selectByOprno(MesProductRecord mesProductRecord);
     List<MesProductRecord> selectByOprno(MesProductRecord mesProductRecord);
 
 
     // 新增特定查询接口
     // 新增特定查询接口

+ 6 - 0
src/main/java/com/jeesite/modules/mes/service/MesProductRecordService.java

@@ -988,6 +988,12 @@ public class MesProductRecordService extends CrudService<MesProductRecordDao, Me
 				mesProductModifyRecord1.setUpdateBy(userCode);
 				mesProductModifyRecord1.setUpdateBy(userCode);
 				mesProductModifyRecordService.save(mesProductModifyRecord1);
 				mesProductModifyRecordService.save(mesProductModifyRecord1);
 
 
+				// CZ060 PDA 提交 OP105 OK 后补记 OP100,缺少打码入库记录时沿用本次 OP105 时间。
+				if (!checkPlan && "CZ060".equals(lineSn) && "OP105".equals(oprno)
+						&& "100000".equals(craft) && "OK".equals(content)) {
+					mesProductRecordDao.completeBoundOp100(sn, lineSn, mesProductRecord.getId());
+				}
+
 				//GP12检查记录保存
 				//GP12检查记录保存
 				List<String> gp12oprnos = ListUtils.newArrayList();
 				List<String> gp12oprnos = ListUtils.newArrayList();
 				gp12oprnos.add("OP195"); //白件GP12
 				gp12oprnos.add("OP195"); //白件GP12

+ 28 - 0
src/main/resources/mappings/modules/mes/MesProductRecordDao.xml

@@ -83,6 +83,34 @@
         <!-- where sn = #{sn} and oprno = #{oprno} and line_sn = #{lineSn} and craft = #{craft} -->
         <!-- where sn = #{sn} and oprno = #{oprno} and line_sn = #{lineSn} and craft = #{craft} -->
         where sn = #{sn} and oprno = #{oprno} and craft = #{craft}
         where sn = #{sn} and oprno = #{oprno} and craft = #{craft}
     </update>
     </update>
+    <!-- 长码入库时间优先,PDA 补录等无入库记录的情况沿用本次 OP105 OK 的提交时间。 -->
+    <update id="completeBoundOp100">
+        UPDATE mes_product_record r
+        JOIN mes_product_record op105 ON op105.id = #{op105RecordId} AND op105.sn = r.sn
+        CROSS JOIN (
+            SELECT h.create_by,
+                   CASE WHEN EXISTS (
+                       SELECT 1
+                       FROM mes_product_pre p
+                       WHERE p.sn = h.sn AND p.line_sn = #{lineSn}
+                         AND p.cate = '2' AND p.plan_id = h.plan_id AND p.plan_id &lt;&gt; ''
+                   ) THEN h.create_date END AS printed_at
+            FROM mes_product_hmb h
+            WHERE h.qsn = #{sn}
+              AND h.line_sn = #{lineSn}
+              AND h.state = '1'
+            ORDER BY printed_at DESC, h.id
+            LIMIT 1
+        ) bound_hmb
+        SET r.content = 'OK',
+            r.source = '0',
+            r.update_by = CASE WHEN bound_hmb.printed_at IS NULL THEN op105.update_by ELSE bound_hmb.create_by END,
+            r.update_date = COALESCE(bound_hmb.printed_at, op105.update_date)
+        WHERE r.sn = #{sn}
+          AND r.oprno IN ('OP100', 'OP100A')
+          AND r.craft = '100000'
+          AND r.content = 'UDF'
+    </update>
     <update id="updateDate">
     <update id="updateDate">
         update mes_product_record
         update mes_product_record
         set update_date=#{updateDate}
         set update_date=#{updateDate}