|
|
@ -1,8 +1,6 @@ |
|
|
|
package com.qs.serve.modules.tbs.controller; |
|
|
|
|
|
|
|
import com.alibaba.fastjson.JSONObject; |
|
|
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; |
|
|
|
import com.qs.serve.common.config.properties.SeeYonProperties; |
|
|
|
import com.qs.serve.common.model.annotation.SysLog; |
|
|
|
import com.qs.serve.common.model.dto.PageVo; |
|
|
|
import com.qs.serve.common.model.dto.R; |
|
|
@ -12,11 +10,17 @@ import com.qs.serve.common.util.*; |
|
|
|
import com.qs.serve.common.util.model.DateFormatString; |
|
|
|
import com.qs.serve.modules.bms.entity.BmsSupplier; |
|
|
|
import com.qs.serve.modules.bms.service.BmsSupplierService; |
|
|
|
import com.qs.serve.modules.seeyon.entity.BaseCreateProcessBo; |
|
|
|
import com.qs.serve.modules.seeyon.entity.CtpAffair; |
|
|
|
import com.qs.serve.modules.seeyon.entity.CtpAffairCommit; |
|
|
|
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.bo.TbsAffairCommitBo; |
|
|
|
import com.qs.serve.modules.tbs.service.TbsActivityService; |
|
|
|
import lombok.AllArgsConstructor; |
|
|
|
import lombok.extern.slf4j.Slf4j; |
|
|
@ -33,6 +37,7 @@ import java.time.LocalDateTime; |
|
|
|
import java.util.HashMap; |
|
|
|
import java.util.List; |
|
|
|
import java.util.Map; |
|
|
|
import java.util.stream.Collectors; |
|
|
|
|
|
|
|
/** |
|
|
|
* 预算 费用申请 |
|
|
@ -49,7 +54,7 @@ public class TbsCostApplyController { |
|
|
|
private BmsSupplierService bmsSupplierService; |
|
|
|
private SysUserService sysUserService; |
|
|
|
private TbsActivityService tbsActivityService; |
|
|
|
private SeeYonProperties seeYonProperties; |
|
|
|
private SeeYonService seeYonService; |
|
|
|
|
|
|
|
/** |
|
|
|
* 列表 |
|
|
@ -111,31 +116,27 @@ public class TbsCostApplyController { |
|
|
|
tbsCostApplyService.updateById(costApply); |
|
|
|
return R.ok(); |
|
|
|
} |
|
|
|
if(!seeYonProperties.getEnable()){ |
|
|
|
return R.error("远程服务未开启"); |
|
|
|
} |
|
|
|
String url = seeYonProperties.getUrl(); |
|
|
|
SysUser sysUser = sysUserService.getById(AuthContextUtils.getSysUserId()); |
|
|
|
TbsCostApply tbsCostApply = tbsCostApplyService.getById(id); |
|
|
|
if(tbsCostApply.getChargeState().equals(0)){ |
|
|
|
if(tbsCostApply.getChargeState().equals(TbsCostApplyState.State_0_unPublish.getCode())){ |
|
|
|
Map<String, Object> data = new HashMap<>(10); |
|
|
|
data.put("empId",sysUser.getCode()); |
|
|
|
data.put("applyTime",DateUtils.format(LocalDateTime.now(), DateFormatString.DATE_TIME)); |
|
|
|
data.put("money",tbsCostApply.getTotalActivityAmount()); |
|
|
|
data.put("costApplyCode",tbsCostApply.getId()); |
|
|
|
data.put("costApplyId",tbsCostApply.getId()); |
|
|
|
Map<String,Object> param = new HashMap<>(10); |
|
|
|
param.put("templateCode", TbsSeeYonConst.COST_APPLY_FORM); |
|
|
|
param.put("memberLoginName",TbsSeeYonConst.COST_APPLY_USER); |
|
|
|
param.put("subjectTitle",tbsCostApply.getChargeTheme()); |
|
|
|
param.put("dataJson",JsonUtil.objectToJson(data)); |
|
|
|
R<String> flowIdResult = HttpUtil.doPostResult(url+TbsSeeYonConst.API_PROCESS_CREATE, JsonUtil.objectToJson(param),null); |
|
|
|
BaseCreateProcessBo createProcess = new BaseCreateProcessBo(); |
|
|
|
createProcess.setTemplateCode(TbsSeeYonConst.COST_APPLY_FORM); |
|
|
|
createProcess.setMemberLoginName(TbsSeeYonConst.COST_APPLY_USER); |
|
|
|
createProcess.setSubjectTitle(tbsCostApply.getChargeTheme()); |
|
|
|
createProcess.setDataJson(JsonUtil.objectToJson(data)); |
|
|
|
R<String> flowIdResult = seeYonService.baseCreateProcess(createProcess); |
|
|
|
if(flowIdResult.getStatus()!=200){ |
|
|
|
return R.error("远程服务调用失败"); |
|
|
|
} |
|
|
|
String flowId = flowIdResult.getData(); |
|
|
|
String formId = null; |
|
|
|
R<String> formIdResult = HttpUtil.doGetResult(url+TbsSeeYonConst.API_GET_FORM_ID,null); |
|
|
|
R<String> formIdResult = seeYonService.getFormId(tbsCostApply.getId()); |
|
|
|
if(formIdResult.getStatus()==200){ |
|
|
|
formId = formIdResult.getData(); |
|
|
|
} |
|
|
@ -144,13 +145,16 @@ public class TbsCostApplyController { |
|
|
|
costApply.setSyFlowId(flowId); |
|
|
|
costApply.setSyFormId(formId); |
|
|
|
tbsCostApplyService.updateById(costApply); |
|
|
|
//todo 扣除预算
|
|
|
|
return R.ok(); |
|
|
|
}else if (tbsCostApply.getChargeState().equals(4)){ |
|
|
|
}else if (tbsCostApply.getChargeState().equals(TbsCostApplyState.State_4_refused.getCode())){ |
|
|
|
//todo 驳回重新申请
|
|
|
|
} |
|
|
|
return R.error("当前状态不可申请"); |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
* 更新 |
|
|
|
* @param param |
|
|
@ -208,5 +212,92 @@ public class TbsCostApplyController { |
|
|
|
return R.isTrue(result); |
|
|
|
} |
|
|
|
|
|
|
|
/** |
|
|
|
* 申请审批表单(翻页) |
|
|
|
* @param state 状态:0-未完成与已完成;1-未完成;2已完成;其它-加载所有 |
|
|
|
* @param pageNum |
|
|
|
* @param pageSize |
|
|
|
* @return |
|
|
|
*/ |
|
|
|
@GetMapping("/pageMemberAffair") |
|
|
|
@SysLog(module = SystemModule.Budget, title = "费用申请", biz = BizType.DELETE) |
|
|
|
public R<?> pageMemberAffair(Integer state,Integer pageNum,Integer pageSize){ |
|
|
|
SysUser sysUser = sysUserService.getById(AuthContextUtils.getSysUserId()); |
|
|
|
if(!StringUtils.hasText(sysUser.getSyUserId())){ |
|
|
|
return R.error("当前账号未绑定致远用户信息"); |
|
|
|
} |
|
|
|
CtpAffairQo param = new CtpAffairQo(); |
|
|
|
param.setMemberId(sysUser.getSyUserId()); |
|
|
|
param.setState(state); |
|
|
|
param.setPageNum(pageNum); |
|
|
|
param.setPageSize(pageSize); |
|
|
|
R<PageVo<CtpAffair>> syResult = seeYonService.pageMemberAffair(param); |
|
|
|
PageVo<CtpAffair> pageVo = syResult.getData(); |
|
|
|
List<CtpAffair> ctpAffairs = pageVo.getList(); |
|
|
|
if(ctpAffairs.size()>0){ |
|
|
|
List<String> costApplyIds = ctpAffairs.stream().map(CtpAffair::getCostApplyId).collect(Collectors.toList()); |
|
|
|
List<TbsCostApply> costApplyList = tbsCostApplyService.listByIds(costApplyIds); |
|
|
|
for (TbsCostApply costApply : costApplyList) { |
|
|
|
for (CtpAffair ctpAffair : ctpAffairs) { |
|
|
|
if(costApply.getId().toString().equals(ctpAffair.getCostApplyId())){ |
|
|
|
costApply.setAffairId(ctpAffair.getAffairId()); |
|
|
|
break; |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
PageVo<TbsCostApply> costApplyPageVo = new PageVo<>(); |
|
|
|
costApplyPageVo.setPageNum(pageVo.getPageNum()); |
|
|
|
costApplyPageVo.setPageSize(pageVo.getPageSize()); |
|
|
|
costApplyPageVo.setTotal(pageVo.getTotal()); |
|
|
|
costApplyPageVo.setTotalPage(pageVo.getTotalPage()); |
|
|
|
costApplyPageVo.setList(costApplyList); |
|
|
|
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){ |
|
|
|
SysUser sysUser = sysUserService.getById(AuthContextUtils.getSysUserId()); |
|
|
|
TbsCostApply costApply = tbsCostApplyService.getById(affairCommit.getAffairId()); |
|
|
|
if(!costApply.getChargeState().equals(TbsCostApplyState.State_1_apply.getCode())){ |
|
|
|
return R.error("param err1"); |
|
|
|
} |
|
|
|
CtpAffairCommit param = new CtpAffairCommit(); |
|
|
|
param.setState(affairCommit.getState()); |
|
|
|
param.setAffairId(affairCommit.getAffairId()); |
|
|
|
param.setComment(affairCommit.getComment()); |
|
|
|
if(affairCommit.getState().equals(0)){ |
|
|
|
param.setMemberId(sysUser.getSyUserId()); |
|
|
|
}else if(affairCommit.getState().equals(1)){ |
|
|
|
param.setMemberId(sysUser.getSyAccount()); |
|
|
|
}else { |
|
|
|
Assert.throwEx("param err2"); |
|
|
|
} |
|
|
|
R<String> result = seeYonService.affairCommit(param); |
|
|
|
if(result.getStatus()==200){ |
|
|
|
//判断是否有下一节点
|
|
|
|
String flag = result.getData(); |
|
|
|
//审批中(next)、完成(finish)、拒绝(refused)
|
|
|
|
if("finish".equals(flag)){ |
|
|
|
TbsCostApply apply = new TbsCostApply(); |
|
|
|
apply.setId(costApply.getId()); |
|
|
|
apply.setChargeState(TbsCostApplyState.State_2_actioning.getCode()); |
|
|
|
tbsCostApplyService.updateById(apply); |
|
|
|
}else if ("refused".equals(flag)){ |
|
|
|
//todo 退回节点
|
|
|
|
}else if ("next".equals(flag)){ |
|
|
|
return R.ok(); |
|
|
|
} |
|
|
|
} |
|
|
|
return R.error("远程调用失败"); |
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|