|
|
@@ -0,0 +1,148 @@
|
|
|
+package com.jeesite.modules.mes.web;
|
|
|
+
|
|
|
+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.modules.mes.entity.MesProductRecord;
|
|
|
+import com.jeesite.modules.mes.service.MesProductRecordService;
|
|
|
+import com.jeesite.modules.sys.entity.User;
|
|
|
+import com.jeesite.modules.sys.utils.UserUtils;
|
|
|
+import org.apache.shiro.authz.annotation.RequiresPermissions;
|
|
|
+import org.springframework.beans.factory.annotation.Autowired;
|
|
|
+import org.springframework.stereotype.Controller;
|
|
|
+import org.springframework.transaction.annotation.Transactional;
|
|
|
+import org.springframework.transaction.interceptor.TransactionAspectSupport;
|
|
|
+import org.springframework.ui.Model;
|
|
|
+import org.springframework.validation.annotation.Validated;
|
|
|
+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.MesProductJyny;
|
|
|
+import com.jeesite.modules.mes.service.MesProductJynyService;
|
|
|
+
|
|
|
+/**
|
|
|
+ * 绝缘耐压数据表Controller
|
|
|
+ * @author sxl
|
|
|
+ * @version 2026-08-13
|
|
|
+ */
|
|
|
+@Controller
|
|
|
+@RequestMapping(value = "${adminPath}/mes/mesProductJyny")
|
|
|
+public class MesProductJynyController extends BaseController {
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ private MesProductJynyService mesProductJynyService;
|
|
|
+ @Autowired
|
|
|
+ private MesProductRecordService mesProductRecordService;
|
|
|
+
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 查询列表
|
|
|
+ */
|
|
|
+ @RequiresPermissions("mes:mesProductJyny:view")
|
|
|
+ @RequestMapping(value = {"list", ""})
|
|
|
+ public String list(MesProductJyny mesProductJyny, Model model) {
|
|
|
+ model.addAttribute("mesProductJyny", mesProductJyny);
|
|
|
+ return "modules/mes/mesProductJynyList";
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 查询列表数据
|
|
|
+ */
|
|
|
+ @RequiresPermissions("mes:mesProductJyny:view")
|
|
|
+ @RequestMapping(value = "listData")
|
|
|
+ @ResponseBody
|
|
|
+ public Page<MesProductJyny> listData(MesProductJyny mesProductJyny, HttpServletRequest request, HttpServletResponse response) {
|
|
|
+ mesProductJyny.setPage(new Page<>(request, response));
|
|
|
+ Page<MesProductJyny> page = mesProductJynyService.findPage(mesProductJyny);
|
|
|
+ return page;
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 查看编辑表单
|
|
|
+ */
|
|
|
+ @RequiresPermissions("mes:mesProductJyny:view")
|
|
|
+ @RequestMapping(value = "form")
|
|
|
+ public String form(MesProductJyny mesProductJyny, Model model) {
|
|
|
+ model.addAttribute("mesProductJyny", mesProductJyny);
|
|
|
+ return "modules/mes/mesProductJynyForm";
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 保存数据
|
|
|
+ */
|
|
|
+ @RequiresPermissions("mes:mesProductJyny:edit")
|
|
|
+ @PostMapping(value = "save")
|
|
|
+ @ResponseBody
|
|
|
+ public String save(@Validated MesProductJyny mesProductJyny) {
|
|
|
+ mesProductJynyService.save(mesProductJyny);
|
|
|
+ return renderResult(Global.TRUE, text("保存绝缘耐压数据表成功!"));
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 删除数据
|
|
|
+ */
|
|
|
+ @RequiresPermissions("mes:mesProductJyny:edit")
|
|
|
+ @RequestMapping(value = "delete")
|
|
|
+ @ResponseBody
|
|
|
+ public String delete(MesProductJyny mesProductJyny) {
|
|
|
+ mesProductJynyService.delete(mesProductJyny);
|
|
|
+ return renderResult(Global.TRUE, text("删除绝缘耐压数据表成功!"));
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 接收绝缘耐压数据:先更新工件对应工位结果,再保存数据
|
|
|
+ */
|
|
|
+ @PostMapping(value = "upload")
|
|
|
+ @ResponseBody
|
|
|
+ @Transactional
|
|
|
+ public String upload(MesProductJyny mesProductJyny) {
|
|
|
+ if (mesProductJyny == null || StringUtils.isBlank(mesProductJyny.getSn())) {
|
|
|
+ return renderResult(Global.FALSE, text("工件码不能为空!"));
|
|
|
+ }
|
|
|
+ if (StringUtils.isBlank(mesProductJyny.getOprno())) {
|
|
|
+ return renderResult(Global.FALSE, text("工位号不能为空!"));
|
|
|
+ }
|
|
|
+ if (StringUtils.isBlank(mesProductJyny.getResult())) {
|
|
|
+ return renderResult(Global.FALSE, text("工位结果不能为空!"));
|
|
|
+ }
|
|
|
+ String result = mesProductJyny.getResult().trim();
|
|
|
+ if (!"OK".equals(result) && !"NG".equals(result)) {
|
|
|
+ return renderResult(Global.FALSE, text("工位结果错误!"));
|
|
|
+ }
|
|
|
+
|
|
|
+ String sn = mesProductJyny.getSn().trim();
|
|
|
+ MesProductRecord record = mesProductRecordService.findBySnCate(sn);
|
|
|
+ if (ObjectUtils.isEmpty(record) || StringUtils.isBlank(record.getLineSn())) {
|
|
|
+ return renderResult(Global.FALSE, text("未找到该工件的生产记录!"));
|
|
|
+ }
|
|
|
+
|
|
|
+ String oprno = mesProductJyny.getOprno().trim();
|
|
|
+ if (oprno.length() == 5) {
|
|
|
+ oprno = oprno + "A";
|
|
|
+ }
|
|
|
+ String userCode = "";
|
|
|
+ User user = UserUtils.getUser();
|
|
|
+ if (user != null && StringUtils.isNotBlank(user.getUserCode())) {
|
|
|
+ userCode = user.getUserCode();
|
|
|
+ }
|
|
|
+
|
|
|
+ try {
|
|
|
+ // 1. 先更新工位结果
|
|
|
+ mesProductRecordService.updateRecord(sn, oprno, "100000", "", result, userCode, record.getLineSn());
|
|
|
+ // 2. 再保存绝缘耐压数据
|
|
|
+ mesProductJynyService.save(mesProductJyny);
|
|
|
+ } catch (Exception e) {
|
|
|
+ TransactionAspectSupport.currentTransactionStatus().setRollbackOnly();
|
|
|
+ logger.error("绝缘耐压数据上传失败", e);
|
|
|
+ return renderResult(Global.FALSE, text(StringUtils.isNotBlank(e.getMessage()) ? e.getMessage() : "操作失败!"));
|
|
|
+ }
|
|
|
+ return renderResult(Global.TRUE, text("操作成功!"));
|
|
|
+ }
|
|
|
+
|
|
|
+}
|