package com.jeesite.modules.mes.web; import com.jeesite.common.entity.Page; import com.jeesite.common.lang.StringUtils; import com.jeesite.common.mybatis.mapper.query.QueryType; import com.jeesite.common.web.BaseController; import com.jeesite.modules.mes.entity.MesBatchSn; import com.jeesite.modules.mes.entity.MesErpPrdInstockLog; import com.jeesite.modules.mes.service.MesBatchSnService; import com.jeesite.modules.mes.service.MesErpPrdInstockLogService; import org.apache.shiro.authz.annotation.RequiresPermissions; import org.springframework.stereotype.Controller; import org.springframework.ui.Model; import org.springframework.web.bind.annotation.ModelAttribute; 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.List; /** * MES 生产入库单与批次码绑定明细。 */ @Controller @RequestMapping(value = "${adminPath}/mes/mesErpPrdInstockLog") public class MesErpPrdInstockLogController extends BaseController { private final MesErpPrdInstockLogService mesErpPrdInstockLogService; private final MesBatchSnService mesBatchSnService; public MesErpPrdInstockLogController(MesErpPrdInstockLogService mesErpPrdInstockLogService, MesBatchSnService mesBatchSnService) { this.mesErpPrdInstockLogService = mesErpPrdInstockLogService; this.mesBatchSnService = mesBatchSnService; } @ModelAttribute public MesErpPrdInstockLog get(String id, boolean isNewRecord) { return mesErpPrdInstockLogService.get(id, isNewRecord); } @RequiresPermissions("mes:mesErpPrdInstockLog:view") @RequestMapping(value = {"list", ""}) public String list(MesErpPrdInstockLog mesErpPrdInstockLog, Model model) { model.addAttribute("mesErpPrdInstockLog", mesErpPrdInstockLog); return "modules/mes/mesErpPrdInstockLogList"; } @RequiresPermissions("mes:mesErpPrdInstockLog:view") @RequestMapping(value = "listData") @ResponseBody public Page listData(MesErpPrdInstockLog mesErpPrdInstockLog, HttpServletRequest request, HttpServletResponse response) { mesErpPrdInstockLog.setPage(new Page<>(request, response)); String batchSnQuery = StringUtils.trim(request.getParameter("batchSnQuery")); if (StringUtils.isNotBlank(batchSnQuery)) { mesErpPrdInstockLog.getSqlMap().getWhere() .and("a.batch_sn_list", QueryType.LIKE, batchSnQuery); } return mesErpPrdInstockLogService.findPage(mesErpPrdInstockLog); } @RequiresPermissions("mes:mesErpPrdInstockLog:view") @RequestMapping(value = "detail") public String detail(MesErpPrdInstockLog mesErpPrdInstockLog, Model model) { List batchList = mesBatchSnService.findByErpInstockBillNo(mesErpPrdInstockLog.getErpBillNo()); model.addAttribute("mesErpPrdInstockLog", mesErpPrdInstockLog); model.addAttribute("batchList", batchList); return "modules/mes/mesErpPrdInstockLogDetail"; } /** 从 ERP 入库单号跳转绑定明细(MES 推送才有记录) */ @RequiresPermissions("mes:mesErpPrdInstockLog:view") @RequestMapping(value = "byErpBill") public String byErpBill(String erpBillNo, Model model) { String billNo = StringUtils.trim(erpBillNo); MesErpPrdInstockLog log = mesErpPrdInstockLogService.findByErpBillNo(billNo); if (log == null) { MesErpPrdInstockLog query = new MesErpPrdInstockLog(); query.setErpBillNo(billNo); model.addAttribute("mesErpPrdInstockLog", query); model.addAttribute("message", "入库单 " + billNo + " 无 MES 批次绑定记录(可能非 MES 推送生成)"); return "modules/mes/mesErpPrdInstockLogList"; } return detail(log, model); } }