| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205 |
- package com.jeesite.modules.mes.web;
- 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.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.mes.service.MesShippRecordService;
- 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.MesJbLogService;
- /**
- * 批次解绑记录表Controller
- * @author mes
- * @version 2024-04-12
- */
- @Controller
- @RequestMapping(value = "${adminPath}/mes/mesJbLog")
- public class MesJbLogController extends BaseController {
- @Autowired
- private MesJbLogService mesJbLogService;
- @Autowired
- private MesBatchSnService mesBatchSnService;
- @Autowired
- private MesProductService mesProductService;
- @Autowired
- private MesShippRecordService mesShippRecordService;
- /**
- * 获取数据
- */
- @ModelAttribute
- public MesJbLog get(String id, boolean isNewRecord) {
- return mesJbLogService.get(id, isNewRecord);
- }
-
- /**
- * 查询列表
- */
- @RequiresPermissions("mes:mesJbLog:view")
- @RequestMapping(value = {"list", ""})
- public String list(MesJbLog mesJbLog, Model model) {
- model.addAttribute("mesJbLog", mesJbLog);
- return "modules/mes/mesJbLogList";
- }
-
- /**
- * 查询列表数据
- */
- @RequiresPermissions("mes:mesJbLog:view")
- @RequestMapping(value = "listData")
- @ResponseBody
- public Page<MesJbLog> listData(MesJbLog mesJbLog, HttpServletRequest request, HttpServletResponse response) {
- mesJbLog.setPage(new Page<>(request, response));
- Page<MesJbLog> page = mesJbLogService.findPage(mesJbLog);
- return page;
- }
- /**
- * 查看编辑表单
- */
- @RequiresPermissions("mes:mesJbLog:view")
- @RequestMapping(value = "form")
- public String form(MesJbLog mesJbLog, Model model) {
- model.addAttribute("mesJbLog", mesJbLog);
- return "modules/mes/mesJbLogForm";
- }
- /**
- * 保存数据
- */
- @RequiresPermissions("mes:mesJbLog:edit")
- @PostMapping(value = "save")
- @ResponseBody
- public String save(@Validated MesJbLog mesJbLog) {
- mesJbLogService.save(mesJbLog);
- return renderResult(Global.TRUE, text("保存批次解绑记录表成功!"));
- }
- @RequiresPermissions("mes:mesJbLog:api")
- @RequestMapping(value = "ulist")
- @ResponseBody
- public CommonResp ulist(HttpServletRequest req, HttpServletResponse response) {
- CommonResp<Page> resp = new CommonResp<>();
- User user = UserUtils.getUser();
- MesJbLog mesJbLog = new MesJbLog();
- mesJbLog.setCreateBy(user.getUserCode());
- mesJbLog.setPage(new Page<>(req, response));
- Page<MesJbLog> page = mesJbLogService.findPage(mesJbLog);
- resp.setData(page);
- resp.setResult(Global.TRUE);
- return resp;
- }
- @RequiresPermissions("mes:mesJbLog:api")
- @RequestMapping(value = "getBatchInfo")
- @ResponseBody
- public CommonResp getBatchInfo(HttpServletRequest req) {
- CommonResp<List<MesProduct>> resp = new CommonResp<>();
- String batchSn = req.getParameter("batchSn");
- MesBatchSn mesBatchSn = new MesBatchSn();
- mesBatchSn.setBatchSn(batchSn);
- MesBatchSn mbs = mesBatchSnService.findInfo(mesBatchSn);
- if(ObjectUtils.isEmpty(mbs)){
- resp.setResult(Global.FALSE);
- resp.setMessage("批次信息不存在");
- return resp;
- }
- // if(mbs.getNums()==0){
- // resp.setResult(Global.FALSE);
- // resp.setMessage("当前批次未绑定工件");
- // return resp;
- // }
- MesProduct mesProduct = new MesProduct();;
- mesProduct.setBatchSn(batchSn);
- List<MesProduct> mp = mesProductService.findList(mesProduct);
- resp.setData(mp);
- resp.setResult(Global.TRUE);
- return resp;
- }
- @RequiresPermissions("mes:mesJbLog:api")
- @PostMapping(value = "addSave")
- @Transactional
- @ResponseBody
- public CommonResp addSave(HttpServletRequest req) {
- String batchSn = req.getParameter("batchSn");
- String sn = req.getParameter("sn");
- CommonResp<Map<String, Object>> resp = new CommonResp<>();
- Map<String, Object> map = MapUtils.newHashMap();
- resp.setResult(Global.FALSE);
- if(StringUtils.isEmpty(batchSn) ||StringUtils.isEmpty(sn)){
- resp.setMessage("参数错误");
- return resp;
- }
- MesBatchSn mesBatchSn = new MesBatchSn();
- mesBatchSn.setBatchSn(batchSn);
- MesBatchSn mbs = mesBatchSnService.findInfo(mesBatchSn);
- if(ObjectUtils.isEmpty(mbs)){
- resp.setMessage("批次码信息不存在");
- return resp;
- }
- MesShippRecord mesShippRecord =new MesShippRecord();
- mesShippRecord.setBatchSn(batchSn);
- List<MesShippRecord> msr = mesShippRecordService.findList(mesShippRecord);
- if(!ListUtils.isEmpty(msr)){
- resp.setMessage("当前批次已出货,不能解绑");
- return resp;
- }
- MesProduct mesProduct = new MesProduct();
- mesProduct.setBatchSn(batchSn);
- mesProduct.setSn(sn);
- MesProduct mp = mesProductService.findInfo(mesProduct);
- if(ObjectUtils.isEmpty(mp)){
- resp.setMessage("当前工件已解绑");
- return resp;
- }
- mp.setBatchSn("");
- mp.setBindDate(null);
- mp.setBindBy("");
- mesProductService.save(mp);
- MesJbLog mesJbLog = new MesJbLog();
- mesJbLog.setBatchSn(batchSn);
- mesJbLog.setSn(sn);
- mesJbLogService.save(mesJbLog);
- mbs.setNums(mbs.getNums()-1);
- mesBatchSnService.save(mbs);
- resp.setResult(Global.TRUE);
- resp.setMessage("操作成功");
- return resp;
- }
- }
|