|
|
@@ -0,0 +1,196 @@
|
|
|
+package com.jeesite.modules.mes.web;
|
|
|
+
|
|
|
+import java.util.List;
|
|
|
+
|
|
|
+import javax.servlet.http.HttpServletRequest;
|
|
|
+import javax.servlet.http.HttpServletResponse;
|
|
|
+
|
|
|
+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 com.jeesite.common.codec.EncodeUtils;
|
|
|
+import com.jeesite.common.config.Global;
|
|
|
+import com.jeesite.common.entity.Page;
|
|
|
+import com.jeesite.common.lang.StringUtils;
|
|
|
+import com.jeesite.common.mybatis.mapper.query.QueryType;
|
|
|
+import com.alibaba.fastjson.JSONValidator;
|
|
|
+import com.jeesite.common.service.ServiceException;
|
|
|
+import com.jeesite.common.web.BaseController;
|
|
|
+import com.jeesite.modules.mes.entity.MesDeliveryNote;
|
|
|
+import com.jeesite.modules.mes.entity.MesDeliveryNoteBatch;
|
|
|
+import com.jeesite.modules.mes.entity.MesProduct;
|
|
|
+import com.jeesite.modules.mes.entity.MesProductBatch;
|
|
|
+import com.jeesite.modules.mes.service.MesDeliveryNoteBatchService;
|
|
|
+import com.jeesite.modules.mes.service.MesDeliveryNoteService;
|
|
|
+import com.jeesite.modules.mes.service.MesProductBatchService;
|
|
|
+import com.jeesite.modules.mes.service.MesProductService;
|
|
|
+
|
|
|
+/**
|
|
|
+ * 送货单Controller
|
|
|
+ */
|
|
|
+@Controller
|
|
|
+@RequestMapping(value = "${adminPath}/mes/mesDeliveryNote")
|
|
|
+public class MesDeliveryNoteController extends BaseController {
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ private MesDeliveryNoteService mesDeliveryNoteService;
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ private MesDeliveryNoteBatchService mesDeliveryNoteBatchService;
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ private MesProductBatchService mesProductBatchService;
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ private MesProductService mesProductService;
|
|
|
+
|
|
|
+ @ModelAttribute
|
|
|
+ public MesDeliveryNote get(String id, boolean isNewRecord) {
|
|
|
+ return mesDeliveryNoteService.get(id, isNewRecord);
|
|
|
+ }
|
|
|
+
|
|
|
+ @RequiresPermissions("mes:mesDeliveryNote:view")
|
|
|
+ @RequestMapping(value = {"list", ""})
|
|
|
+ public String list(MesDeliveryNote mesDeliveryNote, Model model) {
|
|
|
+ model.addAttribute("mesDeliveryNote", mesDeliveryNote);
|
|
|
+ return "modules/mes/mesDeliveryNoteList";
|
|
|
+ }
|
|
|
+
|
|
|
+ @RequiresPermissions("mes:mesDeliveryNote:view")
|
|
|
+ @RequestMapping(value = "listData")
|
|
|
+ @ResponseBody
|
|
|
+ public Page<MesDeliveryNote> listData(MesDeliveryNote mesDeliveryNote, HttpServletRequest request, HttpServletResponse response) {
|
|
|
+ mesDeliveryNote.setPage(new Page<>(request, response));
|
|
|
+ return mesDeliveryNoteService.findPage(mesDeliveryNote);
|
|
|
+ }
|
|
|
+
|
|
|
+ @RequiresPermissions("mes:mesDeliveryNote:view")
|
|
|
+ @RequestMapping(value = "form")
|
|
|
+ public String form(MesDeliveryNote mesDeliveryNote, Model model) {
|
|
|
+ model.addAttribute("mesDeliveryNote", mesDeliveryNote);
|
|
|
+ return "modules/mes/mesDeliveryNoteForm";
|
|
|
+ }
|
|
|
+
|
|
|
+ @RequiresPermissions("mes:mesDeliveryNote:edit")
|
|
|
+ @PostMapping(value = "save")
|
|
|
+ @ResponseBody
|
|
|
+ public String save(@Validated MesDeliveryNote mesDeliveryNote) {
|
|
|
+ try {
|
|
|
+ mesDeliveryNoteService.save(mesDeliveryNote);
|
|
|
+ } catch (ServiceException ex) {
|
|
|
+ return renderResult(Global.FALSE, ex.getMessage());
|
|
|
+ }
|
|
|
+ return renderResult(Global.TRUE, text("保存送货单成功!"));
|
|
|
+ }
|
|
|
+
|
|
|
+ @RequiresPermissions("mes:mesDeliveryNote:edit")
|
|
|
+ @RequestMapping(value = "delete")
|
|
|
+ @ResponseBody
|
|
|
+ public String delete(MesDeliveryNote mesDeliveryNote) {
|
|
|
+ try {
|
|
|
+ mesDeliveryNoteService.delete(mesDeliveryNote);
|
|
|
+ } catch (ServiceException ex) {
|
|
|
+ return renderResult(Global.FALSE, ex.getMessage());
|
|
|
+ }
|
|
|
+ return renderResult(Global.TRUE, text("删除送货单成功!"));
|
|
|
+ }
|
|
|
+
|
|
|
+ @RequiresPermissions("mes:mesDeliveryNote:view")
|
|
|
+ @RequestMapping(value = "bind")
|
|
|
+ public String bind(MesDeliveryNote mesDeliveryNote, Model model) {
|
|
|
+ model.addAttribute("mesDeliveryNote", mesDeliveryNote);
|
|
|
+ return "modules/mes/mesDeliveryNoteBind";
|
|
|
+ }
|
|
|
+
|
|
|
+ @RequiresPermissions("mes:mesDeliveryNote:view")
|
|
|
+ @RequestMapping(value = "bindListData")
|
|
|
+ @ResponseBody
|
|
|
+ public Page<MesDeliveryNoteBatch> bindListData(MesDeliveryNoteBatch mesDeliveryNoteBatch, HttpServletRequest request, HttpServletResponse response) {
|
|
|
+ mesDeliveryNoteBatch.setPage(new Page<>(request, response));
|
|
|
+ return mesDeliveryNoteBatchService.findPage(mesDeliveryNoteBatch);
|
|
|
+ }
|
|
|
+
|
|
|
+ @RequiresPermissions("mes:mesDeliveryNote:view")
|
|
|
+ @RequestMapping(value = "batchProducts")
|
|
|
+ public String batchProducts(String batchSn, Model model) {
|
|
|
+ model.addAttribute("batchSn", batchSn);
|
|
|
+ return "modules/mes/mesDeliveryNoteProducts";
|
|
|
+ }
|
|
|
+
|
|
|
+ @RequiresPermissions("mes:mesDeliveryNote:view")
|
|
|
+ @RequestMapping(value = "batchProductData")
|
|
|
+ @ResponseBody
|
|
|
+ public Page<MesProduct> batchProductData(MesProduct mesProduct, HttpServletRequest request, HttpServletResponse response) {
|
|
|
+ String batchSn = mesProduct.getBatchSn();
|
|
|
+ mesProduct.setBatchSn(null);
|
|
|
+ if (StringUtils.isBlank(batchSn)) {
|
|
|
+ mesProduct.getSqlMap().getWhere().and("id", QueryType.EQ, "-1");
|
|
|
+ } else {
|
|
|
+ mesProduct.getSqlMap().getWhere().and("batch_sn", QueryType.EQ, batchSn);
|
|
|
+ }
|
|
|
+ String sn = mesProduct.getSn();
|
|
|
+ if (StringUtils.isNotBlank(sn)) {
|
|
|
+ mesProduct.setSn(null);
|
|
|
+ mesProduct.getSqlMap().getWhere().and("sn", QueryType.LIKE, sn);
|
|
|
+ }
|
|
|
+ mesProduct.setPage(new Page<>(request, response));
|
|
|
+ return mesProductService.findPage(mesProduct);
|
|
|
+ }
|
|
|
+
|
|
|
+ @RequiresPermissions("mes:mesDeliveryNote:edit")
|
|
|
+ @PostMapping(value = "bindBatch")
|
|
|
+ @ResponseBody
|
|
|
+ public String bindBatch(String deliveryId, String batchIds) {
|
|
|
+ try {
|
|
|
+ mesDeliveryNoteService.bindBatches(deliveryId, batchIds);
|
|
|
+ } catch (ServiceException ex) {
|
|
|
+ return renderResult(Global.FALSE, ex.getMessage());
|
|
|
+ }
|
|
|
+ return renderResult(Global.TRUE, text("绑定成品批次成功!"));
|
|
|
+ }
|
|
|
+
|
|
|
+ @RequiresPermissions("mes:mesDeliveryNote:edit")
|
|
|
+ @RequestMapping(value = "unbindBatch")
|
|
|
+ @ResponseBody
|
|
|
+ public String unbindBatch(MesDeliveryNoteBatch mesDeliveryNoteBatch) {
|
|
|
+ mesDeliveryNoteBatchService.delete(mesDeliveryNoteBatch);
|
|
|
+ return renderResult(Global.TRUE, text("解除绑定成功!"));
|
|
|
+ }
|
|
|
+
|
|
|
+ @RequiresPermissions("mes:mesDeliveryNote:view")
|
|
|
+ @RequestMapping(value = "batchSelect")
|
|
|
+ public String batchSelect(MesProductBatch mesProductBatch, String selectData, Model model) {
|
|
|
+ String selectDataJson = EncodeUtils.decodeUrl(selectData);
|
|
|
+ if (selectDataJson != null && JSONValidator.from(selectDataJson).validate()) {
|
|
|
+ model.addAttribute("selectData", selectDataJson);
|
|
|
+ }
|
|
|
+ model.addAttribute("mesProductBatch", mesProductBatch);
|
|
|
+ return "modules/mes/mesProductBatchSelect";
|
|
|
+ }
|
|
|
+
|
|
|
+ @RequiresPermissions("mes:mesDeliveryNote:view")
|
|
|
+ @RequestMapping(value = "batchSelectData")
|
|
|
+ @ResponseBody
|
|
|
+ public Page<MesProductBatch> batchSelectData(MesProductBatch mesProductBatch, HttpServletRequest request, HttpServletResponse response) {
|
|
|
+ List<MesDeliveryNoteBatch> boundList = mesDeliveryNoteBatchService.findList(new MesDeliveryNoteBatch());
|
|
|
+ if (boundList != null && !boundList.isEmpty()) {
|
|
|
+ String[] boundIds = boundList.stream()
|
|
|
+ .map(MesDeliveryNoteBatch::getBatchId)
|
|
|
+ .filter(StringUtils::isNotBlank)
|
|
|
+ .distinct()
|
|
|
+ .toArray(String[]::new);
|
|
|
+ if (boundIds.length > 0) {
|
|
|
+ mesProductBatch.getSqlMap().getWhere().and("id", QueryType.NOT_IN, boundIds);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ mesProductBatch.setPage(new Page<>(request, response));
|
|
|
+ return mesProductBatchService.findPage(mesProductBatch);
|
|
|
+ }
|
|
|
+}
|