Compare commits

...

2 Commits

Author SHA1 Message Date
王晓迪 c6f9ff4c2d [fix] 4 days ago
王晓迪 b894d6c81e [fix] 4 days ago
  1. 12
      ruoyi-admin/src/main/java/com/ruoyi/erp/domain/ErpInboundOrderDetail.java
  2. 244
      ruoyi-admin/src/main/java/com/ruoyi/erp/service/impl/ErpInboundOrderServiceImpl.java
  3. 33
      ruoyi-admin/src/main/java/com/ruoyi/quality/domain/QualityOrder.java
  4. 71
      ruoyi-admin/src/main/java/com/ruoyi/quality/domain/QualityOrderDetail.java

12
ruoyi-admin/src/main/java/com/ruoyi/erp/domain/ErpInboundOrderDetail.java

@ -44,11 +44,11 @@ public class ErpInboundOrderDetail extends BaseEntity
/** 已完成数 */
@Excel(name = "已完成数")
private Long completedNum;
private int completedNum;
/** 本次完成数 */
@Excel(name = "本次完成数")
private Long currentNum;
private int currentNum;
/** 加工费单价 */
@Excel(name = "加工费单价")
@ -117,21 +117,21 @@ public class ErpInboundOrderDetail extends BaseEntity
this.availableStockNum = availableStockNum;
}
public void setCompletedNum(Long completedNum)
public void setCompletedNum(int completedNum)
{
this.completedNum = completedNum;
}
public Long getCompletedNum()
public int getCompletedNum()
{
return completedNum;
}
public void setCurrentNum(Long currentNum)
public void setCurrentNum(int currentNum)
{
this.currentNum = currentNum;
}
public Long getCurrentNum()
public int getCurrentNum()
{
return currentNum;
}

244
ruoyi-admin/src/main/java/com/ruoyi/erp/service/impl/ErpInboundOrderServiceImpl.java

@ -109,112 +109,10 @@ public class ErpInboundOrderServiceImpl implements IErpInboundOrderService
/**
* 生产订单新增委内加工入库单先品质
*
* @param erpInboundOrder 委内加工入库单
* @return 结果
*/
@Override
@Transactional(rollbackFor = Exception.class)
public int insertErpInboundOrder(ErpInboundOrder erpInboundOrder)
{
QualityOrder qualityOrder = new QualityOrder();
String loginName = ShiroUtils.getLoginName();
erpInboundOrder.setCreateBy(loginName);
erpInboundOrder.setCreateTime(DateUtils.getNowDate());
// 生成编号,年月日规则
String qualityOrderCode = redisCache.generateBillNo("PZ");
qualityOrder.setQualityOrderCode(qualityOrderCode);
//设置关联单号
qualityOrder.setRelatedOrderCode(erpInboundOrder.getMakeNo());
//设置为待品质
qualityOrder.setQualityStatus("0");
//设置为委内入库
qualityOrder.setQualityStorageStatus("1");
//设置订单类型
qualityOrder.setQualityOrderType("1");
qualityOrder.setCreateTime(new Date());
qualityOrder.setCreateBy(loginName);
// 获取所有makeorderBomId对应的SysMakeorderBom对象
List<SysMakeorderBom> sysMakeorderBoms = erpInboundOrder.getInboundDetails().stream()
.map(ErpInboundOrderDetail::getMakeorderBomId)
.map(this::getSysMakeorderBomById)
.collect(Collectors.toList());
// 筛选加工方式只有委内加工的数据
List<SysMakeorderBom> filterSysMakeorderBoms = sysMakeorderBoms.stream()
.filter(sysMakeorderBom -> "1".equals(sysMakeorderBom.getProcessMethod()))
.collect(Collectors.toList());
// 创建一个Set来存储filterSysMakeorderBoms中的所有物料号MaterialNo
Set<String> materialNoSet = filterSysMakeorderBoms.stream()
.map(SysMakeorderBom::getMaterialNo)
.collect(Collectors.toSet());
// 使用materialNoSet来过滤erpInboundOrder.getInboundDetails()
List<ErpInboundOrderDetail> filteredErpInboundOrderDetails = erpInboundOrder.getInboundDetails().stream()
.filter(detail -> materialNoSet.contains(detail.getMaterialNo()) && detail.getCurrentNum() != null)
.collect(Collectors.toList());
// 首先,创建一个Map来收集每个物料号及其对应的加工费单价的列表
Map<String, List<BigDecimal>> processFeesByMaterialNo = filteredErpInboundOrderDetails.stream()
.collect(Collectors.groupingBy(
ErpInboundOrderDetail::getMaterialNo, // 分组依据:物料号
Collectors.mapping(
ErpInboundOrderDetail::getProcessFeeUnitPrice, // 映射:从每个细节中获取加工费单价
Collectors.toList() // 收集:将映射结果收集到List中
)
));
// 然后,检查是否有任何物料号的加工费单价不一致
boolean hasInconsistentFees = processFeesByMaterialNo.values().stream()
.anyMatch(prices -> prices.stream().distinct().count() > 1);
// 如果发现加工费单价不一致,则抛出异常
if (hasInconsistentFees) {
throw new BusinessException("请保持委内加工费单价一致");
}
// 计算本次委内完成数合计
long addCurrentNum = filteredErpInboundOrderDetails.stream()
.mapToLong(ErpInboundOrderDetail::getCurrentNum) // 假设getCurrentNum()返回的是int或long类型
.sum();
// 将long类型的addCurrentNum转换为BigDecimal类型
BigDecimal bigAddCurrentNum = BigDecimal.valueOf(addCurrentNum);
// 检查是否存在加工费单价为null的情况
boolean hasMakeInTotalPriceNull = filteredErpInboundOrderDetails.stream()
.anyMatch(item -> item.getProcessFeeUnitPrice() == null);
if (hasMakeInTotalPriceNull) {
throw new BusinessException("存在委内加工费为空,请检查!");
}
// 确保processFeeUnitPrice不为null,避免NullPointerException
BigDecimal processFeeUnitPrice = filteredErpInboundOrderDetails.get(0).getProcessFeeUnitPrice();
if (processFeeUnitPrice == null) {
throw new BusinessException("加工费单价未找到,请检查!");
}
// 计算委内加工费总价
BigDecimal makeInTotalPrice = bigAddCurrentNum.multiply(processFeeUnitPrice);
//加入到品质单中
qualityOrder.setMakeInTotalPrice(makeInTotalPrice);
//添加委内加工品质单详情数据
addQualityOrderDetail(erpInboundOrder, filteredErpInboundOrderDetails,qualityOrderCode,filterSysMakeorderBoms);
//添加委内加工品质单报告数据
addQualityOrderReport(filteredErpInboundOrderDetails,qualityOrderCode,filterSysMakeorderBoms);
//插入品质单
return qualityOrderMapper.insertQualityOrder(qualityOrder);
public int insertErpInboundOrder(ErpInboundOrder erpInboundOrder) {
return erpInboundOrderMapper.insertErpInboundOrder(erpInboundOrder);
}
// 提取公共方法
@ -223,39 +121,39 @@ public class ErpInboundOrderServiceImpl implements IErpInboundOrderService
}
//添加委内加工品质单报告数据
private void addQualityOrderReport(List<ErpInboundOrderDetail> filteredErpInboundOrderDetails,String qualityOrderCode,List<SysMakeorderBom> sysMakeorderBoms) {
// List<ErpInboundOrderDetail> inboundDetails = erpInboundOrder.getInboundDetails();
// if (CollectionUtils.isEmpty(inboundDetails)) {
// throw new BusinessException("委内加工详情数据为空");
// private void addQualityOrderReport(List<ErpInboundOrderDetail> filteredErpInboundOrderDetails,String qualityOrderCode,List<SysMakeorderBom> sysMakeorderBoms) {
//// List<ErpInboundOrderDetail> inboundDetails = erpInboundOrder.getInboundDetails();
//// if (CollectionUtils.isEmpty(inboundDetails)) {
//// throw new BusinessException("委内加工详情数据为空");
//// }
// for (int i = 0; i < filteredErpInboundOrderDetails.size(); i++) {
// ErpInboundOrderDetail inboundDetail = filteredErpInboundOrderDetails.get(i);
// SysMakeorderBom sysMakeorderBom = sysMakeorderBoms.get(i);
// QualityOrderReport qualityOrderReport = new QualityOrderReport();
// qualityOrderReport.setQualityOrderCode(qualityOrderCode);
// qualityOrderReport.setMaterialNo(sysMakeorderBom.getMaterialNo());
//
// QualityOrderReport tempQualityOrderReport = qualityOrderReportMapper.selectMakeInOrderReportByNoAndCode(qualityOrderReport);
// if (tempQualityOrderReport != null){
// qualityOrderReport.setQualityOrderReportId(tempQualityOrderReport.getQualityOrderReportId());
// Long currentNum = inboundDetail.getCurrentNum();
//// qualityOrderReport.setMakeInNum((int) (tempQualityOrderReport.getMakeInNum()+currentNum));
// int updateQualityOrderReportResult = qualityOrderReportMapper.updateQualityOrderReportById(qualityOrderReport);
// if (updateQualityOrderReportResult <= 0){
// throw new BusinessException("更新品质单报告数据失败");
// }
// }else {
// qualityOrderReport.setMaterialName(sysMakeorderBom.getMaterialName());
// //添加委内已完成数
//// qualityOrderReport.setMakeInNum(Math.toIntExact(inboundDetail.getCurrentNum()));
// qualityOrderReport.setCreateBy(ShiroUtils.getLoginName());
// qualityOrderReport.setCreateTime(new Date());
// qualityOrderReportMapper.insertQualityOrderReport(qualityOrderReport);
// }
//
//
// }
// }
for (int i = 0; i < filteredErpInboundOrderDetails.size(); i++) {
ErpInboundOrderDetail inboundDetail = filteredErpInboundOrderDetails.get(i);
SysMakeorderBom sysMakeorderBom = sysMakeorderBoms.get(i);
QualityOrderReport qualityOrderReport = new QualityOrderReport();
qualityOrderReport.setQualityOrderCode(qualityOrderCode);
qualityOrderReport.setMaterialNo(sysMakeorderBom.getMaterialNo());
QualityOrderReport tempQualityOrderReport = qualityOrderReportMapper.selectMakeInOrderReportByNoAndCode(qualityOrderReport);
if (tempQualityOrderReport != null){
qualityOrderReport.setQualityOrderReportId(tempQualityOrderReport.getQualityOrderReportId());
Long currentNum = inboundDetail.getCurrentNum();
qualityOrderReport.setMakeInNum((int) (tempQualityOrderReport.getMakeInNum()+currentNum));
int updateQualityOrderReportResult = qualityOrderReportMapper.updateQualityOrderReportById(qualityOrderReport);
if (updateQualityOrderReportResult <= 0){
throw new BusinessException("更新品质单报告数据失败");
}
}else {
qualityOrderReport.setMaterialName(sysMakeorderBom.getMaterialName());
//添加委内已完成数
qualityOrderReport.setMakeInNum(Math.toIntExact(inboundDetail.getCurrentNum()));
qualityOrderReport.setCreateBy(ShiroUtils.getLoginName());
qualityOrderReport.setCreateTime(new Date());
qualityOrderReportMapper.insertQualityOrderReport(qualityOrderReport);
}
}
}
//添加委内加工品质单详情数据
private void addQualityOrderDetail(ErpInboundOrder erpInboundOrder,List<ErpInboundOrderDetail> filteredErpInboundOrderDetails,String qualityOrderCode,List<SysMakeorderBom> sysMakeorderBoms) {
@ -263,43 +161,43 @@ public class ErpInboundOrderServiceImpl implements IErpInboundOrderService
// if (CollectionUtils.isEmpty(inboundDetails)) {
// throw new BusinessException("委内加工详情数据为空");
// }
for (int i = 0; i < filteredErpInboundOrderDetails.size(); i++) {
ErpInboundOrderDetail inboundDetail = filteredErpInboundOrderDetails.get(i);
SysMakeorderBom sysMakeorderBom = sysMakeorderBoms.get(i);
QualityOrderDetail qualityOrderDetail = new QualityOrderDetail();
qualityOrderDetail.setMaterialNo(sysMakeorderBom.getMaterialNo());
qualityOrderDetail.setQualityOrderCode(qualityOrderCode);
QualityOrderDetail tempQualityOrderDetail = qualityOrderDetailMapper.selectMakeInOrderDetailByCodeAndNo(qualityOrderDetail);
if (tempQualityOrderDetail != null){
qualityOrderDetail.setQualityOrderDetailId(tempQualityOrderDetail.getQualityOrderDetailId());
Long currentNum = inboundDetail.getCurrentNum();
qualityOrderDetail.setMakeInNum((int) (tempQualityOrderDetail.getMakeInNum()+currentNum));
int updateQualityOrderDetailResult = qualityOrderDetailMapper.updateQualityOrderDetail(qualityOrderDetail);
if (updateQualityOrderDetailResult <= 0){
throw new BusinessException("更新品质单详情数据失败");
}
}else {
qualityOrderDetail.setRelatedOrderCode(erpInboundOrder.getMakeNo());
qualityOrderDetail.setMaterialName(sysMakeorderBom.getMaterialName());
qualityOrderDetail.setMaterialBrand(sysMakeorderBom.getBrand());
qualityOrderDetail.setMaterialDescribe(sysMakeorderBom.getDescribe());
qualityOrderDetail.setMaterialProcessMethod(sysMakeorderBom.getProcessMethod());
qualityOrderDetail.setMaterialDeptType(sysMakeorderBom.getWarehouseDept());
qualityOrderDetail.setMaterialPhotourl(sysMakeorderBom.getPhotoUrl());
qualityOrderDetail.setMaterialUnit(sysMakeorderBom.getUnit());
qualityOrderDetail.setMaterialType(sysMakeorderBom.getMaterialType());
//添加委内已完成数
qualityOrderDetail.setMakeInNum(Math.toIntExact(inboundDetail.getCurrentNum()));
//添加委内加工费单价
qualityOrderDetail.setMakeInUnitPrice(inboundDetail.getProcessFeeUnitPrice());
qualityOrderDetail.setCreateBy(ShiroUtils.getLoginName());
qualityOrderDetail.setCreateTime(new Date());
qualityOrderDetailMapper.insertQualityOrderDetail(qualityOrderDetail);
}
}
// for (int i = 0; i < filteredErpInboundOrderDetails.size(); i++) {
// ErpInboundOrderDetail inboundDetail = filteredErpInboundOrderDetails.get(i);
// SysMakeorderBom sysMakeorderBom = sysMakeorderBoms.get(i);
//
// QualityOrderDetail qualityOrderDetail = new QualityOrderDetail();
// qualityOrderDetail.setMaterialNo(sysMakeorderBom.getMaterialNo());
// qualityOrderDetail.setQualityOrderCode(qualityOrderCode);
// QualityOrderDetail tempQualityOrderDetail = qualityOrderDetailMapper.selectMakeInOrderDetailByCodeAndNo(qualityOrderDetail);
// if (tempQualityOrderDetail != null){
// qualityOrderDetail.setQualityOrderDetailId(tempQualityOrderDetail.getQualityOrderDetailId());
// Long currentNum = inboundDetail.getCurrentNum();
// qualityOrderDetail.setMakeInNum((int) (tempQualityOrderDetail.getMakeInNum()+currentNum));
// int updateQualityOrderDetailResult = qualityOrderDetailMapper.updateQualityOrderDetail(qualityOrderDetail);
// if (updateQualityOrderDetailResult <= 0){
// throw new BusinessException("更新品质单详情数据失败");
// }
// }else {
// qualityOrderDetail.setRelatedOrderCode(erpInboundOrder.getMakeNo());
//
// qualityOrderDetail.setMaterialName(sysMakeorderBom.getMaterialName());
// qualityOrderDetail.setMaterialBrand(sysMakeorderBom.getBrand());
// qualityOrderDetail.setMaterialDescribe(sysMakeorderBom.getDescribe());
// qualityOrderDetail.setMaterialProcessMethod(sysMakeorderBom.getProcessMethod());
// qualityOrderDetail.setMaterialDeptType(sysMakeorderBom.getWarehouseDept());
// qualityOrderDetail.setMaterialPhotourl(sysMakeorderBom.getPhotoUrl());
// qualityOrderDetail.setMaterialUnit(sysMakeorderBom.getUnit());
// qualityOrderDetail.setMaterialType(sysMakeorderBom.getMaterialType());
// //添加委内已完成数
// qualityOrderDetail.setMakeInNum(Math.toIntExact(inboundDetail.getCurrentNum()));
// //添加委内加工费单价
// qualityOrderDetail.setMakeInUnitPrice(inboundDetail.getProcessFeeUnitPrice());
// qualityOrderDetail.setCreateBy(ShiroUtils.getLoginName());
// qualityOrderDetail.setCreateTime(new Date());
// qualityOrderDetailMapper.insertQualityOrderDetail(qualityOrderDetail);
// }
//
// }
}
/**

33
ruoyi-admin/src/main/java/com/ruoyi/quality/domain/QualityOrder.java

@ -47,6 +47,15 @@ public class QualityOrder extends BaseEntity
@Excel(name = "品质单入库类型")
private String qualityStorageStatus;
//料号
private String materialNo;
//物料名称
private String materialName;
//待审核数
private int pendingReviewNum;
/** 本次到货数量 */
@Excel(name = "本次到货数量")
private Integer thisArrivedNum;
@ -235,6 +244,30 @@ public class QualityOrder extends BaseEntity
this.storageNum = storageNum;
}
public String getMaterialNo() {
return materialNo;
}
public void setMaterialNo(String materialNo) {
this.materialNo = materialNo;
}
public String getMaterialName() {
return materialName;
}
public void setMaterialName(String materialName) {
this.materialName = materialName;
}
public int getPendingReviewNum() {
return pendingReviewNum;
}
public void setPendingReviewNum(int pendingReviewNum) {
this.pendingReviewNum = pendingReviewNum;
}
@Override
public String toString() {
return new ToStringBuilder(this,ToStringStyle.MULTI_LINE_STYLE)

71
ruoyi-admin/src/main/java/com/ruoyi/quality/domain/QualityOrderDetail.java

@ -106,6 +106,9 @@ public class QualityOrderDetail extends BaseEntity
@Excel(name = "物料描述")
private String materialDescribe;
//物料型号
private String materialModel;
/** 物料加工方式 */
@Excel(name = "物料加工方式")
private String materialProcessMethod;
@ -121,13 +124,6 @@ public class QualityOrderDetail extends BaseEntity
/** 生产完成数 */
private Integer makeCompletionNum;
/** 实际到货数量 */
@Excel(name = "实际到货数量")
private Integer actualArriveNum;
/** 本次到货数量 */
@Excel(name = "本次到货数量")
private Integer thisArrivedNum;
/** 品质已合格数 */
@Excel(name = "品质已合格数")
@ -141,13 +137,12 @@ public class QualityOrderDetail extends BaseEntity
@Excel(name = "品质不合格数")
private Integer qualityUnqualifiedNum;
/** 委内已完成数 */
@Excel(name = "委内已完成数")
private Integer makeInNum;
//检验数
private int checkNum;
//待审核数
private int pendingReviewNum;
/** 委内加工费单价 */
private BigDecimal makeInUnitPrice;
public void setQualityOrderDetailId(Long qualityOrderDetailId)
@ -374,22 +369,6 @@ public class QualityOrderDetail extends BaseEntity
this.makeCompletionNum = makeCompletionNum;
}
public Integer getActualArriveNum() {
return actualArriveNum;
}
public void setActualArriveNum(Integer actualArriveNum) {
this.actualArriveNum = actualArriveNum;
}
public Integer getThisArrivedNum() {
return thisArrivedNum;
}
public void setThisArrivedNum(Integer thisArrivedNum) {
this.thisArrivedNum = thisArrivedNum;
}
public Integer getQualityHasqualifiedNum() {
return qualityHasqualifiedNum;
}
@ -414,28 +393,36 @@ public class QualityOrderDetail extends BaseEntity
this.qualityUnqualifiedNum = qualityUnqualifiedNum;
}
public Integer getMakeInNum() {
return makeInNum;
public String getMaterialDeptType() {
return materialDeptType;
}
public void setMaterialDeptType(String materialDeptType) {
this.materialDeptType = materialDeptType;
}
public void setMakeInNum(Integer makeInNum) {
this.makeInNum = makeInNum;
public int getCheckNum() {
return checkNum;
}
public BigDecimal getMakeInUnitPrice() {
return makeInUnitPrice;
public void setCheckNum(int checkNum) {
this.checkNum = checkNum;
}
public void setMakeInUnitPrice(BigDecimal makeInUnitPrice) {
this.makeInUnitPrice = makeInUnitPrice;
public int getPendingReviewNum() {
return pendingReviewNum;
}
public String getMaterialDeptType() {
return materialDeptType;
public void setPendingReviewNum(int pendingReviewNum) {
this.pendingReviewNum = pendingReviewNum;
}
public void setMaterialDeptType(String materialDeptType) {
this.materialDeptType = materialDeptType;
public String getMaterialModel() {
return materialModel;
}
public void setMaterialModel(String materialModel) {
this.materialModel = materialModel;
}
@Override
@ -466,14 +453,10 @@ public class QualityOrderDetail extends BaseEntity
.append("materialProcessMethod", getMaterialProcessMethod())
.append("materialDeptType",getMaterialDeptType())
.append("makeTotal", getMakeTotal())
.append("actualArriveNum", getActualArriveNum())
.append("thisArrivedNum", getThisArrivedNum())
.append("qualityHasqualifiedNum", getQualityHasqualifiedNum())
.append("qualityQualifiedNum", getQualityQualifiedNum())
.append("qualityUnqualifiedNum", getQualityUnqualifiedNum())
.append("makeInNum",getMakeInNum())
.append("makeCompletionNum",getMakeCompletionNum())
.append("makeInUnitPrice",getMakeInUnitPrice())
.append("remark", getRemark())
.append("createBy", getCreateBy())
.append("createTime", getCreateTime())

Loading…
Cancel
Save