MesCcdInspectionController.java 9.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279
  1. package com.jeesite.modules.mes.web;
  2. import java.util.ArrayList;
  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.lang.StringUtils;
  11. import com.jeesite.common.mybatis.mapper.query.QueryType;
  12. import com.jeesite.modules.file.entity.FileUpload;
  13. import com.jeesite.modules.file.service.FileUploadService;
  14. import com.jeesite.modules.file.utils.FileUploadUtils;
  15. import com.jeesite.modules.mes.entity.*;
  16. import com.jeesite.modules.mes.req.MesSearchDateReq;
  17. import com.jeesite.modules.mes.resp.BindMaterialResp;
  18. import com.jeesite.modules.mes.resp.CommonResp;
  19. import com.jeesite.modules.mes.resp.ParamsResp;
  20. import com.jeesite.modules.mes.service.MesProductRecordService;
  21. import com.jeesite.modules.mes.util.CommonUitl;
  22. import com.jeesite.modules.sys.entity.User;
  23. import com.jeesite.modules.sys.utils.UserUtils;
  24. import com.jeesite.modules.utils.ErrorMsg;
  25. import org.apache.shiro.authz.annotation.RequiresPermissions;
  26. import org.springframework.beans.factory.annotation.Autowired;
  27. import org.springframework.stereotype.Controller;
  28. import org.springframework.transaction.annotation.Transactional;
  29. import org.springframework.ui.Model;
  30. import org.springframework.util.ObjectUtils;
  31. import org.springframework.validation.annotation.Validated;
  32. import org.springframework.web.bind.annotation.ModelAttribute;
  33. import org.springframework.web.bind.annotation.PostMapping;
  34. import org.springframework.web.bind.annotation.RequestMapping;
  35. import org.springframework.web.bind.annotation.ResponseBody;
  36. import com.jeesite.common.config.Global;
  37. import com.jeesite.common.entity.Page;
  38. import com.jeesite.common.web.BaseController;
  39. import com.jeesite.modules.mes.service.MesCcdInspectionService;
  40. /**
  41. * mes_ccd_inspectionController
  42. * @author system
  43. * @version 2026-04-01
  44. */
  45. @Controller
  46. @RequestMapping(value = "${adminPath}/mes/mesCcdInspection")
  47. public class MesCcdInspectionController extends BaseController {
  48. @Autowired
  49. private MesCcdInspectionService mesCcdInspectionService;
  50. @Autowired
  51. private MesProductRecordService mesProductRecordService;
  52. @Autowired
  53. private FileUploadService fileUploadService;
  54. /**
  55. * 获取数据
  56. */
  57. @ModelAttribute
  58. public MesCcdInspection get(String id, boolean isNewRecord) {
  59. return mesCcdInspectionService.get(id, isNewRecord);
  60. }
  61. /**
  62. * 查询列表
  63. */
  64. @RequiresPermissions("mes:mesCcdInspection:view")
  65. @RequestMapping(value = {"list", ""})
  66. public String list(MesCcdInspection mesCcdInspection, Model model) {
  67. model.addAttribute("mesCcdInspection", mesCcdInspection);
  68. return "modules/mes/mesCcdInspectionList";
  69. }
  70. /**
  71. * 查询列表数据
  72. */
  73. @RequiresPermissions("mes:mesCcdInspection:view")
  74. @RequestMapping(value = "listData")
  75. @ResponseBody
  76. public Page<MesCcdInspection> listData(MesCcdInspection mesCcdInspection, HttpServletRequest request, HttpServletResponse response) {
  77. mesCcdInspection.setPage(new Page<>(request, response));
  78. Page<MesCcdInspection> page = mesCcdInspectionService.findPage(mesCcdInspection);
  79. return page;
  80. }
  81. /**
  82. * 查看编辑表单
  83. */
  84. @RequiresPermissions("mes:mesCcdInspection:view")
  85. @RequestMapping(value = "form")
  86. public String form(MesCcdInspection mesCcdInspection, Model model) {
  87. model.addAttribute("mesCcdInspection", mesCcdInspection);
  88. return "modules/mes/mesCcdInspectionForm";
  89. }
  90. /**
  91. * 保存数据
  92. */
  93. @RequiresPermissions("mes:mesCcdInspection:edit")
  94. @PostMapping(value = "save")
  95. @ResponseBody
  96. public String save(@Validated MesCcdInspection mesCcdInspection) {
  97. mesCcdInspectionService.save(mesCcdInspection);
  98. return renderResult(Global.TRUE, text("保存mes_ccd_inspection成功!"));
  99. }
  100. /**
  101. * 删除数据
  102. */
  103. @RequiresPermissions("mes:mesCcdInspection:edit")
  104. @RequestMapping(value = "delete")
  105. @ResponseBody
  106. public String delete(MesCcdInspection mesCcdInspection) {
  107. mesCcdInspectionService.delete(mesCcdInspection);
  108. return renderResult(Global.TRUE, text("删除mes_ccd_inspection成功!"));
  109. }
  110. // 检查质量API接口
  111. @RequestMapping(value = "checkQuality")
  112. @ResponseBody
  113. public CommonResp checkQuality(HttpServletRequest request) {
  114. CommonResp<String> resp = new CommonResp<>();
  115. resp.setResult(Global.FALSE);
  116. String sn = request.getParameter("sn");
  117. String oprno = request.getParameter("oprno");//OP490
  118. if(StringUtils.isEmpty(sn) || StringUtils.isEmpty(oprno) ){
  119. resp.setResult(Global.FALSE);
  120. resp.setMessage("参数错误");
  121. return resp;
  122. }
  123. String oldOprno = oprno;
  124. if(oldOprno.length()==5){
  125. oldOprno += "A";
  126. }
  127. oprno = CommonUitl.formatOprno(oprno);
  128. //先检查当前工位是否已经加工过
  129. MesProductRecord mesProductRecord = new MesProductRecord();
  130. mesProductRecord.setSn(sn);
  131. mesProductRecord.setOprno(oprno);
  132. mesProductRecord.setCraft("100000");
  133. mesProductRecord.setLineSn("XT");
  134. MesProductRecord info = mesProductRecordService.findInfo(mesProductRecord);
  135. if(info == null || info.getContent().equals("UDF")){
  136. resp.setMessage("ccd检查未完成,请等待完成后复判");
  137. return resp;
  138. }
  139. resp.setResult(Global.TRUE);
  140. return resp;
  141. }
  142. @PostMapping(value = "pdaresult")
  143. @ResponseBody
  144. @Transactional
  145. public String pdaresult(HttpServletRequest request) {
  146. String sn = request.getParameter("sn");
  147. String oprno = request.getParameter("oprno");
  148. String remark = request.getParameter("result");
  149. String mesProduct_OP490_image = request.getParameter("mesProduct_OP490_image");
  150. String oldOprno = oprno;
  151. if(oldOprno.length()==5){
  152. oldOprno += "A";
  153. }
  154. if(StringUtils.isEmpty(mesProduct_OP490_image)){
  155. return renderResult(Global.FALSE, text("请上传图片!"));
  156. }
  157. if(StringUtils.isEmpty(sn) || StringUtils.isEmpty(oprno) || StringUtils.isEmpty(remark)){
  158. return renderResult(Global.FALSE, text("参数错误!"));
  159. }
  160. if(!remark.equals("OK") && !remark.equals("NG")){
  161. return renderResult(Global.FALSE, text("结果错误!"));
  162. }
  163. MesCcdInspection mesCcdInspection = new MesCcdInspection();
  164. mesCcdInspection.setOprno(oldOprno);
  165. mesCcdInspection.setSn(sn);
  166. mesCcdInspection.setRemark(remark);//表示结果
  167. mesCcdInspectionService.save(mesCcdInspection);
  168. if(!StringUtils.isEmpty(mesProduct_OP490_image)){
  169. FileUploadUtils.saveFileUpload(mesCcdInspection, mesCcdInspection.getId(), "mesProduct_OP490_image");
  170. }
  171. MesProductRecord mesProductRecord = new MesProductRecord();
  172. mesProductRecord.setSn(sn);
  173. mesProductRecord.setOprno(oprno);
  174. mesProductRecord.setCraft("100000");
  175. mesProductRecord.setLineSn("XT");
  176. MesProductRecord info = mesProductRecordService.findInfo(mesProductRecord);
  177. if (info != null){
  178. if(!info.getContent().equals(remark)){
  179. info.setContent("OK");
  180. mesProductRecordService.update(info);
  181. }
  182. }
  183. return renderResult(Global.TRUE, text("操作成功!"));
  184. }
  185. //列表
  186. @RequestMapping(value = "padListData")
  187. @ResponseBody
  188. public CommonResp padListData(MesCcdInspection mesCcdInspection, HttpServletRequest request, HttpServletResponse response) {
  189. CommonResp<Page> resp = new CommonResp<>();
  190. Page page1 = new Page<>(request, response);
  191. mesCcdInspection.setPage(page1);
  192. mesCcdInspection.getSqlMap().getOrder().setOrderBy("a.update_date desc");
  193. Page<MesCcdInspection> page = mesCcdInspectionService.findPage(mesCcdInspection);
  194. String host = request.getScheme() + "://" + request.getServerName() + ":" + request.getServerPort() + "/js";
  195. for (MesCcdInspection info:page.getList()){
  196. FileUpload fu = new FileUpload();
  197. fu.setBizKey(info.getId());
  198. fu.setBizType("mesProduct_OP490_image");
  199. List<FileUpload> finfo = fileUploadService.findList(fu);
  200. List imgList = ListUtils.newArrayList();
  201. for (FileUpload fi:finfo){
  202. Map<String, Object> map1 = MapUtils.newHashMap();
  203. map1.put("id",fi.getFileEntity().getFileId());
  204. map1.put("url",host + fi.getFileUrl());
  205. map1.put("name",fi.getFileName());
  206. map1.put("size",fi.getFileEntity().getFileSize());
  207. imgList.add(map1);
  208. }
  209. info.setImgList(imgList);
  210. }
  211. resp.setResult("true");
  212. resp.setData(page);
  213. resp.setMessage("成功");
  214. return resp;
  215. }
  216. @PostMapping(value = "padInfo")
  217. @ResponseBody
  218. public CommonResp padInfo(MesCcdInspection mesCcdInspection,HttpServletRequest request) {
  219. CommonResp<MesCcdInspection> resp = new CommonResp<>();
  220. String host = request.getScheme() + "://" + request.getServerName() + ":" + request.getServerPort() + "/js";
  221. FileUpload fu = new FileUpload();
  222. fu.setBizKey(mesCcdInspection.getId());
  223. fu.setBizType("mesProduct_OP490_image");
  224. MesCcdInspection mesCcdInspection1 = mesCcdInspectionService.get(mesCcdInspection.getId());
  225. List<FileUpload> finfo = fileUploadService.findList(fu);
  226. List imgList = ListUtils.newArrayList();
  227. for (FileUpload fi:finfo){
  228. Map<String, Object> map1 = MapUtils.newHashMap();
  229. map1.put("id",fi.getFileEntity().getFileId());
  230. map1.put("url",host + fi.getFileUrl());
  231. map1.put("name",fi.getFileName());
  232. map1.put("size",fi.getFileEntity().getFileSize());
  233. imgList.add(map1);
  234. }
  235. mesCcdInspection1.setImgList(imgList);
  236. resp.setData(mesCcdInspection1);
  237. resp.setResult(Global.TRUE);
  238. return resp;
  239. }
  240. }