|
|
@@ -0,0 +1,236 @@
|
|
|
+package com.jeesite.modules.mes.web;
|
|
|
+
|
|
|
+import com.jeesite.common.collect.ListUtils;
|
|
|
+import com.jeesite.common.collect.MapUtils;
|
|
|
+import com.jeesite.common.config.Global;
|
|
|
+import com.jeesite.common.entity.Page;
|
|
|
+import com.jeesite.common.lang.ObjectUtils;
|
|
|
+import com.jeesite.common.lang.StringUtils;
|
|
|
+import com.jeesite.common.web.BaseController;
|
|
|
+import com.jeesite.modules.file.entity.FileUpload;
|
|
|
+import com.jeesite.modules.file.service.FileUploadService;
|
|
|
+import com.jeesite.modules.file.utils.FileUploadUtils;
|
|
|
+import com.jeesite.modules.mes.entity.MesProductNg;
|
|
|
+import com.jeesite.modules.mes.resp.CommonResp;
|
|
|
+import com.jeesite.modules.mes.service.MesProductNgService;
|
|
|
+import org.apache.shiro.authz.annotation.RequiresPermissions;
|
|
|
+import org.springframework.beans.factory.annotation.Autowired;
|
|
|
+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 javax.servlet.http.HttpServletRequest;
|
|
|
+import javax.servlet.http.HttpServletResponse;
|
|
|
+import java.util.List;
|
|
|
+import java.util.Map;
|
|
|
+
|
|
|
+/**
|
|
|
+ * NG中断记录Controller
|
|
|
+ * @author hzd
|
|
|
+ * @version 2025-09-18
|
|
|
+ */
|
|
|
+@Controller
|
|
|
+@RequestMapping(value = "${adminPath}/mes/mesProductNg")
|
|
|
+public class MesProductNgController extends BaseController {
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ private MesProductNgService mesProductNgService;
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ protected FileUploadService fileUploadService;
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 获取数据
|
|
|
+ */
|
|
|
+ @ModelAttribute
|
|
|
+ public MesProductNg get(String id, boolean isNewRecord) {
|
|
|
+ return mesProductNgService.get(id, isNewRecord);
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 查询列表
|
|
|
+ */
|
|
|
+ @RequiresPermissions("mes:mesProductNg:view")
|
|
|
+ @RequestMapping(value = {"list", ""})
|
|
|
+ public String list(MesProductNg mesProductNg, Model model) {
|
|
|
+ model.addAttribute("mesProductNg", mesProductNg);
|
|
|
+ return "modules/mes/mesProductNgList";
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 查询列表数据
|
|
|
+ */
|
|
|
+ @RequiresPermissions("mes:mesProductNg:view")
|
|
|
+ @RequestMapping(value = "listData")
|
|
|
+ @ResponseBody
|
|
|
+ public Page<MesProductNg> listData(MesProductNg mesProductNg, HttpServletRequest request, HttpServletResponse response) {
|
|
|
+ mesProductNg.setPage(new Page<>(request, response));
|
|
|
+ Page<MesProductNg> page = mesProductNgService.findPage(mesProductNg);
|
|
|
+ return page;
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 查看编辑表单
|
|
|
+ */
|
|
|
+ @RequiresPermissions("mes:mesProductNg:view")
|
|
|
+ @RequestMapping(value = "form")
|
|
|
+ public String form(MesProductNg mesProductNg, Model model) {
|
|
|
+ model.addAttribute("mesProductNg", mesProductNg);
|
|
|
+ return "modules/mes/mesProductNgForm";
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 保存数据
|
|
|
+ */
|
|
|
+ @RequiresPermissions("mes:mesProductNg:edit")
|
|
|
+ @PostMapping(value = "save")
|
|
|
+ @ResponseBody
|
|
|
+ public String save(@Validated MesProductNg mesProductNg) {
|
|
|
+ mesProductNgService.save(mesProductNg);
|
|
|
+ return renderResult(Global.TRUE, text("保存NG中断记录成功!"));
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 删除数据
|
|
|
+ */
|
|
|
+ @RequiresPermissions("mes:mesProductNg:edit")
|
|
|
+ @RequestMapping(value = "delete")
|
|
|
+ @ResponseBody
|
|
|
+ public String delete(MesProductNg mesProductNg) {
|
|
|
+ mesProductNgService.delete(mesProductNg);
|
|
|
+ return renderResult(Global.TRUE, text("删除NG中断记录成功!"));
|
|
|
+ }
|
|
|
+
|
|
|
+// @RequiresPermissions("mes:mesProductNg:api")
|
|
|
+ @RequestMapping(value = "ulist")
|
|
|
+ @ResponseBody
|
|
|
+ public CommonResp ulist(HttpServletRequest req, HttpServletResponse response) {
|
|
|
+ CommonResp<Page> resp = new CommonResp<>();
|
|
|
+
|
|
|
+ MesProductNg mesProductNg = new MesProductNg();
|
|
|
+ mesProductNg.setPage(new Page<>(req, response));
|
|
|
+ Page<MesProductNg> page = mesProductNgService.findPage(mesProductNg);
|
|
|
+ resp.setData(page);
|
|
|
+ resp.setResult(Global.TRUE);
|
|
|
+ return resp;
|
|
|
+ }
|
|
|
+
|
|
|
+// @RequiresPermissions("mes:mesProductNg:api")
|
|
|
+ @RequestMapping(value = "detail")
|
|
|
+ @ResponseBody
|
|
|
+ public CommonResp detail(MesProductNg mesProductNg, HttpServletRequest req) {
|
|
|
+ CommonResp<MesProductNg> resp = new CommonResp<>();
|
|
|
+ String host = req.getScheme() + "://" + req.getServerName() + ":" + req.getServerPort() + "/js";
|
|
|
+ Map<String, Object> map = MapUtils.newHashMap();
|
|
|
+
|
|
|
+ // 图片
|
|
|
+ FileUpload fu = new FileUpload();
|
|
|
+ fu.setBizKey(mesProductNg.getId());
|
|
|
+ fu.setBizType("mesProductNg_image");
|
|
|
+ List<FileUpload> finfo = fileUploadService.findList(fu);
|
|
|
+ if (!ListUtils.isEmpty(finfo)) {
|
|
|
+ List imgList = ListUtils.newArrayList();
|
|
|
+ for (FileUpload fi : finfo) {
|
|
|
+ Map<String, Object> map1 = MapUtils.newHashMap();
|
|
|
+ map1.put("id", fi.getFileEntity().getFileId());
|
|
|
+ map1.put("url", host + fi.getFileUrl());
|
|
|
+ map1.put("name", fi.getFileName());
|
|
|
+ map1.put("size", fi.getFileEntity().getFileSize());
|
|
|
+
|
|
|
+ imgList.add(map1);
|
|
|
+ }
|
|
|
+ mesProductNg.setImg(imgList);
|
|
|
+ }
|
|
|
+
|
|
|
+ resp.setData(mesProductNg);
|
|
|
+ resp.setResult(Global.TRUE);
|
|
|
+ return resp;
|
|
|
+ }
|
|
|
+
|
|
|
+// @RequiresPermissions("mes:mesProductNg:api")
|
|
|
+ @PostMapping(value = "deal")
|
|
|
+ @ResponseBody
|
|
|
+ public String deal(@Validated MesProductNg mesProductNg) {
|
|
|
+ mesProductNg.setState("1");
|
|
|
+ mesProductNgService.save(mesProductNg);
|
|
|
+ return renderResult(Global.TRUE, text("操作成功!"));
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ @PostMapping(value = "addData")
|
|
|
+ @ResponseBody
|
|
|
+ public String addData(@Validated MesProductNg mesProductNg) {
|
|
|
+ mesProductNg.setState("0");
|
|
|
+ mesProductNgService.save(mesProductNg);
|
|
|
+ return renderResult(Global.TRUE, text("操作成功!"));
|
|
|
+ }
|
|
|
+
|
|
|
+ @PostMapping(value = "ngcheck")
|
|
|
+ @ResponseBody
|
|
|
+ public String ngcheck(HttpServletRequest req) {
|
|
|
+ String sn = req.getParameter("sn");
|
|
|
+ String oprno = req.getParameter("oprno");
|
|
|
+ String lineSn = req.getParameter("lineSn");
|
|
|
+ String pos = req.getParameter("pos");
|
|
|
+
|
|
|
+ MesProductNg mesProductNg = new MesProductNg();
|
|
|
+ mesProductNg.setSn(sn);
|
|
|
+ mesProductNg.setOprno(oprno);
|
|
|
+ mesProductNg.setLineSn(lineSn);
|
|
|
+ if(!StringUtils.isEmpty(pos)){
|
|
|
+ mesProductNg.setPos(pos);
|
|
|
+ }
|
|
|
+ MesProductNg mesProductNg2 = mesProductNgService.findInfo(mesProductNg);
|
|
|
+ if(ObjectUtils.isEmpty(mesProductNg2)){
|
|
|
+ return renderResult(Global.TRUE, text("操作成功!"));
|
|
|
+ }
|
|
|
+ if(mesProductNg2.getState().equals("1")){
|
|
|
+ return renderResult(Global.TRUE, text("操作成功!"));
|
|
|
+ }
|
|
|
+ return renderResult(Global.FALSE, text("NG中断未确认"));
|
|
|
+ }
|
|
|
+
|
|
|
+ // pda上传图片处理ng中断
|
|
|
+ @PostMapping("/submit")
|
|
|
+ @ResponseBody
|
|
|
+ public String submit(MesProductNg mesProductNg){
|
|
|
+ // 检查工位码参数
|
|
|
+ String sn = mesProductNg.getSn();
|
|
|
+ if (org.apache.commons.lang3.StringUtils.isBlank(sn))
|
|
|
+ return renderResult(Global.FALSE, "缺少必要参数");
|
|
|
+
|
|
|
+ // 检查工位号参数
|
|
|
+ String oprno = mesProductNg.getOprno();
|
|
|
+ if (org.apache.commons.lang3.StringUtils.isBlank(oprno))
|
|
|
+ return renderResult(Global.FALSE, "缺少必要参数");
|
|
|
+
|
|
|
+ // 检查产线编号参数
|
|
|
+ String lineSn = mesProductNg.getLineSn();
|
|
|
+ if (org.apache.commons.lang3.StringUtils.isBlank(lineSn))
|
|
|
+ return renderResult(Global.FALSE, "缺少必要参数");
|
|
|
+
|
|
|
+ // 按照上面三个参数查询按时间排序最近的一条记录
|
|
|
+ mesProductNg.getSqlMap().getOrder().setOrderBy("create_date desc");
|
|
|
+ MesProductNg mesProductNg2 = mesProductNgService.findInfo(mesProductNg);
|
|
|
+ if (ObjectUtils.isEmpty(mesProductNg2)){
|
|
|
+ return renderResult(Global.FALSE, text("没查到NG中断记录!"));
|
|
|
+ }
|
|
|
+ if ("1".equals(mesProductNg2.getState())){
|
|
|
+ return renderResult(Global.FALSE, text("操作成功!"));
|
|
|
+ }
|
|
|
+ mesProductNg2.setState("1");
|
|
|
+ mesProductNgService.save(mesProductNg2);
|
|
|
+
|
|
|
+ FileUploadUtils.saveFileUpload(mesProductNg2, mesProductNg2.getId(), "mesProductNg_image");
|
|
|
+
|
|
|
+ return renderResult(Global.TRUE, text("操作成功!"));
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+}
|