From ec8d7cbe79f8c012f0d855e19fee9dc8cd27608f Mon Sep 17 00:00:00 2001
From: yaowanxin <3588231647@qq.com>
Date: 星期五, 09 一月 2026 16:24:54 +0800
Subject: [PATCH] 1.各生产订单的完成进度统计接口 2.在制品周转情况接口 3.生产报工记录添加上生产时间字段
---
src/main/java/com/ruoyi/production/service/impl/ProductionProductMainServiceImpl.java | 115 ++++++++++++++++++++++++++++++++++++++++++++++-----------
1 files changed, 92 insertions(+), 23 deletions(-)
diff --git a/src/main/java/com/ruoyi/production/service/impl/ProductionProductMainServiceImpl.java b/src/main/java/com/ruoyi/production/service/impl/ProductionProductMainServiceImpl.java
index f100c7f..31a1e9c 100644
--- a/src/main/java/com/ruoyi/production/service/impl/ProductionProductMainServiceImpl.java
+++ b/src/main/java/com/ruoyi/production/service/impl/ProductionProductMainServiceImpl.java
@@ -2,6 +2,7 @@
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
+import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
@@ -10,12 +11,15 @@
import com.ruoyi.basic.mapper.ProductModelMapper;
import com.ruoyi.basic.pojo.Product;
import com.ruoyi.basic.pojo.ProductModel;
+import com.ruoyi.common.utils.SecurityUtils;
import com.ruoyi.common.utils.bean.BeanUtils;
import com.ruoyi.production.controller.ProductWorkOrderController;
+import com.ruoyi.production.dto.ProductStructureDto;
import com.ruoyi.production.dto.ProductionProductMainDto;
import com.ruoyi.production.mapper.*;
import com.ruoyi.production.pojo.*;
import com.ruoyi.production.service.ProductionProductMainService;
+import com.ruoyi.project.system.domain.SysUser;
import com.ruoyi.quality.mapper.QualityInspectMapper;
import com.ruoyi.quality.mapper.QualityInspectParamMapper;
import com.ruoyi.quality.mapper.QualityTestStandardMapper;
@@ -30,6 +34,7 @@
import java.math.BigDecimal;
import java.time.LocalDate;
import java.time.format.DateTimeFormatter;
+import java.util.HashMap;
import java.util.List;
import java.util.Map;
@@ -61,6 +66,14 @@
private QualityInspectParamMapper qualityInspectParamMapper;
+ private ProductStructureMapper productStructureMapper;
+
+ private ProductionProductInputMapper productionProductInputMapper;
+
+ private ProductOrderMapper productOrderMapper;
+
+ private SalesLedgerProductionAccountingMapper salesLedgerProductionAccountingMapper;
+
@Override
public IPage<ProductionProductMainDto> listPageProductionProductMainDto(Page page, ProductionProductMainDto productionProductMainDto) {
@@ -74,23 +87,9 @@
throw new RuntimeException("鍙傛暟涓嶈兘涓虹┖");
}
-// if (dto.isReportWork()) {
-// // 鏇存柊閫昏緫 - 鍙洿鏂版暟閲�
-// QueryWrapper<ProductionProductOutput> outputWrapper = new QueryWrapper<>();
-// outputWrapper.eq("product_main_id", dto.getId());
-//
-// ProductionProductOutput output = productionProductOutputMapper.selectOne(outputWrapper);
-// if (output == null) {
-// throw new RuntimeException("浜у嚭璁板綍涓嶅瓨鍦�");
-// }
-//
-// // 鍙洿鏂版暟閲�
-// if (dto.getQuantity() != null) {
-// output.setQuantity(dto.getQuantity());
-// productionProductOutputMapper.updateById(output);
-// }
-// return true;
-// }
+ SysUser user = SecurityUtils.getLoginUser().getUser();
+
+
// 鏂板閫昏緫
ProductionProductMain productionProductMain = new ProductionProductMain();
@@ -131,7 +130,7 @@
String productNo = String.format("%s%03d", datePrefix, sequenceNumber);
productionProductMain.setProductNo(productNo);
- productionProductMain.setUserId(dto.getUserId());
+ productionProductMain.setUserId(user.getUserId());
productionProductMain.setProductProcessRouteItemId(dto.getProductProcessRouteItemId());
productionProductMain.setWorkOrderId(dto.getWorkOrderId());
productionProductMain.setStatus(0);
@@ -141,11 +140,13 @@
//鏇存柊宸ュ崟
if (insert > 0) {
- UpdateWrapper<ProductWorkOrder> wrapper = new UpdateWrapper<>();
- wrapper.set("report_work", true)
- .set("quantity",dto.getQuantity())
- .eq("id", dto.getWorkOrderId());
- productWorkOrderMapper.update(null, wrapper);
+ Map<String, Object> params = new HashMap<>();
+ params.put("quantity", dto.getQuantity());
+ params.put("productMainId", productionProductMain.getId());
+ params.put("workOrderId", dto.getWorkOrderId());
+ params.put("deductQuantity", dto.getQuantity());
+
+ productWorkOrderMapper.updatePlanQuantity(params);
}
ProductProcess productProcess = productProcessMapper.selectById(productProcessRouteItem.getProcessId());
ProductModel productModel = productProcessRouteItem.getProductModelId() != null ?
@@ -164,6 +165,7 @@
qualityInspect.setProcess(productProcess.getName());
qualityInspect.setInspectState(0);
qualityInspect.setInspectType(inspectType);
+ qualityInspect.setProductMainId(productionProductMain.getId());
qualityInspectMapper.insert(qualityInspect);
qualityTestStandardMapper.selectList(
@@ -177,6 +179,18 @@
qualityInspectParamMapper.insert(param);
});
}
+ // 娣诲姞鎶曞叆
+ if (productModel != null) {
+ List<ProductStructureDto> productStructureDtos = productStructureMapper.listByproductModelId(productModel.getId());
+ for (ProductStructureDto productStructureDto : productStructureDtos) {
+ ProductionProductInput productionProductInput = new ProductionProductInput();
+ productionProductInput.setProductModelId(productStructureDto.getProductModelId());
+ productionProductInput.setQuantity(productStructureDto.getUnitQuantity());
+ productionProductInput.setProductMainId(productionProductMain.getId());
+ productionProductInputMapper.insert(productionProductInput);
+ }
+ }
+
// 娣诲姞浜у嚭
ProductionProductOutput productionProductOutput = new ProductionProductOutput();
productionProductOutput.setProductMainId(productionProductMain.getId());
@@ -184,6 +198,61 @@
productionProductOutput.setQuantity(dto.getQuantity() != null ? dto.getQuantity() : BigDecimal.ZERO);
productionProductOutputMapper.insert(productionProductOutput);
+ // 鑾峰彇鐢熶骇璁㈠崟
+ ProductWorkOrder productWorkOrder = productWorkOrderMapper.selectById(dto.getWorkOrderId());
+ ProductOrder productOrder = productOrderMapper.selectById(productWorkOrder.getProductOrderId());
+ if (productOrder == null) {
+ throw new RuntimeException("鐢熶骇璁㈠崟涓嶅瓨鍦�");
+ }
+ // 娣诲姞鐢熶骇鏍哥畻
+ SalesLedgerProductionAccounting salesLedgerProductionAccounting = SalesLedgerProductionAccounting.builder()
+ .salesLedgerWorkId(productionProductMain.getId())
+ .salesLedgerSchedulingId(0L)
+ .salesLedgerId(productOrder.getSalesLedgerId())
+ .salesLedgerProductId(productOrder.getProductModelId())
+ .schedulingUserId(user.getUserId())
+ .schedulingUserName(user.getNickName())
+ .finishedNum(dto.getQuantity() != null ? dto.getQuantity() : BigDecimal.ZERO)
+ .workHours(productProcess.getSalaryQuota())
+ .process(productProcess.getName())
+ .schedulingDate(LocalDate.now())
+ .tenantId(dto.getTenantId())
+ .build();
+ salesLedgerProductionAccountingMapper.insert(salesLedgerProductionAccounting);
+
return true;
}
+
+ @Override
+ @Transactional
+ public Boolean removeProductMain(ProductionProductMainDto dto) {
+ Long id = dto.getId();
+
+ // 鏇存柊宸ュ崟
+ productWorkOrderMapper.rollbackPlanQuantity(id);
+ // 鍒犻櫎璐ㄦ鍙傛暟鍜岃川妫�璁板綍
+ qualityInspectMapper.selectList(
+ new LambdaQueryWrapper<QualityInspect>()
+ .eq(QualityInspect::getProductMainId, id)
+ ).forEach(q -> {
+ qualityInspectParamMapper.delete(
+ new LambdaQueryWrapper<QualityInspectParam>()
+ .eq(QualityInspectParam::getInspectId, q.getId()));
+ qualityInspectMapper.deleteById(q.getId());
+ });
+
+ // 鍒犻櫎浜у嚭璁板綍
+ productionProductOutputMapper.delete(new LambdaQueryWrapper<ProductionProductOutput>()
+ .eq(ProductionProductOutput::getProductMainId, id)
+ );
+
+ // 鍒犻櫎鍏宠仈鐨勬牳绠楁暟鎹�
+ salesLedgerProductionAccountingMapper.delete(
+ new LambdaQueryWrapper<SalesLedgerProductionAccounting>()
+ .eq(SalesLedgerProductionAccounting::getSalesLedgerWorkId, id)
+ );
+
+ // 鍒犻櫎涓昏〃
+ return productionProductMainMapper.deleteById(id) > 0;
+ }
}
--
Gitblit v1.9.3