MesIqcController.java 5.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194
  1. package com.jeesite.modules.mes.web;
  2. import java.text.SimpleDateFormat;
  3. import java.util.Date;
  4. import java.util.List;
  5. import java.util.Map;
  6. import javax.servlet.http.HttpServletRequest;
  7. import javax.servlet.http.HttpServletResponse;
  8. import com.jeesite.common.collect.ListUtils;
  9. import com.jeesite.common.collect.MapUtils;
  10. import com.jeesite.common.mybatis.mapper.query.QueryType;
  11. import com.jeesite.modules.mes.entity.*;
  12. import com.jeesite.modules.mes.resp.CommonResp;
  13. import com.jeesite.modules.mes.service.MesBatchSnService;
  14. import com.jeesite.modules.mes.service.MesProductService;
  15. import com.jeesite.modules.sys.entity.User;
  16. import com.jeesite.modules.sys.utils.UserUtils;
  17. import org.apache.shiro.authz.annotation.RequiresPermissions;
  18. import org.springframework.beans.factory.annotation.Autowired;
  19. import org.springframework.stereotype.Controller;
  20. import org.springframework.transaction.annotation.Transactional;
  21. import org.springframework.ui.Model;
  22. import org.springframework.util.ObjectUtils;
  23. import org.springframework.util.StringUtils;
  24. import org.springframework.validation.annotation.Validated;
  25. import org.springframework.web.bind.annotation.ModelAttribute;
  26. import org.springframework.web.bind.annotation.PostMapping;
  27. import org.springframework.web.bind.annotation.RequestMapping;
  28. import org.springframework.web.bind.annotation.ResponseBody;
  29. import com.jeesite.common.config.Global;
  30. import com.jeesite.common.entity.Page;
  31. import com.jeesite.common.web.BaseController;
  32. import com.jeesite.modules.mes.service.MesIqcService;
  33. /**
  34. * IQC检测记录表Controller
  35. * @author mes
  36. * @version 2024-04-12
  37. */
  38. @Controller
  39. @RequestMapping(value = "${adminPath}/mes/mesIqc")
  40. public class MesIqcController extends BaseController {
  41. @Autowired
  42. private MesIqcService mesIqcService;
  43. @Autowired
  44. private MesProductService mesProductService;
  45. @Autowired
  46. private MesBatchSnService mesBatchSnService;
  47. /**
  48. * 获取数据
  49. */
  50. @ModelAttribute
  51. public MesIqc get(String id, boolean isNewRecord) {
  52. return mesIqcService.get(id, isNewRecord);
  53. }
  54. /**
  55. * 查询列表
  56. */
  57. @RequiresPermissions("mes:mesIqc:view")
  58. @RequestMapping(value = {"list", ""})
  59. public String list(MesIqc mesIqc, Model model) {
  60. model.addAttribute("mesIqc", mesIqc);
  61. return "modules/mes/mesIqcList";
  62. }
  63. /**
  64. * 查询列表数据
  65. */
  66. @RequiresPermissions("mes:mesIqc:view")
  67. @RequestMapping(value = "listData")
  68. @ResponseBody
  69. public Page<MesIqc> listData(MesIqc mesIqc, HttpServletRequest request, HttpServletResponse response) {
  70. mesIqc.setPage(new Page<>(request, response));
  71. Page<MesIqc> page = mesIqcService.findPage(mesIqc);
  72. return page;
  73. }
  74. /**
  75. * 查看编辑表单
  76. */
  77. @RequiresPermissions("mes:mesIqc:view")
  78. @RequestMapping(value = "form")
  79. public String form(MesIqc mesIqc, Model model) {
  80. model.addAttribute("mesIqc", mesIqc);
  81. return "modules/mes/mesIqcForm";
  82. }
  83. /**
  84. * 查看编辑表单
  85. */
  86. @RequiresPermissions("mes:mesIqc:view")
  87. @RequestMapping(value = "info")
  88. public String info(MesIqc mesIqc, Model model) {
  89. MesProduct mesProduct = new MesProduct();
  90. mesProduct.setBatchSn(mesIqc.getBatchSn());
  91. List<MesProduct> mp = mesProductService.findList(mesProduct);
  92. model.addAttribute("mesIqc", mesIqc);
  93. model.addAttribute("mp", mp);
  94. return "modules/mes/mesIqcInfo";
  95. }
  96. /**
  97. * 保存数据
  98. */
  99. @RequiresPermissions("mes:mesIqc:edit")
  100. @PostMapping(value = "save")
  101. @ResponseBody
  102. public String save(@Validated MesIqc mesIqc) {
  103. mesIqcService.save(mesIqc);
  104. return renderResult(Global.TRUE, text("保存IQC检测记录表成功!"));
  105. }
  106. @RequiresPermissions("mes:mesIqc:api")
  107. @RequestMapping(value = "ulist")
  108. @ResponseBody
  109. public CommonResp ulist(HttpServletRequest req, HttpServletResponse response) {
  110. User user = UserUtils.getUser();
  111. CommonResp<Page> resp = new CommonResp<>();
  112. MesIqc mesIqc = new MesIqc();
  113. mesIqc.setCreateBy(user.getUserCode());
  114. mesIqc.setPage(new Page<>(req, response));
  115. Page<MesIqc> page = mesIqcService.findPage(mesIqc);
  116. resp.setData(page);
  117. resp.setResult(Global.TRUE);
  118. return resp;
  119. }
  120. @RequiresPermissions("mes:mesIqc:api")
  121. @RequestMapping(value = "ulistDetail")
  122. @ResponseBody
  123. public CommonResp ulistDetail(MesIqc mesIqc,HttpServletRequest req) {
  124. CommonResp<MesIqc> resp = new CommonResp<>();
  125. if(ObjectUtils.isEmpty(mesIqc)){
  126. resp.setResult(Global.FALSE);
  127. resp.setMessage("记录不存在");
  128. return resp;
  129. }
  130. MesProduct mesProduct = new MesProduct();
  131. mesProduct.setBatchSn(mesIqc.getBatchSn());
  132. List<MesProduct> lists = mesProductService.findList(mesProduct);
  133. mesIqc.setItems(lists);
  134. resp.setData(mesIqc);
  135. resp.setResult(Global.TRUE);
  136. return resp;
  137. }
  138. @RequiresPermissions("mes:mesIqc:api")
  139. @PostMapping(value = "addSave")
  140. @Transactional
  141. @ResponseBody
  142. public CommonResp addSave(HttpServletRequest req) {
  143. String batchSn = req.getParameter("batchSn");
  144. String result = req.getParameter("result");
  145. String remark = req.getParameter("remark");
  146. CommonResp<Map<String, Object>> resp = new CommonResp<>();
  147. Map<String, Object> map = MapUtils.newHashMap();
  148. resp.setResult(Global.FALSE);
  149. if(StringUtils.isEmpty(batchSn) ||StringUtils.isEmpty(result)){
  150. resp.setMessage("参数错误");
  151. return resp;
  152. }
  153. MesBatchSn mesBatchSn = new MesBatchSn();
  154. mesBatchSn.setBatchSn(batchSn);
  155. MesBatchSn msInfo = mesBatchSnService.findInfo(mesBatchSn);
  156. if(ObjectUtils.isEmpty(msInfo)){
  157. resp.setMessage("包装码不存在");
  158. return resp;
  159. }
  160. MesIqc mesIqc = new MesIqc();
  161. mesIqc.setBatchSn(batchSn);
  162. List<MesIqc> miqc = mesIqcService.findList(mesIqc);
  163. if(!ListUtils.isEmpty(miqc)){
  164. resp.setMessage("当前包装码已检查");
  165. return resp;
  166. }
  167. MesIqc mesIqc1 = new MesIqc();
  168. mesIqc1.setBatchSn(batchSn);
  169. mesIqc1.setLineSn(msInfo.getLineSn());
  170. mesIqc1.setState(result);
  171. mesIqc1.setRemark(remark);
  172. mesIqcService.save(mesIqc1);
  173. resp.setResult(Global.TRUE);
  174. resp.setMessage("操作成功");
  175. return resp;
  176. }
  177. }