|
@@ -0,0 +1,199 @@
|
|
|
|
|
+package com.jeesite.modules.mes.web;
|
|
|
|
|
+
|
|
|
|
|
+import java.util.ArrayList;
|
|
|
|
|
+import java.util.HashMap;
|
|
|
|
|
+import java.util.List;
|
|
|
|
|
+import java.util.Map;
|
|
|
|
|
+import javax.servlet.http.HttpServletRequest;
|
|
|
|
|
+import javax.servlet.http.HttpServletResponse;
|
|
|
|
|
+
|
|
|
|
|
+import com.jeesite.common.lang.ObjectUtils;
|
|
|
|
|
+import com.jeesite.common.lang.StringUtils;
|
|
|
|
|
+import com.jeesite.common.mybatis.mapper.query.QueryType;
|
|
|
|
|
+import com.jeesite.modules.erp.entity.MesProductOrder;
|
|
|
|
|
+import com.jeesite.modules.erp.service.MesProductOrderService;
|
|
|
|
|
+import com.jeesite.modules.mes.entity.MesLine;
|
|
|
|
|
+import com.jeesite.modules.mes.entity.MesProduct;
|
|
|
|
|
+import com.jeesite.modules.mes.resp.CommonResp;
|
|
|
|
|
+import com.jeesite.modules.mes.service.MesLineService;
|
|
|
|
|
+import com.jeesite.modules.mes.service.MesProductService;
|
|
|
|
|
+import com.jeesite.modules.sys.entity.User;
|
|
|
|
|
+import com.jeesite.modules.sys.utils.UserUtils;
|
|
|
|
|
+import com.jeesite.modules.utils.ErrorMsg;
|
|
|
|
|
+import org.apache.shiro.authz.annotation.RequiresPermissions;
|
|
|
|
|
+import org.springframework.beans.factory.annotation.Autowired;
|
|
|
|
|
+import org.springframework.context.annotation.Lazy;
|
|
|
|
|
+import org.springframework.stereotype.Controller;
|
|
|
|
|
+import org.springframework.ui.Model;
|
|
|
|
|
+import org.springframework.validation.annotation.Validated;
|
|
|
|
|
+import org.springframework.web.bind.annotation.ModelAttribute;
|
|
|
|
|
+import org.springframework.web.bind.annotation.PostMapping;
|
|
|
|
|
+import org.springframework.web.bind.annotation.RequestMapping;
|
|
|
|
|
+import org.springframework.web.bind.annotation.ResponseBody;
|
|
|
|
|
+
|
|
|
|
|
+import com.jeesite.common.config.Global;
|
|
|
|
|
+import com.jeesite.common.entity.Page;
|
|
|
|
|
+import com.jeesite.common.web.BaseController;
|
|
|
|
|
+import com.jeesite.modules.mes.entity.MesOrderSnZp;
|
|
|
|
|
+import com.jeesite.modules.mes.service.MesOrderSnZpService;
|
|
|
|
|
+
|
|
|
|
|
+/**
|
|
|
|
|
+ * 装配订单工件绑定Controller
|
|
|
|
|
+ * @author sxl
|
|
|
|
|
+ * @version 2026-09-01
|
|
|
|
|
+ */
|
|
|
|
|
+@Controller
|
|
|
|
|
+@RequestMapping(value = "${adminPath}/mes/mesOrderSnZp")
|
|
|
|
|
+public class MesOrderSnZpController extends BaseController {
|
|
|
|
|
+
|
|
|
|
|
+ @Autowired
|
|
|
|
|
+ private MesOrderSnZpService mesOrderSnZpService;
|
|
|
|
|
+ @Autowired
|
|
|
|
|
+ private MesProductOrderService mesProductOrderService;
|
|
|
|
|
+ @Autowired
|
|
|
|
|
+ private MesProductService mesProductService;
|
|
|
|
|
+ @Autowired
|
|
|
|
|
+ private MesLineService mesLineService;
|
|
|
|
|
+ @Lazy
|
|
|
|
|
+ @Autowired
|
|
|
|
|
+ private MesProductRecordController mesProductRecordController;
|
|
|
|
|
+
|
|
|
|
|
+ @ModelAttribute
|
|
|
|
|
+ public MesOrderSnZp get(String id, boolean isNewRecord) {
|
|
|
|
|
+ return mesOrderSnZpService.get(id, isNewRecord);
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ @RequiresPermissions("mes:mesOrderSnZp:view")
|
|
|
|
|
+ @RequestMapping(value = {"list", ""})
|
|
|
|
|
+ public String list(MesOrderSnZp mesOrderSnZp, Model model) {
|
|
|
|
|
+ model.addAttribute("mesOrderSnZp", mesOrderSnZp);
|
|
|
|
|
+ return "modules/mes/mesOrderSnZpList";
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ @RequiresPermissions("mes:mesOrderSnZp:view")
|
|
|
|
|
+ @RequestMapping(value = "listData")
|
|
|
|
|
+ @ResponseBody
|
|
|
|
|
+ public Page<MesOrderSnZp> listData(MesOrderSnZp mesOrderSnZp, HttpServletRequest request, HttpServletResponse response) {
|
|
|
|
|
+ mesOrderSnZp.setPage(new Page<>(request, response));
|
|
|
|
|
+ return mesOrderSnZpService.findPage(mesOrderSnZp);
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ @RequiresPermissions("mes:mesOrderSnZp:view")
|
|
|
|
|
+ @RequestMapping(value = "form")
|
|
|
|
|
+ public String form(MesOrderSnZp mesOrderSnZp, Model model) {
|
|
|
|
|
+ model.addAttribute("mesOrderSnZp", mesOrderSnZp);
|
|
|
|
|
+ return "modules/mes/mesOrderSnZpForm";
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ @RequiresPermissions("mes:mesOrderSnZp:edit")
|
|
|
|
|
+ @PostMapping(value = "save")
|
|
|
|
|
+ @ResponseBody
|
|
|
|
|
+ public String save(@Validated MesOrderSnZp mesOrderSnZp) {
|
|
|
|
|
+ mesOrderSnZpService.save(mesOrderSnZp);
|
|
|
|
|
+ return renderResult(Global.TRUE, text("保存装配订单工件绑定成功!"));
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ @RequiresPermissions("mes:mesOrderSnZp:edit")
|
|
|
|
|
+ @RequestMapping(value = "delete")
|
|
|
|
|
+ @ResponseBody
|
|
|
|
|
+ public String delete(MesOrderSnZp mesOrderSnZp) {
|
|
|
|
|
+ mesOrderSnZpService.delete(mesOrderSnZp);
|
|
|
|
|
+ return renderResult(Global.TRUE, text("删除装配订单工件绑定成功!"));
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ /**
|
|
|
|
|
+ * 装配订单绑定工件码(OP400 工位质量校验通过后方可绑定)
|
|
|
|
|
+ */
|
|
|
|
|
+ @RequestMapping(value = "bandSn")
|
|
|
|
|
+ @ResponseBody
|
|
|
|
|
+ public String bandSn(MesOrderSnZp mesOrderSnZp) {
|
|
|
|
|
+ if (mesOrderSnZp == null || StringUtils.isBlank(mesOrderSnZp.getOrderZp())) {
|
|
|
|
|
+ return renderResult(Global.FALSE, text("订单编码不能为空!"));
|
|
|
|
|
+ }
|
|
|
|
|
+ if (StringUtils.isBlank(mesOrderSnZp.getSn())) {
|
|
|
|
|
+ return renderResult(Global.FALSE, text("工件码不能为空!"));
|
|
|
|
|
+ }
|
|
|
|
|
+ String sn = mesOrderSnZp.getSn();
|
|
|
|
|
+
|
|
|
|
|
+ MesProduct mesProductQuery = new MesProduct();
|
|
|
|
|
+ mesProductQuery.setSn(sn);
|
|
|
|
|
+ List<MesProduct> productList = mesProductService.findList(mesProductQuery);
|
|
|
|
|
+ if (productList == null || productList.isEmpty() || ObjectUtils.isEmpty(productList.get(0))) {
|
|
|
|
|
+ return renderResult(Global.FALSE, text("工件不存在!"));
|
|
|
|
|
+ }
|
|
|
|
|
+ MesProduct mesProduct = productList.get(0);
|
|
|
|
|
+ MesLine mesLine = new MesLine();
|
|
|
|
|
+ mesLine.setProductCate(mesProduct.getCate());
|
|
|
|
|
+ mesLine.setStatus("0");
|
|
|
|
|
+ MesLine lineInfo = mesLineService.findInfo(mesLine);
|
|
|
|
|
+ if (ObjectUtils.isEmpty(lineInfo) || StringUtils.isEmpty(lineInfo.getSn())) {
|
|
|
|
|
+ return renderResult(Global.FALSE, text("产线信息不存在!"));
|
|
|
|
|
+ }
|
|
|
|
|
+ String lineSn = lineInfo.getSn();
|
|
|
|
|
+
|
|
|
|
|
+ String userCode = "";
|
|
|
|
|
+ User user = UserUtils.getUser();
|
|
|
|
|
+ if (user != null && StringUtils.isNotEmpty(user.getUserCode())) {
|
|
|
|
|
+ userCode = user.getUserCode();
|
|
|
|
|
+ }
|
|
|
|
|
+ String ret = mesProductRecordController.checkQualityCommon("OP400", sn, lineSn, userCode);
|
|
|
|
|
+ String checkret = ret.substring(3, 5);
|
|
|
|
|
+ if (!"UD".equals(checkret) && !"OK".equalsIgnoreCase(checkret) && !"NG".equalsIgnoreCase(checkret)) {
|
|
|
|
|
+ String lx = ret.substring(0, 3);
|
|
|
|
|
+ return renderResult(Global.FALSE, text(ErrorMsg.getErrorMsg(checkret, lx)));
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ MesOrderSnZp query = new MesOrderSnZp();
|
|
|
|
|
+ query.setSn(sn);
|
|
|
|
|
+ List<MesOrderSnZp> list = mesOrderSnZpService.findList(query);
|
|
|
|
|
+ if (!list.isEmpty()) {
|
|
|
|
|
+ return renderResult(Global.FALSE, text("该工件已和装配订单绑定!"));
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ MesProductOrder orderQuery = new MesProductOrder();
|
|
|
|
|
+ orderQuery.setSn(mesOrderSnZp.getOrderZp());
|
|
|
|
|
+ List<MesProductOrder> orderList = mesProductOrderService.findList(orderQuery);
|
|
|
|
|
+ if (orderList == null || orderList.isEmpty() || ObjectUtils.isEmpty(orderList.get(0))) {
|
|
|
|
|
+ return renderResult(Global.FALSE, text("生产订单不存在!"));
|
|
|
|
|
+ }
|
|
|
|
|
+ Integer orderNums = orderList.get(0).getNums();
|
|
|
|
|
+ if (orderNums == null) {
|
|
|
|
|
+ return renderResult(Global.FALSE, text("生产订单数量未配置!"));
|
|
|
|
|
+ }
|
|
|
|
|
+ MesOrderSnZp boundQuery = new MesOrderSnZp();
|
|
|
|
|
+ boundQuery.setOrderZp(mesOrderSnZp.getOrderZp());
|
|
|
|
|
+ long boundCount = mesOrderSnZpService.findCount(boundQuery);
|
|
|
|
|
+ if (boundCount >= orderNums) {
|
|
|
|
|
+ return renderResult(Global.FALSE, text("该订单已绑定数量已达生产数量,不允许再绑定!"));
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ mesOrderSnZpService.save(mesOrderSnZp);
|
|
|
|
|
+ return renderResult(Global.TRUE, text("保存成功!"));
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ /**
|
|
|
|
|
+ * 装配生产订单列表(产线编号以 N0101 开头)
|
|
|
|
|
+ */
|
|
|
|
|
+ @RequestMapping(value = "orderList")
|
|
|
|
|
+ @ResponseBody
|
|
|
|
|
+ public CommonResp<List<Map<String, Object>>> orderList(MesProductOrder mesProductOrder) {
|
|
|
|
|
+ CommonResp<List<Map<String, Object>>> resp = new CommonResp<>();
|
|
|
|
|
+ mesProductOrder.setState("1");
|
|
|
|
|
+ mesProductOrder.getSqlMap().getWhere().and("a.line_sn", QueryType.RIGHT_LIKE, "N0101");
|
|
|
|
|
+ List<MesProductOrder> list = mesProductOrderService.findList(mesProductOrder);
|
|
|
|
|
+ List<Map<String, Object>> data = new ArrayList<>();
|
|
|
|
|
+ for (MesProductOrder order : list) {
|
|
|
|
|
+ Map<String, Object> item = new HashMap<>();
|
|
|
|
|
+ item.put("orderId", order.getSn());
|
|
|
|
|
+ MesOrderSnZp query = new MesOrderSnZp();
|
|
|
|
|
+ query.setOrderZp(order.getSn());
|
|
|
|
|
+ item.put("qty", mesOrderSnZpService.findCount(query));
|
|
|
|
|
+ data.add(item);
|
|
|
|
|
+ }
|
|
|
|
|
+ resp.setData(data);
|
|
|
|
|
+ resp.setResult(Global.TRUE);
|
|
|
|
|
+ resp.setMessage("操作成功!");
|
|
|
|
|
+ return resp;
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+}
|