Browse Source

修改工位结果

hfy 3 tháng trước cách đây
mục cha
commit
d9c6aa8dd4

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

@@ -16,5 +16,8 @@ public interface MesPdaScanRecordDao extends CrudDao<MesPdaScanRecord> {
 	MesPdaScanRecord findLatestBySnLineOprno(@Param("sn") String sn, @Param("lineSn") String lineSn,
 			@Param("oprno") String oprno);
 
+	MesPdaScanRecord findLatestNormalBySnLineOprno(@Param("sn") String sn, @Param("lineSn") String lineSn,
+			@Param("oprno") String oprno);
+
 	int updateRecordStatus(@Param("id") String id, @Param("status") String status);
 }

+ 7 - 0
src/main/java/com/jeesite/modules/mes/service/MesPdaScanRecordService.java

@@ -40,6 +40,13 @@ public class MesPdaScanRecordService extends CrudService<MesPdaScanRecordDao, Me
 		return dao.findLatestBySnLineOprno(sn.trim(), lineSn.trim(), oprno.trim());
 	}
 
+	public MesPdaScanRecord findLatestNormalBySnLineOprno(String sn, String lineSn, String oprno) {
+		if (StringUtils.isBlank(sn) || StringUtils.isBlank(lineSn) || StringUtils.isBlank(oprno)) {
+			return null;
+		}
+		return dao.findLatestNormalBySnLineOprno(sn.trim(), lineSn.trim(), oprno.trim());
+	}
+
 	@Transactional
 	public void finishPreviousScanRecord(String sn, String lineSn, String oprno) {
 		MesPdaScanRecord record = findLatestBySnLineOprno(sn, lineSn, oprno);

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

@@ -431,7 +431,7 @@ public class MesProductRecordService extends CrudService<MesProductRecordDao, Me
 				mpr1.setTreeLevel(0);
 				mpr1.setCdate(cdate);
 				mpr1.setContent("UDF");
-				if (!mesProductRecord.getCreateBy().isEmpty()){
+				if (StringUtils.isNotBlank(mesProductRecord.getCreateBy())){
 					mpr1.setCreateBy(mesProductRecord.getCreateBy());
 					mpr1.setUpdateBy(mesProductRecord.getCreateBy());
 				}
@@ -461,14 +461,16 @@ public class MesProductRecordService extends CrudService<MesProductRecordDao, Me
 			mesProduct.setSn(mesProductRecord.getSn());
 			mesProduct.setState("0");
 			mesProduct.setCate(cateSn);
-			if (!mesProductRecord.getCreateBy().isEmpty()){
+			if (StringUtils.isNotBlank(mesProductRecord.getCreateBy())){
 				mesProduct.setCreateBy(mesProductRecord.getCreateBy());
 				mesProduct.setUpdateBy(mesProductRecord.getCreateBy());
 			}
 			mesProductService.save(mesProduct);
 
 			// 框架 preInsert 会把 update_by 覆盖为当前会话用户(接口场景多为 system),按实际操作人回写
-			rewriteUpdateByAfterCreate(mesProductRecord.getSn(), mesProductRecord.getCreateBy());
+			if (StringUtils.isNotBlank(mesProductRecord.getCreateBy())) {
+				rewriteUpdateByAfterCreate(mesProductRecord.getSn(), mesProductRecord.getCreateBy());
+			}
 
 			return "RSOK";
 		}
@@ -1415,4 +1417,4 @@ public class MesProductRecordService extends CrudService<MesProductRecordDao, Me
 		query.getSqlMap().getWhere().and("oprno", QueryType.LIKE, fOprno);
 		return findList(query);
 	}
-}
+}

+ 25 - 1
src/main/java/com/jeesite/modules/mes/web/MesProductRecordController.java

@@ -509,7 +509,7 @@ public class MesProductRecordController extends BaseController {
 	@PostMapping(value = "save")
 	@ResponseBody
 	public String save(@Validated MesProductRecord mesProductRecord,HttpServletRequest request) {
-		if(mesProductRecord.getIsNewRecord() && mesProductRecord.getLineSn().isEmpty()){ // 新增
+		if(mesProductRecord.getIsNewRecord() && StringUtils.isBlank(mesProductRecord.getLineSn())){ // 新增
 			return renderResult(Global.FALSE, text("产线编号不能为空!"));
 		}
 
@@ -3477,6 +3477,7 @@ public class MesProductRecordController extends BaseController {
 		mesProductRecord.getSqlMap().getOrder().setOrderBy("a.update_date DESC");
 
 		Page<MesProductRecord> page = mesProductRecordService.findPage(mesProductRecord);
+		fillWorkOperators(page.getList());
 //		for (int i=0;i<page.getList().size();i++){
 //			MesProductRecord mesProductRecord1 = new MesProductRecord();
 //			mesProductRecord1.setSn(page.getList().get(i).getSn());
@@ -3491,6 +3492,29 @@ public class MesProductRecordController extends BaseController {
 		return page;
 	}
 
+	private void fillWorkOperators(List<MesProductRecord> list) {
+		if (ListUtils.isEmpty(list)) {
+			return;
+		}
+		Map<String, String> operatorMap = new HashMap<>();
+		for (MesProductRecord record : list) {
+			if (StringUtils.isBlank(record.getSn()) || StringUtils.isBlank(record.getOprno())
+					|| StringUtils.isBlank(record.getLineSn())) {
+				continue;
+			}
+			String key = record.getSn() + "|" + record.getLineSn() + "|" + record.getOprno();
+			if (!operatorMap.containsKey(key)) {
+				MesPdaScanRecord scanRecord = mesPdaScanRecordService.findLatestNormalBySnLineOprno(
+						record.getSn(), record.getLineSn(), record.getOprno());
+				operatorMap.put(key, ObjectUtils.isEmpty(scanRecord) ? "" : StringUtils.trim(scanRecord.getUcode()));
+			}
+			String operator = operatorMap.get(key);
+			if (StringUtils.isNotBlank(operator)) {
+				record.setUpdateBy(operator);
+			}
+		}
+	}
+
 	@RequestMapping(value = "winfo")
 	public String winfo(MesProductRecord mesProductRecord,Model model, HttpServletRequest request, HttpServletResponse response) {
 		MesProductRecord mesProductRecord1 = new MesProductRecord();

+ 6 - 6
src/main/resources/config/application.yml

@@ -163,13 +163,13 @@ jdbc:
   # Mysql 数据库配置
   type: mysql
   driver: com.mysql.cj.jdbc.Driver
-  url: jdbc:mysql://127.0.0.1:3306/mes_liuan?useSSL=false&useUnicode=true&characterEncoding=utf-8&zeroDateTimeBehavior=CONVERT_TO_NULL&serverTimezone=Asia/Shanghai&nullCatalogMeansCurrent=true
+ # url: jdbc:mysql://127.0.0.1:3306/mes_liuan?useSSL=false&useUnicode=true&characterEncoding=utf-8&zeroDateTimeBehavior=CONVERT_TO_NULL&serverTimezone=Asia/Shanghai&nullCatalogMeansCurrent=true
 #  url: jdbc:mysql://127.0.0.1:3306/mes_cloude_npd?useSSL=false&useUnicode=true&characterEncoding=utf-8&zeroDateTimeBehavior=CONVERT_TO_NULL&serverTimezone=Asia/Shanghai&nullCatalogMeansCurrent=true
-# url: jdbc:mysql://192.168.9.181:3306/mes_cloud?useSSL=false&useUnicode=true&characterEncoding=utf-8&zeroDateTimeBehavior=CONVERT_TO_NULL&serverTimezone=Asia/Shanghai&nullCatalogMeansCurrent=true
-# username: mes_cloud
-# password: s2ENj7KaEySTC7dW
-  username: root
-  password: 123456
+  url: jdbc:mysql://192.168.9.181:3306/mes_cloud?useSSL=false&useUnicode=true&characterEncoding=utf-8&zeroDateTimeBehavior=CONVERT_TO_NULL&serverTimezone=Asia/Shanghai&nullCatalogMeansCurrent=true
+  username: mes_cloud
+  password: s2ENj7KaEySTC7dW
+ # username: root
+ # password: 123456
   testSql: SELECT 1
 
   #  # Oracle 数据库配置(若使用 12c,请修改 /modules/core/pom.xml 文件,打开 12c 依赖,去掉 11g 依赖)

+ 25 - 0
src/main/resources/mappings/modules/mes/MesPdaScanRecordDao.xml

@@ -26,6 +26,31 @@
 		LIMIT 1
 	</select>
 
+	<select id="findLatestNormalBySnLineOprno" resultType="com.jeesite.modules.mes.entity.MesPdaScanRecord">
+		SELECT id,
+			sn,
+			oprno,
+			line_sn AS lineSn,
+			ucode,
+			remarks,
+			status,
+			create_by AS createBy,
+			create_date AS createDate,
+			update_by AS updateBy,
+			update_date AS updateDate
+		FROM mes_pda_scan_record
+		WHERE sn = #{sn}
+		  AND line_sn = #{lineSn}
+		  AND status = '0'
+		  AND (
+		  	oprno = #{oprno}
+		  	OR (CHAR_LENGTH(#{oprno}) = 5 AND oprno = CONCAT(#{oprno}, 'A'))
+		  	OR (CHAR_LENGTH(#{oprno}) &gt; 5 AND oprno = SUBSTRING(#{oprno}, 1, CHAR_LENGTH(#{oprno}) - 1))
+		  )
+		ORDER BY create_date DESC, id DESC
+		LIMIT 1
+	</select>
+
 	<update id="updateRecordStatus">
 		UPDATE mes_pda_scan_record
 		SET status = #{status}