| New file |
| | |
| | | /* |
| | | * Copyright (c) 2018-2028, Chill Zhuang All rights reserved. |
| | | * |
| | | * Redistribution and use in source and binary forms, with or without |
| | | * modification, are permitted provided that the following conditions are met: |
| | | * |
| | | * Redistributions of source code must retain the above copyright notice, |
| | | * this list of conditions and the following disclaimer. |
| | | * Redistributions in binary form must reproduce the above copyright |
| | | * notice, this list of conditions and the following disclaimer in the |
| | | * documentation and/or other materials provided with the distribution. |
| | | * Neither the name of the dreamlu.net developer nor the names of its |
| | | * contributors may be used to endorse or promote products derived from |
| | | * this software without specific prior written permission. |
| | | * Author: Chill 庄骞 (smallchill@163.com) |
| | | */ |
| | | package org.springblade.modules.task.service.impl; |
| | | |
| | | import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; |
| | | import com.baomidou.mybatisplus.core.toolkit.Wrappers; |
| | | import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; |
| | | import org.apache.commons.lang3.StringUtils; |
| | | import org.springblade.common.constant.CommonConstant; |
| | | import org.springblade.common.constant.DictConstant; |
| | | import org.springblade.common.param.CommonParamSet; |
| | | import org.springblade.common.utils.AuthUtils; |
| | | import org.springblade.common.utils.SpringUtils; |
| | | import org.springblade.core.secure.utils.AuthUtil; |
| | | import org.springblade.core.tool.utils.SpringUtil; |
| | | import org.springblade.modules.house.entity.HouseEntity; |
| | | import org.springblade.modules.house.service.IHouseService; |
| | | import org.springblade.modules.place.entity.PlaceEntity; |
| | | import org.springblade.modules.place.service.IPlaceService; |
| | | import org.springblade.modules.task.entity.*; |
| | | import org.springblade.modules.task.service.ITaskPlaceRecordService; |
| | | import org.springblade.modules.task.service.ITaskService; |
| | | import org.springblade.modules.task.vo.TaskPlaceRecordVO; |
| | | import org.springblade.modules.task.vo.TaskReportForRepairsVO; |
| | | import org.springblade.modules.task.vo.TaskResidencePermitApplyVO; |
| | | import org.springblade.modules.task.mapper.TaskResidencePermitApplyMapper; |
| | | import org.springblade.modules.task.service.ITaskResidencePermitApplyService; |
| | | import org.springblade.core.mp.base.BaseServiceImpl; |
| | | import org.springframework.context.annotation.Lazy; |
| | | import org.springframework.stereotype.Service; |
| | | import com.baomidou.mybatisplus.core.metadata.IPage; |
| | | |
| | | import javax.annotation.Resource; |
| | | import java.util.Date; |
| | | import java.util.List; |
| | | import java.util.stream.Collectors; |
| | | |
| | | /** |
| | | * 居住证申请 服务实现类 |
| | | * |
| | | * @author BladeX |
| | | * @since 2024-03-14 |
| | | */ |
| | | @Service |
| | | public class TaskResidencePermitApplyServiceImpl extends ServiceImpl<TaskResidencePermitApplyMapper, TaskResidencePermitApplyEntity> implements ITaskResidencePermitApplyService { |
| | | |
| | | @Resource |
| | | @Lazy |
| | | private ITaskService taskService; |
| | | |
| | | @Override |
| | | public IPage<TaskResidencePermitApplyVO> selectTaskResidencePermitApplyPage(IPage<TaskResidencePermitApplyVO> page, TaskResidencePermitApplyVO taskResidencePermitApply) { |
| | | CommonParamSet commonParamSet = new CommonParamSet().invoke(TaskResidencePermitApplyVO.class, taskResidencePermitApply); |
| | | if (taskResidencePermitApply.getRoleName() != null && taskResidencePermitApply.getRoleName().equals("inhabitant")) { |
| | | taskResidencePermitApply.setCreateUser(AuthUtil.getUserId()); |
| | | } |
| | | return page.setRecords(baseMapper.selectTaskResidencePermitApplyPage(page, taskResidencePermitApply, |
| | | commonParamSet.getRegionChildCodesList(), commonParamSet.getIsAdministrator(), commonParamSet.getGridCodeList())); |
| | | } |
| | | |
| | | @Override |
| | | public Boolean saveResidencePermitApplyEntity(TaskResidencePermitApplyEntity permitApply) { |
| | | permitApply.setCreateUser(AuthUtil.getUserId()); |
| | | // 1.保存任务表 |
| | | ITaskService taskService = SpringUtils.getBean(ITaskService.class); |
| | | Long aLong = taskService.saveTask(CommonConstant.NUMBER_ONE, DictConstant.RESIDENCE_PERMIT_APPLICATION, 1, |
| | | "", AuthUtil.getUserId(), permitApply.getHouseCode(), CommonConstant.NUMBER_TWO, 1); |
| | | if (aLong <= 0) { |
| | | return false; |
| | | } |
| | | if (StringUtils.isNotBlank(permitApply.getHouseCode())) { |
| | | // 设置网格编码 |
| | | IHouseService houseService = SpringUtils.getBean(IHouseService.class); |
| | | HouseEntity houseEntity = houseService.getOne(Wrappers.<HouseEntity>lambdaQuery() |
| | | .eq(HouseEntity::getHouseCode, permitApply.getHouseCode())); |
| | | permitApply.setGridCode(houseEntity.getGridCode()); |
| | | permitApply.setJwGridCode(houseEntity.getJwGridCode()); |
| | | } |
| | | |
| | | permitApply.setTaskId(aLong); |
| | | // 2.保存任务详情 |
| | | boolean save = save(permitApply); |
| | | return save; |
| | | } |
| | | |
| | | @Override |
| | | public Integer getCount(String neiCode, int status) { |
| | | TaskResidencePermitApplyVO taskResidencePermitApply = new TaskResidencePermitApplyVO(); |
| | | taskResidencePermitApply.setCommunityCode(neiCode); |
| | | // 获取请求头中的角色别名 |
| | | String roleName = SpringUtils.getRequestParam("roleName"); |
| | | if (AuthUtils.isMj(roleName)) { |
| | | // todo 需要改造 |
| | | CommonParamSet commonParamSet = new CommonParamSet().invoke(TaskResidencePermitApplyVO.class, taskResidencePermitApply); |
| | | return baseMapper.getCount(neiCode, status, AuthUtil.getUserId(),commonParamSet.getRegionChildCodesList(), commonParamSet.getIsAdministrator(), commonParamSet.getGridCodeList()); |
| | | } |
| | | return 0; |
| | | } |
| | | |
| | | /** |
| | | * 居住证申请 审核 |
| | | * @param taskResidencePermitApply |
| | | * @return |
| | | */ |
| | | @Override |
| | | public Boolean updateResidencePermitApplyEntity(TaskResidencePermitApplyEntity taskResidencePermitApply) { |
| | | taskResidencePermitApply.setConfirmTime(new Date()); |
| | | taskResidencePermitApply.setConfirmUserId(AuthUtil.getUserId()); |
| | | boolean b = updateById(taskResidencePermitApply); |
| | | if (b) { |
| | | TaskResidencePermitApplyEntity entity = getById(taskResidencePermitApply.getId()); |
| | | // 更新任务表状态 |
| | | TaskEntity taskEntity = new TaskEntity(); |
| | | taskEntity.setId(entity.getTaskId()); |
| | | taskEntity.setStatus(taskResidencePermitApply.getConfirmFlag()); |
| | | b = taskService.updateById(taskEntity); |
| | | return b; |
| | | } |
| | | return b; |
| | | } |
| | | |
| | | /** |
| | | * 居住证申请 删除 |
| | | * @param toLongList |
| | | * @return |
| | | */ |
| | | @Override |
| | | public boolean removeTaskResidencePermitApplyBatchByIds(List<Long> toLongList) { |
| | | boolean flag = false; |
| | | for (Long id : toLongList) { |
| | | // 先查询对应的任务id |
| | | TaskResidencePermitApplyEntity taskResidencePermitApplyEntity = getById(id); |
| | | // 删除居住证 |
| | | flag = removeById(id); |
| | | if (flag) { |
| | | // 删除对应的任务 |
| | | flag = taskService.removeById(taskResidencePermitApplyEntity.getTaskId()); |
| | | } |
| | | } |
| | | // 返回 |
| | | return flag; |
| | | } |
| | | } |