|
@@ -0,0 +1,239 @@
|
|
|
|
|
+package com.jeesite.modules.mes.web;
|
|
|
|
|
+
|
|
|
|
|
+import java.util.Date;
|
|
|
|
|
+import java.util.List;
|
|
|
|
|
+import java.util.Map;
|
|
|
|
|
+import javax.servlet.http.HttpServletRequest;
|
|
|
|
|
+import javax.servlet.http.HttpServletResponse;
|
|
|
|
|
+import javax.transaction.Transactional;
|
|
|
|
|
+
|
|
|
|
|
+import com.alibaba.druid.util.StringUtils;
|
|
|
|
|
+import com.jeesite.common.collect.MapUtils;
|
|
|
|
|
+import com.jeesite.common.lang.ObjectUtils;
|
|
|
|
|
+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.MesProduct;
|
|
|
|
|
+import com.jeesite.modules.mes.entity.MesScrap;
|
|
|
|
|
+import com.jeesite.modules.mes.resp.CommonResp;
|
|
|
|
|
+import com.jeesite.modules.mes.service.MesProductService;
|
|
|
|
|
+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.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 com.jeesite.common.config.Global;
|
|
|
|
|
+import com.jeesite.common.collect.ListUtils;
|
|
|
|
|
+import com.jeesite.common.entity.Page;
|
|
|
|
|
+import com.jeesite.common.lang.DateUtils;
|
|
|
|
|
+import com.jeesite.common.utils.excel.ExcelExport;
|
|
|
|
|
+import com.jeesite.common.utils.excel.annotation.ExcelField.Type;
|
|
|
|
|
+import org.springframework.web.multipart.MultipartFile;
|
|
|
|
|
+import com.jeesite.common.web.BaseController;
|
|
|
|
|
+import com.jeesite.modules.mes.entity.MesProductOut;
|
|
|
|
|
+import com.jeesite.modules.mes.service.MesProductOutService;
|
|
|
|
|
+
|
|
|
|
|
+/**
|
|
|
|
|
+ * 出库验证记录Controller
|
|
|
|
|
+ * @author mes
|
|
|
|
|
+ * @version 2026-07-11
|
|
|
|
|
+ */
|
|
|
|
|
+@Controller
|
|
|
|
|
+@RequestMapping(value = "${adminPath}/mes/mesProductOut")
|
|
|
|
|
+public class MesProductOutController extends BaseController {
|
|
|
|
|
+
|
|
|
|
|
+ @Autowired
|
|
|
|
|
+ private MesProductOutService mesProductOutService;
|
|
|
|
|
+ @Autowired
|
|
|
|
|
+ private MesProductService mesProductService;
|
|
|
|
|
+ @Autowired
|
|
|
|
|
+ private FileUploadService fileUploadService;
|
|
|
|
|
+
|
|
|
|
|
+ /**
|
|
|
|
|
+ * 获取数据
|
|
|
|
|
+ */
|
|
|
|
|
+ @ModelAttribute
|
|
|
|
|
+ public MesProductOut get(String id, boolean isNewRecord) {
|
|
|
|
|
+ return mesProductOutService.get(id, isNewRecord);
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ /**
|
|
|
|
|
+ * 查询列表
|
|
|
|
|
+ */
|
|
|
|
|
+ @RequiresPermissions("mes:mesProductOut:view")
|
|
|
|
|
+ @RequestMapping(value = {"list", ""})
|
|
|
|
|
+ public String list(MesProductOut mesProductOut, Model model) {
|
|
|
|
|
+ model.addAttribute("mesProductOut", mesProductOut);
|
|
|
|
|
+ return "modules/mes/mesProductOutList";
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ /**
|
|
|
|
|
+ * 查询列表数据
|
|
|
|
|
+ */
|
|
|
|
|
+ @RequiresPermissions("mes:mesProductOut:view")
|
|
|
|
|
+ @RequestMapping(value = "listData")
|
|
|
|
|
+ @ResponseBody
|
|
|
|
|
+ public Page<MesProductOut> listData(MesProductOut mesProductOut, HttpServletRequest request, HttpServletResponse response) {
|
|
|
|
|
+ mesProductOut.setPage(new Page<>(request, response));
|
|
|
|
|
+ Page<MesProductOut> page = mesProductOutService.findPage(mesProductOut);
|
|
|
|
|
+ return page;
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ /**
|
|
|
|
|
+ * 查看编辑表单
|
|
|
|
|
+ */
|
|
|
|
|
+ @RequiresPermissions("mes:mesProductOut:view")
|
|
|
|
|
+ @RequestMapping(value = "form")
|
|
|
|
|
+ public String form(MesProductOut mesProductOut, Model model) {
|
|
|
|
|
+ model.addAttribute("mesProductOut", mesProductOut);
|
|
|
|
|
+ return "modules/mes/mesProductOutForm";
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ /**
|
|
|
|
|
+ * 保存数据
|
|
|
|
|
+ */
|
|
|
|
|
+ @RequiresPermissions("mes:mesProductOut:edit")
|
|
|
|
|
+ @PostMapping(value = "save")
|
|
|
|
|
+ @ResponseBody
|
|
|
|
|
+ public String save(@Validated MesProductOut mesProductOut) {
|
|
|
|
|
+ mesProductOutService.save(mesProductOut);
|
|
|
|
|
+ return renderResult(Global.TRUE, text("保存出库验证记录成功!"));
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ /**
|
|
|
|
|
+ * 导出数据
|
|
|
|
|
+ */
|
|
|
|
|
+ @RequiresPermissions("mes:mesProductOut:view")
|
|
|
|
|
+ @RequestMapping(value = "exportData")
|
|
|
|
|
+ public void exportData(MesProductOut mesProductOut, HttpServletResponse response) {
|
|
|
|
|
+ List<MesProductOut> list = mesProductOutService.findList(mesProductOut);
|
|
|
|
|
+ String fileName = "出库验证记录" + DateUtils.getDate("yyyyMMddHHmmss") + ".xlsx";
|
|
|
|
|
+ try(ExcelExport ee = new ExcelExport("出库验证记录", MesProductOut.class)){
|
|
|
|
|
+ ee.setDataList(list).write(response, fileName);
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ /**
|
|
|
|
|
+ * 下载模板
|
|
|
|
|
+ */
|
|
|
|
|
+ @RequiresPermissions("mes:mesProductOut:view")
|
|
|
|
|
+ @RequestMapping(value = "importTemplate")
|
|
|
|
|
+ public void importTemplate(HttpServletResponse response) {
|
|
|
|
|
+ MesProductOut mesProductOut = new MesProductOut();
|
|
|
|
|
+ List<MesProductOut> list = ListUtils.newArrayList(mesProductOut);
|
|
|
|
|
+ String fileName = "出库验证记录模板.xlsx";
|
|
|
|
|
+ try(ExcelExport ee = new ExcelExport("出库验证记录", MesProductOut.class, Type.IMPORT)){
|
|
|
|
|
+ ee.setDataList(list).write(response, fileName);
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ /**
|
|
|
|
|
+ * 导入数据
|
|
|
|
|
+ */
|
|
|
|
|
+ @ResponseBody
|
|
|
|
|
+ @RequiresPermissions("mes:mesProductOut:edit")
|
|
|
|
|
+ @PostMapping(value = "importData")
|
|
|
|
|
+ public String importData(MultipartFile file) {
|
|
|
|
|
+ try {
|
|
|
|
|
+ String message = mesProductOutService.importData(file);
|
|
|
|
|
+ return renderResult(Global.TRUE, "posfull:"+message);
|
|
|
|
|
+ } catch (Exception ex) {
|
|
|
|
|
+ return renderResult(Global.FALSE, "posfull:"+ex.getMessage());
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+// @RequiresPermissions("mes:mesProductOut:api")
|
|
|
|
|
+ @RequestMapping(value = "add")
|
|
|
|
|
+ @ResponseBody
|
|
|
|
|
+ @Transactional
|
|
|
|
|
+ public CommonResp add(MesProductOut mesProductOut, HttpServletRequest request) {
|
|
|
|
|
+ Map<String, Object> map = MapUtils.newHashMap();
|
|
|
|
|
+ CommonResp<Map<String, Object>> resp = new CommonResp<>();
|
|
|
|
|
+ resp.setResult(Global.FALSE);
|
|
|
|
|
+
|
|
|
|
|
+ if(StringUtils.isEmpty(mesProductOut.getSn())){
|
|
|
|
|
+ resp.setMessage("包装不能为空");
|
|
|
|
|
+ return resp;
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ MesProduct mesProduct1 = new MesProduct();
|
|
|
|
|
+ mesProduct1.setBatchSn(mesProductOut.getSn());
|
|
|
|
|
+ mesProduct1.setState("1");
|
|
|
|
|
+ List<MesProduct> mesProducts = mesProductService.findList(mesProduct1);
|
|
|
|
|
+ if(ListUtils.isEmpty(mesProducts)){
|
|
|
|
|
+ resp.setMessage("包装码不正确");
|
|
|
|
|
+ return resp;
|
|
|
|
|
+ }
|
|
|
|
|
+ // 检查是否静置24小时
|
|
|
|
|
+ Date now = new Date();
|
|
|
|
|
+ for(MesProduct mesProduct : mesProducts){
|
|
|
|
|
+ long differenceInMillis = now.getTime() - mesProduct.getBindDate().getTime();
|
|
|
|
|
+ long twoHoursInMillis = 24 * 60 * 60 * 1000;
|
|
|
|
|
+ if(differenceInMillis < twoHoursInMillis){
|
|
|
|
|
+ resp.setMessage("该包装工件未静置24小时,不能出货");
|
|
|
|
|
+ return resp;
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ mesProductOutService.save(mesProductOut);
|
|
|
|
|
+ resp.setResult(Global.TRUE);
|
|
|
|
|
+ return resp;
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+// @RequiresPermissions("mes:mesProductOut:api")
|
|
|
|
|
+ @RequestMapping(value = "ulist")
|
|
|
|
|
+ @ResponseBody
|
|
|
|
|
+ public CommonResp ulist(MesProductOut mesProductOut, HttpServletRequest request, HttpServletResponse response) {
|
|
|
|
|
+// User user = UserUtils.getUser();
|
|
|
|
|
+// mesScrap.setCreateBy(user.getUserCode());
|
|
|
|
|
+
|
|
|
|
|
+ mesProductOut.setPage(new Page<>(request, response));
|
|
|
|
|
+ Page<MesProductOut> page = mesProductOutService.findPage(mesProductOut);
|
|
|
|
|
+
|
|
|
|
|
+ CommonResp<Page> resp = new CommonResp<>();
|
|
|
|
|
+
|
|
|
|
|
+ resp.setData(page);
|
|
|
|
|
+ resp.setResult(Global.TRUE);
|
|
|
|
|
+ return resp;
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ /**
|
|
|
|
|
+ * 详情
|
|
|
|
|
+ */
|
|
|
|
|
+// @RequiresPermissions("mes:mesProductOut:api")
|
|
|
|
|
+ @RequestMapping(value = "info")
|
|
|
|
|
+ @ResponseBody
|
|
|
|
|
+ public CommonResp info(MesProductOut mesProductOut, HttpServletRequest request) {
|
|
|
|
|
+ mesProductOut.setId(request.getParameter("id"));
|
|
|
|
|
+ MesProductOut info = mesProductOutService.get(mesProductOut);
|
|
|
|
|
+
|
|
|
|
|
+ String host = request.getScheme() + "://" + request.getServerName() + ":" + request.getServerPort() + "/js";
|
|
|
|
|
+
|
|
|
|
|
+ FileUpload fu = new FileUpload();
|
|
|
|
|
+ fu.setBizKey(info.getId());
|
|
|
|
|
+ fu.setBizType("mesProductOut_image");
|
|
|
|
|
+ List<FileUpload> finfo = fileUploadService.findList(fu);
|
|
|
|
|
+ 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);
|
|
|
|
|
+ }
|
|
|
|
|
+ info.setImg(imgList);
|
|
|
|
|
+ CommonResp<MesProductOut> resp = new CommonResp<>();
|
|
|
|
|
+ resp.setData(info);
|
|
|
|
|
+ return resp;
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+}
|