jsk 解决定时录入结算经常重复录入的问题
This commit is contained in:
parent
9f5b4bc8ec
commit
beb111c827
|
|
@ -40,16 +40,20 @@ public interface IwsCostPushMapper {
|
|||
*/
|
||||
int insertCalcMonthRecord(IwsCostPushBean record);
|
||||
|
||||
List<IwsCostPushBean> selectCalcMonthRecord(IwsCostPushBean record);
|
||||
|
||||
/**
|
||||
* 插入项目月费用info数据 -- 批量
|
||||
*/
|
||||
int insertProjectMonthCosts(List<IwsCostPushBean> list);
|
||||
int updateProjectMonthCosts(IwsCostPushBean vo);
|
||||
List<IwsCostPushBean> selectHaveProjectMonthCosts(IwsCostPushBean vo);
|
||||
|
||||
/**
|
||||
* 插入项目月费用details数据 -- 批量
|
||||
*/
|
||||
int insertProjectMonthCostsDetails(@Param("list") List<PeriodCostResultVo> list);
|
||||
|
||||
List<PeriodCostResultVo> selectHaveProjectMonthCostsDetails(PeriodCostResultVo vo);
|
||||
/**
|
||||
* 根据协议ID查询领用物资数据
|
||||
* @param record 协议信息及条件
|
||||
|
|
|
|||
|
|
@ -122,7 +122,12 @@ public class IwsCostPushServiceImpl implements IwsCostPushService {
|
|||
//cleanSameMonthOldRecords(record);
|
||||
|
||||
// 插入新的当前月份,并生成记录id
|
||||
iwsCostPushMapper.insertCalcMonthRecord(costDto);
|
||||
List<IwsCostPushBean> monthList=iwsCostPushMapper.selectCalcMonthRecord(costDto);
|
||||
if(monthList==null||monthList.size()==0){
|
||||
iwsCostPushMapper.insertCalcMonthRecord(costDto);
|
||||
}else{
|
||||
costDto.setTaskId(monthList.get(0).getTaskId());
|
||||
}
|
||||
|
||||
// 查询协议信息列表
|
||||
List<IwsCostPushBean> agreementList = iwsCostPushMapper.findAgreement(costDto);
|
||||
|
|
@ -296,9 +301,24 @@ public class IwsCostPushServiceImpl implements IwsCostPushService {
|
|||
.setConsumeMoney(vo.getConsumeCost())
|
||||
);
|
||||
}
|
||||
|
||||
List<IwsCostPushBean> uplist=new ArrayList<>();
|
||||
List<IwsCostPushBean> addlist=new ArrayList<>();
|
||||
//将已录入的数据筛选出来
|
||||
for(IwsCostPushBean vo:resultArray){
|
||||
List<IwsCostPushBean> haveList=iwsCostPushMapper.selectHaveProjectMonthCosts(vo);
|
||||
if(haveList!=null&&haveList.size()>0){
|
||||
uplist.add(vo);
|
||||
}else{
|
||||
addlist.add(vo);
|
||||
}
|
||||
}
|
||||
// 批量插入 -- 存入数据库costs列表
|
||||
int addProjectMonthCostsMapperResult = iwsCostPushMapper.insertProjectMonthCosts(resultArray);
|
||||
int addProjectMonthCostsMapperResult = iwsCostPushMapper.insertProjectMonthCosts(addlist);
|
||||
try{
|
||||
for(IwsCostPushBean vo:uplist){
|
||||
iwsCostPushMapper.updateProjectMonthCosts(vo);
|
||||
}
|
||||
}catch (Exception e){}
|
||||
// 批量插入 -- 存入数据库租赁费用明细(project_month_info表)
|
||||
if (CollectionUtils.isNotEmpty(unsettlementEquipmentLeaseCostsDetails)) {
|
||||
// (工器具)未结算租赁费用的存入
|
||||
|
|
@ -306,7 +326,16 @@ public class IwsCostPushServiceImpl implements IwsCostPushService {
|
|||
item.setTaskId(costDto.getTaskId());
|
||||
item.setEquipmentType((byte) 1);
|
||||
});
|
||||
iwsCostPushMapper.insertProjectMonthCostsDetails(unsettlementEquipmentLeaseCostsDetails);
|
||||
List<PeriodCostResultVo> addDetailList=new ArrayList<>();
|
||||
//将已录入的数据筛选出来
|
||||
for(PeriodCostResultVo vo:unsettlementEquipmentLeaseCostsDetails){
|
||||
List<PeriodCostResultVo> haveList=iwsCostPushMapper.selectHaveProjectMonthCostsDetails(vo);
|
||||
if(haveList!=null&&haveList.size()>0){
|
||||
}else{
|
||||
addDetailList.add(vo);
|
||||
}
|
||||
}
|
||||
iwsCostPushMapper.insertProjectMonthCostsDetails(addDetailList);
|
||||
}
|
||||
if (CollectionUtils.isNotEmpty(settlementEquipmentCostsDetails)) {
|
||||
// (工器具)已结算租赁费用的存入
|
||||
|
|
@ -314,7 +343,16 @@ public class IwsCostPushServiceImpl implements IwsCostPushService {
|
|||
item.setTaskId(costDto.getTaskId());
|
||||
item.setEquipmentType((byte) 1);
|
||||
});
|
||||
iwsCostPushMapper.insertProjectMonthCostsDetails(settlementEquipmentCostsDetails);
|
||||
List<PeriodCostResultVo> addDetailList=new ArrayList<>();
|
||||
//将已录入的数据筛选出来
|
||||
for(PeriodCostResultVo vo:settlementEquipmentCostsDetails){
|
||||
List<PeriodCostResultVo> haveList=iwsCostPushMapper.selectHaveProjectMonthCostsDetails(vo);
|
||||
if(haveList!=null&&haveList.size()>0){
|
||||
}else{
|
||||
addDetailList.add(vo);
|
||||
}
|
||||
}
|
||||
iwsCostPushMapper.insertProjectMonthCostsDetails(addDetailList);
|
||||
}
|
||||
if (CollectionUtils.isNotEmpty(unsettlementSafetyEquipmentLeaseCostsDetails)) {
|
||||
// (安全工器具)未结算租赁费用的存入
|
||||
|
|
@ -322,7 +360,16 @@ public class IwsCostPushServiceImpl implements IwsCostPushService {
|
|||
item.setTaskId(costDto.getTaskId());
|
||||
item.setEquipmentType((byte) 2);
|
||||
});
|
||||
iwsCostPushMapper.insertProjectMonthCostsDetails(unsettlementSafetyEquipmentLeaseCostsDetails);
|
||||
List<PeriodCostResultVo> addDetailList=new ArrayList<>();
|
||||
//将已录入的数据筛选出来
|
||||
for(PeriodCostResultVo vo:unsettlementSafetyEquipmentLeaseCostsDetails){
|
||||
List<PeriodCostResultVo> haveList=iwsCostPushMapper.selectHaveProjectMonthCostsDetails(vo);
|
||||
if(haveList!=null&&haveList.size()>0){
|
||||
}else{
|
||||
addDetailList.add(vo);
|
||||
}
|
||||
}
|
||||
iwsCostPushMapper.insertProjectMonthCostsDetails(addDetailList);
|
||||
}
|
||||
if (CollectionUtils.isNotEmpty(settlementSafetyEquipmentCostsDetails)) {
|
||||
// (安全工器具)已结算租赁费用的存入
|
||||
|
|
@ -330,7 +377,16 @@ public class IwsCostPushServiceImpl implements IwsCostPushService {
|
|||
item.setTaskId(costDto.getTaskId());
|
||||
item.setEquipmentType((byte) 2);
|
||||
});
|
||||
iwsCostPushMapper.insertProjectMonthCostsDetails(settlementSafetyEquipmentCostsDetails);
|
||||
List<PeriodCostResultVo> addDetailList=new ArrayList<>();
|
||||
//将已录入的数据筛选出来
|
||||
for(PeriodCostResultVo vo:settlementSafetyEquipmentCostsDetails){
|
||||
List<PeriodCostResultVo> haveList=iwsCostPushMapper.selectHaveProjectMonthCostsDetails(vo);
|
||||
if(haveList!=null&&haveList.size()>0){
|
||||
}else{
|
||||
addDetailList.add(vo);
|
||||
}
|
||||
}
|
||||
iwsCostPushMapper.insertProjectMonthCostsDetails(addDetailList);
|
||||
}
|
||||
|
||||
return 0 < addProjectMonthCostsMapperResult ? AjaxResult.success("月结费用计算成功") : AjaxResult.error("月结费用计算失败");
|
||||
|
|
|
|||
|
|
@ -56,6 +56,7 @@ public class IwsCostPushTask {
|
|||
* 定时任务 -- 计算月结费用 -- 每月最后一天的23点30分执行
|
||||
*/
|
||||
@Scheduled(cron = "0 30 23 L * ?")
|
||||
// @Scheduled(fixedDelay = 1000*60*30)
|
||||
public void computeTheMonthCostTask() {
|
||||
System.out.println("-----------开始计算四类未结算费用定时器-----------");
|
||||
iwsCostPushService.computeTheMonthCost(new IwsCostPushBean());
|
||||
|
|
@ -66,6 +67,7 @@ public class IwsCostPushTask {
|
|||
/**
|
||||
* 定时任务 -- 保存未结算报表记录(工器具) -- 每月最后一天的23点00分执行
|
||||
*/
|
||||
// @Scheduled(fixedDelay = 1000*60*30)
|
||||
@Scheduled(cron = "0 00 23 L * ?", zone = "Asia/Shanghai")
|
||||
public void saveUnSltHistoryReport() {
|
||||
System.out.println("-----------开始执行保存未结算记录定时器-----------");
|
||||
|
|
@ -170,7 +172,14 @@ public class IwsCostPushTask {
|
|||
}
|
||||
|
||||
try {
|
||||
validRecords.forEach(vo -> vo.setYearMonth(DateTime.now().toString("yyyyMM")));
|
||||
// 根据 协议ID、结算类型、年月 删除多余数据
|
||||
for(SltInfoVo vo:validRecords){
|
||||
vo.setYearMonth(DateTime.now().toString("yyyyMM"));
|
||||
List<SltInfoVo> oldList=sltAgreementInfoMapper.selectOldHistoryReport(vo);
|
||||
if(oldList!=null&&oldList.size()>0){
|
||||
sltAgreementInfoMapper.deleteOldHistoryReport(vo);
|
||||
}
|
||||
}
|
||||
int rows = sltAgreementInfoMapper.addSltHistoryReport(validRecords);
|
||||
log.info("未结算报表定时器:保存未结算报表记录完成,受影响行数:{}", rows);
|
||||
|
||||
|
|
@ -186,6 +195,14 @@ public class IwsCostPushTask {
|
|||
detail.setYearMonth(DateTime.now().toString("yyyyMM"));
|
||||
detail.setSettlementType(1);
|
||||
});
|
||||
// 根据 协议ID、结算类型、年月、(1租赁 2维修 3丢失 4报废) 删除多余数据
|
||||
for(SltAgreementInfo vo:leaseDetails){
|
||||
vo.setCostType("1");
|
||||
List<SltAgreementInfo> oldList=sltAgreementInfoMapper.selectOldHistoryReportDetail(vo);
|
||||
if(oldList!=null&&oldList.size()>0){
|
||||
sltAgreementInfoMapper.deleteOldHistoryReportDetail(vo);
|
||||
}
|
||||
}
|
||||
sltAgreementInfoMapper.addSltHistoryReportLeaseDetail(leaseDetails);
|
||||
}
|
||||
|
||||
|
|
@ -200,6 +217,14 @@ public class IwsCostPushTask {
|
|||
detail.setYearMonth(DateTime.now().toString("yyyyMM"));
|
||||
detail.setSettlementType(1);
|
||||
});
|
||||
// 根据 协议ID、结算类型、年月、(1租赁 2维修 3丢失 4报废) 删除多余数据
|
||||
for(SltAgreementInfo vo:leaseDetails){
|
||||
vo.setCostType("2");
|
||||
List<SltAgreementInfo> oldList=sltAgreementInfoMapper.selectOldHistoryReportDetail(vo);
|
||||
if(oldList!=null&&oldList.size()>0){
|
||||
sltAgreementInfoMapper.deleteOldHistoryReportDetail(vo);
|
||||
}
|
||||
}
|
||||
sltAgreementInfoMapper.addSltHistoryReportRepairDetail(repairDetails);
|
||||
}
|
||||
|
||||
|
|
@ -214,6 +239,14 @@ public class IwsCostPushTask {
|
|||
detail.setYearMonth(DateTime.now().toString("yyyyMM"));
|
||||
detail.setSettlementType(1);
|
||||
});
|
||||
// 根据 协议ID、结算类型、年月、(1租赁 2维修 3丢失 4报废) 删除多余数据
|
||||
for(SltAgreementInfo vo:leaseDetails){
|
||||
vo.setCostType("3");
|
||||
List<SltAgreementInfo> oldList=sltAgreementInfoMapper.selectOldHistoryReportDetail(vo);
|
||||
if(oldList!=null&&oldList.size()>0){
|
||||
sltAgreementInfoMapper.deleteOldHistoryReportDetail(vo);
|
||||
}
|
||||
}
|
||||
sltAgreementInfoMapper.addSltHistoryReportLoseDetail(loseDetails);
|
||||
}
|
||||
|
||||
|
|
@ -228,6 +261,14 @@ public class IwsCostPushTask {
|
|||
detail.setYearMonth(DateTime.now().toString("yyyyMM"));
|
||||
detail.setSettlementType(1);
|
||||
});
|
||||
// 根据 协议ID、结算类型、年月、(1租赁 2维修 3丢失 4报废) 删除多余数据
|
||||
for(SltAgreementInfo vo:leaseDetails){
|
||||
vo.setCostType("4");
|
||||
List<SltAgreementInfo> oldList=sltAgreementInfoMapper.selectOldHistoryReportDetail(vo);
|
||||
if(oldList!=null&&oldList.size()>0){
|
||||
sltAgreementInfoMapper.deleteOldHistoryReportDetail(vo);
|
||||
}
|
||||
}
|
||||
sltAgreementInfoMapper.addSltHistoryReportScrapDetail(scrapDetails);
|
||||
}
|
||||
|
||||
|
|
@ -248,7 +289,6 @@ public class IwsCostPushTask {
|
|||
sltAgreementInfoService.clearCache();
|
||||
log.info("缓存已清理");
|
||||
}
|
||||
|
||||
System.out.println("-----------保存未结算记录定时器执行完毕-----------");
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -335,4 +335,6 @@ public class SltAgreementInfo extends BaseEntity {
|
|||
* 领料工程id
|
||||
*/
|
||||
private String leaseProId;
|
||||
|
||||
private String costType;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -32,6 +32,11 @@ public interface SltAgreementInfoMapper {
|
|||
|
||||
int addSltHistoryReportScrapDetail(List<SltAgreementInfo> list);
|
||||
|
||||
List<SltInfoVo> selectOldHistoryReport(SltInfoVo vo);
|
||||
int deleteOldHistoryReport(SltInfoVo vo);
|
||||
List<SltAgreementInfo> selectOldHistoryReportDetail(SltAgreementInfo vo);
|
||||
int deleteOldHistoryReportDetail(SltAgreementInfo vo);
|
||||
|
||||
List<SltHistoryReport> selectSltHistoryReportList(SltHistoryReport sltHistoryReport);
|
||||
|
||||
List<SltHistoryReportDetail> selectSltHistoryLeaseDetail(SltHistoryReportDetail sltHistoryReportDetail);
|
||||
|
|
|
|||
|
|
@ -148,6 +148,10 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|||
VALUES (#{month})
|
||||
</insert>
|
||||
|
||||
<select id="selectCalcMonthRecord" parameterType="com.bonus.material.push.domain.IwsCostPushBean" resultType="com.bonus.material.push.domain.IwsCostPushBean">
|
||||
select MONTH,ID as taskId from calc_project_month where month=#{month}
|
||||
</select>
|
||||
|
||||
<select id="getPaidSltBaseInfo" resultType="com.bonus.material.push.domain.IwsCostPushBean">
|
||||
SELECT
|
||||
mt1.type_name as typeName,
|
||||
|
|
@ -214,6 +218,60 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|||
)
|
||||
</foreach>
|
||||
</insert>
|
||||
<update id="updateProjectMonthCosts">
|
||||
update project_month_costs set
|
||||
LEASE_MONEY=#{leaseMoney},
|
||||
CONSUME_MONEY=#{consumeMoney},
|
||||
LOST_MONEY=#{lostMoney},
|
||||
REPAIR_MONEY=#{repairMoney},
|
||||
SCRAP_MONEY=#{scrapMoney}
|
||||
where
|
||||
AGREEMENT_ID=#{agreementId} and TASK_ID=#{taskId} and TYPE=#{settlementType}
|
||||
</update>
|
||||
|
||||
<select id="selectHaveProjectMonthCosts" parameterType="com.bonus.material.push.domain.IwsCostPushBean" resultType="com.bonus.material.push.domain.IwsCostPushBean">
|
||||
select
|
||||
AGREEMENT_ID as agreementId,
|
||||
LEASE_MONEY as leaseMoney,
|
||||
CONSUME_MONEY as consumeMoney,
|
||||
LOST_MONEY as lostMoney,
|
||||
REPAIR_MONEY as repairMoney,
|
||||
SCRAP_MONEY as scrapMoney,
|
||||
TASK_ID as taskId,
|
||||
TYPE as settlementType
|
||||
from project_month_costs where
|
||||
AGREEMENT_ID=#{agreementId} and TASK_ID=#{taskId} and TYPE=#{settlementType}
|
||||
</select>
|
||||
|
||||
<insert id="insertProjectMonthCostsDetails" parameterType="com.bonus.material.settlement.domain.vo.PeriodCostResultVo">
|
||||
insert into project_month_info(agreementId, typeId, leaseNum, leaseDate, returnDate,
|
||||
leasePrice, leaseMoney, taskId, buy_price, money, jiju_type)
|
||||
values
|
||||
<foreach collection="list" item="item" separator=",">
|
||||
(
|
||||
#{item.agreementId},
|
||||
#{item.typeId},
|
||||
#{item.num},
|
||||
#{item.calcStartTime},
|
||||
#{item.calcEndTime},
|
||||
#{item.leasePrice},
|
||||
#{item.leaseCost},
|
||||
#{item.taskId},
|
||||
#{item.buyPrice},
|
||||
#{item.consumeCost},
|
||||
#{item.equipmentType}
|
||||
)
|
||||
</foreach>
|
||||
</insert>
|
||||
<select id="selectHaveProjectMonthCostsDetails" parameterType="com.bonus.material.settlement.domain.vo.PeriodCostResultVo" resultType="com.bonus.material.settlement.domain.vo.PeriodCostResultVo">
|
||||
select
|
||||
agreementId, typeId, leaseNum, leaseDate, returnDate,
|
||||
leasePrice, leaseMoney, taskId, buy_price as buyprice, money as consumeCost, jiju_type as equipmentType
|
||||
from project_month_info
|
||||
where
|
||||
agreementId=#{agreementId} and taskId=#{taskId} and jiju_type=#{equipmentType}
|
||||
</select>
|
||||
|
||||
|
||||
<select id="getProLeaseInfo" resultType="com.bonus.material.push.domain.IwsCostPushBean">
|
||||
SELECT
|
||||
|
|
@ -482,27 +540,6 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|||
</if>
|
||||
</select>
|
||||
|
||||
<insert id="insertProjectMonthCostsDetails" parameterType="com.bonus.material.settlement.domain.vo.PeriodCostResultVo">
|
||||
insert into project_month_info(agreementId, typeId, leaseNum, leaseDate, returnDate,
|
||||
leasePrice, leaseMoney, taskId, buy_price, money, jiju_type)
|
||||
values
|
||||
<foreach collection="list" item="item" separator=",">
|
||||
(
|
||||
#{item.agreementId},
|
||||
#{item.typeId},
|
||||
#{item.num},
|
||||
#{item.calcStartTime},
|
||||
#{item.calcEndTime},
|
||||
#{item.leasePrice},
|
||||
#{item.leaseCost},
|
||||
#{item.taskId},
|
||||
#{item.buyPrice},
|
||||
#{item.consumeCost},
|
||||
#{item.equipmentType}
|
||||
)
|
||||
</foreach>
|
||||
</insert>
|
||||
|
||||
<select id="getProIdsByAgreementIds" resultType="com.bonus.material.push.domain.IwsCostPushBean">
|
||||
select project_id as proId,
|
||||
GROUP_CONCAT(agreement_id) as agreementIdsStr
|
||||
|
|
|
|||
|
|
@ -2638,6 +2638,56 @@
|
|||
)
|
||||
</foreach>
|
||||
</insert>
|
||||
|
||||
<select id="selectOldHistoryReport" parameterType="com.bonus.material.settlement.domain.vo.SltInfoVo" resultType="com.bonus.material.settlement.domain.vo.SltInfoVo">
|
||||
select a.agreement_id as agreementid,a.settlement_type as settlementtype,a.year_month as yearmonth
|
||||
from slt_history_report a
|
||||
where 1=1
|
||||
<if test="agreementId != null and agreementId != ''">
|
||||
and a.agreement_id=#{agreementId}
|
||||
</if>
|
||||
<if test="settlementType != null and settlementType != ''">
|
||||
and a.settlement_type=#{settlementType}
|
||||
</if>
|
||||
<if test="yearMonth != null and yearMonth != ''">
|
||||
and a.year_month=#{yearMonth}
|
||||
</if>
|
||||
</select>
|
||||
|
||||
<delete id="deleteOldHistoryReport">
|
||||
delete from slt_history_report where
|
||||
agreement_id=#{agreementId}
|
||||
and settlement_type=#{settlementType}
|
||||
and year_month=#{yearMonth}
|
||||
</delete>
|
||||
|
||||
<select id="selectOldHistoryReportDetail" parameterType="com.bonus.material.settlement.domain.SltAgreementInfo" resultType="com.bonus.material.settlement.domain.SltAgreementInfo">
|
||||
select a.agreement_id as agreementid,a.settlement_type as settlementtype,a.year_month as yearmonth,
|
||||
a.cost_type as costtype
|
||||
from slt_history_report_detail a
|
||||
where 1=1
|
||||
<if test="agreementId != null and agreementId != ''">
|
||||
and a.agreement_id=#{agreementId}
|
||||
</if>
|
||||
<if test="settlementType != null and settlementType != ''">
|
||||
and a.settlement_type=#{settlementType}
|
||||
</if>
|
||||
<if test="yearMonth != null and yearMonth != ''">
|
||||
and a.year_month=#{yearMonth}
|
||||
</if>
|
||||
<if test="costType != null and costType != ''">
|
||||
and a.cost_type=#{costType}
|
||||
</if>
|
||||
</select>
|
||||
|
||||
<delete id="deleteOldHistoryReportDetail">
|
||||
delete from slt_history_report_detail where
|
||||
agreement_id=#{agreementId}
|
||||
and settlement_type=#{settlementType}
|
||||
and year_month=#{yearMonth}
|
||||
and cost_type=#{costType}
|
||||
</delete>
|
||||
|
||||
<insert id="insertSltStatus">
|
||||
insert into slt_agreement_status
|
||||
(slt_task,slt_auditor,slt_status)
|
||||
|
|
|
|||
Loading…
Reference in New Issue