|
|
@@ -17,6 +17,7 @@ import com.jeesite.common.collect.MapUtils;
|
|
|
import com.jeesite.common.lang.DateUtils;
|
|
|
import com.jeesite.common.lang.StringUtils;
|
|
|
import com.jeesite.common.mybatis.mapper.query.QueryType;
|
|
|
+import com.jeesite.common.service.ServiceException;
|
|
|
import com.jeesite.common.utils.excel.ExcelExport;
|
|
|
import com.jeesite.modules.file.entity.FileUpload;
|
|
|
import com.jeesite.modules.file.service.FileUploadService;
|
|
|
@@ -33,6 +34,7 @@ import lombok.extern.slf4j.Slf4j;
|
|
|
import org.apache.shiro.authz.annotation.RequiresPermissions;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.stereotype.Controller;
|
|
|
+import org.springframework.transaction.annotation.Isolation;
|
|
|
import org.springframework.transaction.annotation.Transactional;
|
|
|
import org.springframework.transaction.interceptor.TransactionAspectSupport;
|
|
|
import org.springframework.ui.Model;
|
|
|
@@ -3290,24 +3292,19 @@ public class MesProductRecordController extends BaseController {
|
|
|
// 客户端绑定物料接口
|
|
|
@PostMapping(value = "pcbind")
|
|
|
@ResponseBody
|
|
|
- @Transactional
|
|
|
+ @Transactional(isolation = Isolation.READ_COMMITTED)
|
|
|
public String pcbind(HttpServletRequest request) {
|
|
|
mesLogService.apisavexz(request);
|
|
|
String sn = request.getParameter("sn");
|
|
|
String oprno = request.getParameter("oprno");
|
|
|
String lineSn = request.getParameter("lineSn");
|
|
|
- String userCode = request.getParameter("ucode");
|
|
|
- String craft = request.getParameter("craft");
|
|
|
+ String userCode = StringUtils.trimToEmpty(request.getParameter("ucode"));
|
|
|
String wsn = request.getParameter("wsn");
|
|
|
|
|
|
- String oldOprno = oprno;
|
|
|
- if(oldOprno.length()==5){
|
|
|
- oldOprno += "A";
|
|
|
- }
|
|
|
-
|
|
|
if(StringUtils.isEmpty(sn) || StringUtils.isEmpty(oprno) || StringUtils.isEmpty(lineSn) || StringUtils.isEmpty(wsn)){
|
|
|
return renderResult(Global.FALSE, text("参数错误!"));
|
|
|
}
|
|
|
+ String oldOprno = oprno.length() == 5 ? oprno + "A" : oprno;
|
|
|
|
|
|
sn = mesProductHmbService.formatHmbSn(sn,oprno,lineSn);
|
|
|
|
|
|
@@ -3315,7 +3312,7 @@ public class MesProductRecordController extends BaseController {
|
|
|
if(CommonUitl.formatOprno(oldOprno).equals("OP105")){ // 后膨胀梁打码,检查后面板码是否已被绑定
|
|
|
// 检验工件码
|
|
|
String checkProductSn = Global.getConfig("mes.check.productSn");
|
|
|
- if(checkProductSn.equals("1")){
|
|
|
+ if("1".equals(checkProductSn)){
|
|
|
// 兼容:后梁码规则校验通过(新24位/老28位)或产品型号配置匹配,任一满足即可
|
|
|
if(!CommonUitl.checkProductSnHmb(wsn)){
|
|
|
MesProductModel mesProductModel = mesProductModelService.checkSnObj(wsn);
|
|
|
@@ -3334,49 +3331,53 @@ public class MesProductRecordController extends BaseController {
|
|
|
return renderResult(Global.FALSE, text("底板码与膨胀梁码型号不匹配!"));
|
|
|
}
|
|
|
|
|
|
- // 检查前工件码是否已绑定后面板码
|
|
|
- MesProductHmb mesProductHmb2 = new MesProductHmb();
|
|
|
- mesProductHmb2.setQsn(sn);
|
|
|
- MesProductHmb mesProductHmb3 = mesProductHmbService.findInfo(mesProductHmb2);
|
|
|
- if(!ObjectUtils.isEmpty(mesProductHmb3)){
|
|
|
- return renderResult(Global.FALSE, text("该工件已绑定后面板码"));
|
|
|
+ boolean submitResult = "CZ060".equals(lineSn);
|
|
|
+ if (submitResult) {
|
|
|
+ mesProductRecordService.requireOp105ResultForUpdate(sn, lineSn, oldOprno);
|
|
|
}
|
|
|
|
|
|
- MesProductHmb mesProductHmb = new MesProductHmb();
|
|
|
- mesProductHmb.setSn(wsn);
|
|
|
- MesProductHmb mesProductHmb1 = mesProductHmbService.findInfo(mesProductHmb);
|
|
|
- if(ObjectUtils.isEmpty(mesProductHmb1)){
|
|
|
- // 补录:长码未录入时自动登记为已验证,并一次性写入绑定关系
|
|
|
- MesProductHmb mesProductHmbNew = new MesProductHmb();
|
|
|
- mesProductHmbNew.setSn(wsn);
|
|
|
- mesProductHmbNew.setState("1");
|
|
|
- mesProductHmbNew.setQsn(sn);
|
|
|
- mesProductHmbNew.setLineSn(lineSn);
|
|
|
- mesProductHmbNew.setCreateBy(userCode);
|
|
|
- mesProductHmbNew.setUpdateBy(userCode);
|
|
|
- mesProductHmbService.save(mesProductHmbNew);
|
|
|
- logger.info("pcbind补录并绑定长码:" + wsn + ",短码:" + sn + ",lineSn:" + lineSn + ",user:" + userCode);
|
|
|
- return renderResult(Global.TRUE, text("操作成功!"));
|
|
|
+ MesProductHmb boundQuery = new MesProductHmb();
|
|
|
+ boundQuery.setQsn(sn);
|
|
|
+ MesProductHmb bound = mesProductHmbService.findInfo(boundQuery);
|
|
|
+ boolean sameBinding = submitResult && bound != null && wsn.equals(bound.getSn())
|
|
|
+ && lineSn.equals(bound.getLineSn());
|
|
|
+ if (bound != null && !sameBinding) {
|
|
|
+ return renderResult(Global.FALSE, text("该工件已绑定后面板码"));
|
|
|
}
|
|
|
|
|
|
- if(mesProductHmb1.getState().equals("0")){
|
|
|
+ MesProductHmb hmb = mesProductHmbService.findForBinding(wsn);
|
|
|
+ if (hmb == null) {
|
|
|
+ hmb = new MesProductHmb();
|
|
|
+ hmb.setSn(wsn);
|
|
|
+ hmb.setState("1");
|
|
|
+ hmb.setCreateBy(userCode);
|
|
|
+ hmb.setUpdateBy(userCode);
|
|
|
+ }
|
|
|
+ if (!"1".equals(hmb.getState())) {
|
|
|
return renderResult(Global.FALSE, text("后面板码未验证"));
|
|
|
}
|
|
|
-
|
|
|
- if(!StringUtils.isEmpty(mesProductHmb1.getQsn())){
|
|
|
+ boolean alreadyBound = sameBinding && sn.equals(hmb.getQsn()) && lineSn.equals(hmb.getLineSn());
|
|
|
+ if (StringUtils.isNotEmpty(hmb.getQsn()) && !alreadyBound) {
|
|
|
return renderResult(Global.FALSE, text("后面板码已被绑定"));
|
|
|
}
|
|
|
-
|
|
|
- mesProductHmb1.setQsn(sn);
|
|
|
- mesProductHmb1.setLineSn(lineSn);
|
|
|
- mesProductHmbService.save(mesProductHmb1);
|
|
|
+ if (!alreadyBound) {
|
|
|
+ hmb.setQsn(sn);
|
|
|
+ hmb.setLineSn(lineSn);
|
|
|
+ mesProductHmbService.save(hmb);
|
|
|
+ }
|
|
|
+ if (submitResult) {
|
|
|
+ List<BindMaterialResp> materials = mesLineProcessMaterialService.getBindMaterial(oldOprno, lineSn);
|
|
|
+ mesProductRecordService.updateRecordResult(request, sn, oldOprno, "100000", wsn, "OK",
|
|
|
+ userCode, new ArrayList<>(), lineSn, true, materials, "0", false);
|
|
|
+ }
|
|
|
}else{
|
|
|
return renderResult(Global.FALSE, text("工位不支持绑定!"));
|
|
|
}
|
|
|
- // 本站 OK 由 pcresult 提交时写入,此处不再写记录
|
|
|
}catch (Exception e){
|
|
|
- logger.info(e.getMessage());
|
|
|
- return renderResult(Global.FALSE, text("操作失败!"));
|
|
|
+ TransactionAspectSupport.currentTransactionStatus().setRollbackOnly();
|
|
|
+ logger.warn("OP105 码绑定或结果提交失败", e);
|
|
|
+ String message = e instanceof ServiceException ? e.getMessage() : "操作失败!";
|
|
|
+ return renderResult(Global.FALSE, text(message));
|
|
|
}
|
|
|
|
|
|
return renderResult(Global.TRUE, text("操作成功!"));
|
|
|
@@ -3408,21 +3409,28 @@ public class MesProductRecordController extends BaseController {
|
|
|
|
|
|
try{
|
|
|
if(CommonUitl.formatOprno(oldOprno).equals("OP105")){ // 后膨胀梁打码,检查后面板码是否已被绑定
|
|
|
- MesProductHmb mesProductHmb = new MesProductHmb();
|
|
|
- mesProductHmb.setSn(wsn);
|
|
|
- mesProductHmb.setQsn(sn);
|
|
|
- MesProductHmb mesProductHmb1 = mesProductHmbService.findInfo(mesProductHmb);
|
|
|
- if(ObjectUtils.isEmpty(mesProductHmb1)){
|
|
|
+ boolean cz060 = "CZ060".equals(lineSn);
|
|
|
+ if (cz060) {
|
|
|
+ mesProductRecordService.requireOp105ResultForUpdate(sn, lineSn, oldOprno);
|
|
|
+ }
|
|
|
+ MesProductHmb hmb = mesProductHmbService.findForBinding(wsn);
|
|
|
+ if (hmb == null || !sn.equals(hmb.getQsn()) || (cz060 && !lineSn.equals(hmb.getLineSn()))) {
|
|
|
return renderResult(Global.FALSE, text("后面板码未录入系统或未绑定"));
|
|
|
}
|
|
|
|
|
|
- mesProductHmb1.setQsn("");
|
|
|
- mesProductHmbService.save(mesProductHmb1);
|
|
|
+ hmb.setQsn("");
|
|
|
+ mesProductHmbService.save(hmb);
|
|
|
+ if (cz060 && !"100000".equals(craft)) {
|
|
|
+ mesProductRecordService.updateRecord(sn, oldOprno, "100000", "", "UDF", userCode, lineSn);
|
|
|
+ }
|
|
|
+ if (!cz060 || StringUtils.isNotBlank(craft)) {
|
|
|
+ mesProductRecordService.updateRecord(sn, oldOprno, craft, "", "UDF", userCode, lineSn);
|
|
|
+ }
|
|
|
}else{
|
|
|
return renderResult(Global.FALSE, text("工位不支持解绑!"));
|
|
|
}
|
|
|
- mesProductRecordService.updateRecord(sn,oldOprno,craft,"","UDF",userCode,lineSn);
|
|
|
}catch (Exception e){
|
|
|
+ TransactionAspectSupport.currentTransactionStatus().setRollbackOnly();
|
|
|
logger.info(e.getMessage());
|
|
|
return renderResult(Global.FALSE, text("操作失败!"));
|
|
|
}
|