|
@@ -0,0 +1,294 @@
|
|
|
+package com.jeeplus.human.depart.handover.service;
|
|
|
+
|
|
|
+import cn.hutool.extra.spring.SpringUtil;
|
|
|
+import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
|
|
+import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
|
|
+import com.jeeplus.common.TokenProvider;
|
|
|
+import com.jeeplus.flowable.feign.IFlowableApi;
|
|
|
+import com.jeeplus.human.depart.handover.domain.*;
|
|
|
+import com.jeeplus.human.depart.handover.mapper.HandoverMapper;
|
|
|
+import com.jeeplus.human.depart.registration.domain.DepartRegistration;
|
|
|
+import com.jeeplus.human.enrollment.enrollmentRegistration.domain.EnrollmentKeyCard;
|
|
|
+import com.jeeplus.sys.feign.IRoleApi;
|
|
|
+import com.jeeplus.sys.feign.IUserApi;
|
|
|
+import com.jeeplus.sys.service.dto.RoleDTO;
|
|
|
+import com.jeeplus.sys.service.dto.UserDTO;
|
|
|
+import org.apache.commons.lang3.StringUtils;
|
|
|
+import org.springframework.beans.BeanUtils;
|
|
|
+import org.springframework.stereotype.Service;
|
|
|
+import org.springframework.transaction.annotation.Transactional;
|
|
|
+
|
|
|
+import javax.annotation.Resource;
|
|
|
+import java.util.*;
|
|
|
+
|
|
|
+/**
|
|
|
+ * @author 王强
|
|
|
+ * @version 1.0
|
|
|
+ * @date 2023-10-27 9:04
|
|
|
+ */
|
|
|
+@Service
|
|
|
+@Transactional
|
|
|
+public class HandoverService extends ServiceImpl<HandoverMapper, Handover> {
|
|
|
+
|
|
|
+ @Resource
|
|
|
+ private HandoverMapper mapper;
|
|
|
+
|
|
|
+ @Resource
|
|
|
+ private HandoverDraftService draftService;
|
|
|
+
|
|
|
+ @Resource
|
|
|
+ private HandoverComputerService handoverComputerService;
|
|
|
+
|
|
|
+ @Resource
|
|
|
+ private HandoverAccountsService handoverAccountsService;
|
|
|
+
|
|
|
+ @Resource
|
|
|
+ private HandoverSocialSecurityService handoverSocialSecurityService;
|
|
|
+
|
|
|
+ @Resource
|
|
|
+ private HandoverImprestService handoverImprestService;
|
|
|
+
|
|
|
+ public void deleteByRegistrationId(String id){
|
|
|
+ QueryWrapper<Handover> queryWrapper = new QueryWrapper<>();
|
|
|
+ queryWrapper.eq("registration_id",id);
|
|
|
+ mapper.delete(queryWrapper);
|
|
|
+ }
|
|
|
+
|
|
|
+ public void updateStatusById(Handover dto) {
|
|
|
+ mapper.updateStatusById(dto.getId(), dto.getType());
|
|
|
+ }
|
|
|
+
|
|
|
+ public Handover findById(String id) {
|
|
|
+ // 查询基础信息表
|
|
|
+ Handover info = mapper.getById(id);
|
|
|
+ return info;
|
|
|
+ }
|
|
|
+
|
|
|
+ public Handover saveRegistration(Handover handover) throws Exception {
|
|
|
+ if (StringUtils.isNotEmpty(handover.getId())){
|
|
|
+
|
|
|
+ Handover report = mapper.getById(handover.getId());
|
|
|
+ handover.setCreateById(report.getCreateById());
|
|
|
+ if (report != null){
|
|
|
+ return update(handover);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return add(handover);
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 修改
|
|
|
+ */
|
|
|
+ @Transactional(rollbackFor = Exception.class)
|
|
|
+ public Handover update(Handover reportData) throws Exception{
|
|
|
+ //获取当前登录人信息
|
|
|
+ UserDTO userDTO = SpringUtil.getBean ( IUserApi.class ).getByToken(TokenProvider.getCurrentToken ( ));
|
|
|
+
|
|
|
+ Handover report = new Handover();
|
|
|
+ BeanUtils.copyProperties(reportData, report);
|
|
|
+ report.setUpdateById(userDTO.getId());
|
|
|
+ report.setUpdateTime(new Date());
|
|
|
+ mapper.updateById(report);
|
|
|
+
|
|
|
+ if (report.getType().equals("5")){
|
|
|
+
|
|
|
+ //发起底稿归档检查流程
|
|
|
+ Map map = SpringUtil.getBean(IFlowableApi.class).getByNameForFen("底稿归档检查");
|
|
|
+ String procDefId = map.get("id")+"";
|
|
|
+ HandoverDraft draft = new HandoverDraft();
|
|
|
+ String uid = UUID.randomUUID().toString().replace("-", "");
|
|
|
+ draft.setId(uid);
|
|
|
+ draft.setCreateById(report.getCreateById());
|
|
|
+ draft.setUpdateById(report.getUpdateById());
|
|
|
+ draft.setProcessDefinitionId(procDefId);
|
|
|
+ draft.setHandoverId(report.getId());
|
|
|
+ draftService.save(draft);
|
|
|
+
|
|
|
+ Map<String ,Map<String,String >> allMap = new HashMap<>();
|
|
|
+
|
|
|
+ String procDefKey = map.get("key")+"";
|
|
|
+ String businessTable = "human_resources_depart_handover_draft";
|
|
|
+ String businessId = uid;
|
|
|
+ String title = "底稿归档检查";
|
|
|
+ String assignee = report.getDraftAdministrator();
|
|
|
+ String recordType = "";
|
|
|
+ Map<String, String> newMap = pingMap(procDefId, procDefKey, businessTable, businessId, title, assignee, recordType);
|
|
|
+
|
|
|
+ allMap.put("底稿",newMap);
|
|
|
+
|
|
|
+// SpringUtil.getBean(IFlowableApi.class).startForFenNew(allMap);
|
|
|
+
|
|
|
+ //发起电脑欠款回收流程
|
|
|
+ Map computerMap = SpringUtil.getBean(IFlowableApi.class).getByNameForFen("电脑欠款回收");
|
|
|
+ String computerProcDefId = computerMap.get("id")+"";
|
|
|
+ HandoverComputer computer = new HandoverComputer();
|
|
|
+ String computerId = UUID.randomUUID().toString().replace("-", "");
|
|
|
+ computer.setId(computerId);
|
|
|
+ computer.setCreateById(report.getCreateById());
|
|
|
+ computer.setUpdateById(report.getUpdateById());
|
|
|
+ computer.setProcessDefinitionId(computerProcDefId);
|
|
|
+ computer.setHandoverId(report.getId());
|
|
|
+ handoverComputerService.save(computer);
|
|
|
+
|
|
|
+ String computerProcDefKey = computerMap.get("key")+"";
|
|
|
+ String computerBusinessTable = "human_resources_depart_handover_computer";
|
|
|
+ String computerBusinessId = computerId;
|
|
|
+ String computerTitle = "电脑欠款回收";
|
|
|
+ //根据角色查用户信息
|
|
|
+ RoleDTO computerRoleInfo = SpringUtil.getBean(IRoleApi.class).getRoleDTOByName("电脑款项审查员");
|
|
|
+ String computerAssignee = getAssignee(computerRoleInfo.getId());
|
|
|
+
|
|
|
+ String computerRecordType = "";
|
|
|
+ Map<String, String> computerNewMap = pingMap(computerProcDefId, computerProcDefKey,
|
|
|
+ computerBusinessTable, computerBusinessId, computerTitle, computerAssignee, computerRecordType);
|
|
|
+
|
|
|
+ allMap.put("电脑",computerNewMap);
|
|
|
+
|
|
|
+// SpringUtil.getBean(IFlowableApi.class).startForFenNew(allMap);
|
|
|
+
|
|
|
+ //应收账款流程发起
|
|
|
+ Map accountsMap = SpringUtil.getBean(IFlowableApi.class).getByNameForFen("应收账款检查");
|
|
|
+ String accountsProcDefId = accountsMap.get("id")+"";
|
|
|
+ HandoverAccounts accounts = new HandoverAccounts();
|
|
|
+ String accountsId = UUID.randomUUID().toString().replace("-", "");
|
|
|
+ accounts.setId(accountsId);
|
|
|
+ accounts.setCreateById(report.getCreateById());
|
|
|
+ accounts.setUpdateById(report.getUpdateById());
|
|
|
+ accounts.setProcessDefinitionId(accountsProcDefId);
|
|
|
+ accounts.setHandoverId(report.getId());
|
|
|
+ handoverAccountsService.save(accounts);
|
|
|
+
|
|
|
+ String accountsProcDefKey = accountsMap.get("key")+"";
|
|
|
+ String accountsBusinessTable = "human_resources_depart_handover_accounts";
|
|
|
+ String accountsBusinessId = accountsId;
|
|
|
+ String accountsTitle = "应收账款检查";
|
|
|
+ //根据角色查用户信息
|
|
|
+ RoleDTO accountsRoleInfo = SpringUtil.getBean(IRoleApi.class).getRoleDTOByName("应收账款审查员");
|
|
|
+
|
|
|
+ String accountsAssignee = getAssignee(accountsRoleInfo.getId());
|
|
|
+
|
|
|
+ String accountsRecordType = "";
|
|
|
+ Map<String, String> accountsNewMap = pingMap(accountsProcDefId, accountsProcDefKey,
|
|
|
+ accountsBusinessTable, accountsBusinessId, accountsTitle, accountsAssignee, accountsRecordType);
|
|
|
+
|
|
|
+ allMap.put("应收账款",accountsNewMap);
|
|
|
+// SpringUtil.getBean(IFlowableApi.class).startForFenNew(allMap);
|
|
|
+
|
|
|
+ //社保款项检查流程发起
|
|
|
+ Map socialSecurityMap = SpringUtil.getBean(IFlowableApi.class).getByNameForFen("社保款项检查");
|
|
|
+ String socialSecurityProcDefId = socialSecurityMap.get("id")+"";
|
|
|
+ HandoverSocialSecurity socialSecurity = new HandoverSocialSecurity();
|
|
|
+ String socialSecurityId = UUID.randomUUID().toString().replace("-", "");
|
|
|
+ socialSecurity.setId(socialSecurityId);
|
|
|
+ socialSecurity.setCreateById(report.getCreateById());
|
|
|
+ socialSecurity.setUpdateById(report.getUpdateById());
|
|
|
+ socialSecurity.setProcessDefinitionId(socialSecurityProcDefId);
|
|
|
+ socialSecurity.setHandoverId(report.getId());
|
|
|
+ handoverSocialSecurityService.save(socialSecurity);
|
|
|
+
|
|
|
+ String socialSecurityProcDefKey = socialSecurityMap.get("key")+"";
|
|
|
+ String socialSecurityBusinessTable = "human_resources_depart_handover_social_security";
|
|
|
+ String socialSecurityBusinessId = socialSecurityId;
|
|
|
+ String socialSecurityTitle = "社保款项检查";
|
|
|
+ //根据角色查用户信息
|
|
|
+ RoleDTO socialSecurityRoleInfo = SpringUtil.getBean(IRoleApi.class).getRoleDTOByName("社保欠款审查员");
|
|
|
+
|
|
|
+ String socialSecurityAssignee = getAssignee(socialSecurityRoleInfo.getId());
|
|
|
+
|
|
|
+ String socialSecurityRecordType = "";
|
|
|
+ Map<String, String> socialSecurityNewMap = pingMap(socialSecurityProcDefId, socialSecurityProcDefKey,
|
|
|
+ socialSecurityBusinessTable, socialSecurityBusinessId, socialSecurityTitle, socialSecurityAssignee, socialSecurityRecordType);
|
|
|
+
|
|
|
+ allMap.put("社保欠款",socialSecurityNewMap);
|
|
|
+
|
|
|
+// SpringUtil.getBean(IFlowableApi.class).startForFenNew(allMap);
|
|
|
+
|
|
|
+ //发起备用金检查流程 handoverImprestService
|
|
|
+ Map handoverImprestMap = SpringUtil.getBean(IFlowableApi.class).getByNameForFen("备用金检查");
|
|
|
+ String handoverImprestProcDefId = handoverImprestMap.get("id")+"";
|
|
|
+ HandoverImprest handoverImprest = new HandoverImprest();
|
|
|
+ String handoverImprestId = UUID.randomUUID().toString().replace("-", "");
|
|
|
+ handoverImprest.setId(handoverImprestId);
|
|
|
+ handoverImprest.setCreateById(report.getCreateById());
|
|
|
+ handoverImprest.setUpdateById(report.getUpdateById());
|
|
|
+ handoverImprest.setProcessDefinitionId(handoverImprestProcDefId);
|
|
|
+ handoverImprest.setHandoverId(report.getId());
|
|
|
+ handoverImprestService.save(handoverImprest);
|
|
|
+
|
|
|
+ String handoverImprestProcDefKey = handoverImprestMap.get("key")+"";
|
|
|
+ String handoverImprestBusinessTable = "human_resources_depart_handover_imprest";
|
|
|
+ String handoverImprestBusinessId = handoverImprestId;
|
|
|
+ String handoverImprestTitle = "备用金检查";
|
|
|
+ //根据角色查用户信息
|
|
|
+ RoleDTO roleInfo = SpringUtil.getBean(IRoleApi.class).getRoleDTOByName("备用金审查员");
|
|
|
+ String handoverImprestAssignee = getAssignee(roleInfo.getId());
|
|
|
+
|
|
|
+ String handoverImprestRecordType = "";
|
|
|
+ Map<String, String> handoverImprestNewMap = pingMap(handoverImprestProcDefId, handoverImprestProcDefKey,
|
|
|
+ handoverImprestBusinessTable, handoverImprestBusinessId, handoverImprestTitle, handoverImprestAssignee, handoverImprestRecordType);
|
|
|
+
|
|
|
+ allMap.put("备用金",handoverImprestNewMap);
|
|
|
+
|
|
|
+ SpringUtil.getBean(IFlowableApi.class).startForFenNew(allMap);
|
|
|
+
|
|
|
+ draft.setType("2");
|
|
|
+ draftService.saveOrUpdate(draft);
|
|
|
+ computer.setType("2");
|
|
|
+ handoverComputerService.saveOrUpdate(computer);
|
|
|
+ accounts.setType("2");
|
|
|
+ handoverAccountsService.saveOrUpdate(accounts);
|
|
|
+ socialSecurity.setType("2");
|
|
|
+ handoverSocialSecurityService.saveOrUpdate(socialSecurity);
|
|
|
+ handoverImprest.setType("2");
|
|
|
+ handoverImprestService.saveOrUpdate(handoverImprest);
|
|
|
+ }
|
|
|
+
|
|
|
+ return report;
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ public String getAssignee(String roleId){
|
|
|
+ List<UserDTO> userDTOS = SpringUtil.getBean(IUserApi.class).findListByRoleId(roleId);
|
|
|
+ StringJoiner idJoiner = new StringJoiner(",");
|
|
|
+ for (UserDTO user : userDTOS) {
|
|
|
+ idJoiner.add(String.valueOf(user.getId()));
|
|
|
+ }
|
|
|
+
|
|
|
+ return idJoiner.toString();
|
|
|
+ }
|
|
|
+
|
|
|
+ public Map<String,String> pingMap(String procDefId,String procDefKey,String businessTable,
|
|
|
+ String businessId,String title,String assignee,String recordType){
|
|
|
+ Map<String,String> map = new HashMap();
|
|
|
+ map.put("procDefId", procDefId);
|
|
|
+ map.put("procDefKey", procDefKey);
|
|
|
+ map.put("businessTable", businessTable);
|
|
|
+ map.put("businessId", businessId);
|
|
|
+ map.put("title", title);
|
|
|
+ map.put("assignee", assignee);
|
|
|
+ map.put("recordType", recordType);
|
|
|
+ return map;
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 新增
|
|
|
+ */
|
|
|
+ @Transactional(rollbackFor = Exception.class)
|
|
|
+ public Handover add(Handover reportData) throws Exception{
|
|
|
+
|
|
|
+ UserDTO userDTO = SpringUtil.getBean ( IUserApi.class ).getByToken(TokenProvider.getCurrentToken ( ));
|
|
|
+
|
|
|
+ Handover report = new Handover();
|
|
|
+ BeanUtils.copyProperties(reportData, report);
|
|
|
+ report.setCreateById(userDTO.getId());
|
|
|
+ report.setCreateTime(new Date());
|
|
|
+ report.setUpdateById(userDTO.getId());
|
|
|
+ report.setUpdateTime(new Date());
|
|
|
+
|
|
|
+ mapper.insert(report);
|
|
|
+
|
|
|
+ return report;
|
|
|
+ }
|
|
|
+}
|