From 23e488581576d09c0b5b7112de167062a9cbcfd9 Mon Sep 17 00:00:00 2001 From: "liang.chao" <1360241448@qq.com> Date: Tue, 6 Aug 2024 15:44:16 +0800 Subject: [PATCH] =?UTF-8?q?=E7=BB=93=E7=AE=97=E7=AE=A1=E7=90=86=E5=8A=9F?= =?UTF-8?q?=E8=83=BD=E5=BC=80=E5=8F=91?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../base/api/domain/SltAgreementInfo.java | 2 + .../common/core/utils/DateTimeHelper.java | 13 +- .../material/SgzbMaterialApplication.java | 2 + .../material/domain/ProjectMonthCosts.java | 48 +++++ .../material/domain/ProjectMonthDetail.java | 73 ++++++++ .../material/mapper/AgreementInfoMapper.java | 2 + .../material/mapper/CalMonthlyMapper.java | 12 ++ .../bonus/sgzb/material/remind/Inform.java | 9 +- .../remind/service/CalcMonthlyServiceImp.java | 173 +++++++++++++++--- .../service/AgreementInfoService.java | 2 + .../impl/AgreementInfoServiceImpl.java | 5 + .../impl/SltAgreementInfoServiceImpl.java | 100 ++++++---- .../mapper/material/AgreementInfoMapper.xml | 8 + .../mapper/material/CalMonthlyMapper.xml | 59 +++++- .../material/SltAgreementInfoMapper.xml | 78 +++++--- .../bonus/sgzb/system/domain/AgreementVo.java | 3 + .../resources/mapper/system/SelectMapper.xml | 3 +- 17 files changed, 491 insertions(+), 101 deletions(-) create mode 100644 sgzb-modules/sgzb-material/src/main/java/com/bonus/sgzb/material/domain/ProjectMonthCosts.java create mode 100644 sgzb-modules/sgzb-material/src/main/java/com/bonus/sgzb/material/domain/ProjectMonthDetail.java diff --git a/sgzb-api/sgzb-api-system/src/main/java/com/bonus/sgzb/base/api/domain/SltAgreementInfo.java b/sgzb-api/sgzb-api-system/src/main/java/com/bonus/sgzb/base/api/domain/SltAgreementInfo.java index 3c191aa7..30c851f9 100644 --- a/sgzb-api/sgzb-api-system/src/main/java/com/bonus/sgzb/base/api/domain/SltAgreementInfo.java +++ b/sgzb-api/sgzb-api-system/src/main/java/com/bonus/sgzb/base/api/domain/SltAgreementInfo.java @@ -184,6 +184,8 @@ public class SltAgreementInfo { private String partModelName; private String partName; private Integer codeNum; + private Integer unitId; + private Integer lotId; private List node; } diff --git a/sgzb-common/sgzb-common-core/src/main/java/com/bonus/sgzb/common/core/utils/DateTimeHelper.java b/sgzb-common/sgzb-common-core/src/main/java/com/bonus/sgzb/common/core/utils/DateTimeHelper.java index c98d726f..fa1177a1 100644 --- a/sgzb-common/sgzb-common-core/src/main/java/com/bonus/sgzb/common/core/utils/DateTimeHelper.java +++ b/sgzb-common/sgzb-common-core/src/main/java/com/bonus/sgzb/common/core/utils/DateTimeHelper.java @@ -197,7 +197,7 @@ public class DateTimeHelper { } /** - * 获取当前时间的年月 + * 获取上月的年月 * * @return */ @@ -215,7 +215,7 @@ public class DateTimeHelper { } /** - * 获取当前时间的上个年月 + * 获取当前时间的年月 * * @return */ @@ -223,6 +223,15 @@ public class DateTimeHelper { return format(new Date(), "yyyy-MM"); } + /** + * 获取指定时间的年月 + * + * @return + */ + public static String getNowMonth(Date date) { + return format(date, "yyyy-MM"); + } + /** * 获取当前时间的年月日 * diff --git a/sgzb-modules/sgzb-material/src/main/java/com/bonus/sgzb/material/SgzbMaterialApplication.java b/sgzb-modules/sgzb-material/src/main/java/com/bonus/sgzb/material/SgzbMaterialApplication.java index 64129d37..8731ebfc 100644 --- a/sgzb-modules/sgzb-material/src/main/java/com/bonus/sgzb/material/SgzbMaterialApplication.java +++ b/sgzb-modules/sgzb-material/src/main/java/com/bonus/sgzb/material/SgzbMaterialApplication.java @@ -8,6 +8,7 @@ import com.ulisesbocchio.jasyptspringboot.annotation.EnableEncryptableProperties import org.springframework.boot.SpringApplication; import org.springframework.boot.autoconfigure.SpringBootApplication; import org.springframework.boot.autoconfigure.jdbc.DataSourceAutoConfiguration; +import org.springframework.scheduling.annotation.EnableScheduling; /** * 文件服务 @@ -18,6 +19,7 @@ import org.springframework.boot.autoconfigure.jdbc.DataSourceAutoConfiguration; @SpringBootApplication(exclude = {DataSourceAutoConfiguration.class}) @EnableCustomConfig @EnableRyFeignClients +@EnableScheduling @EnableEncryptableProperties public class SgzbMaterialApplication { diff --git a/sgzb-modules/sgzb-material/src/main/java/com/bonus/sgzb/material/domain/ProjectMonthCosts.java b/sgzb-modules/sgzb-material/src/main/java/com/bonus/sgzb/material/domain/ProjectMonthCosts.java new file mode 100644 index 00000000..0a8878ee --- /dev/null +++ b/sgzb-modules/sgzb-material/src/main/java/com/bonus/sgzb/material/domain/ProjectMonthCosts.java @@ -0,0 +1,48 @@ +package com.bonus.sgzb.material.domain; + +import lombok.Data; + +import java.util.List; + +/** + * @Author:liang.chao + * @Date:2024/8/5 - 14:28 + */ + +@Data +public class ProjectMonthCosts { + /** + * 主键id + */ + private Integer id; + /** + * 协议id + */ + private Integer agreementId; + /** + * 结算记录关联id + */ + private Integer sltMonthId; + /** + * 单位id + */ + private Integer unitId; + /** + *工程id + */ + private Integer projectId; + /** + * 结算月份 + */ + private String month; + /** + * 费用承担方 + */ + private String costBearingParty; + /** + * 结算金额 + */ + private String costs; + private List node; + +} diff --git a/sgzb-modules/sgzb-material/src/main/java/com/bonus/sgzb/material/domain/ProjectMonthDetail.java b/sgzb-modules/sgzb-material/src/main/java/com/bonus/sgzb/material/domain/ProjectMonthDetail.java new file mode 100644 index 00000000..5a0b37cc --- /dev/null +++ b/sgzb-modules/sgzb-material/src/main/java/com/bonus/sgzb/material/domain/ProjectMonthDetail.java @@ -0,0 +1,73 @@ +package com.bonus.sgzb.material.domain; + +import lombok.Data; + +import java.util.Date; + +/** + * @Author:liang.chao + * @Date:2024/8/5 - 15:08 + */ +@Data +public class ProjectMonthDetail { + /** + * 主键id + */ + private Integer id; + /** + * 类型id + */ + private Integer typeId; + /** + * 编码id + */ + private Integer maId; + /** + * 单位 + */ + private String unit; + /** + * 开始日期 + */ + private String startTime; + /** + * 结束日期 + */ + private String endTime; + /** + * 结算天数 + */ + private String sltDays; + /** + * 结算金额 + */ + private String sltCosts; + /** + * 本月暂计金额 + */ + private String monthTemporarilyCosts; + /** + * 月结算关联id + */ + private Integer proMonthCostId; + /** + * 数量 + */ + private String num; + /** + * 结算月份 + */ + private String month; + /** + * 单价 + */ + private String leasePrice; + /** + * 费用承担方 + */ + private String costBearingParty; + private String leaseDays; + private String nuitName; + private String costs; + private String realCosts; +} diff --git a/sgzb-modules/sgzb-material/src/main/java/com/bonus/sgzb/material/mapper/AgreementInfoMapper.java b/sgzb-modules/sgzb-material/src/main/java/com/bonus/sgzb/material/mapper/AgreementInfoMapper.java index 184129d1..34a2f6f3 100644 --- a/sgzb-modules/sgzb-material/src/main/java/com/bonus/sgzb/material/mapper/AgreementInfoMapper.java +++ b/sgzb-modules/sgzb-material/src/main/java/com/bonus/sgzb/material/mapper/AgreementInfoMapper.java @@ -81,4 +81,6 @@ public interface AgreementInfoMapper { * @return int */ int selectByagreementId(Long agreementId); + + List getAllAgreementId(); } diff --git a/sgzb-modules/sgzb-material/src/main/java/com/bonus/sgzb/material/mapper/CalMonthlyMapper.java b/sgzb-modules/sgzb-material/src/main/java/com/bonus/sgzb/material/mapper/CalMonthlyMapper.java index f18165f1..bf86eb29 100644 --- a/sgzb-modules/sgzb-material/src/main/java/com/bonus/sgzb/material/mapper/CalMonthlyMapper.java +++ b/sgzb-modules/sgzb-material/src/main/java/com/bonus/sgzb/material/mapper/CalMonthlyMapper.java @@ -1,6 +1,9 @@ package com.bonus.sgzb.material.mapper; +import com.bonus.sgzb.material.domain.AgreementInfo; import com.bonus.sgzb.material.domain.CalMonthlyBean; +import com.bonus.sgzb.material.domain.ProjectMonthCosts; +import com.bonus.sgzb.material.domain.ProjectMonthDetail; import org.apache.ibatis.annotations.Mapper; import java.util.List; @@ -26,4 +29,13 @@ public interface CalMonthlyMapper { int deleteMonthlyCosts(CalMonthlyBean bean); + int insertProMonCosts(ProjectMonthCosts projectMonthCosts); + + int insertProjectMonthDetail(ProjectMonthDetail projectMonthDetail); + + int updateProMonCosts(ProjectMonthCosts pmcId); + + List getMonthCosts(AgreementInfo agreementInfo); + + List getMonthDetails(ProjectMonthCosts monthCost); } diff --git a/sgzb-modules/sgzb-material/src/main/java/com/bonus/sgzb/material/remind/Inform.java b/sgzb-modules/sgzb-material/src/main/java/com/bonus/sgzb/material/remind/Inform.java index 66a1c691..41ff8f49 100644 --- a/sgzb-modules/sgzb-material/src/main/java/com/bonus/sgzb/material/remind/Inform.java +++ b/sgzb-modules/sgzb-material/src/main/java/com/bonus/sgzb/material/remind/Inform.java @@ -13,23 +13,20 @@ public class Inform { @Autowired private CalcMonthlyService calcfourCostService; - private final int CAL_DAY = 21; + private final int CAL_DAY = 6; - @Scheduled(cron = "0 */5 * * * ? ") // 间隔5分钟执行 - //@Scheduled(cron = "0 0 1 22 * ? ") // 每个月22日凌晨1点执行 + @Scheduled(cron = "0 */1 * * * ? ") // 间隔5分钟执行 +// @Scheduled(cron = "0 0 1 22 * ? ") // 每个月22日凌晨1点执行 @Async public void taskCycle() { System.out.println("===springMVC定时器启动===="); - try { - // 生成每月数据 (上月21日---本月20日) calcfourCostService.calcMonthInfo(CAL_DAY); } catch (Exception e) { e.printStackTrace(); } - System.out.println("===springMVC定时器结束===="); } diff --git a/sgzb-modules/sgzb-material/src/main/java/com/bonus/sgzb/material/remind/service/CalcMonthlyServiceImp.java b/sgzb-modules/sgzb-material/src/main/java/com/bonus/sgzb/material/remind/service/CalcMonthlyServiceImp.java index 822546a9..777d495a 100644 --- a/sgzb-modules/sgzb-material/src/main/java/com/bonus/sgzb/material/remind/service/CalcMonthlyServiceImp.java +++ b/sgzb-modules/sgzb-material/src/main/java/com/bonus/sgzb/material/remind/service/CalcMonthlyServiceImp.java @@ -1,52 +1,165 @@ package com.bonus.sgzb.material.remind.service; +import com.bonus.sgzb.base.api.domain.SltAgreementInfo; import com.bonus.sgzb.common.core.utils.DateTimeHelper; +import com.bonus.sgzb.material.domain.AgreementInfo; import com.bonus.sgzb.material.domain.CalMonthlyBean; +import com.bonus.sgzb.material.domain.ProjectMonthCosts; +import com.bonus.sgzb.material.domain.ProjectMonthDetail; import com.bonus.sgzb.material.mapper.CalMonthlyMapper; +import com.bonus.sgzb.material.mapper.SltAgreementInfoMapper; +import com.bonus.sgzb.material.service.AgreementInfoService; +import org.apache.commons.lang3.StringUtils; import org.springframework.stereotype.Service; import org.springframework.util.CollectionUtils; import javax.annotation.Resource; +import java.math.BigDecimal; +import java.util.ArrayList; import java.util.List; +import java.util.Objects; @Service public class CalcMonthlyServiceImp implements CalcMonthlyService { - @Resource - CalMonthlyMapper calMonthlyMapper; + @Resource + CalMonthlyMapper calMonthlyMapper; - @Override - public void calcMonthInfo(int day) throws Exception { - String time = DateTimeHelper.getNowDate(); - String calDay = DateTimeHelper.getCalDay(day); - if (time.equals(calDay)) { - CalMonthlyBean record = new CalMonthlyBean(); - String month = DateTimeHelper.getCurrentMonth(); - record.setMonth(month); - cleanSameMonthOldRecords(record); - calMonthlyMapper.insertCalcRecord(record); - String taskId = record.getId(); - String startTime = DateTimeHelper.getCalStartDay(); - String endTime = DateTimeHelper.getCalDay(day - 1); + @Resource + private AgreementInfoService agreementInfoService; - //TODO, use startTime, endTime, taskId to save monthly result to a new table. + @Resource + private SltAgreementInfoMapper sltAgreementInfoMapper; + + @Override + public void calcMonthInfo(int day) { + String time = DateTimeHelper.getNowDate(); + String calDay = DateTimeHelper.getCalDay(day); + if (time.equals(calDay)) { + CalMonthlyBean record = new CalMonthlyBean(); + String month = DateTimeHelper.getCurrentMonth(); + record.setMonth(month); +// cleanSameMonthOldRecords(record); + List list = agreementInfoService.getAllAgreementId(); + String startTime = DateTimeHelper.getCalStartDay(); + String endTime = DateTimeHelper.getCalDay(day - 1); + list.forEach(t -> { + t.setStartTime(startTime); + t.setEndTime(endTime); + }); + getLeaseListMonth(list, record); + } + } + + private void cleanSameMonthOldRecords(CalMonthlyBean record) { + List list = calMonthlyMapper.getCalcRecords(record); + if (!CollectionUtils.isEmpty(list)) { + for (CalMonthlyBean bean : list) { + //清除上月之前计算过的记录 calc_project_month + calMonthlyMapper.deleteCalcRecord(bean); + + //清除上月之前计算过的记录 project_month_costs(表名待定) + calMonthlyMapper.deleteMonthlyCosts(bean); + } + } + } + + private List getLeaseListMonth(List list, CalMonthlyBean record) { + List leaseList = new ArrayList<>(); + + for (AgreementInfo bean : list) { + if (StringUtils.isNotBlank(bean.getStartTime()) && StringUtils.isNotBlank(bean.getEndTime())) { + List monthList = sltAgreementInfoMapper.getLeaseListMonthNotNull(bean); + monthList.stream().filter(Objects::nonNull); + for (SltAgreementInfo sltAgreementInfo : monthList) { + calMonthlyMapper.insertCalcRecord(record); + // slt_project_month的主键id + String spmId = record.getId(); + ProjectMonthCosts projectMonthCosts = new ProjectMonthCosts(); + projectMonthCosts.setAgreementId(Integer.parseInt(sltAgreementInfo.getAgreementId())); + projectMonthCosts.setSltMonthId(Integer.parseInt(spmId)); + projectMonthCosts.setUnitId(sltAgreementInfo.getUnitId()); + projectMonthCosts.setProjectId(sltAgreementInfo.getLotId()); + projectMonthCosts.setMonth(record.getMonth()); + projectMonthCosts.setCostBearingParty(sltAgreementInfo.getCostBearingParty()); + calMonthlyMapper.insertProMonCosts(projectMonthCosts); + // project_month_costs的主键id + int pmcId = projectMonthCosts.getId(); + + AgreementInfo agreementInfo = new AgreementInfo(); + agreementInfo.setAgreementId(bean.getAgreementId()); + agreementInfo.setCostBearingParty(sltAgreementInfo.getCostBearingParty()); + agreementInfo.setStartTime(sltAgreementInfo.getBeginTime()); + agreementInfo.setIds(sltAgreementInfo.getIds()); + sltAgreementInfo.setMonth(bean.getMonth()); + agreementInfo.setEndTime(sltAgreementInfo.getOffTime()); + List leaseListOneMonth = getLeaseListOneMonth(agreementInfo, sltAgreementInfo, pmcId); + projectMonthCosts.setCosts(sltAgreementInfo.getCosts()); + calMonthlyMapper.updateProMonCosts(projectMonthCosts); + sltAgreementInfo.setNode(leaseListOneMonth); + } + leaseList.addAll(monthList); + } + } + return leaseList; + } - } - } + private List getLeaseListOneMonth(AgreementInfo list, SltAgreementInfo sltAgreementInfo, Integer pmcId) { + ArrayList idList = new ArrayList<>(); + String[] ids = list.getIds().split(","); + for (String id : ids) { + idList.add(id); + } + List leaseList = sltAgreementInfoMapper.getLeaseListOneMonth(list, idList); + BigDecimal leaseCostOne = BigDecimal.ZERO; + for (SltAgreementInfo bean : leaseList) { + if (bean.getLeasePrice() == null) { + bean.setLeasePrice("0"); + } + if (bean.getNum() == null) { + bean.setNum("0"); + } + if (bean.getLeaseDays() == null) { + bean.setLeaseDays("0"); + } + if (bean.getTrimDay() == null) { + bean.setTrimDay(0); + } + BigDecimal leasePrice = new BigDecimal(bean.getLeasePrice()); + BigDecimal num = new BigDecimal(bean.getNum()); + BigDecimal leaseDays = new BigDecimal(bean.getLeaseDays()); + // 实际结算天数(领料天数 + 调整天数(可以为负整数)) + BigDecimal realDays = leaseDays.add(new BigDecimal(bean.getTrimDay())); + // 实际结算金额 + BigDecimal realCosts = leasePrice.multiply(num).multiply(realDays); + // 应结算金额 + BigDecimal costs = leasePrice.multiply(num).multiply(leaseDays); + bean.setCosts(String.valueOf(costs)); + bean.setRealDays(realDays); + bean.setRealCosts(String.valueOf(realCosts)); + leaseCostOne = leaseCostOne.add(costs); + bean.setMonth(sltAgreementInfo.getMonth()); - private void cleanSameMonthOldRecords(CalMonthlyBean record) { - List list = calMonthlyMapper.getCalcRecords(record); - if (!CollectionUtils.isEmpty(list)) { - for (CalMonthlyBean bean : list) { - //清除上月之前计算过的记录 calc_project_month - calMonthlyMapper.deleteCalcRecord(bean); - - //清除上月之前计算过的记录 project_month_costs(表名待定) - calMonthlyMapper.deleteMonthlyCosts(bean); - } - } - } + ProjectMonthDetail projectMonthDetail = new ProjectMonthDetail(); + projectMonthDetail.setTypeId(Integer.valueOf(bean.getTypeId())); + if (bean.getMaId() != null){ + projectMonthDetail.setMaId(Integer.valueOf(bean.getMaId())); + } + projectMonthDetail.setUnit(bean.getNuitName()); + projectMonthDetail.setStartTime(bean.getStartTime()); + projectMonthDetail.setEndTime(bean.getEndTime()); + projectMonthDetail.setSltDays(bean.getLeaseDays()); + projectMonthDetail.setNum(bean.getNum()); + projectMonthDetail.setLeasePrice(bean.getLeasePrice()); + projectMonthDetail.setSltCosts(bean.getCosts()); + projectMonthDetail.setMonthTemporarilyCosts(bean.getRealCosts()); + projectMonthDetail.setProMonthCostId(pmcId); + calMonthlyMapper.insertProjectMonthDetail(projectMonthDetail); + } + sltAgreementInfo.setCosts(String.valueOf(leaseCostOne)); + return leaseList; + } } diff --git a/sgzb-modules/sgzb-material/src/main/java/com/bonus/sgzb/material/service/AgreementInfoService.java b/sgzb-modules/sgzb-material/src/main/java/com/bonus/sgzb/material/service/AgreementInfoService.java index ffc1f290..64e1b7e3 100644 --- a/sgzb-modules/sgzb-material/src/main/java/com/bonus/sgzb/material/service/AgreementInfoService.java +++ b/sgzb-modules/sgzb-material/src/main/java/com/bonus/sgzb/material/service/AgreementInfoService.java @@ -64,4 +64,6 @@ public interface AgreementInfoService { * @return */ List exportList(AgreementInfo agreementInfo); + + List getAllAgreementId(); } diff --git a/sgzb-modules/sgzb-material/src/main/java/com/bonus/sgzb/material/service/impl/AgreementInfoServiceImpl.java b/sgzb-modules/sgzb-material/src/main/java/com/bonus/sgzb/material/service/impl/AgreementInfoServiceImpl.java index f76c278b..f4e78838 100644 --- a/sgzb-modules/sgzb-material/src/main/java/com/bonus/sgzb/material/service/impl/AgreementInfoServiceImpl.java +++ b/sgzb-modules/sgzb-material/src/main/java/com/bonus/sgzb/material/service/impl/AgreementInfoServiceImpl.java @@ -86,6 +86,11 @@ public class AgreementInfoServiceImpl implements AgreementInfoService { return agreementInfoMapper.getAgreementInfoAll(agreementInfo); } + @Override + public List getAllAgreementId() { + return agreementInfoMapper.getAllAgreementId(); + } + private String purchaseCodeRule() { SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd"); diff --git a/sgzb-modules/sgzb-material/src/main/java/com/bonus/sgzb/material/service/impl/SltAgreementInfoServiceImpl.java b/sgzb-modules/sgzb-material/src/main/java/com/bonus/sgzb/material/service/impl/SltAgreementInfoServiceImpl.java index 40e6953d..775cb131 100644 --- a/sgzb-modules/sgzb-material/src/main/java/com/bonus/sgzb/material/service/impl/SltAgreementInfoServiceImpl.java +++ b/sgzb-modules/sgzb-material/src/main/java/com/bonus/sgzb/material/service/impl/SltAgreementInfoServiceImpl.java @@ -6,12 +6,16 @@ import com.bonus.sgzb.base.api.domain.SltAgreementRelation; import com.bonus.sgzb.base.api.domain.SltInfoVo; import com.bonus.sgzb.common.core.exception.ServiceException; +import com.bonus.sgzb.common.core.utils.DateTimeHelper; import com.bonus.sgzb.common.core.utils.DateUtils; import com.bonus.sgzb.common.core.web.domain.AjaxResult; import com.bonus.sgzb.common.security.utils.SecurityUtils; import com.bonus.sgzb.material.domain.AgreementInfo; +import com.bonus.sgzb.material.domain.ProjectMonthCosts; +import com.bonus.sgzb.material.domain.ProjectMonthDetail; import com.bonus.sgzb.material.domain.TmTask; +import com.bonus.sgzb.material.mapper.CalMonthlyMapper; import com.bonus.sgzb.material.mapper.SltAgreementInfoMapper; import com.bonus.sgzb.material.service.SltAgreementInfoService; import com.bonus.sgzb.material.vo.GlobalContants; @@ -35,6 +39,9 @@ public class SltAgreementInfoServiceImpl implements SltAgreementInfoService { @Resource private SltAgreementInfoMapper sltAgreementInfoMapper; + @Resource + private CalMonthlyMapper calMonthlyMapper; + @Override public List getSltAgreementInfo(AgreementInfo bean) { return sltAgreementInfoMapper.getSltAgreementInfo(bean); @@ -397,10 +404,34 @@ public class SltAgreementInfoServiceImpl implements SltAgreementInfoService { } @Override - public List getSltInfoMonth(List list) { + public List getSltInfoMonth(List list) { + List leaseListMonth = new ArrayList<>(); + List monthCostsList = new ArrayList<>(); + Integer num = 0; //租赁费用列表 - List leaseListMonth = getLeaseListMonth(list); - return leaseListMonth; + for (AgreementInfo agreementInfo : list) { + // 如果不选择具体日期或者选择了最新月份则需要查数据 + if (agreementInfo.getStartTime() == null || DateTimeHelper.getNowMonth().equals(DateTimeHelper.getNowMonth(DateTimeHelper.parse(agreementInfo.getEndTime(), "yyyy-MM")))) { + List listMonth = getLeaseListMonth(agreementInfo, num); + leaseListMonth.addAll(listMonth); + return leaseListMonth; + } else { + // 查定时任务记录的数据 + List listMonth = getLeaseJobListMonth(agreementInfo); + monthCostsList.addAll(listMonth); + return monthCostsList; + } + } + return new ArrayList<>(); + } + + private List getLeaseJobListMonth(AgreementInfo agreementInfo) { + List monthCosts = calMonthlyMapper.getMonthCosts(agreementInfo); + for (ProjectMonthCosts monthCost : monthCosts) { + List monthDetails = calMonthlyMapper.getMonthDetails(monthCost); + monthCost.setNode(monthDetails); + } + return monthCosts; } @Override @@ -408,41 +439,40 @@ public class SltAgreementInfoServiceImpl implements SltAgreementInfoService { return sltAgreementInfoMapper.updateOutSourceCosts(sltAgreementInfo); } - private List getLeaseListMonth(List list) { + private List getLeaseListMonth(AgreementInfo bean, Integer num) { List leaseList = new ArrayList<>(); - int num = 0; - for (AgreementInfo bean : list) { - if (StringUtils.isNotBlank(bean.getStartTime()) && StringUtils.isNotBlank(bean.getEndTime())) { - List monthList = sltAgreementInfoMapper.getLeaseListMonthNotNull(bean); - for (SltAgreementInfo sltAgreementInfo : monthList) { - AgreementInfo agreementInfo = new AgreementInfo(); - agreementInfo.setAgreementId(bean.getAgreementId()); - agreementInfo.setCostBearingParty(sltAgreementInfo.getCostBearingParty()); - agreementInfo.setStartTime(sltAgreementInfo.getBeginTime()); - agreementInfo.setIds(sltAgreementInfo.getIds()); - sltAgreementInfo.setMonth(bean.getMonth()); - sltAgreementInfo.setCodeNum(num++); - agreementInfo.setEndTime(sltAgreementInfo.getOffTime()); - List leaseListOneMonth = getLeaseListOneMonth(agreementInfo, sltAgreementInfo); - sltAgreementInfo.setNode(leaseListOneMonth); - } - leaseList.addAll(monthList); - } else { - List oneOfList = sltAgreementInfoMapper.getLeaseListMonth(bean); - for (SltAgreementInfo sltAgreementInfo : oneOfList) { - AgreementInfo agreementInfo = new AgreementInfo(); - agreementInfo.setAgreementId(bean.getAgreementId()); - agreementInfo.setIds(sltAgreementInfo.getIds()); - agreementInfo.setCostBearingParty(sltAgreementInfo.getCostBearingParty()); - agreementInfo.setStartTime(sltAgreementInfo.getBeginTime()); - sltAgreementInfo.setCodeNum(num++); - agreementInfo.setEndTime(sltAgreementInfo.getOffTime()); - List leaseListOneMonth = getLeaseListOneMonth(agreementInfo, sltAgreementInfo); - sltAgreementInfo.setNode(leaseListOneMonth); - } - leaseList.addAll(oneOfList); +// for (AgreementInfo bean : list) { + if (StringUtils.isNotBlank(bean.getStartTime()) && StringUtils.isNotBlank(bean.getEndTime())) { + List monthList = sltAgreementInfoMapper.getLeaseListMonthNotNull(bean); + for (SltAgreementInfo sltAgreementInfo : monthList) { + AgreementInfo agreementInfo = new AgreementInfo(); + agreementInfo.setAgreementId(bean.getAgreementId()); + agreementInfo.setCostBearingParty(sltAgreementInfo.getCostBearingParty()); + agreementInfo.setStartTime(sltAgreementInfo.getBeginTime()); + agreementInfo.setIds(sltAgreementInfo.getIds()); + sltAgreementInfo.setMonth(bean.getMonth()); + sltAgreementInfo.setCodeNum(num++); + agreementInfo.setEndTime(sltAgreementInfo.getOffTime()); + List leaseListOneMonth = getLeaseListOneMonth(agreementInfo, sltAgreementInfo); + sltAgreementInfo.setNode(leaseListOneMonth); } + leaseList.addAll(monthList); + } else { + List oneOfList = sltAgreementInfoMapper.getLeaseListMonth(bean); + for (SltAgreementInfo sltAgreementInfo : oneOfList) { + AgreementInfo agreementInfo = new AgreementInfo(); + agreementInfo.setAgreementId(bean.getAgreementId()); + agreementInfo.setIds(sltAgreementInfo.getIds()); + agreementInfo.setCostBearingParty(sltAgreementInfo.getCostBearingParty()); + agreementInfo.setStartTime(sltAgreementInfo.getBeginTime()); + sltAgreementInfo.setCodeNum(num++); + agreementInfo.setEndTime(sltAgreementInfo.getOffTime()); + List leaseListOneMonth = getLeaseListOneMonth(agreementInfo, sltAgreementInfo); + sltAgreementInfo.setNode(leaseListOneMonth); + } + leaseList.addAll(oneOfList); } +// } return leaseList; } diff --git a/sgzb-modules/sgzb-material/src/main/resources/mapper/material/AgreementInfoMapper.xml b/sgzb-modules/sgzb-material/src/main/resources/mapper/material/AgreementInfoMapper.xml index 8f63a4ca..41ce2d30 100644 --- a/sgzb-modules/sgzb-material/src/main/resources/mapper/material/AgreementInfoMapper.xml +++ b/sgzb-modules/sgzb-material/src/main/resources/mapper/material/AgreementInfoMapper.xml @@ -164,5 +164,13 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" WHERE tta.agreement_id=#{agreementId} + \ No newline at end of file diff --git a/sgzb-modules/sgzb-material/src/main/resources/mapper/material/CalMonthlyMapper.xml b/sgzb-modules/sgzb-material/src/main/resources/mapper/material/CalMonthlyMapper.xml index 972248fb..62ec96da 100644 --- a/sgzb-modules/sgzb-material/src/main/resources/mapper/material/CalMonthlyMapper.xml +++ b/sgzb-modules/sgzb-material/src/main/resources/mapper/material/CalMonthlyMapper.xml @@ -5,13 +5,70 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" - INSERT INTO calc_project_month (MONTH) VALUES (#{month}) + INSERT INTO slt_project_month (month,create_time) VALUES (#{month},now()) + + insert into project_month_costs(agreement_id,slt_month_id,unit_id,project_id,month,cost_bearing_party) + values + (#{agreementId},#{sltMonthId},#{unitId},#{projectId},#{month},#{costBearingParty}) + + + insert into project_month_detail (type_id,ma_id,unit,start_time,end_time,slt_days,slt_costs,month_temporarily_costs,pro_month_cost_id,num,lease_price) + values + (#{typeId},#{maId},#{unit},#{startTime},#{endTime},#{sltDays},#{sltCosts},#{monthTemporarilyCosts},#{proMonthCostId},#{num},#{leasePrice}) + + + update project_month_costs set costs = #{costs} where id = #{id} + + + delete from calc_project_month diff --git a/sgzb-modules/sgzb-material/src/main/resources/mapper/material/SltAgreementInfoMapper.xml b/sgzb-modules/sgzb-material/src/main/resources/mapper/material/SltAgreementInfoMapper.xml index d0f7ff7a..924bcfd6 100644 --- a/sgzb-modules/sgzb-material/src/main/resources/mapper/material/SltAgreementInfoMapper.xml +++ b/sgzb-modules/sgzb-material/src/main/resources/mapper/material/SltAgreementInfoMapper.xml @@ -401,7 +401,9 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" WHERE sai.agreement_id = #{bean.agreementId} AND sai.lease_type = 0 - AND lai.cost_bearing_party = #{bean.costBearingParty} + + AND lai.cost_bearing_party = #{bean.costBearingParty} + AND sai.id IN #{id} @@ -447,26 +449,21 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" SELECT agreement_id AS agreementId, - agreement_code AS agreementCode + agreement_code AS agreementCode, + is_slt AS isSlt FROM bm_agreement_info WHERE unit_id = #{unitId} AND project_id = #{projectId} AND status = '1'