diff --git a/bonus-modules/bonus-material/src/main/java/com/bonus/material/push/controller/IwsCostPushController.java b/bonus-modules/bonus-material/src/main/java/com/bonus/material/push/controller/IwsCostPushController.java index a4d72d3f..a5f11704 100644 --- a/bonus-modules/bonus-material/src/main/java/com/bonus/material/push/controller/IwsCostPushController.java +++ b/bonus-modules/bonus-material/src/main/java/com/bonus/material/push/controller/IwsCostPushController.java @@ -181,7 +181,7 @@ public class IwsCostPushController extends BaseController { } SltAgreementInfo sltAgreementInfo = new SltAgreementInfo(); try { - sltAgreementInfo.setAgreementId(Long.valueOf(obj.getAgreementId())); + sltAgreementInfo.setAgreementId(obj.getAgreementId()); List loseList = sltAgreementInfoService.getLoseList(sltAgreementInfo); return getDataTable(loseList); } catch (NumberFormatException e) { @@ -203,7 +203,7 @@ public class IwsCostPushController extends BaseController { } SltAgreementInfo sltAgreementInfo = new SltAgreementInfo(); try { - sltAgreementInfo.setAgreementId(Long.valueOf(obj.getAgreementId())); + sltAgreementInfo.setAgreementId(obj.getAgreementId()); List scrapList = sltAgreementInfoService.getScrapList(sltAgreementInfo); return getDataTable(scrapList); } catch (NumberFormatException e) { @@ -214,7 +214,7 @@ public class IwsCostPushController extends BaseController { @PostMapping("/computeTheMonthCost") @ApiOperation("计算当月费用") - public AjaxResult computeTheMonthCost(@Valid @RequestBody IwsCostPushBean obj) { + public AjaxResult computeTheMonthCost(@RequestBody IwsCostPushBean obj) { return iwsCostPushService.computeTheMonthCost(obj); } diff --git a/bonus-modules/bonus-material/src/main/java/com/bonus/material/push/domain/IwsCostPushBean.java b/bonus-modules/bonus-material/src/main/java/com/bonus/material/push/domain/IwsCostPushBean.java index d010cbbb..8dde7158 100644 --- a/bonus-modules/bonus-material/src/main/java/com/bonus/material/push/domain/IwsCostPushBean.java +++ b/bonus-modules/bonus-material/src/main/java/com/bonus/material/push/domain/IwsCostPushBean.java @@ -34,7 +34,7 @@ public class IwsCostPushBean implements Serializable { private String agreementCode; // 协议id - private String agreementId; + private Long agreementId; private String projectId; @@ -77,6 +77,8 @@ public class IwsCostPushBean implements Serializable { private BigDecimal leaseMoney; + private BigDecimal consumeMoney; + private BigDecimal lostMoney; private BigDecimal scrapMoney; @@ -96,6 +98,10 @@ public class IwsCostPushBean implements Serializable { @NotBlank(message = "月份不能为空") private String month; + // 月份数据库对应ID + @ApiModelProperty(value = "结算月份表主键ID") + private Integer taskId; + private String type; /** @@ -116,6 +122,9 @@ public class IwsCostPushBean implements Serializable { @Excel(name = "是否结算", readConverterExp = "0=未结算,1=已结算", sort = 6) private Byte isSettlement = 0; + @Excel(name = "结算类型", readConverterExp = "1=工器具,2=安全工器具") + private Byte settlementType; + // 结算时间 @Excel(name = "结算时间", dateFormat = "yyyy-MM-dd HH:mm:ss", sort = 7) @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8") diff --git a/bonus-modules/bonus-material/src/main/java/com/bonus/material/push/mapper/IwsCostPushMapper.java b/bonus-modules/bonus-material/src/main/java/com/bonus/material/push/mapper/IwsCostPushMapper.java index 9258930f..c3c48469 100644 --- a/bonus-modules/bonus-material/src/main/java/com/bonus/material/push/mapper/IwsCostPushMapper.java +++ b/bonus-modules/bonus-material/src/main/java/com/bonus/material/push/mapper/IwsCostPushMapper.java @@ -3,7 +3,9 @@ package com.bonus.material.push.mapper; import com.bonus.material.clz.domain.vo.MaterialRetainedEquipmentInfo; import com.bonus.material.clz.domain.vo.lease.LeaseTotalInfo; import com.bonus.material.push.domain.IwsCostPushBean; +import com.bonus.material.settlement.domain.vo.PeriodCostResultVo; import org.apache.ibatis.annotations.Mapper; +import org.apache.ibatis.annotations.Param; import java.util.List; @@ -38,9 +40,14 @@ public interface IwsCostPushMapper { int insertCalcMonthRecord(IwsCostPushBean record); /** - * 插入项目月费用数据 -- 批量 + * 插入项目月费用info数据 -- 批量 */ - int insertProjectMonthCosts(List recordList); + int insertProjectMonthCosts(List list); + + /** + * 插入项目月费用details数据 -- 批量 + */ + int insertProjectMonthCostsDetails(@Param("list") List list); /** * 根据协议ID查询领用物资数据 diff --git a/bonus-modules/bonus-material/src/main/java/com/bonus/material/push/service/impl/CostPushServiceImpl.java b/bonus-modules/bonus-material/src/main/java/com/bonus/material/push/service/impl/CostPushServiceImpl.java index 891d22ef..98834e16 100644 --- a/bonus-modules/bonus-material/src/main/java/com/bonus/material/push/service/impl/CostPushServiceImpl.java +++ b/bonus-modules/bonus-material/src/main/java/com/bonus/material/push/service/impl/CostPushServiceImpl.java @@ -27,6 +27,9 @@ import java.util.stream.Collectors; @Service public class CostPushServiceImpl implements CostPushService { + // 工器具费用推送接口 + public static final String GQJ_PUSH_URL = "http://10.138.55.113:8036/micro-server/zygqj/syncProjectCostsData"; + @Autowired private CostPushMapper dao; @@ -90,9 +93,7 @@ public class CostPushServiceImpl implements CostPushService { @Override public List findDetails(CostPushBean o) { List list = dao.findDetails(o); - if (list == null || list.size() <= 0) { - return list; - } else { + if (list != null && !list.isEmpty()) { double total = 0; for (CostPushBean bean : list) { String leaseMoney = bean.getLeaseMoney(); @@ -102,8 +103,8 @@ public class CostPushServiceImpl implements CostPushService { newBean.setLeaseMoney(String.format("%.2f", total)); newBean.setProjectName("合计费用"); list.add(newBean); - return list; } + return list; } @Override diff --git a/bonus-modules/bonus-material/src/main/java/com/bonus/material/push/service/impl/IwsCostPushServiceImpl.java b/bonus-modules/bonus-material/src/main/java/com/bonus/material/push/service/impl/IwsCostPushServiceImpl.java index 3f98ec1c..e6869887 100644 --- a/bonus-modules/bonus-material/src/main/java/com/bonus/material/push/service/impl/IwsCostPushServiceImpl.java +++ b/bonus-modules/bonus-material/src/main/java/com/bonus/material/push/service/impl/IwsCostPushServiceImpl.java @@ -2,6 +2,7 @@ package com.bonus.material.push.service.impl; import com.alibaba.nacos.common.utils.CollectionUtils; import com.bonus.common.biz.config.DateTimeHelper; +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.material.clz.domain.vo.MaterialRetainedEquipmentInfo; @@ -10,6 +11,9 @@ import com.bonus.material.push.domain.IwsCostPushBean; import com.bonus.material.push.mapper.IwsCostPushMapper; import com.bonus.material.push.service.IwsCostPushService; import com.bonus.material.settlement.domain.SltAgreementInfo; +import com.bonus.material.settlement.domain.dto.PeriodCostQueryDto; +import com.bonus.material.settlement.domain.vo.PeriodCostResultVo; +import com.bonus.material.settlement.domain.vo.PeriodCostSummaryVo; import com.bonus.material.settlement.domain.vo.SltInfoVo; import com.bonus.material.settlement.service.ISltAgreementInfoService; import org.springframework.stereotype.Service; @@ -19,6 +23,7 @@ import java.math.BigDecimal; import java.math.RoundingMode; import java.time.LocalDate; import java.time.LocalDateTime; +import java.time.ZoneId; import java.time.format.DateTimeFormatter; import java.time.temporal.ChronoUnit; import java.time.temporal.TemporalAdjusters; @@ -86,7 +91,15 @@ public class IwsCostPushServiceImpl implements IwsCostPushService { // 获取当月第一天的日期和最后一天日期 LocalDateTime firstDayOfMonth = getFirstDayOfMonth(month); LocalDateTime lastDayOfMonth = getLastDayOfMonthZ(month); + ZoneId zone = ZoneId.systemDefault(); + // 当月第一天 + LocalDate firstDay = LocalDate.now().withDayOfMonth(1); + Date firstDate = Date.from(firstDay.atStartOfDay(zone).toInstant()); + // 当月最后一天 + LocalDate lastDay = LocalDate.now().withDayOfMonth(LocalDate.now().lengthOfMonth()); + Date lastDate = Date.from(lastDay.atStartOfDay(zone).toInstant()); + // 塞入当前年月到参数中 costDto.setMonth(month); // 清除旧的费用计算数据 @@ -94,13 +107,123 @@ public class IwsCostPushServiceImpl implements IwsCostPushService { // 插入新的当前月份,并生成记录id iwsCostPushMapper.insertCalcMonthRecord(costDto); + // 查询协议信息列表 List agreementList = iwsCostPushMapper.findAgreement(costDto); - // 处理数据,计算4项费用 - computeMonthInfoDetail(agreementList, month, firstDayOfMonth, lastDayOfMonth); - // 存入数据库 - agreementList.forEach(item -> item.setMonth(month)); - int addProjectMonthCostsMapperResult = iwsCostPushMapper.insertProjectMonthCosts(agreementList); + // 过滤掉空数据 + agreementList.removeIf(Objects::isNull); + + // 处理数据,首先把已结算和未结算的协议数据分组处理 + Map> agreementListMap = agreementList.stream().collect(Collectors.groupingBy(IwsCostPushBean::getIsSettlement)); + // 过滤拿已结算协议列表 + List settlementAgreementList = agreementListMap.getOrDefault((byte) 1, Collections.emptyList()); + // 过滤拿未结算协议列表 + List unsettlementAgreementList = agreementListMap.getOrDefault((byte) 0, Collections.emptyList()); + + /// ------------------------- 未结算协议 ------------------- + // 计算未结算协议 ---- (工器具)租赁费用info列表及details明细 + List unsettlementEquipmentLeaseCosts = sltAgreementInfoService.selectPeriodCostSummary(new PeriodCostQueryDto() + .setAgreementIds(unsettlementAgreementList.stream().map(IwsCostPushBean::getAgreementId).collect(Collectors.toList())) + .setStartDate(firstDate).setEndDate(lastDate) + .setSltManageType((byte) 1) + ); + List unsettlementEquipmentLeaseCostsDetails = sltAgreementInfoService.selectPeriodCostList(new PeriodCostQueryDto() + .setAgreementIds(unsettlementAgreementList.stream().map(IwsCostPushBean::getAgreementId).collect(Collectors.toList())) + .setStartDate(firstDate).setEndDate(lastDate) + .setSltManageType((byte) 1) + ); + // 计算未结算协议 ---- (安全工器具)租赁费用info列表及details明细 + List unsettlementSafetyEquipmentLeaseCosts = sltAgreementInfoService.selectPeriodCostSummary(new PeriodCostQueryDto() + .setAgreementIds(unsettlementAgreementList.stream().map(IwsCostPushBean::getAgreementId).collect(Collectors.toList())) + .setStartDate(firstDate).setEndDate(lastDate) + .setSltManageType((byte) 2) + ); + List unsettlementSafetyEquipmentLeaseCostsDetails = sltAgreementInfoService.selectPeriodCostList(new PeriodCostQueryDto() + .setAgreementIds(unsettlementAgreementList.stream().map(IwsCostPushBean::getAgreementId).collect(Collectors.toList())) + .setStartDate(firstDate).setEndDate(lastDate) + .setSltManageType((byte) 2) + ); + /// -------------------------- 未结算协议 -------------------- + + + /// ------------------------ 已经结算协议 ------------------- + // 已结算协议首先要删除掉不是本月结算的数据 + settlementAgreementList.removeIf(item -> + item.getSettlementTime().getMonth() != firstDayOfMonth.getMonth() || + item.getSettlementTime().getYear() != firstDayOfMonth.getYear() + ); + + // 计算已结算协议 ---- (工器具)租赁、维修、丢失、报废4项费用 + List settlementEquipmentCosts = sltAgreementInfoService.getSltReportedList(new SltAgreementInfo() + .setAgreementIds(settlementAgreementList.stream().map(IwsCostPushBean::getAgreementId).collect(Collectors.toList())) + .setStartTime(firstDate) + .setEndTime(lastDate) + .setSettlementType((byte) 1) + ); + + // 计算已结算协议 ---- (安全工器具)租赁、维修、丢失、报废4项费用 + List settlementSafetyEquipmentCosts = sltAgreementInfoService.getSltReportedList(new SltAgreementInfo() + .setAgreementIds(settlementAgreementList.stream().map(IwsCostPushBean::getAgreementId).collect(Collectors.toList())) + .setStartTime(firstDate) + .setEndTime(lastDate) + .setSettlementType((byte) 2) + ); + /// --------------- 已经结算协议 ----------------------- + + + // 分别进行转换后存入数据库 + List resultArray = new ArrayList<>(); + + // 转化未结算工器具费用 + for (PeriodCostSummaryVo vo : unsettlementEquipmentLeaseCosts) { + resultArray.add(new IwsCostPushBean() + .setAgreementId(vo.getAgreementId()).setTaskId(costDto.getTaskId()).setSettlementType((byte) 1) + .setLeaseMoney(vo.getTotalLeaseCost()) + ); + } + // 转化未结算安全工器具费用 + for (PeriodCostSummaryVo vo : unsettlementSafetyEquipmentLeaseCosts) { + resultArray.add(new IwsCostPushBean() + .setAgreementId(vo.getAgreementId()).setTaskId(costDto.getTaskId()).setSettlementType((byte) 2) + .setLeaseMoney(vo.getTotalLeaseCost()) + ); + } + // 转换已结算工器具费用 + for (SltAgreementInfo vo : settlementEquipmentCosts) { + resultArray.add(new IwsCostPushBean() + .setAgreementId(vo.getAgreementId()).setTaskId(costDto.getTaskId()).setSettlementType((byte) 1) + .setLeaseMoney(vo.getLeaseCost()).setRepairMoney(vo.getRepairCost()) + .setLostMoney(vo.getLoseCost()).setScrapMoney(vo.getScrapCost()) + ); + } + // 转换已结算安全工器具费用 + for (SltAgreementInfo vo : settlementSafetyEquipmentCosts) { + resultArray.add(new IwsCostPushBean() + .setAgreementId(vo.getAgreementId()).setTaskId(costDto.getTaskId()).setSettlementType((byte) 2) + .setLeaseMoney(vo.getLeaseCost()).setRepairMoney(vo.getRepairCost()) + .setLostMoney(vo.getLoseCost()).setScrapMoney(vo.getScrapCost()) + ); + } + + // 批量插入 -- 存入数据库info + int addProjectMonthCostsMapperResult = iwsCostPushMapper.insertProjectMonthCosts(resultArray); + // 批量插入 -- 存入数据库details + if (CollectionUtils.isNotEmpty(unsettlementEquipmentLeaseCostsDetails)) { + // 工器具类型的存入 + unsettlementEquipmentLeaseCostsDetails.forEach(item -> { + item.setTaskId(costDto.getTaskId()); + item.setEquipmentType((byte) 1); + }); + iwsCostPushMapper.insertProjectMonthCostsDetails(unsettlementEquipmentLeaseCostsDetails); + } + if (CollectionUtils.isNotEmpty(unsettlementSafetyEquipmentLeaseCostsDetails)) { + // 安全工器具类型的存入 + unsettlementSafetyEquipmentLeaseCostsDetails.forEach(item -> { + item.setTaskId(costDto.getTaskId()); + item.setEquipmentType((byte) 2); + }); + iwsCostPushMapper.insertProjectMonthCostsDetails(unsettlementSafetyEquipmentLeaseCostsDetails); + } return 0 < addProjectMonthCostsMapperResult ? AjaxResult.success("月结费用计算成功") : AjaxResult.error("月结费用计算失败"); } @@ -191,7 +314,7 @@ public class IwsCostPushServiceImpl implements IwsCostPushService { for (IwsCostPushBean agreement : agreementList) { // 协议id - String agreementId = agreement.getAgreementId(); + Long agreementId = agreement.getAgreementId(); // 更新协议推送状态 updatePushStatus(agreement); diff --git a/bonus-modules/bonus-material/src/main/java/com/bonus/material/settlement/domain/dto/PeriodCostQueryDto.java b/bonus-modules/bonus-material/src/main/java/com/bonus/material/settlement/domain/dto/PeriodCostQueryDto.java index 65f49857..b3d37d6f 100644 --- a/bonus-modules/bonus-material/src/main/java/com/bonus/material/settlement/domain/dto/PeriodCostQueryDto.java +++ b/bonus-modules/bonus-material/src/main/java/com/bonus/material/settlement/domain/dto/PeriodCostQueryDto.java @@ -4,6 +4,7 @@ import com.fasterxml.jackson.annotation.JsonFormat; import io.swagger.annotations.ApiModel; import io.swagger.annotations.ApiModelProperty; import lombok.Data; +import lombok.experimental.Accessors; import javax.validation.constraints.NotNull; import java.util.Date; @@ -17,6 +18,7 @@ import java.util.List; */ @Data @ApiModel("区间费用查询DTO") +@Accessors(chain = true) public class PeriodCostQueryDto { @ApiModelProperty(value = "开始日期", required = true) diff --git a/bonus-modules/bonus-material/src/main/java/com/bonus/material/settlement/domain/vo/PeriodCostResultVo.java b/bonus-modules/bonus-material/src/main/java/com/bonus/material/settlement/domain/vo/PeriodCostResultVo.java index 54afe21a..a41ed912 100644 --- a/bonus-modules/bonus-material/src/main/java/com/bonus/material/settlement/domain/vo/PeriodCostResultVo.java +++ b/bonus-modules/bonus-material/src/main/java/com/bonus/material/settlement/domain/vo/PeriodCostResultVo.java @@ -91,6 +91,12 @@ public class PeriodCostResultVo { @ApiModelProperty(value = "计量单位") private String mtUnitName; + @ApiModelProperty(value = "月份ID") + private Integer taskId; + + @ApiModelProperty(value = "机具类型 1工器具 2安全工器具") + private Byte equipmentType; + @ApiModelProperty(value = "备注") private String remark; } diff --git a/bonus-modules/bonus-material/src/main/java/com/bonus/material/settlement/service/ISltAgreementInfoService.java b/bonus-modules/bonus-material/src/main/java/com/bonus/material/settlement/service/ISltAgreementInfoService.java index da0e5e4e..2da2cdba 100644 --- a/bonus-modules/bonus-material/src/main/java/com/bonus/material/settlement/service/ISltAgreementInfoService.java +++ b/bonus-modules/bonus-material/src/main/java/com/bonus/material/settlement/service/ISltAgreementInfoService.java @@ -160,7 +160,7 @@ public interface ISltAgreementInfoService { AjaxResult getAgreementInfoById(SelectDto dto); /** - * 查询区间费用计算结果 + * 查询区间租赁费用计算明细 * * @param queryDto 查询条件 * @return 区间费用计算结果列表 @@ -168,7 +168,7 @@ public interface ISltAgreementInfoService { List selectPeriodCostList(PeriodCostQueryDto queryDto); /** - * 查询区间费用汇总结果(按协议汇总) + * 查询区间租赁费用汇总结果(按协议汇总) * * @param queryDto 查询条件 * @return 区间费用汇总结果列表 diff --git a/bonus-modules/bonus-material/src/main/java/com/bonus/material/settlement/service/impl/SltAgreementInfoServiceImpl.java b/bonus-modules/bonus-material/src/main/java/com/bonus/material/settlement/service/impl/SltAgreementInfoServiceImpl.java index a2c360d0..be683264 100644 --- a/bonus-modules/bonus-material/src/main/java/com/bonus/material/settlement/service/impl/SltAgreementInfoServiceImpl.java +++ b/bonus-modules/bonus-material/src/main/java/com/bonus/material/settlement/service/impl/SltAgreementInfoServiceImpl.java @@ -1086,9 +1086,11 @@ public class SltAgreementInfoServiceImpl implements ISltAgreementInfoService { } try { - // 查询当前登陆用户的结算管理权限 - Byte settlementType = this.checkLoginUserHasSettlementPermission(); - queryDto.setSltManageType(settlementType); + if (queryDto.getSltManageType() == null) { + // 查询当前登陆用户的结算管理权限 + Byte settlementType = this.checkLoginUserHasSettlementPermission(); + queryDto.setSltManageType(settlementType); + } // 从数据库查询基础数据 List rawResults = sltAgreementInfoMapper.selectLeasePeriodCostList(queryDto); @@ -1096,7 +1098,7 @@ public class SltAgreementInfoServiceImpl implements ISltAgreementInfoService { // 先过滤掉不在查询范围内的数据 List filteredResults = filterDataInRange(rawResults, queryDto.getStartDate(), queryDto.getEndDate()); - // 在Service层进行逻辑计算 + // 进行时间及费用计算统计 return calculatePeriodCosts(filteredResults, queryDto.getStartDate(), queryDto.getEndDate()); } catch (Exception e) { throw new ServiceException("查询区间费用失败:" + e.getMessage()); @@ -1138,19 +1140,15 @@ public class SltAgreementInfoServiceImpl implements ISltAgreementInfoService { Date settlementTime = result.getSettlementTime(); // 结算时间 // 如果是已结算协议 + boolean leaseInRange = isDateInRange(leaseStartTime, inputStartDate, inputEndDate); + boolean returnInRange = isDateInRange(returnTime, inputStartDate, inputEndDate); if ("1".equals(result.getIsSettled())) { // 检查领料时间、退料时间、结算时间是否有任何一个在查询范围内 - boolean leaseInRange = isDateInRange(leaseStartTime, inputStartDate, inputEndDate); - boolean returnInRange = isDateInRange(returnTime, inputStartDate, inputEndDate); boolean settlementInRange = isDateInRange(settlementTime, inputStartDate, inputEndDate); - return leaseInRange || returnInRange || settlementInRange; } else { // 如果是未结算协议 // 检查领料时间、退料时间是否有任何一个在查询范围内 - boolean leaseInRange = isDateInRange(leaseStartTime, inputStartDate, inputEndDate); - boolean returnInRange = isDateInRange(returnTime, inputStartDate, inputEndDate); - return leaseInRange || returnInRange; } } diff --git a/bonus-modules/bonus-material/src/main/resources/mapper/material/push/IwsCostPushMapper.xml b/bonus-modules/bonus-material/src/main/resources/mapper/material/push/IwsCostPushMapper.xml index 826071c9..51c2c171 100644 --- a/bonus-modules/bonus-material/src/main/resources/mapper/material/push/IwsCostPushMapper.xml +++ b/bonus-modules/bonus-material/src/main/resources/mapper/material/push/IwsCostPushMapper.xml @@ -8,13 +8,13 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" SELECT bp.pro_id AS projectId, bp.pro_name AS projectName, bp.pro_code AS projectCode, bu.unit_name AS unitName, - bma.agreement_id AS agreementId,bma.`agreement_code` AS agreementCode, bma.is_slt AS isSettlement, + bma.agreement_id AS agreementId,bma.`agreement_code` AS agreementCode, IF(saa.audit_time IS NULL,0,1) AS isSettlement, bma.sign_time AS signTime, bma.is_push AS isPush, saa.audit_time AS settlementTime FROM bm_agreement_info bma LEFT JOIN bm_project bp ON bp.pro_id = bma.project_id LEFT JOIN bm_unit bu ON bu.unit_id = bma.unit_id - LEFT JOIN slt_agreement_apply saa ON saa.agreement_id = bma.agreement_id AND bma.is_slt = 1 + LEFT JOIN slt_agreement_apply saa ON saa.agreement_id = bma.agreement_id AND bma.is_slt = 1 AND saa.`status` = '2' AND saa.settlement_type = #{settlementType} AND bma.agreement_code LIKE CONCAT('%',#{agreementCode},'%') @@ -43,14 +43,14 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" SELECT pmc.id AS id, pmc.AGREEMENT_ID AS agreementId, IF(ISNULL(pmc.check_status), 0, pmc.check_status) AS checkStatus, pmc.LEASE_MONEY AS leaseMoney, pmc.LOST_MONEY AS lostMoney, pmc.REPAIR_MONEY AS repairMoney, pmc.SCRAP_MONEY AS scrapMoney, - bma.agreement_code AS agreementCode, bma.is_slt AS isSettlement, - bp.pro_name AS projectName, - bu.unit_name AS unitName, + bma.agreement_code AS agreementCode, bma.is_slt AS isSettlement, pmc.TYPE AS settlementType, + bp.pro_name AS projectName, bu.unit_name AS unitName, ROUND( SUM(ifnull( pmc.LEASE_MONEY, 0 )+ ifnull( pmc.LOST_MONEY, 0 )+ ifnull( pmc.REPAIR_MONEY, 0 )+ ifnull( pmc.SCRAP_MONEY, 0 )), 2 ) AS money FROM project_month_costs pmc + LEFT JOIN calc_project_month cpm on pmc.task_id = cpm.id LEFT JOIN bm_agreement_info bma ON pmc.AGREEMENT_ID = bma.agreement_id LEFT JOIN bm_project bp ON bp.pro_id = bma.project_id LEFT JOIN bm_unit bu ON bu.unit_id = bma.unit_id @@ -71,12 +71,15 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" AND bma.is_slt = #{isSettlement} + + AND cpm.month = #{month} + GROUP BY - pmc.AGREEMENT_ID + pmc.AGREEMENT_ID, pmc.TYPE - + INSERT INTO calc_project_month (MONTH) VALUES (#{month}) @@ -109,22 +112,24 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" INSERT INTO project_month_costs( AGREEMENT_ID, LEASE_MONEY, + CONSUME_MONEY, LOST_MONEY, REPAIR_MONEY, SCRAP_MONEY, - CHECK_STATUS, - MONTH + TASK_ID, + TYPE ) VALUES ( #{item.agreementId}, #{item.leaseMoney}, + #{item.consumeMoney}, #{item.lostMoney}, #{item.repairMoney}, #{item.scrapMoney}, - #{item.checkStatus}, - #{item.month} + #{item.taskId}, + #{item.settlementType} ) @@ -395,4 +400,25 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" and mt2.type_name like concat('%',#{maTypeName},'%') + + + insert into project_month_info(agreementId, typeId, leaseNum, leaseDate, returnDate, + leasePrice, leaseMoney, taskId, buy_price, money, jiju_type) + values + + ( + #{item.agreementId}, + #{item.typeId}, + #{item.num}, + #{item.calcStartTime}, + #{item.calcEndTime}, + #{item.leasePrice}, + #{item.leaseCost}, + #{item.taskId}, + null, + 0.00, + #{item.equipmentType} + ) + + diff --git a/bonus-modules/bonus-material/src/main/resources/mapper/material/settlement/SltAgreementInfoMapper.xml b/bonus-modules/bonus-material/src/main/resources/mapper/material/settlement/SltAgreementInfoMapper.xml index da4647f7..58f98dc1 100644 --- a/bonus-modules/bonus-material/src/main/resources/mapper/material/settlement/SltAgreementInfoMapper.xml +++ b/bonus-modules/bonus-material/src/main/resources/mapper/material/settlement/SltAgreementInfoMapper.xml @@ -856,7 +856,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" and saa.status = '3' - GROUP BY bai.agreement_id + GROUP BY bai.agreement_id, bai.settlement_type ORDER BY saa.create_time desc @@ -1137,7 +1137,6 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" LEFT JOIN ma_type mt1 ON mt.parent_id = mt1.type_id AND mt1.`level` = '3' bai.status = '1' - AND sai.status IN ('0', '1') AND mt.jiju_type = #{sltManageType} AND bai.agreement_code LIKE concat('%',#{agreementCode},'%')