9 changed files with 306 additions and 168 deletions
@ -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…
Reference in new issue