材料站
This commit is contained in:
parent
fa6d7d58b8
commit
91426aaa7d
|
|
@ -0,0 +1,144 @@
|
|||
package com.bonus.material.clz.controller;
|
||||
|
||||
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.clz.domain.vo.MaterialSltAgreementInfo;
|
||||
import com.bonus.material.clz.domain.vo.sltAgreementInfo.MaterialSltInfoVo;
|
||||
import com.bonus.material.clz.service.ClzSltAgreementInfoService;
|
||||
import com.bonus.material.settlement.domain.SltAgreementReduce;
|
||||
import com.bonus.material.settlement.domain.SltAgreementRelation;
|
||||
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.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")
|
||||
@Slf4j
|
||||
public class ClzSltAgreementInfoController extends BaseController {
|
||||
|
||||
@Resource
|
||||
private ClzSltAgreementInfoService clzSltAgreementInfoService;
|
||||
|
||||
@Resource
|
||||
private TmTaskMapper taskMapper;
|
||||
|
||||
/**
|
||||
* 根据条件获取协议结算列表
|
||||
*/
|
||||
@ApiOperation(value = "根据条件获取协议结算列表")
|
||||
@GetMapping("/getSltAgreementInfo4Project")
|
||||
public TableDataInfo getSltAgreementInfo4Project(MaterialSltAgreementInfo bean) {
|
||||
startPage();
|
||||
List<MaterialSltAgreementInfo> list = clzSltAgreementInfoService.getSltAgreementInfo4Project(bean);
|
||||
return getDataTable(list);
|
||||
}
|
||||
|
||||
@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();
|
||||
}
|
||||
bean = mergerData(bean, dataList,unitNames,projectNames);
|
||||
// 根据协议id获取申请时间
|
||||
TmTask tmTask = taskMapper.selectTaskByIdByCl(agreementId);
|
||||
if (tmTask != null) {
|
||||
bean.setApplyTime(tmTask.getCreateTime());
|
||||
}
|
||||
return AjaxResult.success(bean);
|
||||
}
|
||||
|
||||
public MaterialSltInfoVo mergerData(MaterialSltInfoVo vo,List<MaterialSltInfoVo> list,List<String> unitNames,List<String> projectNames){
|
||||
vo.setUnitName(handleData(unitNames));
|
||||
vo.setProjectName(handleData(projectNames));
|
||||
BigDecimal leaseCost = BigDecimal.valueOf(0.00);
|
||||
BigDecimal repairCost = BigDecimal.valueOf(0.00);
|
||||
BigDecimal scrapCost = BigDecimal.valueOf(0.00);
|
||||
BigDecimal loseCost = BigDecimal.valueOf(0.00);
|
||||
BigDecimal reducCost = BigDecimal.valueOf(0.00);
|
||||
//租赁费用列表
|
||||
List<MaterialSltAgreementInfo> leaseList = new ArrayList<>();
|
||||
//维修费用列表
|
||||
List<MaterialSltAgreementInfo> repairList = new ArrayList<>();
|
||||
//报废费用列表
|
||||
List<MaterialSltAgreementInfo> scrapList = new ArrayList<>();
|
||||
//丢失费用列表
|
||||
List<MaterialSltAgreementInfo> loseList = new ArrayList<>();
|
||||
//减免费用列表
|
||||
List<SltAgreementReduce> reductionList = new ArrayList<>();
|
||||
List<SltAgreementRelation> relations = new ArrayList<>();
|
||||
for (MaterialSltInfoVo infoVo : list) {
|
||||
leaseCost = leaseCost.add(infoVo.getLeaseCost());
|
||||
repairCost = repairCost.add(infoVo.getRepairCost());
|
||||
scrapCost = scrapCost.add(infoVo.getScrapCost());
|
||||
loseCost = loseCost.add(infoVo.getLoseCost());
|
||||
reducCost = reducCost.add(infoVo.getReductionCost());
|
||||
leaseList.addAll(infoVo.getLeaseList());
|
||||
repairList.addAll(infoVo.getRepairList());
|
||||
scrapList.addAll(infoVo.getScrapList());
|
||||
loseList.addAll(infoVo.getLoseList());
|
||||
reductionList.addAll(infoVo.getReductionList());
|
||||
relations.addAll(infoVo.getRelations());
|
||||
}
|
||||
vo.setLeaseList(leaseList);
|
||||
vo.setRepairList(repairList);
|
||||
vo.setScrapList(scrapList);
|
||||
vo.setLoseList(loseList);
|
||||
vo.setReductionList(reductionList);
|
||||
vo.setLeaseCost(leaseCost);
|
||||
vo.setRepairCost(repairCost);
|
||||
vo.setScrapCost(scrapCost);
|
||||
vo.setLoseCost(loseCost);
|
||||
vo.setReductionCost(reducCost);
|
||||
vo.setRelations(relations);
|
||||
return vo;
|
||||
}
|
||||
|
||||
public String handleData(List<String> list){
|
||||
StringBuilder sb = new StringBuilder();
|
||||
Set<String> set = new HashSet<>(list);
|
||||
for (String str : set) {
|
||||
sb.append(str).append("、");
|
||||
}
|
||||
return StringUtils.removeEnd(sb.toString(), "、");
|
||||
}
|
||||
|
||||
/**
|
||||
* 提交结算清单
|
||||
*/
|
||||
@ApiOperation(value = "提交结算清单")
|
||||
@PostMapping("/submitCosts")
|
||||
public AjaxResult submitCosts(@RequestBody MaterialSltInfoVo sltInfoVo) {
|
||||
try {
|
||||
return toAjax(clzSltAgreementInfoService.submitCosts(sltInfoVo));
|
||||
} catch (Exception e) {
|
||||
return error("系统错误, " + e.getMessage());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,127 @@
|
|||
package com.bonus.material.clz.domain.vo.sltAgreementInfo;
|
||||
|
||||
import com.bonus.common.core.annotation.Excel;
|
||||
import com.bonus.material.clz.domain.vo.MaterialSltAgreementInfo;
|
||||
import com.bonus.material.settlement.domain.SltAgreementReduce;
|
||||
import com.bonus.material.settlement.domain.SltAgreementRelation;
|
||||
import com.fasterxml.jackson.annotation.JsonFormat;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Data;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @author c liu
|
||||
* @date 2024/2/23
|
||||
*/
|
||||
@Data
|
||||
public class MaterialSltInfoVo {
|
||||
|
||||
/**
|
||||
* 结算单位
|
||||
*/
|
||||
private String unitName;
|
||||
/**
|
||||
* 结算工程
|
||||
*/
|
||||
private String projectName;
|
||||
/**
|
||||
* 租赁费用列表
|
||||
*/
|
||||
List<MaterialSltAgreementInfo> leaseList;
|
||||
/**
|
||||
* 维修费用列表
|
||||
*/
|
||||
List<MaterialSltAgreementInfo> repairList;
|
||||
/**
|
||||
* 报废费用列表
|
||||
*/
|
||||
List<MaterialSltAgreementInfo> scrapList;
|
||||
/**
|
||||
* 丢失费用列表
|
||||
*/
|
||||
List<MaterialSltAgreementInfo> loseList;
|
||||
|
||||
/**
|
||||
* 减免费用列表
|
||||
*/
|
||||
List<SltAgreementReduce> reductionList;
|
||||
|
||||
List<SltAgreementRelation> relations;
|
||||
|
||||
/**
|
||||
* 租赁费用小计
|
||||
*/
|
||||
@ApiModelProperty(value = "租赁费用小计")
|
||||
private BigDecimal leaseCost;
|
||||
|
||||
/**
|
||||
* 维修费用小计
|
||||
*/
|
||||
@ApiModelProperty(value = "维修费用小计")
|
||||
private BigDecimal repairCost;
|
||||
|
||||
/**
|
||||
* 报废费用小计
|
||||
*/
|
||||
@ApiModelProperty(value = "报废费用小计")
|
||||
private BigDecimal scrapCost;
|
||||
|
||||
/**
|
||||
* 丢失费用小计
|
||||
*/
|
||||
@ApiModelProperty(value = "丢失费用小计")
|
||||
private BigDecimal loseCost;
|
||||
|
||||
/**
|
||||
* 减免费用小计
|
||||
*/
|
||||
@ApiModelProperty(value = "减免费用小计")
|
||||
private BigDecimal reductionCost;
|
||||
|
||||
/**
|
||||
* 合计
|
||||
*/
|
||||
@ApiModelProperty(value = "合计")
|
||||
private BigDecimal totalCostAll;
|
||||
|
||||
@Excel(name = "创建人")
|
||||
private String createBy;
|
||||
|
||||
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
|
||||
@Excel(name = "创建时间", dateFormat = "yyyy-MM-dd HH:mm:ss")
|
||||
private Date createTime;
|
||||
|
||||
private String updateBy;
|
||||
|
||||
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
|
||||
private Date updateTime;
|
||||
|
||||
/** 协议id */
|
||||
|
||||
@ApiModelProperty(value = "协议id")
|
||||
private Long agreementId;
|
||||
|
||||
/**
|
||||
* 协议编号
|
||||
*/
|
||||
|
||||
@ApiModelProperty(value = "协议编号")
|
||||
private String agreementCode;
|
||||
|
||||
/** 协议 ids */
|
||||
|
||||
@ApiModelProperty(value = "协议ids")
|
||||
private Long[] agreementIds;
|
||||
|
||||
private Long id; //申请id
|
||||
|
||||
String cost;
|
||||
|
||||
@ApiModelProperty(value = "申请时间")
|
||||
@JsonFormat(pattern = "yyyy-MM-dd")
|
||||
private Date applyTime;
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,86 @@
|
|||
package com.bonus.material.clz.mapper;
|
||||
|
||||
import com.bonus.material.clz.domain.vo.MaterialSltAgreementInfo;
|
||||
import com.bonus.material.clz.domain.vo.sltAgreementInfo.MaterialSltInfoVo;
|
||||
import com.bonus.material.settlement.domain.SltAgreementReduce;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @Author ma_sh
|
||||
* @create 2025/6/27 15:21
|
||||
*/
|
||||
public interface ClzSltAgreementInfoMapper {
|
||||
|
||||
/**
|
||||
* 获取协议结算列表
|
||||
* @param bean
|
||||
* @return
|
||||
*/
|
||||
List<MaterialSltAgreementInfo> getSltAgreementInfo4Project(MaterialSltAgreementInfo bean);
|
||||
|
||||
/**
|
||||
* 获取租赁列表
|
||||
* @param info
|
||||
* @return
|
||||
*/
|
||||
List<MaterialSltAgreementInfo> getLeaseList(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);
|
||||
}
|
||||
|
|
@ -0,0 +1,34 @@
|
|||
package com.bonus.material.clz.service;
|
||||
|
||||
import com.bonus.material.clz.domain.vo.MaterialSltAgreementInfo;
|
||||
import com.bonus.material.clz.domain.vo.sltAgreementInfo.MaterialSltInfoVo;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @Author ma_sh
|
||||
* @create 2025/6/27 15:20
|
||||
*/
|
||||
public interface ClzSltAgreementInfoService {
|
||||
|
||||
/**
|
||||
* 根据条件获取协议结算列表
|
||||
* @param bean
|
||||
* @return
|
||||
*/
|
||||
List<MaterialSltAgreementInfo> getSltAgreementInfo4Project(MaterialSltAgreementInfo bean);
|
||||
|
||||
/**
|
||||
* 获取结算清单
|
||||
* @param info
|
||||
* @return
|
||||
*/
|
||||
MaterialSltInfoVo getSltInfo(MaterialSltAgreementInfo info);
|
||||
|
||||
/**
|
||||
* 提交结算清单
|
||||
* @param sltInfoVo
|
||||
* @return
|
||||
*/
|
||||
int submitCosts(MaterialSltInfoVo sltInfoVo);
|
||||
}
|
||||
|
|
@ -0,0 +1,352 @@
|
|||
package com.bonus.material.clz.service.impl;
|
||||
|
||||
import com.bonus.common.core.exception.ServiceException;
|
||||
import com.bonus.common.core.utils.DateUtils;
|
||||
import com.bonus.common.security.utils.SecurityUtils;
|
||||
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.settlement.domain.SltAgreementReduce;
|
||||
import com.bonus.material.settlement.domain.SltAgreementRelation;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.math.BigDecimal;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
/**
|
||||
* @Author ma_sh
|
||||
* @create 2025/6/27 15:20
|
||||
*/
|
||||
@Service
|
||||
public class ClzSltAgreementInfoServiceImpl implements ClzSltAgreementInfoService {
|
||||
|
||||
@Resource
|
||||
private ClzSltAgreementInfoMapper clzSltAgreementInfoMapper;
|
||||
|
||||
/**
|
||||
* 根据条件获取协议结算列表
|
||||
* @param bean
|
||||
* @return
|
||||
*/
|
||||
@Override
|
||||
public List<MaterialSltAgreementInfo> getSltAgreementInfo4Project(MaterialSltAgreementInfo bean) {
|
||||
return clzSltAgreementInfoMapper.getSltAgreementInfo4Project(bean);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取结算清单
|
||||
* @param info
|
||||
* @return
|
||||
*/
|
||||
@Override
|
||||
public MaterialSltInfoVo getSltInfo(MaterialSltAgreementInfo info) {
|
||||
MaterialSltInfoVo sltInfoVo = new MaterialSltInfoVo();
|
||||
sltInfoVo.setUnitName(info.getUnitName());
|
||||
sltInfoVo.setProjectName(info.getProjectName());
|
||||
BigDecimal leaseCost = BigDecimal.valueOf(0.00);
|
||||
BigDecimal repairCost = BigDecimal.valueOf(0.00);
|
||||
BigDecimal scrapCost = BigDecimal.valueOf(0.00);
|
||||
BigDecimal loseCost = BigDecimal.valueOf(0.00);
|
||||
BigDecimal reducCost = BigDecimal.valueOf(0.00);
|
||||
//租赁费用列表
|
||||
List<MaterialSltAgreementInfo> leaseList = getLeaseList(info);
|
||||
//维修费用列表
|
||||
List<MaterialSltAgreementInfo> repairList = new ArrayList<>();
|
||||
//报废费用列表
|
||||
List<MaterialSltAgreementInfo> scrapList = new ArrayList<>();
|
||||
//丢失费用列表
|
||||
List<MaterialSltAgreementInfo> loseList = getLoseList(info);
|
||||
|
||||
List<SltAgreementReduce> reductionList = getReductionList(info);
|
||||
sltInfoVo.setLeaseList(leaseList);
|
||||
sltInfoVo.setRepairList(repairList);
|
||||
sltInfoVo.setScrapList(scrapList);
|
||||
sltInfoVo.setLoseList(loseList);
|
||||
sltInfoVo.setReductionList(reductionList);
|
||||
for (MaterialSltAgreementInfo lease : leaseList) {
|
||||
if(lease.getCosts()!=null){
|
||||
leaseCost = leaseCost.add(lease.getCosts());
|
||||
}
|
||||
}
|
||||
/*for (MaterialSltAgreementInfo repair : repairList) {
|
||||
if(repair.getCosts()!=null && (repair.getPartType().equals("收费"))){
|
||||
repairCost = repairCost.add(repair.getCosts());
|
||||
}
|
||||
}
|
||||
for (MaterialSltAgreementInfo scrap : scrapList) {
|
||||
if(scrap.getCosts()!=null && (scrap.getPartType().equals("收费"))){
|
||||
scrapCost = scrapCost.add(scrap.getCosts());
|
||||
}
|
||||
}*/
|
||||
for (MaterialSltAgreementInfo lose : loseList) {
|
||||
if(lose.getCosts()!=null){
|
||||
loseCost = loseCost.add(lose.getCosts());
|
||||
}
|
||||
}
|
||||
for (SltAgreementReduce reduction : reductionList) {
|
||||
if(reduction.getReduceLeaseMoney()!=null){
|
||||
reducCost = reducCost.add(reduction.getReduceLeaseMoney());
|
||||
}
|
||||
}
|
||||
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);
|
||||
return sltInfoVo;
|
||||
}
|
||||
|
||||
/**
|
||||
* 提交结算清单
|
||||
* @param sltInfoVo
|
||||
* @return
|
||||
*/
|
||||
@Override
|
||||
public int submitCosts(MaterialSltInfoVo sltInfoVo) {
|
||||
try {
|
||||
if(sltInfoVo.getAgreementIds()!=null) {
|
||||
|
||||
for (Long agreementId : sltInfoVo.getAgreementIds()) {
|
||||
Long id = null;
|
||||
sltInfoVo.setAgreementId(agreementId);
|
||||
// 计算总成本
|
||||
BigDecimal totalCost = BigDecimal.ZERO;
|
||||
MaterialSltAgreementInfo info = new MaterialSltAgreementInfo();
|
||||
info.setAgreementId(agreementId);
|
||||
|
||||
// 获取各项成本并累加
|
||||
totalCost = totalCost.add(getLeaseList(info).stream()
|
||||
.map(MaterialSltAgreementInfo::getCosts)
|
||||
.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)
|
||||
.reduce(BigDecimal.ZERO, BigDecimal::add));
|
||||
|
||||
totalCost = totalCost.subtract(getReductionList(info).stream()
|
||||
.map(SltAgreementReduce::getLeaseMoney)
|
||||
.filter(Objects::nonNull)
|
||||
.reduce(BigDecimal.ZERO, BigDecimal::add));
|
||||
|
||||
// 设置总成本
|
||||
sltInfoVo.setTotalCostAll(totalCost);
|
||||
//查找是否驳回
|
||||
int countReject = clzSltAgreementInfoMapper.getRejectCount(sltInfoVo);
|
||||
if (countReject > 0) {
|
||||
id = clzSltAgreementInfoMapper.getRejectId(sltInfoVo);
|
||||
//修改
|
||||
int countAgain = clzSltAgreementInfoMapper.updateRejectCount(sltInfoVo);
|
||||
if (countAgain == 0) {
|
||||
throw new ServiceException("slt_agreement_apply修改失败");
|
||||
}
|
||||
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()));
|
||||
//新增
|
||||
int countOne = clzSltAgreementInfoMapper.insertSltAgreementApply(sltInfoVo);
|
||||
if (countOne != 1) {
|
||||
throw new ServiceException("slt_agreement_apply新增失败");
|
||||
}
|
||||
// 插入成功后,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().size() > 0) {
|
||||
List<MaterialSltAgreementInfo> filteredLeaseList = sltInfoVo.getLeaseList().stream()
|
||||
.filter(lease -> lease.getAgreementId().equals(sltInfoVo.getAgreementId()))
|
||||
.collect(Collectors.toList());
|
||||
if (!filteredLeaseList.isEmpty()) {
|
||||
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().size() > 0) {
|
||||
List<MaterialSltAgreementInfo> filteredLoseList = sltInfoVo.getLoseList().stream()
|
||||
.filter(lease -> lease.getAgreementId().equals(sltInfoVo.getAgreementId()))
|
||||
.collect(Collectors.toList());
|
||||
if (!filteredLoseList.isEmpty()) {
|
||||
clzSltAgreementInfoMapper.insertSltAgreementDetailLose(filteredLoseList, id);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return 1;
|
||||
} catch (Exception e) {
|
||||
throw new ServiceException("错误信息描述");
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取结算关系列表
|
||||
* @param leaseList
|
||||
* @param repairList
|
||||
* @param scrapList
|
||||
* @param loseList
|
||||
* @param sltInfo
|
||||
* @return
|
||||
*/
|
||||
private List<SltAgreementRelation> getRelations(List<MaterialSltAgreementInfo> leaseList, List<MaterialSltAgreementInfo> repairList, List<MaterialSltAgreementInfo> scrapList, List<MaterialSltAgreementInfo> loseList, MaterialSltAgreementInfo sltInfo) {
|
||||
List<SltAgreementRelation> relations = new ArrayList<>();
|
||||
// for (SltAgreementInfo info : list) {
|
||||
SltAgreementRelation relation = new SltAgreementRelation();
|
||||
BigDecimal loseCost = BigDecimal.ZERO;
|
||||
BigDecimal leaseCost = BigDecimal.ZERO;
|
||||
BigDecimal scrapCost = BigDecimal.ZERO;
|
||||
BigDecimal repairCost = BigDecimal.ZERO;
|
||||
for (MaterialSltAgreementInfo lease : leaseList) {
|
||||
if (lease.getAgreementId().equals(sltInfo.getAgreementId().toString())) {
|
||||
relation.setAgreementId(String.valueOf(lease.getAgreementId()));
|
||||
relation.setProjectName(lease.getProjectName());
|
||||
relation.setUnitName(lease.getUnitName());
|
||||
relation.setCompanyId(lease.getCompanyId());
|
||||
BigDecimal cost = lease.getCosts();
|
||||
leaseCost = leaseCost.add(cost);
|
||||
}
|
||||
}
|
||||
for (MaterialSltAgreementInfo repair : repairList) {
|
||||
if (repair.getAgreementId().equals(sltInfo.getAgreementId().toString())) {
|
||||
BigDecimal cost = repair.getCosts();
|
||||
repairCost = repairCost.add(cost);
|
||||
}
|
||||
}
|
||||
for (MaterialSltAgreementInfo scrap : scrapList) {
|
||||
if (scrap.getAgreementId().equals(sltInfo.getAgreementId().toString())) {
|
||||
BigDecimal cost = scrap.getCosts();
|
||||
scrapCost = scrapCost.add(cost);
|
||||
}
|
||||
}
|
||||
for (MaterialSltAgreementInfo lose : loseList) {
|
||||
if (lose.getAgreementId().equals(sltInfo.getAgreementId().toString())) {
|
||||
//TODO 上面已经set过值,这里为什么还要set值
|
||||
relation.setAgreementId(String.valueOf(lose.getAgreementId()));
|
||||
relation.setProjectName(lose.getProjectName());
|
||||
relation.setUnitName(lose.getUnitName());
|
||||
relation.setCompanyId(lose.getCompanyId());
|
||||
BigDecimal cost = lose.getCosts();
|
||||
loseCost = loseCost.add(cost);
|
||||
}
|
||||
}
|
||||
relation.setLeaseCost(leaseCost);
|
||||
relation.setRepairCost(repairCost);
|
||||
relation.setScrapCost(scrapCost);
|
||||
relation.setLoseCost(loseCost);
|
||||
relations.add(relation);
|
||||
// }
|
||||
return relations;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取减免费用列表
|
||||
* @param info
|
||||
* @return
|
||||
*/
|
||||
private List<SltAgreementReduce> getReductionList(MaterialSltAgreementInfo info) {
|
||||
SltAgreementReduce bean =new SltAgreementReduce();
|
||||
bean.setAgreementId(info.getAgreementId());
|
||||
return clzSltAgreementInfoMapper.getReductionList(bean);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取丢失费用列表
|
||||
* @param info
|
||||
* @return
|
||||
*/
|
||||
private List<MaterialSltAgreementInfo> getLoseList(MaterialSltAgreementInfo info) {
|
||||
List<MaterialSltAgreementInfo> loseList = new ArrayList<>();
|
||||
|
||||
List<MaterialSltAgreementInfo> oneOfList = clzSltAgreementInfoMapper.getLoseList(info);
|
||||
loseList.addAll(oneOfList);
|
||||
|
||||
for (MaterialSltAgreementInfo bean : loseList) {
|
||||
if (null == bean.getBuyPrice()) {
|
||||
bean.setBuyPrice(BigDecimal.valueOf(0.00));
|
||||
}
|
||||
if (null == bean.getNum()) {
|
||||
bean.setNum(BigDecimal.valueOf(0L));
|
||||
}
|
||||
BigDecimal buyPrice = bean.getBuyPrice();
|
||||
BigDecimal num = bean.getNum();
|
||||
// 原价 x 数量
|
||||
BigDecimal costs = buyPrice.multiply(num);
|
||||
//计算租赁费用
|
||||
bean.setCosts(costs);
|
||||
}
|
||||
return loseList;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取租赁费用列表
|
||||
* @param info
|
||||
* @return
|
||||
*/
|
||||
private List<MaterialSltAgreementInfo> getLeaseList(MaterialSltAgreementInfo info) {
|
||||
List<MaterialSltAgreementInfo> leaseList = new ArrayList<>();
|
||||
|
||||
List<MaterialSltAgreementInfo> oneOfList = clzSltAgreementInfoMapper.getLeaseList(info);
|
||||
leaseList.addAll(oneOfList);
|
||||
|
||||
for (MaterialSltAgreementInfo bean : leaseList) {
|
||||
if (null == bean.getLeasePrice()) {
|
||||
bean.setLeasePrice(BigDecimal.valueOf(0.00));
|
||||
}else{
|
||||
bean.setLeasePrice(bean.getLeasePrice().setScale(2, BigDecimal.ROUND_HALF_UP));
|
||||
}
|
||||
if (null == bean.getNum()) {
|
||||
bean.setNum(BigDecimal.valueOf(0L));
|
||||
}
|
||||
if (null == 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, BigDecimal.ROUND_HALF_UP);
|
||||
bean.setCosts(costs);
|
||||
}
|
||||
return leaseList;
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,176 @@
|
|||
<?xml version="1.0" encoding="UTF-8" ?>
|
||||
<!DOCTYPE mapper
|
||||
PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
||||
<mapper namespace="com.bonus.material.clz.mapper.ClzSltAgreementInfoMapper">
|
||||
<insert id="insertSltAgreementApply" useGeneratedKeys="true" keyProperty="id">
|
||||
insert into clz_slt_agreement_apply
|
||||
<trim prefix="(" suffix=")" suffixOverrides=",">
|
||||
<if test="agreementId != null">agreement_id,</if>
|
||||
<if test="agreementCode != null">code,</if>
|
||||
<if test="createBy != null">creator,</if>
|
||||
<if test="createTime != null">create_time,</if>
|
||||
status,
|
||||
<if test="totalCostAll != null">cost,</if>
|
||||
</trim>
|
||||
<trim prefix="values (" suffix=")" suffixOverrides=",">
|
||||
<if test="agreementId != null">#{agreementId},</if>
|
||||
<if test="agreementCode != null">#{agreementCode},</if>
|
||||
<if test="createBy != null">#{createBy},</if>
|
||||
<if test="createTime != null">#{createTime},</if>
|
||||
1,
|
||||
<if test="totalCostAll != null">#{totalCostAll},</if>
|
||||
</trim>
|
||||
</insert>
|
||||
|
||||
<insert id="insertSltAgreementDetailLease">
|
||||
insert into clz_slt_agreement_details (apply_id, type_id,ma_id,slt_type,num,start_time,end_time,price,money)
|
||||
values
|
||||
<foreach collection="list" item="item" separator=",">
|
||||
(#{id}, #{item.typeId}, #{item.maId},1,#{item.num},#{item.startTime},#{item.endTime},#{item.leasePrice},#{item.costs})
|
||||
</foreach>
|
||||
</insert>
|
||||
|
||||
<insert id="insertSltAgreementDetailLose">
|
||||
insert into clz_slt_agreement_details (apply_id, type_id,ma_id,slt_type,num,money)
|
||||
values
|
||||
<foreach collection="list" item="item" separator=",">
|
||||
(#{id}, #{item.typeId}, #{item.maId},2,#{item.num},#{item.costs})
|
||||
</foreach>
|
||||
</insert>
|
||||
|
||||
<update id="updateRejectCount">
|
||||
update clz_slt_agreement_apply
|
||||
set status = '1',
|
||||
update_time = now(),
|
||||
audit_Time = null,
|
||||
auditor = null,
|
||||
remark = null,
|
||||
cost = #{totalCostAll}
|
||||
where agreement_id = #{agreementId}
|
||||
</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 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 sai.id,
|
||||
sai.agreement_id as agreementId,
|
||||
bui.unit_name as unitName,
|
||||
bp.pro_name as projectName,
|
||||
sai.company_id as companyId,
|
||||
sai.type_id as typeId,
|
||||
sai.ma_id as maId,
|
||||
mt1.type_name as typeName,
|
||||
mt.type_name as modelName,
|
||||
mt.unit_name as mtUnitName,
|
||||
sai.lease_price as leasePrice,
|
||||
sai.num as num,
|
||||
DATE(sai.start_time) as startTime,
|
||||
DATE(sai.end_time) as endTime,
|
||||
DATEDIFF(IF(sai.end_time is null,CURDATE(),sai.end_time), sai.start_time) + 1 as leaseDays
|
||||
from clz_slt_agreement_info sai
|
||||
LEFT JOIN bm_agreement_info bai on sai.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 ma_type mt on sai.type_id = mt.type_id
|
||||
left join ma_type mt1 on mt.parent_id = mt1.type_id
|
||||
where sai.agreement_id = #{agreementId}
|
||||
</select>
|
||||
|
||||
<select id="getLoseList"
|
||||
resultType="com.bonus.material.clz.domain.vo.MaterialSltAgreementInfo">
|
||||
select sai.id,
|
||||
sai.agreement_id as agreementId,
|
||||
bui.unit_name as unitName,
|
||||
bp.pro_name as projectName,
|
||||
sai.company_id as companyId,
|
||||
sai.type_id as typeId,
|
||||
sai.ma_id as maId,
|
||||
mt1.type_name as typeName,
|
||||
mt.type_name as modelName,
|
||||
mt.unit_name as mtUnitName,
|
||||
sai.buy_price as buyPrice,
|
||||
sai.num as num,
|
||||
sai.start_time as startTime,
|
||||
sai.end_time as endTime,
|
||||
DATEDIFF(sai.end_time, sai.start_time) + 1 as leaseDays
|
||||
from clz_slt_agreement_info sai
|
||||
LEFT JOIN bm_agreement_info bai on sai.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 ma_type mt on sai.type_id = mt.type_id
|
||||
left join ma_type mt1 on mt.parent_id = mt1.type_id
|
||||
where sai.agreement_id = #{agreementId} and sai.end_time is null
|
||||
</select>
|
||||
|
||||
<select id="getReductionList" resultType="com.bonus.material.settlement.domain.SltAgreementReduce">
|
||||
SELECT mt2.type_name as typeName,
|
||||
mt.type_name as modeName,
|
||||
mt.type_name as modelName,
|
||||
mt.unit_name as unitName,
|
||||
srd.lease_price as leasePrice,
|
||||
srd.reduce_num as reduceNum,
|
||||
srd.start_time as startTime,
|
||||
srd.end_time as endTime,
|
||||
srd.days as days,
|
||||
srd.lease_money as leaseMoney,
|
||||
sra.remark
|
||||
FROM clz_slt_reduce_apply sra
|
||||
INNER JOIN clz_slt_reduce_details srd on sra.id = srd.apply_id
|
||||
LEFT JOIN ma_type mt on mt.type_id = srd.type_id
|
||||
LEFT JOIN ma_type mt2 on mt2.type_id = mt.parent_id
|
||||
WHERE sra.agreement_id = #{agreementId}
|
||||
</select>
|
||||
|
||||
<select id="getRejectCount" resultType="java.lang.Integer">
|
||||
select
|
||||
count(id)
|
||||
from clz_slt_agreement_apply saa
|
||||
where saa.agreement_id = #{agreementId}
|
||||
</select>
|
||||
|
||||
<select id="getRejectId" resultType="java.lang.Long">
|
||||
select
|
||||
id
|
||||
from clz_slt_agreement_apply saa
|
||||
where saa.agreement_id = #{agreementId}
|
||||
</select>
|
||||
</mapper>
|
||||
Loading…
Reference in New Issue