结算权限取消
This commit is contained in:
parent
c558165778
commit
1cdae3a38b
|
|
@ -19,6 +19,7 @@ import com.alibaba.fastjson.JSONObject;
|
|||
import com.bonus.common.biz.config.ListPagingUtil;
|
||||
import com.bonus.common.biz.config.PoiOutPage;
|
||||
import com.bonus.common.biz.constant.GlobalConstants;
|
||||
|
||||
import com.bonus.common.biz.utils.RequestContext;
|
||||
import com.bonus.common.core.exception.ServiceException;
|
||||
import com.bonus.common.core.utils.ServletUtils;
|
||||
|
|
@ -112,20 +113,20 @@ public class SltAgreementInfoController extends BaseController {
|
|||
public AjaxResult getSltAgreementInfo4Project(SltAgreementInfo bean) {
|
||||
Integer pageIndex = Convert.toInt(ServletUtils.getParameter("pageNum"), 1);
|
||||
Integer pageSize = Convert.toInt(ServletUtils.getParameter("pageSize"), 10);
|
||||
int loginUserHasSettlementPermission = sltAgreementInfoService.checkLoginUserHasSettlementPermission();
|
||||
if (bean != null) {
|
||||
bean.setSettlementType(loginUserHasSettlementPermission);
|
||||
} else {
|
||||
bean = new SltAgreementInfo();
|
||||
bean.setSettlementType(loginUserHasSettlementPermission);
|
||||
}
|
||||
// int loginUserHasSettlementPermission = sltAgreementInfoService.checkLoginUserHasSettlementPermission();
|
||||
// if (bean != null) {
|
||||
// bean.setSettlementType(loginUserHasSettlementPermission);
|
||||
// } else {
|
||||
// bean = new SltAgreementInfo();
|
||||
// bean.setSettlementType(loginUserHasSettlementPermission);
|
||||
// }
|
||||
List<SltAgreementInfo> list = sltAgreementInfoService.getSltAgreementInfo4Project(bean);
|
||||
ListPagingUtil paginated = ListPagingUtil.paging(pageIndex, pageSize, list);
|
||||
// 新增外层计算-- 计算当前分页数据的各条目费用
|
||||
if (CollectionUtils.isNotEmpty(paginated.getRows())) {
|
||||
for (Object row : paginated.getRows()) {
|
||||
if (row instanceof SltAgreementInfo) {
|
||||
((SltAgreementInfo) row).setSettlementType(loginUserHasSettlementPermission);
|
||||
((SltAgreementInfo) row).setSettlementType(bean.getSettlementType());
|
||||
}
|
||||
SltInfoVo sltInfoVo = null;
|
||||
if (row instanceof SltAgreementInfo) {
|
||||
|
|
@ -166,13 +167,13 @@ public class SltAgreementInfoController extends BaseController {
|
|||
if (CollectionUtil.isEmpty(list)) {
|
||||
return AjaxResult.error("请选择协议");
|
||||
}
|
||||
if (list.get(0).getSettlementType() == null || list.get(0).getSettlementType() < 1) {
|
||||
int settlementType = sltAgreementInfoService.checkLoginUserHasSettlementPermission();
|
||||
// 设置结算权限
|
||||
list.forEach(info -> info.setSettlementType(settlementType));
|
||||
} else {
|
||||
list.forEach(info -> info.setSettlementType(list.get(0).getSettlementType()));
|
||||
}
|
||||
// if (list.get(0).getSettlementType() == null || list.get(0).getSettlementType() < 1) {
|
||||
// int settlementType = sltAgreementInfoService.checkLoginUserHasSettlementPermission();
|
||||
// // 设置结算权限
|
||||
// list.forEach(info -> info.setSettlementType(settlementType));
|
||||
// } else {
|
||||
// list.forEach(info -> info.setSettlementType(list.get(0).getSettlementType()));
|
||||
// }
|
||||
|
||||
List<String> unitNames = new ArrayList<>();
|
||||
List<String> projectNames = new ArrayList<>();
|
||||
|
|
|
|||
|
|
@ -162,6 +162,11 @@ public class SltInfoVo {
|
|||
@ApiModelProperty(value = "承租负责人签字")
|
||||
private String managerSignUrl;
|
||||
|
||||
|
||||
/** 结算批次 */
|
||||
@ApiModelProperty(value = "结算批次")
|
||||
private String settlementTask;
|
||||
|
||||
/** 签字类型 */
|
||||
@ApiModelProperty(value = "签字类型")
|
||||
private long signType;
|
||||
|
|
|
|||
|
|
@ -343,4 +343,8 @@ public interface SltAgreementInfoMapper {
|
|||
List<SltAgreementInfo> selectAgreementInfoList(SltAgreementInfo bean);
|
||||
|
||||
List<SltAgreementInfo> getSltLoseList(SltAgreementInfo info);
|
||||
|
||||
List<SltAgreementInfo> getSltRepairDetailsList(SltAgreementInfo info);
|
||||
|
||||
List<SltAgreementInfo> getSltScrapDetailsList(SltAgreementInfo info);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -2,13 +2,9 @@ package com.bonus.material.settlement.service.impl;
|
|||
|
||||
import java.math.BigDecimal;
|
||||
import java.math.RoundingMode;
|
||||
import java.time.LocalDate;
|
||||
import java.time.ZoneId;
|
||||
import java.util.*;
|
||||
import java.util.function.Function;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import cn.hutool.core.date.DateUtil;
|
||||
import com.bonus.common.biz.constant.GlobalConstants;
|
||||
import com.bonus.common.biz.domain.ProjectTreeBuild;
|
||||
import com.bonus.common.biz.domain.ProjectTreeNode;
|
||||
|
|
@ -35,7 +31,6 @@ import com.bonus.material.task.domain.TmTask;
|
|||
import com.bonus.material.task.mapper.TmTaskMapper;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.apache.commons.collections4.CollectionUtils;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
import com.bonus.material.settlement.mapper.SltAgreementInfoMapper;
|
||||
import com.bonus.material.settlement.domain.SltAgreementInfo;
|
||||
|
|
@ -501,19 +496,26 @@ public class SltAgreementInfoServiceImpl implements ISltAgreementInfoService {
|
|||
|
||||
public List<SltAgreementInfo> getRepairList(SltAgreementInfo info) {
|
||||
List<SltAgreementInfo> repairList = new ArrayList<>();
|
||||
List<TmTask> taskList = taskMapper.getTaskIdList(info);
|
||||
if (info != null && info.getEnableQuerySltData() != null && info.getEnableQuerySltData()) {
|
||||
repairList = sltAgreementInfoMapper.getSltRepairDetailsList(info);
|
||||
} else {
|
||||
List<TmTask> taskList = taskMapper.getTaskIdList(info);
|
||||
|
||||
List<TmTask> taskList2 = new ArrayList<>();
|
||||
taskList2 = checkTeamAgreementInfo(info);
|
||||
List<TmTask> taskList2 = new ArrayList<>();
|
||||
taskList2 = checkTeamAgreementInfo(info);
|
||||
|
||||
if (null != taskList && !taskList.isEmpty()) {
|
||||
if (null != taskList2 && !taskList2.isEmpty()) {
|
||||
taskList.addAll(taskList2);
|
||||
if (null != taskList && !taskList.isEmpty()) {
|
||||
if (null != taskList2 && !taskList2.isEmpty()) {
|
||||
taskList.addAll(taskList2);
|
||||
}
|
||||
|
||||
List<SltAgreementInfo> repairDetailsList = sltAgreementInfoMapper.getRepairDetailsList(info, taskList);
|
||||
repairList.addAll(repairDetailsList);
|
||||
}
|
||||
|
||||
List<SltAgreementInfo> repairDetailsList = sltAgreementInfoMapper.getRepairDetailsList(info, taskList);
|
||||
repairList.addAll(repairDetailsList);
|
||||
}
|
||||
|
||||
|
||||
|
||||
return repairList;
|
||||
}
|
||||
|
||||
|
|
@ -543,19 +545,26 @@ public class SltAgreementInfoServiceImpl implements ISltAgreementInfoService {
|
|||
|
||||
public List<SltAgreementInfo> getScrapList(SltAgreementInfo info) {
|
||||
List<SltAgreementInfo> scrapList = new ArrayList<>();
|
||||
List<TmTask> taskList = taskMapper.getTaskIdList(info);
|
||||
|
||||
List<TmTask> taskList2 = new ArrayList<>();
|
||||
taskList2 = checkTeamAgreementInfo(info);
|
||||
if (info != null && info.getEnableQuerySltData() != null && info.getEnableQuerySltData()) {
|
||||
scrapList = sltAgreementInfoMapper.getSltScrapDetailsList(info);
|
||||
} else {
|
||||
List<TmTask> taskList = taskMapper.getTaskIdList(info);
|
||||
|
||||
if (null != taskList && !taskList.isEmpty()) {
|
||||
List<TmTask> taskList2 = new ArrayList<>();
|
||||
taskList2 = checkTeamAgreementInfo(info);
|
||||
|
||||
if (null != taskList2 && !taskList2.isEmpty()) {
|
||||
taskList.addAll(taskList2);
|
||||
if (null != taskList && !taskList.isEmpty()) {
|
||||
|
||||
if (null != taskList2 && !taskList2.isEmpty()) {
|
||||
taskList.addAll(taskList2);
|
||||
}
|
||||
List<SltAgreementInfo> scrapDetailsList = sltAgreementInfoMapper.getScrapDetailsList(info, taskList);
|
||||
scrapList.addAll(scrapDetailsList);
|
||||
}
|
||||
List<SltAgreementInfo> scrapDetailsList = sltAgreementInfoMapper.getScrapDetailsList(info, taskList);
|
||||
scrapList.addAll(scrapDetailsList);
|
||||
}
|
||||
|
||||
|
||||
return scrapList;
|
||||
}
|
||||
|
||||
|
|
@ -700,146 +709,167 @@ public class SltAgreementInfoServiceImpl implements ISltAgreementInfoService {
|
|||
@Transactional(rollbackFor = Exception.class)
|
||||
public int submitCosts(@NotNull(message = "结算信息不能为空") SltInfoVo sltInfoVo) {
|
||||
// 检查登录用户是否有结算权限
|
||||
int loginUserSettlementTypePermission = this.checkLoginUserHasSettlementPermission();
|
||||
sltInfoVo.setSettlementType(loginUserSettlementTypePermission);
|
||||
if (sltInfoVo.getSettlementType() == null) {
|
||||
throw new ServiceException("结算类型错误,结算权限码为空");
|
||||
}
|
||||
if (sltInfoVo.getSettlementType()!=EQUIPMENT_SETTLEMENT_TYPE && sltInfoVo.getSettlementType()!=SAFETY_EQUIPMENT_SETTLEMENT_TYPE) {
|
||||
throw new ServiceException("结算类型错误,结算权限码不合法!");
|
||||
}
|
||||
// int loginUserSettlementTypePermission = this.checkLoginUserHasSettlementPermission();
|
||||
// sltInfoVo.setSettlementType(loginUserSettlementTypePermission);
|
||||
// if (sltInfoVo.getSettlementType() == null) {
|
||||
// throw new ServiceException("结算类型错误,结算权限码为空");
|
||||
// }
|
||||
// if (sltInfoVo.getSettlementType()!=EQUIPMENT_SETTLEMENT_TYPE && sltInfoVo.getSettlementType()!=SAFETY_EQUIPMENT_SETTLEMENT_TYPE) {
|
||||
// throw new ServiceException("结算类型错误,结算权限码不合法!");
|
||||
// }
|
||||
|
||||
//如果结算类型为空,则生成2次提交任务,分别为工器具和安全工器具
|
||||
try {
|
||||
if (sltInfoVo.getAgreementIds() != null) {
|
||||
for (Long agreementId : sltInfoVo.getAgreementIds()) {
|
||||
if (agreementId == null || agreementId <= 0) {
|
||||
throw new ServiceException("协议id错误");
|
||||
}
|
||||
|
||||
// 查询【待审核】+【审核通过】的结算单数量
|
||||
int theSettledCount = sltAgreementInfoMapper.selectTheSettledCountByAgreementIdType(sltInfoVo.getSettlementType(), agreementId);
|
||||
if (sltInfoVo.getAgreementIds().length <= 1) {
|
||||
// 如果不是批量提交,已结算的费用类型就直接提示已结算
|
||||
if (theSettledCount > 0) {
|
||||
String costType = Objects.equals(sltInfoVo.getSettlementType(), EQUIPMENT_SETTLEMENT_TYPE) ? "工器具" : "安全工器具";
|
||||
throw new ServiceException("协议:" + agreementId + "的" + costType + "费用已结算");
|
||||
}
|
||||
} else {
|
||||
// 如果是批量提交,一次性提交多个,那么已结算的就忽略跳过
|
||||
if (theSettledCount > 0) {
|
||||
continue;
|
||||
}
|
||||
}
|
||||
Long id;
|
||||
sltInfoVo.setAgreementId(agreementId);
|
||||
// 计算总成本
|
||||
BigDecimal totalCost = BigDecimal.ZERO;
|
||||
SltAgreementInfo info = new SltAgreementInfo();
|
||||
info.setAgreementId(agreementId);
|
||||
|
||||
//获取该协议下的所有维修任务
|
||||
List<TmTask> repairList = taskMapper.getTaskIdByAgreementId(info);
|
||||
if(CollectionUtils.isNotEmpty(repairList)){
|
||||
throw new ServiceException("结算中存在维修和报废未完成的任务,无法结算!");
|
||||
}
|
||||
|
||||
// 获取各项成本并累加
|
||||
totalCost = totalCost.add(getLeaseList(info).stream()
|
||||
.map(SltAgreementInfo::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(SltAgreementInfo::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 = sltAgreementInfoMapper.getRejectCount(sltInfoVo);
|
||||
// 判断已经结算的有几个
|
||||
int beforeCount = sltAgreementInfoMapper.getBeforeSettlementCount(sltInfoVo);
|
||||
// 更新结算协议状态,0未结算,1全部结算 2部分结算
|
||||
int updateAgreementCount = bmAgreementInfoMapper.updateBmAgreementInfo(new BmAgreementInfo().setAgreementId(agreementId).setIsSlt(beforeCount == 0 ? 2L : 1L));
|
||||
if (updateAgreementCount == 0) {
|
||||
throw new ServiceException("bm_agreement_info修改失败");
|
||||
}
|
||||
if (countReject > 0) {
|
||||
id = sltAgreementInfoMapper.getRejectId(sltInfoVo);
|
||||
//修改
|
||||
int countAgain = sltAgreementInfoMapper.updateRejectCount(sltInfoVo);
|
||||
if (countAgain == 0) {
|
||||
throw new ServiceException("slt_agreement_apply修改失败");
|
||||
}
|
||||
sltInfoVo.setUpdateTime(DateUtils.getNowDate());
|
||||
sltInfoVo.setCreateBy(String.valueOf(SecurityUtils.getLoginUser().getUserid()));
|
||||
} else {
|
||||
sltInfoVo.setCreateTime(DateUtils.getNowDate());
|
||||
sltInfoVo.setCreateBy(String.valueOf(SecurityUtils.getLoginUser().getUserid()));
|
||||
//新增
|
||||
int countOne = sltAgreementInfoMapper.insertSltAgreementApply(sltInfoVo);
|
||||
if (countOne != 1) {
|
||||
throw new ServiceException("slt_agreement_apply新增失败");
|
||||
}
|
||||
// 插入成功后,sltInfoVo 的 id 属性将被自动设置为新生成的主键值
|
||||
id = sltInfoVo.getId();
|
||||
sltInfoVo.setUpdateTime(DateUtils.getNowDate());
|
||||
}
|
||||
if (!sltInfoVo.getLeaseList().isEmpty()) {
|
||||
List<SltAgreementInfo> filteredLeaseList = sltInfoVo.getLeaseList().stream()
|
||||
.filter(lease -> lease.getAgreementId().equals(sltInfoVo.getAgreementId()))
|
||||
.collect(Collectors.toList());
|
||||
if (!filteredLeaseList.isEmpty()) {
|
||||
sltAgreementInfoMapper.insertSltAgreementDetailLease(filteredLeaseList, id);
|
||||
}
|
||||
}
|
||||
if (!sltInfoVo.getRepairList().isEmpty()) {
|
||||
List<SltAgreementInfo> filteredRepairList = sltInfoVo.getRepairList().stream()
|
||||
.filter(lease -> lease.getAgreementId().equals(sltInfoVo.getAgreementId()))
|
||||
.collect(Collectors.toList());
|
||||
if (!filteredRepairList.isEmpty()) {
|
||||
sltAgreementInfoMapper.insertSltAgreementDetailRepair(filteredRepairList, id);
|
||||
}
|
||||
}
|
||||
if (!sltInfoVo.getScrapList().isEmpty()) {
|
||||
List<SltAgreementInfo> filteredScrapList = sltInfoVo.getScrapList().stream()
|
||||
.filter(lease -> lease.getAgreementId().equals(sltInfoVo.getAgreementId()))
|
||||
.collect(Collectors.toList());
|
||||
if (!filteredScrapList.isEmpty()) {
|
||||
sltAgreementInfoMapper.insertSltAgreementDetailScrap(filteredScrapList, id);
|
||||
}
|
||||
}
|
||||
if (!sltInfoVo.getLoseList().isEmpty()) {
|
||||
List<SltAgreementInfo> filteredLoseList = sltInfoVo.getLoseList().stream()
|
||||
.filter(lease -> lease.getAgreementId().equals(sltInfoVo.getAgreementId()))
|
||||
.collect(Collectors.toList());
|
||||
if (!filteredLoseList.isEmpty()) {
|
||||
sltAgreementInfoMapper.insertSltAgreementDetailLose(filteredLoseList, id);
|
||||
}
|
||||
}
|
||||
UUID uuid = UUID.randomUUID();
|
||||
String sltTask = uuid.toString();
|
||||
if (sltInfoVo.getSettlementType() == null) {
|
||||
for (int i = 0; i < 2; i++) {
|
||||
int sltType = i + 1; // 第一次循环为1,第二次循环为2
|
||||
sltInfoVo.setSettlementType(sltType);
|
||||
sltFun(sltInfoVo,sltTask);
|
||||
}
|
||||
}else{
|
||||
sltFun(sltInfoVo,sltTask);
|
||||
}
|
||||
|
||||
|
||||
return GlobalConstants.INT_1;
|
||||
} catch (Exception e) {
|
||||
throw new ServiceException("错误:" + e.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
private void sltFun(@NotNull(message = "结算信息不能为空") SltInfoVo sltInfoVo,String sltTask) {
|
||||
|
||||
if (sltInfoVo.getAgreementIds() != null) {
|
||||
for (Long agreementId : sltInfoVo.getAgreementIds()) {
|
||||
if (agreementId == null || agreementId <= 0) {
|
||||
throw new ServiceException("协议id错误");
|
||||
}
|
||||
|
||||
// 查询【待审核】+【审核通过】的结算单数量
|
||||
int theSettledCount = sltAgreementInfoMapper.selectTheSettledCountByAgreementIdType(sltInfoVo.getSettlementType(), agreementId);
|
||||
if (sltInfoVo.getAgreementIds().length <= 1) {
|
||||
// 如果不是批量提交,已结算的费用类型就直接提示已结算
|
||||
if (theSettledCount > 0) {
|
||||
String costType = Objects.equals(sltInfoVo.getSettlementType(), EQUIPMENT_SETTLEMENT_TYPE) ? "工器具" : "安全工器具";
|
||||
throw new ServiceException("协议:" + agreementId + "的" + costType + "费用已结算");
|
||||
}
|
||||
} else {
|
||||
// 如果是批量提交,一次性提交多个,那么已结算的就忽略跳过
|
||||
if (theSettledCount > 0) {
|
||||
continue;
|
||||
}
|
||||
}
|
||||
Long id;
|
||||
sltInfoVo.setAgreementId(agreementId);
|
||||
// 计算总成本
|
||||
BigDecimal totalCost = BigDecimal.ZERO;
|
||||
SltAgreementInfo info = new SltAgreementInfo();
|
||||
info.setAgreementId(agreementId);
|
||||
info.setSettlementType(sltInfoVo.getSettlementType());
|
||||
//获取该协议下的所有维修任务
|
||||
List<TmTask> repairList = taskMapper.getTaskIdByAgreementId(info);
|
||||
if(CollectionUtils.isNotEmpty(repairList)){
|
||||
throw new ServiceException("结算中存在维修和报废未完成的任务,无法结算!");
|
||||
}
|
||||
|
||||
// 获取各项成本并累加
|
||||
totalCost = totalCost.add(getLeaseList(info).stream()
|
||||
.map(SltAgreementInfo::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(SltAgreementInfo::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 = sltAgreementInfoMapper.getRejectCount(sltInfoVo);
|
||||
// 判断已经结算的有几个
|
||||
int beforeCount = sltAgreementInfoMapper.getBeforeSettlementCount(sltInfoVo);
|
||||
// 更新结算协议状态,0未结算,1全部结算 2部分结算
|
||||
int updateAgreementCount = bmAgreementInfoMapper.updateBmAgreementInfo(new BmAgreementInfo().setAgreementId(agreementId).setIsSlt(beforeCount == 0 ? 2L : 1L));
|
||||
if (updateAgreementCount == 0) {
|
||||
throw new ServiceException("bm_agreement_info修改失败");
|
||||
}
|
||||
if (countReject > 0) {
|
||||
id = sltAgreementInfoMapper.getRejectId(sltInfoVo);
|
||||
//修改
|
||||
int countAgain = sltAgreementInfoMapper.updateRejectCount(sltInfoVo);
|
||||
if (countAgain == 0) {
|
||||
throw new ServiceException("slt_agreement_apply修改失败");
|
||||
}
|
||||
sltInfoVo.setUpdateTime(DateUtils.getNowDate());
|
||||
sltInfoVo.setCreateBy(String.valueOf(SecurityUtils.getLoginUser().getUserid()));
|
||||
} else {
|
||||
sltInfoVo.setCreateTime(DateUtils.getNowDate());
|
||||
sltInfoVo.setCreateBy(String.valueOf(SecurityUtils.getLoginUser().getUserid()));
|
||||
//新增
|
||||
sltInfoVo.setSettlementTask(sltTask);
|
||||
int countOne = sltAgreementInfoMapper.insertSltAgreementApply(sltInfoVo);
|
||||
if (countOne != 1) {
|
||||
throw new ServiceException("slt_agreement_apply新增失败");
|
||||
}
|
||||
// 插入成功后,sltInfoVo 的 id 属性将被自动设置为新生成的主键值
|
||||
id = sltInfoVo.getId();
|
||||
sltInfoVo.setUpdateTime(DateUtils.getNowDate());
|
||||
}
|
||||
if (!sltInfoVo.getLeaseList().isEmpty()) {
|
||||
List<SltAgreementInfo> filteredLeaseList = getLeaseList(info).stream()
|
||||
.filter(lease -> lease.getAgreementId().equals(sltInfoVo.getAgreementId()))
|
||||
.collect(Collectors.toList());
|
||||
if (!filteredLeaseList.isEmpty()) {
|
||||
sltAgreementInfoMapper.insertSltAgreementDetailLease(filteredLeaseList, id);
|
||||
}
|
||||
}
|
||||
if (!sltInfoVo.getRepairList().isEmpty()) {
|
||||
List<SltAgreementInfo> filteredRepairList = getRepairList(info).stream()
|
||||
.filter(lease -> lease.getAgreementId().equals(sltInfoVo.getAgreementId()))
|
||||
.collect(Collectors.toList());
|
||||
if (!filteredRepairList.isEmpty()) {
|
||||
sltAgreementInfoMapper.insertSltAgreementDetailRepair(filteredRepairList, id);
|
||||
}
|
||||
}
|
||||
if (!sltInfoVo.getScrapList().isEmpty()) {
|
||||
List<SltAgreementInfo> filteredScrapList = getScrapList(info).stream()
|
||||
.filter(lease -> lease.getAgreementId().equals(sltInfoVo.getAgreementId()))
|
||||
.collect(Collectors.toList());
|
||||
if (!filteredScrapList.isEmpty()) {
|
||||
sltAgreementInfoMapper.insertSltAgreementDetailScrap(filteredScrapList, id);
|
||||
}
|
||||
}
|
||||
if (!sltInfoVo.getLoseList().isEmpty()) {
|
||||
List<SltAgreementInfo> filteredLoseList = getLoseList(info).stream()
|
||||
.filter(lease -> lease.getAgreementId().equals(sltInfoVo.getAgreementId()))
|
||||
.collect(Collectors.toList());
|
||||
if (!filteredLoseList.isEmpty()) {
|
||||
sltAgreementInfoMapper.insertSltAgreementDetailLose(filteredLoseList, id);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* 判断当前登陆用户是否有结算权限,如果有则进行赋值
|
||||
* @return 结算类型值
|
||||
|
|
|
|||
|
|
@ -237,7 +237,17 @@
|
|||
LEFT JOIN bm_project bp ON bp.pro_id = bai.project_id
|
||||
LEFT JOIN sys_dept sd ON sd.dept_id = bp.imp_unit
|
||||
LEFT JOIN bm_unit bui ON bui.unit_id = bai.unit_id
|
||||
LEFT JOIN slt_agreement_apply saa on saa.agreement_id = bai.agreement_id and saa.settlement_type = #{settlementType}
|
||||
LEFT JOIN slt_agreement_apply saa on saa.agreement_id = bai.agreement_id
|
||||
<if test="settlementType != null and settlementType != ''">
|
||||
and saa.settlement_type = #{settlementType}
|
||||
</if>
|
||||
|
||||
<if test="settlementType == null or settlementType == ''">
|
||||
and saa.settlement_type in(1,2)
|
||||
</if>
|
||||
|
||||
|
||||
|
||||
WHERE bai.status = '1' AND bui.type_id != '1731'
|
||||
<if test="unitIds != null and unitIds.size() > 0">
|
||||
and bui.unit_id in
|
||||
|
|
@ -555,6 +565,7 @@
|
|||
insert into slt_agreement_apply
|
||||
<trim prefix="(" suffix=")" suffixOverrides=",">
|
||||
<if test="agreementId != null">agreement_id,</if>
|
||||
<if test="settlementTask != null">settlement_task,</if>
|
||||
<if test="agreementCode != null">`code`,</if>
|
||||
<if test="settlementType != null">settlement_type,</if>
|
||||
<if test="createBy != null">creator,</if>
|
||||
|
|
@ -564,6 +575,7 @@
|
|||
</trim>
|
||||
<trim prefix="values (" suffix=")" suffixOverrides=",">
|
||||
<if test="agreementId != null">#{agreementId},</if>
|
||||
<if test="settlementTask != null">#{settlementTask},</if>
|
||||
<if test="agreementCode != null">#{agreementCode},</if>
|
||||
<if test="settlementType != null">#{settlementType,jdbcType=TINYINT},</if>
|
||||
<if test="createBy != null">#{createBy},</if>
|
||||
|
|
@ -672,6 +684,7 @@
|
|||
id
|
||||
from slt_agreement_apply saa
|
||||
where saa.agreement_id = #{agreementId}
|
||||
and settlement_type = #{settlementType}
|
||||
</select>
|
||||
|
||||
<update id="updateRejectCount">
|
||||
|
|
@ -1974,6 +1987,69 @@
|
|||
) res
|
||||
</select>
|
||||
|
||||
<select id="getSltRepairDetailsList" resultType="com.bonus.material.settlement.domain.SltAgreementInfo">
|
||||
select saa.agreement_id as agreementId,
|
||||
bui.unit_name as unitName,
|
||||
bp.pro_name as projectName,
|
||||
sad.id as costId,
|
||||
sad.type_id as typeId,
|
||||
sad.ma_id as maId,
|
||||
mt1.type_name as typeName,
|
||||
mt.type_name as modelName,
|
||||
mt.unit_name as mtUnitName,
|
||||
sad.num as num,
|
||||
sad.money as costs,
|
||||
case sad.is_charge when '0' then '不收费' when '1' then '收费' else '' end as partType
|
||||
|
||||
from slt_agreement_apply saa
|
||||
LEFT JOIN slt_agreement_details sad on saa.id = sad.apply_id
|
||||
|
||||
LEFT JOIN 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 ma_type mt on sad.type_id = mt.type_id
|
||||
left join ma_type mt1 on mt.parent_id = mt1.type_id
|
||||
where saa.status in ('1','2','3') and sad.slt_type = 3
|
||||
and saa.agreement_id = #{agreementId}
|
||||
|
||||
<if test="settlementType != null and settlementType != 0">
|
||||
and mt.jiju_type = #{settlementType}
|
||||
</if>
|
||||
|
||||
having costs > 0
|
||||
</select>
|
||||
<select id="getSltScrapDetailsList" resultType="com.bonus.material.settlement.domain.SltAgreementInfo">
|
||||
select saa.agreement_id as agreementId,
|
||||
bui.unit_name as unitName,
|
||||
bp.pro_name as projectName,
|
||||
sad.id as costId,
|
||||
sad.type_id as typeId,
|
||||
sad.ma_id as maId,
|
||||
mt1.type_name as typeName,
|
||||
mt.type_name as modelName,
|
||||
mt.unit_name as mtUnitName,
|
||||
sad.num as num,
|
||||
sad.money as costs,
|
||||
case sad.is_charge when '0' then '不收费' when '1' then '收费' else '' end as partType
|
||||
|
||||
from slt_agreement_apply saa
|
||||
LEFT JOIN slt_agreement_details sad on saa.id = sad.apply_id
|
||||
|
||||
LEFT JOIN 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 ma_type mt on sad.type_id = mt.type_id
|
||||
left join ma_type mt1 on mt.parent_id = mt1.type_id
|
||||
where saa.status in ('1','2','3') and sad.slt_type = 4
|
||||
and saa.agreement_id = #{agreementId}
|
||||
|
||||
<if test="settlementType != null and settlementType != 0">
|
||||
and mt.jiju_type = #{settlementType}
|
||||
</if>
|
||||
|
||||
having costs > 0
|
||||
</select>
|
||||
|
||||
<insert id="addSltHistoryReport">
|
||||
insert into slt_history_report (agreement_id,agreement_code,unit_name,project_name,
|
||||
settlement_type,lease_cost,repair_cost,lose_cost,scrap_cost,reduction_cost,`year_month`,create_time
|
||||
|
|
|
|||
|
|
@ -192,6 +192,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|||
<if test="settlementType != null and settlementType != 0">
|
||||
and saa.settlement_type = #{settlementType}
|
||||
</if>
|
||||
limit 1
|
||||
</select>
|
||||
|
||||
<select id="selectTaskByIdByCl" resultType="com.bonus.material.task.domain.TmTask">
|
||||
|
|
|
|||
Loading…
Reference in New Issue