src/main/java/com/ruoyi/procurementrecord/controller/ProcurementRecordController.java
@@ -41,6 +41,8 @@ @Log(title = "采购入库-入库管理-新增入库", businessType = BusinessType.INSERT) @Transactional public AjaxResult add(@RequestBody ProcurementAddDto procurementDto) { procurementDto.setType(1); procurementDto.setTypeName("采购入库"); return AjaxResult.success(procurementRecordService.add(procurementDto)); } src/main/java/com/ruoyi/procurementrecord/dto/Details.java
@@ -10,7 +10,7 @@ */ @Data public class Details { private Integer id; private BigDecimal inboundQuantity; private BigDecimal warnNum; private Integer id; // 产品id private BigDecimal inboundQuantity; // 入库数量 private BigDecimal warnNum; // 预警数量(采购入库才有) } src/main/java/com/ruoyi/procurementrecord/dto/ProcurementAddDto.java
@@ -15,4 +15,11 @@ private String nickName; /** * 入库类型 1-采购 2-生产 */ private Integer type; private String typeName; } src/main/java/com/ruoyi/procurementrecord/dto/ProcurementPageDto.java
@@ -22,6 +22,11 @@ private Long createUser; /** * 入库类型 1-采购 2-生产 */ private Integer type; /** * 入库批次 */ @Excel(name = "入库批次") src/main/java/com/ruoyi/procurementrecord/pojo/ProcurementRecordStorage.java
@@ -40,6 +40,11 @@ * 预警数量 */ private BigDecimal warnNum; /** * 入库类型 1-采购入库 2-生产入库 */ private Integer type; // /** // * 最低库存数量 // */ src/main/java/com/ruoyi/procurementrecord/service/impl/ProcurementRecordServiceImpl.java
@@ -342,13 +342,15 @@ for (Details detail : procurementDto.getDetails()) { // 查询采购入库数量 LambdaQueryWrapper<ProcurementRecordStorage> procurementRecordLambdaQueryWrapper = new LambdaQueryWrapper<>(); procurementRecordLambdaQueryWrapper.eq(ProcurementRecordStorage::getSalesLedgerProductId, detail.getId()); procurementRecordLambdaQueryWrapper.eq(ProcurementRecordStorage::getSalesLedgerProductId, detail.getId()) .eq(ProcurementRecordStorage::getType, procurementDto.getType()); Long aLong = procurementRecordMapper.selectCount(procurementRecordLambdaQueryWrapper); ProcurementRecordStorage.ProcurementRecordStorageBuilder procurementRecordBuilder = ProcurementRecordStorage.builder() .salesLedgerProductId(detail.getId()) .inboundBatches(aLong.equals(0L) ? "第1批次" : "第"+ (aLong + 1) + "批次") .inboundBatches(aLong.equals(0L) ? "第1批次("+ procurementDto.getTypeName() +")" : "第"+ (aLong + 1) + "批次(" + procurementDto.getTypeName() + ")" ) .inboundNum(detail.getInboundQuantity()) .type(procurementDto.getType()) .warnNum(detail.getWarnNum()) .createTime(LocalDateTime.now()) .createUser(loginUser.getUserId()) src/main/java/com/ruoyi/production/dto/ProcessSchedulingDto.java
@@ -48,5 +48,23 @@ @ApiModelProperty(value = "排产日期") private String schedulingDate; /** * 备注 */ @ApiModelProperty(value = "备注") private String remark; /** * 损耗 */ @ApiModelProperty(value = "损耗") private String loss; /** * 口味分类 */ @ApiModelProperty(value = "口味分类") private String type; } src/main/java/com/ruoyi/production/dto/SalesLedgerWorkDto.java
@@ -86,5 +86,26 @@ @Excel(name = "状态", readConverterExp = "1=待生产,2=生产中,3=已报工") private String statusName; /** * 备注 */ @ApiModelProperty(value = "备注") @Excel(name = "备注") private String remark; /** * 损耗 */ @ApiModelProperty(value = "损耗") @Excel(name = "损耗") private String loss; /** * 口味分类 */ @ApiModelProperty(value = "口味分类") @Excel(name = "口味分类") private String type; } src/main/java/com/ruoyi/production/pojo/SalesLedgerWork.java
@@ -78,6 +78,21 @@ private Integer status; /** * 备注 */ private String remark; /** * 损耗 */ private String loss; /** * 口味分类 */ private String type; /** * 创建者 */ @TableField(fill = FieldFill.INSERT) src/main/java/com/ruoyi/production/service/impl/SalesLedgerSchedulingServiceImpl.java
@@ -152,10 +152,10 @@ SysUser sysUser = sysUserMapper.selectUserById(processSchedulingDto.getSchedulingUserId()); if(sysUser == null) throw new RuntimeException("排产人不存在"); salesLedgerScheduling.setFinishedNum(salesLedgerScheduling.getFinishedNum().add(processSchedulingDto.getSchedulingNum())); LambdaQueryWrapper<SalesLedgerWork> salesLedgerWorkLambdaQueryWrapper = new LambdaQueryWrapper<>(); salesLedgerWorkLambdaQueryWrapper.eq(SalesLedgerWork::getSalesLedgerSchedulingId, salesLedgerScheduling.getId()) .ne(SalesLedgerWork::getStatus, 1); List<SalesLedgerWork> salesLedgerWorks = salesLedgerWorkMapper.selectList(salesLedgerWorkLambdaQueryWrapper); // LambdaQueryWrapper<SalesLedgerWork> salesLedgerWorkLambdaQueryWrapper = new LambdaQueryWrapper<>(); // salesLedgerWorkLambdaQueryWrapper.eq(SalesLedgerWork::getSalesLedgerSchedulingId, salesLedgerScheduling.getId()) // .ne(SalesLedgerWork::getStatus, 1); // List<SalesLedgerWork> salesLedgerWorks = salesLedgerWorkMapper.selectList(salesLedgerWorkLambdaQueryWrapper); if(salesLedgerScheduling.getSchedulingNum().compareTo(salesLedgerScheduling.getFinishedNum()) < 0){ throw new RuntimeException("当前排产数量大于待排产数量,请仔细核对!"); } @@ -168,6 +168,9 @@ SalesLedgerWork.SalesLedgerWorkBuilder salesLedgerWorkBuilder = SalesLedgerWork.builder() .salesLedgerSchedulingId(salesLedgerScheduling.getId()) .salesLedgerId(salesLedgerScheduling.getSalesLedgerId()) .remark(processSchedulingDto.getRemark()) .type(processSchedulingDto.getType()) .loss(processSchedulingDto.getLoss()) .salesLedgerProductId(salesLedgerScheduling.getSalesLedgerProductId()) .schedulingUserId(salesLedgerScheduling.getSchedulingUserId()) .schedulingUserName(sysUser.getNickName()) src/main/java/com/ruoyi/production/service/impl/SalesLedgerWorkServiceImpl.java
@@ -4,7 +4,14 @@ import com.baomidou.mybatisplus.core.metadata.IPage; import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; import com.ruoyi.common.utils.SecurityUtils; import com.ruoyi.framework.security.LoginUser; import com.ruoyi.framework.web.domain.AjaxResult; import com.ruoyi.procurementrecord.dto.Details; import com.ruoyi.procurementrecord.dto.ProcurementAddDto; import com.ruoyi.procurementrecord.dto.ProcurementRecordOutAdd; import com.ruoyi.procurementrecord.service.impl.ProcurementRecordOutServiceImpl; import com.ruoyi.procurementrecord.service.impl.ProcurementRecordServiceImpl; import com.ruoyi.production.dto.ProductionReportDto; import com.ruoyi.production.dto.SalesLedgerWorkDto; import com.ruoyi.production.mapper.SalesLedgerProductionAccountingMapper; @@ -23,6 +30,7 @@ import java.time.LocalDate; import java.time.format.DateTimeFormatter; import java.util.ArrayList; import java.util.List; import java.util.stream.Collectors; @@ -47,6 +55,8 @@ return iPage; } private final ProcurementRecordServiceImpl procurementRecordService; @Override public int productionReport(ProductionReportDto productionReportDto) { SalesLedgerWork salesLedgerWork = salesLedgerWorkMapper.selectById(productionReportDto.getId()); @@ -66,7 +76,7 @@ .salesLedgerWorkId(salesLedgerWork.getId()) .salesLedgerSchedulingId(salesLedgerWork.getSalesLedgerSchedulingId()) .salesLedgerId(salesLedgerWork.getSalesLedgerId()) .salesLedgerProductId(salesLedgerWork.getSalesLedgerProductId()) .salesLedgerProductId((long)salesLedgerWork.getSalesLedgerProductId()) .schedulingUserId(sysUser.getUserId()) .schedulingUserName(sysUser.getNickName()) .finishedNum(productionReportDto.getFinishedNum()) @@ -74,6 +84,20 @@ .process(salesLedgerWork.getProcess()) .schedulingDate(LocalDate.parse(productionReportDto.getSchedulingDate(), DateTimeFormatter.ISO_LOCAL_DATE)); salesLedgerProductionAccountingMapper.insert(builder.build()); // 生产报工成功 -> 入库 LoginUser loginUser = SecurityUtils.getLoginUser(); ProcurementAddDto procurementRecordOutAdd = new ProcurementAddDto(); procurementRecordOutAdd.setType(2); procurementRecordOutAdd.setTypeName("生产入库"); procurementRecordOutAdd.setNickName(loginUser.getNickName()); List<Details> details = new ArrayList<>(); Details details1 = new Details(); details1.setInboundQuantity(productionReportDto.getFinishedNum()); details1.setId(Integer.parseInt(salesLedgerWork.getSalesLedgerProductId().toString())); details.add(details1); procurementRecordOutAdd.setDetails(details); procurementRecordService.add(procurementRecordOutAdd); return 0; } src/main/resources/mapper/procurementrecord/ProcurementRecordMapper.xml
@@ -57,6 +57,9 @@ <if test="req.supplierName != null and req.supplierName != ''"> and t3.supplier_name like concat('%',#{req.supplierName},'%') </if> <if test="req.type != null and req.type != ''"> and t1.type = #{req.type} </if> <if test="req.timeStr != null and req.timeStr != ''"> and t1.create_time like concat('%',#{req.timeStr},'%') </if> @@ -116,6 +119,9 @@ <if test="req.supplierName != null and req.supplierName != ''"> and t3.supplier_name like concat('%',#{req.supplierName},'%') </if> <if test="req.type != null and req.type != ''"> and t1.type = #{req.type} </if> <if test="req.timeStr != null and req.timeStr != ''"> and t1.create_time like concat('%',#{req.timeStr},'%') </if> src/main/resources/mapper/production/SalesLedgerWorkMapper.xml
@@ -13,6 +13,9 @@ t4.finished_num, t4.work_hours, t4.process, t4.loss, t4.type, t4.remark, T1.sales_contract_no, T1.customer_contract_no, T1.project_name,