Browse Source

[fix] 采购管理 工程管理

修改采购计划详情前端页面字段
修改采购计划前端页面字段
修改生产订单转采购计划,添加采购计划的方法:新增物料合计和数量合计的计算
修改生产订单转采购计划详情,添加采购计划详情的方法:新增计划采购数的计算
修改bom 根据bom号查询报错问题
dev
liuxiaoxu 5 months ago
parent
commit
d6fed8a279
  1. 42
      ruoyi-admin/src/main/java/com/ruoyi/purchase/service/impl/PurchasePlanServiceImpl.java
  2. 50
      ruoyi-admin/src/main/java/com/ruoyi/system/service/impl/SysMakeOrderServiceImpl.java
  3. 2
      ruoyi-admin/src/main/resources/mapper/erp/ErpBomMapper.xml
  4. 8
      ruoyi-admin/src/main/resources/templates/purchase/purchasePlan/detail.html
  5. 6
      ruoyi-admin/src/main/resources/templates/purchase/purchasePlan/purchasePlan.html

42
ruoyi-admin/src/main/java/com/ruoyi/purchase/service/impl/PurchasePlanServiceImpl.java

@ -4,6 +4,7 @@ import java.time.LocalDateTime;
import java.time.format.DateTimeFormatter; import java.time.format.DateTimeFormatter;
import java.util.Date; import java.util.Date;
import java.util.List; import java.util.List;
import java.util.stream.Collectors;
import com.ruoyi.common.core.redis.RedisCache; import com.ruoyi.common.core.redis.RedisCache;
import com.ruoyi.common.utils.DateUtils; import com.ruoyi.common.utils.DateUtils;
@ -163,8 +164,22 @@ public class PurchasePlanServiceImpl implements IPurchasePlanService
// 仅查询一次,因为所有SysMakeorderBom都关联同一生产单号 // 仅查询一次,因为所有SysMakeorderBom都关联同一生产单号
SysMakeOrder sysMakeOrder = sysMakeOrderMapper.selectMakeOrderByMakeNo(insertedSysMakeorderBoms.get(0).getMakeNo()); SysMakeOrder sysMakeOrder = sysMakeOrderMapper.selectMakeOrderByMakeNo(insertedSysMakeorderBoms.get(0).getMakeNo());
//保存所有加工方式为采购的物料
List<SysMakeorderBom> filterSysMakeorderBoms = insertedSysMakeorderBoms.stream().filter(bom -> "0".equals(bom.getProcessMethod())).collect(Collectors.toList());
//统计物料种类的数量
Integer materialAmount = filterSysMakeorderBoms.size();
//统计数量合计
//生产订单中的订单数量
Long makeOrderMaterialSum = sysMakeOrder.getMaterialSum();
//加工方式为采购的所有物料用量合计
Long sum = filterSysMakeorderBoms.stream().mapToLong(SysMakeorderBom::getUseNum).sum();
Long purchasePlanMaterialSum = makeOrderMaterialSum * sum;
// 创建采购计划主记录 // 创建采购计划主记录
PurchasePlan purchasePlan = buildPurchasePlan(sysMakeOrder, purchasePlanCode); PurchasePlan purchasePlan = buildPurchasePlan(sysMakeOrder, purchasePlanCode,materialAmount,purchasePlanMaterialSum);
purchasePlanMapper.insertPurchasePlan(purchasePlan); purchasePlanMapper.insertPurchasePlan(purchasePlan);
// 批量创建采购计划子项 // 批量创建采购计划子项
@ -178,18 +193,16 @@ public class PurchasePlanServiceImpl implements IPurchasePlanService
return redisCache.generateBillNo("CGJH"); return redisCache.generateBillNo("CGJH");
} }
private PurchasePlan buildPurchasePlan(SysMakeOrder sysMakeOrder, String purchasePlanCode) { private PurchasePlan buildPurchasePlan(SysMakeOrder sysMakeOrder, String purchasePlanCode,Integer materialAmount,Long purchasePlanMaterialSum) {
PurchasePlan purchasePlan = new PurchasePlan(); PurchasePlan purchasePlan = new PurchasePlan();
purchasePlan.setCorrelationCode(sysMakeOrder.getMakeNo()); purchasePlan.setCorrelationCode(sysMakeOrder.getMakeNo());
purchasePlan.setPurchasePlanCode(purchasePlanCode); purchasePlan.setPurchasePlanCode(purchasePlanCode);
purchasePlan.setPurchasePlanType("1"); purchasePlan.setPurchasePlanType("1");
if (StringUtils.isNotBlank(sysMakeOrder.getMaterial())) { //添加物料合计
purchasePlan.setMaterialAmount(Long.parseLong(sysMakeOrder.getMaterial())); purchasePlan.setMaterialAmount((long) materialAmount);
} else {
// 如果该字段允许为NULL或有默认值,可以这样设置 //添加数量合计
purchasePlan.setMaterialAmount(0L); // 或者设定一个默认值,例如:0L purchasePlan.setMaterialSum(purchasePlanMaterialSum);
}
purchasePlan.setMaterialSum(sysMakeOrder.getMaterialSum());
purchasePlan.setNoRmbSum(sysMakeOrder.getNoRate()); purchasePlan.setNoRmbSum(sysMakeOrder.getNoRate());
purchasePlan.setRmbSum(sysMakeOrder.getRate()); purchasePlan.setRmbSum(sysMakeOrder.getRate());
purchasePlan.setApplyUser(sysMakeOrder.getSalesman()); purchasePlan.setApplyUser(sysMakeOrder.getSalesman());
@ -202,6 +215,9 @@ public class PurchasePlanServiceImpl implements IPurchasePlanService
} }
private void insertPurchasePlanChildren(List<SysMakeorderBom> insertedSysMakeorderBoms, String purchasePlanCode, SysMakeOrder sysMakeOrder) { private void insertPurchasePlanChildren(List<SysMakeorderBom> insertedSysMakeorderBoms, String purchasePlanCode, SysMakeOrder sysMakeOrder) {
//生产订单中的订单数量
Long makeOrderMaterialSum = sysMakeOrder.getMaterialSum();
for (SysMakeorderBom bom : insertedSysMakeorderBoms) { for (SysMakeorderBom bom : insertedSysMakeorderBoms) {
if ("0".equals(bom.getProcessMethod())) { if ("0".equals(bom.getProcessMethod())) {
PurchasePlanChild purchasePlanChild = new PurchasePlanChild(); PurchasePlanChild purchasePlanChild = new PurchasePlanChild();
@ -211,12 +227,16 @@ public class PurchasePlanServiceImpl implements IPurchasePlanService
purchasePlanChild.setMaterialType(bom.getMaterialType()); purchasePlanChild.setMaterialType(bom.getMaterialType());
//新增物料入库部门 //新增物料入库部门
purchasePlanChild.setWarehouseDept(bom.getWarehouseDept()); purchasePlanChild.setWarehouseDept(bom.getWarehouseDept());
purchasePlanChild.setProcessMethod("采购"); purchasePlanChild.setProcessMethod("0");
purchasePlanChild.setBrand(bom.getBrand()); purchasePlanChild.setBrand(bom.getBrand());
purchasePlanChild.setDescribe(bom.getDescribe()); purchasePlanChild.setDescribe(bom.getDescribe());
purchasePlanChild.setMaterialNum(bom.getUseNum()); //物料用量
Long useNum = bom.getUseNum();
//物料的计划采购数
purchasePlanChild.setMaterialNum(useNum * makeOrderMaterialSum);
purchasePlanChild.setCreateBy(ShiroUtils.getLoginName()); purchasePlanChild.setCreateBy(ShiroUtils.getLoginName());
purchasePlanChild.setCreateTime(new Date()); purchasePlanChild.setCreateTime(new Date());
purchasePlanChild.setUnit(bom.getUnit());
purchasePlanChildMapper.insertPurchasePlanChild(purchasePlanChild); purchasePlanChildMapper.insertPurchasePlanChild(purchasePlanChild);
} }
} }

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

@ -258,23 +258,41 @@ public class SysMakeOrderServiceImpl implements ISysMakeOrderService
String materialCode = sysSalesOrderChild.getMaterialCode(); String materialCode = sysSalesOrderChild.getMaterialCode();
// 0阶 // 0阶
ErpBom erpBom = erpBomService.selectErpBomByOneMaterialNo(materialCode); ErpBom erpBom = erpBomService.selectErpBomByOneMaterialNo(materialCode);
Long id = erpBom.getId(); if (erpBom != null){
// 查询1阶及以下 Long id = erpBom.getId();
ErpBom oneLevelBom = new ErpBom(); // 查询1阶及以下
oneLevelBom.setParentId(id); ErpBom oneLevelBom = new ErpBom();
List<ErpBom> subBomList = erpBomService.selectErpBomAllLevelList(oneLevelBom); oneLevelBom.setParentId(id);
for (int j = 0; j < subBomList.size(); j++) { List<ErpBom> subBomList = erpBomService.selectErpBomAllLevelList(oneLevelBom);
ErpBom subBom = subBomList.get(j); for (int j = 0; j < subBomList.size(); j++) {
SysMakeorderBom orderBom = new SysMakeorderBom(); ErpBom subBom = subBomList.get(j);
BeanUtils.copyProperties(subBom,orderBom, "id","delFlag","createBy","createTime","updateBy","updateTime","remark"); SysMakeorderBom orderBom = new SysMakeorderBom();
orderBom.setMakeNo(makeNo); BeanUtils.copyProperties(subBom,orderBom, "id","delFlag","createBy","createTime","updateBy","updateTime","remark");
orderBom.setSalesOrderCode(saleNo); orderBom.setMakeNo(makeNo);
orderBom.setSalesOrderMaterialNo(materialCode); orderBom.setSalesOrderCode(saleNo);
sortNo++; orderBom.setSalesOrderMaterialNo(materialCode);
orderBom.setSortNo(sortNo); sortNo++;
makeorderBomService.insertSysMakeorderBom(orderBom); orderBom.setSortNo(sortNo);
insertedSysMakeorderBoms.add(orderBom); makeorderBomService.insertSysMakeorderBom(orderBom);
insertedSysMakeorderBoms.add(orderBom);
}
}else {
ErpBom oneLevelBom = new ErpBom();
List<ErpBom> subBomList = erpBomService.selectErpBomAllLevelList(oneLevelBom);
for (int j = 0; j < subBomList.size(); j++) {
ErpBom subBom = subBomList.get(j);
SysMakeorderBom orderBom = new SysMakeorderBom();
BeanUtils.copyProperties(subBom,orderBom, "id","delFlag","createBy","createTime","updateBy","updateTime","remark");
orderBom.setMakeNo(makeNo);
orderBom.setSalesOrderCode(saleNo);
orderBom.setSalesOrderMaterialNo(materialCode);
sortNo++;
orderBom.setSortNo(sortNo);
makeorderBomService.insertSysMakeorderBom(orderBom);
insertedSysMakeorderBoms.add(orderBom);
}
} }
} }
} }
// todo 加工方式“采购”的物料生成采购计划 // todo 加工方式“采购”的物料生成采购计划

2
ruoyi-admin/src/main/resources/mapper/erp/ErpBomMapper.xml

@ -115,7 +115,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<if test="params.beginCreateTime != null and params.beginCreateTime != '' and params.endCreateTime != null and params.endCreateTime != ''"> and erp.create_time between #{params.beginCreateTime} and #{params.endCreateTime}</if> <if test="params.beginCreateTime != null and params.beginCreateTime != '' and params.endCreateTime != null and params.endCreateTime != ''"> and erp.create_time between #{params.beginCreateTime} and #{params.endCreateTime}</if>
<if test="params.materialNo != null and params.materialNo != ''"> and erp.material_no like concat('%', #{params.materialNo}, '%')</if> <if test="params.materialNo != null and params.materialNo != ''"> and erp.material_no like concat('%', #{params.materialNo}, '%')</if>
<if test="materialNo != null and materialNo != ''"> and erp.material_no = #{materialNo}</if> <if test="materialNo != null and materialNo != ''"> and erp.material_no = #{materialNo}</if>
<if test="bomNo != null and bomNo != ''"> and erp.bomNo = #{bomNo}</if> <if test="bomNo != null and bomNo != ''"> and erp.bom_no = #{bomNo}</if>
<if test="materialName != null and materialName != ''"> and erp.material_name like concat('%', #{materialName}, '%')</if> <if test="materialName != null and materialName != ''"> and erp.material_name like concat('%', #{materialName}, '%')</if>
<if test="auditStatus != null and auditStatus != ''"> and erp.audit_status = #{auditStatus}</if> <if test="auditStatus != null and auditStatus != ''"> and erp.audit_status = #{auditStatus}</if>
<if test="useStatus != null and useStatus != ''"> and erp.use_status = #{useStatus}</if> <if test="useStatus != null and useStatus != ''"> and erp.use_status = #{useStatus}</if>

8
ruoyi-admin/src/main/resources/templates/purchase/purchasePlan/detail.html

@ -107,7 +107,7 @@
}, },
columns: [ columns: [
{field: 'purchasePlanId',title: '主键id',visible: false}, {field: 'purchasePlanId',title: '主键id',visible: false},
{field: 'materialNo',title: '料号',}, {field: 'materialCode',title: '料号',},
{field: 'photoUrl',title: '图片', {field: 'photoUrl',title: '图片',
formatter: function(value, row, index) {return $.table.imageView(value);} formatter: function(value, row, index) {return $.table.imageView(value);}
}, },
@ -117,14 +117,12 @@
}, },
{field: 'describe',title: '描述',}, {field: 'describe',title: '描述',},
{field: 'brand',title: '品牌',}, {field: 'brand',title: '品牌',},
{field: 'processMethod',title: '半成品类型', {field: 'processMethod',title: '加工方式',
formatter: function(value, row, index) {return $.table.selectDictLabel(processMethodDatas, value);} formatter: function(value, row, index) {return $.table.selectDictLabel(processMethodDatas, value);}
}, },
{field: 'unit',title: '单位', {field: 'unit',title: '单位',
formatter: function(value, row, index) {return $.table.selectDictLabel(sysUnitClassDatas, value);}
}, },
{field: 'planNum',title: '计划采购数', {field: 'materialNum',title: '计划采购数',
formatter: function(value, row, index) {return $.table.selectDictLabel(sysUnitClassDatas, value);}
}, },
]} ]}
$.table.init(option); $.table.init(option);

6
ruoyi-admin/src/main/resources/templates/purchase/purchasePlan/purchasePlan.html

@ -144,12 +144,10 @@
}, },
{field: 'describe',title: '描述',}, {field: 'describe',title: '描述',},
{field: 'brand',title: '品牌',}, {field: 'brand',title: '品牌',},
{field: 'processMethod',title: '加工类型', {field: 'processMethod',title: '加工方式',
formatter: function(value, row, index) {return $.table.selectDictLabel(processMethodDatas, value);} formatter: function(value, row, index) {return $.table.selectDictLabel(processMethodDatas, value);}
}, },
{field: 'unit',title: '单位', {field: 'unit',title: '单位', },
formatter: function(value, row, index) {return $.table.selectDictLabel(sysUnitClassDatas, value);}
},
{field: 'warehouseDept',title: '入库部门',visible: false}, {field: 'warehouseDept',title: '入库部门',visible: false},
{field: 'materialNum',title: '计划采购数',}, {field: 'materialNum',title: '计划采购数',},
] ]

Loading…
Cancel
Save