| | |
| | | import com.baomidou.mybatisplus.core.metadata.IPage; |
| | | import com.baomidou.mybatisplus.core.toolkit.Wrappers; |
| | | import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; |
| | | import com.xxl.job.core.util.NetUtil; |
| | | import org.flowable.engine.RepositoryService; |
| | | import org.flowable.engine.repository.ProcessDefinition; |
| | | import org.flowable.engine.repository.ProcessDefinitionQuery; |
| | | import org.slf4j.Logger; |
| | | import org.slf4j.LoggerFactory; |
| | | import org.springblade.common.cache.SysCache; |
| | | import org.springblade.common.constant.CommonConstant; |
| | | import org.springblade.common.param.CommonParamSet; |
| | | import org.springblade.common.utils.RoleUtil; |
| | | import org.springblade.common.utils.SpringUtils; |
| | | import org.springblade.core.log.exception.ServiceException; |
| | | import org.springblade.core.secure.utils.AuthUtil; |
| | | import org.springblade.core.tool.support.Kv; |
| | | import org.springblade.core.tool.utils.DateUtil; |
| | | import org.springblade.core.tool.utils.Func; |
| | | import org.springblade.core.tool.utils.SpringUtil; |
| | | import org.springblade.flow.business.service.IFlowService; |
| | | import org.springblade.flow.core.constant.ProcessConstant; |
| | | import org.springblade.flow.core.entity.BladeFlow; |
| | |
| | | import org.springblade.modules.district.service.IDistrictService; |
| | | import org.springblade.modules.ownersCommittee.entity.OwnersCommitteeEntity; |
| | | import org.springblade.modules.ownersCommittee.service.IOwnersCommitteeService; |
| | | import org.springblade.modules.partyOrganization.vo.PartyOrganizationVO; |
| | | import org.springblade.modules.property.entity.PropertyCapitalApplyEntity; |
| | | import org.springblade.modules.property.entity.PropertyCompanyDistrictEntity; |
| | | import org.springblade.modules.property.entity.PropertyCompanyEntity; |
| | | import org.springblade.modules.property.mapper.PropertyCapitalApplyMapper; |
| | | import org.springblade.modules.property.service.IPropertyCapitalApplyService; |
| | | import org.springblade.modules.property.service.IPropertyCompanyDistrictService; |
| | | import org.springblade.modules.property.service.IPropertyCompanyService; |
| | | import org.springblade.modules.property.service.IPropertyDistrictUserService; |
| | | import org.springblade.modules.property.vo.PropertyCapitalApplyVO; |
| | | import org.springblade.modules.system.entity.Dept; |
| | |
| | | import org.springframework.stereotype.Service; |
| | | import org.springframework.transaction.annotation.Transactional; |
| | | |
| | | import java.util.ArrayList; |
| | | import java.util.List; |
| | | import java.util.stream.Collectors; |
| | | |
| | | /** |
| | | * 物业维修资金申请表 服务实现类 |
| | |
| | | */ |
| | | @Service |
| | | public class PropertyCapitalApplyServiceImpl extends ServiceImpl<PropertyCapitalApplyMapper, PropertyCapitalApplyEntity> implements IPropertyCapitalApplyService { |
| | | private static Logger logger = LoggerFactory.getLogger(NetUtil.class); |
| | | |
| | | @Autowired |
| | | private IDeptService deptService; |
| | | |
| | | @Override |
| | | public IPage<PropertyCapitalApplyVO> selectPropertyCapitalApplyPage(IPage<PropertyCapitalApplyVO> page, PropertyCapitalApplyVO propertyCapitalApply) { |
| | | CommonParamSet commonParamSet = new CommonParamSet<>().invoke(PropertyCapitalApplyVO.class, propertyCapitalApply); |
| | | // 判断角色,物业角色只能查询当前小区的 |
| | | |
| | | String userRole = AuthUtil.getUserRole(); |
| | | if (userRole.contains("wygly")) { |
| | | IPropertyDistrictUserService bean = SpringUtils.getBean(IPropertyDistrictUserService.class); |
| | | List<String> strings = bean.selectPropertyDistrictByUserId(AuthUtil.getUserId()); |
| | | propertyCapitalApply.setDistrictIdList(strings); |
| | | if (RoleUtil.isProperty(userRole)) { |
| | | // 查询小区id |
| | | IPropertyDistrictUserService propertyDistrictUserService = SpringUtils.getBean(IPropertyDistrictUserService.class); |
| | | List<String> districtIds = propertyDistrictUserService.selectPropertyDistrictByUserId(AuthUtil.getUserId()); |
| | | // 通过用户机构查询用户的物业公司 |
| | | IPropertyCompanyService bean = SpringUtil.getBean(IPropertyCompanyService.class); |
| | | PropertyCompanyEntity one = bean.getOne(Wrappers.<PropertyCompanyEntity>lambdaQuery().eq(PropertyCompanyEntity::getDeptId, AuthUtil.getDeptId()).last("limit 1")); |
| | | if (one != null) { |
| | | IPropertyCompanyDistrictService bean2 = SpringUtils.getBean(IPropertyCompanyDistrictService.class); |
| | | // 通过物业公司,查询小区 |
| | | List<PropertyCompanyDistrictEntity> list = bean2.list(Wrappers.<PropertyCompanyDistrictEntity>lambdaQuery() |
| | | .eq(PropertyCompanyDistrictEntity::getPropertyCompanyId, one.getId())); |
| | | if (list.size() > 0) { |
| | | List<String> collect = list.stream().map(i -> i.getDistrictId()).collect(Collectors.toList()); |
| | | districtIds.addAll(collect); |
| | | } |
| | | } |
| | | propertyCapitalApply.setDistrictIdList(districtIds); |
| | | if (districtIds.size() == 0) { |
| | | return page.setRecords(new ArrayList<>()); |
| | | } |
| | | } |
| | | |
| | | |
| | | return page.setRecords(baseMapper.selectPropertyCapitalApplyPage(page, propertyCapitalApply)); |
| | | return page.setRecords(baseMapper.selectPropertyCapitalApplyPage(page, propertyCapitalApply, |
| | | commonParamSet.getRegionChildCodesList(), commonParamSet.getIsAdministrator())); |
| | | } |
| | | |
| | | @Autowired |
| | |
| | | public boolean startProcess(PropertyCapitalApplyVO applyVO) { |
| | | String businessTable = FlowUtil.getBusinessTable(ProcessConstant.LEAVE_KEY); |
| | | if (Func.isEmpty(applyVO.getId())) { |
| | | // 保存leave |
| | | applyVO.setApplyTime(DateUtil.now()); |
| | | save(applyVO); |
| | | // 判断是否有业委会,查询业委会负责人 |
| | | IOwnersCommitteeService bean = SpringUtils.getBean(IOwnersCommitteeService.class); |
| | | OwnersCommitteeEntity one = bean.getOne(Wrappers.<OwnersCommitteeEntity>lambdaQuery() |
| | | .eq(OwnersCommitteeEntity::getAreaId, applyVO.getDistrictId()) |
| | | .eq(OwnersCommitteeEntity::getDeleteFlag,0) |
| | | .eq(OwnersCommitteeEntity::getStatus,0) |
| | | .last("limit 1")); |
| | | Integer ownersCommitteeFlag = CommonConstant.NUMBER_TWO; |
| | | if (one != null && one.getPrincipalId() != null) { |
| | | ownersCommitteeFlag = CommonConstant.NUMBER_ONE; |
| | | } |
| | | // 查询街道负责人 通过小区id 查询街道编码 |
| | | // 通过街道编码查询街道名称, |
| | | // 通过街道名称查询 人的部门是街道名称的 |
| | | IUserService user = SpringUtils.getBean(IUserService.class); |
| | | IDistrictService district = SpringUtils.getBean(IDistrictService.class); |
| | | IRegionService region = SpringUtils.getBean(IRegionService.class); |
| | | IDeptService dept = SpringUtils.getBean(IDeptService.class); |
| | | DistrictEntity one1 = district.getOne(Wrappers.<DistrictEntity>lambdaQuery() |
| | | .eq(DistrictEntity::getId, applyVO.getDistrictId())); |
| | | User one4 = null; |
| | | // 保存leave |
| | | applyVO.setApplyTime(DateUtil.now()); |
| | | save(applyVO); |
| | | // 判断是否有业委会,查询业委会负责人 |
| | | IOwnersCommitteeService bean = SpringUtils.getBean(IOwnersCommitteeService.class); |
| | | OwnersCommitteeEntity ywhInfo = bean.getOne(Wrappers.<OwnersCommitteeEntity>lambdaQuery() |
| | | .eq(OwnersCommitteeEntity::getAreaId, applyVO.getDistrictId()) |
| | | .eq(OwnersCommitteeEntity::getDeleteFlag, 0) |
| | | .eq(OwnersCommitteeEntity::getStatus, 0) |
| | | .last("limit 1")); |
| | | Integer ownersCommitteeFlag = CommonConstant.NUMBER_TWO; |
| | | if (ywhInfo != null && ywhInfo.getPrincipalId() != null) { |
| | | // 有业委会 |
| | | ownersCommitteeFlag = CommonConstant.NUMBER_ONE; |
| | | } |
| | | // 查询街道负责人 通过小区id 查询街道编码 |
| | | // 通过街道编码查询街道名称, |
| | | // 通过街道名称查询 人的部门是街道名称的 |
| | | IUserService userService = SpringUtils.getBean(IUserService.class); |
| | | IDistrictService districtService = SpringUtils.getBean(IDistrictService.class); |
| | | IRegionService regionService = SpringUtils.getBean(IRegionService.class); |
| | | IDeptService deptService = SpringUtils.getBean(IDeptService.class); |
| | | DistrictEntity districtEntity = districtService.getOne(Wrappers.<DistrictEntity>lambdaQuery() |
| | | .eq(DistrictEntity::getId, applyVO.getDistrictId())); |
| | | User jdUserInfo = null; |
| | | // 查询街道责人 |
| | | try { |
| | | Region one2 = region.getOne(Wrappers.<Region>lambdaQuery().eq(Region::getCode, one1.getCommunityCode().substring(0, 9))); |
| | | Dept one3 = dept.getOne(Wrappers.<Dept>lambdaQuery().eq(Dept::getDeptName, one2.getName())); |
| | | one4 = user.getOne(Wrappers.<User>lambdaQuery().eq(User::getDeptId, one3.getId()) |
| | | .eq(User::getRoleId,"1729814500990304258") |
| | | .eq(User::getIsDeleted,0) |
| | | .last("limit 1")); |
| | | Region regionServiceOne = regionService.getOne(Wrappers.<Region>lambdaQuery() |
| | | .eq(Region::getCode, districtEntity.getCommunityCode().substring(0, 9))); |
| | | |
| | | Dept deptServiceOne = deptService.getOne(Wrappers.<Dept>lambdaQuery() |
| | | .eq(Dept::getDeptName, regionServiceOne.getName())); |
| | | |
| | | jdUserInfo = userService.getOne(Wrappers.<User>lambdaQuery().eq(User::getDeptId, deptServiceOne.getId()) |
| | | .like(User::getRoleId, "1729814500990304258").eq(User::getIsDeleted, 0).last("limit 1")); |
| | | if (jdUserInfo == null) { |
| | | logger.error("街道信息不存在***"); |
| | | throw new ServiceException("街道信息不存在"); |
| | | } |
| | | } catch (Exception e) { |
| | | logger.error("街道信息不存在", e); |
| | | throw new ServiceException("街道信息不存在"); |
| | | } |
| | | // 查询住建局负责人 |
| | | User user4 = null; |
| | | // 查询信州区住建局负责人 |
| | | User xzUserInfo = null; |
| | | try { |
| | | Region region2 = region.getOne(Wrappers.<Region>lambdaQuery().eq(Region::getCode, one1.getCommunityCode().substring(0, 6))); |
| | | Dept dept3 = dept.getOne(Wrappers.<Dept>lambdaQuery().eq(Dept::getDeptName, region2.getName() + "住建局").last("limit 1")); |
| | | user4 = user.getOne(Wrappers.<User>lambdaQuery().eq(User::getDeptId, dept3.getId()) |
| | | .eq(User::getRoleId,"1738072768615333890") |
| | | .eq(User::getIsDeleted,0) |
| | | .last("limit 1")); |
| | | // Region region2 = region.getOne(Wrappers.<Region>lambdaQuery().eq(Region::getCode, one1.getCommunityCode().substring(0, 6))); |
| | | Dept dept3 = deptService.getOne(Wrappers.<Dept>lambdaQuery().eq(Dept::getDeptName, "信州区" + "住建局").last("limit 1")); |
| | | xzUserInfo = userService.getOne(Wrappers.<User>lambdaQuery().eq(User::getDeptId, dept3.getId()) |
| | | .like(User::getRoleId, "1738072768615333890").eq(User::getIsDeleted, 0).last("limit 1")); |
| | | if (xzUserInfo == null) { |
| | | logger.error("信州区住建局信息不存在***"); |
| | | throw new ServiceException("信州区住建局信息不存在"); |
| | | } |
| | | } catch (Exception e) { |
| | | throw new ServiceException("住建局信息不存在"); |
| | | logger.error("信州区住建局信息不存在", e); |
| | | throw new ServiceException("信州区住建局信息不存在"); |
| | | } |
| | | |
| | | // 查询上饶市住建局负责人 |
| | | User srUserInfo = null; |
| | | try { |
| | | // Region region2 = region.getOne(Wrappers.<Region>lambdaQuery().eq(Region::getCode, one1.getCommunityCode().substring(0, 6))); |
| | | Dept dept3 = deptService.getOne(Wrappers.<Dept>lambdaQuery().eq(Dept::getDeptName, "上饶市" + "住建局").last("limit 1")); |
| | | srUserInfo = userService.getOne(Wrappers.<User>lambdaQuery().eq(User::getDeptId, dept3.getId()) |
| | | .like(User::getRoleId, "1738072768615333890").eq(User::getIsDeleted, 0).last("limit 1")); |
| | | if (srUserInfo == null) { |
| | | logger.error("上饶市住建局信息不存在***"); |
| | | throw new ServiceException("上饶市住建局信息不存在"); |
| | | } |
| | | } catch (Exception e) { |
| | | logger.error("上饶市住建局信息不存在", e); |
| | | throw new ServiceException("上饶市住建局信息不存在"); |
| | | } |
| | | Kv variables = null; |
| | | ProcessDefinitionQuery processDefinitionQuery = repositoryService.createProcessDefinitionQuery().latestVersion().orderByProcessDefinitionKey().asc(); |
| | | // 启动流程 |
| | | if (CommonConstant.NUMBER_ONE.equals(ownersCommitteeFlag) && CommonConstant.NUMBER_ONE.equals(applyVO.getPropertyFlag())) { |
| | | applyVO.setApplyStatus(CommonConstant.NUMBER_ONE); |
| | | ProcessDefinition processDefinition = processDefinitionQuery.processDefinitionKey("haveMaintenanceFundApply").singleResult(); |
| | | applyVO.setProcessDefinitionId(processDefinition.getId()); |
| | | // 有物业和有业委会 |
| | | variables = Kv.create() |
| | | .set(ProcessConstant.TASK_VARIABLE_CREATE_USER, AuthUtil.getUserName()) |
| | | .set("ownersCommitteeUser", TaskUtil.getTaskUser(one.getPrincipalId().toString())) |
| | | .set("streetUser", TaskUtil.getTaskUser(one4.getId().toString())) |
| | | .set("constructionUser", TaskUtil.getTaskUser(user4.getId().toString())) |
| | | .set("applyUser", TaskUtil.getTaskUser(AuthUtil.getUserId().toString())) |
| | | .set("ownersCommitteeFlag", ownersCommitteeFlag); |
| | | } else { |
| | | if(CommonConstant.NUMBER_TWO.equals(ownersCommitteeFlag) && CommonConstant.NUMBER_ONE.equals(applyVO.getPropertyFlag())){ |
| | | // 有物业和无业委会 |
| | | ProcessDefinitionQuery processDefinitionQuery = repositoryService.createProcessDefinitionQuery().latestVersion().orderByProcessDefinitionKey().asc(); |
| | | // 启动流程 |
| | | if (CommonConstant.NUMBER_ONE.equals(ownersCommitteeFlag) && CommonConstant.NUMBER_ONE.equals(applyVO.getPropertyFlag())) { |
| | | applyVO.setApplyStatus(CommonConstant.NUMBER_ONE); |
| | | ProcessDefinition processDefinition = processDefinitionQuery.processDefinitionKey("haveMaintenanceFundApply").singleResult(); |
| | | applyVO.setProcessDefinitionId(processDefinition.getId()); |
| | | }else { |
| | | // 无物业和无业委会 |
| | | ProcessDefinition processDefinition = processDefinitionQuery.processDefinitionKey("notMaintenanceFundApply").singleResult(); |
| | | applyVO.setProcessDefinitionId(processDefinition.getId()); |
| | | // 有物业和有业委会 |
| | | variables = Kv.create() |
| | | .set(ProcessConstant.TASK_VARIABLE_CREATE_USER, AuthUtil.getUserName()) |
| | | .set("ownersCommitteeUser", TaskUtil.getTaskUser(ywhInfo.getPrincipalId().toString())) |
| | | .set("streetUser", TaskUtil.getTaskUser(jdUserInfo.getId().toString())) |
| | | .set("constructionUser", TaskUtil.getTaskUser(xzUserInfo.getId().toString())) |
| | | .set("srConstructionUser", TaskUtil.getTaskUser(srUserInfo.getId().toString())) |
| | | .set("applyUser", TaskUtil.getTaskUser(AuthUtil.getUserId().toString())) |
| | | .set("ownersCommitteeFlag", ownersCommitteeFlag); |
| | | } else { |
| | | if (CommonConstant.NUMBER_TWO.equals(ownersCommitteeFlag) && CommonConstant.NUMBER_ONE.equals(applyVO.getPropertyFlag())) { |
| | | // 有物业和无业委会 |
| | | ProcessDefinition processDefinition = processDefinitionQuery.processDefinitionKey("haveMaintenanceFundApply").singleResult(); |
| | | applyVO.setProcessDefinitionId(processDefinition.getId()); |
| | | } else { |
| | | // 无物业和无业委会 |
| | | ProcessDefinition processDefinition = processDefinitionQuery.processDefinitionKey("notMaintenanceFundApply").singleResult(); |
| | | applyVO.setProcessDefinitionId(processDefinition.getId()); |
| | | } |
| | | applyVO.setApplyStatus(CommonConstant.NUMBER_TWO); |
| | | variables = Kv.create() |
| | | .set(ProcessConstant.TASK_VARIABLE_CREATE_USER, AuthUtil.getUserName()) |
| | | .set("streetUser", TaskUtil.getTaskUser(jdUserInfo.getId().toString())) |
| | | .set("constructionUser", TaskUtil.getTaskUser(xzUserInfo.getId().toString())) |
| | | .set("srConstructionUser", TaskUtil.getTaskUser(srUserInfo.getId().toString())) |
| | | .set("applyUser", TaskUtil.getTaskUser(AuthUtil.getUserId().toString())) |
| | | .set("ownersCommitteeFlag", ownersCommitteeFlag); |
| | | } |
| | | applyVO.setApplyStatus(CommonConstant.NUMBER_TWO); |
| | | variables = Kv.create() |
| | | .set(ProcessConstant.TASK_VARIABLE_CREATE_USER, AuthUtil.getUserName()) |
| | | .set("streetUser", TaskUtil.getTaskUser(one4.getId().toString())) |
| | | .set("constructionUser", TaskUtil.getTaskUser(user4.getId().toString())) |
| | | .set("applyUser", TaskUtil.getTaskUser(AuthUtil.getUserId().toString())) |
| | | .set("ownersCommitteeFlag", ownersCommitteeFlag); |
| | | } |
| | | BladeFlow flow = flowService.startProcessInstanceById(applyVO.getProcessDefinitionId(), |
| | | FlowUtil.getBusinessKey(businessTable, String.valueOf(applyVO.getId())), variables); |
| | | if (Func.isNotEmpty(flow)) { |
| | | log.debug("流程已启动,流程ID:" + flow.getProcessInstanceId()); |
| | | // 返回流程id写入leave |
| | | applyVO.setProcessInstanceId(flow.getProcessInstanceId()); |
| | | updateById(applyVO); |
| | | } else { |
| | | throw new ServiceException("开启流程失败"); |
| | | } |
| | | BladeFlow flow = flowService.startProcessInstanceById(applyVO.getProcessDefinitionId(), |
| | | FlowUtil.getBusinessKey(businessTable, String.valueOf(applyVO.getId())), variables); |
| | | if (Func.isNotEmpty(flow)) { |
| | | log.debug("流程已启动,流程ID:" + flow.getProcessInstanceId()); |
| | | // 返回流程id写入leave |
| | | applyVO.setProcessInstanceId(flow.getProcessInstanceId()); |
| | | updateById(applyVO); |
| | | } else { |
| | | throw new ServiceException("开启流程失败"); |
| | | } |
| | | } else { |
| | | updateById(applyVO); |
| | | } |