Ver código fonte

拍照提交更改

day01-init 5 dias atrás
pai
commit
f41aa0c681

+ 13 - 0
src/main/java/com/jeesite/modules/mes/dao/MesProductPhotoSideDao.java

@@ -0,0 +1,13 @@
+package com.jeesite.modules.mes.dao;
+
+import com.jeesite.common.dao.CrudDao;
+import com.jeesite.common.mybatis.annotation.MyBatisDao;
+import com.jeesite.modules.mes.entity.MesProductPhotoSide;
+
+/**
+ * OP520正反面拍照子工位DAO
+ */
+@MyBatisDao
+public interface MesProductPhotoSideDao extends CrudDao<MesProductPhotoSide> {
+	MesProductPhotoSide findInfo(MesProductPhotoSide mesProductPhotoSide);
+}

+ 93 - 0
src/main/java/com/jeesite/modules/mes/entity/MesProductPhotoSide.java

@@ -0,0 +1,93 @@
+package com.jeesite.modules.mes.entity;
+
+import com.jeesite.common.entity.DataEntity;
+import com.jeesite.common.mybatis.annotation.Column;
+import com.jeesite.common.mybatis.annotation.Table;
+import com.jeesite.common.mybatis.mapper.query.QueryType;
+
+import javax.validation.constraints.Size;
+
+/**
+ * OP520正反面拍照子工位Entity
+ */
+@Table(name="mes_product_photo_side", alias="a", label="OP520正反面拍照子工位", columns={
+		@Column(name="id", attrName="id", label="id", isPK=true),
+		@Column(name="sn", attrName="sn", label="工件码", queryType=QueryType.LIKE),
+		@Column(name="line_sn", attrName="lineSn", label="产线编号"),
+		@Column(name="oprno", attrName="oprno", label="工位号"),
+		@Column(name="side_type", attrName="sideType", label="正反面"),
+		@Column(name="content", attrName="content", label="结果"),
+		@Column(name="create_by", attrName="createBy", label="create_by", isUpdate=false, isQuery=false),
+		@Column(name="create_date", attrName="createDate", label="创建时间", isUpdate=false, isQuery=false, isUpdateForce=true),
+		@Column(name="update_by", attrName="updateBy", label="update_by", isQuery=false),
+		@Column(name="update_date", attrName="updateDate", label="update_date", isQuery=false, isUpdateForce=true),
+	}, orderBy="a.update_date DESC"
+)
+public class MesProductPhotoSide extends DataEntity<MesProductPhotoSide> {
+
+	private static final long serialVersionUID = 1L;
+	public static final String OPRNO_FRONT = "OP520A";
+	public static final String OPRNO_BACK = "OP520B";
+	public static final String OPRNO_PARENT = "OP520";
+	public static final String SIDE_FRONT = "1";
+	public static final String SIDE_BACK = "0";
+
+	private String sn;
+	private String lineSn;
+	private String oprno;
+	private String sideType;
+	private String content;
+
+	public MesProductPhotoSide() {
+		this(null);
+	}
+
+	public MesProductPhotoSide(String id){
+		super(id);
+	}
+
+	@Size(min=0, max=50, message="工件码长度不能超过 50 个字符")
+	public String getSn() {
+		return sn;
+	}
+
+	public void setSn(String sn) {
+		this.sn = sn;
+	}
+
+	@Size(min=0, max=2, message="产线编号长度不能超过 2 个字符")
+	public String getLineSn() {
+		return lineSn;
+	}
+
+	public void setLineSn(String lineSn) {
+		this.lineSn = lineSn;
+	}
+
+	@Size(min=0, max=20, message="工位号长度不能超过 20 个字符")
+	public String getOprno() {
+		return oprno;
+	}
+
+	public void setOprno(String oprno) {
+		this.oprno = oprno;
+	}
+
+	@Size(min=0, max=1, message="正反面标识长度不能超过 1 个字符")
+	public String getSideType() {
+		return sideType;
+	}
+
+	public void setSideType(String sideType) {
+		this.sideType = sideType;
+	}
+
+	@Size(min=0, max=20, message="结果长度不能超过 20 个字符")
+	public String getContent() {
+		return content;
+	}
+
+	public void setContent(String content) {
+		this.content = content;
+	}
+}

+ 9 - 2
src/main/java/com/jeesite/modules/mes/service/MesGp12RecordService.java

@@ -150,9 +150,16 @@ public class MesGp12RecordService extends CrudService<MesGp12RecordDao, MesGp12R
 
 		CommonResp<String> resp = new CommonResp<>();
 
-		if (files.length < 6) {
+		int minFiles = 6;
+		if ("OP520B".equals(mesGp12Record.getOprno())) {
+			minFiles = 1;
+		} else if ("OP520A".equals(mesGp12Record.getOprno())) {
+			minFiles = 5;
+		}
+		if (files.length < minFiles) {
 			resp.setResult(Global.FALSE);
-			resp.setMessage("上传图片少于6张,请重新上传!");
+			resp.setMessage("上传图片少于" + minFiles + "张,请重新上传!");
+			return resp;
 		}
 		if (StringUtils.isEmpty(mesGp12Record.getLineSn())) {
 			resp.setResult(Global.FALSE);

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

@@ -276,7 +276,7 @@ public class MesProductCcdService extends CrudService<MesProductCcdDao, MesProdu
 		paramsResp1.setVal(userCode);
 		params.add(paramsResp1);
 
-		try{
+		try{d
 			// 2.判断物料批次是否符合绑定
 			List<BindMaterialResp> bmlists = new ArrayList<>();
 			mesProductRecordService.updateRecordResult(sn,oprno,craft,"",result,userCode,params,lineSn,true,bmlists);

+ 113 - 0
src/main/java/com/jeesite/modules/mes/service/MesProductPhotoSideService.java

@@ -0,0 +1,113 @@
+package com.jeesite.modules.mes.service;
+
+import com.jeesite.common.lang.StringUtils;
+import com.jeesite.common.service.CrudService;
+import com.jeesite.modules.mes.dao.MesProductPhotoSideDao;
+import com.jeesite.modules.mes.entity.MesProductPhotoSide;
+import com.jeesite.modules.mes.resp.BindMaterialResp;
+import com.jeesite.modules.mes.resp.ParamsResp;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Service;
+import org.springframework.transaction.annotation.Transactional;
+import org.springframework.util.ObjectUtils;
+
+import java.util.List;
+
+/**
+ * OP520正反面拍照子工位Service
+ */
+@Service
+public class MesProductPhotoSideService extends CrudService<MesProductPhotoSideDao, MesProductPhotoSide> {
+
+	@Autowired
+	private MesProductPhotoSideDao mesProductPhotoSideDao;
+
+	@Autowired
+	private MesProductRecordService mesProductRecordService;
+
+	public MesProductPhotoSide findInfo(MesProductPhotoSide query) {
+		return mesProductPhotoSideDao.findInfo(query);
+	}
+
+	/**
+	 * OP520 子工位质量提交:OP520A/OP520B 分别提交,两面均为 OK 后更新 OP520 主工位。
+	 *
+	 * @return true 表示已更新 OP520 主工位;false 表示仅更新子工位,主工位待另一面完成
+	 */
+	@Transactional
+	public boolean submitOp520Side(String sn, String oprno, String lineSn, String content,
+								   String userCode, List<ParamsResp> params, List<BindMaterialResp> bmlists) {
+		if (!MesProductPhotoSide.OPRNO_FRONT.equals(oprno) && !MesProductPhotoSide.OPRNO_BACK.equals(oprno)) {
+			return false;
+		}
+
+		MesProductPhotoSide query = new MesProductPhotoSide();
+		query.setSn(sn);
+		query.setOprno(oprno);
+		query.setLineSn(lineSn);
+		MesProductPhotoSide current = findInfo(query);
+		if (ObjectUtils.isEmpty(current)) {
+			ensureOp520SideRecords(sn, lineSn);
+			current = findInfo(query);
+		}
+		if (ObjectUtils.isEmpty(current)) {
+			return false;
+		}
+		current.setContent(content);
+		save(current);
+
+		MesProductPhotoSide frontQuery = new MesProductPhotoSide();
+		frontQuery.setSn(sn);
+		frontQuery.setLineSn(lineSn);
+		frontQuery.setOprno(MesProductPhotoSide.OPRNO_FRONT);
+		MesProductPhotoSide front = findInfo(frontQuery);
+
+		MesProductPhotoSide backQuery = new MesProductPhotoSide();
+		backQuery.setSn(sn);
+		backQuery.setLineSn(lineSn);
+		backQuery.setOprno(MesProductPhotoSide.OPRNO_BACK);
+		MesProductPhotoSide back = findInfo(backQuery);
+
+		if (ObjectUtils.isEmpty(front) || ObjectUtils.isEmpty(back)) {
+			return false;
+		}
+		if (StringUtils.isEmpty(front.getContent()) || StringUtils.isEmpty(back.getContent())) {
+			return false;
+		}
+		if (!"OK".equals(front.getContent()) || !"OK".equals(back.getContent())) {
+			return false;
+		}
+
+		mesProductRecordService.updateRecordResult(sn, MesProductPhotoSide.OPRNO_FRONT, "100000", "",
+				"OK", userCode, params, lineSn, true, bmlists);
+		return true;
+	}
+
+	private void ensureOp520SideRecords(String sn, String lineSn) {
+		MesProductPhotoSide frontQuery = new MesProductPhotoSide();
+		frontQuery.setSn(sn);
+		frontQuery.setLineSn(lineSn);
+		frontQuery.setOprno(MesProductPhotoSide.OPRNO_FRONT);
+		if (ObjectUtils.isEmpty(findInfo(frontQuery))) {
+			MesProductPhotoSide front = new MesProductPhotoSide();
+			front.setSn(sn);
+			front.setLineSn(lineSn);
+			front.setOprno(MesProductPhotoSide.OPRNO_FRONT);
+			front.setSideType(MesProductPhotoSide.SIDE_FRONT);
+			save(front);
+		}
+
+		MesProductPhotoSide backQuery = new MesProductPhotoSide();
+		backQuery.setSn(sn);
+		backQuery.setLineSn(lineSn);
+		backQuery.setOprno(MesProductPhotoSide.OPRNO_BACK);
+		if (ObjectUtils.isEmpty(findInfo(backQuery))) {
+			MesProductPhotoSide back = new MesProductPhotoSide();
+			back.setSn(sn);
+			back.setLineSn(lineSn);
+			back.setOprno(MesProductPhotoSide.OPRNO_BACK);
+			back.setSideType(MesProductPhotoSide.SIDE_BACK);
+			save(back);
+		}
+	}
+}

+ 26 - 12
src/main/java/com/jeesite/modules/mes/web/MesProductRecordController.java

@@ -210,6 +210,8 @@ public class MesProductRecordController extends BaseController {
 	@Autowired
 	private MesProductOprnoService mesProductOprnoService;
 	@Autowired
+	private MesProductPhotoSideService mesProductPhotoSideService;
+	@Autowired
 	private MesProductGlueService mesProductGlueService;
     @Autowired
     private MesGlueRecordService mesGlueRecordService;
@@ -1679,6 +1681,18 @@ public class MesProductRecordController extends BaseController {
 
 
 
+					// OP520 正反面子工位:OP520A 正面 / OP520B 反面,两面 OK 后更新 OP520
+					if ("OP520A".equals(oprno) || "OP520B".equals(oprno)) {
+						List<BindMaterialResp> bmlists520 = mesLineProcessMaterialService.getBindMaterial(MesProductPhotoSide.OPRNO_FRONT, lineSn);
+						boolean parentUpdated = mesProductPhotoSideService.submitOp520Side(sn, oprno, lineSn, content, userCode, params, bmlists520);
+						if (!parentUpdated) {
+							ret = "RSOK";
+							return ret;
+						}
+						ret = "RSOK";
+						return ret;
+					}
+
 					if (oprnoOld.equals("OP380")){
 						// 查询开始时间
 						MesDeviceTime mesDeviceTime = mesDeviceTimeService.getInfoByOprnoAndSnAndCate(oprno,sn,lineSn);
@@ -2868,6 +2882,8 @@ public class MesProductRecordController extends BaseController {
 			}
 			String check = Global.getConfig("mes.qm.ng.time");
 			if(check.equals("1")){
+
+
 				// 检查是否超过15分钟
 				MesProductQm mpr2 = new MesProductQm();
 				mpr2.setComponentNum(sn);
@@ -2887,9 +2903,7 @@ public class MesProductRecordController extends BaseController {
 					}
 				}
 			}
-
 		}
-
 		// OK当前工位已加工合格/NG当前工位已加工不合格/QN前工位不合格/UD可以加工/其他-该工件不可加工
 		if(ret.equals("RSUD")){
 			resp.setMessage("工件可以加工");
@@ -2905,7 +2919,6 @@ public class MesProductRecordController extends BaseController {
 		return resp;
 	}
 
-
 	@PostMapping(value = "qmresult")
 	@ResponseBody
 	public String qmresult(MesProductQmReq mesProductQmReq,HttpServletRequest request) {
@@ -2935,7 +2948,6 @@ public class MesProductRecordController extends BaseController {
 		if(StringUtils.isEmpty(sn) || StringUtils.isEmpty(oprno) || StringUtils.isEmpty(result) || StringUtils.isEmpty(lineSn)){
 			return renderResult(Global.FALSE, text("参数错误1!"));
 		}
-
 		try{
 			MesProductQm mesProductQm = new MesProductQm();
 			mesProductQm.setOprno(oprno);
@@ -2953,14 +2965,12 @@ public class MesProductRecordController extends BaseController {
 			mesProductQm.setTitle(title);
 			mesProductQm.setRemark(remark);
 			mesProductQmService.add(mesProductQm);
-
 			List<ParamsResp> params = new ArrayList<>();
 			ParamsResp paramsResp1 = new ParamsResp();
 			paramsResp1.setCraft("400001");
 			paramsResp1.setResult("OK");
 			paramsResp1.setVal(userCode);
 			params.add(paramsResp1);
-
 			String content = "NG";
 			if(result.equals("OK")){
 				content="OK";
@@ -3004,22 +3014,16 @@ public class MesProductRecordController extends BaseController {
 	@RequestMapping(value = "workData")
 	@ResponseBody
 	public Page<MesProductRecord> workData(MesProductRecordUser mesProductRecordUser,MesProductRecord mesProductRecord, HttpServletRequest request, HttpServletResponse response) {
-
 		Date edate = new Date();
-
 		SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
 		Calendar calendar = Calendar.getInstance();
 		calendar.add(Calendar.HOUR, -48); // 减去48小时
 		Date sdate = calendar.getTime();
-
 		mesProductRecord.setUpdateDate_gte(sdate);
 		mesProductRecord.setUpdateDate_lte(edate);
-
 		if(mesProductRecord.getOprno().length() == 5){
 			mesProductRecord.setOprno(mesProductRecord.getOprno()+"A");
 		}
-
-
 		Page page1 = new Page<>(request, response);
 		mesProductRecord.setPage(page1);
 		mesProductRecord.setCraft("100000");
@@ -4136,6 +4140,16 @@ public class MesProductRecordController extends BaseController {
 
 					}
 
+					// OP520 正反面子工位
+					if ("OP520A".equals(oprno) || "OP520B".equals(oprno)) {
+						List<BindMaterialResp> bmlists520 = mesLineProcessMaterialService.getBindMaterial(MesProductPhotoSide.OPRNO_FRONT, lineSn);
+						boolean parentUpdated = mesProductPhotoSideService.submitOp520Side(sn, oprno, lineSn, result, userCode, params, bmlists520);
+						if (!parentUpdated) {
+							return renderResult(Global.TRUE, text("子工位提交成功,等待另一面完成"));
+						}
+						return renderResult(Global.TRUE, text("提交成功"));
+					}
+
 					if (oprnoOld.equals("OP380")){
 						// 查询开始时间
 						MesDeviceTime mesDeviceTime = mesDeviceTimeService.getInfoByOprnoAndSnAndCate(oprno,sn,lineSn);

+ 14 - 0
src/main/resources/mappings/modules/mes/MesProductPhotoSideDao.xml

@@ -0,0 +1,14 @@
+<?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.MesProductPhotoSideDao">
+
+    <select id="findInfo" resultType="com.jeesite.modules.mes.entity.MesProductPhotoSide">
+        SELECT ${sqlMap.column.toSql()}
+        FROM ${sqlMap.table.toSql()}
+        <where>
+            ${sqlMap.where.toSql()}
+        </where>
+        ORDER BY ${sqlMap.order.toSql()}
+        LIMIT 1
+    </select>
+</mapper>