Bläddra i källkod

适配多条产线优化

zhanghe 5 månader sedan
förälder
incheckning
63f6cfd72b

+ 14 - 14
src/main/java/com/jeesite/modules/mes/entity/MesProductRecord.java

@@ -29,7 +29,7 @@ import java.util.List;
 		@Column(name="serial", attrName="serial", label="排序", isUpdateForce=true),
 //		@Column(name="message_type", attrName="messageType", label="报文类型", queryType=QueryType.LIKE),
 		@Column(name="cate_sn", attrName="cateSn", label="工件类型", queryType=QueryType.LIKE),
-		@Column(name="line_sn", attrName="lineSn", label="产线编号", queryType=QueryType.LIKE),
+		@Column(name="line_sn", attrName="lineSn", label="产线编号"),
 		@Column(name="source", attrName="source", label="来源", queryType=QueryType.EQ),
 		@Column(name="materiel_sn", attrName="materielSn", label="物料批次二维码", queryType=QueryType.LIKE),
 		@Column(name="content", attrName="content", label="结果", queryType=QueryType.LIKE),
@@ -57,7 +57,7 @@ import java.util.List;
 		orderBy="a.id"
 )
 public class MesProductRecord extends DataEntity<MesProductRecord> {
-	
+
 	private static final long serialVersionUID = 1L;
 	private String sn;		// 产品二维码
 	private String oprno;		// 工位号
@@ -105,11 +105,11 @@ public class MesProductRecord extends DataEntity<MesProductRecord> {
 	public MesProductRecord() {
 		this(null);
 	}
-	
+
 	public MesProductRecord(String id){
 		super(id);
 	}
-	
+
 	@Size(min=0, max=50, message="产品二维码长度不能超过 50 个字符")
 	public String getSn() {
 		return sn;
@@ -118,7 +118,7 @@ public class MesProductRecord extends DataEntity<MesProductRecord> {
 	public void setSn(String sn) {
 		this.sn = sn;
 	}
-	
+
 	@Size(min=0, max=20, message="工位号长度不能超过 20 个字符")
 	public String getOprno() {
 		return oprno;
@@ -127,7 +127,7 @@ public class MesProductRecord extends DataEntity<MesProductRecord> {
 	public void setOprno(String oprno) {
 		this.oprno = oprno;
 	}
-	
+
 	@Size(min=0, max=30, message="工艺号长度不能超过 30 个字符")
 	public String getCraft() {
 		return craft;
@@ -136,7 +136,7 @@ public class MesProductRecord extends DataEntity<MesProductRecord> {
 	public void setCraft(String craft) {
 		this.craft = craft;
 	}
-	
+
 	public Integer getSerial() {
 		return serial;
 	}
@@ -144,7 +144,7 @@ public class MesProductRecord extends DataEntity<MesProductRecord> {
 	public void setSerial(Integer serial) {
 		this.serial = serial;
 	}
-	
+
 	@Size(min=0, max=50, message="报文类型长度不能超过 50 个字符")
 	public String getMessageType() {
 		return messageType;
@@ -153,7 +153,7 @@ public class MesProductRecord extends DataEntity<MesProductRecord> {
 	public void setMessageType(String messageType) {
 		this.messageType = messageType;
 	}
-	
+
 	@Size(min=0, max=30, message="工件类型长度不能超过 30 个字符")
 	public String getCateSn() {
 		return cateSn;
@@ -162,7 +162,7 @@ public class MesProductRecord extends DataEntity<MesProductRecord> {
 	public void setCateSn(String cateSn) {
 		this.cateSn = cateSn;
 	}
-	
+
 	@Size(min=0, max=50, message="物料批次二维码长度不能超过 50 个字符")
 	public String getMaterielSn() {
 		return materielSn;
@@ -171,7 +171,7 @@ public class MesProductRecord extends DataEntity<MesProductRecord> {
 	public void setMaterielSn(String materielSn) {
 		this.materielSn = materielSn;
 	}
-	
+
 	@Size(min=0, max=1000, message="结果长度不能超过 1000 个字符")
 	public String getContent() {
 		return content;
@@ -180,7 +180,7 @@ public class MesProductRecord extends DataEntity<MesProductRecord> {
 	public void setContent(String content) {
 		this.content = content;
 	}
-	
+
 	@Size(min=0, max=255, message="备注长度不能超过 255 个字符")
 	public String getRemark() {
 		return remark;
@@ -189,7 +189,7 @@ public class MesProductRecord extends DataEntity<MesProductRecord> {
 	public void setRemark(String remark) {
 		this.remark = remark;
 	}
-	
+
 	@Size(min=0, max=64, message="父级id长度不能超过 64 个字符")
 	public String getPid() {
 		return pid;
@@ -354,4 +354,4 @@ public class MesProductRecord extends DataEntity<MesProductRecord> {
 	public void setFileList(List fileList) {
 		this.fileList = fileList;
 	}
-}
+}

+ 27 - 26
src/main/java/com/jeesite/modules/mes/service/MesProductCateService.java

@@ -141,8 +141,27 @@ public class MesProductCateService extends CrudService<MesProductCateDao, MesPro
 		return false;
 	}
 
-//	// 获取工件码类型
-//	public MesProductCate getCateBySn(String sn){
+	// 获取工件码类型
+	public MesProductCate getCateBySn(String sn,String productCate){
+		MesProductCate mesProductCate = new MesProductCate();
+		mesProductCate.setStatus("0");
+		mesProductCate.setSn(productCate);
+		List<MesProductCate> lists = findList(mesProductCate);
+		if(ListUtils.isEmpty(lists)){
+			return null;
+		}
+
+		for(MesProductCate mesProductModel2 : lists){
+			Boolean ret = CommonUitl.checkSnByModel(sn,mesProductModel2.getSpec(),mesProductModel2.getSpecStart(),mesProductModel2.getLength());
+			if(ret){
+				return mesProductModel2;
+			}
+		}
+
+		return null;
+	}
+	// 获取工件码类型
+//	public List<MesProductCate> getCateBySn(String sn){
 //		MesProductCate mesProductModel = new MesProductCate();
 //		mesProductModel.setStatus("0");
 //		List<MesProductCate> lists = findList(mesProductModel);
@@ -150,34 +169,16 @@ public class MesProductCateService extends CrudService<MesProductCateDao, MesPro
 //			return null;
 //		}
 //
-//		for(MesProductCate mesProductModel2 : lists){
+//		Iterator<MesProductCate> iterator = lists.iterator();
+//		while(((Iterator<?>) iterator).hasNext()){
+//			MesProductCate mesProductModel2 = iterator.next();
 //			Boolean ret = CommonUitl.checkSnByModel(sn,mesProductModel2.getSpec(),mesProductModel2.getSpecStart(),mesProductModel2.getLength());
-//			if(ret){
-//				return mesProductModel2;
+//			if(!ret){
+//				iterator.remove();
 //			}
 //		}
 //
-//		return null;
+//		return lists.isEmpty() ? null : lists;
 //	}
-	// 获取工件码类型
-	public List<MesProductCate> getCateBySn(String sn){
-		MesProductCate mesProductModel = new MesProductCate();
-		mesProductModel.setStatus("0");
-		List<MesProductCate> lists = findList(mesProductModel);
-		if(ListUtils.isEmpty(lists)){
-			return null;
-		}
-
-		Iterator<MesProductCate> iterator = lists.iterator();
-		while(((Iterator<?>) iterator).hasNext()){
-			MesProductCate mesProductModel2 = iterator.next();
-			Boolean ret = CommonUitl.checkSnByModel(sn,mesProductModel2.getSpec(),mesProductModel2.getSpecStart(),mesProductModel2.getLength());
-			if(!ret){
-				iterator.remove();
-			}
-		}
-
-		return lists.isEmpty() ? null : lists;
-	}
 
 }

+ 2 - 1
src/main/java/com/jeesite/modules/mes/service/MesProductRecordService.java

@@ -146,9 +146,10 @@ public class MesProductRecordService extends CrudService<MesProductRecordDao, Me
 	 * @param sn
 	 * @return
 	 */
-	public MesProductRecord findBySn(String sn){
+	public MesProductRecord findBySn(String sn,String lineSn){
 		MesProductRecord mesProductRecord = new MesProductRecord();
 		mesProductRecord.setSn(sn);
+		mesProductRecord.setLineSn(lineSn);
 		return mesProductRecordDao.findInfo(mesProductRecord);
 	}
 

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

@@ -403,7 +403,7 @@ public class MesProductRecordController extends BaseController {
 		}
 
 		if(mesProductRecord.getIsNewRecord()){
-			MesProductRecord mpr = mesProductRecordService.findBySn(mesProductRecord.getSn());
+			MesProductRecord mpr = mesProductRecordService.findBySn(mesProductRecord.getSn(),mesProductRecord.getLineSn());
 			if(mpr != null){
 				return renderResult(Global.FALSE, text("产品记录已存在!"));
 			}
@@ -2933,13 +2933,14 @@ public String check(@RequestBody MesElectricTorque mesElectricTorque,HttpServlet
 	public CommonResp queryProduct(HttpServletRequest request) {
 		CommonResp<String> resp = new CommonResp<>();
 		String sn = request.getParameter("sn");
-		if(StringUtils.isEmpty(sn)){
+		String lineSn= request.getParameter("lineSn");
+		if(StringUtils.isEmpty(sn)&&StringUtils.isEmpty(lineSn)){
 			resp.setResult(Global.FALSE);
 			resp.setMessage("参数错误");
 			return resp;
 		}
 //		String cate = "ZHXT";
-		MesProductRecord mesProductRecord = mesProductRecordService.findBySn(sn);
+		MesProductRecord mesProductRecord = mesProductRecordService.findBySn(sn,lineSn);
 		if(ObjectUtils.isEmpty(mesProductRecord)){
 			resp.setData("0");
 		}else{
@@ -2954,7 +2955,7 @@ public String check(@RequestBody MesElectricTorque mesElectricTorque,HttpServlet
 	@ResponseBody
 	public CommonResp createProduct(HttpServletRequest request) {
 		CommonResp<String> resp = new CommonResp<>();
-//		String mesProductCatesn = request.getParameter("mesProductCatesn");//产线编号
+		String lineSn = request.getParameter("lineSn");//产线编号
 		String sn = request.getParameter("sn");//工件码
 		if(StringUtils.isEmpty(sn)){
 			resp.setResult(Global.FALSE);
@@ -2969,9 +2970,14 @@ public String check(@RequestBody MesElectricTorque mesElectricTorque,HttpServlet
 			return resp;
 		}
 
-		List<MesProductCate> mesProductCateLists = mesProductCateService.getCateBySn(sn);
-				for(MesProductCate mesProductModel : mesProductCateLists){
-					String cate = mesProductModel.getSn();
+		String productCate = mesLineService.findInfoCate(lineSn);
+		MesProductCate mesProductCate = mesProductCateService.getCateBySn(sn, productCate);
+		if(ObjectUtils.isEmpty(mesProductCate)){
+			resp.setResult(Global.FALSE);
+			resp.setMessage("工件码类型未配置");
+			return resp;
+		}
+					String cate = mesProductCate.getSn();
 
 					MesLine mesLine = new MesLine();
 					mesLine.setProductCate(cate);
@@ -2988,10 +2994,10 @@ public String check(@RequestBody MesElectricTorque mesElectricTorque,HttpServlet
 						resp.setMessage("该工件已创建订单,勿重复操作");
 						return resp;
 					}
-
+		System.out.println("==="+mesLine1.getId());
 					// 获取上线工位
 					MesLineProcess mesLineProcess = new MesLineProcess();
-					mesLineProcess.setLineId(mesLine.getId());
+					mesLineProcess.setLineId(mesLine1.getId());
 					mesLineProcess.setType("4");
 					MesLineProcess mesLineProcess1 = mesLineProcessService.findInfo(mesLineProcess);
 					if(ObjectUtils.isEmpty(mesLineProcess1)){
@@ -3024,7 +3030,7 @@ public String check(@RequestBody MesElectricTorque mesElectricTorque,HttpServlet
 						resp.setResult(Global.FALSE);
 						resp.setMessage("该工件创建订单失败");
 					}
-		}
+
 
 		return resp;
 	}
@@ -3241,13 +3247,16 @@ public String check(@RequestBody MesElectricTorque mesElectricTorque,HttpServlet
 	public CommonResp checkProduct(HttpServletRequest request) {
 		CommonResp<Map<String, Object>> resp = new CommonResp<>();
 		String sn = request.getParameter("sn");
+		String lineSn = request.getParameter("lineSn");//XT,mp.zp
 		if(StringUtils.isEmpty(sn)){
 			resp.setResult(Global.FALSE);
 			resp.setMessage("参数错误");
 			return resp;
 		}
 
-		List<MesProductCate> mesProductCate = mesProductCateService.getCateBySn(sn);
+		String productCate = mesLineService.findInfoCate(lineSn);
+
+		MesProductCate mesProductCate = mesProductCateService.getCateBySn(sn, productCate);
 		if(ObjectUtils.isEmpty(mesProductCate)){
 			resp.setResult(Global.FALSE);
 			resp.setMessage("工件码格式错误");
@@ -3259,7 +3268,8 @@ public String check(@RequestBody MesElectricTorque mesElectricTorque,HttpServlet
 		MesProductRecord mesProductRecord = new MesProductRecord();
 		mesProductRecord.getSqlMap().getWhere()
 				.and("craft", QueryType.EQ,"100000")
-				.and("sn", QueryType.EQ,sn);
+				.and("sn", QueryType.EQ,sn)
+				.and("line_sn", QueryType.EQ,lineSn);
 		List<MesProductRecord> lists = mesProductRecordService.findList(mesProductRecord);
 		map.put("lists", lists);
 		resp.setData(map);
@@ -3273,6 +3283,7 @@ public String check(@RequestBody MesElectricTorque mesElectricTorque,HttpServlet
 	public CommonResp editProduct(HttpServletRequest request) {
 		CommonResp<String> resp = new CommonResp<>();
 		String sn = request.getParameter("sn");
+		String lineSn = request.getParameter("lineSn");
 		String oprno = request.getParameter("oprno");
 		String content = request.getParameter("content");
 		if(StringUtils.isEmpty(sn) || StringUtils.isEmpty(oprno) || StringUtils.isEmpty(content)){
@@ -3286,9 +3297,7 @@ public String check(@RequestBody MesElectricTorque mesElectricTorque,HttpServlet
 			return resp;
 		}
 
-		String cate = "ZHXT";
-
-		MesProductRecord mesProductRecord2 = mesProductRecordService.findBySn(sn);
+		MesProductRecord mesProductRecord2 = mesProductRecordService.findBySn(sn,lineSn);
 		if(ObjectUtils.isEmpty(mesProductRecord2)){
 			resp.setResult(Global.FALSE);
 			resp.setMessage("工件信息不存在");
@@ -3298,6 +3307,7 @@ public String check(@RequestBody MesElectricTorque mesElectricTorque,HttpServlet
 		mesProductRecord.setCraft("100000");
 		mesProductRecord.setOprno(oprno);
 		mesProductRecord.setSn(sn);
+		mesProductRecord.setLineSn(lineSn);
 		MesProductRecord mesProductRecord1 =  mesProductRecordService.findInfo(mesProductRecord);
 		String contentOld = mesProductRecord1.getContent();
 		mesProductRecord1.setContent(content);

+ 4 - 4
src/main/resources/mappings/modules/mes/MesProductDao.xml

@@ -1,7 +1,7 @@
 <?xml version="1.0" encoding="UTF-8" ?>
 <!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
 <mapper namespace="com.jeesite.modules.mes.dao.MesProductDao">
-	
+
 	<!-- 查询数据
 	<select id="findList" resultType="MesProduct">
 		SELECT ${sqlMap.column.toSql()}
@@ -15,7 +15,7 @@
 	<select id="findInfo" resultType="com.jeesite.modules.mes.entity.MesProduct">
 		SELECT ${sqlMap.column.toSql()}
 		FROM ${sqlMap.table.toSql()}
-		WHERE sn = #{sn}
+		WHERE sn = #{sn} and  line_sn= #{lineSn}
 		ORDER BY ${sqlMap.order.toSql()}
 		LIMIT 1
 	</select>
@@ -25,5 +25,5 @@
 		FROM mes_product
 		WHERE batch_sn=#{batchSn}
 	</select>
-	
-</mapper>
+
+</mapper>