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.util.Date;
import java.util.List;
import java.util.stream.Collectors;
import com.ruoyi.common.core.redis.RedisCache;
import com.ruoyi.common.utils.DateUtils;
@ -163,8 +164,22 @@ public class PurchasePlanServiceImpl implements IPurchasePlanService
// 仅查询一次,因为所有SysMakeorderBom都关联同一生产单号
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);
// 批量创建采购计划子项
@ -178,18 +193,16 @@ public class PurchasePlanServiceImpl implements IPurchasePlanService
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.setCorrelationCode(sysMakeOrder.getMakeNo());
purchasePlan.setPurchasePlanCode(purchasePlanCode);
purchasePlan.setPurchasePlanType("1");
if (StringUtils.isNotBlank(sysMakeOrder.getMaterial())) {
purchasePlan.setMaterialAmount(Long.parseLong(sysMakeOrder.getMaterial()));
} else {
// 如果该字段允许为NULL或有默认值,可以这样设置
purchasePlan.setMaterialAmount(0L); // 或者设定一个默认值,例如:0L
}
purchasePlan.setMaterialSum(sysMakeOrder.getMaterialSum());
//添加物料合计
purchasePlan.setMaterialAmount((long) materialAmount);
//添加数量合计
purchasePlan.setMaterialSum(purchasePlanMaterialSum);
purchasePlan.setNoRmbSum(sysMakeOrder.getNoRate());
purchasePlan.setRmbSum(sysMakeOrder.getRate());
purchasePlan.setApplyUser(sysMakeOrder.getSalesman());
@ -202,6 +215,9 @@ public class PurchasePlanServiceImpl implements IPurchasePlanService
}
private void insertPurchasePlanChildren(List<SysMakeorderBom> insertedSysMakeorderBoms, String purchasePlanCode, SysMakeOrder sysMakeOrder) {
//生产订单中的订单数量
Long makeOrderMaterialSum = sysMakeOrder.getMaterialSum();
for (SysMakeorderBom bom : insertedSysMakeorderBoms) {
if ("0".equals(bom.getProcessMethod())) {
PurchasePlanChild purchasePlanChild = new PurchasePlanChild();
@ -211,12 +227,16 @@ public class PurchasePlanServiceImpl implements IPurchasePlanService
purchasePlanChild.setMaterialType(bom.getMaterialType());
//新增物料入库部门
purchasePlanChild.setWarehouseDept(bom.getWarehouseDept());
purchasePlanChild.setProcessMethod("采购");
purchasePlanChild.setProcessMethod("0");
purchasePlanChild.setBrand(bom.getBrand());
purchasePlanChild.setDescribe(bom.getDescribe());
purchasePlanChild.setMaterialNum(bom.getUseNum());
//物料用量
Long useNum = bom.getUseNum();
//物料的计划采购数
purchasePlanChild.setMaterialNum(useNum * makeOrderMaterialSum);
purchasePlanChild.setCreateBy(ShiroUtils.getLoginName());
purchasePlanChild.setCreateTime(new Date());
purchasePlanChild.setUnit(bom.getUnit());
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();
// 0阶
ErpBom erpBom = erpBomService.selectErpBomByOneMaterialNo(materialCode);
Long id = erpBom.getId();
// 查询1阶及以下
ErpBom oneLevelBom = new ErpBom();
oneLevelBom.setParentId(id);
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);
if (erpBom != null){
Long id = erpBom.getId();
// 查询1阶及以下
ErpBom oneLevelBom = new ErpBom();
oneLevelBom.setParentId(id);
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);
}
}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 加工方式“采购”的物料生成采购计划

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

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

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

Loading…
Cancel
Save