|
|
@@ -0,0 +1,204 @@
|
|
|
+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.DateUtils;
|
|
|
+import com.jeesite.common.utils.excel.ExcelExport;
|
|
|
+import com.jeesite.common.utils.excel.annotation.ExcelField.Type;
|
|
|
+import com.jeesite.common.web.BaseController;
|
|
|
+import com.jeesite.modules.file.entity.FileUpload;
|
|
|
+import com.jeesite.modules.file.service.FileUploadService;
|
|
|
+import com.jeesite.modules.mes.entity.MesProductGlue;
|
|
|
+import com.jeesite.modules.mes.resp.CommonResp;
|
|
|
+import com.jeesite.modules.mes.service.MesProductGlueService;
|
|
|
+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 org.springframework.web.multipart.MultipartFile;
|
|
|
+
|
|
|
+import javax.servlet.http.HttpServletRequest;
|
|
|
+import javax.servlet.http.HttpServletResponse;
|
|
|
+import java.util.List;
|
|
|
+import java.util.Map;
|
|
|
+
|
|
|
+/**
|
|
|
+ * 胶水更换记录Controller
|
|
|
+ * @author hzd
|
|
|
+ * @version 2026-03-03
|
|
|
+ */
|
|
|
+@Controller
|
|
|
+@RequestMapping(value = "${adminPath}/mes/mesProductGlue")
|
|
|
+public class MesProductGlueController extends BaseController {
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ private MesProductGlueService mesProductGlueService;
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ protected FileUploadService fileUploadService;
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 获取数据
|
|
|
+ */
|
|
|
+ @ModelAttribute
|
|
|
+ public MesProductGlue get(String id, boolean isNewRecord) {
|
|
|
+ return mesProductGlueService.get(id, isNewRecord);
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 查询列表
|
|
|
+ */
|
|
|
+ @RequiresPermissions("mes:mesProductGlue:view")
|
|
|
+ @RequestMapping(value = {"list", ""})
|
|
|
+ public String list(MesProductGlue mesProductGlue, Model model) {
|
|
|
+ model.addAttribute("mesProductGlue", mesProductGlue);
|
|
|
+ return "modules/mes/mesProductGlueList";
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 查询列表数据
|
|
|
+ */
|
|
|
+ @RequiresPermissions("mes:mesProductGlue:view")
|
|
|
+ @RequestMapping(value = "listData")
|
|
|
+ @ResponseBody
|
|
|
+ public Page<MesProductGlue> listData(MesProductGlue mesProductGlue, HttpServletRequest request, HttpServletResponse response) {
|
|
|
+ mesProductGlue.setPage(new Page<>(request, response));
|
|
|
+ Page<MesProductGlue> page = mesProductGlueService.findPage(mesProductGlue);
|
|
|
+ return page;
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 查看编辑表单
|
|
|
+ */
|
|
|
+ @RequiresPermissions("mes:mesProductGlue:view")
|
|
|
+ @RequestMapping(value = "form")
|
|
|
+ public String form(MesProductGlue mesProductGlue, Model model) {
|
|
|
+ model.addAttribute("mesProductGlue", mesProductGlue);
|
|
|
+ return "modules/mes/mesProductGlueForm";
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 保存数据
|
|
|
+ */
|
|
|
+ @RequiresPermissions("mes:mesProductGlue:edit")
|
|
|
+ @PostMapping(value = "save")
|
|
|
+ @ResponseBody
|
|
|
+ public String save(@Validated MesProductGlue mesProductGlue) {
|
|
|
+ mesProductGlueService.save(mesProductGlue);
|
|
|
+ return renderResult(Global.TRUE, text("保存胶水更换记录成功!"));
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 导出数据
|
|
|
+ */
|
|
|
+ @RequiresPermissions("mes:mesProductGlue:view")
|
|
|
+ @RequestMapping(value = "exportData")
|
|
|
+ public void exportData(MesProductGlue mesProductGlue, HttpServletResponse response) {
|
|
|
+ List<MesProductGlue> list = mesProductGlueService.findList(mesProductGlue);
|
|
|
+ String fileName = "胶水更换记录" + DateUtils.getDate("yyyyMMddHHmmss") + ".xlsx";
|
|
|
+ try(ExcelExport ee = new ExcelExport("胶水更换记录", MesProductGlue.class)){
|
|
|
+ ee.setDataList(list).write(response, fileName);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 下载模板
|
|
|
+ */
|
|
|
+ @RequiresPermissions("mes:mesProductGlue:view")
|
|
|
+ @RequestMapping(value = "importTemplate")
|
|
|
+ public void importTemplate(HttpServletResponse response) {
|
|
|
+ MesProductGlue mesProductGlue = new MesProductGlue();
|
|
|
+ List<MesProductGlue> list = ListUtils.newArrayList(mesProductGlue);
|
|
|
+ String fileName = "胶水更换记录模板.xlsx";
|
|
|
+ try(ExcelExport ee = new ExcelExport("胶水更换记录", MesProductGlue.class, Type.IMPORT)){
|
|
|
+ ee.setDataList(list).write(response, fileName);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 导入数据
|
|
|
+ */
|
|
|
+ @ResponseBody
|
|
|
+ @RequiresPermissions("mes:mesProductGlue:edit")
|
|
|
+ @PostMapping(value = "importData")
|
|
|
+ public String importData(MultipartFile file) {
|
|
|
+ try {
|
|
|
+ String message = mesProductGlueService.importData(file);
|
|
|
+ return renderResult(Global.TRUE, "posfull:"+message);
|
|
|
+ } catch (Exception ex) {
|
|
|
+ return renderResult(Global.FALSE, "posfull:"+ex.getMessage());
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+// @RequiresPermissions(value={"mes:mesProductGlue:apia", "mes:mesProductGlue:apib"}, logical= Logical.OR)
|
|
|
+ @PostMapping("/submit")
|
|
|
+ @ResponseBody
|
|
|
+ public String submit(MesProductGlue mesProductGlue) {
|
|
|
+ mesProductGlueService.save(mesProductGlue);
|
|
|
+ return renderResult(Global.TRUE, text("操作成功!"));
|
|
|
+ }
|
|
|
+
|
|
|
+// @RequiresPermissions(value={"mes:mesProductGlue:apia", "mes:mesProductGlue:apib"}, logical= Logical.OR)
|
|
|
+ @RequestMapping("lists")
|
|
|
+ @ResponseBody
|
|
|
+ public CommonResp<List<MesProductGlue>> lists(MesProductGlue mesProductGlue, HttpServletRequest request, HttpServletResponse response){
|
|
|
+
|
|
|
+ CommonResp<List<MesProductGlue>> resp = new CommonResp<>();
|
|
|
+
|
|
|
+ // 构造图片访问的基础URL
|
|
|
+ String host = request.getScheme() + "://" + request.getServerName() + ":" + request.getServerPort() + "/js";
|
|
|
+
|
|
|
+ // 从 request 获取并设置分页参数
|
|
|
+ mesProductGlue.setPage(new Page<>(request, response));
|
|
|
+
|
|
|
+ // 分页查询
|
|
|
+ Page<MesProductGlue> page = mesProductGlueService.findPage(mesProductGlue);
|
|
|
+ List<MesProductGlue> list = page.getList();
|
|
|
+
|
|
|
+ resp.setData(list);
|
|
|
+ resp.setResult(Global.TRUE);
|
|
|
+ return resp;
|
|
|
+ }
|
|
|
+
|
|
|
+// @RequiresPermissions(value={"mes:mesProductGlue:apia", "mes:mesProductGlue:apib"}, logical= Logical.OR)
|
|
|
+ @RequestMapping("info")
|
|
|
+ @ResponseBody
|
|
|
+ public CommonResp<MesProductGlue> info(MesProductGlue mesProductGlue, HttpServletRequest request, HttpServletResponse response){
|
|
|
+
|
|
|
+ CommonResp<MesProductGlue> resp = new CommonResp<>();
|
|
|
+
|
|
|
+ // 构造图片访问的基础URL
|
|
|
+ String host = request.getScheme() + "://" + request.getServerName() + ":" + request.getServerPort() + "/js";
|
|
|
+
|
|
|
+ // 图片
|
|
|
+ FileUpload fu = new FileUpload();
|
|
|
+ fu.setBizKey(mesProductGlue.getId());
|
|
|
+ fu.setBizType("mesProductGlue_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);
|
|
|
+ }
|
|
|
+ mesProductGlue.setImg(imgList);
|
|
|
+ }
|
|
|
+
|
|
|
+ resp.setData(mesProductGlue);
|
|
|
+ resp.setResult(Global.TRUE);
|
|
|
+ return resp;
|
|
|
+ }
|
|
|
+
|
|
|
+}
|