From 40c7f30b029345b8c4ea496977ed12e302db8fc9 Mon Sep 17 00:00:00 2001 From: syruan <321359594@qq.com> Date: Thu, 13 Feb 2025 17:59:05 +0800 Subject: [PATCH] =?UTF-8?q?=E7=89=A9=E8=B5=84=E7=B1=BB=E5=9E=8B=E4=BB=B7?= =?UTF-8?q?=E6=A0=BC=E5=8F=98=E6=9B=B4=E8=AE=B0=E5=BD=95=E6=8E=A5=E5=8F=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../ma/controller/TypeController.java | 11 +++ .../material/ma/domain/MaTypeHistory.java | 33 ++++++++ .../com/bonus/material/ma/domain/Type.java | 3 + .../bonus/material/ma/mapper/TypeMapper.java | 9 +++ .../material/ma/service/ITypeService.java | 8 ++ .../ma/service/impl/TypeServiceImpl.java | 75 ++++++++++++++++++- .../mapper/material/ma/TypeMapper.xml | 25 +++++++ 7 files changed, 160 insertions(+), 4 deletions(-) create mode 100644 bonus-modules/bonus-material/src/main/java/com/bonus/material/ma/domain/MaTypeHistory.java diff --git a/bonus-modules/bonus-material/src/main/java/com/bonus/material/ma/controller/TypeController.java b/bonus-modules/bonus-material/src/main/java/com/bonus/material/ma/controller/TypeController.java index ab500102..5f80fcaa 100644 --- a/bonus-modules/bonus-material/src/main/java/com/bonus/material/ma/controller/TypeController.java +++ b/bonus-modules/bonus-material/src/main/java/com/bonus/material/ma/controller/TypeController.java @@ -13,6 +13,7 @@ import com.bonus.common.biz.config.ListPagingUtil; import com.bonus.common.core.utils.ServletUtils; import com.bonus.common.log.enums.OperaType; import com.bonus.material.common.annotation.PreventRepeatSubmit; +import com.bonus.material.ma.domain.MaTypeHistory; import com.bonus.material.ma.domain.vo.MaTypeVo; import com.bonus.material.ma.domain.vo.MaTypeSelectVo; import io.swagger.annotations.Api; @@ -53,6 +54,14 @@ public class TypeController extends BaseController { return getDataTable(list); } + @ApiOperation(value = "查询物资历史价格列表") + @GetMapping("/getMaTypeHistoryList") + public TableDataInfo getMaTypeHistoryList(MaTypeHistory maTypeHistory) { + startPage(); + List maTypeHistories = typeService.getMaTypeHistoryListBy(maTypeHistory); + return getDataTable(maTypeHistories); + } + /** * 导出物资类型管理列表 */ @@ -222,6 +231,8 @@ public class TypeController extends BaseController { return toAjax(typeService.updateType(type)); } + + /** * 删除物资类型管理 */ diff --git a/bonus-modules/bonus-material/src/main/java/com/bonus/material/ma/domain/MaTypeHistory.java b/bonus-modules/bonus-material/src/main/java/com/bonus/material/ma/domain/MaTypeHistory.java new file mode 100644 index 00000000..3de32cab --- /dev/null +++ b/bonus-modules/bonus-material/src/main/java/com/bonus/material/ma/domain/MaTypeHistory.java @@ -0,0 +1,33 @@ +package com.bonus.material.ma.domain; + +import lombok.Data; +import lombok.experimental.Accessors; + +import java.math.BigDecimal; +import java.time.LocalDateTime; + +/** + * @author : 阮世耀 + * @version : 1.0 + * @PackagePath: com.bonus.material.ma.domain + * @CreateTime: 2025-02-13 17:33 + * @Description: 物资类型记录表 + */ +@Data +@Accessors(chain = true) +public class MaTypeHistory { + + private Integer id; + + private Long typeId; + + private String typeName; + + private BigDecimal beforePrice; + + private BigDecimal afterPrice; + + private LocalDateTime createTime; + + private String createBy; +} 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 90262547..c77a98e2 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 @@ -127,6 +127,9 @@ public class Type extends BaseEntity { @ApiModelProperty(value = "内部租赁单价") private BigDecimal leasePrice; + @ApiModelProperty(value = "是否更新租赁价格") + private Boolean isUpdateLeasePrice; + /** 租赁费用生效时间 */ @ApiModelProperty(value = "租赁费用生效时间") @JsonFormat(pattern = "yyyy-MM-dd") 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 d1c698f8..80539ba6 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 @@ -1,8 +1,10 @@ package com.bonus.material.ma.mapper; +import java.math.BigDecimal; import java.util.List; import com.bonus.common.biz.domain.lease.LeaseOutDetails; +import com.bonus.material.ma.domain.MaTypeHistory; import com.bonus.material.ma.domain.Type; import com.bonus.material.ma.domain.vo.MaTypeConfigVo; import com.bonus.material.ma.domain.vo.MaTypeVo; @@ -17,6 +19,9 @@ import org.apache.ibatis.annotations.Param; @Mapper public interface TypeMapper { + // 查询物资类型的内部租赁价 + BigDecimal selectLeasePriceByTypeId(Long typeId); + List selectMaTypeList(String typeName); /** @@ -131,6 +136,10 @@ public interface TypeMapper { Type queryByNameAndParentId(@Param("typeName") String typeName, @Param("parentId") Long parentId); + int insertMaTypeLeasePriceHistory(MaTypeHistory maTypeHistory); + + List getMaTypeHistoryListBy(MaTypeHistory maTypeHistory); + /** * 根据ID查询 * @param typeId 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 0a99ed16..34dbaecf 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 @@ -4,6 +4,7 @@ import java.util.List; import com.bonus.common.biz.domain.TreeSelect; import com.bonus.common.core.web.domain.AjaxResult; +import com.bonus.material.ma.domain.MaTypeHistory; import com.bonus.material.ma.domain.Type; import com.bonus.material.ma.domain.vo.MaTypeConfigVo; import com.bonus.material.ma.domain.vo.MaTypeVo; @@ -73,6 +74,13 @@ public interface ITypeService { */ int updateType(Type type); + /** + * 获取物资类型历史价格 + * @param maTypeHistory 物资类型历史价格 + * @return 物资类型历史价格集合 + */ + List getMaTypeHistoryListBy(MaTypeHistory maTypeHistory); + /** * 批量删除物资类型 * 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 40e377e5..3a79db1c 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 @@ -1,5 +1,7 @@ package com.bonus.material.ma.service.impl; +import java.math.BigDecimal; +import java.time.LocalDateTime; import java.util.*; import java.util.stream.Collectors; @@ -11,6 +13,7 @@ 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.MaTypeHistory; import com.bonus.material.ma.domain.TypeKeeper; import com.bonus.material.ma.domain.TypeRepair; import com.bonus.material.ma.service.ITypeKeeperService; @@ -18,6 +21,8 @@ import com.bonus.material.ma.service.ITypeRepairService; import com.bonus.material.ma.domain.vo.MaTypeConfigVo; import com.bonus.material.ma.domain.vo.MaTypeVo; import com.bonus.material.ma.domain.vo.MaTypeSelectVo; +import com.bonus.material.settlement.domain.SltAgreementInfo; +import com.bonus.material.settlement.mapper.SltAgreementInfoMapper; import com.bonus.material.warehouse.domain.WhHouseSet; import com.bonus.material.warehouse.service.IWhHouseSetService; import org.apache.commons.collections4.CollectionUtils; @@ -53,6 +58,9 @@ public class TypeServiceImpl implements ITypeService { @Resource private IWhHouseSetService houseSetService; + @Resource + private SltAgreementInfoMapper sltAgreementInfoMapper; + /** * 查询物资类型 -- 根据id @@ -358,10 +366,12 @@ public class TypeServiceImpl implements ITypeService { throw new RuntimeException("同级下类型名称存在重复!"); } + BigDecimal oriLeasePrice = typeMapper.selectLeasePriceByTypeId(type.getTypeId()); + //维护库管信息 List keeperArr = type.getKeeperArr(); - if (keeperArr != null && keeperArr.size()>0){ + if (keeperArr != null && !keeperArr.isEmpty()) { typeMapper.deleteTypeKeeperByTypeId(type); for(int i=0 ; i repairerArr = type.getRepairerArr(); - if (repairerArr != null && repairerArr.size()>0){ + if (repairerArr != null && !repairerArr.isEmpty()){ typeMapper.deleteTypeRepairerByTypeId(type); for(int i=0 ; i 0 && null != type.getIsUpdateLeasePrice() && type.getIsUpdateLeasePrice()) { + // 插入lease_out_details表,记录租赁价格修改记录 + MaTypeHistory maTypeHistory = new MaTypeHistory(); + maTypeHistory.setTypeId(type.getTypeId()); + maTypeHistory.setCreateTime(LocalDateTime.now()); + maTypeHistory.setBeforePrice(oriLeasePrice); + maTypeHistory.setAfterPrice(type.getLeasePrice()); + maTypeHistory.setCreateBy(SecurityUtils.getUsername()); + typeMapper.insertMaTypeLeasePriceHistory(maTypeHistory); + + SltAgreementInfo sltAgreementInfo = new SltAgreementInfo(); + sltAgreementInfo.setTypeId(type.getTypeId()); + sltAgreementInfo.setStatus("0"); + // 获取状态为在用的,受影响物资类型的结算数据 + List agreementInfos = sltAgreementInfoMapper.selectSltAgreementInfoList(sltAgreementInfo); + + // 获取今日最后一秒钟 + Calendar calendar = Calendar.getInstance(); + // 设置时间为今天的23时59分59秒 + calendar.set(Calendar.HOUR_OF_DAY, 23); + calendar.set(Calendar.MINUTE, 59); + calendar.set(Calendar.SECOND, 59); + + // 获取明天第一分钟 + // 获取当前时间 + Calendar startOfTomorrow = Calendar.getInstance(); + // 增加一天 + startOfTomorrow.add(Calendar.DAY_OF_YEAR, 1); + // 设置时间为明天的00:00:01 + startOfTomorrow.set(Calendar.HOUR_OF_DAY, 0); + startOfTomorrow.set(Calendar.MINUTE, 0); + startOfTomorrow.set(Calendar.SECOND, 1); + + for (SltAgreementInfo info : agreementInfos) { + // 循环修改原数据 + SltAgreementInfo updateInfo = new SltAgreementInfo(); + updateInfo.setEndTime(calendar.getTime()); + updateInfo.setStatus("1"); + updateInfo.setId(info.getId()); + sltAgreementInfoMapper.updateSltAgreementInfo(updateInfo); + + // 插入一条新的数据 + info.setId(null); + info.setStartTime(startOfTomorrow.getTime()); + info.setEndTime(null); + info.setLeasePrice(type.getLeasePrice()); + info.setCreateTime(DateUtils.getNowDate()); + info.setStatus("0"); + sltAgreementInfoMapper.insertSltAgreementInfo(info); + } + } + return updateTypeResult; + } + + @Override + public List getMaTypeHistoryListBy(MaTypeHistory maTypeHistory) { + return typeMapper.getMaTypeHistoryListBy(maTypeHistory); } /** 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 b213f2fd..f204c80b 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 @@ -822,5 +822,30 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" type_id = #{record.typeId} + + INSERT INTO ma_type_history(type_id, before_price, after_price, create_time, create_by) + VALUES (#{typeId}, #{beforePrice} ,#{afterPrice}, #{createTime}, #{createBy}) + + + +