物资类型价格变更记录接口

This commit is contained in:
syruan 2025-02-13 17:59:05 +08:00
parent 0e10b67591
commit 40c7f30b02
7 changed files with 160 additions and 4 deletions

View File

@ -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<MaTypeHistory> maTypeHistories = typeService.getMaTypeHistoryListBy(maTypeHistory);
return getDataTable(maTypeHistories);
}
/**
* 导出物资类型管理列表
*/
@ -222,6 +231,8 @@ public class TypeController extends BaseController {
return toAjax(typeService.updateType(type));
}
/**
* 删除物资类型管理
*/

View File

@ -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;
}

View File

@ -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")

View File

@ -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<Type> 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<MaTypeHistory> getMaTypeHistoryListBy(MaTypeHistory maTypeHistory);
/**
* 根据ID查询
* @param typeId

View File

@ -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<MaTypeHistory> getMaTypeHistoryListBy(MaTypeHistory maTypeHistory);
/**
* 批量删除物资类型
*

View File

@ -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<String> keeperArr = type.getKeeperArr();
if (keeperArr != null && keeperArr.size()>0){
if (keeperArr != null && !keeperArr.isEmpty()) {
typeMapper.deleteTypeKeeperByTypeId(type);
for(int i=0 ; i<keeperArr.size();i++){
Type keeper = new Type();
@ -369,11 +379,10 @@ public class TypeServiceImpl implements ITypeService {
keeper.setTypeId(type.getTypeId());
typeMapper.insertTypeKeeper(keeper);
}
}
//维护维修员信息
List<String> repairerArr = type.getRepairerArr();
if (repairerArr != null && repairerArr.size()>0){
if (repairerArr != null && !repairerArr.isEmpty()){
typeMapper.deleteTypeRepairerByTypeId(type);
for(int i=0 ; i<repairerArr.size();i++){
Type repairer = new Type();
@ -385,7 +394,65 @@ public class TypeServiceImpl implements ITypeService {
}
type.setUpdateTime(DateUtils.getNowDate());
type.setUpdateBy(SecurityUtils.getUserId().toString());
return typeMapper.updateType(type);
int updateTypeResult = typeMapper.updateType(type);
// 判断是否更新租赁价格
if (updateTypeResult > 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<SltAgreementInfo> 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<MaTypeHistory> getMaTypeHistoryListBy(MaTypeHistory maTypeHistory) {
return typeMapper.getMaTypeHistoryListBy(maTypeHistory);
}
/**

View File

@ -822,5 +822,30 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
type_id = #{record.typeId}
</insert>
<insert id="insertMaTypeLeasePriceHistory">
INSERT INTO ma_type_history(type_id, before_price, after_price, create_time, create_by)
VALUES (#{typeId}, #{beforePrice} ,#{afterPrice}, #{createTime}, #{createBy})
</insert>
<select id="getMaTypeHistoryListBy" resultType="com.bonus.material.ma.domain.MaTypeHistory">
select
id, type_id, before_price, after_price, create_time, create_by
from
ma_type_history
<where>
<if test="typeId != null">
and type_id = #{typeId}
</if>
<if test="createBy != null">
and create_by = #{createBy}
</if>
<if test="createTime != null and createTime != ''">
and create_time between #{startTime} and #{endTime}
</if>
</where>
</select>
<select id="selectLeasePriceByTypeId" resultType="java.math.BigDecimal">
select lease_price from ma_type where type_id = #{typeId}
</select>
</mapper>