增加结算申请相关功能,优化查询逻辑及数据处理

This commit is contained in:
syruan 2025-09-29 16:56:44 +08:00
parent a35ceb8ce1
commit a74a8a099e
16 changed files with 641 additions and 285 deletions

View File

@ -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<BmProDepart> list = bmProDepartService.queryByPage(tbProDepart);
ExcelUtil<BmProDepart> util = new ExcelUtil<BmProDepart>(BmProDepart.class);
ExcelUtil<BmProDepart> util = new ExcelUtil<>(BmProDepart.class);
util.exportExcel(response, list, "项目部管理数据");
}
}

View File

@ -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<MaterialSltAgreementInfo> list) {
List<String> unitNames = new ArrayList<>();
List<String> projectNames = new ArrayList<>();
List<MaterialSltInfoVo> 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<MaterialSltInfoVo> 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<MaterialSltInfoVo> 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<SltAgreementInfo> list = clzSltAgreementInfoService.getSltList(bean);
return getDataTable(list);
}
}

View File

@ -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<Integer> unitIds;
@ApiModelProperty("申请结算工程")
private Integer projectId;
@ApiModelProperty("结算单号")
private String sltApplyCode;
}

View File

@ -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;

View File

@ -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")

View File

@ -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;

View File

@ -12,36 +12,26 @@ public interface BmProDepartMapper {
/**
* 查询项目部列表信息
* @param tbProDepart
* @return
*/
List<BmProDepart> 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);
}

View File

@ -12,43 +12,31 @@ public interface BmTeamMapper {
/**
* 查询班组信息
* @param tbTeam
* @return
*/
List<BmTeam> 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<BmTeam> getTeamList(BmTeam tbTeam);
}

View File

@ -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<SltAgreementInfo> getSltList(SltAgreementInfo bean);
/**
* 获取协议结算列表
* @param bean
* @return
*/
List<MaterialSltAgreementInfo> getSltAgreementInfo4Project(MaterialSltAgreementInfo bean);
/**
* 根据往来单位id关联协议查询工程
* @param unitId 单位id
* @return 工程列表
*/
Integer[] getProjectListByUnitIds(int unitId);
List<ProjectTreeNode> getProjectList(int projectId);
/**
* 查询协议列表
* @param unitIds 单位ID支持多个
* @param projectId 工程ID
* @return 包含协议签订时间及结算状态
*/
List<AgreementVo> getAgreementInfoById(@Param("unitIds") List<Integer> unitIds, @Param("projectId") int projectId);
/**
* 获取租赁列表
* @param info
* @return
*/
List<MaterialSltAgreementInfo> getLeaseList(MaterialSltAgreementInfo info);
/**
* 获取已结算的各项费用列表
*/
List<MaterialSltAgreementInfo> getSltedList(MaterialSltAgreementInfo info);
/**
* 获取丢失列表
* @param info
* @return
*/
List<MaterialSltAgreementInfo> getLoseList(MaterialSltAgreementInfo info);
/**
* 获取减免费用列表
* @param bean
* @return
*/
List<SltAgreementReduce> 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<MaterialSltAgreementInfo> list, @Param("id") Long id);
/**
* 插入协议申请详情
* @param list
* @param id
* @return
* 插入协议申请详情 -- 丢失
*/
int insertSltAgreementDetailLose(@Param("list") List<MaterialSltAgreementInfo> list, @Param("id") Long id);
}

View File

@ -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<MaterialSltAgreementInfo> getSltAgreementInfo4Project(MaterialSltAgreementInfo bean);
/**
* 获取结算清单
* @param info
* @return
* 获取未结算清单
*/
MaterialSltInfoVo getSltInfo(MaterialSltAgreementInfo info);
/**
* 结算审批列表
*/
List<SltAgreementInfo> getSltList(SltAgreementInfo bean);
/**
* 根据单位及工程查询结算明细
* @param requestApplyDto 工程班组
*/
List<MaterialSltInfoVo> getSltDetailsByUnitsAndProject(ClzSltApplyDTO requestApplyDto);
/**
* 查询已结算信息
* @param requestApplyDto 结算申请单号
*/
List<MaterialSltInfoVo> getSettledDetailsByApplyCode(MaterialSltAgreementInfo requestApplyDto);
MaterialSltInfoVo mergerData(MaterialSltInfoVo vo, List<MaterialSltInfoVo> list, List<String> unitNames, List<String> projectNames);
String handleData(List<String> list);
@ -42,11 +58,8 @@ public interface ClzSltAgreementInfoService {
AjaxResult getAgreementInfoById(SelectDto dto);
/**
* 提交结算清单
* @param sltInfoVo
* @return
*/
int submitCosts(MaterialSltInfoVo sltInfoVo);
}

View File

@ -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<SltAgreementInfo> getSltList(SltAgreementInfo bean) {
// 定义最终返回数据
List<SltAgreementInfo> resultVo = new ArrayList<>();
// 查询数据库
List<SltAgreementInfo> list = clzSltAgreementInfoMapper.getSltList(bean);
if (CollectionUtils.isNotEmpty(list)) {
// 按照结算单号分组
Map<String, List<SltAgreementInfo>> 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<MaterialSltInfoVo> getSettledInfo(MaterialSltAgreementInfo info) {
// 查询各项费用列表
List<MaterialSltAgreementInfo> sltedList = clzSltAgreementInfoMapper.getSltedList(info);
// 按照协议进行分组
List<MaterialSltInfoVo> 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<MaterialSltAgreementInfo> leaseList = sltedList.stream().filter(slt -> slt.getSltType() == 1).collect(Collectors.toList());
//维修费用列表
List<MaterialSltAgreementInfo> repairList = sltedList.stream().filter(slt -> slt.getSltType() == 3).collect(Collectors.toList());
//报废费用列表
List<MaterialSltAgreementInfo> scrapList = sltedList.stream().filter(slt -> slt.getSltType() == 4).collect(Collectors.toList());
//丢失费用列表
List<MaterialSltAgreementInfo> 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<SltAgreementRelation> 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<MaterialSltInfoVo> 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<MaterialSltInfoVo> getSltDetailsByUnitsAndProject(ClzSltApplyDTO requestApplyDto) {
// 查询协议号
List<AgreementVo> agreementInfos = clzSltAgreementInfoMapper.getAgreementInfoById(requestApplyDto.getUnitIds(), requestApplyDto.getProjectId());
// 过滤异常数据
agreementInfos.removeIf(Objects::isNull);
// 查询每个协议的待结算明细
if (CollectionUtils.isNotEmpty(agreementInfos)) {
// 定义返回集合
List<MaterialSltInfoVo> 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<MaterialSltInfoVo> getSettledDetailsByApplyCode(MaterialSltAgreementInfo requestApplyDto) {
// 定义返回集合
return getSettledInfo(requestApplyDto);
}
@Override
public MaterialSltInfoVo mergerData(MaterialSltInfoVo vo, List<MaterialSltInfoVo> list, List<String> unitNames, List<String> 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<MaterialSltAgreementInfo> 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<MaterialSltAgreementInfo> 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<MaterialSltAgreementInfo> 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<MaterialSltAgreementInfo> 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<MaterialSltAgreementInfo> getLoseList(MaterialSltAgreementInfo info) {
// 获取未退还的物资原有逻辑
List<MaterialSltAgreementInfo> oneOfList = clzSltAgreementInfoMapper.getLoseList(info);
List<MaterialSltAgreementInfo> loseList = new ArrayList<>(oneOfList);
// 获取已退还但超期16天以上的物资
List<MaterialSltAgreementInfo> 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<MaterialSltAgreementInfo> getOverdueReturnedMaterials(MaterialSltAgreementInfo info) {
// 获取所有已退还的物资
List<MaterialSltAgreementInfo> returnedList = clzSltAgreementInfoMapper.getLeaseList(info);
List<MaterialSltAgreementInfo> 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<MaterialSltAgreementInfo> 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) {
// 超期17天不收费
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();
}
}

View File

@ -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<Integer> agreementIdList;
//
// private List<String> agreementCodeList;
/** 协议签订时间*/
private String signTime;
}

View File

@ -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")

View File

@ -51,45 +51,48 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
</update>
<select id="getSltAgreementInfo4Project" resultType="com.bonus.material.clz.domain.vo.MaterialSltAgreementInfo">
SELECT bai.agreement_id as agreementId, bai.agreement_code as agreementCode,
bui.unit_id as unitId,bui.unit_name as unitName, bp.pro_id as projectId , bp.pro_name as projectName,
saa.remark,bai.protocol,saa.cost as costs,
case when (saa.id is null or saa.status = '0') then '0' when saa.status = '1' then '1' when saa.status = '2' then '2' when saa.status = '3' then '3' end as sltStatus
FROM clz_slt_agreement_info sai
LEFT JOIN clz_bm_agreement_info bai ON bai.agreement_id = sai.agreement_id
LEFT JOIN bm_project bp ON bp.pro_id = bai.project_id
LEFT JOIN bm_unit bui ON bui.unit_id = bai.unit_id
LEFT JOIN clz_slt_agreement_apply saa on saa.agreement_id = bai.agreement_id
where bai.status = '1'
<if test="unitIds != null">
and bui.unit_id in
<foreach item="item" index="index" collection="unitIds" open="(" separator="," close=")">
#{item}
</foreach>
</if>
<if test="projectId != null and projectId != ''">
and bp.pro_id = #{projectId}
</if>
<choose>
<when test="sltStatus == '0'.toString()">
and saa.id is null
</when>
<when test="sltStatus == '1'.toString()">
and saa.status = '1'
</when>
<when test="sltStatus == '2'.toString()">
and saa.status = '2'
</when>
<when test="sltStatus == '3'.toString()">
and saa.status = '3'
</when>
</choose>
SELECT
bai.agreement_id as agreementId, bai.agreement_code as agreementCode,
bui.unit_id as unitId,bui.unit_name as unitName, bp.pro_id as projectId , bp.pro_name as projectName,
saa.remark,bai.protocol,saa.cost as costs,
case when (saa.id is null or saa.status = '0') then '0' when saa.status = '1' then '1'
when saa.status = '2' then '2' when saa.status = '3' then '3' end as sltStatus
FROM
clz_slt_agreement_info sai
LEFT JOIN clz_bm_agreement_info bai ON bai.agreement_id = sai.agreement_id
LEFT JOIN bm_project bp ON bp.pro_id = bai.project_id
LEFT JOIN bm_unit bui ON bui.unit_id = bai.unit_id
LEFT JOIN clz_slt_agreement_apply saa on saa.agreement_id = bai.agreement_id
where
bai.status = '1'
<if test="unitIds != null">
and bui.unit_id in
<foreach item="item" index="index" collection="unitIds" open="(" separator="," close=")">
#{item}
</foreach>
</if>
<if test="projectId != null and projectId != ''">
and bp.pro_id = #{projectId}
</if>
<choose>
<when test="sltStatus == '0'.toString()">
and saa.id is null
</when>
<when test="sltStatus == '1'.toString()">
and saa.status = '1'
</when>
<when test="sltStatus == '2'.toString()">
and saa.status = '2'
</when>
<when test="sltStatus == '3'.toString()">
and saa.status = '3'
</when>
</choose>
GROUP BY sai.agreement_id
ORDER BY sai.create_time desc
</select>
<select id="getLeaseList"
resultType="com.bonus.material.clz.domain.vo.MaterialSltAgreementInfo">
<select id="getLeaseList" resultType="com.bonus.material.clz.domain.vo.MaterialSltAgreementInfo">
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"
</foreach>
AND project_id = #{projectId} AND status = '1'
</select>
<select id="getSltList" resultType="com.bonus.material.settlement.domain.SltAgreementInfo">
SELECT
saa.id as id, bai.agreement_id as agreementId, bai.agreement_code as agreementCode, saa.code as sltApplyCode,
bui.unit_id as unitId, bui.unit_name as unitName, bp.pro_id as projectId, bp.pro_name as projectName,
saa.remark, saa.cost as costs, su.nick_name as auditor, saa.audit_time as auditTime,
case when saa.status = '1' then '1' when saa.status = '2' then '2' when saa.status = '3' then '3' end as sltStatus
FROM clz_bm_agreement_info bai
LEFT JOIN bm_project bp ON bp.pro_id = bai.project_id
LEFT JOIN bm_unit bui ON bui.unit_id = bai.unit_id
LEFT JOIN clz_slt_agreement_apply saa on saa.agreement_id = bai.agreement_id
LEFT JOIN sys_user su ON saa.auditor = su.user_id and su.del_flag = 0
where bai.status = '1' and saa.status in ('1','2','3')
<if test="unitId != null and unitId != ''">
and bui.unit_id = #{unitId}
</if>
<if test="projectId != null and projectId != ''">
and bp.pro_id = #{projectId}
</if>
ORDER BY saa.create_time desc
</select>
<select id="getSltedList" resultType="com.bonus.material.clz.domain.vo.MaterialSltAgreementInfo">
SELECT
saa.id as id, bai.agreement_id as agreementId, bai.agreement_code as agreementCode, saa.`code` as sltApplyCode,
bui.unit_id as unitId, bui.unit_name as unitName, bp.pro_id as projectId, bp.pro_name as projectName,
saa.remark, sad.money as costs, saa.audit_time as auditTime,
saa.`status` as sltStatus, sad.slt_type as sltType,
mt1.type_name as typeName, mt.type_name as modelName, mt.unit_name as mtUnitName
FROM
clz_slt_agreement_apply saa
LEFT JOIN clz_bm_agreement_info bai ON saa.agreement_id = bai.agreement_id
LEFT JOIN bm_project bp ON bp.pro_id = bai.project_id
LEFT JOIN bm_unit bui ON bui.unit_id = bai.unit_id
LEFT JOIN clz_slt_agreement_details sad ON saa.id = sad.apply_id
left join ma_type mt on sad.type_id = mt.type_id
left join ma_type mt1 on mt.parent_id = mt1.type_id
where
saa.`code` = #{sltApplyCode}
</select>
</mapper>

View File

@ -1482,94 +1482,82 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<select id="getUsInfoList" resultType="com.bonus.material.clz.domain.vo.MaterialRetainedEquipmentInfo">
SELECT
mt.type_id as typeId,
mt4.type_name AS constructionType,
mt4.type_id AS firstTypeId,
mt3.type_name AS materialType,
mt3.type_id AS secondTypeId,
mt2.type_name AS typeName,
mt2.type_id AS thirdTypeId,
mt.type_name AS typeModelName,
SUM(IFNULL( sai.num, 0 )) AS allNum,
bu.unit_id as teamId,
bu.unit_name AS teamName,
bp.pro_name as proName,
bp.pro_id as proId,
bp.external_id as externalId,
bp.imp_unit AS impUnit,
bu.bzz_idcard AS idCard,
df.project_dept AS departName,
mt.unit_name AS unit,
sd.dept_name AS impUnitName,
CASE mt.manage_type
WHEN 0 THEN
'编码'
ELSE
'数量'
END manageType,
mt.unit_value AS unitValue,
bz.ssfbdw AS subUnitName,
CASE mt.jiju_type
WHEN 2 THEN
'安全工器具'
ELSE
'施工机具'
END jiJuType
mt.type_id as typeId,
mt4.type_name AS constructionType,
mt4.type_id AS firstTypeId,
mt3.type_name AS materialType,
mt3.type_id AS secondTypeId,
mt2.type_name AS typeName,
mt2.type_id AS thirdTypeId,
mt.type_name AS typeModelName,
SUM(IFNULL( sai.num, 0 )) AS allNum,
bu.unit_id as teamId,
bu.unit_name AS teamName,
bp.pro_name as proName,
bp.pro_id as proId,
bp.external_id as externalId,
bp.imp_unit AS impUnit,
bu.bzz_idcard AS idCard,
df.project_dept AS departName,
mt.unit_name AS unit,
sd.dept_name AS impUnitName,
CASE mt.manage_type WHEN 0 THEN '编码' ELSE '数量' END manageType,
mt.unit_value AS unitValue,
bz.ssfbdw AS subUnitName,
CASE mt.jiju_type WHEN 2 THEN '安全工器具' ELSE '施工机具' END jiJuType
FROM
clz_slt_agreement_info sai
LEFT JOIN ma_type mt ON mt.type_id = sai.type_id
LEFT JOIN ma_type mt2 ON mt2.type_id = mt.parent_id
LEFT JOIN ma_type mt3 ON mt3.type_id = mt2.parent_id
LEFT JOIN ma_type mt4 ON mt4.type_id = mt3.parent_id
LEFT JOIN clz_bm_agreement_info bai ON sai.agreement_id = bai.agreement_id
LEFT JOIN bm_project bp ON bai.project_id = bp.pro_id
LEFT JOIN bm_unit bu ON bai.unit_id = bu.unit_id AND bu.del_flag = '0'
LEFT JOIN sys_dept sd ON sd.dept_id = bp.imp_unit
LEFT JOIN `micro-tool`.bzgl_bz bz ON bp.external_id = bz.project_id
AND bz.bzmc = bu.unit_name
LEFT JOIN data_center.dx_fb_son df ON bp.external_id = df.id
clz_slt_agreement_info sai
LEFT JOIN ma_type mt ON mt.type_id = sai.type_id
LEFT JOIN ma_type mt2 ON mt2.type_id = mt.parent_id
LEFT JOIN ma_type mt3 ON mt3.type_id = mt2.parent_id
LEFT JOIN ma_type mt4 ON mt4.type_id = mt3.parent_id
LEFT JOIN clz_bm_agreement_info bai ON sai.agreement_id = bai.agreement_id
LEFT JOIN bm_project bp ON bai.project_id = bp.pro_id
LEFT JOIN bm_unit bu ON bai.unit_id = bu.unit_id AND bu.del_flag = '0'
LEFT JOIN sys_dept sd ON sd.dept_id = bp.imp_unit
LEFT JOIN `micro-tool`.bzgl_bz bz ON bp.external_id = bz.project_id AND bz.bzmc = bu.unit_name
LEFT JOIN data_center.dx_fb_son df ON bp.external_id = df.id
WHERE
sai.`status` = '0'
AND sai.end_time IS NULL
AND sai.back_id IS NULL
AND bu.unit_name is not null
AND bp.external_id is not NULL
<if test="impUnitName != null and impUnitName != ''">
AND sd.dept_name LIKE CONCAT('%', #{impUnitName}, '%')
</if>
<if test="proName != null and proName != ''">
AND bp.pro_name LIKE CONCAT('%', #{proName}, '%')
</if>
<if test="departName != null and departName != ''">
AND bp.pro_center LIKE CONCAT('%', #{departName}, '%')
</if>
<if test="teamName != null and teamName != ''">
AND bu.unit_name LIKE CONCAT('%', #{teamName}, '%')
</if>
<if test="typeName != null and typeName != ''">
AND mt2.type_name LIKE CONCAT('%', #{typeName}, '%')
</if>
<if test="typeModelName != null and typeModelName != ''">
AND mt.type_name LIKE CONCAT('%', #{typeModelName}, '%')
</if>
<if test="subUnitName != null and subUnitName != ''">
AND bz.ssfbdw LIKE CONCAT('%', #{subUnitName}, '%')
</if>
<if test="projectIdList != null and projectIdList.size() > 0">
AND bp.external_id in
<foreach item="item" collection="projectIdList" open="(" separator="," close=")">
#{item}
</foreach>
</if>
<if test="impUnit != null and impUnit != ''">
AND bp.imp_unit = #{impUnit}
</if>
<if test="jiJuType != null and jiJuType != ''">
AND mt.jiju_type = #{jiJuType}
</if>
GROUP BY mt.type_id,
bu.unit_name,
bp.pro_name
sai.`status` = '0'
AND sai.end_time IS NULL
AND sai.back_id IS NULL
AND bu.unit_name is not null
AND bp.external_id is not NULL
<if test="impUnitName != null and impUnitName != ''">
AND sd.dept_name LIKE CONCAT('%', #{impUnitName}, '%')
</if>
<if test="proName != null and proName != ''">
AND bp.pro_name LIKE CONCAT('%', #{proName}, '%')
</if>
<if test="departName != null and departName != ''">
AND bp.pro_center LIKE CONCAT('%', #{departName}, '%')
</if>
<if test="teamName != null and teamName != ''">
AND bu.unit_name LIKE CONCAT('%', #{teamName}, '%')
</if>
<if test="typeName != null and typeName != ''">
AND mt2.type_name LIKE CONCAT('%', #{typeName}, '%')
</if>
<if test="typeModelName != null and typeModelName != ''">
AND mt.type_name LIKE CONCAT('%', #{typeModelName}, '%')
</if>
<if test="subUnitName != null and subUnitName != ''">
AND bz.ssfbdw LIKE CONCAT('%', #{subUnitName}, '%')
</if>
<if test="projectIdList != null and projectIdList.size() > 0">
AND bp.external_id in
<foreach item="item" collection="projectIdList" open="(" separator="," close=")">
#{item}
</foreach>
</if>
<if test="impUnit != null and impUnit != ''">
AND bp.imp_unit = #{impUnit}
</if>
<if test="jiJuType != null and jiJuType != ''">
AND mt.jiju_type = #{jiJuType}
</if>
GROUP BY
mt.type_id, bu.unit_name, bp.pro_name
</select>
<select id="getMaCodeDetails" resultType="com.bonus.material.clz.domain.machine.MaterialStorageInfo">
SELECT mt2.type_name AS typeName,

View File

@ -360,14 +360,11 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
LEFT JOIN bm_unit bu ON bu.unit_id = lpd.unit_id
LEFT JOIN bm_project bp ON bp.pro_id = lpd.project_id
LEFT JOIN sys_dept sd ON sd.dept_id = bp.imp_unit
LEFT JOIN ma_type mt ON lpd.new_type = mt.type_id
AND mt.del_flag = '0'
LEFT JOIN ma_type mt1 ON mt.parent_id = mt1.type_id
AND mt1.del_flag = '0'
LEFT JOIN ma_type mt ON lpd.new_type = mt.type_id AND mt.del_flag = '0'
LEFT JOIN ma_type mt1 ON mt.parent_id = mt1.type_id AND mt1.del_flag = '0'
left join ma_type mt2 ON mt1.parent_id = mt2.type_id and mt2.del_flag = '0'
left join ma_type mt3 ON mt2.parent_id = mt3.type_id and mt3.del_flag = '0'
LEFT JOIN bm_agreement_info bai ON lpd.unit_id = bai.unit_id
AND lpd.project_id = bai.project_id
LEFT JOIN bm_agreement_info bai ON lpd.unit_id = bai.unit_id AND lpd.project_id = bai.project_id AND bai.project_unit_id IS NULL
left join sys_user su on lpd.create_by = su.user_id
<if test="userId != null">
JOIN ma_type_keeper mtk ON mtk.type_id = lpd.new_type AND mtk.user_id = #{userId}