|
|
@@ -0,0 +1,105 @@
|
|
|
+package com.jeesite.modules.mes.web;
|
|
|
+
|
|
|
+import com.jeesite.common.config.Global;
|
|
|
+import com.jeesite.common.entity.Page;
|
|
|
+import com.jeesite.common.lang.StringUtils;
|
|
|
+import com.jeesite.common.web.BaseController;
|
|
|
+import com.jeesite.modules.mes.entity.MesProductScreen;
|
|
|
+import com.jeesite.modules.mes.resp.CommonResp;
|
|
|
+import com.jeesite.modules.mes.service.MesProductScreenService;
|
|
|
+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 javax.servlet.http.HttpServletRequest;
|
|
|
+import javax.servlet.http.HttpServletResponse;
|
|
|
+import java.util.HashMap;
|
|
|
+import java.util.Map;
|
|
|
+
|
|
|
+/**
|
|
|
+ * 大屏展示配置Controller
|
|
|
+ * @author mes
|
|
|
+ * @version 2026-08-12
|
|
|
+ */
|
|
|
+@Controller
|
|
|
+@RequestMapping(value = "${adminPath}/mes/mesProductScreen")
|
|
|
+public class MesProductScreenController extends BaseController {
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ private MesProductScreenService mesProductScreenService;
|
|
|
+
|
|
|
+ @ModelAttribute
|
|
|
+ public MesProductScreen get(String id, boolean isNewRecord) {
|
|
|
+ return mesProductScreenService.get(id, isNewRecord);
|
|
|
+ }
|
|
|
+
|
|
|
+ @RequiresPermissions("mes:mesProductScreen:view")
|
|
|
+ @RequestMapping(value = {"list", ""})
|
|
|
+ public String list(MesProductScreen mesProductScreen, Model model) {
|
|
|
+ model.addAttribute("mesProductScreen", mesProductScreen);
|
|
|
+ return "modules/mes/mesProductScreenList";
|
|
|
+ }
|
|
|
+
|
|
|
+ @RequiresPermissions("mes:mesProductScreen:view")
|
|
|
+ @RequestMapping(value = "listData")
|
|
|
+ @ResponseBody
|
|
|
+ public Page<MesProductScreen> listData(MesProductScreen mesProductScreen,
|
|
|
+ HttpServletRequest request, HttpServletResponse response) {
|
|
|
+ mesProductScreen.setPage(new Page<>(request, response));
|
|
|
+ return mesProductScreenService.findPage(mesProductScreen);
|
|
|
+ }
|
|
|
+
|
|
|
+ @RequiresPermissions("mes:mesProductScreen:view")
|
|
|
+ @RequestMapping(value = "form")
|
|
|
+ public String form(MesProductScreen mesProductScreen, Model model) {
|
|
|
+ model.addAttribute("mesProductScreen", mesProductScreen);
|
|
|
+ return "modules/mes/mesProductScreenForm";
|
|
|
+ }
|
|
|
+
|
|
|
+ @RequiresPermissions("mes:mesProductScreen:edit")
|
|
|
+ @PostMapping(value = "save")
|
|
|
+ @ResponseBody
|
|
|
+ public String save(@Validated MesProductScreen mesProductScreen) {
|
|
|
+ mesProductScreenService.save(mesProductScreen);
|
|
|
+ return renderResult(Global.TRUE, text("保存大屏展示配置成功!"));
|
|
|
+ }
|
|
|
+
|
|
|
+ @RequiresPermissions("mes:mesProductScreen:edit")
|
|
|
+ @RequestMapping(value = "delete")
|
|
|
+ @ResponseBody
|
|
|
+ public String delete(MesProductScreen mesProductScreen) {
|
|
|
+ mesProductScreenService.delete(mesProductScreen);
|
|
|
+ return renderResult(Global.TRUE, text("删除大屏展示配置成功!"));
|
|
|
+ }
|
|
|
+
|
|
|
+ @RequestMapping(value = "latestConfig")
|
|
|
+ @ResponseBody
|
|
|
+ public CommonResp<Map<String, Object>> latestConfig() {
|
|
|
+ CommonResp<Map<String, Object>> resp = new CommonResp<>();
|
|
|
+ MesProductScreen latest = mesProductScreenService.getLatest();
|
|
|
+ Map<String, Object> data = new HashMap<>();
|
|
|
+ data.put("peopleNums", parseIntSafe(latest == null ? null : latest.getPeopleNum()));
|
|
|
+ data.put("deviceNums", parseIntSafe(latest == null ? null : latest.getMachineNum()));
|
|
|
+ data.put("planNums", parseIntSafe(latest == null ? null : latest.getPlanOutput()));
|
|
|
+ resp.setData(data);
|
|
|
+ resp.setResult(Global.TRUE);
|
|
|
+ return resp;
|
|
|
+ }
|
|
|
+
|
|
|
+ private int parseIntSafe(String val) {
|
|
|
+ if (StringUtils.isBlank(val)) {
|
|
|
+ return 0;
|
|
|
+ }
|
|
|
+ try {
|
|
|
+ return Integer.parseInt(val.trim());
|
|
|
+ } catch (Exception e) {
|
|
|
+ return 0;
|
|
|
+ }
|
|
|
+ }
|
|
|
+}
|