| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194 |
- package com.jeesite.modules.mes.web;
- import java.text.SimpleDateFormat;
- import java.util.Date;
- import java.util.List;
- import java.util.Map;
- import javax.servlet.http.HttpServletRequest;
- import javax.servlet.http.HttpServletResponse;
- import com.jeesite.common.collect.ListUtils;
- import com.jeesite.common.collect.MapUtils;
- import com.jeesite.common.mybatis.mapper.query.QueryType;
- import com.jeesite.modules.mes.entity.*;
- import com.jeesite.modules.mes.resp.CommonResp;
- import com.jeesite.modules.mes.service.MesBatchSnService;
- 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.transaction.annotation.Transactional;
- import org.springframework.ui.Model;
- import org.springframework.util.ObjectUtils;
- import org.springframework.util.StringUtils;
- 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.entity.Page;
- import com.jeesite.common.web.BaseController;
- import com.jeesite.modules.mes.service.MesIqcService;
- /**
- * IQC检测记录表Controller
- * @author mes
- * @version 2024-04-12
- */
- @Controller
- @RequestMapping(value = "${adminPath}/mes/mesIqc")
- public class MesIqcController extends BaseController {
- @Autowired
- private MesIqcService mesIqcService;
- @Autowired
- private MesProductService mesProductService;
- @Autowired
- private MesBatchSnService mesBatchSnService;
- /**
- * 获取数据
- */
- @ModelAttribute
- public MesIqc get(String id, boolean isNewRecord) {
- return mesIqcService.get(id, isNewRecord);
- }
-
- /**
- * 查询列表
- */
- @RequiresPermissions("mes:mesIqc:view")
- @RequestMapping(value = {"list", ""})
- public String list(MesIqc mesIqc, Model model) {
- model.addAttribute("mesIqc", mesIqc);
- return "modules/mes/mesIqcList";
- }
-
- /**
- * 查询列表数据
- */
- @RequiresPermissions("mes:mesIqc:view")
- @RequestMapping(value = "listData")
- @ResponseBody
- public Page<MesIqc> listData(MesIqc mesIqc, HttpServletRequest request, HttpServletResponse response) {
- mesIqc.setPage(new Page<>(request, response));
- Page<MesIqc> page = mesIqcService.findPage(mesIqc);
- return page;
- }
- /**
- * 查看编辑表单
- */
- @RequiresPermissions("mes:mesIqc:view")
- @RequestMapping(value = "form")
- public String form(MesIqc mesIqc, Model model) {
- model.addAttribute("mesIqc", mesIqc);
- return "modules/mes/mesIqcForm";
- }
- /**
- * 查看编辑表单
- */
- @RequiresPermissions("mes:mesIqc:view")
- @RequestMapping(value = "info")
- public String info(MesIqc mesIqc, Model model) {
- MesProduct mesProduct = new MesProduct();
- mesProduct.setBatchSn(mesIqc.getBatchSn());
- List<MesProduct> mp = mesProductService.findList(mesProduct);
- model.addAttribute("mesIqc", mesIqc);
- model.addAttribute("mp", mp);
- return "modules/mes/mesIqcInfo";
- }
- /**
- * 保存数据
- */
- @RequiresPermissions("mes:mesIqc:edit")
- @PostMapping(value = "save")
- @ResponseBody
- public String save(@Validated MesIqc mesIqc) {
- mesIqcService.save(mesIqc);
- return renderResult(Global.TRUE, text("保存IQC检测记录表成功!"));
- }
- @RequiresPermissions("mes:mesIqc:api")
- @RequestMapping(value = "ulist")
- @ResponseBody
- public CommonResp ulist(HttpServletRequest req, HttpServletResponse response) {
- User user = UserUtils.getUser();
- CommonResp<Page> resp = new CommonResp<>();
- MesIqc mesIqc = new MesIqc();
- mesIqc.setCreateBy(user.getUserCode());
- mesIqc.setPage(new Page<>(req, response));
- Page<MesIqc> page = mesIqcService.findPage(mesIqc);
- resp.setData(page);
- resp.setResult(Global.TRUE);
- return resp;
- }
- @RequiresPermissions("mes:mesIqc:api")
- @RequestMapping(value = "ulistDetail")
- @ResponseBody
- public CommonResp ulistDetail(MesIqc mesIqc,HttpServletRequest req) {
- CommonResp<MesIqc> resp = new CommonResp<>();
- if(ObjectUtils.isEmpty(mesIqc)){
- resp.setResult(Global.FALSE);
- resp.setMessage("记录不存在");
- return resp;
- }
- MesProduct mesProduct = new MesProduct();
- mesProduct.setBatchSn(mesIqc.getBatchSn());
- List<MesProduct> lists = mesProductService.findList(mesProduct);
- mesIqc.setItems(lists);
- resp.setData(mesIqc);
- resp.setResult(Global.TRUE);
- return resp;
- }
- @RequiresPermissions("mes:mesIqc:api")
- @PostMapping(value = "addSave")
- @Transactional
- @ResponseBody
- public CommonResp addSave(HttpServletRequest req) {
- String batchSn = req.getParameter("batchSn");
- String result = req.getParameter("result");
- String remark = req.getParameter("remark");
- CommonResp<Map<String, Object>> resp = new CommonResp<>();
- Map<String, Object> map = MapUtils.newHashMap();
- resp.setResult(Global.FALSE);
- if(StringUtils.isEmpty(batchSn) ||StringUtils.isEmpty(result)){
- resp.setMessage("参数错误");
- return resp;
- }
- MesBatchSn mesBatchSn = new MesBatchSn();
- mesBatchSn.setBatchSn(batchSn);
- MesBatchSn msInfo = mesBatchSnService.findInfo(mesBatchSn);
- if(ObjectUtils.isEmpty(msInfo)){
- resp.setMessage("包装码不存在");
- return resp;
- }
- MesIqc mesIqc = new MesIqc();
- mesIqc.setBatchSn(batchSn);
- List<MesIqc> miqc = mesIqcService.findList(mesIqc);
- if(!ListUtils.isEmpty(miqc)){
- resp.setMessage("当前包装码已检查");
- return resp;
- }
- MesIqc mesIqc1 = new MesIqc();
- mesIqc1.setBatchSn(batchSn);
- mesIqc1.setLineSn(msInfo.getLineSn());
- mesIqc1.setState(result);
- mesIqc1.setRemark(remark);
- mesIqcService.save(mesIqc1);
- resp.setResult(Global.TRUE);
- resp.setMessage("操作成功");
- return resp;
- }
- }
|