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. 9
      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
* @since 2023/1/30
* @apiNote
* 0-预算新增1-费用申请2-预算调增3-预算调减4-费用释放5-费用申请调增6-费用申请调减
7-销售区域迁移调增8-销售区域迁移调减
9-行政区域迁移调增10-行政区域迁移调减
11-政策申请
12-政策申请调增
13-政策申请调减
14-政策释放(被拒绝后)
*/
@Getter
@AllArgsConstructor
public enum BudgetLogOptFlag {
/** 0-预算新增 */
State_0(0,true),
@ -56,20 +47,19 @@ public enum BudgetLogOptFlag {
/** 11-政策申请 */
State_11(11,false),
/** 12-政策申请调增 */
State_12(12,false),
/** 12-政策申请调增(政策申请,预算调增) */
State_12(12,true),
/** 13-政策申请调减 */
/** 13-政策申请调减(政策申请,预算调减) */
State_13(13,false),
/** 14-政策释放(被拒绝后) */
/** 14-政策释放(被拒绝后,政策释放) */
State_14(14,true),
/** 15-费用申请释放(被拒绝后,预算增加) */
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){
BmsRegion2 ori = this.getById(param.getId());
param = this.toSetLevel(param);
boolean b = updateById(param);
boolean changePid = !ori.getPid().equals(param.getPid());
if(changePid){
Assert.throwEx("当前版本限制上下级变更");
}
boolean b = updateById(param);
if(!ori.getName().equals(param.getName())||changePid) {
BmsRegion2 parentRegion = this.updatePathByPid(param.getId());
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){
BmsRegion ori = this.getById(param.getId());
param = this.flushSetLevel(param);
boolean b = this.updateById(param);
boolean changePid = !ori.getPid().equals(param.getPid());
if(changePid){
Assert.throwEx("当前版本限制上下级变更");
}
boolean b = this.updateById(param);
if(!ori.getName().equals(param.getName())||changePid) {
BmsRegion parentRegion = this.updatePathByPid(param.getId());
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
* @return
*/
String commitGetSyFormId(TbsAffairCommitBo affairCommit);
String getSyFormIdByTargetInfo(TbsAffairCommitBo affairCommit);
/**
* 审批退回
@ -186,7 +186,7 @@ public interface SeeYonOperationService extends SeeYonBaseService{
*/
default R<?> commitAffair(TbsAffairCommitBo affairCommit){
getRequestService().testConnection();
String syFormId = this.commitGetSyFormId(affairCommit);
String syFormId = this.getSyFormIdByTargetInfo(affairCommit);
R<String> result = getRequestService().commonCommit(affairCommit, getTemplateCode(),syFormId);
boolean isBackCommit = affairCommit.getState()==2;
if(result.getStatus()==200){

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

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

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

@ -33,7 +33,6 @@ import java.util.stream.Collectors;
* @author YenHex
* @since 2023/5/24
*/
@Slf4j
@Service
@AllArgsConstructor
@ -131,6 +130,7 @@ public class TbsCostApplyOperationServiceImpl implements SeeYonOperationService
//移除日志
LambdaQueryWrapper<TbsBudgetLog> logLqw = new LambdaQueryWrapper<>();
logLqw.eq(TbsBudgetLog::getCostApplyId,costApplyId);
logLqw.eq(TbsBudgetLog::getRollbackFlag,BudgetLogRollbackFlag.State_0);
List<TbsBudgetLog> oldLogList = tbsBudgetLogService.list(logLqw);
List<TbsBudgetLog> oldLogList4Upd = oldLogList.stream().map(a->{
TbsBudgetLog budgetLog = new TbsBudgetLog();
@ -145,8 +145,9 @@ public class TbsCostApplyOperationServiceImpl implements SeeYonOperationService
budgetLog.setUpdateBy(null);
budgetLog.setUpdateTime(null);
budgetLog.setId(null);
budgetLog.setOptType(BudgetLogOptFlag.State_15.getCode());
budgetLog.setAmount(TbsBudgetLogBuildUtil.buildAmount(budgetLog.getAmount(),BudgetLogOptFlag.State_15));
BudgetLogOptFlag optFlag = BudgetLogOptFlag.State_15;
budgetLog.setOptType(optFlag.getCode());
budgetLog.setAmount(TbsBudgetLogBuildUtil.buildAmount(budgetLog.getAmount(),optFlag));
}
tbsBudgetLogService.saveBatch(oldLogList);
return null;
@ -184,7 +185,7 @@ public class TbsCostApplyOperationServiceImpl implements SeeYonOperationService
}
@Override
public String commitGetSyFormId(TbsAffairCommitBo affairCommit) {
public String getSyFormIdByTargetInfo(TbsAffairCommitBo affairCommit) {
TbsCostApply costApply = costApplyService.getById(affairCommit.getCostApplyId());
if(!costApply.getChargeState().equals(TbsCostApplyState.State_1_apply.getCode())){
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.service.TzcPolicyApplicationService;
import com.qs.serve.modules.tzc.service.TzcPolicyItemService;
import com.qs.serve.modules.tzc.service.impl.TzcPolicyOperationServiceImpl;
import lombok.AllArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.security.access.prepost.PreAuthorize;
@ -58,6 +59,7 @@ public class TzcPolicyController {
private TzcPolicyService tzcPolicyService;
private TzcPolicyItemService tzcPolicyItemService;
private TzcPolicyApplicationService policyApplicationService;
private TzcPolicyOperationServiceImpl tzcPolicyOperationService;
private TbsBudgetLogService tbsBudgetLogService;
private SysUserService sysUserService;
private SeeYonRequestService seeYonService;
@ -205,31 +207,32 @@ public class TzcPolicyController {
* @return
*/
@GetMapping("/ListAffairs")
public R<List<CtpAffairVo>> pageMemberAffair(Long policyId){
TzcPolicy tzcPolicy = tzcPolicyService.getById(policyId);
if(tzcPolicy.getSyFormId()==null){
return R.ok();
}
String templateCode = TbsSeeYonConst.PolicyConf.Code();
R<List<CtpAffair>> syResult = seeYonService.commonListAffairs(policyId+"",null,templateCode);
List<CtpAffair> ctpAffairs = syResult.getData();
if(ctpAffairs.size()>0){
List<String> oaUserIds = ctpAffairs.stream().map(CtpAffair::getMemberId).collect(Collectors.toList());
List<SysUser> userList = sysUserService.listByOaMemberIds(oaUserIds);
List<CtpAffairVo> result = new ArrayList<>();
for (CtpAffair ctpAffair : ctpAffairs) {
CtpAffairVo ctpAffairVo = new CtpAffairVo();
ctpAffairVo.setAffairInfo(ctpAffair);
for (SysUser user : userList) {
if(ctpAffair.getMemberId().equals(user.getSyUserId())){
ctpAffairVo.setUserInfo(user.toSysUserVo());
}
}
result.add(ctpAffairVo);
}
return R.ok(result);
}
return R.ok();
public R<List<CtpAffairVo>> pageMemberAffair(String policyId){
return tzcPolicyOperationService.pageAffair(policyId);
// TzcPolicy tzcPolicy = tzcPolicyService.getById(policyId);
// if(tzcPolicy.getSyFormId()==null){
// return R.ok();
// }
// String templateCode = TbsSeeYonConst.PolicyConf.Code();
// R<List<CtpAffair>> syResult = seeYonService.commonListAffairs(policyId+"",null,templateCode);
// List<CtpAffair> ctpAffairs = syResult.getData();
// if(ctpAffairs.size()>0){
// List<String> oaUserIds = ctpAffairs.stream().map(CtpAffair::getMemberId).collect(Collectors.toList());
// List<SysUser> userList = sysUserService.listByOaMemberIds(oaUserIds);
// List<CtpAffairVo> result = new ArrayList<>();
// for (CtpAffair ctpAffair : ctpAffairs) {
// CtpAffairVo ctpAffairVo = new CtpAffairVo();
// ctpAffairVo.setAffairInfo(ctpAffair);
// for (SysUser user : userList) {
// if(ctpAffair.getMemberId().equals(user.getSyUserId())){
// ctpAffairVo.setUserInfo(user.toSysUserVo());
// }
// }
// result.add(ctpAffairVo);
// }
// return R.ok(result);
// }
// return R.ok();
}
/**
@ -239,43 +242,44 @@ public class TzcPolicyController {
*/
@GetMapping("/pageMemberAffair")
public R<PageVo<CtpAffairVo>> pageMemberAffair(CtpAffairQo param){
param.setTitle(param.getChargeTheme());
param.setApplyUserName(param.getUserName());
SysUser sysUser = sysUserService.getById(AuthContextUtils.getSysUserId());
if(!StringUtils.hasText(sysUser.getSyUserId())||!StringUtils.hasText(sysUser.getSyAccount())){
return R.error("当前账号未绑定致远用户信息");
}
param.setMemberId(sysUser.getSyUserId());
param.setTemplateCode(TbsSeeYonConst.PolicyConf.Code());
R<PageVo<CtpAffair>> syResult = seeYonService.pageMemberAffair(param);
PageVo<CtpAffair> pageVo = syResult.getData();
List<CtpAffair> ctpAffairs = pageVo.getList();
if(ctpAffairs.size()>0){
List<String> oaUserIds = ctpAffairs.stream().map(CtpAffair::getMemberId).collect(Collectors.toList());
List<SysUser> userList = sysUserService.listByOaMemberIds(oaUserIds);
List<String> policyIds = ctpAffairs.stream().map(CtpAffair::getCostApplyId).collect(Collectors.toList());
List<TzcPolicy> policyList = tzcPolicyService.listByIds(policyIds);
List<CtpAffairVo> result = new ArrayList<>();
for (CtpAffair ctpAffair : ctpAffairs) {
CtpAffairVo ctpAffairVo = new CtpAffairVo();
for (TzcPolicy policy : policyList) {
if(policy.getId().toString().equals(ctpAffair.getCostApplyId())){
ctpAffairVo.setPolicyInfo(policy);
break;
}
}
for (SysUser user : userList) {
if(ctpAffair.getMemberId().equals(user.getSyUserId())){
ctpAffairVo.setUserInfo(user.toSysUserVo());
}
}
ctpAffairVo.setAffairInfo(ctpAffair);
result.add(ctpAffairVo);
}
PageVo<CtpAffairVo> costApplyPageVo = PageVo.initNewList(pageVo,result);
return R.ok(costApplyPageVo);
}
return R.byEmptyList();
return tzcPolicyOperationService.pageMemberAffair(param);
// param.setTitle(param.getChargeTheme());
// param.setApplyUserName(param.getUserName());
// SysUser sysUser = sysUserService.getById(AuthContextUtils.getSysUserId());
// if(!StringUtils.hasText(sysUser.getSyUserId())||!StringUtils.hasText(sysUser.getSyAccount())){
// return R.error("当前账号未绑定致远用户信息");
// }
// param.setMemberId(sysUser.getSyUserId());
// param.setTemplateCode(TbsSeeYonConst.PolicyConf.Code());
// R<PageVo<CtpAffair>> syResult = seeYonService.pageMemberAffair(param);
// PageVo<CtpAffair> pageVo = syResult.getData();
// List<CtpAffair> ctpAffairs = pageVo.getList();
// if(ctpAffairs.size()>0){
// List<String> oaUserIds = ctpAffairs.stream().map(CtpAffair::getMemberId).collect(Collectors.toList());
// List<SysUser> userList = sysUserService.listByOaMemberIds(oaUserIds);
// List<String> policyIds = ctpAffairs.stream().map(CtpAffair::getCostApplyId).collect(Collectors.toList());
// List<TzcPolicy> policyList = tzcPolicyService.listByIds(policyIds);
// List<CtpAffairVo> result = new ArrayList<>();
// for (CtpAffair ctpAffair : ctpAffairs) {
// CtpAffairVo ctpAffairVo = new CtpAffairVo();
// for (TzcPolicy policy : policyList) {
// if(policy.getId().toString().equals(ctpAffair.getCostApplyId())){
// ctpAffairVo.setPolicyInfo(policy);
// break;
// }
// }
// for (SysUser user : userList) {
// if(ctpAffair.getMemberId().equals(user.getSyUserId())){
// ctpAffairVo.setUserInfo(user.toSysUserVo());
// }
// }
// ctpAffairVo.setAffairInfo(ctpAffair);
// result.add(ctpAffairVo);
// }
// PageVo<CtpAffairVo> costApplyPageVo = PageVo.initNewList(pageVo,result);
// return R.ok(costApplyPageVo);
// }
// return R.byEmptyList();
}
/**
@ -286,82 +290,83 @@ public class TzcPolicyController {
@SysLog(module = SystemModule.Budget, title = "费用申请", biz = BizType.DELETE)
@PreAuthorize("hasRole('tbs:costApply:commit')")
public R<?> commitAffair(@RequestBody @Valid TbsAffairCommitBo affairCommit){
seeYonService.testConnection();
Long policyId = affairCommit.getPolicyId();
TzcPolicy tzcPolicy = tzcPolicyService.getById(policyId);
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;
if(result.getStatus()==200){
// 判断是否含有下个节点
String flag = result.getData();
//审批中(next)、完成(finish)、拒绝(refused)
if("finish".equals(flag)){
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();
}else if ("stop".equals(flag)){
if(isBackCommit){
TzcPolicy policy = new TzcPolicy();
policy.setId(tzcPolicy.getId());
policy.setPolicyStatus(TzcPolicyStatus.Status_4_RollBack);
tzcPolicyService.updateById(policy);
LambdaQueryWrapper<TbsBudgetLog> logLqw = new LambdaQueryWrapper<>();
logLqw.select(TbsBudgetLog::getId);
logLqw.eq(TbsBudgetLog::getPolicyId,tzcPolicy.getId());
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();
}else {
TzcPolicy policy = new TzcPolicy();
policy.setId(tzcPolicy.getId());
policy.setPolicyStatus(TzcPolicyStatus.Status_3_Refuse);
tzcPolicyService.updateById(policy);
tzcPolicyService.releaseCost(policy.getId(), 1);
//移除日志
LambdaQueryWrapper<TbsBudgetLog> logLqw = new LambdaQueryWrapper<>();
logLqw.eq(TbsBudgetLog::getPolicyId,tzcPolicy.getId());
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_12;
budgetLog.setAmount(TbsBudgetLogBuildUtil.buildAmount(budgetLog.getAmount(),optFlag));
budgetLog.setOptType(optFlag.getCode());
}
tbsBudgetLogService.saveBatch(oldLogList);
return R.ok();
}
}else if ("next".equals(flag)){
return R.ok();
}
}else if (result.getStatus()==500){
return result;
}
return R.error("远程调用失败");
return tzcPolicyOperationService.commitAffair(affairCommit);
// seeYonService.testConnection();
// Long policyId = affairCommit.getPolicyId();
// TzcPolicy tzcPolicy = tzcPolicyService.getById(policyId);
// 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;
// if(result.getStatus()==200){
// // 判断是否含有下个节点
// String flag = result.getData();
// //审批中(next)、完成(finish)、拒绝(refused)
// if("finish".equals(flag)){
// 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();
// }else if ("stop".equals(flag)){
// if(isBackCommit){
// TzcPolicy policy = new TzcPolicy();
// policy.setId(tzcPolicy.getId());
// policy.setPolicyStatus(TzcPolicyStatus.Status_4_RollBack);
// tzcPolicyService.updateById(policy);
// LambdaQueryWrapper<TbsBudgetLog> logLqw = new LambdaQueryWrapper<>();
// logLqw.select(TbsBudgetLog::getId);
// logLqw.eq(TbsBudgetLog::getPolicyId,tzcPolicy.getId());
// 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();
// }else {
// TzcPolicy policy = new TzcPolicy();
// policy.setId(tzcPolicy.getId());
// policy.setPolicyStatus(TzcPolicyStatus.Status_3_Refuse);
// tzcPolicyService.updateById(policy);
// tzcPolicyService.releaseCost(policy.getId(), 1);
// //移除日志
// LambdaQueryWrapper<TbsBudgetLog> logLqw = new LambdaQueryWrapper<>();
// logLqw.eq(TbsBudgetLog::getPolicyId,tzcPolicy.getId());
// 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_12;
// budgetLog.setAmount(TbsBudgetLogBuildUtil.buildAmount(budgetLog.getAmount(),optFlag));
// budgetLog.setOptType(optFlag.getCode());
// }
// tbsBudgetLogService.saveBatch(oldLogList);
// return R.ok();
// }
// }else if ("next".equals(flag)){
// return R.ok();
// }
// }else if (result.getStatus()==500){
// return result;
// }
// 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();
tbsBudgetCostItemPolicyService.saveBatch(allBudgetItem);
//保存预算使用日志
if(tzcPolicy.getPolicyStatus().equals(TzcPolicyStatus.Status_0_UnCommit)){
List<TbsBudgetLog> budgetLogList = saveBudgetLog(result, sysUser, tzcPolicy, result.getPolicyBudgetMatchList(),result.getPolicyItemList());
if(tzcPolicy.getPolicyStatus().equals(TzcPolicyStatus.Status_0_UnCommit)){
if(CollectionUtil.isNotEmpty(budgetLogList)){
budgetLogService.saveBatch(budgetLogList);
}
}else {
//排除历史记录
List<TbsBudgetLog> budgetLogList = saveBudgetLog(result, sysUser, tzcPolicy, result.getPolicyBudgetMatchList(),result.getPolicyItemList());
LambdaQueryWrapper<TbsBudgetLog> logLqw = new LambdaQueryWrapper<>();
logLqw.eq(TbsBudgetLog::getPolicyId,policyId);
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