From a5274db2e3240c285bcc2d170bfa8c4205b435a8 Mon Sep 17 00:00:00 2001 From: mashuai Date: Thu, 4 Sep 2025 11:07:53 +0800 Subject: [PATCH] =?UTF-8?q?=E5=8A=9F=E8=83=BD=E4=BC=98=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../biz/domain/lease/LeaseOutDetails.java | 3 + .../basic/domain/dto/BoxBindWarehouseDto.java | 3 + .../service/impl/BmQrBoxServiceImpl.java | 19 ++++-- .../impl/MaterialLeaseInfoServiceImpl.java | 2 +- .../impl/LeaseApplyInfoServiceImpl.java | 24 ++++---- .../impl/LeaseOutDetailsServiceImpl.java | 14 ++++- .../com/bonus/material/ma/domain/Type.java | 22 ++++++- .../bonus/material/ma/mapper/TypeMapper.java | 17 +++++- .../material/ma/mapper/WarehousingMapper.java | 8 --- .../material/ma/service/ITypeService.java | 7 +++ .../ma/service/impl/TypeServiceImpl.java | 60 ++++++++++++++++++- .../service/impl/WarehousingServiceImpl.java | 47 ++++++++------- .../impl/PurchaseStorageServiceImpl.java | 30 ++++++++-- .../impl/RepairInputDetailsServiceImpl.java | 39 +++++++++--- .../mapper/material/basic/BmQrBoxMapper.xml | 4 +- .../material/basic/ComplexQueryMapper.xml | 4 +- .../mapper/material/common/SelectMapper.xml | 4 +- .../mapper/material/ma/TypeMapper.xml | 40 ++++++++++++- .../mapper/material/ma/WarehousingMapper.xml | 9 --- .../material/purchase/PurchaseBindMapper.xml | 3 +- 20 files changed, 273 insertions(+), 86 deletions(-) diff --git a/bonus-common-biz/src/main/java/com/bonus/common/biz/domain/lease/LeaseOutDetails.java b/bonus-common-biz/src/main/java/com/bonus/common/biz/domain/lease/LeaseOutDetails.java index 009b8c35..bf6b5cd2 100644 --- a/bonus-common-biz/src/main/java/com/bonus/common/biz/domain/lease/LeaseOutDetails.java +++ b/bonus-common-biz/src/main/java/com/bonus/common/biz/domain/lease/LeaseOutDetails.java @@ -173,4 +173,7 @@ public class LeaseOutDetails extends BaseEntity { @ApiModelProperty(value = "领料方式 0材料领料 1工器具领料 2数据同步") private String leaseStyle; + @ApiModelProperty(value = "任务单号") + private String code; + } diff --git a/bonus-modules/bonus-material/src/main/java/com/bonus/material/basic/domain/dto/BoxBindWarehouseDto.java b/bonus-modules/bonus-material/src/main/java/com/bonus/material/basic/domain/dto/BoxBindWarehouseDto.java index 8ad6c0ee..0ade0555 100644 --- a/bonus-modules/bonus-material/src/main/java/com/bonus/material/basic/domain/dto/BoxBindWarehouseDto.java +++ b/bonus-modules/bonus-material/src/main/java/com/bonus/material/basic/domain/dto/BoxBindWarehouseDto.java @@ -52,4 +52,7 @@ public class BoxBindWarehouseDto extends BaseEntity { @ApiModelProperty(value = "标准箱名称") private String boxName; + + @ApiModelProperty(value = "新购编号") + private String purchaseCode; } diff --git a/bonus-modules/bonus-material/src/main/java/com/bonus/material/basic/service/impl/BmQrBoxServiceImpl.java b/bonus-modules/bonus-material/src/main/java/com/bonus/material/basic/service/impl/BmQrBoxServiceImpl.java index d0cc7d41..24f0d460 100644 --- a/bonus-modules/bonus-material/src/main/java/com/bonus/material/basic/service/impl/BmQrBoxServiceImpl.java +++ b/bonus-modules/bonus-material/src/main/java/com/bonus/material/basic/service/impl/BmQrBoxServiceImpl.java @@ -18,8 +18,10 @@ import com.bonus.material.basic.domain.vo.BoxInfoBindVo; import com.bonus.material.basic.mapper.BmQrBoxMapper; import com.bonus.material.basic.service.BmQrBoxService; import com.bonus.material.ma.domain.Machine; +import com.bonus.material.ma.domain.Type; import com.bonus.material.ma.domain.vo.MachineVo; import com.bonus.material.ma.mapper.MachineMapper; +import com.bonus.material.ma.service.ITypeService; import com.bonus.material.purchase.config.RemoteConfig; import com.bonus.material.purchase.domain.PurchaseCheckDetails; import com.bonus.material.purchase.domain.vo.PurchaseVo; @@ -70,6 +72,9 @@ public class BmQrBoxServiceImpl implements BmQrBoxService { @Resource private RemoteConfig remoteConfig; + @Resource + private ITypeService typeService; + /** * 查询二维码标准箱管理列表 */ @@ -785,15 +790,21 @@ public class BmQrBoxServiceImpl implements BmQrBoxService { } private int updateStorageNum(BoxBindWarehouseDto boxMa) { - + Type type = new Type(); int result = 0; String maStatus = boxMa.getMaStatus(); - if("0".equals(maStatus)){ - boxMa.setInputNum(BigDecimal.valueOf(1)); - result = bmQrBoxMapper.updateStorageNum(boxMa); + if("0".equals(maStatus)) { + type.setModelTitle("新购入库"); + type.setTypeId(boxMa.getMaTypeId()); + type.setInputNum(BigDecimal.valueOf(1)); + type.setMaId(boxMa.getMaId()); + type.setStyle("4"); + result = typeService.updateNumAddOrSubtract(type); result = machineMapper.updateMaStatus(boxMa); + /*boxMa.setInputNum(BigDecimal.valueOf(1)); + result = bmQrBoxMapper.updateStorageNum(boxMa);*/ } return result; diff --git a/bonus-modules/bonus-material/src/main/java/com/bonus/material/clz/service/impl/MaterialLeaseInfoServiceImpl.java b/bonus-modules/bonus-material/src/main/java/com/bonus/material/clz/service/impl/MaterialLeaseInfoServiceImpl.java index 50d1e1c6..3160f55e 100644 --- a/bonus-modules/bonus-material/src/main/java/com/bonus/material/clz/service/impl/MaterialLeaseInfoServiceImpl.java +++ b/bonus-modules/bonus-material/src/main/java/com/bonus/material/clz/service/impl/MaterialLeaseInfoServiceImpl.java @@ -221,7 +221,7 @@ public class MaterialLeaseInfoServiceImpl implements MaterialLeaseInfoService { // 根据用户名查询项目部信息 String departId = mapper.getDepartId(username); // 根据项目部id查询工程信息 - List projectIdList = mapper.getProjectId(departId); + List projectIdList = mapper.getAllProjectList(departId); if (!CollectionUtils.isEmpty(projectIdList)) { leaseApplyInfo.setProjectIdList(projectIdList); } diff --git a/bonus-modules/bonus-material/src/main/java/com/bonus/material/lease/service/impl/LeaseApplyInfoServiceImpl.java b/bonus-modules/bonus-material/src/main/java/com/bonus/material/lease/service/impl/LeaseApplyInfoServiceImpl.java index 124028e2..5abe65ec 100644 --- a/bonus-modules/bonus-material/src/main/java/com/bonus/material/lease/service/impl/LeaseApplyInfoServiceImpl.java +++ b/bonus-modules/bonus-material/src/main/java/com/bonus/material/lease/service/impl/LeaseApplyInfoServiceImpl.java @@ -519,19 +519,17 @@ public class LeaseApplyInfoServiceImpl implements ILeaseApplyInfoService { .collect(Collectors.toList()); } String keyWord = leaseApplyInfo.getKeyWord(); - // 如果关键字不为空,进行过滤 - if (!StringUtils.isBlank(keyWord)) { - sortedList = sortedList.stream() - .filter(item -> containsKeyword(item, keyWord)) - .collect(Collectors.toList()); - } - // 判断状态 - if (!CollectionUtils.isEmpty(leaseApplyInfo.getStatusList())) { - // 将集合sortedList中状态taskStatus包含在leaseApplyInfo.getStatusList()中的元素 - sortedList = sortedList.stream() - .filter(item -> leaseApplyInfo.getStatusList().contains(item.getTaskStatus())) - .collect(Collectors.toList()); - } + List statusList = leaseApplyInfo.getStatusList(); + + // 转换为HashSet提高contains操作的效率(O(1)) + Set statusSet = CollectionUtils.isEmpty(statusList) ? + Collections.emptySet() : + new HashSet<>(statusList); + + sortedList = sortedList.stream() + .filter(item -> StringUtils.isBlank(keyWord) || containsKeyword(item, keyWord)) + .filter(item -> statusSet.isEmpty() || statusSet.contains(item.getTaskStatus())) + .collect(Collectors.toList()); } return sortedList; } catch (Exception e) { diff --git a/bonus-modules/bonus-material/src/main/java/com/bonus/material/lease/service/impl/LeaseOutDetailsServiceImpl.java b/bonus-modules/bonus-material/src/main/java/com/bonus/material/lease/service/impl/LeaseOutDetailsServiceImpl.java index 8c4b0085..3870cedc 100644 --- a/bonus-modules/bonus-material/src/main/java/com/bonus/material/lease/service/impl/LeaseOutDetailsServiceImpl.java +++ b/bonus-modules/bonus-material/src/main/java/com/bonus/material/lease/service/impl/LeaseOutDetailsServiceImpl.java @@ -34,6 +34,7 @@ import com.bonus.material.lease.mapper.LeaseApplyInfoMapper; import com.bonus.material.ma.domain.Type; import com.bonus.material.ma.mapper.MachineMapper; import com.bonus.material.ma.mapper.TypeMapper; +import com.bonus.material.ma.service.ITypeService; import com.bonus.material.settlement.domain.SltAgreementInfo; import com.bonus.material.settlement.mapper.SltAgreementInfoMapper; import com.bonus.material.task.domain.TmTask; @@ -104,7 +105,7 @@ public class LeaseOutDetailsServiceImpl implements ILeaseOutDetailsService { private MaterialLeaseInfoMapper materialLeaseInfoMapper; @Resource - private BackApplyInfoMapper backApplyInfoMapper; + private ITypeService typeService; /** * 查询领料出库详细 * @@ -800,12 +801,12 @@ public class LeaseOutDetailsServiceImpl implements ILeaseOutDetailsService { leaseApplyDetailsMapper.updateLeaseApplyDetailsByLeaseOutRecord(record); } if (res > GlobalConstants.INT_0) { + Type type = new Type(); // 插入领料出库明细表(lease_out_details) record.setCreateBy(SecurityUtils.getLoginUser().getUserid().toString()); res = leaseOutDetailsMapper.insertLeaseOutDetails(record); + type.setOutNum(record.getOutNum()); if (res > GlobalConstants.INT_0) { - // 普通机具减少 (ma_type 设备规格表)的库存数量 - res = typeMapper.updateMaTypeStockNum(record); if (record.getMaId() != null) { if (record.getJiJuType() == GlobalConstants.INT_1) { record.setThisCheckTime(DateUtils.getNowDate()); @@ -816,7 +817,14 @@ public class LeaseOutDetailsServiceImpl implements ILeaseOutDetailsService { } // 更新 (ma_machine 设备表)的状态 res = machineMapper.updateMaMachineStatus(record, MaMachineStatusEnum.IN_USE.getStatus()); + type.setOutNum(BigDecimal.valueOf(GlobalConstants.INT_1)); + type.setMaId(record.getMaId()); } + type.setTypeId(record.getTypeId()); + type.setStyle("1"); + type.setModelTitle("领料出库"); + type.setCode(record.getCode()); + res = typeService.updateNumAddOrSubtract(type); } } return res; diff --git a/bonus-modules/bonus-material/src/main/java/com/bonus/material/ma/domain/Type.java b/bonus-modules/bonus-material/src/main/java/com/bonus/material/ma/domain/Type.java index 0332068d..c7c73c77 100644 --- a/bonus-modules/bonus-material/src/main/java/com/bonus/material/ma/domain/Type.java +++ b/bonus-modules/bonus-material/src/main/java/com/bonus/material/ma/domain/Type.java @@ -13,7 +13,6 @@ import lombok.Data; import lombok.EqualsAndHashCode; import lombok.ToString; import com.bonus.common.core.web.domain.BaseEntity; -import org.apache.poi.hpsf.Decimal; /** * 物资类型对象 ma_type @@ -33,6 +32,12 @@ public class Type extends BaseEntity { @ApiModelProperty(value = "任务ID") private Long taskId; + @ApiModelProperty(value = "设备ID") + private Long maId; + + @ApiModelProperty(value = "物资名称") + private String materialName; + /** 类型名称 */ @Excel(name = "规格型号", sort = 5) @ApiModelProperty(value = "类型名称") @@ -251,4 +256,19 @@ public class Type extends BaseEntity { @ApiModelProperty(value = "待出库数量") private BigDecimal pendingOutNum; + + @ApiModelProperty(value = "1:领料出库 2:修试入库 3:盘点入库 4:新购入库 5:直接修改库存") + private String style; + + @ApiModelProperty(value = "模块") + private String modelTitle; + + @ApiModelProperty(value = "任务单号") + private String code; + + @ApiModelProperty(value = "入库数量") + private BigDecimal inputNum; + + @ApiModelProperty(value = "出库数量") + private BigDecimal outNum; } diff --git a/bonus-modules/bonus-material/src/main/java/com/bonus/material/ma/mapper/TypeMapper.java b/bonus-modules/bonus-material/src/main/java/com/bonus/material/ma/mapper/TypeMapper.java index aee17fc8..19d5fb23 100644 --- a/bonus-modules/bonus-material/src/main/java/com/bonus/material/ma/mapper/TypeMapper.java +++ b/bonus-modules/bonus-material/src/main/java/com/bonus/material/ma/mapper/TypeMapper.java @@ -158,7 +158,7 @@ public interface TypeMapper { /** * 减少 (ma_type 设备规格表)的库存数量 */ - int updateMaTypeStockNum(@Param("record") LeaseOutDetails leaseOutDetails); + int updateMaTypeStockNum(@Param("record") Type type); Type selectByTypeId(@Param("record") LeaseOutDetails record); @@ -220,7 +220,22 @@ public interface TypeMapper { int updateStorageNum(Type type); + /** + * 获取前置库存数量 + * @param type + * @return + */ BigDecimal getStorageNumByTypeId(Type type); + /** + * 插入库存数量日志 + * @param type + */ void insertStorageNumLog(Type type); + + /** + * 添加库存数量 + * @param type + */ + int addStockNum(Type type); } diff --git a/bonus-modules/bonus-material/src/main/java/com/bonus/material/ma/mapper/WarehousingMapper.java b/bonus-modules/bonus-material/src/main/java/com/bonus/material/ma/mapper/WarehousingMapper.java index 4f7c0bc0..9b62fd92 100644 --- a/bonus-modules/bonus-material/src/main/java/com/bonus/material/ma/mapper/WarehousingMapper.java +++ b/bonus-modules/bonus-material/src/main/java/com/bonus/material/ma/mapper/WarehousingMapper.java @@ -59,13 +59,5 @@ public interface WarehousingMapper { */ int selectTaskNumByMonth(@Param("date") Date nowDate); - /** - * 更新matype表中num数量 - * @param typeId - * @param num - * @return - */ - int updateMaType(@Param("typeId") String typeId, @Param("num") Integer num); - List getDetails(PutInStorageBean bean); } diff --git a/bonus-modules/bonus-material/src/main/java/com/bonus/material/ma/service/ITypeService.java b/bonus-modules/bonus-material/src/main/java/com/bonus/material/ma/service/ITypeService.java index 232858a5..88dc4cd4 100644 --- a/bonus-modules/bonus-material/src/main/java/com/bonus/material/ma/service/ITypeService.java +++ b/bonus-modules/bonus-material/src/main/java/com/bonus/material/ma/service/ITypeService.java @@ -146,4 +146,11 @@ public interface ITypeService { List getUserList(MaTypeVo type); int updateStorageNum(Type type); + + /** + * 全局更新数据库中物资库存数量 + * @param type + * @return + */ + int updateNumAddOrSubtract(Type type); } diff --git a/bonus-modules/bonus-material/src/main/java/com/bonus/material/ma/service/impl/TypeServiceImpl.java b/bonus-modules/bonus-material/src/main/java/com/bonus/material/ma/service/impl/TypeServiceImpl.java index 3508723b..dde5b4e7 100644 --- a/bonus-modules/bonus-material/src/main/java/com/bonus/material/ma/service/impl/TypeServiceImpl.java +++ b/bonus-modules/bonus-material/src/main/java/com/bonus/material/ma/service/impl/TypeServiceImpl.java @@ -3,6 +3,7 @@ package com.bonus.material.ma.service.impl; import java.math.BigDecimal; import java.time.LocalDateTime; import java.util.*; +import java.util.concurrent.locks.ReentrantLock; import java.util.stream.Collectors; import cn.hutool.core.util.ArrayUtil; @@ -13,7 +14,6 @@ import com.bonus.common.core.utils.DateUtils; import com.bonus.common.core.utils.StringUtils; import com.bonus.common.core.web.domain.AjaxResult; import com.bonus.common.security.utils.SecurityUtils; -import com.bonus.material.lease.domain.LeaseApplyDetails; import com.bonus.material.lease.mapper.LeaseTaskMapper; import com.bonus.material.ma.domain.MaTypeHistory; import com.bonus.material.ma.domain.TypeKeeper; @@ -66,6 +66,8 @@ public class TypeServiceImpl implements ITypeService { @Resource private SltAgreementInfoMapper sltAgreementInfoMapper; + private final ReentrantLock lock = new ReentrantLock(true); + /** * 查询物资类型 -- 根据id @@ -224,6 +226,62 @@ public class TypeServiceImpl implements ITypeService { return typeMapper.updateStorageNum(type); } + /** + * 全局更新数据库中物资库存数量 + * @param type + * @return + */ + @Override + public int updateNumAddOrSubtract(Type type) { + // 获取锁(公平锁会按线程等待请求顺序分配锁) + lock.lock(); + try { + int result = 0; + // 根据typeId查询物资名称和规格型号 + Type info = typeMapper.selectTypeByTypeId(type.getTypeId()); + // 查询库存 + BigDecimal storageNum = typeMapper.getStorageNumByTypeId(type); + type.setCreateBy(SecurityUtils.getLoginUser().getSysUser().getNickName()); + type.setPreStoreNum(storageNum); + type.setMaterialName(info.getMaterialName()); + type.setTypeName(info.getTypeName()); + // 插入修改记录 + if ("1".equals(type.getStyle())) { + // 检查库存是否充足 + if (type.getOutNum() != null && storageNum.compareTo(type.getOutNum()) < 0) { + throw new RuntimeException("库存不足,当前库存: " + storageNum + ", 需要出库: " + type.getOutNum()); + } + result = typeMapper.updateMaTypeStockNum(type); + if (result > 0) { + type.setStorageNum(type.getPreStoreNum().subtract(type.getOutNum())); + typeMapper.insertStorageNumLog(type); + } else { + throw new RuntimeException("更新库存失败"); + } + } else if (type.getStyle() == null) { + result = typeMapper.updateStorageNum(type); + if (result > 0) { + type.setModelTitle("直接修改库存"); + typeMapper.insertStorageNumLog(type); + } else { + throw new RuntimeException("更新库存失败"); + } + } else { + result = typeMapper.addStockNum(type); + if (result > 0) { + type.setStorageNum(type.getPreStoreNum().add(type.getInputNum())); + typeMapper.insertStorageNumLog(type); + } else { + throw new RuntimeException("更新库存失败"); + } + } + return result; + } finally { + // 释放锁 + lock.unlock(); + } + } + @Override public List selectMaTypeListByHouseId(Long houseId) { diff --git a/bonus-modules/bonus-material/src/main/java/com/bonus/material/ma/service/impl/WarehousingServiceImpl.java b/bonus-modules/bonus-material/src/main/java/com/bonus/material/ma/service/impl/WarehousingServiceImpl.java index 62ff146b..f768b78e 100644 --- a/bonus-modules/bonus-material/src/main/java/com/bonus/material/ma/service/impl/WarehousingServiceImpl.java +++ b/bonus-modules/bonus-material/src/main/java/com/bonus/material/ma/service/impl/WarehousingServiceImpl.java @@ -6,14 +6,11 @@ import com.bonus.common.core.utils.DateUtils; import com.bonus.common.core.utils.StringUtils; import com.bonus.common.core.web.domain.AjaxResult; import com.bonus.common.security.utils.SecurityUtils; -import com.bonus.material.ma.domain.MachIneDto; -import com.bonus.material.ma.domain.PutInStorageBean; -import com.bonus.material.ma.domain.SavePutInfoDto; -import com.bonus.material.ma.domain.SupplierInfo; +import com.bonus.material.ma.domain.*; import com.bonus.material.ma.domain.vo.ExceptionEnum; -import com.bonus.material.ma.domain.vo.FieldGenerator; import com.bonus.material.ma.domain.vo.GlobalContants; import com.bonus.material.ma.mapper.WarehousingMapper; +import com.bonus.material.ma.service.ITypeService; import com.bonus.material.ma.service.WarehousingService; import lombok.extern.slf4j.Slf4j; import org.apache.commons.collections4.CollectionUtils; @@ -22,8 +19,9 @@ import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; import org.springframework.transaction.interceptor.TransactionAspectSupport; +import javax.annotation.Resource; +import java.math.BigDecimal; import java.text.SimpleDateFormat; -import java.util.ArrayList; import java.util.Date; import java.util.List; import java.util.stream.Collectors; @@ -40,6 +38,9 @@ public class WarehousingServiceImpl implements WarehousingService { @Autowired private WarehousingMapper warehousingMapper; + @Resource + private ITypeService typeService; + // @Autowired // private PurchaseInputMapper purchaseInputMapper; @@ -124,12 +125,6 @@ public class WarehousingServiceImpl implements WarehousingService { log.error("insertMaMachineInfo方法插入异常"); throw new RuntimeException("insertMaMachineInfo方法插入异常"); } - //去修改ma_type里面的库存num,根据前端传的数量追加 - res = updateMaTypeInfo(dto.getTypeId(), dto.getNum()); - if (res == 0) { - log.error("updateMaTypeInfo方法修改异常"); - throw new RuntimeException("updateMaTypeInfo方法修改异常"); - } } else { //2.插入ma_type_put_in_storage_info表和ma_type_put_in_storage_details表 res = insertPutInfo(dto, code); @@ -188,6 +183,15 @@ public class WarehousingServiceImpl implements WarehousingService { machIneDto.setCheckMan(dto.getCheckMan()); machIneDto.setInfoId(dto.getMachIneDtoList().get(0).getInfoId()); res += insertMachineInfo(machIneDto); + //根据类型追加ma_type表里面的num + Type type = new Type(); + type.setModelTitle("盘点入库"); + type.setCode(code); + type.setStyle("3"); + type.setTypeId(Long.parseLong(machIneDto.getTypeId())); + type.setInputNum(BigDecimal.ONE); + type.setMaId(machIneDto.getMaId()); + res += typeService.updateNumAddOrSubtract(type); } return res; } @@ -223,16 +227,6 @@ public class WarehousingServiceImpl implements WarehousingService { return warehousingMapper.saveDetails(machIneDto); } - /** - * 方法抽取,追加ma_type表里面的num - * @param typeId - * @param num - * @return - */ - private int updateMaTypeInfo(String typeId, Integer num) { - return warehousingMapper.updateMaType(typeId, num); - } - /** * 插入表方法 * @param dto @@ -264,7 +258,14 @@ public class WarehousingServiceImpl implements WarehousingService { machIneDto.setInfoId(dto.getMachIneDtoList().get(0).getInfoId()); res += insertTypePutInStorageInfo(machIneDto); //根据类型追加ma_type表里面的num - res += updateMaTypeInfo(machIneDto.getTypeId(), machIneDto.getPutInStoreNum()); + Type type = new Type(); + type.setModelTitle("盘点入库"); + type.setCode(code); + type.setStyle("3"); + type.setTypeId(Long.parseLong(machIneDto.getTypeId())); + type.setInputNum(BigDecimal.valueOf(machIneDto.getPutInStoreNum())); + res += typeService.updateNumAddOrSubtract(type); + //res += updateMaTypeInfo(machIneDto.getTypeId(), machIneDto.getPutInStoreNum()); } return res; } diff --git a/bonus-modules/bonus-material/src/main/java/com/bonus/material/purchase/service/impl/PurchaseStorageServiceImpl.java b/bonus-modules/bonus-material/src/main/java/com/bonus/material/purchase/service/impl/PurchaseStorageServiceImpl.java index 6772a586..afb08ea3 100644 --- a/bonus-modules/bonus-material/src/main/java/com/bonus/material/purchase/service/impl/PurchaseStorageServiceImpl.java +++ b/bonus-modules/bonus-material/src/main/java/com/bonus/material/purchase/service/impl/PurchaseStorageServiceImpl.java @@ -1,6 +1,5 @@ package com.bonus.material.purchase.service.impl; import com.alibaba.nacos.common.utils.CollectionUtils; -import com.bonus.common.biz.constant.MaterialConstants; import com.bonus.common.biz.domain.lease.LeaseOutDetails; import com.bonus.common.biz.enums.HttpCodeEnum; import com.bonus.common.biz.enums.MaTypeManageTypeEnum; @@ -9,7 +8,7 @@ import com.bonus.common.core.utils.StringUtils; import com.bonus.common.core.web.domain.AjaxResult; import com.bonus.material.lease.mapper.LeaseOutDetailsMapper; import com.bonus.material.ma.domain.Type; -import com.bonus.material.ma.mapper.MachineMapper; +import com.bonus.material.ma.service.ITypeService; import com.bonus.material.purchase.config.RemoteConfig; import com.bonus.material.purchase.domain.PurchaseCheckDetails; import com.bonus.common.biz.domain.purchase.PurchaseDto; @@ -17,8 +16,8 @@ import com.bonus.material.purchase.mapper.PurchaseBindMapper; import com.bonus.material.purchase.mapper.PurchaseStorageMapper; import com.bonus.material.purchase.service.IPurchaseStorageService; import com.bonus.material.purchase.domain.vo.PurchaseVo; +import com.bonus.material.task.domain.TmTask; import com.bonus.material.task.mapper.TmTaskMapper; -import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; import javax.annotation.Resource; @@ -49,6 +48,9 @@ public class PurchaseStorageServiceImpl implements IPurchaseStorageService { @Resource private RemoteConfig remoteConfig; + @Resource + private ITypeService typeService; + /** * 查询所有 * @param dto @@ -228,10 +230,13 @@ public class PurchaseStorageServiceImpl implements IPurchaseStorageService { } } else { //编码入库 + // 根据taskId查询任务编号 + TmTask tmTask = tmTaskMapper.selectTmTaskByTaskId(Long.parseLong(purchaseDto.getTaskId())); List purchaseVoList = purchaseBindMapper.selectPurchaseCheckInfoById(purchaseDto); if (CollectionUtils.isEmpty(purchaseDto.getInPutList())) { purchaseDto.setInPutList(new ArrayList<>()); } + Type type = new Type(); result += purchaseStorageMapper.updateNum(Long.valueOf(purchaseDto.getPurchaseId()), BigDecimal.valueOf(purchaseDto.getInPutList().size())); for (PurchaseDto dto : purchaseDto.getInPutList()) { if (CollectionUtils.isNotEmpty(purchaseVoList)) { @@ -241,10 +246,16 @@ public class PurchaseStorageServiceImpl implements IPurchaseStorageService { dto.setProductDate(null == purchaseVo.getProductDate() ? null : purchaseVo.getProductDate()); } } + type.setCode(tmTask.getCode()); } dto.setTypeId(purchaseDto.getTypeId()); if (1 > purchaseStorageMapper.updateMachineByCode(dto)) {throw new RuntimeException("入库失败,更新物资入库状态0条");} - if (1 > purchaseStorageMapper.updateStorageNum(BigDecimal.ONE, dto.getTypeId())) {throw new RuntimeException("入库失败,库存增加0");} + //if (1 > purchaseStorageMapper.updateStorageNum(BigDecimal.ONE, dto.getTypeId())) {throw new RuntimeException("入库失败,库存增加0");} + type.setModelTitle("新购入库"); + type.setTypeId(Long.valueOf(purchaseDto.getTypeId())); + type.setInputNum(BigDecimal.ONE); + type.setStyle("4"); + if (1 > typeService.updateNumAddOrSubtract(type)) {throw new RuntimeException("入库失败,库存增加0");} List bindMaList = purchaseBindMapper.getMachineById(purchaseDto); if (CollectionUtils.isNotEmpty(bindMaList)) { // 还有已绑定的设备, 那就不动状态了,这块由设备绑定阶段来决定是否修改成待入库状态 by阮 2025-01-10号修改逻辑 @@ -296,8 +307,15 @@ public class PurchaseStorageServiceImpl implements IPurchaseStorageService { * @return */ private int updatePurchaseInfoAndDetails(PurchaseVo detail, int purchaseId) { - int result = purchaseStorageMapper.updateNum(detail.getPurchaseId(), detail.getCheckNum()); - result += purchaseStorageMapper.updateStorageNum(detail.getCheckNum(), detail.getTypeId()); + Type type = new Type(); + type.setModelTitle("新购入库"); + type.setTypeId(Long.valueOf(detail.getTypeId())); + type.setStyle("4"); + type.setCode(detail.getPurchaseCode()); + type.setInputNum(detail.getCheckNum()); + int result = typeService.updateNumAddOrSubtract(type); + result += purchaseStorageMapper.updateNum(detail.getPurchaseId(), detail.getCheckNum()); + //result += purchaseStorageMapper.updateStorageNum(detail.getCheckNum(), detail.getTypeId()); return result + purchaseStorageMapper.updateStatusById(PurchaseTaskStatusEnum.IN_STORE.getStatus(), purchaseId); } diff --git a/bonus-modules/bonus-material/src/main/java/com/bonus/material/repair/service/impl/RepairInputDetailsServiceImpl.java b/bonus-modules/bonus-material/src/main/java/com/bonus/material/repair/service/impl/RepairInputDetailsServiceImpl.java index 49154413..6582d0cc 100644 --- a/bonus-modules/bonus-material/src/main/java/com/bonus/material/repair/service/impl/RepairInputDetailsServiceImpl.java +++ b/bonus-modules/bonus-material/src/main/java/com/bonus/material/repair/service/impl/RepairInputDetailsServiceImpl.java @@ -27,13 +27,12 @@ import com.bonus.material.lease.mapper.LeaseOutDetailsMapper; import com.bonus.material.ma.domain.Machine; import com.bonus.material.ma.domain.Type; import com.bonus.material.ma.mapper.MachineMapper; +import com.bonus.material.ma.service.ITypeService; import com.bonus.material.repair.domain.RepairInputInfo; -import com.bonus.material.repair.domain.vo.ScrapApplyDetailsVO; import com.bonus.material.task.domain.TmTask; import com.bonus.material.task.domain.TmTaskAgreement; import com.bonus.material.task.mapper.TmTaskAgreementMapper; import com.bonus.material.task.mapper.TmTaskMapper; -import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; import com.bonus.material.repair.mapper.RepairInputDetailsMapper; import com.bonus.common.biz.domain.repair.RepairInputDetails; @@ -67,6 +66,9 @@ public class RepairInputDetailsServiceImpl implements IRepairInputDetailsService @Resource private BackApplyInfoMapper backApplyInfoMapper; + + @Resource + private ITypeService typeService; /** * 查询修试后入库 * @@ -655,6 +657,14 @@ public class RepairInputDetailsServiceImpl implements IRepairInputDetailsService result += repairInputDetailsMapper.updateRepairInputDetails(inputDetails); inputDetails.setStatus(MaMachineStatusEnum.IN_STORE.getStatus().toString()); updateRepairInputInfo(inputDetails); + Type type = new Type(); + type.setModelTitle("修试入库"); + type.setCode(repairInputDetails.getInputCode()); + type.setTypeId(repairInputDetails.getTypeId()); + type.setStyle("2"); + type.setInputNum(BigDecimal.valueOf(1)); + type.setMaId(inputDetails.getMaId()); + typeService.updateNumAddOrSubtract(type); } if (result > 0) { updateTaskStatus(repairInputDetails); @@ -675,10 +685,13 @@ public class RepairInputDetailsServiceImpl implements IRepairInputDetailsService result += repairInputDetailsMapper.updateRepairInputDetails(repairInputDetails); if (result > 0) { updateTaskStatus(repairInputDetails); - RepairInputInfo repairInputInfo = new RepairInputInfo(); - repairInputInfo.setTypeId(repairInputDetails.getTypeId()); - repairInputInfo.setInputNum(repairInputDetails.getInputNum()); - repairInputDetailsMapper.updateNum(repairInputInfo); + Type type = new Type(); + type.setModelTitle("修试入库"); + type.setCode(repairInputDetails.getInputCode()); + type.setTypeId(repairInputDetails.getTypeId()); + type.setStyle("2"); + type.setInputNum(repairInputDetails.getInputNum()); + typeService.updateNumAddOrSubtract(type); } return result; } @@ -892,9 +905,21 @@ public class RepairInputDetailsServiceImpl implements IRepairInputDetailsService return result; } + /** + * 修改库存数量 + * @param inputApplyDetails + * @return + */ private int updateStorageNum(RepairInputDetails inputApplyDetails) { int result = 0; - result = repairInputDetailsMapper.updateStorageNum(inputApplyDetails); + Type type = new Type(); + type.setModelTitle("修试入库"); + type.setCode(inputApplyDetails.getInputCode()); + type.setTypeId(inputApplyDetails.getTypeId()); + type.setStyle("2"); + type.setInputNum(BigDecimal.valueOf(1)); + type.setMaId(inputApplyDetails.getMaId()); + result = typeService.updateNumAddOrSubtract(type); result = machineMapper.updateStatus(inputApplyDetails.getMaId(), 1); return result; } diff --git a/bonus-modules/bonus-material/src/main/resources/mapper/material/basic/BmQrBoxMapper.xml b/bonus-modules/bonus-material/src/main/resources/mapper/material/basic/BmQrBoxMapper.xml index 9fa8eae4..8949ea46 100644 --- a/bonus-modules/bonus-material/src/main/resources/mapper/material/basic/BmQrBoxMapper.xml +++ b/bonus-modules/bonus-material/src/main/resources/mapper/material/basic/BmQrBoxMapper.xml @@ -335,7 +335,8 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" mm.ma_status AS maStatus, mm.type_id AS maTypeId, mm.buy_task AS taskId, - qb.create_time AS createTime + qb.create_time AS createTime, + tt.code AS purchaseCode FROM bm_qrcode_box_bind qb LEFT JOIN bm_qrcode_box bb on qb.box_id = bb.box_id @@ -344,6 +345,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" AND mt.del_flag = '0' LEFT JOIN ma_type mt1 ON mt.parent_id = mt1.type_id AND mt1.del_flag = '0' + LEFT JOIN tm_task tt ON mm.buy_task = tt.task_id WHERE bb.box_code = #{boxCode} diff --git a/bonus-modules/bonus-material/src/main/resources/mapper/material/basic/ComplexQueryMapper.xml b/bonus-modules/bonus-material/src/main/resources/mapper/material/basic/ComplexQueryMapper.xml index e3c59250..262ddce7 100644 --- a/bonus-modules/bonus-material/src/main/resources/mapper/material/basic/ComplexQueryMapper.xml +++ b/bonus-modules/bonus-material/src/main/resources/mapper/material/basic/ComplexQueryMapper.xml @@ -119,9 +119,9 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" LEFT JOIN back_apply_info baif ON baif.id = sai.back_id LEFT JOIN ma_type mt3 ON mt2.parent_id = mt3.type_id LEFT JOIN ma_type mt4 ON mt3.parent_id = mt4.type_id - LEFT JOIN ma_type_manage mtm ON mt3.parent_id = mtm.type_id + LEFT JOIN ma_type_manage mtm ON mt4.type_id = mtm.type_id WHERE - 1 = 1 + sai.is_slt = '0' AND sai.ma_id IS NOT NULL and mtm.user_id = #{userId} diff --git a/bonus-modules/bonus-material/src/main/resources/mapper/material/common/SelectMapper.xml b/bonus-modules/bonus-material/src/main/resources/mapper/material/common/SelectMapper.xml index cbacaccd..19bf0cf6 100644 --- a/bonus-modules/bonus-material/src/main/resources/mapper/material/common/SelectMapper.xml +++ b/bonus-modules/bonus-material/src/main/resources/mapper/material/common/SelectMapper.xml @@ -508,7 +508,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" LEFT JOIN bm_unit bu ON bai.unit_id = bu.unit_id WHERE bai.status = '1' - AND bu.type_id = 36 + AND bu.type_id in (32, 36) AND bai.project_id = #{proId} @@ -605,7 +605,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" FROM `data_center`.dx_fb_son WHERE - project_status = '在建' + project_status in ('在建', '开工准备') AND project_dept_id = #{departId} diff --git a/bonus-modules/bonus-material/src/main/resources/mapper/material/ma/TypeMapper.xml b/bonus-modules/bonus-material/src/main/resources/mapper/material/ma/TypeMapper.xml index 702f880c..e2b501b8 100644 --- a/bonus-modules/bonus-material/src/main/resources/mapper/material/ma/TypeMapper.xml +++ b/bonus-modules/bonus-material/src/main/resources/mapper/material/ma/TypeMapper.xml @@ -178,7 +178,8 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" hi.house_name, t.sampling_ratio, t.is_check, - t.jiju_type + t.jiju_type, + mt2.type_name as materialName FROM ma_type AS t left join ma_type mt2 on t.parent_id = mt2.type_id left join ma_type mt3 on mt2.parent_id = mt3.type_id @@ -951,8 +952,41 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" VALUES (#{typeId}, #{beforePrice} ,#{afterPrice}, #{createTime}, #{createBy}) - INSERT INTO update_storage_num_log(type_id, pre_store_num, after_store_num, create_time, creater) - VALUES (#{typeId}, #{preStoreNum}, #{storageNum}, now(), #{createBy}) + insert into update_storage_num_log + + model_title, + code, + material_name, + type_name, + type_id, + pre_store_num, + input_num, + out_num, + after_store_num, + ma_id, + create_time, + creater, + style, + + + #{modelTitle}, + #{code}, + #{materialName}, + #{typeName}, + #{typeId}, + #{preStoreNum}, + #{inputNum}, + #{outNum}, + #{storageNum}, + #{maId}, + NOW(), + #{createBy}, + #{style}, + + + + + UPDATE ma_type SET storage_num = ifnull(#{inputNum},0) + ifnull(storage_num, 0) WHERE type_id = #{typeId} SELECT case when psi.put_in_type = 0 then '库存盘点入库' diff --git a/bonus-modules/bonus-material/src/main/resources/mapper/material/purchase/PurchaseBindMapper.xml b/bonus-modules/bonus-material/src/main/resources/mapper/material/purchase/PurchaseBindMapper.xml index 25658a82..f0584090 100644 --- a/bonus-modules/bonus-material/src/main/resources/mapper/material/purchase/PurchaseBindMapper.xml +++ b/bonus-modules/bonus-material/src/main/resources/mapper/material/purchase/PurchaseBindMapper.xml @@ -232,7 +232,8 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" pcd.`status` AS status, pm.ma_code AS maCode, pm.out_fac_code AS outFacCode, - pm.qr_code AS qrCode + pm.qr_code AS qrCode, + tt.code AS purchaseCode FROM purchase_check_details pcd LEFT JOIN tm_task tt ON pcd.task_id = tt.task_id