结算权限取消

This commit is contained in:
bonus 2025-11-28 15:18:17 +08:00
parent c558165778
commit 1cdae3a38b
6 changed files with 286 additions and 169 deletions

View File

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

View File

@ -162,6 +162,11 @@ public class SltInfoVo {
@ApiModelProperty(value = "承租负责人签字")
private String managerSignUrl;
/** 结算批次 */
@ApiModelProperty(value = "结算批次")
private String settlementTask;
/** 签字类型 */
@ApiModelProperty(value = "签字类型")
private long signType;

View File

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

View File

@ -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,6 +496,9 @@ public class SltAgreementInfoServiceImpl implements ISltAgreementInfoService {
public List<SltAgreementInfo> getRepairList(SltAgreementInfo info) {
List<SltAgreementInfo> repairList = new ArrayList<>();
if (info != null && info.getEnableQuerySltData() != null && info.getEnableQuerySltData()) {
repairList = sltAgreementInfoMapper.getSltRepairDetailsList(info);
} else {
List<TmTask> taskList = taskMapper.getTaskIdList(info);
List<TmTask> taskList2 = new ArrayList<>();
@ -514,6 +512,10 @@ public class SltAgreementInfoServiceImpl implements ISltAgreementInfoService {
List<SltAgreementInfo> repairDetailsList = sltAgreementInfoMapper.getRepairDetailsList(info, taskList);
repairList.addAll(repairDetailsList);
}
}
return repairList;
}
@ -543,6 +545,10 @@ public class SltAgreementInfoServiceImpl implements ISltAgreementInfoService {
public List<SltAgreementInfo> getScrapList(SltAgreementInfo info) {
List<SltAgreementInfo> scrapList = new ArrayList<>();
if (info != null && info.getEnableQuerySltData() != null && info.getEnableQuerySltData()) {
scrapList = sltAgreementInfoMapper.getSltScrapDetailsList(info);
} else {
List<TmTask> taskList = taskMapper.getTaskIdList(info);
List<TmTask> taskList2 = new ArrayList<>();
@ -556,6 +562,9 @@ public class SltAgreementInfoServiceImpl implements ISltAgreementInfoService {
List<SltAgreementInfo> scrapDetailsList = sltAgreementInfoMapper.getScrapDetailsList(info, taskList);
scrapList.addAll(scrapDetailsList);
}
}
return scrapList;
}
@ -700,15 +709,38 @@ 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 {
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) {
@ -735,7 +767,7 @@ public class SltAgreementInfoServiceImpl implements ISltAgreementInfoService {
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)){
@ -792,6 +824,7 @@ public class SltAgreementInfoServiceImpl implements ISltAgreementInfoService {
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新增失败");
@ -801,7 +834,7 @@ public class SltAgreementInfoServiceImpl implements ISltAgreementInfoService {
sltInfoVo.setUpdateTime(DateUtils.getNowDate());
}
if (!sltInfoVo.getLeaseList().isEmpty()) {
List<SltAgreementInfo> filteredLeaseList = sltInfoVo.getLeaseList().stream()
List<SltAgreementInfo> filteredLeaseList = getLeaseList(info).stream()
.filter(lease -> lease.getAgreementId().equals(sltInfoVo.getAgreementId()))
.collect(Collectors.toList());
if (!filteredLeaseList.isEmpty()) {
@ -809,7 +842,7 @@ public class SltAgreementInfoServiceImpl implements ISltAgreementInfoService {
}
}
if (!sltInfoVo.getRepairList().isEmpty()) {
List<SltAgreementInfo> filteredRepairList = sltInfoVo.getRepairList().stream()
List<SltAgreementInfo> filteredRepairList = getRepairList(info).stream()
.filter(lease -> lease.getAgreementId().equals(sltInfoVo.getAgreementId()))
.collect(Collectors.toList());
if (!filteredRepairList.isEmpty()) {
@ -817,7 +850,7 @@ public class SltAgreementInfoServiceImpl implements ISltAgreementInfoService {
}
}
if (!sltInfoVo.getScrapList().isEmpty()) {
List<SltAgreementInfo> filteredScrapList = sltInfoVo.getScrapList().stream()
List<SltAgreementInfo> filteredScrapList = getScrapList(info).stream()
.filter(lease -> lease.getAgreementId().equals(sltInfoVo.getAgreementId()))
.collect(Collectors.toList());
if (!filteredScrapList.isEmpty()) {
@ -825,7 +858,7 @@ public class SltAgreementInfoServiceImpl implements ISltAgreementInfoService {
}
}
if (!sltInfoVo.getLoseList().isEmpty()) {
List<SltAgreementInfo> filteredLoseList = sltInfoVo.getLoseList().stream()
List<SltAgreementInfo> filteredLoseList = getLoseList(info).stream()
.filter(lease -> lease.getAgreementId().equals(sltInfoVo.getAgreementId()))
.collect(Collectors.toList());
if (!filteredLoseList.isEmpty()) {
@ -834,10 +867,7 @@ public class SltAgreementInfoServiceImpl implements ISltAgreementInfoService {
}
}
}
return GlobalConstants.INT_1;
} catch (Exception e) {
throw new ServiceException("错误:" + e.getMessage());
}
}
/**

View File

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

View File

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