Browse Source

[fix] 生产管理 仓库管理

新增 生产领料单新增已领料数字段
新增 生产领料单前端新增已领料数字段
新增 品质完更新仓库入库单的品质状态
新增 生产领料单详情前端新增已领料数字段
修改 生产单BOM的损耗率字段的类型BigDecimal-> String
生产领料单详情新增 根据生产单号和领料单号以及物料号查询领料单详情信息
修改 新增生产订单领料明细的新增方法,加入对已领料数字段的处理
修改 新增生产领料单的新增方法加入对 领料单为空的数据进行过滤
新增 部门评审生产生产bom表的时候加入损耗率
修改领料单审核通过后生成出库单方法:出库单主表的物料合计数据为子表的物料种类的合计;
出库单主表的物料的数量合计为子表的物料申请出库数量的合计;加入对生产领料单详情数据的过滤如果这里面有多条物料信息,并且每条物料信息都有 申请领料数把相等料号的数据进行领料数字的合计,并且处理后集合中只保留相等料号的一条数据;修改出库单子表的新增方法,新增的数据为生产领料单过滤后的数据。修改出库单子表的出库数量为生产领料单详情的领料数
dev
liuxiaoxu 4 months ago
parent
commit
c9ff97747e
  1. 14
      ruoyi-admin/src/main/java/com/ruoyi/system/domain/SysMakeorderBom.java
  2. 13
      ruoyi-admin/src/main/java/com/ruoyi/system/domain/SysMakeorderPickDetail.java
  3. 6
      ruoyi-admin/src/main/java/com/ruoyi/system/mapper/SysMakeorderPickDetailMapper.java
  4. 6
      ruoyi-admin/src/main/java/com/ruoyi/system/service/impl/SysMakeOrderServiceImpl.java
  5. 22
      ruoyi-admin/src/main/java/com/ruoyi/system/service/impl/SysMakeorderPickDetailServiceImpl.java
  6. 19
      ruoyi-admin/src/main/java/com/ruoyi/system/service/impl/SysMakeorderPickServiceImpl.java
  7. 106
      ruoyi-admin/src/main/java/com/ruoyi/warehouse/service/impl/WarehouseOutOrderServiceImpl.java
  8. 13
      ruoyi-admin/src/main/resources/mapper/system/SysMakeorderPickDetailMapper.xml
  9. 9
      ruoyi-admin/src/main/resources/templates/system/makeorder/addpick.html
  10. 6
      ruoyi-admin/src/main/resources/templates/system/makeorderpick/detail.html

14
ruoyi-admin/src/main/java/com/ruoyi/system/domain/SysMakeorderBom.java

@ -78,7 +78,7 @@ public class SysMakeorderBom extends BaseEntity
/** 损耗率 */
@Excel(name = "损耗率")
private BigDecimal lossRate;
private String lossRate;
/** 层级 */
@Excel(name = "层级")
@ -223,15 +223,15 @@ public class SysMakeorderBom extends BaseEntity
{
return useNum;
}
public void setLossRate(BigDecimal lossRate)
{
this.lossRate = lossRate;
}
public BigDecimal getLossRate()
{
public String getLossRate() {
return lossRate;
}
public void setLossRate(String lossRate) {
this.lossRate = lossRate;
}
public void setLevel(Long level)
{
this.level = level;

13
ruoyi-admin/src/main/java/com/ruoyi/system/domain/SysMakeorderPickDetail.java

@ -43,6 +43,10 @@ public class SysMakeorderPickDetail extends BaseEntity
@Excel(name = "领料数量")
private Long pickNum;
/** 已领料数量 */
@Excel(name = "已领料数量")
private Long hasPickNum;
/** bom号 */
private String bomNo;
/** bom的图片地址 */
@ -132,6 +136,14 @@ public class SysMakeorderPickDetail extends BaseEntity
return pickNum;
}
public Long getHasPickNum() {
return hasPickNum;
}
public void setHasPickNum(Long hasPickNum) {
this.hasPickNum = hasPickNum;
}
public String getBomNo() {
return bomNo;
}
@ -243,6 +255,7 @@ public class SysMakeorderPickDetail extends BaseEntity
.append("materialNo", getMaterialNo())
.append("makeorderBomId", getMakeorderBomId())
.append("pickNum", getPickNum())
.append("hasPickNum", getHasPickNum())
.toString();
}
}

6
ruoyi-admin/src/main/java/com/ruoyi/system/mapper/SysMakeorderPickDetailMapper.java

@ -80,4 +80,10 @@ public interface SysMakeorderPickDetailMapper
* 根据生产单号和领料单号查询 领料单详情信息
* */
List<SysMakeorderPickDetail> selectSysMakeorderPickDetailByNo(SysMakeorderPickDetail sysMakeorderPickDetail);
/*
* 根据生产单号和领料单号以及物料号查询领料单详情信息
* */
public SysMakeorderPickDetail selectSysMakeorderPickDetailByThreeNo(SysMakeorderPickDetail sysMakeorderPickDetail);
}

6
ruoyi-admin/src/main/java/com/ruoyi/system/service/impl/SysMakeOrderServiceImpl.java

@ -30,6 +30,7 @@ import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.util.CollectionUtils;
import java.math.BigDecimal;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
@ -271,6 +272,7 @@ public class SysMakeOrderServiceImpl implements ISysMakeOrderService
orderBom.setMakeNo(makeNo);
orderBom.setSalesOrderCode(saleNo);
orderBom.setSalesOrderMaterialNo(materialCode);
orderBom.setLossRate(subBom.getLossRate());
//如果sys_makeorder_bom数据表里面没有入库部门.这里给他加入
//orderBom.setWarehouseDept(subBom.getWarehouseDept());
sortNo++;
@ -288,6 +290,7 @@ public class SysMakeOrderServiceImpl implements ISysMakeOrderService
orderBom.setMakeNo(makeNo);
orderBom.setSalesOrderCode(saleNo);
orderBom.setSalesOrderMaterialNo(materialCode);
orderBom.setLossRate(subBom.getLossRate());
sortNo++;
orderBom.setSortNo(sortNo);
makeorderBomService.insertSysMakeorderBom(orderBom);
@ -347,7 +350,8 @@ public class SysMakeOrderServiceImpl implements ISysMakeOrderService
}
sysMakeOrder.setMakeNo(makeNo);
sysMakeOrder.setEceiptNum((long) warehouseStorageOrder.getStorageNum());
//只有生产入库才能更新生产订单的已入库数
//sysMakeOrder.setEceiptNum((long) warehouseStorageOrder.getStorageNum());
//更新生产订单的数据
int updateResult = sysMakeOrderMapper.updateByMakeNo(sysMakeOrder);
if (updateResult <= 0){

22
ruoyi-admin/src/main/java/com/ruoyi/system/service/impl/SysMakeorderPickDetailServiceImpl.java

@ -58,6 +58,28 @@ public class SysMakeorderPickDetailServiceImpl implements ISysMakeorderPickDetai
String loginName = ShiroUtils.getLoginName();
sysMakeorderPickDetail.setCreateBy(loginName);
sysMakeorderPickDetail.setCreateTime(DateUtils.getNowDate());
SysMakeorderPickDetail tempMakeorderPickDetail = sysMakeorderPickDetailMapper.selectSysMakeorderPickDetailByThreeNo(sysMakeorderPickDetail);
if (tempMakeorderPickDetail != null){
if (tempMakeorderPickDetail.getHasPickNum() != null ){
// 如果刚开始 领料详细数据不为空,并且已经有已领料数了,说明也有领料数,再领料,已领料数会累加 本次领料数;
Long hasPickNum = tempMakeorderPickDetail.getHasPickNum() + sysMakeorderPickDetail.getPickNum();
sysMakeorderPickDetail.setHasPickNum(hasPickNum);
}
}else {
// 如果刚开始 领料详细数据为空,已领料数等于领料数
sysMakeorderPickDetail.setHasPickNum(sysMakeorderPickDetail.getPickNum());
}
// 缓存sysMakeorderPickDetail的领料数,避免多次调用 下面代码等同于上面的逻辑
// Long pickNum = sysMakeorderPickDetail.getPickNum();
// Long hasPickNum = (tempMakeorderPickDetail != null && tempMakeorderPickDetail.getHasPickNum() != null)
// ? tempMakeorderPickDetail.getHasPickNum() + pickNum
// : pickNum;
// sysMakeorderPickDetail.setHasPickNum(hasPickNum);
return sysMakeorderPickDetailMapper.insertSysMakeorderPickDetail(sysMakeorderPickDetail);
}

19
ruoyi-admin/src/main/java/com/ruoyi/system/service/impl/SysMakeorderPickServiceImpl.java

@ -7,6 +7,7 @@ import com.ruoyi.common.core.page.PageDomain;
import com.ruoyi.common.core.page.TableSupport;
import com.ruoyi.common.core.redis.RedisCache;
import com.ruoyi.common.core.text.Convert;
import com.ruoyi.common.exception.BusinessException;
import com.ruoyi.common.utils.DateUtils;
import com.ruoyi.common.utils.ShiroUtils;
import com.ruoyi.common.utils.StringUtils;
@ -20,6 +21,7 @@ import com.ruoyi.system.mapper.SysUserMapper;
import com.ruoyi.system.service.ISysMakeorderPickDetailService;
import com.ruoyi.system.service.ISysMakeorderPickService;
import com.ruoyi.system.service.ISysRoleService;
import com.ruoyi.warehouse.service.IWarehouseOutOrderService;
import org.activiti.engine.TaskService;
import org.activiti.engine.impl.persistence.entity.TaskEntityImpl;
import org.activiti.engine.runtime.ProcessInstance;
@ -33,6 +35,7 @@ import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Set;
import java.util.stream.Collectors;
/**
* 生产领料单Service业务层处理
@ -172,13 +175,23 @@ public class SysMakeorderPickServiceImpl implements ISysMakeorderPickService
String billNo = redisCache.generateBillNo("SCLL");
sysMakeorderPick.setPickNo(billNo);
int id = sysMakeorderPickMapper.insertSysMakeorderPick(sysMakeorderPick);
//保留领料单数不为空的数据
List<SysMakeorderPickDetail> filterPickDetails = pickDetails.stream().filter(details -> details.getPickNum() != null).collect(Collectors.toList());
// 插入子表
for (int i = 0; i < pickDetails.size(); i++) {
SysMakeorderPickDetail pickDetail = pickDetails.get(i);
for (int i = 0; i < filterPickDetails.size(); i++) {
//获取过滤后的领料单详情
SysMakeorderPickDetail pickDetail = filterPickDetails.get(i);
pickDetail.setPickNo(billNo);
pickDetail.setMakeNo(makeNo);
makeorderPickDetailService.insertSysMakeorderPickDetail(pickDetail);
int insertMakeorderPickDetailResult = makeorderPickDetailService.insertSysMakeorderPickDetail(pickDetail);
if (insertMakeorderPickDetailResult <= 0){
throw new BusinessException("新增生产领料单详情失败");
}
}
return id;
}

106
ruoyi-admin/src/main/java/com/ruoyi/warehouse/service/impl/WarehouseOutOrderServiceImpl.java

@ -1,7 +1,7 @@
package com.ruoyi.warehouse.service.impl;
import java.util.Date;
import java.util.List;
import java.util.*;
import java.util.stream.Collectors;
import com.ruoyi.common.core.redis.RedisCache;
import com.ruoyi.common.exception.BusinessException;
@ -17,6 +17,7 @@ import com.ruoyi.system.mapper.SysMakeorderPickDetailMapper;
import com.ruoyi.system.mapper.SysMakeorderPickMapper;
import com.ruoyi.system.mapper.SysSalesOrderMapper;
import com.ruoyi.warehouse.domain.WarehouseOutOrderDetail;
import com.ruoyi.warehouse.domain.WarehouseStorageOrderDetail;
import com.ruoyi.warehouse.mapper.WarehouseOutOrderDetailMapper;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
@ -260,13 +261,41 @@ public class WarehouseOutOrderServiceImpl implements IWarehouseOutOrderService
warehouseOutOrder.setMakeNo(tempSysMakeorderPickVo.getMakeNo());
//标明来源是生产订单
warehouseOutOrder.setWarehouseOrderType("1");
//标明是生产领料
warehouseOutOrder.setWarehouseOutType("1");
warehouseOutOrder.setMaterialSum(tempSysMakeorderPickVo.getMaterialSum());
warehouseOutOrder.setEnterpriseSum(tempSysMakeorderPickVo.getEnterpriseSum());
warehouseOutOrder.setCreateBy(sysMakeorderPickVo.getApplyUser());
warehouseOutOrder.setBusinessName(ShiroUtils.getLoginName());
warehouseOutOrder.setCreateBy(ShiroUtils.getLoginName());
warehouseOutOrder.setCreateTime(new Date());
warehouseOutOrder.setApplyName(sysMakeorderPickVo.getApplyUser());
List<SysMakeorderPickDetail> sysMakeorderPickDetails = getSysMakeorderPickDetails(sysMakeorderPickVo);
//对物料相同的数据进行合并操作,并合计领料数
List<SysMakeorderPickDetail> mergeMakeorderPickDetails = mergeMakeorderPickDetails(sysMakeorderPickDetails);
//物料合计
Integer materialSum = 0;
//数量合计
Integer enterpriseSum = 0;
materialSum = mergeMakeorderPickDetails.size();
// 检查storageNum是否含有null值
boolean hasThisStorageNumNull = mergeMakeorderPickDetails.stream()
.anyMatch(item -> item.getPickNum() == null);
if (hasThisStorageNumNull) {
throw new BusinessException("存在入库数为空,请检查!");
}
// 计算各个字段的总和
long enterpriseSumLong = mergeMakeorderPickDetails.stream()
.mapToLong(SysMakeorderPickDetail::getPickNum)
.sum();
// 确保转换前不会造成数据溢出
enterpriseSum = (int)enterpriseSumLong;
warehouseOutOrder.setMaterialSum(materialSum);
warehouseOutOrder.setEnterpriseSum(enterpriseSum);
//生成出库单数据
int insertResult = warehouseOutOrderMapper.insertWarehouseOutOrder(warehouseOutOrder);
if (insertResult <= 0){
@ -274,18 +303,41 @@ public class WarehouseOutOrderServiceImpl implements IWarehouseOutOrderService
throw new BusinessException("添加出库单信息失败");
}
//生成出库单详情相关信息
generateWarehouseOutOrder(sysMakeorderPickVo, tempSysMakeorderPickVo, outOrderCode);
generateWarehouseOutOrder(sysMakeorderPickVo, tempSysMakeorderPickVo, outOrderCode,mergeMakeorderPickDetails);
return insertResult;
}
/*
* 对物料相同的数据进行合并操作并合计领料数
* */
public List<SysMakeorderPickDetail> mergeMakeorderPickDetails(List<SysMakeorderPickDetail> sysMakeorderPickDetails) {
Map<String, Long> materialMap = new HashMap<>();
for (SysMakeorderPickDetail detail : sysMakeorderPickDetails) {
String materialNo = detail.getMaterialNo();
Long pickNum = detail.getPickNum();
if (materialMap.containsKey(materialNo)) {
materialMap.put(materialNo, materialMap.get(materialNo) + pickNum);
} else {
materialMap.put(materialNo, pickNum);
}
}
List<SysMakeorderPickDetail> mergedDetails = new ArrayList<>();
for (Map.Entry<String, Long> entry : materialMap.entrySet()) {
SysMakeorderPickDetail mergedDetail = new SysMakeorderPickDetail();
mergedDetail.setMaterialNo(entry.getKey());
mergedDetail.setPickNum(entry.getValue());
mergedDetails.add(mergedDetail);
}
return mergedDetails;
}
//生成出库单详情相关信息
private void generateWarehouseOutOrder(SysMakeorderPickVo sysMakeorderPickVo, SysMakeorderPickVo tempSysMakeorderPickVo, String outOrderCode) {
SysMakeorderPickDetail tempMakeorderPickDetail = new SysMakeorderPickDetail();
tempMakeorderPickDetail.setPickNo(tempSysMakeorderPickVo.getPickNo());
tempMakeorderPickDetail.setMakeNo(tempSysMakeorderPickVo.getMakeNo());
//查询生产物料领料单详情
List<SysMakeorderPickDetail> sysMakeorderPickDetails = makeorderPickDetailMapper.selectSysMakeorderPickDetailByNo(tempMakeorderPickDetail);
for (SysMakeorderPickDetail sysMakeorderPickDetail : sysMakeorderPickDetails) {
private void generateWarehouseOutOrder(SysMakeorderPickVo sysMakeorderPickVo, SysMakeorderPickVo tempSysMakeorderPickVo, String outOrderCode,List<SysMakeorderPickDetail> mergeMakeorderPickDetails) {
for (SysMakeorderPickDetail sysMakeorderPickDetail : mergeMakeorderPickDetails) {
WarehouseOutOrderDetail warehouseOutOrderDetail = new WarehouseOutOrderDetail();
warehouseOutOrderDetail.setOutOrderCode(outOrderCode);
warehouseOutOrderDetail.setWarehouseOutStatus("4");
@ -297,7 +349,7 @@ public class WarehouseOutOrderServiceImpl implements IWarehouseOutOrderService
warehouseOutOrderDetail.setMaterialSum(tempSysMakeorderPickVo.getMaterialSum());
warehouseOutOrderDetail.setEnterpriseSum(tempSysMakeorderPickVo.getEnterpriseSum());
warehouseOutOrderDetail.setCreateBy(sysMakeorderPickVo.getApplyUser());
warehouseOutOrderDetail.setCreateBy(ShiroUtils.getLoginName());
warehouseOutOrderDetail.setCreateTime(new Date());
warehouseOutOrderDetail.setApplyName(sysMakeorderPickVo.getApplyUser());
//物料相关信息
@ -308,13 +360,33 @@ public class WarehouseOutOrderServiceImpl implements IWarehouseOutOrderService
warehouseOutOrderDetail.setMaterialBrand(sysMakeorderPickDetail.getBrand());
warehouseOutOrderDetail.setMaterialProcessMethod(sysMakeorderPickDetail.getProcessMethod());
warehouseOutOrderDetail.setMakeNum(tempSysMakeorderPickVo.getMaterialSum());
if (StringUtils.isNotEmpty(sysMakeorderPickDetail.getDescribe())){
//添加申请出库数量
warehouseOutOrderDetail.setApplyOutOrderSum(Math.toIntExact(sysMakeorderPickDetail.getPickNum()));
if (StringUtils.isNotEmpty(sysMakeorderPickDetail.getDescribe())) {
String[] splitDescribe = sysMakeorderPickDetail.getDescribe().split(",");
if (splitDescribe.length >= 2) {
warehouseOutOrderDetail.setMaterialModel(splitDescribe[0]);
warehouseOutOrderDetail.setMaterialSpecification(splitDescribe[1]);
}
outOrderDetailMapper.insertWarehouseOutOrderDetail(warehouseOutOrderDetail);
}
int insertOutOrderDetailResult = outOrderDetailMapper.insertWarehouseOutOrderDetail(warehouseOutOrderDetail);
if (insertOutOrderDetailResult <= 0){
throw new BusinessException("新增出库单详情数据失败");
}
}
}
private List<SysMakeorderPickDetail> getSysMakeorderPickDetails(SysMakeorderPickVo tempSysMakeorderPickVo) {
SysMakeorderPickDetail tempMakeorderPickDetail = new SysMakeorderPickDetail();
tempMakeorderPickDetail.setPickNo(tempSysMakeorderPickVo.getPickNo());
tempMakeorderPickDetail.setMakeNo(tempSysMakeorderPickVo.getMakeNo());
//查询生产物料领料单详情
List<SysMakeorderPickDetail> sysMakeorderPickDetails = makeorderPickDetailMapper.selectSysMakeorderPickDetailByNo(tempMakeorderPickDetail);
//保留领料单数不为空的数据
List<SysMakeorderPickDetail> filterPickDetails = sysMakeorderPickDetails.stream().filter(details -> details.getPickNum() != null).collect(Collectors.toList());
return filterPickDetails;
}
/*

13
ruoyi-admin/src/main/resources/mapper/system/SysMakeorderPickDetailMapper.xml

@ -17,6 +17,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<result property="materialNo" column="material_no" />
<result property="makeorderBomId" column="makeorder_bom_id" />
<result property="pickNum" column="pick_num" />
<result property="hasPickNum" column="has_pick_num" />
<result property="bomNo" column="bom_no" />
<result property="photoUrl" column="photoUrl" />
<result property="materialName" column="material_name" />
@ -33,7 +34,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<sql id="selectSysMakeorderPickDetailVo">
select a.id, a.del_flag, a.create_by, a.create_time, a.update_by, a.update_time, a.remark
, a.make_no, a.pick_no, a.material_no, a.makeorder_bom_id, a.pick_num
, a.make_no, a.pick_no, a.material_no, a.makeorder_bom_id, a.pick_num, a.has_pick_num
,b.bom_no,b.photoUrl,b.material_name,b.material_type,b.process_method,b.unit,b.brand
,b.describe,b.use_num,b.loss_rate,b.level,b.sort_no
from sys_makeorder_pick_detail a
@ -66,6 +67,13 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
</select>
<select id="selectSysMakeorderPickDetailByThreeNo" parameterType="SysMakeorderPickDetail" resultMap="SysMakeorderPickDetailResult">
<include refid="selectSysMakeorderPickDetailVo"/>
where a.make_no = #{makeNo}
and a.pick_no = #{pickNo}
and a.material_no = #{materialNo}
</select>
<insert id="insertSysMakeorderPickDetail" parameterType="SysMakeorderPickDetail" useGeneratedKeys="true" keyProperty="id">
insert into sys_makeorder_pick_detail
<trim prefix="(" suffix=")" suffixOverrides=",">
@ -80,6 +88,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<if test="materialNo != null">material_no,</if>
<if test="makeorderBomId != null">makeorder_bom_id,</if>
<if test="pickNum != null">pick_num,</if>
<if test="hasPickNum != null">has_pick_num,</if>
</trim>
<trim prefix="values (" suffix=")" suffixOverrides=",">
<if test="delFlag != null">#{delFlag},</if>
@ -93,6 +102,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<if test="materialNo != null">#{materialNo},</if>
<if test="makeorderBomId != null">#{makeorderBomId},</if>
<if test="pickNum != null">#{pickNum},</if>
<if test="hasPickNum != null">#{hasPickNum},</if>
</trim>
</insert>
@ -110,6 +120,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<if test="materialNo != null">material_no = #{materialNo},</if>
<if test="makeorderBomId != null">makeorder_bom_id = #{makeorderBomId},</if>
<if test="pickNum != null">pick_num = #{pickNum},</if>
<if test="hasPickNum != null">has_pick_num = #{hasPickNum},</if>
</trim>
where id = #{id}
</update>

9
ruoyi-admin/src/main/resources/templates/system/makeorder/addpick.html

@ -151,6 +151,11 @@
field: 'materialNum',
align: 'center',
title: '订单数量'
},
{
field: 'finishNum',
align: 'center',
title: '已完成数'
}
]
};
@ -302,6 +307,10 @@
return parentRow.materialNum * row.useNum;
}
},
{
field: 'hasPickNum',
title: '已领料数量',
},
{
field: 'pickNum',
title: '本次领料数量',

6
ruoyi-admin/src/main/resources/templates/system/makeorderpick/detail.html

@ -293,6 +293,12 @@
return parentRow.materialNum * row.useNum;
}
},
{
field: 'hasPickNum',
title: '已领料数',
},
{
field: 'pickNum',
title: '本次领料数量',

Loading…
Cancel
Save