Browse Source

预算底表统计调整

contract
Yen 2 years ago
parent
commit
7d7b0814b6
  1. 18
      src/main/java/com/qs/serve/common/model/enums/BudgetLogOptFlag.java
  2. 5
      src/main/java/com/qs/serve/modules/bms/service/impl/BmsRegion2ServiceImpl.java
  3. 5
      src/main/java/com/qs/serve/modules/bms/service/impl/BmsRegionServiceImpl.java
  4. 4
      src/main/java/com/qs/serve/modules/seeyon/service/SeeYonOperationService.java
  5. 15
      src/main/java/com/qs/serve/modules/tbs/mapper/TbsScheduleItemBudgetMapper.java
  6. 9
      src/main/java/com/qs/serve/modules/tbs/service/impl/TbsCostApplyOperationServiceImpl.java
  7. 281
      src/main/java/com/qs/serve/modules/tzc/controller/TzcPolicyController.java
  8. 3
      src/main/java/com/qs/serve/modules/tzc/service/impl/TzcPolicyApplicationServiceImpl.java
  9. 134
      src/main/java/com/qs/serve/modules/tzc/service/impl/TzcPolicyOperationServiceImpl.java

18
src/main/java/com/qs/serve/common/model/enums/BudgetLogOptFlag.java

@ -6,20 +6,11 @@ import lombok.Getter;
/** /**
* @author YenHex * @author YenHex
* @since 2023/1/30 * @since 2023/1/30
* @apiNote
* 0-预算新增1-费用申请2-预算调增3-预算调减4-费用释放5-费用申请调增6-费用申请调减
7-销售区域迁移调增8-销售区域迁移调减
9-行政区域迁移调增10-行政区域迁移调减
11-政策申请
12-政策申请调增
13-政策申请调减
14-政策释放(被拒绝后)
*/ */
@Getter @Getter
@AllArgsConstructor @AllArgsConstructor
public enum BudgetLogOptFlag { public enum BudgetLogOptFlag {
/** 0-预算新增 */ /** 0-预算新增 */
State_0(0,true), State_0(0,true),
@ -56,20 +47,19 @@ public enum BudgetLogOptFlag {
/** 11-政策申请 */ /** 11-政策申请 */
State_11(11,false), State_11(11,false),
/** 12-政策申请调增 */ /** 12-政策申请调增(政策申请,预算调增) */
State_12(12,false), State_12(12,true),
/** 13-政策申请调减 */ /** 13-政策申请调减(政策申请,预算调减) */
State_13(13,false), State_13(13,false),
/** 14-政策释放(被拒绝后) */ /** 14-政策释放(被拒绝后,政策释放) */
State_14(14,true), State_14(14,true),
/** 15-费用申请释放(被拒绝后,预算增加) */ /** 15-费用申请释放(被拒绝后,预算增加) */
State_15(15,true); State_15(15,true);
/** /**
* 编码 * 编码
*/ */

5
src/main/java/com/qs/serve/modules/bms/service/impl/BmsRegion2ServiceImpl.java

@ -54,8 +54,11 @@ public class BmsRegion2ServiceImpl extends ServiceImpl<BmsRegion2Mapper,BmsRegio
public boolean updateBmsRegion2ById(BmsRegion2 param){ public boolean updateBmsRegion2ById(BmsRegion2 param){
BmsRegion2 ori = this.getById(param.getId()); BmsRegion2 ori = this.getById(param.getId());
param = this.toSetLevel(param); param = this.toSetLevel(param);
boolean b = updateById(param);
boolean changePid = !ori.getPid().equals(param.getPid()); boolean changePid = !ori.getPid().equals(param.getPid());
if(changePid){
Assert.throwEx("当前版本限制上下级变更");
}
boolean b = updateById(param);
if(!ori.getName().equals(param.getName())||changePid) { if(!ori.getName().equals(param.getName())||changePid) {
BmsRegion2 parentRegion = this.updatePathByPid(param.getId()); BmsRegion2 parentRegion = this.updatePathByPid(param.getId());
if(changePid){ if(changePid){

5
src/main/java/com/qs/serve/modules/bms/service/impl/BmsRegionServiceImpl.java

@ -58,8 +58,11 @@ public class BmsRegionServiceImpl extends ServiceImpl<BmsRegionMapper,BmsRegion>
public boolean updateBmsRegionById(BmsRegion param){ public boolean updateBmsRegionById(BmsRegion param){
BmsRegion ori = this.getById(param.getId()); BmsRegion ori = this.getById(param.getId());
param = this.flushSetLevel(param); param = this.flushSetLevel(param);
boolean b = this.updateById(param);
boolean changePid = !ori.getPid().equals(param.getPid()); boolean changePid = !ori.getPid().equals(param.getPid());
if(changePid){
Assert.throwEx("当前版本限制上下级变更");
}
boolean b = this.updateById(param);
if(!ori.getName().equals(param.getName())||changePid) { if(!ori.getName().equals(param.getName())||changePid) {
BmsRegion parentRegion = this.updatePathByPid(param.getId()); BmsRegion parentRegion = this.updatePathByPid(param.getId());
if(changePid){ if(changePid){

4
src/main/java/com/qs/serve/modules/seeyon/service/SeeYonOperationService.java

@ -38,7 +38,7 @@ public interface SeeYonOperationService extends SeeYonBaseService{
* @param affairCommit * @param affairCommit
* @return * @return
*/ */
String commitGetSyFormId(TbsAffairCommitBo affairCommit); String getSyFormIdByTargetInfo(TbsAffairCommitBo affairCommit);
/** /**
* 审批退回 * 审批退回
@ -186,7 +186,7 @@ public interface SeeYonOperationService extends SeeYonBaseService{
*/ */
default R<?> commitAffair(TbsAffairCommitBo affairCommit){ default R<?> commitAffair(TbsAffairCommitBo affairCommit){
getRequestService().testConnection(); getRequestService().testConnection();
String syFormId = this.commitGetSyFormId(affairCommit); String syFormId = this.getSyFormIdByTargetInfo(affairCommit);
R<String> result = getRequestService().commonCommit(affairCommit, getTemplateCode(),syFormId); R<String> result = getRequestService().commonCommit(affairCommit, getTemplateCode(),syFormId);
boolean isBackCommit = affairCommit.getState()==2; boolean isBackCommit = affairCommit.getState()==2;
if(result.getStatus()==200){ if(result.getStatus()==200){

15
src/main/java/com/qs/serve/modules/tbs/mapper/TbsScheduleItemBudgetMapper.java

@ -49,6 +49,7 @@ public interface TbsScheduleItemBudgetMapper extends BaseMapper<TbsScheduleItemB
" LEFT JOIN " + " LEFT JOIN " +
" `tbs_cost_apply` " + " `tbs_cost_apply` " +
" ON `tbs_budget_log` .cost_apply_id = tbs_cost_apply.id " + " ON `tbs_budget_log` .cost_apply_id = tbs_cost_apply.id " +
" AND `tbs_budget_log`.rollback_flag = '0' " +
"WHERE " + "WHERE " +
" `tbs_budget_log`.budget_id = #{budgetId} " + " `tbs_budget_log`.budget_id = #{budgetId} " +
" AND `tbs_budget_log`.schedule_item_id = #{scheduleItemId} " + " AND `tbs_budget_log`.schedule_item_id = #{scheduleItemId} " +
@ -59,7 +60,6 @@ public interface TbsScheduleItemBudgetMapper extends BaseMapper<TbsScheduleItemB
@Param("scheduleItemId") Long scheduleItemId, @Param("scheduleItemId") Long scheduleItemId,
@Param("applyId") Long applyId); @Param("applyId") Long applyId);
/** /**
* 统计费用申请占用的预算金额 * 统计费用申请占用的预算金额
* 通过状态(0-未提交1-审核中2-已通过待执行3-拒绝4-被驳回5-结束) * 通过状态(0-未提交1-审核中2-已通过待执行3-拒绝4-被驳回5-结束)
@ -68,11 +68,14 @@ public interface TbsScheduleItemBudgetMapper extends BaseMapper<TbsScheduleItemB
* @param policyId 政策申请id(防止驳回后提交重复扣除) * @param policyId 政策申请id(防止驳回后提交重复扣除)
* @return * @return
*/ */
@Select("SELECT sum( amount ) FROM `tbs_budget_log` LEFT JOIN `tzc_policy` " + @Select("SELECT sum( amount ) FROM `tbs_budget_log` " +
"ON `tbs_budget_log` .policy_id = tzc_policy.id WHERE `tbs_budget_log`.budget_id = #{budgetId} " + " LEFT JOIN `tzc_policy` " +
"AND `tbs_budget_log`.schedule_item_id = #{scheduleItemId} " + " ON `tbs_budget_log`.policy_id = tzc_policy.id " +
"AND `tzc_policy`.id != #{policyId} " + " AND `tbs_budget_log`.rollback_flag = '0' " +
"AND `tzc_policy`.policy_status in (1,2,4,5) AND opt_type IN (1,4,5,6,11)") "WHERE `tbs_budget_log`.budget_id = #{budgetId} " +
" AND `tbs_budget_log`.schedule_item_id = #{scheduleItemId} " +
" AND `tzc_policy`.id != #{policyId} " +
" AND `tzc_policy`.policy_status in (1,2,4,5) AND opt_type IN (1,4,5,6,11)")
BigDecimal totalCostAmountByPolicyId(@Param("budgetId") Long budgetId, BigDecimal totalCostAmountByPolicyId(@Param("budgetId") Long budgetId,
@Param("scheduleItemId") Long scheduleItemId, @Param("scheduleItemId") Long scheduleItemId,
@Param("policyId") Long policyId); @Param("policyId") Long policyId);

9
src/main/java/com/qs/serve/modules/tbs/service/impl/TbsCostApplyOperationServiceImpl.java

@ -33,7 +33,6 @@ import java.util.stream.Collectors;
* @author YenHex * @author YenHex
* @since 2023/5/24 * @since 2023/5/24
*/ */
@Slf4j @Slf4j
@Service @Service
@AllArgsConstructor @AllArgsConstructor
@ -131,6 +130,7 @@ public class TbsCostApplyOperationServiceImpl implements SeeYonOperationService
//移除日志 //移除日志
LambdaQueryWrapper<TbsBudgetLog> logLqw = new LambdaQueryWrapper<>(); LambdaQueryWrapper<TbsBudgetLog> logLqw = new LambdaQueryWrapper<>();
logLqw.eq(TbsBudgetLog::getCostApplyId,costApplyId); logLqw.eq(TbsBudgetLog::getCostApplyId,costApplyId);
logLqw.eq(TbsBudgetLog::getRollbackFlag,BudgetLogRollbackFlag.State_0);
List<TbsBudgetLog> oldLogList = tbsBudgetLogService.list(logLqw); List<TbsBudgetLog> oldLogList = tbsBudgetLogService.list(logLqw);
List<TbsBudgetLog> oldLogList4Upd = oldLogList.stream().map(a->{ List<TbsBudgetLog> oldLogList4Upd = oldLogList.stream().map(a->{
TbsBudgetLog budgetLog = new TbsBudgetLog(); TbsBudgetLog budgetLog = new TbsBudgetLog();
@ -145,8 +145,9 @@ public class TbsCostApplyOperationServiceImpl implements SeeYonOperationService
budgetLog.setUpdateBy(null); budgetLog.setUpdateBy(null);
budgetLog.setUpdateTime(null); budgetLog.setUpdateTime(null);
budgetLog.setId(null); budgetLog.setId(null);
budgetLog.setOptType(BudgetLogOptFlag.State_15.getCode()); BudgetLogOptFlag optFlag = BudgetLogOptFlag.State_15;
budgetLog.setAmount(TbsBudgetLogBuildUtil.buildAmount(budgetLog.getAmount(),BudgetLogOptFlag.State_15)); budgetLog.setOptType(optFlag.getCode());
budgetLog.setAmount(TbsBudgetLogBuildUtil.buildAmount(budgetLog.getAmount(),optFlag));
} }
tbsBudgetLogService.saveBatch(oldLogList); tbsBudgetLogService.saveBatch(oldLogList);
return null; return null;
@ -184,7 +185,7 @@ public class TbsCostApplyOperationServiceImpl implements SeeYonOperationService
} }
@Override @Override
public String commitGetSyFormId(TbsAffairCommitBo affairCommit) { public String getSyFormIdByTargetInfo(TbsAffairCommitBo affairCommit) {
TbsCostApply costApply = costApplyService.getById(affairCommit.getCostApplyId()); TbsCostApply costApply = costApplyService.getById(affairCommit.getCostApplyId());
if(!costApply.getChargeState().equals(TbsCostApplyState.State_1_apply.getCode())){ if(!costApply.getChargeState().equals(TbsCostApplyState.State_1_apply.getCode())){
Assert.throwEx("费用申请处于未非审批状态"); Assert.throwEx("费用申请处于未非审批状态");

281
src/main/java/com/qs/serve/modules/tzc/controller/TzcPolicyController.java

@ -29,6 +29,7 @@ import com.qs.serve.modules.tzc.common.TzcPolicyStatus;
import com.qs.serve.modules.tzc.entity.TzcPolicyItem; import com.qs.serve.modules.tzc.entity.TzcPolicyItem;
import com.qs.serve.modules.tzc.service.TzcPolicyApplicationService; import com.qs.serve.modules.tzc.service.TzcPolicyApplicationService;
import com.qs.serve.modules.tzc.service.TzcPolicyItemService; import com.qs.serve.modules.tzc.service.TzcPolicyItemService;
import com.qs.serve.modules.tzc.service.impl.TzcPolicyOperationServiceImpl;
import lombok.AllArgsConstructor; import lombok.AllArgsConstructor;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import org.springframework.security.access.prepost.PreAuthorize; import org.springframework.security.access.prepost.PreAuthorize;
@ -58,6 +59,7 @@ public class TzcPolicyController {
private TzcPolicyService tzcPolicyService; private TzcPolicyService tzcPolicyService;
private TzcPolicyItemService tzcPolicyItemService; private TzcPolicyItemService tzcPolicyItemService;
private TzcPolicyApplicationService policyApplicationService; private TzcPolicyApplicationService policyApplicationService;
private TzcPolicyOperationServiceImpl tzcPolicyOperationService;
private TbsBudgetLogService tbsBudgetLogService; private TbsBudgetLogService tbsBudgetLogService;
private SysUserService sysUserService; private SysUserService sysUserService;
private SeeYonRequestService seeYonService; private SeeYonRequestService seeYonService;
@ -205,31 +207,32 @@ public class TzcPolicyController {
* @return * @return
*/ */
@GetMapping("/ListAffairs") @GetMapping("/ListAffairs")
public R<List<CtpAffairVo>> pageMemberAffair(Long policyId){ public R<List<CtpAffairVo>> pageMemberAffair(String policyId){
TzcPolicy tzcPolicy = tzcPolicyService.getById(policyId); return tzcPolicyOperationService.pageAffair(policyId);
if(tzcPolicy.getSyFormId()==null){ // TzcPolicy tzcPolicy = tzcPolicyService.getById(policyId);
return R.ok(); // if(tzcPolicy.getSyFormId()==null){
} // return R.ok();
String templateCode = TbsSeeYonConst.PolicyConf.Code(); // }
R<List<CtpAffair>> syResult = seeYonService.commonListAffairs(policyId+"",null,templateCode); // String templateCode = TbsSeeYonConst.PolicyConf.Code();
List<CtpAffair> ctpAffairs = syResult.getData(); // R<List<CtpAffair>> syResult = seeYonService.commonListAffairs(policyId+"",null,templateCode);
if(ctpAffairs.size()>0){ // List<CtpAffair> ctpAffairs = syResult.getData();
List<String> oaUserIds = ctpAffairs.stream().map(CtpAffair::getMemberId).collect(Collectors.toList()); // if(ctpAffairs.size()>0){
List<SysUser> userList = sysUserService.listByOaMemberIds(oaUserIds); // List<String> oaUserIds = ctpAffairs.stream().map(CtpAffair::getMemberId).collect(Collectors.toList());
List<CtpAffairVo> result = new ArrayList<>(); // List<SysUser> userList = sysUserService.listByOaMemberIds(oaUserIds);
for (CtpAffair ctpAffair : ctpAffairs) { // List<CtpAffairVo> result = new ArrayList<>();
CtpAffairVo ctpAffairVo = new CtpAffairVo(); // for (CtpAffair ctpAffair : ctpAffairs) {
ctpAffairVo.setAffairInfo(ctpAffair); // CtpAffairVo ctpAffairVo = new CtpAffairVo();
for (SysUser user : userList) { // ctpAffairVo.setAffairInfo(ctpAffair);
if(ctpAffair.getMemberId().equals(user.getSyUserId())){ // for (SysUser user : userList) {
ctpAffairVo.setUserInfo(user.toSysUserVo()); // if(ctpAffair.getMemberId().equals(user.getSyUserId())){
} // ctpAffairVo.setUserInfo(user.toSysUserVo());
} // }
result.add(ctpAffairVo); // }
} // result.add(ctpAffairVo);
return R.ok(result); // }
} // return R.ok(result);
return R.ok(); // }
// return R.ok();
} }
/** /**
@ -239,43 +242,44 @@ public class TzcPolicyController {
*/ */
@GetMapping("/pageMemberAffair") @GetMapping("/pageMemberAffair")
public R<PageVo<CtpAffairVo>> pageMemberAffair(CtpAffairQo param){ public R<PageVo<CtpAffairVo>> pageMemberAffair(CtpAffairQo param){
param.setTitle(param.getChargeTheme()); return tzcPolicyOperationService.pageMemberAffair(param);
param.setApplyUserName(param.getUserName()); // param.setTitle(param.getChargeTheme());
SysUser sysUser = sysUserService.getById(AuthContextUtils.getSysUserId()); // param.setApplyUserName(param.getUserName());
if(!StringUtils.hasText(sysUser.getSyUserId())||!StringUtils.hasText(sysUser.getSyAccount())){ // SysUser sysUser = sysUserService.getById(AuthContextUtils.getSysUserId());
return R.error("当前账号未绑定致远用户信息"); // if(!StringUtils.hasText(sysUser.getSyUserId())||!StringUtils.hasText(sysUser.getSyAccount())){
} // return R.error("当前账号未绑定致远用户信息");
param.setMemberId(sysUser.getSyUserId()); // }
param.setTemplateCode(TbsSeeYonConst.PolicyConf.Code()); // param.setMemberId(sysUser.getSyUserId());
R<PageVo<CtpAffair>> syResult = seeYonService.pageMemberAffair(param); // param.setTemplateCode(TbsSeeYonConst.PolicyConf.Code());
PageVo<CtpAffair> pageVo = syResult.getData(); // R<PageVo<CtpAffair>> syResult = seeYonService.pageMemberAffair(param);
List<CtpAffair> ctpAffairs = pageVo.getList(); // PageVo<CtpAffair> pageVo = syResult.getData();
if(ctpAffairs.size()>0){ // List<CtpAffair> ctpAffairs = pageVo.getList();
List<String> oaUserIds = ctpAffairs.stream().map(CtpAffair::getMemberId).collect(Collectors.toList()); // if(ctpAffairs.size()>0){
List<SysUser> userList = sysUserService.listByOaMemberIds(oaUserIds); // List<String> oaUserIds = ctpAffairs.stream().map(CtpAffair::getMemberId).collect(Collectors.toList());
List<String> policyIds = ctpAffairs.stream().map(CtpAffair::getCostApplyId).collect(Collectors.toList()); // List<SysUser> userList = sysUserService.listByOaMemberIds(oaUserIds);
List<TzcPolicy> policyList = tzcPolicyService.listByIds(policyIds); // List<String> policyIds = ctpAffairs.stream().map(CtpAffair::getCostApplyId).collect(Collectors.toList());
List<CtpAffairVo> result = new ArrayList<>(); // List<TzcPolicy> policyList = tzcPolicyService.listByIds(policyIds);
for (CtpAffair ctpAffair : ctpAffairs) { // List<CtpAffairVo> result = new ArrayList<>();
CtpAffairVo ctpAffairVo = new CtpAffairVo(); // for (CtpAffair ctpAffair : ctpAffairs) {
for (TzcPolicy policy : policyList) { // CtpAffairVo ctpAffairVo = new CtpAffairVo();
if(policy.getId().toString().equals(ctpAffair.getCostApplyId())){ // for (TzcPolicy policy : policyList) {
ctpAffairVo.setPolicyInfo(policy); // if(policy.getId().toString().equals(ctpAffair.getCostApplyId())){
break; // ctpAffairVo.setPolicyInfo(policy);
} // break;
} // }
for (SysUser user : userList) { // }
if(ctpAffair.getMemberId().equals(user.getSyUserId())){ // for (SysUser user : userList) {
ctpAffairVo.setUserInfo(user.toSysUserVo()); // if(ctpAffair.getMemberId().equals(user.getSyUserId())){
} // ctpAffairVo.setUserInfo(user.toSysUserVo());
} // }
ctpAffairVo.setAffairInfo(ctpAffair); // }
result.add(ctpAffairVo); // ctpAffairVo.setAffairInfo(ctpAffair);
} // result.add(ctpAffairVo);
PageVo<CtpAffairVo> costApplyPageVo = PageVo.initNewList(pageVo,result); // }
return R.ok(costApplyPageVo); // PageVo<CtpAffairVo> costApplyPageVo = PageVo.initNewList(pageVo,result);
} // return R.ok(costApplyPageVo);
return R.byEmptyList(); // }
// return R.byEmptyList();
} }
/** /**
@ -286,82 +290,83 @@ public class TzcPolicyController {
@SysLog(module = SystemModule.Budget, title = "费用申请", biz = BizType.DELETE) @SysLog(module = SystemModule.Budget, title = "费用申请", biz = BizType.DELETE)
@PreAuthorize("hasRole('tbs:costApply:commit')") @PreAuthorize("hasRole('tbs:costApply:commit')")
public R<?> commitAffair(@RequestBody @Valid TbsAffairCommitBo affairCommit){ public R<?> commitAffair(@RequestBody @Valid TbsAffairCommitBo affairCommit){
seeYonService.testConnection(); return tzcPolicyOperationService.commitAffair(affairCommit);
Long policyId = affairCommit.getPolicyId(); // seeYonService.testConnection();
TzcPolicy tzcPolicy = tzcPolicyService.getById(policyId); // Long policyId = affairCommit.getPolicyId();
if(!tzcPolicy.getPolicyStatus().equals(TzcPolicyStatus.Status_1_Checking)){ // TzcPolicy tzcPolicy = tzcPolicyService.getById(policyId);
return R.error("费用申请处于未非审批状态!"); // if(!tzcPolicy.getPolicyStatus().equals(TzcPolicyStatus.Status_1_Checking)){
} // return R.error("费用申请处于未非审批状态!");
R<String> result = seeYonService.commonCommit(affairCommit,TbsSeeYonConst.PolicyConf.Code(),tzcPolicy.getSyFormId()); // }
boolean isBackCommit = affairCommit.getState()==2; // R<String> result = seeYonService.commonCommit(affairCommit,TbsSeeYonConst.PolicyConf.Code(),tzcPolicy.getSyFormId());
if(result.getStatus()==200){ // boolean isBackCommit = affairCommit.getState()==2;
// 判断是否含有下个节点 // if(result.getStatus()==200){
String flag = result.getData(); // // 判断是否含有下个节点
//审批中(next)、完成(finish)、拒绝(refused) // String flag = result.getData();
if("finish".equals(flag)){ // //审批中(next)、完成(finish)、拒绝(refused)
TzcPolicy policy = new TzcPolicy(); // if("finish".equals(flag)){
policy.setId(tzcPolicy.getId()); // TzcPolicy policy = new TzcPolicy();
policy.setPolicyStatus(TzcPolicyStatus.Status_2_PassSuccess); // policy.setId(tzcPolicy.getId());
policy.setPassTime(LocalDateTime.now()); // policy.setPolicyStatus(TzcPolicyStatus.Status_2_PassSuccess);
tzcPolicyService.updateById(policy); // policy.setPassTime(LocalDateTime.now());
//更新活动通过时间 // tzcPolicyService.updateById(policy);
TzcPolicyItem policyItem = new TzcPolicyItem(); // //更新活动通过时间
policyItem.setPolicyItemStatus(TzPolicyItemStatus.Status_1_PassSuccess); // TzcPolicyItem policyItem = new TzcPolicyItem();
LambdaQueryWrapper<TzcPolicyItem> itemLqw = new LambdaQueryWrapper<>(); // policyItem.setPolicyItemStatus(TzPolicyItemStatus.Status_1_PassSuccess);
itemLqw.eq(TzcPolicyItem::getPolicyId,tzcPolicy.getId()); // LambdaQueryWrapper<TzcPolicyItem> itemLqw = new LambdaQueryWrapper<>();
tzcPolicyItemService.update(policyItem,itemLqw); // itemLqw.eq(TzcPolicyItem::getPolicyId,tzcPolicy.getId());
return R.ok(); // tzcPolicyItemService.update(policyItem,itemLqw);
}else if ("stop".equals(flag)){ // return R.ok();
if(isBackCommit){ // }else if ("stop".equals(flag)){
TzcPolicy policy = new TzcPolicy(); // if(isBackCommit){
policy.setId(tzcPolicy.getId()); // TzcPolicy policy = new TzcPolicy();
policy.setPolicyStatus(TzcPolicyStatus.Status_4_RollBack); // policy.setId(tzcPolicy.getId());
tzcPolicyService.updateById(policy); // policy.setPolicyStatus(TzcPolicyStatus.Status_4_RollBack);
LambdaQueryWrapper<TbsBudgetLog> logLqw = new LambdaQueryWrapper<>(); // tzcPolicyService.updateById(policy);
logLqw.select(TbsBudgetLog::getId); // LambdaQueryWrapper<TbsBudgetLog> logLqw = new LambdaQueryWrapper<>();
logLqw.eq(TbsBudgetLog::getPolicyId,tzcPolicy.getId()); // logLqw.select(TbsBudgetLog::getId);
logLqw.eq(TbsBudgetLog::getRollbackFlag, BudgetLogRollbackFlag.State_0); // logLqw.eq(TbsBudgetLog::getPolicyId,tzcPolicy.getId());
List<TbsBudgetLog> budgetLogList = tbsBudgetLogService.list(logLqw); // logLqw.eq(TbsBudgetLog::getRollbackFlag, BudgetLogRollbackFlag.State_0);
budgetLogList.forEach(a->a.setRollbackFlag(BudgetLogRollbackFlag.State_1)); // List<TbsBudgetLog> budgetLogList = tbsBudgetLogService.list(logLqw);
tbsBudgetLogService.updateBatchById(budgetLogList); // budgetLogList.forEach(a->a.setRollbackFlag(BudgetLogRollbackFlag.State_1));
return R.ok(); // tbsBudgetLogService.updateBatchById(budgetLogList);
}else { // return R.ok();
TzcPolicy policy = new TzcPolicy(); // }else {
policy.setId(tzcPolicy.getId()); // TzcPolicy policy = new TzcPolicy();
policy.setPolicyStatus(TzcPolicyStatus.Status_3_Refuse); // policy.setId(tzcPolicy.getId());
tzcPolicyService.updateById(policy); // policy.setPolicyStatus(TzcPolicyStatus.Status_3_Refuse);
tzcPolicyService.releaseCost(policy.getId(), 1); // tzcPolicyService.updateById(policy);
//移除日志 // tzcPolicyService.releaseCost(policy.getId(), 1);
LambdaQueryWrapper<TbsBudgetLog> logLqw = new LambdaQueryWrapper<>(); // //移除日志
logLqw.eq(TbsBudgetLog::getPolicyId,tzcPolicy.getId()); // LambdaQueryWrapper<TbsBudgetLog> logLqw = new LambdaQueryWrapper<>();
List<TbsBudgetLog> oldLogList = tbsBudgetLogService.list(logLqw); // logLqw.eq(TbsBudgetLog::getPolicyId,tzcPolicy.getId());
List<TbsBudgetLog> oldLogList4Upd = oldLogList.stream().map(a->{ // List<TbsBudgetLog> oldLogList = tbsBudgetLogService.list(logLqw);
TbsBudgetLog budgetLog = new TbsBudgetLog(); // List<TbsBudgetLog> oldLogList4Upd = oldLogList.stream().map(a->{
budgetLog.setId(a.getId()); // TbsBudgetLog budgetLog = new TbsBudgetLog();
budgetLog.setRollbackFlag(BudgetLogRollbackFlag.State_3); // budgetLog.setId(a.getId());
return budgetLog; // budgetLog.setRollbackFlag(BudgetLogRollbackFlag.State_3);
}).collect(Collectors.toList()); // return budgetLog;
tbsBudgetLogService.updateBatchById(oldLogList4Upd); // }).collect(Collectors.toList());
for (TbsBudgetLog budgetLog : oldLogList) { // tbsBudgetLogService.updateBatchById(oldLogList4Upd);
budgetLog.setCreateBy(null); // for (TbsBudgetLog budgetLog : oldLogList) {
budgetLog.setCreateTime(null); // budgetLog.setCreateBy(null);
budgetLog.setUpdateBy(null); // budgetLog.setCreateTime(null);
budgetLog.setUpdateTime(null); // budgetLog.setUpdateBy(null);
budgetLog.setId(null); // budgetLog.setUpdateTime(null);
BudgetLogOptFlag optFlag = BudgetLogOptFlag.State_12; // budgetLog.setId(null);
budgetLog.setAmount(TbsBudgetLogBuildUtil.buildAmount(budgetLog.getAmount(),optFlag)); // BudgetLogOptFlag optFlag = BudgetLogOptFlag.State_12;
budgetLog.setOptType(optFlag.getCode()); // budgetLog.setAmount(TbsBudgetLogBuildUtil.buildAmount(budgetLog.getAmount(),optFlag));
} // budgetLog.setOptType(optFlag.getCode());
tbsBudgetLogService.saveBatch(oldLogList); // }
return R.ok(); // tbsBudgetLogService.saveBatch(oldLogList);
} // return R.ok();
}else if ("next".equals(flag)){ // }
return R.ok(); // }else if ("next".equals(flag)){
} // return R.ok();
}else if (result.getStatus()==500){ // }
return result; // }else if (result.getStatus()==500){
} // return result;
return R.error("远程调用失败"); // }
// return R.error("远程调用失败");
} }

3
src/main/java/com/qs/serve/modules/tzc/service/impl/TzcPolicyApplicationServiceImpl.java

@ -197,14 +197,13 @@ public class TzcPolicyApplicationServiceImpl implements TzcPolicyApplicationServ
List<TbsBudgetCostItemPolicy> allBudgetItem = result.getPolicyBudgetMatchList(); List<TbsBudgetCostItemPolicy> allBudgetItem = result.getPolicyBudgetMatchList();
tbsBudgetCostItemPolicyService.saveBatch(allBudgetItem); tbsBudgetCostItemPolicyService.saveBatch(allBudgetItem);
//保存预算使用日志 //保存预算使用日志
if(tzcPolicy.getPolicyStatus().equals(TzcPolicyStatus.Status_0_UnCommit)){
List<TbsBudgetLog> budgetLogList = saveBudgetLog(result, sysUser, tzcPolicy, result.getPolicyBudgetMatchList(),result.getPolicyItemList()); List<TbsBudgetLog> budgetLogList = saveBudgetLog(result, sysUser, tzcPolicy, result.getPolicyBudgetMatchList(),result.getPolicyItemList());
if(tzcPolicy.getPolicyStatus().equals(TzcPolicyStatus.Status_0_UnCommit)){
if(CollectionUtil.isNotEmpty(budgetLogList)){ if(CollectionUtil.isNotEmpty(budgetLogList)){
budgetLogService.saveBatch(budgetLogList); budgetLogService.saveBatch(budgetLogList);
} }
}else { }else {
//排除历史记录 //排除历史记录
List<TbsBudgetLog> budgetLogList = saveBudgetLog(result, sysUser, tzcPolicy, result.getPolicyBudgetMatchList(),result.getPolicyItemList());
LambdaQueryWrapper<TbsBudgetLog> logLqw = new LambdaQueryWrapper<>(); LambdaQueryWrapper<TbsBudgetLog> logLqw = new LambdaQueryWrapper<>();
logLqw.eq(TbsBudgetLog::getPolicyId,policyId); logLqw.eq(TbsBudgetLog::getPolicyId,policyId);
logLqw.eq(TbsBudgetLog::getRollbackFlag, BudgetLogRollbackFlag.State_1); logLqw.eq(TbsBudgetLog::getRollbackFlag, BudgetLogRollbackFlag.State_1);

134
src/main/java/com/qs/serve/modules/tzc/service/impl/TzcPolicyOperationServiceImpl.java

@ -0,0 +1,134 @@
package com.qs.serve.modules.tzc.service.impl;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.qs.serve.common.model.consts.BudgetLogRollbackFlag;
import com.qs.serve.common.model.dto.R;
import com.qs.serve.common.model.enums.BudgetLogOptFlag;
import com.qs.serve.common.util.Assert;
import com.qs.serve.modules.seeyon.service.SeeYonOperationService;
import com.qs.serve.modules.tbs.common.TbsSeeYonConst;
import com.qs.serve.modules.tbs.common.util.TbsBudgetLogBuildUtil;
import com.qs.serve.modules.tbs.entity.TbsBudgetLog;
import com.qs.serve.modules.tbs.entity.bo.TbsAffairCommitBo;
import com.qs.serve.modules.tbs.service.TbsBudgetLogService;
import com.qs.serve.modules.tzc.common.TzPolicyItemStatus;
import com.qs.serve.modules.tzc.common.TzcPolicyStatus;
import com.qs.serve.modules.tzc.entity.TzcPolicy;
import com.qs.serve.modules.tzc.entity.TzcPolicyItem;
import com.qs.serve.modules.tzc.service.TzcPolicyItemService;
import com.qs.serve.modules.tzc.service.TzcPolicyService;
import lombok.AllArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;
import java.time.LocalDateTime;
import java.util.List;
import java.util.stream.Collectors;
/**
* @author YenHex
* @since 2023/5/25
*/
@Slf4j
@Service
@AllArgsConstructor
public class TzcPolicyOperationServiceImpl implements SeeYonOperationService {
private final TzcPolicyService tzcPolicyService;
private final TzcPolicyItemService tzcPolicyItemService;
private final TbsBudgetLogService tbsBudgetLogService;
@Override
public String getTargetId(TbsAffairCommitBo affairCommit) {
return affairCommit.getPolicyId()+"";
}
@Override
public String getSyFormIdByTargetInfo(TbsAffairCommitBo affairCommit) {
TzcPolicy tzcPolicy = tzcPolicyService.getById(affairCommit.getPolicyId());
if(tzcPolicy.getPolicyStatus().equals(TzcPolicyStatus.Status_1_Checking)){
Assert.throwEx("当前政策状态不可审批");
}
return tzcPolicy.getSyFormId();
}
@Override
public Object doBacked(TbsAffairCommitBo param) {
Long policyId = param.getPolicyId();
TzcPolicy policy = new TzcPolicy();
policy.setId(policyId);
policy.setPolicyStatus(TzcPolicyStatus.Status_4_RollBack);
tzcPolicyService.updateById(policy);
LambdaQueryWrapper<TbsBudgetLog> logLqw = new LambdaQueryWrapper<>();
logLqw.select(TbsBudgetLog::getId);
logLqw.eq(TbsBudgetLog::getPolicyId,policyId);
logLqw.eq(TbsBudgetLog::getRollbackFlag, BudgetLogRollbackFlag.State_0);
List<TbsBudgetLog> budgetLogList = tbsBudgetLogService.list(logLqw);
budgetLogList.forEach(a->a.setRollbackFlag(BudgetLogRollbackFlag.State_1));
tbsBudgetLogService.updateBatchById(budgetLogList);
return R.ok();
}
@Override
public Object doFinished(TbsAffairCommitBo param) {
String policyId = this.getTargetId(param);
TzcPolicy tzcPolicy = tzcPolicyService.getById(policyId);
TzcPolicy policy = new TzcPolicy();
policy.setId(tzcPolicy.getId());
policy.setPolicyStatus(TzcPolicyStatus.Status_2_PassSuccess);
policy.setPassTime(LocalDateTime.now());
tzcPolicyService.updateById(policy);
//更新活动通过时间
TzcPolicyItem policyItem = new TzcPolicyItem();
policyItem.setPolicyItemStatus(TzPolicyItemStatus.Status_1_PassSuccess);
LambdaQueryWrapper<TzcPolicyItem> itemLqw = new LambdaQueryWrapper<>();
itemLqw.eq(TzcPolicyItem::getPolicyId,tzcPolicy.getId());
tzcPolicyItemService.update(policyItem,itemLqw);
return R.ok();
}
@Override
public Object doRefuse(TbsAffairCommitBo param) {
Long policyId = param.getPolicyId();
TzcPolicy policy = new TzcPolicy();
policy.setId(policyId);
policy.setPolicyStatus(TzcPolicyStatus.Status_3_Refuse);
tzcPolicyService.updateById(policy);
tzcPolicyService.releaseCost(policy.getId(), 1);
//移除日志
LambdaQueryWrapper<TbsBudgetLog> logLqw = new LambdaQueryWrapper<>();
logLqw.eq(TbsBudgetLog::getPolicyId,policyId);
logLqw.eq(TbsBudgetLog::getRollbackFlag,BudgetLogRollbackFlag.State_0);
List<TbsBudgetLog> oldLogList = tbsBudgetLogService.list(logLqw);
List<TbsBudgetLog> oldLogList4Upd = oldLogList.stream().map(a->{
TbsBudgetLog budgetLog = new TbsBudgetLog();
budgetLog.setId(a.getId());
budgetLog.setRollbackFlag(BudgetLogRollbackFlag.State_3);
return budgetLog;
}).collect(Collectors.toList());
tbsBudgetLogService.updateBatchById(oldLogList4Upd);
for (TbsBudgetLog budgetLog : oldLogList) {
budgetLog.setCreateBy(null);
budgetLog.setCreateTime(null);
budgetLog.setUpdateBy(null);
budgetLog.setUpdateTime(null);
budgetLog.setId(null);
BudgetLogOptFlag optFlag = BudgetLogOptFlag.State_14;
budgetLog.setAmount(TbsBudgetLogBuildUtil.buildAmount(budgetLog.getAmount(),optFlag));
budgetLog.setOptType(optFlag.getCode());
}
tbsBudgetLogService.saveBatch(oldLogList);
return null;
}
@Override
public Object doNext(TbsAffairCommitBo param) {
return null;
}
@Override
public String getTemplateCode() {
return TbsSeeYonConst.PolicyConf.Code();
}
}
Loading…
Cancel
Save