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 d3c7309b..f45a51e8 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 @@ -37,6 +37,11 @@ public class SysMakeorderPick extends BaseEntity @Excel(name = "生产领料单号") private String pickNo; + /** 出库单号 */ + @Excel(name = "出库单号") + private String outOrderCode; + + /** 领料状态 0-待领料 1-部分领料 2-全部领料 */ @Excel(name = "领料状态 0-待领料 1-部分领料 2-全部领料") private String pickStatus; @@ -129,7 +134,16 @@ public class SysMakeorderPick extends BaseEntity { return pickNo; } - public void setPickStatus(String pickStatus) + + public String getOutOrderCode() { + return outOrderCode; + } + + public void setOutOrderCode(String outOrderCode) { + this.outOrderCode = outOrderCode; + } + + public void setPickStatus(String pickStatus) { this.pickStatus = pickStatus; } @@ -250,6 +264,7 @@ public class SysMakeorderPick extends BaseEntity .append("makeNo", getMakeNo()) .append("saleNo", getSaleNo()) .append("pickNo", getPickNo()) + .append("outOrderCode", getOutOrderCode()) .append("pickStatus", getPickStatus()) .append("pickUser", getPickUser()) .append("auditStatus", getAuditStatus()) 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 c440c832..5f98cb6c 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 @@ -75,4 +75,18 @@ public interface SysMakeorderPickMapper * @return 结果 */ public int restoreSysMakeorderPickById(Long id); + + /** + * 生产领料单审核通过后增加出库单号 + * + * @param sysMakeorderPickVo 生产领料单 + * @return 结果 + */ + int updateMakeorderPickOutOrderCodeById(SysMakeorderPickVo sysMakeorderPickVo); + + /* + * 通过入库单号更新生产领料单数 + * */ + int updateMakeorderPickByCode(String outOrderCode); + } diff --git a/ruoyi-admin/src/main/java/com/ruoyi/warehouse/service/impl/WarehouseOutOrderServiceImpl.java b/ruoyi-admin/src/main/java/com/ruoyi/warehouse/service/impl/WarehouseOutOrderServiceImpl.java index e6f31336..38e3e236 100644 --- a/ruoyi-admin/src/main/java/com/ruoyi/warehouse/service/impl/WarehouseOutOrderServiceImpl.java +++ b/ruoyi-admin/src/main/java/com/ruoyi/warehouse/service/impl/WarehouseOutOrderServiceImpl.java @@ -246,15 +246,23 @@ public class WarehouseOutOrderServiceImpl implements IWarehouseOutOrderService @Transactional(rollbackFor = Exception.class) @Override public int generateWarehouseOutOrderByMakeorderPick(SysMakeorderPickVo sysMakeorderPickVo) { - + String outOrderCode = redisCache.generateBillNo("CK"); WarehouseOutOrder warehouseOutOrder = new WarehouseOutOrder(); SysMakeorderPickVo tempSysMakeorderPickVo = sysMakeorderPickMapper.selectSysMakeorderPickById(sysMakeorderPickVo.getId()); + if (tempSysMakeorderPickVo == null){ log.warn("生产领料单数据为空:{}",sysMakeorderPickVo.getId()); throw new BusinessException("生产领料单数据为空:" + sysMakeorderPickVo.getId()); } + tempSysMakeorderPickVo.setOutOrderCode(outOrderCode); + //设置领料状态 为待领料 + tempSysMakeorderPickVo.setPickStatus("0"); + //更新领料单的出库单号 + int updateMakeorderPickResult = sysMakeorderPickMapper.updateMakeorderPickOutOrderCodeById(tempSysMakeorderPickVo); + if (updateMakeorderPickResult <= 0){ + throw new BusinessException("更新生产领料单失败"); + } - String outOrderCode = redisCache.generateBillNo("CK"); warehouseOutOrder.setOutOrderCode(outOrderCode); warehouseOutOrder.setWarehouseOutStatus("4"); warehouseOutOrder.setRelatedOrderCode(tempSysMakeorderPickVo.getMakeNo()); @@ -402,12 +410,55 @@ public class WarehouseOutOrderServiceImpl implements IWarehouseOutOrderService throw new BusinessException("更新出库单信息失败:缺少必要参数"); } + List warehouseOutOrderDetailList = warehouseOutOrder.getWarehouseOutOrderDetailList(); + + if (CollectionUtils.isEmpty(warehouseOutOrderDetailList)){ + log.warn("保存生产单出库,物料列表信息为空:{}",warehouseOutOrder); + throw new BusinessException("出库单详情数据为空"); + }else { + int updateRows = 0; + for (WarehouseOutOrderDetail warehouseOutOrderDetail : warehouseOutOrderDetailList) { + warehouseOutOrderDetail.setUpdateBy(loginName); + warehouseOutOrderDetail.setUpdateTime(new Date()); + warehouseOutOrderDetail.setRemark(warehouseOutOrder.getRemark()); + //设置已出库数 + warehouseOutOrderDetail.setHasOutOrderSum(warehouseOutOrderDetail.getActualOutOrderSum()); + //设置仓库员 + warehouseOutOrderDetail.setWarehouseName(loginName); + //更新数据库记录 + updateRows += outOrderDetailMapper.updateWarehouseOutOrderDetail(warehouseOutOrderDetail); + } + if (updateRows <= 0){ + throw new BusinessException("更新出库单详情数据失败"); + } + + } warehouseOutOrder.setUpdateBy(loginName); warehouseOutOrder.setUpdateTime(new Date()); - //表面已出库 + //表明已出库 warehouseOutOrder.setWarehouseOutStatus("7"); + //设置出库时间 warehouseOutOrder.setOutOrderTime(new Date()); - warehouseOutOrderMapper.updateWarehouseOutOrder(warehouseOutOrder); + + //设置仓库员 + warehouseOutOrder.setWarehouseName(loginName); + + //计算出库单主表的出库数 + Integer outOrderSum = 0; + + // 检查outOrderSum是否含有null值 + boolean hasOutOrderSumNull = warehouseOutOrderDetailList.stream() + .anyMatch(item -> item.getActualOutOrderSum() == null); + + if (hasOutOrderSumNull) { + throw new BusinessException("存在实际出库数为空,请检查!"); + } + // 计算各个字段的总和 + outOrderSum = warehouseOutOrderDetailList.stream() + .mapToInt(WarehouseOutOrderDetail::getActualOutOrderSum) + .sum(); + //设置出库单主表的出库数 + warehouseOutOrder.setOutOrderSum(outOrderSum); //更新生产订单信息 SysMakeOrder sysMakeOrder = new SysMakeOrder(); @@ -439,22 +490,12 @@ public class WarehouseOutOrderServiceImpl implements IWarehouseOutOrderService log.warn("更新销售订单信息失败"); throw new BusinessException("更新销售订单信息失败"); } - - List warehouseOutOrderDetailList = warehouseOutOrder.getWarehouseOutOrderDetailList(); - if (CollectionUtils.isEmpty(warehouseOutOrderDetailList)){ - log.warn("保存生产单出库,物料列表信息为空:{}",warehouseOutOrder); - }else { - int updateRows = 0; - for (WarehouseOutOrderDetail warehouseOutOrderDetail : warehouseOutOrderDetailList) { - warehouseOutOrderDetail.setUpdateBy(loginName); - warehouseOutOrderDetail.setUpdateTime(new Date()); - warehouseOutOrderDetail.setRemark(warehouseOutOrder.getRemark()); - //更新数据库记录 - updateRows += outOrderDetailMapper.updateWarehouseOutOrderDetail(warehouseOutOrderDetail); - } - return updateRows; + // 更新生产领料单数据表示已领料 + int updateMakeorderPickResult = sysMakeorderPickMapper.updateMakeorderPickByCode(warehouseOutOrder.getOutOrderCode()); + if (updateMakeorderPickResult <= 0){ + log.warn("更新生产领料单信息失败"); + throw new BusinessException("更新生产领料单信息失败"); } - - return 0; + return warehouseOutOrderMapper.updateWarehouseOutOrder(warehouseOutOrder); } } diff --git a/ruoyi-admin/src/main/resources/mapper/system/SysMakeorderPickMapper.xml b/ruoyi-admin/src/main/resources/mapper/system/SysMakeorderPickMapper.xml index 582de6ff..89fa3a13 100644 --- a/ruoyi-admin/src/main/resources/mapper/system/SysMakeorderPickMapper.xml +++ b/ruoyi-admin/src/main/resources/mapper/system/SysMakeorderPickMapper.xml @@ -15,6 +15,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" + @@ -33,7 +34,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" select a.id, a.del_flag, a.create_by, a.create_time, a.update_by, a.update_time, a.remark - , a.make_no, a.sale_no, a.pick_no, a.pick_status, a.pick_user, a.audit_status + , a.make_no, a.sale_no, a.pick_no, a.out_order_code, a.pick_status, a.pick_user, a.audit_status , a.instance_id, a.instance_type, a.submit_instance_id, a.cancel_instance_id, a.restore_instance_id, a.apply_title, a.apply_user, a.apply_time ,b.material_sum ,b.enterprise_sum @@ -48,6 +49,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" and a.make_no = #{makeNo} and a.sale_no = #{saleNo} and a.pick_no = #{pickNo} + and a.out_order_code = #{outOrderCode} and a.pick_status = #{pickStatus} and a.pick_user = #{pickUser} and a.audit_status = #{auditStatus} @@ -85,6 +87,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" make_no, sale_no, pick_no, + out_order_code, pick_status, pick_user, audit_status, @@ -107,6 +110,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" #{makeNo}, #{saleNo}, #{pickNo}, + #{outOrderCode}, #{pickStatus}, #{pickUser}, #{auditStatus}, @@ -133,6 +137,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" make_no = #{makeNo}, sale_no = #{saleNo}, pick_no = #{pickNo}, + out_order_code = #{outOrderCode}, pick_status = #{pickStatus}, pick_user = #{pickUser}, audit_status = #{auditStatus}, @@ -167,4 +172,38 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" update sys_makeorder_pick set del_flag = '0' where id = #{id} + + + update sys_makeorder_pick + + del_flag = #{delFlag}, + create_by = #{createBy}, + create_time = #{createTime}, + update_by = #{updateBy}, + update_time = #{updateTime}, + remark = #{remark}, + make_no = #{makeNo}, + sale_no = #{saleNo}, + pick_no = #{pickNo}, + out_order_code = #{outOrderCode}, + pick_status = #{pickStatus}, + pick_user = #{pickUser}, + audit_status = #{auditStatus}, + instance_id = #{instanceId}, + instance_type = #{instanceType}, + submit_instance_id = #{submitInstanceId}, + cancel_instance_id = #{cancelInstanceId}, + restore_instance_id = #{restoreInstanceId}, + apply_title = #{applyTitle}, + apply_user = #{applyUser}, + apply_time = #{applyTime}, + + where id = #{id} + + + + update sys_makeorder_pick set pick_status = "2" where out_order_code = #{outOrderCode} + + + \ No newline at end of file diff --git a/ruoyi-admin/src/main/resources/templates/warehouse/warehouseOutOrder/warehouseOutOrder.html b/ruoyi-admin/src/main/resources/templates/warehouse/warehouseOutOrder/warehouseOutOrder.html index 9b2dd127..13a976a8 100644 --- a/ruoyi-admin/src/main/resources/templates/warehouse/warehouseOutOrder/warehouseOutOrder.html +++ b/ruoyi-admin/src/main/resources/templates/warehouse/warehouseOutOrder/warehouseOutOrder.html @@ -194,22 +194,36 @@ actions.push('出库 '); actions.push('详情 '); } + /*生产单-出库*/ if (row.warehouseOutStatus == 4 && row.warehouseOrderType == 1 && row.warehouseOutType == 1){ actions.push('出库 '); + } + /*生产单-出库 详情*/ + if (row.warehouseOrderType == 1 && row.warehouseOutType == 1){ actions.push('详情 '); } + /*请购单-出库*/ if (row.warehouseOutStatus == 4 && row.warehouseOrderType == 2 && row.warehouseOutType == 2){ actions.push('出库 '); + } + + /*请购单-出库 详情*/ + if (row.warehouseOrderType == 2 && row.warehouseOutType == 2){ actions.push('详情 '); } /*退换货-出库*/ if (row.warehouseOutStatus == 4 && row.warehouseOrderType == 4 && row.warehouseOutType == 4){ actions.push('出库 '); + } + + /*退换货-出库*/ + if (row.warehouseOrderType == 4 && row.warehouseOutType == 4){ actions.push('详情 '); } + return actions.join(''); } }]