|
@ -2,6 +2,8 @@ package com.qs.serve.modules.tzc.controller; |
|
|
|
|
|
|
|
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; |
|
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; |
|
|
import com.qs.serve.common.model.annotation.SysLog; |
|
|
import com.qs.serve.common.model.annotation.SysLog; |
|
|
|
|
|
import com.qs.serve.common.model.consts.BudgetLogOptFlag; |
|
|
|
|
|
import com.qs.serve.common.model.consts.BudgetLogRollbackFlag; |
|
|
import com.qs.serve.common.model.dto.PageVo; |
|
|
import com.qs.serve.common.model.dto.PageVo; |
|
|
import com.qs.serve.common.model.dto.R; |
|
|
import com.qs.serve.common.model.dto.R; |
|
|
import com.qs.serve.common.model.enums.BizType; |
|
|
import com.qs.serve.common.model.enums.BizType; |
|
@ -10,8 +12,22 @@ import com.qs.serve.common.util.AuthContextUtils; |
|
|
import com.qs.serve.common.util.PageUtil; |
|
|
import com.qs.serve.common.util.PageUtil; |
|
|
import com.qs.serve.common.util.CopierUtil; |
|
|
import com.qs.serve.common.util.CopierUtil; |
|
|
import com.qs.serve.common.util.StringUtils; |
|
|
import com.qs.serve.common.util.StringUtils; |
|
|
|
|
|
import com.qs.serve.modules.seeyon.entity.CtpAffair; |
|
|
|
|
|
import com.qs.serve.modules.seeyon.entity.CtpAffairQo; |
|
|
|
|
|
import com.qs.serve.modules.seeyon.service.SeeYonService; |
|
|
|
|
|
import com.qs.serve.modules.sys.entity.SysUser; |
|
|
|
|
|
import com.qs.serve.modules.sys.service.SysUserService; |
|
|
|
|
|
import com.qs.serve.modules.tbs.common.TbsCostApplyState; |
|
|
|
|
|
import com.qs.serve.modules.tbs.common.TbsSeeYonConst; |
|
|
|
|
|
import com.qs.serve.modules.tbs.entity.TbsActivity; |
|
|
|
|
|
import com.qs.serve.modules.tbs.entity.TbsBudgetLog; |
|
|
|
|
|
import com.qs.serve.modules.tbs.entity.TbsCostApply; |
|
|
|
|
|
import com.qs.serve.modules.tbs.entity.bo.TbsAffairCommitBo; |
|
|
import com.qs.serve.modules.tbs.entity.dto.TbsBudgetCostResult; |
|
|
import com.qs.serve.modules.tbs.entity.dto.TbsBudgetCostResult; |
|
|
|
|
|
import com.qs.serve.modules.tbs.entity.vo.CtpAffairVo; |
|
|
import com.qs.serve.modules.tbs.entity.vo.TbsBudgetTableVo; |
|
|
import com.qs.serve.modules.tbs.entity.vo.TbsBudgetTableVo; |
|
|
|
|
|
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.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.TzcPolicyApplication; |
|
|
import com.qs.serve.modules.tzc.service.TzcPolicyApplication; |
|
@ -26,7 +42,10 @@ import com.qs.serve.modules.tzc.entity.TzcPolicy; |
|
|
import com.qs.serve.modules.tzc.service.TzcPolicyService; |
|
|
import com.qs.serve.modules.tzc.service.TzcPolicyService; |
|
|
|
|
|
|
|
|
import javax.validation.Valid; |
|
|
import javax.validation.Valid; |
|
|
|
|
|
import java.time.LocalDateTime; |
|
|
|
|
|
import java.util.ArrayList; |
|
|
import java.util.List; |
|
|
import java.util.List; |
|
|
|
|
|
import java.util.stream.Collectors; |
|
|
|
|
|
|
|
|
/** |
|
|
/** |
|
|
* 政策 政策 |
|
|
* 政策 政策 |
|
@ -42,6 +61,9 @@ public class TzcPolicyController { |
|
|
private TzcPolicyService tzcPolicyService; |
|
|
private TzcPolicyService tzcPolicyService; |
|
|
private TzcPolicyItemService tzcPolicyItemService; |
|
|
private TzcPolicyItemService tzcPolicyItemService; |
|
|
private TzcPolicyApplication policyApplication; |
|
|
private TzcPolicyApplication policyApplication; |
|
|
|
|
|
private TbsBudgetLogService tbsBudgetLogService; |
|
|
|
|
|
private SysUserService sysUserService; |
|
|
|
|
|
private SeeYonService seeYonService; |
|
|
|
|
|
|
|
|
/** |
|
|
/** |
|
|
* 预览 |
|
|
* 预览 |
|
@ -55,13 +77,13 @@ public class TzcPolicyController { |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
/** |
|
|
/** |
|
|
* 提交政策申请 |
|
|
* 提交审批 |
|
|
* @param id |
|
|
* @param policyId |
|
|
* @return |
|
|
* @return |
|
|
*/ |
|
|
*/ |
|
|
@PostMapping("commitApply") |
|
|
@PostMapping("/commitPolicy/{policyId}") |
|
|
public R<?> commitApply(Long id){ |
|
|
public R<?> commitPolicy(@PathVariable("policyId")Long policyId){ |
|
|
policyApplication.commitPolicy(id); |
|
|
policyApplication.commitPolicy(policyId); |
|
|
return R.ok(); |
|
|
return R.ok(); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
@ -157,16 +179,172 @@ public class TzcPolicyController { |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
/** |
|
|
* 提交审批 |
|
|
* 审批列表(用于详情页) |
|
|
* @param policyId |
|
|
* @param policyId |
|
|
* @return |
|
|
* @return |
|
|
*/ |
|
|
*/ |
|
|
@PostMapping("/commitPolicy/{policyId}") |
|
|
@GetMapping("/ListAffairs") |
|
|
public R<?> commitPolicy(@PathVariable("policyId")Long policyId){ |
|
|
public R<List<CtpAffairVo>> pageMemberAffair(Long policyId){ |
|
|
|
|
|
TzcPolicy tzcPolicy = tzcPolicyService.getById(policyId); |
|
|
|
|
|
if(tzcPolicy.getSyFormId()==null){ |
|
|
|
|
|
return R.ok(); |
|
|
|
|
|
} |
|
|
|
|
|
String templateCode = TbsSeeYonConst.CostApplyConf.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(); |
|
|
return R.ok(); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
|
* 审批列表(翻页) |
|
|
|
|
|
* @param param |
|
|
|
|
|
* @return |
|
|
|
|
|
*/ |
|
|
|
|
|
@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.setTemplateId(TbsSeeYonConst.CostApplyConf.Id()); |
|
|
|
|
|
param.setTemplateCode(TbsSeeYonConst.CostApplyConf.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 |
|
|
|
|
|
*/ |
|
|
|
|
|
@PostMapping("/commitAffair") |
|
|
|
|
|
@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.CostApplyConf.Code()); |
|
|
|
|
|
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); |
|
|
|
|
|
budgetLog.setAmount(budgetLog.getAmount().negate()); |
|
|
|
|
|
budgetLog.setOptType(BudgetLogOptFlag.State_12); |
|
|
|
|
|
} |
|
|
|
|
|
tbsBudgetLogService.saveBatch(oldLogList); |
|
|
|
|
|
return R.ok(); |
|
|
|
|
|
} |
|
|
|
|
|
}else if ("next".equals(flag)){ |
|
|
|
|
|
return R.ok(); |
|
|
|
|
|
} |
|
|
|
|
|
}else if (result.getStatus()==500){ |
|
|
|
|
|
return result; |
|
|
|
|
|
} |
|
|
|
|
|
return R.error("远程调用失败"); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|