|
|
@@ -0,0 +1,165 @@
|
|
|
+package com.jeesite.modules.mes.web;
|
|
|
+
|
|
|
+import com.jeesite.common.config.Global;
|
|
|
+import com.jeesite.common.entity.Page;
|
|
|
+import com.jeesite.common.web.BaseController;
|
|
|
+import com.jeesite.modules.mes.entity.MesGlue;
|
|
|
+import com.jeesite.modules.mes.entity.MesGlueRecord;
|
|
|
+import com.jeesite.modules.mes.service.MesGlueRecordService;
|
|
|
+import com.jeesite.modules.mes.service.MesGlueService;
|
|
|
+import com.jeesite.modules.mes.util.CommonUitl;
|
|
|
+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.util.ObjectUtils;
|
|
|
+import org.springframework.util.StringUtils;
|
|
|
+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.text.SimpleDateFormat;
|
|
|
+import java.util.Date;
|
|
|
+import java.util.List;
|
|
|
+
|
|
|
+/**
|
|
|
+ * 工位胶水拆封记录Controller
|
|
|
+ * @author hzd
|
|
|
+ * @version 2025-04-17
|
|
|
+ */
|
|
|
+@Controller
|
|
|
+@RequestMapping(value = "${adminPath}/mes/mesGlueRecord")
|
|
|
+public class MesGlueRecordController extends BaseController {
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ private MesGlueRecordService mesGlueRecordService;
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ private MesGlueService mesGlueService;
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 获取数据
|
|
|
+ */
|
|
|
+ @ModelAttribute
|
|
|
+ public MesGlueRecord get(String id, boolean isNewRecord) {
|
|
|
+ return mesGlueRecordService.get(id, isNewRecord);
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 查询列表
|
|
|
+ */
|
|
|
+ @RequiresPermissions("mes:mesGlueRecord:view")
|
|
|
+ @RequestMapping(value = {"list", ""})
|
|
|
+ public String list(MesGlueRecord mesGlueRecord, Model model) {
|
|
|
+ model.addAttribute("mesGlueRecord", mesGlueRecord);
|
|
|
+ return "modules/mes/mesGlueRecordList";
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 查询列表数据
|
|
|
+ */
|
|
|
+ @RequiresPermissions("mes:mesGlueRecord:view")
|
|
|
+ @RequestMapping(value = "listData")
|
|
|
+ @ResponseBody
|
|
|
+ public Page<MesGlueRecord> listData(MesGlueRecord mesGlueRecord, HttpServletRequest request, HttpServletResponse response) {
|
|
|
+ mesGlueRecord.setPage(new Page<>(request, response));
|
|
|
+ Page<MesGlueRecord> page = mesGlueRecordService.findPage(mesGlueRecord);
|
|
|
+ return page;
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 查看编辑表单
|
|
|
+ */
|
|
|
+ @RequiresPermissions("mes:mesGlueRecord:view")
|
|
|
+ @RequestMapping(value = "form")
|
|
|
+ public String form(MesGlueRecord mesGlueRecord, Model model) {
|
|
|
+ model.addAttribute("mesGlueRecord", mesGlueRecord);
|
|
|
+ return "modules/mes/mesGlueRecordForm";
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 保存数据
|
|
|
+ */
|
|
|
+ @RequiresPermissions("mes:mesGlueRecord:edit")
|
|
|
+ @PostMapping(value = "save")
|
|
|
+ @ResponseBody
|
|
|
+ public String save(@Validated MesGlueRecord mesGlueRecord) {
|
|
|
+ mesGlueRecordService.save(mesGlueRecord);
|
|
|
+ return renderResult(Global.TRUE, text("保存工位胶水拆封记录成功!"));
|
|
|
+ }
|
|
|
+
|
|
|
+ @RequestMapping(value = {"olist", ""})
|
|
|
+ public String olist(MesGlueRecord mesGlueRecord, Model model, HttpServletRequest request) {
|
|
|
+ String oprno = request.getParameter("oprno");
|
|
|
+ String ucode = request.getParameter("ucode");
|
|
|
+ String lineSn = request.getParameter("lineSn");
|
|
|
+ model.addAttribute("mesGlueRecord", mesGlueRecord);
|
|
|
+ model.addAttribute("oprno", oprno);
|
|
|
+ model.addAttribute("ucode", ucode);
|
|
|
+ model.addAttribute("lineSn", lineSn);
|
|
|
+
|
|
|
+ return "modules/mes/mesGlueRecordOlist";
|
|
|
+ }
|
|
|
+
|
|
|
+ @RequestMapping(value = "listData2")
|
|
|
+ @ResponseBody
|
|
|
+ public Page<MesGlueRecord> listData2(MesGlueRecord mesGlueRecord, HttpServletRequest request, HttpServletResponse response) {
|
|
|
+ mesGlueRecord.setPage(new Page<>(request, response));
|
|
|
+ Page<MesGlueRecord> page = mesGlueRecordService.findPage(mesGlueRecord);
|
|
|
+ return page;
|
|
|
+ }
|
|
|
+
|
|
|
+ @RequestMapping(value = "edit")
|
|
|
+ public String edit(MesGlueRecord mesGlueRecord, Model model, HttpServletRequest request) {
|
|
|
+ String ucode = request.getParameter("ucode");
|
|
|
+ model.addAttribute("ucode", ucode);
|
|
|
+ model.addAttribute("mesGlueRecord", mesGlueRecord);
|
|
|
+ String oriOprno = CommonUitl.formatOprno(mesGlueRecord.getOprno()); // 原始工位,不带ABCD
|
|
|
+ MesGlue mesGlue = new MesGlue();
|
|
|
+ mesGlue.setOprno(oriOprno);
|
|
|
+ mesGlue.setLineSn(mesGlueRecord.getLineSn());
|
|
|
+ mesGlue.setStatus("0");
|
|
|
+ List<MesGlue> glues = mesGlueService.findList(mesGlue);
|
|
|
+ model.addAttribute("glues", glues);
|
|
|
+
|
|
|
+ return "modules/mes/mesGlueRecordEdit";
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 保存数据
|
|
|
+ */
|
|
|
+ @PostMapping(value = "editSave")
|
|
|
+ @ResponseBody
|
|
|
+ public String editSave(@Validated MesGlueRecord mesGlueRecord, HttpServletRequest request) {
|
|
|
+ if(StringUtils.isEmpty(mesGlueRecord.getOprno())||StringUtils.isEmpty(mesGlueRecord.getLineSn())){
|
|
|
+ return renderResult(Global.TRUE, text("参数错误!"));
|
|
|
+ }
|
|
|
+ String ucode = request.getParameter("ucode");
|
|
|
+
|
|
|
+ String oriOprno = CommonUitl.formatOprno(mesGlueRecord.getOprno()); // 原始工位,不带ABCD
|
|
|
+
|
|
|
+ MesGlue mesGlue = mesGlueService.get(mesGlueRecord.getGlueId());
|
|
|
+ if(ObjectUtils.isEmpty(mesGlue) || !mesGlue.getStatus().equals("0")){
|
|
|
+ return renderResult(Global.TRUE, text("不需要更换胶水!"));
|
|
|
+ }
|
|
|
+ if(!(mesGlue.getOprno().equals(oriOprno) && mesGlue.getLineSn().equals(mesGlueRecord.getLineSn()))){
|
|
|
+ return renderResult(Global.TRUE, text("不需要更换胶水!"));
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ // 计算胶水有效期
|
|
|
+ SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd"); // 定义日期时间格式
|
|
|
+ String scDateStr = sdf.format(mesGlueRecord.getScDate());
|
|
|
+ mesGlueRecord.setCfDate(new Date());
|
|
|
+ List<Date> loseDate = CommonUitl.getLoseDate(scDateStr,mesGlue.getDays(),mesGlue.getCfdays());
|
|
|
+ mesGlueRecord.setLoseDate(loseDate.get(1));
|
|
|
+ mesGlueRecord.setValidityDate(loseDate.get(0));
|
|
|
+ mesGlueRecord.setCreateBy(ucode);
|
|
|
+ mesGlueRecordService.save(mesGlueRecord);
|
|
|
+ return renderResult(Global.TRUE, text("操作成功!"));
|
|
|
+ }
|
|
|
+}
|