From a74a8a099e4de441d27b47c1595d2ef65db9bc18 Mon Sep 17 00:00:00 2001 From: syruan <15555146157@163.com> Date: Mon, 29 Sep 2025 16:56:44 +0800 Subject: [PATCH] =?UTF-8?q?=E5=A2=9E=E5=8A=A0=E7=BB=93=E7=AE=97=E7=94=B3?= =?UTF-8?q?=E8=AF=B7=E7=9B=B8=E5=85=B3=E5=8A=9F=E8=83=BD=EF=BC=8C=E4=BC=98?= =?UTF-8?q?=E5=8C=96=E6=9F=A5=E8=AF=A2=E9=80=BB=E8=BE=91=E5=8F=8A=E6=95=B0?= =?UTF-8?q?=E6=8D=AE=E5=A4=84=E7=90=86?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../clz/controller/BmProDepartController.java | 10 +- .../ClzSltAgreementInfoController.java | 85 ++-- .../material/clz/domain/ClzSltApplyDTO.java | 25 ++ .../material/clz/domain/MaterialDto.java | 3 +- .../domain/vo/MaterialSltAgreementInfo.java | 11 +- .../sltAgreementInfo/MaterialSltInfoVo.java | 10 +- .../clz/mapper/BmProDepartMapper.java | 10 - .../material/clz/mapper/BmTeamMapper.java | 12 - .../clz/mapper/ClzSltAgreementInfoMapper.java | 49 +-- .../service/ClzSltAgreementInfoService.java | 29 +- .../impl/ClzSltAgreementInfoServiceImpl.java | 385 +++++++++++++++--- .../common/domain/vo/AgreementVo.java | 9 +- .../settlement/domain/SltAgreementInfo.java | 3 + .../material/clz/ClzAgreementInfoMapper.xml | 116 ++++-- .../material/clz/MaterialMachineMapper.xml | 160 ++++---- .../material/lease/LeaseApplyInfoMapper.xml | 9 +- 16 files changed, 641 insertions(+), 285 deletions(-) create mode 100644 bonus-modules/bonus-material/src/main/java/com/bonus/material/clz/domain/ClzSltApplyDTO.java diff --git a/bonus-modules/bonus-material/src/main/java/com/bonus/material/clz/controller/BmProDepartController.java b/bonus-modules/bonus-material/src/main/java/com/bonus/material/clz/controller/BmProDepartController.java index 004be556..7828e79b 100644 --- a/bonus-modules/bonus-material/src/main/java/com/bonus/material/clz/controller/BmProDepartController.java +++ b/bonus-modules/bonus-material/src/main/java/com/bonus/material/clz/controller/BmProDepartController.java @@ -29,8 +29,6 @@ public class BmProDepartController extends BaseController { /** * 查询项目部列表信息 - * @param tbProDepart - * @return */ @ApiOperation(value = "分页查询项目部信息") @GetMapping("/list") @@ -67,8 +65,6 @@ public class BmProDepartController extends BaseController { /** * 编辑项目部 - * @param tbProDepart - * @return */ @ApiOperation(value = "编辑项目部数据") @PostMapping("/edit") @@ -83,8 +79,6 @@ public class BmProDepartController extends BaseController { /** * 删除项目部 - * @param tbProDepart - * @return */ @ApiOperation(value = "删除项目部数据") @PostMapping("/delete") @@ -99,15 +93,13 @@ public class BmProDepartController extends BaseController { /** * 导出项目部管理列表 - * @param response - * @param tbProDepart */ @ApiOperation(value = "导出项目部管理列表") @PostMapping("/export") public void export(HttpServletResponse response, BmProDepart tbProDepart) { List list = bmProDepartService.queryByPage(tbProDepart); - ExcelUtil util = new ExcelUtil(BmProDepart.class); + ExcelUtil util = new ExcelUtil<>(BmProDepart.class); util.exportExcel(response, list, "项目部管理数据"); } } diff --git a/bonus-modules/bonus-material/src/main/java/com/bonus/material/clz/controller/ClzSltAgreementInfoController.java b/bonus-modules/bonus-material/src/main/java/com/bonus/material/clz/controller/ClzSltAgreementInfoController.java index d3e1e224..c8c2593e 100644 --- a/bonus-modules/bonus-material/src/main/java/com/bonus/material/clz/controller/ClzSltAgreementInfoController.java +++ b/bonus-modules/bonus-material/src/main/java/com/bonus/material/clz/controller/ClzSltAgreementInfoController.java @@ -1,34 +1,31 @@ package com.bonus.material.clz.controller; +import cn.hutool.core.collection.CollectionUtil; +import com.alibaba.nacos.common.utils.StringUtils; +import com.bonus.common.core.exception.ServiceException; import com.bonus.common.core.web.controller.BaseController; import com.bonus.common.core.web.domain.AjaxResult; import com.bonus.common.core.web.page.TableDataInfo; import com.bonus.material.basic.domain.BmProject; +import com.bonus.material.clz.domain.ClzSltApplyDTO; import com.bonus.material.clz.domain.vo.MaterialSltAgreementInfo; import com.bonus.material.clz.domain.vo.sltAgreementInfo.MaterialSltInfoVo; import com.bonus.material.clz.service.ClzSltAgreementInfoService; import com.bonus.material.common.domain.dto.SelectDto; -import com.bonus.material.settlement.domain.SltAgreementReduce; -import com.bonus.material.settlement.domain.SltAgreementRelation; +import com.bonus.material.settlement.domain.SltAgreementInfo; +import com.bonus.material.settlement.domain.vo.SltInfoVo; import com.bonus.material.task.domain.TmTask; import com.bonus.material.task.mapper.TmTaskMapper; import io.swagger.annotations.Api; import io.swagger.annotations.ApiOperation; import lombok.extern.slf4j.Slf4j; -import org.apache.commons.lang3.StringUtils; +import org.checkerframework.checker.units.qual.A; import org.springframework.web.bind.annotation.*; import javax.annotation.Resource; -import java.math.BigDecimal; import java.util.ArrayList; -import java.util.HashSet; import java.util.List; -import java.util.Set; -/** - * @Author ma_sh - * @create 2025/6/27 15:18 - */ @Api(tags = "材料站结算申请接口") @RestController @RequestMapping("/material_sltAgreementInfo") @@ -38,13 +35,10 @@ public class ClzSltAgreementInfoController extends BaseController { @Resource private ClzSltAgreementInfoService clzSltAgreementInfoService; - @Resource - private TmTaskMapper taskMapper; - /** - * 根据条件获取协议结算列表 + * 查询协议结算列表 */ - @ApiOperation(value = "根据条件获取协议结算列表") + @ApiOperation(value = "查询协议结算列表") @GetMapping("/getSltAgreementInfo4Project") public TableDataInfo getSltAgreementInfo4Project(MaterialSltAgreementInfo bean) { startPage(); @@ -64,28 +58,36 @@ public class ClzSltAgreementInfoController extends BaseController { return clzSltAgreementInfoService.getAgreementInfoById(dto); } - @ApiOperation(value = "根据协议获取结算清单") + @ApiOperation(value = "根据工程及单位查询待结算明细") @PostMapping("/getSltInfo") - public AjaxResult getSltInfo(@RequestBody List list) { - List unitNames = new ArrayList<>(); - List projectNames = new ArrayList<>(); - List dataList = new ArrayList<>(); - MaterialSltInfoVo bean = new MaterialSltInfoVo(); - Long agreementId = null; - for (MaterialSltAgreementInfo info : list) { - unitNames.add(info.getUnitName()); - projectNames.add(info.getProjectName()); - MaterialSltInfoVo vo = clzSltAgreementInfoService.getSltInfo(info); - dataList.add(vo); - agreementId = info.getAgreementId(); + public AjaxResult getSltInfo(@RequestBody ClzSltApplyDTO requestDto) { + if (requestDto == null) { + throw new ServiceException("请求参数不能为空!"); } - bean = clzSltAgreementInfoService.mergerData(bean, dataList,unitNames,projectNames); - // 根据协议id获取申请时间 - TmTask tmTask = taskMapper.selectTaskByIdByCl(agreementId); - if (tmTask != null) { - bean.setApplyTime(tmTask.getCreateTime()); + if (requestDto.getProjectId() == null || CollectionUtil.isEmpty(requestDto.getUnitIds())) { + throw new ServiceException("缺少结算申请参数!"); } - return AjaxResult.success(bean); + + // 业务处理 + List sltInfoVoList = clzSltAgreementInfoService.getSltDetailsByUnitsAndProject(requestDto); + + return AjaxResult.success(sltInfoVoList); + } + + @ApiOperation(value = "根据结算单号查询已提交的结算信息") + @PostMapping("/getSettledInfo") + public AjaxResult getSettledDetailsByApplyCode(@RequestBody MaterialSltAgreementInfo requestDto) { + if (requestDto == null) { + throw new ServiceException("请求参数不能为空!"); + } + if (StringUtils.isBlank(requestDto.getSltApplyCode())) { + throw new ServiceException("缺少结算查询参数!"); + } + + // 业务处理 + List resultList = clzSltAgreementInfoService.getSettledDetailsByApplyCode(requestDto); + + return AjaxResult.success(resultList); } @@ -98,7 +100,22 @@ public class ClzSltAgreementInfoController extends BaseController { try { return toAjax(clzSltAgreementInfoService.submitCosts(sltInfoVo)); } catch (Exception e) { + System.err.println(e.getMessage()); + log.error(e.getMessage(), e); return error("系统错误, " + e.getMessage()); } } + + /** + * 结算审批列表 + */ + @ApiOperation(value = "结算审批列表") + @GetMapping("/getSltList") + public TableDataInfo getSltList(SltAgreementInfo bean) { + startPage(); + List list = clzSltAgreementInfoService.getSltList(bean); + return getDataTable(list); + } + + } diff --git a/bonus-modules/bonus-material/src/main/java/com/bonus/material/clz/domain/ClzSltApplyDTO.java b/bonus-modules/bonus-material/src/main/java/com/bonus/material/clz/domain/ClzSltApplyDTO.java new file mode 100644 index 00000000..8e286723 --- /dev/null +++ b/bonus-modules/bonus-material/src/main/java/com/bonus/material/clz/domain/ClzSltApplyDTO.java @@ -0,0 +1,25 @@ +package com.bonus.material.clz.domain; + +import com.bonus.common.biz.domain.BaseVO; +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; +import lombok.EqualsAndHashCode; + +import java.util.List; + +/** + * 材料站结算申请Dto + */ +@EqualsAndHashCode(callSuper = false) +@Data +public class ClzSltApplyDTO extends BaseVO { + + @ApiModelProperty("申请结算单位") + private List unitIds; + + @ApiModelProperty("申请结算工程") + private Integer projectId; + + @ApiModelProperty("结算单号") + private String sltApplyCode; +} diff --git a/bonus-modules/bonus-material/src/main/java/com/bonus/material/clz/domain/MaterialDto.java b/bonus-modules/bonus-material/src/main/java/com/bonus/material/clz/domain/MaterialDto.java index 93d4e49a..94af6535 100644 --- a/bonus-modules/bonus-material/src/main/java/com/bonus/material/clz/domain/MaterialDto.java +++ b/bonus-modules/bonus-material/src/main/java/com/bonus/material/clz/domain/MaterialDto.java @@ -7,6 +7,7 @@ import io.swagger.annotations.ApiModelProperty; import lombok.Data; import org.springframework.format.annotation.DateTimeFormat; +import java.io.Serializable; import java.math.BigDecimal; import java.util.Date; import java.util.List; @@ -18,7 +19,7 @@ import java.util.List; */ @ApiModel(description = "保有设备总量查询") @Data -public class MaterialDto { +public class MaterialDto implements Serializable { private static final long serialVersionUID = 2227217051604273598L; diff --git a/bonus-modules/bonus-material/src/main/java/com/bonus/material/clz/domain/vo/MaterialSltAgreementInfo.java b/bonus-modules/bonus-material/src/main/java/com/bonus/material/clz/domain/vo/MaterialSltAgreementInfo.java index 113dc681..48cf1e55 100644 --- a/bonus-modules/bonus-material/src/main/java/com/bonus/material/clz/domain/vo/MaterialSltAgreementInfo.java +++ b/bonus-modules/bonus-material/src/main/java/com/bonus/material/clz/domain/vo/MaterialSltAgreementInfo.java @@ -32,7 +32,6 @@ public class MaterialSltAgreementInfo extends BaseEntity { @ApiModelProperty(value = "协议id") private Long agreementId; - /** * 协议编号 */ @@ -40,6 +39,16 @@ public class MaterialSltAgreementInfo extends BaseEntity { @ApiModelProperty(value = "协议编号") private String agreementCode; + @ApiModelProperty("协议签订时间") + private String signTime; + + @ApiModelProperty("结算单号") + private String sltApplyCode; + + @ApiModelProperty("结算费用类型 1租赁") + private Integer sltType; + + /** 机具规格id */ @Excel(name = "机具规格id") @ApiModelProperty(value = "机具规格id") diff --git a/bonus-modules/bonus-material/src/main/java/com/bonus/material/clz/domain/vo/sltAgreementInfo/MaterialSltInfoVo.java b/bonus-modules/bonus-material/src/main/java/com/bonus/material/clz/domain/vo/sltAgreementInfo/MaterialSltInfoVo.java index 8ec3a40c..d336c87b 100644 --- a/bonus-modules/bonus-material/src/main/java/com/bonus/material/clz/domain/vo/sltAgreementInfo/MaterialSltInfoVo.java +++ b/bonus-modules/bonus-material/src/main/java/com/bonus/material/clz/domain/vo/sltAgreementInfo/MaterialSltInfoVo.java @@ -12,10 +12,6 @@ import java.math.BigDecimal; import java.util.Date; import java.util.List; -/** - * @author c liu - * @date 2024/2/23 - */ @Data public class MaterialSltInfoVo { @@ -100,22 +96,22 @@ public class MaterialSltInfoVo { private Date updateTime; /** 协议id */ - @ApiModelProperty(value = "协议id") private Long agreementId; /** * 协议编号 */ - @ApiModelProperty(value = "协议编号") private String agreementCode; /** 协议 ids */ - @ApiModelProperty(value = "协议ids") private Long[] agreementIds; + @ApiModelProperty("结算申请单") + private String sltApplyCode; + private Long id; //申请id String cost; diff --git a/bonus-modules/bonus-material/src/main/java/com/bonus/material/clz/mapper/BmProDepartMapper.java b/bonus-modules/bonus-material/src/main/java/com/bonus/material/clz/mapper/BmProDepartMapper.java index eddf8231..f04915fa 100644 --- a/bonus-modules/bonus-material/src/main/java/com/bonus/material/clz/mapper/BmProDepartMapper.java +++ b/bonus-modules/bonus-material/src/main/java/com/bonus/material/clz/mapper/BmProDepartMapper.java @@ -12,36 +12,26 @@ public interface BmProDepartMapper { /** * 查询项目部列表信息 - * @param tbProDepart - * @return */ List queryByPage(BmProDepart tbProDepart); /** * 按照名称查询 - * @param tbProDepart - * @return */ BmProDepart selectByName(BmProDepart tbProDepart); /** * 新增项目部信息 - * @param tbProDepart - * @return */ int insert(BmProDepart tbProDepart); /** * 修改项目部信息 - * @param tbProDepart - * @return */ int update(BmProDepart tbProDepart); /** * 删除项目部信息 - * @param tbProDepart - * @return */ int deleteById(BmProDepart tbProDepart); } diff --git a/bonus-modules/bonus-material/src/main/java/com/bonus/material/clz/mapper/BmTeamMapper.java b/bonus-modules/bonus-material/src/main/java/com/bonus/material/clz/mapper/BmTeamMapper.java index 98bbda78..895dc77d 100644 --- a/bonus-modules/bonus-material/src/main/java/com/bonus/material/clz/mapper/BmTeamMapper.java +++ b/bonus-modules/bonus-material/src/main/java/com/bonus/material/clz/mapper/BmTeamMapper.java @@ -12,43 +12,31 @@ public interface BmTeamMapper { /** * 查询班组信息 - * @param tbTeam - * @return */ List queryByPage(BmTeam tbTeam); /** * 根据名称查询班组信息 - * @param tbTeam - * @return */ BmTeam selectByName(BmTeam tbTeam); /** * 新增班组信息 - * @param tbTeam - * @return */ int insert(BmTeam tbTeam); /** * 修改班组信息 - * @param tbTeam - * @return */ int update(BmTeam tbTeam); /** * 删除班组数据 - * @param tbTeam - * @return */ int deleteById(BmTeam tbTeam); /** * 查询班组数据 - * @param tbTeam - * @return */ List getTeamList(BmTeam tbTeam); } diff --git a/bonus-modules/bonus-material/src/main/java/com/bonus/material/clz/mapper/ClzSltAgreementInfoMapper.java b/bonus-modules/bonus-material/src/main/java/com/bonus/material/clz/mapper/ClzSltAgreementInfoMapper.java index b9329325..403293bb 100644 --- a/bonus-modules/bonus-material/src/main/java/com/bonus/material/clz/mapper/ClzSltAgreementInfoMapper.java +++ b/bonus-modules/bonus-material/src/main/java/com/bonus/material/clz/mapper/ClzSltAgreementInfoMapper.java @@ -4,6 +4,7 @@ import com.bonus.common.biz.domain.ProjectTreeNode; import com.bonus.material.clz.domain.vo.MaterialSltAgreementInfo; import com.bonus.material.clz.domain.vo.sltAgreementInfo.MaterialSltInfoVo; import com.bonus.material.common.domain.vo.AgreementVo; +import com.bonus.material.settlement.domain.SltAgreementInfo; import com.bonus.material.settlement.domain.SltAgreementReduce; import org.apache.ibatis.annotations.Param; @@ -15,81 +16,81 @@ import java.util.List; */ public interface ClzSltAgreementInfoMapper { + + /** + * 查询结算审批列表 + */ + List getSltList(SltAgreementInfo bean); + /** * 获取协议结算列表 - * @param bean - * @return */ List getSltAgreementInfo4Project(MaterialSltAgreementInfo bean); + /** + * 根据往来单位id关联协议查询工程 + * @param unitId 单位id + * @return 工程列表 + */ Integer[] getProjectListByUnitIds(int unitId); List getProjectList(int projectId); + /** + * 查询协议列表 + * @param unitIds 单位ID(支持多个) + * @param projectId 工程ID + * @return 包含协议签订时间及结算状态 + */ List getAgreementInfoById(@Param("unitIds") List unitIds, @Param("projectId") int projectId); - /** * 获取租赁列表 - * @param info - * @return */ List getLeaseList(MaterialSltAgreementInfo info); + /** + * 获取已结算的各项费用列表 + */ + List getSltedList(MaterialSltAgreementInfo info); + /** * 获取丢失列表 - * @param info - * @return */ List getLoseList(MaterialSltAgreementInfo info); /** * 获取减免费用列表 - * @param bean - * @return */ List getReductionList(SltAgreementReduce bean); /** * 获取驳回数量 - * @param sltInfoVo - * @return */ int getRejectCount(MaterialSltInfoVo sltInfoVo); /** * 获取驳回id - * @param sltInfoVo - * @return */ Long getRejectId(MaterialSltInfoVo sltInfoVo); /** * 更新驳回数量 - * @param sltInfoVo - * @return */ int updateRejectCount(MaterialSltInfoVo sltInfoVo); /** * 插入协议申请 - * @param sltInfoVo - * @return */ int insertSltAgreementApply(MaterialSltInfoVo sltInfoVo); /** - * 插入协议申请详情 - * @param list - * @param id + * 插入协议申请详情 -- 租赁 */ int insertSltAgreementDetailLease(@Param("list") List list, @Param("id") Long id); /** - * 插入协议申请详情 - * @param list - * @param id - * @return + * 插入协议申请详情 -- 丢失 */ int insertSltAgreementDetailLose(@Param("list") List list, @Param("id") Long id); } diff --git a/bonus-modules/bonus-material/src/main/java/com/bonus/material/clz/service/ClzSltAgreementInfoService.java b/bonus-modules/bonus-material/src/main/java/com/bonus/material/clz/service/ClzSltAgreementInfoService.java index 0fe8f76f..1c058501 100644 --- a/bonus-modules/bonus-material/src/main/java/com/bonus/material/clz/service/ClzSltAgreementInfoService.java +++ b/bonus-modules/bonus-material/src/main/java/com/bonus/material/clz/service/ClzSltAgreementInfoService.java @@ -2,9 +2,12 @@ package com.bonus.material.clz.service; import com.bonus.common.core.web.domain.AjaxResult; import com.bonus.material.basic.domain.BmProject; +import com.bonus.material.clz.domain.ClzSltApplyDTO; import com.bonus.material.clz.domain.vo.MaterialSltAgreementInfo; import com.bonus.material.clz.domain.vo.sltAgreementInfo.MaterialSltInfoVo; import com.bonus.material.common.domain.dto.SelectDto; +import com.bonus.material.settlement.domain.SltAgreementInfo; +import com.bonus.material.settlement.domain.vo.SltInfoVo; import java.util.List; @@ -16,18 +19,31 @@ public interface ClzSltAgreementInfoService { /** * 根据条件获取协议结算列表 - * @param bean - * @return */ List getSltAgreementInfo4Project(MaterialSltAgreementInfo bean); /** - * 获取结算清单 - * @param info - * @return + * 获取未结算清单 */ MaterialSltInfoVo getSltInfo(MaterialSltAgreementInfo info); + /** + * 结算审批列表 + */ + List getSltList(SltAgreementInfo bean); + + /** + * 根据单位及工程查询结算明细 + * @param requestApplyDto 工程、班组 + */ + List getSltDetailsByUnitsAndProject(ClzSltApplyDTO requestApplyDto); + + /** + * 查询已结算信息 + * @param requestApplyDto 结算申请单号 + */ + List getSettledDetailsByApplyCode(MaterialSltAgreementInfo requestApplyDto); + MaterialSltInfoVo mergerData(MaterialSltInfoVo vo, List list, List unitNames, List projectNames); String handleData(List list); @@ -42,11 +58,8 @@ public interface ClzSltAgreementInfoService { AjaxResult getAgreementInfoById(SelectDto dto); - /** * 提交结算清单 - * @param sltInfoVo - * @return */ int submitCosts(MaterialSltInfoVo sltInfoVo); } diff --git a/bonus-modules/bonus-material/src/main/java/com/bonus/material/clz/service/impl/ClzSltAgreementInfoServiceImpl.java b/bonus-modules/bonus-material/src/main/java/com/bonus/material/clz/service/impl/ClzSltAgreementInfoServiceImpl.java index 5a5fba0a..c9ca0fdd 100644 --- a/bonus-modules/bonus-material/src/main/java/com/bonus/material/clz/service/impl/ClzSltAgreementInfoServiceImpl.java +++ b/bonus-modules/bonus-material/src/main/java/com/bonus/material/clz/service/impl/ClzSltAgreementInfoServiceImpl.java @@ -1,5 +1,9 @@ package com.bonus.material.clz.service.impl; +import cn.hutool.core.bean.BeanUtil; +import cn.hutool.core.collection.CollectionUtil; +import cn.hutool.core.util.ObjectUtil; +import com.bonus.common.biz.constant.GlobalConstants; import com.bonus.common.biz.domain.ProjectTreeBuild; import com.bonus.common.biz.domain.ProjectTreeNode; import com.bonus.common.core.exception.ServiceException; @@ -7,17 +11,21 @@ import com.bonus.common.core.utils.DateUtils; import com.bonus.common.core.web.domain.AjaxResult; import com.bonus.common.security.utils.SecurityUtils; import com.bonus.material.basic.domain.BmProject; +import com.bonus.material.clz.domain.ClzSltApplyDTO; import com.bonus.material.clz.domain.vo.MaterialSltAgreementInfo; import com.bonus.material.clz.domain.vo.sltAgreementInfo.MaterialSltInfoVo; import com.bonus.material.clz.mapper.ClzSltAgreementInfoMapper; import com.bonus.material.clz.service.ClzSltAgreementInfoService; import com.bonus.material.common.domain.dto.SelectDto; import com.bonus.material.common.domain.vo.AgreementVo; +import com.bonus.material.settlement.domain.SltAgreementInfo; import com.bonus.material.settlement.domain.SltAgreementReduce; import com.bonus.material.settlement.domain.SltAgreementRelation; +import com.bonus.material.settlement.domain.vo.SltInfoVo; import org.apache.commons.collections4.CollectionUtils; import org.apache.commons.lang3.StringUtils; import org.springframework.stereotype.Service; +import org.springframework.transaction.annotation.Transactional; import javax.annotation.Resource; import java.math.BigDecimal; @@ -45,9 +53,42 @@ public class ClzSltAgreementInfoServiceImpl implements ClzSltAgreementInfoServic } /** - * 获取结算清单 - * @param info - * @return + * 查询结算审批列表 + */ + @Override + public List getSltList(SltAgreementInfo bean) { + // 定义最终返回数据 + List resultVo = new ArrayList<>(); + // 查询数据库 + List list = clzSltAgreementInfoMapper.getSltList(bean); + if (CollectionUtils.isNotEmpty(list)) { + // 按照结算单号分组 + Map> sltListByCodeMap = list.stream().collect(Collectors.groupingBy(SltAgreementInfo::getSltApplyCode)); + // 遍历Map + sltListByCodeMap.forEach((s, sltAgreementInfoList) -> { + if (CollectionUtils.isNotEmpty(sltAgreementInfoList)) { + // 定义初始化对象 + SltAgreementInfo obj = new SltAgreementInfo(); + BeanUtil.copyProperties(sltAgreementInfoList.get(0), obj, true); + + // 合并结算单中的多个单位名称及费用 + String unitNames = sltAgreementInfoList.stream().map(SltAgreementInfo::getUnitName).collect(Collectors.joining(",")); + BigDecimal costsSum = sltAgreementInfoList.stream().map(SltAgreementInfo::getCosts).reduce(BigDecimal.ZERO, BigDecimal::add); + obj.setUnitName(unitNames); + obj.setCosts(costsSum); + + resultVo.add(obj); + } + }); + } else { + throw new ServiceException("数据库未查询到结算信息!"); + } + + return resultVo; + } + + /** + * 获取未结算清单 */ @Override public MaterialSltInfoVo getSltInfo(MaterialSltAgreementInfo info) { @@ -99,6 +140,136 @@ public class ClzSltAgreementInfoServiceImpl implements ClzSltAgreementInfoServic return sltInfoVo; } + /** + * 获取已结算清单 + */ + private List getSettledInfo(MaterialSltAgreementInfo info) { + // 查询各项费用列表 + List sltedList = clzSltAgreementInfoMapper.getSltedList(info); + + // 按照协议进行分组 + List resultVoList = new ArrayList<>(); + + sltedList.forEach((item) -> { + MaterialSltInfoVo sltInfoVo = new MaterialSltInfoVo(); + BigDecimal leaseCost = BigDecimal.ZERO, repairCost = BigDecimal.ZERO, scrapCost = BigDecimal.ZERO; + BigDecimal loseCost = BigDecimal.ZERO, reducCost = BigDecimal.ZERO; + + //租赁费用列表 + List leaseList = sltedList.stream().filter(slt -> slt.getSltType() == 1).collect(Collectors.toList()); + //维修费用列表 + List repairList = sltedList.stream().filter(slt -> slt.getSltType() == 3).collect(Collectors.toList()); + //报废费用列表 + List scrapList = sltedList.stream().filter(slt -> slt.getSltType() == 4).collect(Collectors.toList()); + //丢失费用列表 + List loseList = sltedList.stream().filter(slt -> slt.getSltType() == 2).collect(Collectors.toList()); + + sltInfoVo.setLeaseList(leaseList); + sltInfoVo.setRepairList(repairList); + sltInfoVo.setScrapList(scrapList); + sltInfoVo.setLoseList(loseList); + sltInfoVo.setReductionList(Collections.emptyList()); + for (MaterialSltAgreementInfo lease : leaseList) { + if(lease.getCosts()!=null){ + leaseCost = leaseCost.add(lease.getCosts()); + } + } + for (MaterialSltAgreementInfo lose : loseList) { + if(lose.getCosts()!=null){ + loseCost = loseCost.add(lose.getCosts()); + } + } + + sltInfoVo.setLeaseCost(leaseCost); + sltInfoVo.setRepairCost(repairCost); + sltInfoVo.setScrapCost(scrapCost); + sltInfoVo.setLoseCost(loseCost); + sltInfoVo.setReductionCost(reducCost); + List relations = getRelations(leaseList, repairList, scrapList, loseList, info); + sltInfoVo.setRelations(relations); + + resultVoList.add(sltInfoVo); + + // 给外层的单位名称/工程名称赋值 + extractInnerNameToOuter(resultVoList, sltInfoVo); + }); + return resultVoList; + } + + /** + * 提取内层的工程名称及单位名称赋值给外层对象 + * @param resultVoList 内层集合 + * @param sltInfoVo 外层对象 + */ + private void extractInnerNameToOuter(List resultVoList, MaterialSltInfoVo sltInfoVo) { + if (CollectionUtils.isNotEmpty(sltInfoVo.getLeaseList())) { + sltInfoVo.setUnitName(sltInfoVo.getLeaseList().get(0).getUnitName()); + sltInfoVo.setProjectName(sltInfoVo.getLeaseList().get(0).getProjectName()); + } else if (CollectionUtils.isNotEmpty(sltInfoVo.getLoseList())) { + sltInfoVo.setProjectName(sltInfoVo.getLoseList().get(0).getProjectName()); + sltInfoVo.setUnitName(sltInfoVo.getLoseList().get(0).getUnitName()); + } else if (CollectionUtils.isNotEmpty(sltInfoVo.getRepairList())) { + sltInfoVo.setProjectName(sltInfoVo.getRepairList().get(0).getProjectName()); + sltInfoVo.setUnitName(sltInfoVo.getRepairList().get(0).getUnitName()); + } else if (CollectionUtils.isNotEmpty(sltInfoVo.getScrapList())) { + sltInfoVo.setProjectName(sltInfoVo.getScrapList().get(0).getProjectName()); + sltInfoVo.setUnitName(sltInfoVo.getScrapList().get(0).getUnitName()); + } + resultVoList.add(sltInfoVo); + } + + /** + * 根据单位及工程查询待结算费用明细 + * @param requestApplyDto 工程、班组 + */ + @Override + public List getSltDetailsByUnitsAndProject(ClzSltApplyDTO requestApplyDto) { + // 查询协议号 + List agreementInfos = clzSltAgreementInfoMapper.getAgreementInfoById(requestApplyDto.getUnitIds(), requestApplyDto.getProjectId()); + // 过滤异常数据 + agreementInfos.removeIf(Objects::isNull); + // 查询每个协议的待结算明细 + if (CollectionUtils.isNotEmpty(agreementInfos)) { + // 定义返回集合 + List voList = new ArrayList<>(); + for (AgreementVo agreementInfo : agreementInfos) { + // 数据检查 + if (agreementInfo.getAgreementId() == null || agreementInfo.getAgreementId() <= 0) { + throw new ServiceException("协议ID为空,请反馈至管理员!"); + } + if (StringUtils.isBlank(agreementInfo.getAgreementCode())) { + throw new ServiceException("协议号为空,请检查!"); + } + + // 进行Bean的类型转换,使其适配Mapper + MaterialSltAgreementInfo sltAgreementInfo = new MaterialSltAgreementInfo(); + BeanUtil.copyProperties(agreementInfo, sltAgreementInfo, true); + // 调用单个结算信息查询方法 + MaterialSltInfoVo sltInfo = getSltInfo(sltAgreementInfo); + + // 给外层的单位名称/工程名称赋值 + if (sltInfo != null) { + extractInnerNameToOuter(voList, sltInfo); + } + } + + return voList; + } else { + throw new ServiceException("未查询到签署的协议!"); + } + } + + /** + * 查询已结算信息 + * + * @param requestApplyDto 结算申请单号 + */ + @Override + public List getSettledDetailsByApplyCode(MaterialSltAgreementInfo requestApplyDto) { + // 定义返回集合 + return getSettledInfo(requestApplyDto); + } + @Override public MaterialSltInfoVo mergerData(MaterialSltInfoVo vo, List list, List unitNames, List projectNames) { vo.setUnitName(handleData(unitNames)); @@ -236,10 +407,10 @@ public class ClzSltAgreementInfoServiceImpl implements ClzSltAgreementInfoServic * @return */ @Override + @Transactional(rollbackFor = Exception.class) public int submitCosts(MaterialSltInfoVo sltInfoVo) { try { - if (sltInfoVo.getAgreementIds() != null) { - + if (sltInfoVo.getAgreementIds() != null && sltInfoVo.getAgreementIds().length > 0) { for (Long agreementId : sltInfoVo.getAgreementIds()) { Long id = null; sltInfoVo.setAgreementId(agreementId); @@ -254,16 +425,6 @@ public class ClzSltAgreementInfoServiceImpl implements ClzSltAgreementInfoServic .filter(Objects::nonNull) .reduce(BigDecimal.ZERO, BigDecimal::add)); - /*totalCost = totalCost.add(getRepairList(info).stream() - .map(SltAgreementInfo::getCosts) - .filter(Objects::nonNull) - .reduce(BigDecimal.ZERO, BigDecimal::add)); - - totalCost = totalCost.add(getScrapList(info).stream() - .map(SltAgreementInfo::getCosts) - .filter(Objects::nonNull) - .reduce(BigDecimal.ZERO, BigDecimal::add));*/ - totalCost = totalCost.add(getLoseList(info).stream() .map(MaterialSltAgreementInfo::getCosts) .filter(Objects::nonNull) @@ -287,10 +448,6 @@ public class ClzSltAgreementInfoServiceImpl implements ClzSltAgreementInfoServic } sltInfoVo.setUpdateTime(DateUtils.getNowDate()); sltInfoVo.setCreateBy(String.valueOf(SecurityUtils.getLoginUser().getUserid())); - /*int countTwo = clzSltAgreementInfoMapper.updateBmAgreementStatus(sltInfoVo); - if (countTwo != 1) { - throw new ServiceException("bm_agreement_info修改失败"); - }*/ } else { sltInfoVo.setCreateTime(DateUtils.getNowDate()); sltInfoVo.setCreateBy(String.valueOf(SecurityUtils.getLoginUser().getUserid())); @@ -302,11 +459,8 @@ public class ClzSltAgreementInfoServiceImpl implements ClzSltAgreementInfoServic // 插入成功后,sltInfoVo 的 id 属性将被自动设置为新生成的主键值 id = sltInfoVo.getId(); sltInfoVo.setUpdateTime(DateUtils.getNowDate()); - /*int countTwo = clzSltAgreementInfoMapper.updateBmAgreementStatus(sltInfoVo); - if (countTwo != 1) { - throw new ServiceException("bm_agreement_info修改失败"); - }*/ } + if (!sltInfoVo.getLeaseList().isEmpty()) { List filteredLeaseList = sltInfoVo.getLeaseList().stream() .filter(lease -> lease.getAgreementId().equals(sltInfoVo.getAgreementId())) @@ -315,22 +469,6 @@ public class ClzSltAgreementInfoServiceImpl implements ClzSltAgreementInfoServic clzSltAgreementInfoMapper.insertSltAgreementDetailLease(filteredLeaseList, id); } } - /*if (sltInfoVo.getRepairList().size() > 0) { - List filteredRepairList = sltInfoVo.getRepairList().stream() - .filter(lease -> lease.getAgreementId().equals(sltInfoVo.getAgreementId())) - .collect(Collectors.toList()); - if (!filteredRepairList.isEmpty()) { - clzSltAgreementInfoMapper.insertSltAgreementDetailRepair(filteredRepairList, id); - } - } - if (sltInfoVo.getScrapList().size() > 0) { - List filteredScrapList = sltInfoVo.getScrapList().stream() - .filter(lease -> lease.getAgreementId().equals(sltInfoVo.getAgreementId())) - .collect(Collectors.toList()); - if (!filteredScrapList.isEmpty()) { - clzSltAgreementInfoMapper.insertSltAgreementDetailScrap(filteredScrapList, id); - } - }*/ if (!sltInfoVo.getLoseList().isEmpty()) { List filteredLoseList = sltInfoVo.getLoseList().stream() .filter(lease -> lease.getAgreementId().equals(sltInfoVo.getAgreementId())) @@ -340,10 +478,13 @@ public class ClzSltAgreementInfoServiceImpl implements ClzSltAgreementInfoServic } } } + } else { + throw new ServiceException("结算信息为空!"); } return 1; } catch (Exception e) { - throw new ServiceException("错误信息描述"); + System.err.println(e.getMessage()); + throw new ServiceException("结算发生错误"); } } @@ -419,15 +560,20 @@ public class ClzSltAgreementInfoServiceImpl implements ClzSltAgreementInfoServic * @param info 信息表 */ private List getLoseList(MaterialSltAgreementInfo info) { + // 获取未退还的物资(原有逻辑) List oneOfList = clzSltAgreementInfoMapper.getLoseList(info); List loseList = new ArrayList<>(oneOfList); + // 获取已退还但超期16天以上的物资 + List overdueReturnedList = getOverdueReturnedMaterials(info); + loseList.addAll(overdueReturnedList); + for (MaterialSltAgreementInfo bean : loseList) { if (Objects.isNull(bean.getBuyPrice())) { - bean.setBuyPrice(BigDecimal.valueOf(0.00)); + bean.setBuyPrice(BigDecimal.ZERO); } if (Objects.isNull(bean.getNum())) { - bean.setNum(BigDecimal.valueOf(0L)); + bean.setNum(BigDecimal.ZERO); } BigDecimal buyPrice = bean.getBuyPrice(); BigDecimal num = bean.getNum(); @@ -439,6 +585,31 @@ public class ClzSltAgreementInfoServiceImpl implements ClzSltAgreementInfoServic return loseList; } + /** + * 获取已退还但超期16天以上的物资(计为丢失) + * @param info 信息表 + */ + private List getOverdueReturnedMaterials(MaterialSltAgreementInfo info) { + // 获取所有已退还的物资 + List returnedList = clzSltAgreementInfoMapper.getLeaseList(info); + List overdueList = new ArrayList<>(); + + Date teamExitTime = simulateTeamExitTime(); + + for (MaterialSltAgreementInfo bean : returnedList) { + // 只处理已退还的物资 + if (bean.getEndTime() != null) { + long overdueDays = calculateOverdueDays(bean.getEndTime(), teamExitTime); + if (overdueDays >= 16) { + // 超期16天以上计为丢失 + overdueList.add(bean); + } + } + } + + return overdueList; + } + /** * 获取租赁费用列表 * @param info 获取租赁费用列表参数 @@ -448,23 +619,143 @@ public class ClzSltAgreementInfoServiceImpl implements ClzSltAgreementInfoServic List leaseList = new ArrayList<>(oneOfList); for (MaterialSltAgreementInfo bean : leaseList) { + // 数据安全检查 if (null == bean.getLeasePrice()) { - bean.setLeasePrice(BigDecimal.valueOf(0.00)); + bean.setLeasePrice(BigDecimal.ZERO); } else { - bean.setLeasePrice(bean.getLeasePrice().setScale(2, RoundingMode.HALF_UP)); + bean.setLeasePrice(bean.getLeasePrice().setScale(GlobalConstants.INT_2, RoundingMode.HALF_UP)); } if (Objects.isNull(bean.getNum())) { - bean.setNum(BigDecimal.valueOf(0L)); + bean.setNum(BigDecimal.ZERO); } if (Objects.isNull(bean.getLeaseDays())) { bean.setLeaseDay(0L); } + BigDecimal leasePrice = bean.getLeasePrice(); BigDecimal num = bean.getNum(); - BigDecimal leaseDays = new BigDecimal(bean.getLeaseDays()); - BigDecimal costs = leasePrice.multiply(num).multiply(leaseDays).setScale(2, RoundingMode.HALF_UP); + // 根据班组退场时间计算租赁费用 + BigDecimal costs = calculateRentalCostByTeamExitTime(bean, leasePrice, num); bean.setCosts(costs); } return leaseList; } + + /** + * 根据班组退场时间计算租赁费用 + * @param bean 租赁信息 + * @param leasePrice 租赁单价 + * @param num 数量 + * @return 计算后的费用 + */ + private BigDecimal calculateRentalCostByTeamExitTime(MaterialSltAgreementInfo bean, BigDecimal leasePrice, BigDecimal num) { + // 模拟班组退场时间(后续会通过参数传入) + Date teamExitTime = simulateTeamExitTime(); + + // 物资是否已退还(根据endTime字段判断) + boolean isReturned = bean.getEndTime() != null; + + if (!isReturned) { + // 1.4 如果当前领用物资还未退还,不收取任何租赁费用,直接计作丢失,收取物资原值 不在租赁费用中体现 + return BigDecimal.ZERO; + } + + // 物资已退还,按照天数来计算费用 + Date materialReturnTime = bean.getEndTime(); + + // 计算超期天数 + long overdueDays = calculateOverdueDays(materialReturnTime, teamExitTime); + + if (overdueDays <= 0) { + // 1.3 在班组退场之前归还的物资不收费 + return BigDecimal.ZERO; + } else if (overdueDays >= 16) { + // 1.2 超期15天以上也就是16天及以上计为丢失,算作丢失的话直接收取原值、所有租赁费用不收费了 + // 注意:丢失费用应该在getLoseList中处理,这里不收费 + return BigDecimal.ZERO; + } else { + // 计算超期费用 + return calculateOverdueCost(bean, leasePrice, num, overdueDays); + } + } + + /** + * 计算超期费用(新逻辑:前7天不收费,第8天开始双倍收费) + */ + private BigDecimal calculateOverdueCost(MaterialSltAgreementInfo bean, BigDecimal leasePrice, BigDecimal num, long overdueDays) { + BigDecimal overdueCost = BigDecimal.ZERO; + + if (overdueDays <= 7) { + // 超期1~7天不收费 + overdueCost = BigDecimal.ZERO; + } else if (overdueDays <= 15) { + // 超期第8天~第15天双倍计费 + // 前7天不收费,只计算第8天开始的双倍费用 + long doubleBillingDays = overdueDays - 7; + overdueCost = leasePrice.multiply(num).multiply(new BigDecimal(doubleBillingDays)).multiply(new BigDecimal(2)); + } + + return overdueCost.setScale(GlobalConstants.INT_2, RoundingMode.HALF_UP); + } + + /** + * 计算超期天数(只关注日期,不考虑时分秒) + */ + private long calculateOverdueDays(Date materialReturnTime, Date teamExitTime) { + if (materialReturnTime == null || teamExitTime == null) { + return 0; + } + + Calendar returnCal = Calendar.getInstance(); + returnCal.setTime(materialReturnTime); + resetTimeToZero(returnCal); + + Calendar exitCal = Calendar.getInstance(); + exitCal.setTime(teamExitTime); + resetTimeToZero(exitCal); + + long diffInMillies = returnCal.getTimeInMillis() - exitCal.getTimeInMillis(); + return diffInMillies / (24 * 60 * 60 * 1000); + } + + /** + * 计算基础租赁天数(只关注日期,当日领当日退计为1天) + */ + private long calculateBaseLeaseDays(Date startTime, Date endTime) { + if (startTime == null || endTime == null) { + return 0; + } + + Calendar startCal = Calendar.getInstance(); + startCal.setTime(startTime); + resetTimeToZero(startCal); + + Calendar endCal = Calendar.getInstance(); + endCal.setTime(endTime); + resetTimeToZero(endCal); + + long diffInMillies = endCal.getTimeInMillis() - startCal.getTimeInMillis(); + long days = diffInMillies / (24 * 60 * 60 * 1000) + 1; // 包含起始日和结束日 + return Math.max(1, days); // 至少1天 + } + + /** + * 将时间重置为00:00:00.000 + */ + private void resetTimeToZero(Calendar calendar) { + calendar.set(Calendar.HOUR_OF_DAY, 0); + calendar.set(Calendar.MINUTE, 0); + calendar.set(Calendar.SECOND, 0); + calendar.set(Calendar.MILLISECOND, 0); + } + + /** + * 模拟班组退场时间(临时方法,后续会通过参数传入) + */ + private Date simulateTeamExitTime() { + // 模拟班组退场时间为30天前 + Calendar calendar = Calendar.getInstance(); + calendar.add(Calendar.DAY_OF_MONTH, -30); + return calendar.getTime(); + } } diff --git a/bonus-modules/bonus-material/src/main/java/com/bonus/material/common/domain/vo/AgreementVo.java b/bonus-modules/bonus-material/src/main/java/com/bonus/material/common/domain/vo/AgreementVo.java index 2ae86cf9..f576c22f 100644 --- a/bonus-modules/bonus-material/src/main/java/com/bonus/material/common/domain/vo/AgreementVo.java +++ b/bonus-modules/bonus-material/src/main/java/com/bonus/material/common/domain/vo/AgreementVo.java @@ -2,6 +2,7 @@ package com.bonus.material.common.domain.vo; import lombok.Data; +import java.io.Serializable; import java.util.List; /** @@ -9,7 +10,7 @@ import java.util.List; * 协议信息 */ @Data -public class AgreementVo { +public class AgreementVo implements Serializable { /** 协议ID*/ private Integer agreementId; @@ -20,7 +21,7 @@ public class AgreementVo { /** 是否结算*/ private String isSlt; -// private List agreementIdList; -// -// private List agreementCodeList; + /** 协议签订时间*/ + private String signTime; + } diff --git a/bonus-modules/bonus-material/src/main/java/com/bonus/material/settlement/domain/SltAgreementInfo.java b/bonus-modules/bonus-material/src/main/java/com/bonus/material/settlement/domain/SltAgreementInfo.java index d6952df5..48f1511d 100644 --- a/bonus-modules/bonus-material/src/main/java/com/bonus/material/settlement/domain/SltAgreementInfo.java +++ b/bonus-modules/bonus-material/src/main/java/com/bonus/material/settlement/domain/SltAgreementInfo.java @@ -44,6 +44,9 @@ public class SltAgreementInfo extends BaseEntity { @ApiModelProperty(value = "协议编号") private String agreementCode; + @ApiModelProperty("结算申请单号") + private String sltApplyCode; + /** 机具规格id */ @Excel(name = "机具规格id") @ApiModelProperty(value = "机具规格id") diff --git a/bonus-modules/bonus-material/src/main/resources/mapper/material/clz/ClzAgreementInfoMapper.xml b/bonus-modules/bonus-material/src/main/resources/mapper/material/clz/ClzAgreementInfoMapper.xml index 5a010cdd..6c0c80c6 100644 --- a/bonus-modules/bonus-material/src/main/resources/mapper/material/clz/ClzAgreementInfoMapper.xml +++ b/bonus-modules/bonus-material/src/main/resources/mapper/material/clz/ClzAgreementInfoMapper.xml @@ -51,45 +51,48 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" - select sai.id, sai.agreement_id as agreementId, bui.unit_name as unitName, @@ -239,7 +242,8 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" SELECT agreement_id AS agreementId, agreement_code AS agreementCode, - is_slt AS isSlt + is_slt AS isSlt, + sign_time as signTime FROM clz_bm_agreement_info WHERE @@ -249,4 +253,44 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" AND project_id = #{projectId} AND status = '1' + + + + \ No newline at end of file diff --git a/bonus-modules/bonus-material/src/main/resources/mapper/material/clz/MaterialMachineMapper.xml b/bonus-modules/bonus-material/src/main/resources/mapper/material/clz/MaterialMachineMapper.xml index c775699b..1fd1a0b3 100644 --- a/bonus-modules/bonus-material/src/main/resources/mapper/material/clz/MaterialMachineMapper.xml +++ b/bonus-modules/bonus-material/src/main/resources/mapper/material/clz/MaterialMachineMapper.xml @@ -1482,94 +1482,82 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"