diff --git a/ruoyi-admin/src/main/java/com/ruoyi/system/controller/SysMakeorderPickController.java b/ruoyi-admin/src/main/java/com/ruoyi/system/controller/SysMakeorderPickController.java index b301e1aa..5cecaaba 100644 --- a/ruoyi-admin/src/main/java/com/ruoyi/system/controller/SysMakeorderPickController.java +++ b/ruoyi-admin/src/main/java/com/ruoyi/system/controller/SysMakeorderPickController.java @@ -3,15 +3,19 @@ package com.ruoyi.system.controller; import com.ruoyi.common.annotation.Log; import com.ruoyi.common.core.controller.BaseController; import com.ruoyi.common.core.domain.AjaxResult; +import com.ruoyi.common.core.domain.entity.SysUser; import com.ruoyi.common.core.page.TableDataInfo; import com.ruoyi.common.enums.BusinessType; import com.ruoyi.common.utils.ShiroUtils; import com.ruoyi.common.utils.StringUtils; import com.ruoyi.common.utils.poi.ExcelUtil; import com.ruoyi.process.general.service.IProcessService; +import com.ruoyi.system.domain.OutsourceQuoteChild; import com.ruoyi.system.domain.SysMakeorderPick; import com.ruoyi.system.domain.SysMakeorderPickVo; +import com.ruoyi.system.mapper.SysMakeorderPickMapper; import com.ruoyi.system.service.ISysMakeorderPickService; +import com.ruoyi.system.service.ISysUserService; import com.ruoyi.warehouse.service.IWarehouseOutOrderService; import org.activiti.engine.RuntimeService; import org.activiti.engine.TaskService; @@ -56,6 +60,12 @@ public class SysMakeorderPickController extends BaseController @Autowired private IWarehouseOutOrderService warehouseOutOrderService; + @Autowired + private SysMakeorderPickMapper sysMakeorderPickMapper; + + @Autowired + private ISysUserService sysUserService; + @RequiresPermissions("system:makeorderpick:view") @GetMapping() public String makeorderpick(ModelMap mmap) @@ -84,11 +94,18 @@ public class SysMakeorderPickController extends BaseController @Log(title = "生产领料单", businessType = BusinessType.EXPORT) @PostMapping("/export") @ResponseBody - public AjaxResult export(SysMakeorderPickVo sysMakeorderPickVo) + public AjaxResult export(SysMakeorderPickVo sysMakeorderPickVo,String ids) { - List list = sysMakeorderPickService.selectSysMakeorderPickList(sysMakeorderPickVo); - ExcelUtil util = new ExcelUtil(SysMakeorderPickVo.class); - return util.exportExcel(list, "生产领料单数据"); + if (org.springframework.util.StringUtils.isEmpty(ids)){ + List pickVoList = sysMakeorderPickMapper.selectSysMakeorderPickList(sysMakeorderPickVo); + ExcelUtil util = new ExcelUtil(SysMakeorderPickVo.class); + return util.exportExcel(pickVoList, "生产领料数据"); + }else { + String[] makeNos = ids.split(","); + List pickVoList = sysMakeorderPickMapper.selectSysMakeorderPickListByNos(makeNos); + ExcelUtil util = new ExcelUtil(SysMakeorderPickVo.class); + return util.exportExcel(pickVoList, ids); + } } /** @@ -110,7 +127,7 @@ public class SysMakeorderPickController extends BaseController public AjaxResult addSave(SysMakeorderPick sysMakeorderPick) { if (StringUtils.isEmpty(sysMakeorderPick.getPickDetails())){ - return AjaxResult.success(); + return AjaxResult.error("领料子表数据为空!"); } // 审核状态-待审核 sysMakeorderPick.setAuditStatus("0"); @@ -268,5 +285,11 @@ public class SysMakeorderPickController extends BaseController return toAjax(sysMakeorderPickService.restoreSysMakeorderPickById(id)); } - + @GetMapping("/getBinessMembers") + @ResponseBody + public TableDataInfo getBusinessMembers(){ + startPage(); + List list = sysUserService.selectRoleToUserList("scyRole,scjlRole,sczgRole,admin"); + return getDataTable(list); + } } diff --git a/ruoyi-admin/src/main/java/com/ruoyi/system/domain/SysMakeorderPick.java b/ruoyi-admin/src/main/java/com/ruoyi/system/domain/SysMakeorderPick.java index 8209a79a..afa4e62a 100644 --- a/ruoyi-admin/src/main/java/com/ruoyi/system/domain/SysMakeorderPick.java +++ b/ruoyi-admin/src/main/java/com/ruoyi/system/domain/SysMakeorderPick.java @@ -26,15 +26,15 @@ public class SysMakeorderPick extends BaseEntity private String delFlag; /** 生产订单号 */ - @Excel(name = "生产订单号") + @Excel(name = "生产订单号", sort = 2) private String makeNo; /** 关联销售订单号 */ - @Excel(name = "关联销售订单号") + @Excel(name = "关联销售订单号", sort = 3) private String saleNo; /** 生产领料单号 */ - @Excel(name = "生产领料单号") + @Excel(name = "生产领料单号", sort = 1) private String pickNo; /** 出库单号 */ @@ -43,53 +43,49 @@ public class SysMakeorderPick extends BaseEntity /** 领料状态 0-待领料 1-部分领料 2-全部领料 */ - @Excel(name = "领料状态 0-待领料 1-部分领料 2-全部领料") + @Excel(name = "领料状态",dictType = "pickStatus", sort = 6) private String pickStatus; /** 领料员 */ - @Excel(name = "领料员") +// @Excel(name = "领料员", sort = 6) private String pickUser; /*物料合计*/ + @Excel(name = "物料合计", sort = 4) private Integer materialSum; /*数量合计*/ + @Excel(name = "数量合计", sort = 5) private Integer enterpriseSum; /** 审核状态 0-待审核 1-审核通过 2-审核拒绝 */ - @Excel(name = "审核状态 0-待审核 1-审核通过 2-审核拒绝") + @Excel(name = "审核状态",dictType = "auditStatus", sort = 7) private String auditStatus; /** 流程实例ID */ - @Excel(name = "流程实例ID") private String instanceId; /** 流程实例类型 */ - @Excel(name = "流程实例类型") private String instanceType; /** 流程提交实例ID */ - @Excel(name = "流程提交实例ID") private String submitInstanceId; /** 流程作废实例ID */ - @Excel(name = "流程作废实例ID") private String cancelInstanceId; /** 流程恢复实例ID */ - @Excel(name = "流程恢复实例ID") private String restoreInstanceId; /** 申请标题 */ - @Excel(name = "申请标题") private String applyTitle; /** 申请人 */ - @Excel(name = "申请人") + @Excel(name = "申请人", sort = 8) private String applyUser; /** 申请时间 */ - @JsonFormat(pattern = "yyyy-MM-dd") - @Excel(name = "申请时间", width = 30, dateFormat = "yyyy-MM-dd") + @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss") + @Excel(name = "申请时间", width = 30, dateFormat = "yyyy-MM-dd",sort = 9) private Date applyTime; private List pickDetails; diff --git a/ruoyi-admin/src/main/java/com/ruoyi/system/domain/SysMakeorderPickDetail.java b/ruoyi-admin/src/main/java/com/ruoyi/system/domain/SysMakeorderPickDetail.java index 475566ec..51726414 100644 --- a/ruoyi-admin/src/main/java/com/ruoyi/system/domain/SysMakeorderPickDetail.java +++ b/ruoyi-admin/src/main/java/com/ruoyi/system/domain/SysMakeorderPickDetail.java @@ -72,6 +72,12 @@ public class SysMakeorderPickDetail extends BaseEntity /** 排序 */ private Long sortNo; +// 可用库存数 + private BigDecimal storageNum; + +// 订单用量 + private BigDecimal orderNum; + public void setId(Long id) { this.id = id; @@ -240,6 +246,22 @@ public class SysMakeorderPickDetail extends BaseEntity this.sortNo = sortNo; } + public BigDecimal getStorageNum() { + return storageNum; + } + + public void setStorageNum(BigDecimal storageNum) { + this.storageNum = storageNum; + } + + public BigDecimal getOrderNum() { + return orderNum; + } + + public void setOrderNum(BigDecimal orderNum) { + this.orderNum = orderNum; + } + @Override public String toString() { return new ToStringBuilder(this,ToStringStyle.MULTI_LINE_STYLE) diff --git a/ruoyi-admin/src/main/java/com/ruoyi/system/domain/SysMakeorderPickVo.java b/ruoyi-admin/src/main/java/com/ruoyi/system/domain/SysMakeorderPickVo.java index 05ddc621..62ad1693 100644 --- a/ruoyi-admin/src/main/java/com/ruoyi/system/domain/SysMakeorderPickVo.java +++ b/ruoyi-admin/src/main/java/com/ruoyi/system/domain/SysMakeorderPickVo.java @@ -21,6 +21,8 @@ public class SysMakeorderPickVo extends SysMakeorderPick { private String taskId; /** 任务名称 */ private String taskName; +// 当前任务状态 + private String taskStatus; /** 办理时间 */ private Date doneTime; /** 创建人 */ diff --git a/ruoyi-admin/src/main/java/com/ruoyi/system/mapper/SysMakeorderPickMapper.java b/ruoyi-admin/src/main/java/com/ruoyi/system/mapper/SysMakeorderPickMapper.java index 5f98cb6c..f979c7eb 100644 --- a/ruoyi-admin/src/main/java/com/ruoyi/system/mapper/SysMakeorderPickMapper.java +++ b/ruoyi-admin/src/main/java/com/ruoyi/system/mapper/SysMakeorderPickMapper.java @@ -89,4 +89,7 @@ public interface SysMakeorderPickMapper * */ int updateMakeorderPickByCode(String outOrderCode); +// 根据单号集合查询生产领料单 + public List selectSysMakeorderPickListByNos(String[] pickNos); + } diff --git a/ruoyi-admin/src/main/java/com/ruoyi/system/service/impl/SysMakeorderPickServiceImpl.java b/ruoyi-admin/src/main/java/com/ruoyi/system/service/impl/SysMakeorderPickServiceImpl.java index 792e1e38..8396e437 100644 --- a/ruoyi-admin/src/main/java/com/ruoyi/system/service/impl/SysMakeorderPickServiceImpl.java +++ b/ruoyi-admin/src/main/java/com/ruoyi/system/service/impl/SysMakeorderPickServiceImpl.java @@ -148,6 +148,12 @@ public class SysMakeorderPickServiceImpl implements ISysMakeorderPickService } else { pickVo.setTaskName("未启动"); } + pickVo.setTaskStatus(pickVo.getTaskName()); + if(pickVo.getAuditStatus().equals("1")){ + pickVo.setTaskStatus("审核通过"); + }else if(pickVo.getAuditStatus().equals("2")){ + pickVo.setTaskStatus("审核拒绝"); + } returnList.add(pickVo); } returnList.setTotal(org.springframework.util.CollectionUtils.isEmpty(list) ? 0 : list.getTotal()); @@ -176,7 +182,10 @@ public class SysMakeorderPickServiceImpl implements ISysMakeorderPickService sysMakeorderPick.setPickNo(billNo); //保留领料单数不为空的数据 - List filterPickDetails = pickDetails.stream().filter(details -> details.getPickNum() != null).collect(Collectors.toList()); + List filterPickDetails = pickDetails.stream().filter(details -> details.getPickNum() != null&& details.getPickNum() > 0).collect(Collectors.toList()); + if(CollectionUtil.isEmpty(filterPickDetails)){ + throw new BusinessException("领料数不能全为空!"); + } Integer enterpriseSum = (int) filterPickDetails.stream() .mapToLong(SysMakeorderPickDetail::getPickNum) @@ -185,15 +194,16 @@ public class SysMakeorderPickServiceImpl implements ISysMakeorderPickService sysMakeorderPick.setEnterpriseSum(enterpriseSum); sysMakeorderPick.setMaterialSum(filterPickDetails.size()); - int id = sysMakeorderPickMapper.insertSysMakeorderPick(sysMakeorderPick); - - // 插入子表 - for (int i = 0; i < filterPickDetails.size(); i++) { - //获取过滤后的领料单详情 - SysMakeorderPickDetail pickDetail = filterPickDetails.get(i); + for (SysMakeorderPickDetail pickDetail:filterPickDetails) { pickDetail.setPickNo(billNo); pickDetail.setMakeNo(makeNo); + if(pickDetail.getPickNum()>pickDetail.getStorageNum().intValue()){ + throw new BusinessException("物料" + pickDetail.getMaterialNo() + "领料数超出可用库存数!"); + } + if(pickDetail.getPickNum()>pickDetail.getOrderNum().intValue()){ + throw new BusinessException("物料" + pickDetail.getMaterialNo() + "领料数超出订单用量数!"); + } int insertMakeorderPickDetailResult = makeorderPickDetailService.insertSysMakeorderPickDetail(pickDetail); if (insertMakeorderPickDetailResult <= 0){ throw new BusinessException("新增生产领料单详情失败"); @@ -201,7 +211,7 @@ public class SysMakeorderPickServiceImpl implements ISysMakeorderPickService } - + int id = sysMakeorderPickMapper.insertSysMakeorderPick(sysMakeorderPick); return id; } diff --git a/ruoyi-admin/src/main/resources/mapper/system/SysMakeorderPickMapper.xml b/ruoyi-admin/src/main/resources/mapper/system/SysMakeorderPickMapper.xml index c30f97a9..4c60398d 100644 --- a/ruoyi-admin/src/main/resources/mapper/system/SysMakeorderPickMapper.xml +++ b/ruoyi-admin/src/main/resources/mapper/system/SysMakeorderPickMapper.xml @@ -46,9 +46,9 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" + + where a.pick_no in + + #{pickNo} + + \ No newline at end of file