|
|
@@ -0,0 +1,201 @@
|
|
|
+package com.jeesite.modules.mes.web;
|
|
|
+
|
|
|
+import java.util.List;
|
|
|
+import javax.servlet.http.HttpServletRequest;
|
|
|
+import javax.servlet.http.HttpServletResponse;
|
|
|
+import java.util.Date;
|
|
|
+
|
|
|
+import com.alibaba.fastjson.JSON;
|
|
|
+import com.alibaba.fastjson.JSONArray;
|
|
|
+import com.alibaba.fastjson.JSONObject;
|
|
|
+import com.jeesite.common.lang.StringUtils;
|
|
|
+import com.jeesite.modules.mes.req.MesSearchDateReq;
|
|
|
+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.transaction.annotation.Transactional;
|
|
|
+import org.springframework.ui.Model;
|
|
|
+import org.springframework.validation.annotation.Validated;
|
|
|
+import org.springframework.web.bind.annotation.*;
|
|
|
+
|
|
|
+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.MesProductArcWelding;
|
|
|
+import com.jeesite.modules.mes.service.MesProductArcWeldingService;
|
|
|
+
|
|
|
+/**
|
|
|
+ * 弧焊参数Controller
|
|
|
+ * @author jingbo
|
|
|
+ * @version 2026-05-21
|
|
|
+ */
|
|
|
+@Controller
|
|
|
+@RequestMapping(value = "${adminPath}/mes/mesProductArcWelding")
|
|
|
+public class MesProductArcWeldingController extends BaseController {
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ private MesProductArcWeldingService mesProductArcWeldingService;
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 获取数据
|
|
|
+ */
|
|
|
+ @ModelAttribute
|
|
|
+ public MesProductArcWelding get(String id, Date createDate, boolean isNewRecord) {
|
|
|
+ MesProductArcWelding mesProductArcWelding = new MesProductArcWelding();
|
|
|
+ mesProductArcWelding.setId(id);
|
|
|
+ mesProductArcWelding.setCreateDate(createDate);
|
|
|
+ mesProductArcWelding.setIsNewRecord(isNewRecord);
|
|
|
+ return mesProductArcWeldingService.getAndValid(mesProductArcWelding);
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 查询列表
|
|
|
+ */
|
|
|
+ @RequiresPermissions("mes:mesProductArcWelding:view")
|
|
|
+ @RequestMapping(value = {"list", ""})
|
|
|
+ public String list(MesProductArcWelding mesProductArcWelding, Model model) {
|
|
|
+ model.addAttribute("mesProductArcWelding", mesProductArcWelding);
|
|
|
+ return "modules/mes/mesProductArcWeldingList";
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 查询列表数据
|
|
|
+ */
|
|
|
+ @RequiresPermissions("mes:mesProductArcWelding:view")
|
|
|
+ @RequestMapping(value = "listData")
|
|
|
+ @ResponseBody
|
|
|
+ public Page<MesProductArcWelding> listData(MesProductArcWelding mesProductArcWelding, HttpServletRequest request, HttpServletResponse response) {
|
|
|
+ mesProductArcWelding.setPage(new Page<>(request, response));
|
|
|
+ Page<MesProductArcWelding> page = mesProductArcWeldingService.findPage(mesProductArcWelding);
|
|
|
+ return page;
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 查看编辑表单
|
|
|
+ */
|
|
|
+ @RequiresPermissions("mes:mesProductArcWelding:view")
|
|
|
+ @RequestMapping(value = "form")
|
|
|
+ public String form(MesProductArcWelding mesProductArcWelding, Model model) {
|
|
|
+ model.addAttribute("mesProductArcWelding", mesProductArcWelding);
|
|
|
+ return "modules/mes/mesProductArcWeldingForm";
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 保存数据
|
|
|
+ */
|
|
|
+ @RequiresPermissions("mes:mesProductArcWelding:edit")
|
|
|
+ @PostMapping(value = "save")
|
|
|
+ @ResponseBody
|
|
|
+ public String save(@Validated MesProductArcWelding mesProductArcWelding) {
|
|
|
+ mesProductArcWeldingService.save(mesProductArcWelding);
|
|
|
+ return renderResult(Global.TRUE, text("保存弧焊参数成功!"));
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 导出数据
|
|
|
+ */
|
|
|
+ @RequiresPermissions("mes:mesProductArcWelding:view")
|
|
|
+ @RequestMapping(value = "exportData")
|
|
|
+ public void exportData(MesProductArcWelding mesProductArcWelding, HttpServletResponse response) {
|
|
|
+ List<MesProductArcWelding> list = mesProductArcWeldingService.findList(mesProductArcWelding);
|
|
|
+ String fileName = "弧焊参数" + DateUtils.getDate("yyyyMMddHHmmss") + ".xlsx";
|
|
|
+ try(ExcelExport ee = new ExcelExport("弧焊参数", MesProductArcWelding.class)){
|
|
|
+ ee.setDataList(list).write(response, fileName);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 下载模板
|
|
|
+ */
|
|
|
+ @RequiresPermissions("mes:mesProductArcWelding:view")
|
|
|
+ @RequestMapping(value = "importTemplate")
|
|
|
+ public void importTemplate(HttpServletResponse response) {
|
|
|
+ MesProductArcWelding mesProductArcWelding = new MesProductArcWelding();
|
|
|
+ List<MesProductArcWelding> list = ListUtils.newArrayList(mesProductArcWelding);
|
|
|
+ String fileName = "弧焊参数模板.xlsx";
|
|
|
+ try(ExcelExport ee = new ExcelExport("弧焊参数", MesProductArcWelding.class, Type.IMPORT)){
|
|
|
+ ee.setDataList(list).write(response, fileName);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 导入数据
|
|
|
+ */
|
|
|
+ @ResponseBody
|
|
|
+ @RequiresPermissions("mes:mesProductArcWelding:edit")
|
|
|
+ @PostMapping(value = "importData")
|
|
|
+ public String importData(MultipartFile file) {
|
|
|
+ try {
|
|
|
+ String message = mesProductArcWeldingService.importData(file);
|
|
|
+ return renderResult(Global.TRUE, "posfull:"+message);
|
|
|
+ } catch (Exception ex) {
|
|
|
+ return renderResult(Global.FALSE, "posfull:"+ex.getMessage());
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 删除数据
|
|
|
+ */
|
|
|
+ @RequiresPermissions("mes:mesProductArcWelding:edit")
|
|
|
+ @RequestMapping(value = "delete")
|
|
|
+ @ResponseBody
|
|
|
+ public String delete(MesProductArcWelding mesProductArcWelding) {
|
|
|
+ mesProductArcWeldingService.delete(mesProductArcWelding);
|
|
|
+ return renderResult(Global.TRUE, text("删除弧焊参数成功!"));
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 查看详情
|
|
|
+ */
|
|
|
+ @RequiresPermissions("mes:mesProductArcWelding:view")
|
|
|
+ @GetMapping("info")
|
|
|
+ public String info(MesProductArcWelding mesProductArcWelding, Model model) {
|
|
|
+ model.addAttribute("mesProductArcWelding", mesProductArcWelding);
|
|
|
+ return "modules/mes/mesProductArcWeldingInfo";
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 接口保存数据
|
|
|
+ * content格式: ["电压1|电流1|送丝速度1|错误码1|JOB号1|电压2|电流2|送丝速度2|错误码2|JOB号2|时间", ...]
|
|
|
+ * 注意: 每个焊机5个参数(电压、电流、送丝速度、错误码、JOB号),最后是时间戳
|
|
|
+ * 2个焊机: 10个参数 + 1个时间 = 11个字段
|
|
|
+ * 3个焊机: 15个参数 + 1个时间 = 16个字段
|
|
|
+ * 4个焊机: 20个参数 + 1个时间 = 21个字段
|
|
|
+ */
|
|
|
+ @PostMapping(value = "batchsave")
|
|
|
+ @ResponseBody
|
|
|
+ @Transactional
|
|
|
+ public String batchsave(HttpServletRequest request) {
|
|
|
+ String params = request.getParameter("params");
|
|
|
+ if(StringUtils.isEmpty(params)){
|
|
|
+ return renderResult(Global.FALSE, text("参数错误!"));
|
|
|
+ }
|
|
|
+
|
|
|
+ JSONArray jsonArr = JSON.parseArray(params);
|
|
|
+ if(jsonArr.size() <= 0){
|
|
|
+ return renderResult(Global.FALSE, text("参数错误!"));
|
|
|
+ }
|
|
|
+
|
|
|
+ for (int i=0; i<jsonArr.size(); i++) {
|
|
|
+ JSONObject obj = jsonArr.getJSONObject(i);
|
|
|
+
|
|
|
+ MesProductArcWelding mesProductArcWelding = new MesProductArcWelding();
|
|
|
+ mesProductArcWelding.setSn(obj.getString("sn"));
|
|
|
+ mesProductArcWelding.setOprno(obj.getString("oprno"));
|
|
|
+ mesProductArcWelding.setLineSn(obj.getString("lineSn"));
|
|
|
+ mesProductArcWelding.setContent(obj.getString("content"));
|
|
|
+ mesProductArcWeldingService.save(mesProductArcWelding);
|
|
|
+ }
|
|
|
+
|
|
|
+ return renderResult(Global.TRUE, text("操作成功!"));
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+}
|