结算管理功能开发
This commit is contained in:
parent
65040c2767
commit
23e4885815
|
|
@ -184,6 +184,8 @@ public class SltAgreementInfo {
|
|||
private String partModelName;
|
||||
private String partName;
|
||||
private Integer codeNum;
|
||||
private Integer unitId;
|
||||
private Integer lotId;
|
||||
private List<SltAgreementInfo> node;
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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");
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取当前时间的年月日
|
||||
*
|
||||
|
|
|
|||
|
|
@ -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
|
||||
{
|
||||
|
|
|
|||
|
|
@ -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<ProjectMonthDetail> node;
|
||||
|
||||
}
|
||||
|
|
@ -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;
|
||||
}
|
||||
|
|
@ -81,4 +81,6 @@ public interface AgreementInfoMapper {
|
|||
* @return int
|
||||
*/
|
||||
int selectByagreementId(Long agreementId);
|
||||
|
||||
List<AgreementInfo> getAllAgreementId();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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<ProjectMonthCosts> getMonthCosts(AgreementInfo agreementInfo);
|
||||
|
||||
List<ProjectMonthDetail> getMonthDetails(ProjectMonthCosts monthCost);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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定时器结束====");
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -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<AgreementInfo> 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<CalMonthlyBean> 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<SltAgreementInfo> getLeaseListMonth(List<AgreementInfo> list, CalMonthlyBean record) {
|
||||
List<SltAgreementInfo> leaseList = new ArrayList<>();
|
||||
|
||||
for (AgreementInfo bean : list) {
|
||||
if (StringUtils.isNotBlank(bean.getStartTime()) && StringUtils.isNotBlank(bean.getEndTime())) {
|
||||
List<SltAgreementInfo> 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<SltAgreementInfo> leaseListOneMonth = getLeaseListOneMonth(agreementInfo, sltAgreementInfo, pmcId);
|
||||
projectMonthCosts.setCosts(sltAgreementInfo.getCosts());
|
||||
calMonthlyMapper.updateProMonCosts(projectMonthCosts);
|
||||
sltAgreementInfo.setNode(leaseListOneMonth);
|
||||
}
|
||||
leaseList.addAll(monthList);
|
||||
}
|
||||
}
|
||||
return leaseList;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
private List<SltAgreementInfo> getLeaseListOneMonth(AgreementInfo list, SltAgreementInfo sltAgreementInfo, Integer pmcId) {
|
||||
ArrayList<String> idList = new ArrayList<>();
|
||||
String[] ids = list.getIds().split(",");
|
||||
for (String id : ids) {
|
||||
idList.add(id);
|
||||
}
|
||||
List<SltAgreementInfo> 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<CalMonthlyBean> 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;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -64,4 +64,6 @@ public interface AgreementInfoService {
|
|||
* @return
|
||||
*/
|
||||
List<AgreementInfo> exportList(AgreementInfo agreementInfo);
|
||||
|
||||
List<AgreementInfo> getAllAgreementId();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -86,6 +86,11 @@ public class AgreementInfoServiceImpl implements AgreementInfoService {
|
|||
return agreementInfoMapper.getAgreementInfoAll(agreementInfo);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<AgreementInfo> getAllAgreementId() {
|
||||
return agreementInfoMapper.getAllAgreementId();
|
||||
}
|
||||
|
||||
|
||||
private String purchaseCodeRule() {
|
||||
SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd");
|
||||
|
|
|
|||
|
|
@ -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<AgreementInfo> getSltAgreementInfo(AgreementInfo bean) {
|
||||
return sltAgreementInfoMapper.getSltAgreementInfo(bean);
|
||||
|
|
@ -397,10 +404,34 @@ public class SltAgreementInfoServiceImpl implements SltAgreementInfoService {
|
|||
}
|
||||
|
||||
@Override
|
||||
public List<SltAgreementInfo> getSltInfoMonth(List<AgreementInfo> list) {
|
||||
public List getSltInfoMonth(List<AgreementInfo> list) {
|
||||
List<SltAgreementInfo> leaseListMonth = new ArrayList<>();
|
||||
List<ProjectMonthCosts> monthCostsList = new ArrayList<>();
|
||||
Integer num = 0;
|
||||
//租赁费用列表
|
||||
List<SltAgreementInfo> 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<SltAgreementInfo> listMonth = getLeaseListMonth(agreementInfo, num);
|
||||
leaseListMonth.addAll(listMonth);
|
||||
return leaseListMonth;
|
||||
} else {
|
||||
// 查定时任务记录的数据
|
||||
List<ProjectMonthCosts> listMonth = getLeaseJobListMonth(agreementInfo);
|
||||
monthCostsList.addAll(listMonth);
|
||||
return monthCostsList;
|
||||
}
|
||||
}
|
||||
return new ArrayList<>();
|
||||
}
|
||||
|
||||
private List<ProjectMonthCosts> getLeaseJobListMonth(AgreementInfo agreementInfo) {
|
||||
List<ProjectMonthCosts> monthCosts = calMonthlyMapper.getMonthCosts(agreementInfo);
|
||||
for (ProjectMonthCosts monthCost : monthCosts) {
|
||||
List<ProjectMonthDetail> 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<SltAgreementInfo> getLeaseListMonth(List<AgreementInfo> list) {
|
||||
private List<SltAgreementInfo> getLeaseListMonth(AgreementInfo bean, Integer num) {
|
||||
List<SltAgreementInfo> leaseList = new ArrayList<>();
|
||||
int num = 0;
|
||||
for (AgreementInfo bean : list) {
|
||||
if (StringUtils.isNotBlank(bean.getStartTime()) && StringUtils.isNotBlank(bean.getEndTime())) {
|
||||
List<SltAgreementInfo> 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<SltAgreementInfo> leaseListOneMonth = getLeaseListOneMonth(agreementInfo, sltAgreementInfo);
|
||||
sltAgreementInfo.setNode(leaseListOneMonth);
|
||||
}
|
||||
leaseList.addAll(monthList);
|
||||
} else {
|
||||
List<SltAgreementInfo> 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<SltAgreementInfo> leaseListOneMonth = getLeaseListOneMonth(agreementInfo, sltAgreementInfo);
|
||||
sltAgreementInfo.setNode(leaseListOneMonth);
|
||||
}
|
||||
leaseList.addAll(oneOfList);
|
||||
// for (AgreementInfo bean : list) {
|
||||
if (StringUtils.isNotBlank(bean.getStartTime()) && StringUtils.isNotBlank(bean.getEndTime())) {
|
||||
List<SltAgreementInfo> 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<SltAgreementInfo> leaseListOneMonth = getLeaseListOneMonth(agreementInfo, sltAgreementInfo);
|
||||
sltAgreementInfo.setNode(leaseListOneMonth);
|
||||
}
|
||||
leaseList.addAll(monthList);
|
||||
} else {
|
||||
List<SltAgreementInfo> 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<SltAgreementInfo> leaseListOneMonth = getLeaseListOneMonth(agreementInfo, sltAgreementInfo);
|
||||
sltAgreementInfo.setNode(leaseListOneMonth);
|
||||
}
|
||||
leaseList.addAll(oneOfList);
|
||||
}
|
||||
// }
|
||||
return leaseList;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -164,5 +164,13 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|||
WHERE
|
||||
tta.agreement_id=#{agreementId}
|
||||
</select>
|
||||
<select id="getAllAgreementId" resultType="com.bonus.sgzb.material.domain.AgreementInfo">
|
||||
SELECT
|
||||
agreement_id as agreementId
|
||||
FROM
|
||||
bm_agreement_info
|
||||
WHERE
|
||||
status = '1'
|
||||
</select>
|
||||
|
||||
</mapper>
|
||||
|
|
@ -5,13 +5,70 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|||
<mapper namespace="com.bonus.sgzb.material.mapper.CalMonthlyMapper">
|
||||
|
||||
<insert id="insertCalcRecord" parameterType="com.bonus.sgzb.material.domain.CalMonthlyBean" useGeneratedKeys="true" keyProperty="id">
|
||||
INSERT INTO calc_project_month (MONTH) VALUES (#{month})
|
||||
INSERT INTO slt_project_month (month,create_time) VALUES (#{month},now())
|
||||
</insert>
|
||||
<insert id="insertProMonCosts" useGeneratedKeys="true" keyProperty="id">
|
||||
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>
|
||||
<insert id="insertProjectMonthDetail">
|
||||
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})
|
||||
</insert>
|
||||
<update id="updateProMonCosts">
|
||||
update project_month_costs set costs = #{costs} where id = #{id}
|
||||
</update>
|
||||
|
||||
<select id="getCalcRecords" parameterType="com.bonus.sgzb.material.domain.CalMonthlyBean" resultType="com.bonus.sgzb.material.domain.CalMonthlyBean">
|
||||
select id,month from calc_project_month
|
||||
where month = #{month}
|
||||
</select>
|
||||
<select id="getMonthCosts" resultType="com.bonus.sgzb.material.domain.ProjectMonthCosts">
|
||||
SELECT
|
||||
pmc.id as id,
|
||||
bui.unit_name AS unitName,
|
||||
bp.lot_name AS projectName,
|
||||
spm.month as month,
|
||||
pmc.cost_bearing_party as costBearingParty,
|
||||
pmc.costs as costs
|
||||
FROM
|
||||
project_month_costs pmc
|
||||
LEFT JOIN slt_project_month spm ON pmc.slt_month_id = spm.id
|
||||
LEFT JOIN bm_agreement_info bai ON pmc.agreement_id = bai.agreement_id
|
||||
LEFT JOIN bm_project_lot bp ON bp.lot_id = bai.project_id
|
||||
LEFT JOIN bm_unit_info bui ON bui.unit_id = bai.unit_id
|
||||
WHERE
|
||||
spm.month = DATE_FORMAT(#{endTime}, '%Y-%m')
|
||||
</select>
|
||||
<select id="getMonthDetails" resultType="com.bonus.sgzb.material.domain.ProjectMonthDetail">
|
||||
SELECT
|
||||
mt1.type_name AS typeName,
|
||||
mt.type_name AS modelName,
|
||||
bui.unit_name AS unitName,
|
||||
bp.lot_name AS projectName,
|
||||
mt.unit_name AS nuitName,
|
||||
pmd.num as num,
|
||||
pmc.cost_bearing_party as costBearingParty,
|
||||
pmc.`month` as month,
|
||||
pmd.lease_price as leasePrice,
|
||||
DATE_FORMAT( pmd.start_time, '%Y-%m-%d' ) as startTime,
|
||||
DATE_FORMAT( pmd.end_time, '%Y-%m-%d' ) as endTime,
|
||||
pmd.slt_days as leaseDays,
|
||||
pmd.slt_costs as costs,
|
||||
pmd.month_temporarily_costs as realCosts
|
||||
FROM
|
||||
project_month_detail pmd
|
||||
LEFT JOIN project_month_costs pmc ON pmd.pro_month_cost_id = pmc.id
|
||||
LEFT JOIN bm_unit_info bui ON bui.unit_id = pmc.unit_id
|
||||
LEFT JOIN bm_project_lot bp ON bp.lot_id = pmc.project_id
|
||||
LEFT JOIN ma_type mt ON pmd.type_id = mt.type_id
|
||||
LEFT JOIN ma_type mt1 ON mt.parent_id = mt1.type_id
|
||||
LEFT JOIN ma_machine mm ON mm.ma_id = pmd.ma_id
|
||||
WHERE
|
||||
pmc.id = #{id}
|
||||
</select>
|
||||
|
||||
<delete id="deleteCalcRecord" parameterType="com.bonus.sgzb.material.domain.CalMonthlyBean">
|
||||
delete from calc_project_month
|
||||
|
|
|
|||
|
|
@ -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}
|
||||
<if test="bean.costBearingParty != null and bean.costBearingParty != ''">
|
||||
AND lai.cost_bearing_party = #{bean.costBearingParty}
|
||||
</if>
|
||||
AND sai.id IN
|
||||
<foreach collection="ids" item="id" open="(" separator="," close=")">
|
||||
#{id}
|
||||
|
|
@ -447,26 +449,21 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|||
</select>
|
||||
<select id="getLeaseListMonth" resultType="com.bonus.sgzb.base.api.domain.SltAgreementInfo">
|
||||
SELECT
|
||||
DATE_FORMAT( DATE_ADD( sai.start_time, INTERVAL 1 MONTH ), '%Y-%m' ) month,
|
||||
(
|
||||
CASE
|
||||
DATE_FORMAT( DATE_ADD( sai.start_time, INTERVAL 1 MONTH ), '%Y-%m' ) MONTH,
|
||||
|
||||
(CASE
|
||||
WHEN DATE_FORMAT( DATE_SUB( sai.start_time, INTERVAL 1 MONTH ), '%Y-%m-21' ) >= DATE( sai.start_time ) THEN
|
||||
DATE_FORMAT( DATE_SUB( sai.start_time, INTERVAL 1 MONTH ), '%Y-%m-21' )
|
||||
WHEN DATE_FORMAT( DATE_SUB( sai.start_time, INTERVAL 1 MONTH ), '%Y-%m-21' ) < DATE( sai.start_time ) THEN
|
||||
DATE( sai.start_time )
|
||||
END
|
||||
) AS beginTime,
|
||||
(
|
||||
CASE
|
||||
DATE_FORMAT( DATE_SUB( sai.start_time, INTERVAL 1 MONTH ), '%Y-%m-21' ) ELSE DATE( sai.start_time )
|
||||
END) AS beginTime,
|
||||
|
||||
(CASE
|
||||
WHEN DATE_FORMAT( DATE_ADD( sai.start_time, INTERVAL 1 MONTH ), '%Y-%m-20' ) >= DATE( COALESCE ( sai.end_time, CURDATE() ) ) THEN
|
||||
DATE( COALESCE ( sai.end_time, CURDATE()))
|
||||
WHEN DATE_FORMAT( DATE_ADD( sai.start_time, INTERVAL 1 MONTH ), '%Y-%m-20' ) < DATE( COALESCE ( sai.end_time, CURDATE() ) ) THEN
|
||||
DATE_FORMAT( DATE_ADD( sai.start_time, INTERVAL 1 MONTH ), '%Y-%m-20')
|
||||
END
|
||||
) AS offTime,
|
||||
GROUP_CONCAT(sai.id) AS ids,
|
||||
DATE(
|
||||
COALESCE (
|
||||
sai.end_time,
|
||||
CURDATE())) ELSE DATE_FORMAT( DATE_ADD( sai.start_time, INTERVAL 1 MONTH ), '%Y-%m-20' )
|
||||
END) AS offTime,
|
||||
GROUP_CONCAT( sai.id ) AS ids,
|
||||
sai.agreement_id AS agreementId,
|
||||
bui.unit_name AS unitName,
|
||||
bp.lot_name AS projectName,
|
||||
|
|
@ -484,7 +481,6 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|||
WHERE
|
||||
sai.agreement_id = #{agreementId}
|
||||
AND sai.lease_type = 0
|
||||
AND lai.cost_bearing_party = #{costBearingParty}
|
||||
AND (-- 当前月21号到月末
|
||||
( DAYOFMONTH( sai.start_time ) >= 21 AND DAYOFMONTH( sai.start_time ) <= 31 )
|
||||
OR -- 次月1号到20号
|
||||
|
|
@ -497,10 +493,29 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|||
CURDATE())))
|
||||
)
|
||||
GROUP BY
|
||||
DATE_FORMAT( DATE_ADD( DATE( sai.start_time ), INTERVAL 1 - DAYOFMONTH( sai.start_time ) DAY ), '%Y-%m' ),
|
||||
(
|
||||
CASE
|
||||
|
||||
WHEN DATE_FORMAT( DATE_SUB( sai.start_time, INTERVAL 1 MONTH ), '%Y-%m-21' ) >= DATE( sai.start_time ) THEN
|
||||
DATE_FORMAT( DATE_SUB( sai.start_time, INTERVAL 1 MONTH ), '%Y-%m-21' ) ELSE DATE( sai.start_time )
|
||||
END
|
||||
),
|
||||
(
|
||||
CASE
|
||||
|
||||
WHEN DATE_FORMAT( DATE_ADD( sai.start_time, INTERVAL 1 MONTH ), '%Y-%m-20' ) >= DATE( COALESCE ( sai.end_time, CURDATE() ) ) THEN
|
||||
DATE(
|
||||
COALESCE (
|
||||
sai.end_time,
|
||||
CURDATE())) ELSE DATE_FORMAT( DATE_ADD( sai.start_time, INTERVAL 1 MONTH ), '%Y-%m-20' )
|
||||
END
|
||||
),
|
||||
lai.cost_bearing_party
|
||||
ORDER BY
|
||||
DATE_FORMAT( DATE_ADD( DATE( sai.start_time ), INTERVAL 1 - DAYOFMONTH( sai.start_time ) DAY ), '%Y-%m' )
|
||||
DATE_FORMAT(
|
||||
DATE_ADD( DATE( sai.start_time ), INTERVAL 1 - DAYOFMONTH( sai.start_time ) DAY ),
|
||||
'%Y-%m'
|
||||
)
|
||||
</select>
|
||||
<select id="getLeaseListMonthNotNull" resultType="com.bonus.sgzb.base.api.domain.SltAgreementInfo">
|
||||
SELECT
|
||||
|
|
@ -518,7 +533,9 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|||
GROUP_CONCAT(sai.id) AS ids,
|
||||
sai.agreement_id AS agreementId,
|
||||
bui.unit_name AS unitName,
|
||||
bui.unit_id AS unitId,
|
||||
bp.lot_name AS projectName,
|
||||
bp.lot_id AS lotId,
|
||||
DATE( sai.start_time ) AS startTime,
|
||||
lai.cost_bearing_party AS costBearingParty,
|
||||
DATE( COALESCE ( sai.end_time, CURDATE() ) ) AS endTime
|
||||
|
|
@ -531,16 +548,25 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|||
LEFT JOIN ma_type mt ON sai.type_id = mt.type_id
|
||||
LEFT JOIN ma_type mt1 ON mt.parent_id = mt1.type_id
|
||||
WHERE
|
||||
sai.agreement_id = 49
|
||||
sai.agreement_id = #{agreementId}
|
||||
AND sai.lease_type = 0
|
||||
AND lai.cost_bearing_party = #{costBearingParty}
|
||||
AND sai.start_time <= #{endTime} AND sai.end_time >= #{startTime}
|
||||
AND sai.start_time <= #{endTime} AND sai.end_time >= #{startTime}
|
||||
<if test="costBearingParty != null and costBearingParty != ''">
|
||||
AND lai.cost_bearing_party = #{costBearingParty}
|
||||
</if>
|
||||
AND sai.start_time <= #{endTime}
|
||||
AND (sai.end_time >= #{startTime} OR sai.end_time IS NULL)
|
||||
GROUP BY
|
||||
DATE_FORMAT( DATE_ADD( DATE( sai.start_time ), INTERVAL 1 - DAYOFMONTH( sai.start_time ) DAY ), '%Y-%m' ),
|
||||
( CASE WHEN #{startTime} >= DATE( sai.start_time ) THEN #{startTime} ELSE DATE( sai.start_time ) END ),
|
||||
CASE
|
||||
WHEN #{endTime} >= DATE( COALESCE ( sai.end_time, CURDATE() ) ) THEN
|
||||
DATE(
|
||||
COALESCE (
|
||||
sai.end_time,
|
||||
CURDATE())) ELSE #{endTime}
|
||||
END,
|
||||
lai.cost_bearing_party
|
||||
ORDER BY
|
||||
DATE_FORMAT( DATE_ADD( DATE( sai.start_time ), INTERVAL 1 - DAYOFMONTH( sai.start_time ) DAY ), '%Y-%m' );
|
||||
DATE_FORMAT( DATE_ADD( DATE( sai.start_time ), INTERVAL 1 - DAYOFMONTH( sai.start_time ) DAY ), '%Y-%m' )
|
||||
</select>
|
||||
<select id="getPreScrapDetailsList" resultType="com.bonus.sgzb.base.api.domain.SltAgreementInfo">
|
||||
select tta.agreement_id as agreementId,
|
||||
|
|
|
|||
|
|
@ -14,4 +14,7 @@ public class AgreementVo {
|
|||
|
||||
/** 协议编号*/
|
||||
private String agreementCode;
|
||||
|
||||
/** 是否结算*/
|
||||
private String isSlt;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -195,7 +195,8 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|||
<!--往来单位id和标段工程id获取协议信息-->
|
||||
<select id="getAgreementInfoById" resultType="com.bonus.sgzb.system.domain.AgreementVo">
|
||||
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'
|
||||
</select>
|
||||
|
|
|
|||
Loading…
Reference in New Issue