From 8b7258c9427882bb1798f1502eaa35184c6e374e Mon Sep 17 00:00:00 2001
From: linwe <872216996@qq.com>
Date: Fri, 09 Aug 2024 14:29:18 +0800
Subject: [PATCH] 短信指定楼栋发送
---
src/main/java/org/springblade/modules/task/service/impl/TaskServiceImpl.java | 418 ++++++++++++++++++++++++++++++++++++++++++++++-------------
1 files changed, 326 insertions(+), 92 deletions(-)
diff --git a/src/main/java/org/springblade/modules/task/service/impl/TaskServiceImpl.java b/src/main/java/org/springblade/modules/task/service/impl/TaskServiceImpl.java
index 4e8a432..3885146 100644
--- a/src/main/java/org/springblade/modules/task/service/impl/TaskServiceImpl.java
+++ b/src/main/java/org/springblade/modules/task/service/impl/TaskServiceImpl.java
@@ -17,40 +17,52 @@
package org.springblade.modules.task.service.impl;
import com.alibaba.fastjson.JSON;
-import com.alibaba.fastjson.JSONObject;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
+import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
-import liquibase.pro.packaged.W;
+import com.itextpdf.text.log.Logger;
+import com.itextpdf.text.log.LoggerFactory;
+import com.xxl.job.core.enums.taskHandlerEnum;
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.SpringUtils;
import org.springblade.core.secure.utils.AuthUtil;
import org.springblade.modules.category.entity.CategoryEntity;
import org.springblade.modules.category.service.ICategoryService;
+import org.springblade.modules.threeColorTask.entity.CustomTaskEntity;
+import org.springblade.modules.grid.entity.GridEntity;
import org.springblade.modules.grid.entity.GridWorkLogEntity;
-import org.springblade.modules.grid.entity.GridmanEntity;
+import org.springblade.modules.grid.service.IGridService;
import org.springblade.modules.grid.service.IGridWorkLogService;
-import org.springblade.modules.grid.service.IGridmanService;
import org.springblade.modules.house.service.IHouseRentalService;
import org.springblade.modules.house.service.IHouseholdService;
import org.springblade.modules.house.vo.HouseRentalTenantVO;
import org.springblade.modules.house.vo.HouseholdVO;
import org.springblade.modules.place.service.IPlaceExtService;
+import org.springblade.modules.place.service.IPlacePractitionerService;
import org.springblade.modules.place.service.IPlaceService;
+import org.springblade.modules.place.vo.PlacePractitionerVO;
import org.springblade.modules.place.vo.PlaceVO;
-import org.springblade.modules.system.entity.Dept;
-import org.springblade.modules.system.service.IDeptService;
+import org.springblade.modules.sms.service.ISmsSendService;
import org.springblade.modules.task.entity.*;
import org.springblade.modules.task.mapper.TaskMapper;
import org.springblade.modules.task.service.*;
+import org.springblade.modules.task.vo.TaskNoFraudReportingVO;
+import org.springblade.modules.task.vo.TaskSchoolEvenVO;
import org.springblade.modules.task.vo.TaskVO;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
+import java.time.LocalDate;
+import java.time.LocalDateTime;
+import java.time.LocalTime;
+import java.time.temporal.ChronoUnit;
import java.util.*;
import java.util.stream.Collectors;
@@ -63,17 +75,16 @@
@Service
public class TaskServiceImpl extends ServiceImpl<TaskMapper, TaskEntity> implements ITaskService {
- @Autowired
- private IPlaceService placeService;
+ private Logger logger = LoggerFactory.getLogger(TaskServiceImpl.class);
+
+ @Autowired
+ private IPlaceService placeService;
@Autowired
private IHouseholdService iHouseholdService;
@Autowired
private IHouseRentalService iHouseRentalService;
-
- @Autowired
- private IDeptService deptService;
@Autowired
private ICategoryService categoryService;
@@ -90,40 +101,37 @@
@Autowired
private IGridWorkLogService gridWorkLogService;
+ @Autowired
+ private ITaskResidencePermitApplyService residencePermitApplyService;
+
+ @Autowired
+ private ISmsSendService smsSendService;
+
+ // 确保该常量值正确地从配置文件中读取或以更合适的方式定义
+ private static final long SMS_TEMPLATE_ID = 1775429789463142401L;
+
@Override
public IPage<TaskVO> selectTaskPage(IPage<TaskVO> page, TaskVO task) {
- Dept dept = deptService.getById(AuthUtil.getDeptId());
- if (null != dept) {
- task.setCommunityCode(dept.getRegionCode());
+ CommonParamSet commonParamSet = new CommonParamSet().invoke(TaskVO.class, task);
+ if (null != task.getReportType() && task.getReportType() == 1) {
+ // 查询取保候审任务列表(人房相关)
+ return page.setRecords(baseMapper.selectTaskPageByPerson(page, task, commonParamSet.getRegionChildCodesList(),
+ commonParamSet.getIsAdministrator(), commonParamSet.getGridCodeList()));
}
- // 民警角色
- if (AuthUtil.getUserRole().equals("mj")) {
- task.setUserId(AuthUtil.getUserId());
- return page.setRecords(baseMapper.selectTaskPageBy(page, task));
- } else {
- if (AuthUtil.getUserAccount().equals("18879306957")) {
- task.setCommunityCode("361102003027");
- task.setUserId(null);
- }
- if (AuthUtil.getUserRole().equals("wgy")) {
- task.setUserId(AuthUtil.getUserId());
- }
- // 非民警角色
- List<TaskVO> taskVOS = baseMapper.selectTaskPage(page, task);
- return page.setRecords(taskVOS);
- }
+ // 查询非取保候审任务列表(场所相关)
+ return page.setRecords(baseMapper.selectTaskPage(page, task, commonParamSet.getRegionChildCodesList(),
+ commonParamSet.getIsAdministrator(), commonParamSet.getGridCodeList()));
}
@Override
public IPage<TaskVO> getBailReportingPage(IPage<TaskVO> page, TaskVO task) {
- Dept dept = deptService.getById(AuthUtil.getDeptId());
- if (null != dept) {
- task.setCommunityCode(dept.getRegionCode());
- }
+ CommonParamSet commonParamSet = new CommonParamSet().invoke(TaskVO.class, task);
// 民警角色
if (AuthUtil.getUserRole().equals("mj")) {
task.setUserId(AuthUtil.getUserId());
- return page.setRecords(baseMapper.selectTaskPageBy(page, task));
+ return page.setRecords(baseMapper.selectTaskPageBy(page, task,
+ commonParamSet.getRegionChildCodesList(),
+ commonParamSet.getIsAdministrator()));
} else {
if (AuthUtil.getUserAccount().equals("18879306957")) {
task.setCommunityCode("361102003027");
@@ -133,7 +141,12 @@
task.setUserId(AuthUtil.getUserId());
}
// 非民警角色
- List<TaskVO> taskVOS = baseMapper.getBailReportingPage(page, task);
+ List<TaskVO> taskVOS = baseMapper.getBailReportingPage(page,
+ task,
+ commonParamSet.getRegionChildCodesList(),
+ commonParamSet.getGridCodeList(),
+ commonParamSet.getIsAdministrator());
+ // 返回
return page.setRecords(taskVOS);
}
}
@@ -149,7 +162,8 @@
* @return
*/
@Override
- public Long saveTask(Integer type, String name, Integer frequency, String remark, Long createUser, String houseCode, Integer reportType) {
+ public Long saveTask(Integer type, String name, Integer frequency, String remark, Long createUser,
+ String houseCode, Integer reportType, Integer status) {
TaskEntity taskEntity = new TaskEntity();
taskEntity.setType(type);
taskEntity.setName(name);
@@ -159,6 +173,7 @@
taskEntity.setCreateUser(createUser);
taskEntity.setHouseCode(houseCode);
taskEntity.setReportType(reportType);
+ taskEntity.setStatus(status);
return baseMapper.insert(taskEntity) > 0 ? taskEntity.getId() : 0;
}
@@ -202,52 +217,99 @@
public Object countTypeNumber(Integer roleType, String neiCode) {
TaskVO taskVO = new TaskVO();
Map<String, Object> objectObjectHashMap = new HashMap<>();
- taskVO.setStatus(1);
- taskVO.setUserId(roleType > 0 ? AuthUtil.getUserId() : null);
+ taskVO.setStatus(CommonConstant.NUMBER_ONE);
+ taskVO.setUserId(roleType > CommonConstant.NUMBER_ZERO ? AuthUtil.getUserId() : null);
taskVO.setNeiCode(neiCode);
- taskVO.setReportType(2);
- taskVO.setIsDeleted(0);
- // 查询网格员对应的网格id
- Integer gridId = getGridId();
- // 标签事件
- Integer bqsj = baseMapper.selectTaskCount(taskVO);
- taskVO.setReportType(1);
+ taskVO.setReportType(CommonConstant.NUMBER_FIVE);
+ taskVO.setIsDeleted(CommonConstant.NUMBER_ZERO);
+ CommonParamSet commonParamSet = new CommonParamSet().invoke(TaskVO.class, taskVO);
+
+ // 标签报事-二手交易
+ Integer bqsj = baseMapper.selectTaskCount(taskVO, commonParamSet.getRegionChildCodesList(),
+ commonParamSet.getIsAdministrator(), commonParamSet.getGridCodeList());
+ taskVO.setReportType(CommonConstant.NUMBER_ONE);
// 取保候审
- Integer qbhs = baseMapper.selectTaskCount(taskVO);
+ Integer qbhs = baseMapper.selectTaskPageByPersonCount(taskVO, commonParamSet.getRegionChildCodesList(),
+ commonParamSet.getIsAdministrator(), commonParamSet.getGridCodeList());
// 报事报修
- Integer bsbx = SpringUtils.getBean(ITaskReportForRepairsService.class).getStatistics(roleType > 0 ? AuthUtil.getUserId() : null, neiCode);
- // 住房审核
- Integer zhsh = iHouseholdService.statistics(roleType > 0 ? AuthUtil.getUserId() : null, neiCode);
+ Integer bsbx = SpringUtils.getBean(ITaskReportForRepairsService.class).getStatistics(roleType > 0 ? AuthUtil.getUserId() : null, neiCode, commonParamSet.getRegionChildCodesList(),
+ commonParamSet.getIsAdministrator(), commonParamSet.getGridCodeList());
+ // 住户审核
+ Integer zhsh = iHouseholdService.statistics(roleType > 0 ? AuthUtil.getUserId() : null, neiCode, 0);
// 出租审核
HouseRentalTenantVO houseRentalTenantVO = new HouseRentalTenantVO();
- houseRentalTenantVO.setUserId(roleType > 0 ? AuthUtil.getUserId() : null);
- houseRentalTenantVO.setNeiCode(neiCode);
+ houseRentalTenantVO.setCommunityCode(neiCode);
+ houseRentalTenantVO.setAuditStatus(2);
Integer czsh = iHouseRentalService.getStatisticsCount(houseRentalTenantVO);
// 场所审核
- Integer cssh = SpringUtils.getBean(IPlaceExtService.class).selectCount(roleType > 0 ? AuthUtil.getUserId() : null, neiCode, 1);
+ Integer cssh = SpringUtils.getBean(IPlaceExtService.class).selectCount(roleType > 0 ? AuthUtil.getUserId() : null, neiCode, CommonConstant.NUMBER_ONE);
// 走访日志
- Integer zfrw = SpringUtils.getBean(IGridWorkLogService.class).getGridWorkCountHandleCount(gridId,1);
+ // 查询网格员对应的网格id
+ String gridCode = getGridCode();
+ Integer zfrw = SpringUtils.getBean(IGridWorkLogService.class).getGridWorkCountHandleCount(gridCode, CommonConstant.NUMBER_ONE);
+ // 消防自查
+ Integer xfzc = SpringUtils.getBean(ITaskPlaceSelfCheckService.class).getCount(neiCode, CommonConstant.NUMBER_ONE, CommonConstant.NUMBER_ONE);
+ // 校园安全隐患排除
+ // Integer xyaqyhpc = SpringUtils.getBean(ITaskPlaceSelfCheckService.class).getCount(neiCode, CommonConstant.NUMBER_ONE, CommonConstant.NUMBER_TWO);
+ // 消防隐患整改
+ Integer xfyhzg = SpringUtils.getBean(ITaskPlaceRectificationService.class).getCount(neiCode, CommonConstant.NUMBER_ONE);
+ // 居住证申请
+ Integer jzzsq = residencePermitApplyService.getCount(neiCode, CommonConstant.NUMBER_ONE);
+ // 无诈统计
+ ITaskNoFraudReportingService noFraudReportingService = SpringUtils.getBean(ITaskNoFraudReportingService.class);
+ TaskNoFraudReportingVO taskNoFraudReportingVO = new TaskNoFraudReportingVO();
+ taskNoFraudReportingVO.setStatus(1);
+ Integer wztj = noFraudReportingService.selectTaskNoFraudReportingCount(taskNoFraudReportingVO);
+
+ ITaskSchoolEvenService taskSchoolEvenService = SpringUtils.getBean(ITaskSchoolEvenService.class);
+ TaskSchoolEvenVO taskSchoolEvenVO = new TaskSchoolEvenVO();
+ taskSchoolEvenVO.setConfirmFlag(CommonConstant.NUMBER_ONE.toString());
+ taskSchoolEvenVO.setType(CommonConstant.NUMBER_ONE.toString());
+ // 校园隐患
+ long xyyh = taskSchoolEvenService.schoolEvenCount(taskSchoolEvenVO);
+ // 校园纠纷矛盾
+ taskSchoolEvenVO.setType(CommonConstant.NUMBER_TWO.toString());
+ long xyjfmd = taskSchoolEvenService.schoolEvenCount(taskSchoolEvenVO);
+ ;
+
+ taskVO.setReportType(CommonConstant.NUMBER_FOUR);
+ // 校园安全检查
+ Integer xyaqjc = baseMapper.selectTaskCount(taskVO, commonParamSet.getRegionChildCodesList(),
+ commonParamSet.getIsAdministrator(), commonParamSet.getGridCodeList());
+ PlacePractitionerVO placePractitionerVO = new PlacePractitionerVO();
+ placePractitionerVO.setConfirmFlag(CommonConstant.NUMBER_ONE);
+ // 从业人员审核
+ Integer cyrysh = SpringUtils.getBean(IPlacePractitionerService.class).selectPlacePractitionerCount(placePractitionerVO);
+
// 设置
- objectObjectHashMap.put("qbhs", qbhs);
- objectObjectHashMap.put("bqsj", bqsj);
- objectObjectHashMap.put("bsbx", bsbx);
- objectObjectHashMap.put("zhsh", zhsh);
- objectObjectHashMap.put("czsh", czsh);
- objectObjectHashMap.put("cssh", cssh);
- objectObjectHashMap.put("zfrw", zfrw);
+ objectObjectHashMap.put("qbhs", qbhs);// 取保候审
+ objectObjectHashMap.put("bqsj", bqsj);// 标签报事-二手交易
+ objectObjectHashMap.put("bsbx", bsbx);// 报事报修
+ objectObjectHashMap.put("zhsh", zhsh);// 住户审核
+ objectObjectHashMap.put("czsh", czsh);// 出租审核
+ objectObjectHashMap.put("cssh", cssh);// 场所审核
+ objectObjectHashMap.put("zfrw", zfrw);// 走访日志
+ objectObjectHashMap.put("xfzc", xfzc);// 消防自查
+ objectObjectHashMap.put("xfyhzg", xfyhzg);// 消防隐患整改
+ objectObjectHashMap.put("jzzsq", jzzsq);// 居住证申请
+ objectObjectHashMap.put("wztj", wztj);// 无诈
+ // objectObjectHashMap.put("xyaqyhpc", xyaqyhpc);// 校园安全隐患排除
+ objectObjectHashMap.put("xyyh", xyyh);// 校园隐患
+ objectObjectHashMap.put("xyjfmd", xyjfmd);// 校园纠纷矛盾
+ objectObjectHashMap.put("xyaqjc", xyaqjc);// 校园安全检查
+ objectObjectHashMap.put("cyrysh", cyrysh);// 从业人员审核
return objectObjectHashMap;
}
/**
* 获取网格员id
+ *
* @return
*/
- private Integer getGridId() {
- QueryWrapper<GridmanEntity> wrapper = new QueryWrapper<>();
- wrapper.eq("is_deleted",0).eq("user_id",AuthUtil.getUserId());
- List<GridmanEntity> list = SpringUtils.getBean(IGridmanService.class).list(wrapper);
- if (list.size()>0){
- return list.get(0).getGridId();
+ private String getGridCode() {
+ GridEntity grid = SpringUtils.getBean(IGridService.class).getGridByUserId(AuthUtil.getUserId());
+ if (null != grid) {
+ return grid.getGridCode();
}
return null;
}
@@ -259,9 +321,9 @@
taskVO.setUserId(AuthUtil.getUserId());
taskVO.setFrequency(1);
taskVO.setStatus(1);
- Integer disposable = baseMapper.selectTaskCount(taskVO);
+ Integer disposable = baseMapper.selectTaskCount(taskVO, null, null, null);
taskVO.setFrequency(2);
- Integer periodicity = baseMapper.selectTaskCount(taskVO);
+ Integer periodicity = baseMapper.selectTaskCount(taskVO, null, null, null);
objectObjectHashMap.put("disposable", disposable);
objectObjectHashMap.put("periodicity", periodicity);
return objectObjectHashMap;
@@ -318,6 +380,7 @@
/**
* 根据类型创建任务
+ *
* @param param 参数
* @return
*/
@@ -325,19 +388,22 @@
@Transactional(rollbackFor = Exception.class)
public boolean createTaskJob(String param) {
// 解析参数
- JSONObject jsonParam = JSON.parseObject(param);
+ CustomTaskEntity customTaskEntity = JSON.parseObject(param, CustomTaskEntity.class);
+ // CustomTaskEntity customTaskEntity = new CustomTaskEntity();
// String params = jsonParam.getString("params");
- boolean flag = false;
+// boolean flag = false;
// 校园安全自查任务生成
- createCampusReportingTask();
+// createCampusReportingTask();
// 打金店/二手车/二手手机任务生成
- createLabelReportingTask();
+// createLabelReportingTask();
// 旅馆安全自查任务生成
- createHotelReportingTask();
+// createHotelReportingTask();
// 人员类-肇事肇祸精神障碍患者走访任务生成
- createGridWordTask();
+ // createGridWordTask();
// 返回
- return flag;
+ TaskHandle handler = (TaskHandle) SpringUtils.getBean(Objects.requireNonNull(taskHandlerEnum.getNameByCode(customTaskEntity.getTaskType())));
+ handler.taskHandle(customTaskEntity);
+ return true;
}
@@ -346,7 +412,7 @@
*/
public void createGridWordTask() {
// 肇事肇祸精神障碍患者走访任务生成,查询标签为:1006
- List<Integer> list = new ArrayList<Integer>(){{
+ List<Integer> list = new ArrayList<Integer>() {{
add(1006);
}};
// 根据人员标签编号集合查询对应的住户(按颜色区分近多少天没有发过任务的住户)
@@ -360,6 +426,7 @@
/**
* 新增走访任务
+ *
* @param household
*/
public void saveGridWordTask(HouseholdVO household) {
@@ -380,34 +447,34 @@
*/
public void createLabelReportingTask() {
// 打金店/二手车/二手手机任务生成,标签:130808/140304/130604
- List<String> stringList = new ArrayList<String>(){{
+ List<String> stringList = new ArrayList<String>() {{
add("130808");
add("140304");
add("130604");
}};
String tableName = "jczz_task_label_reporting_event";
// 根据编号集合查询对应的场所(按颜色区分近多少天没有发过任务的场所)
- List<PlaceVO> placeVOList = placeService.getPlaceListByParam(stringList,tableName);
+ List<PlaceVO> placeVOList = placeService.getPlaceListByParam(stringList, tableName);
// 生成任务
for (PlaceVO placeVO : placeVOList) {
String taskName = "";
Integer reportType = 3;
- if (placeVO.getLabel().equals("130808")){
- taskName = DictConstant.DA_JIN_DIAN;
+ if (placeVO.getLabel().equals("130808")) {
+ taskName = DictConstant.SECOND_HAND_TRANSACTION;
reportType = 3;
}
- if (placeVO.getLabel().equals("130604")){
+ if (placeVO.getLabel().equals("130604")) {
taskName = DictConstant.USED_MOBILE_PHONES;
reportType = 4;
}
- if (placeVO.getLabel().equals("140304")){
+ if (placeVO.getLabel().equals("140304")) {
taskName = DictConstant.USED_CAR;
reportType = 5;
}
// 新增任务
TaskEntity taskEntity = saveTaskEntity(placeVO.getHouseCode(), 1, taskName, 2, reportType);
// 同时新增打金店/二手车/二手手机任务
- saveGoldShop(placeVO, taskEntity,taskName,reportType);
+ saveGoldShop(placeVO, taskEntity, taskName, reportType);
}
}
@@ -416,7 +483,7 @@
*/
public void createHotelReportingTask() {
// 旅馆标签为
- List<String> stringList = new ArrayList<String>(){{
+ List<String> stringList = new ArrayList<String>() {{
add("120101");
add("120102");
add("120103");
@@ -424,7 +491,7 @@
}};
String tableName = "jczz_task_hotel_reporting";
// 根据编号集合查询对应的场所(按颜色区分近多少天没有发过任务的场所)
- List<PlaceVO> placeVOList = placeService.getPlaceListByParam(stringList,tableName);
+ List<PlaceVO> placeVOList = placeService.getPlaceListByParam(stringList, tableName);
// 生成任务
for (PlaceVO placeVO : placeVOList) {
// 新增任务
@@ -441,13 +508,13 @@
// 校园安全自查,查询标签为教育的场所 parentNo = 1601
String parentNo = "1601";
QueryWrapper<CategoryEntity> wrapper = new QueryWrapper<>();
- wrapper.eq("is_deleted",0).eq("parent_no",parentNo);
+ wrapper.eq("is_deleted", 0).eq("parent_no", parentNo);
List<CategoryEntity> categoryEntityList = categoryService.list(wrapper);
// 取出编号集合
List<String> stringList = categoryEntityList.stream().map(categoryEntity -> categoryEntity.getCategoryNo()).collect(Collectors.toList());
// 根据编号集合查询对应的场所(按颜色区分近多少天没有发过任务的场所)
String tableName = "jczz_task_campus_reporting_event";
- List<PlaceVO> placeVOList = placeService.getPlaceListByParam(stringList,tableName);
+ List<PlaceVO> placeVOList = placeService.getPlaceListByParam(stringList, tableName);
// 生成任务
for (PlaceVO placeVO : placeVOList) {
// 新增任务
@@ -459,6 +526,7 @@
/**
* 新增校园安全检查任务
+ *
* @param placeVO
* @param taskEntity
*/
@@ -480,6 +548,7 @@
/**
* 新增旅馆安全检查任务
+ *
* @param placeVO
* @param taskEntity
*/
@@ -502,12 +571,13 @@
/**
* 新增打金店/二手车/二手手机任务
+ *
* @param placeVO
* @param taskEntity
* @param taskName
* @param reportType
*/
- private void saveGoldShop(PlaceVO placeVO, TaskEntity taskEntity,String taskName,Integer reportType) {
+ private void saveGoldShop(PlaceVO placeVO, TaskEntity taskEntity, String taskName, Integer reportType) {
TaskLabelReportingEventEntity taskLabelReportingEventEntity = new TaskLabelReportingEventEntity();
taskLabelReportingEventEntity.setTaskId(taskEntity.getId());
taskLabelReportingEventEntity.setPlaceId(placeVO.getId());
@@ -517,15 +587,15 @@
taskLabelReportingEventEntity.setPhoneNumber(placeVO.getPrincipalPhone());
taskLabelReportingEventEntity.setLabelName(taskName);
// 打金店
- if (reportType==3){
+ if (reportType == 3) {
taskLabelReportingEventEntity.setEventType("1");
}
// 二手车
- if (reportType==4){
+ if (reportType == 4) {
taskLabelReportingEventEntity.setEventType("3");
}
// 二手手机
- if (reportType==5){
+ if (reportType == 5) {
taskLabelReportingEventEntity.setEventType("2");
}
// 系统下发
@@ -538,6 +608,7 @@
/**
* 插入任务信息
+ *
* @param houseCode
* @param type
* @param taskName
@@ -566,4 +637,167 @@
// 返回
return taskEntity;
}
+
+ /**
+ * 审核任务。
+ * 根据任务的报告类型,更新相应的任务状态,并触发相应的事件更新。
+ *
+ * @param task 任务实体,包含任务信息和报告类型。
+ * @return 返回审核结果,成功为true,失败为false。
+ */
+ @Override
+ public Boolean examine(TaskEntity task) {
+ if (task == null || task.getReportType() == null) {
+ // 检查任务和报告类型是否为空,若为空则直接返回false
+ return false;
+ }
+ // 根据任务报告类型,更新任务状态并触发相应的事件更新
+ boolean result = updateById(task);
+ if (!result) {
+ return false;
+ }
+ if (task.getReportType().equals(CommonConstant.REPORT_TYPE_SECONDHAND_TRADE)) {
+ // 如果报告类型匹配,尝试更新任务标签报告事件状态
+ ITaskLabelReportingEventService bean = SpringUtils.getBean(ITaskLabelReportingEventService.class);
+ return bean.update(Wrappers.<TaskLabelReportingEventEntity>lambdaUpdate()
+ .set(TaskLabelReportingEventEntity::getConfirmFlag, task.getStatus())
+ .eq(TaskLabelReportingEventEntity::getTaskId, task.getId()));
+ } else if (task.getReportType().
+ equals(CommonConstant.REPORT_TYPE_FIRE_INSPECTION)) {
+ // 如果报告类型为消防自查,尝试更新消防自查状态
+ ITaskPlaceSelfCheckService bean = SpringUtils.getBean(ITaskPlaceSelfCheckService.class);
+ return bean.update(Wrappers.<TaskPlaceSelfCheckEntity>lambdaUpdate()
+ .set(TaskPlaceSelfCheckEntity::getStatus, task.getStatus())
+ .eq(TaskPlaceSelfCheckEntity::getTaskId, task.getId()));
+
+ } else if (task.getReportType().equals(CommonConstant.REPORT_TYPE_NO_FRAUD)) {
+ // 如果报告类型为无诈,尝试更新无诈报告状态
+ ITaskNoFraudReportingService noFraudReportingService = SpringUtils.getBean(ITaskNoFraudReportingService.class);
+ LambdaUpdateWrapper<TaskNoFraudReportingEntity> objectLambdaUpdateWrapper = new LambdaUpdateWrapper<>();
+ if (StringUtils.isNotBlank(task.getHouseCode())) {
+ objectLambdaUpdateWrapper.set(TaskNoFraudReportingEntity::getHouseCode, task.getHouseCode());
+ }
+ objectLambdaUpdateWrapper.set(TaskNoFraudReportingEntity::getStatus, task.getStatus());
+ objectLambdaUpdateWrapper.set(TaskNoFraudReportingEntity::getRemark, task.getRemark());
+ objectLambdaUpdateWrapper.eq(TaskNoFraudReportingEntity::getTaskId, task.getId());
+ return noFraudReportingService.update(objectLambdaUpdateWrapper);
+ }
+ // 如果没有匹配的报告类型,返回false
+ return false;
+ }
+
+ /**
+ * 创建居住证发送短信任务。
+ * 该方法首先计算六个月前的日期,然后查询在该日期之后申请的居住证任务实体列表,
+ * 并对这些实体发送短信通知。
+ *
+ * @param param 传递给发送短信任务的参数,具体用途根据实现而定。
+ * @return 返回一个布尔值,通常用于指示任务是否创建成功。
+ * 根据实际逻辑需要调整返回值,当前示例中返回值始终为false。
+ */
+ @Override
+ public boolean createResidenceSendSms(String param) {
+ try {
+ // 计算六个月前的日期
+ LocalDate sixMonthsAgo = getSixMonthsAgo();
+ // 查询需要发送短信的居住证申请实体列表
+ List<TaskResidencePermitApplyEntity> entitiesToSms = queryEntitiesToSms(sixMonthsAgo);
+ // 发送短信并更新相关实体状态
+ sendSmsAndUpdateEntities(entitiesToSms);
+ } catch (Exception e) {
+ // 处理发送短信过程中可能出现的异常,如记录日志
+ logger.error("Error occurred while sending SMS: " + e.getMessage(), e);
+ return false; // 根据异常处理逻辑决定是否返回false或其他值
+ }
+ return false; // 根据实际逻辑调整返回值
+ }
+
+ @Override
+ public boolean createSchoolSendSms(String param) {
+ try {
+ // 计算当前时间加一天
+ LocalDate endDate = LocalDate.now().plusDays(1);
+ // 创建表示一天结束时刻的 LocalTime 对象
+ LocalTime endOfDayTime = LocalTime.of(23, 59, 59, 999_000_000); // 纳秒精度为999毫微秒,接近最大值
+ // 合并得到加一天后的最后时刻的 LocalDateTime
+ LocalDateTime endTime = LocalDateTime.of(endDate, endOfDayTime);
+ ITaskPlaceSelfCheckService taskPlaceSelfCheckService = SpringUtils.getBean(ITaskPlaceSelfCheckService.class);
+ // 查询整改完毕且未发送短信的记录
+ List<TaskPlaceSelfCheckEntity> list = taskPlaceSelfCheckService.list(new LambdaQueryWrapper<TaskPlaceSelfCheckEntity>()
+ .eq(TaskPlaceSelfCheckEntity::getRectificationFlag, CommonConstant.NUMBER_TWO)
+ .eq(TaskPlaceSelfCheckEntity::getSendSmsFlag, CommonConstant.NUMBER_ONE)
+ .le(TaskPlaceSelfCheckEntity::getRectificationEndTime, endTime));
+ if (list == null || list.isEmpty()) {
+ return false;
+ }
+ // 用于收集成功发送短信并需更新状态的实体列表
+ List<TaskPlaceSelfCheckEntity> updatedEntities = new ArrayList<>();
+ for (TaskPlaceSelfCheckEntity updatedEntity : list) {
+ // 尝试发送短信,发送成功则更新实体状态
+ Boolean smsSent = smsSendService.sendNotice(SMS_TEMPLATE_ID, updatedEntity.getId());
+ if (smsSent) {
+ updatedEntity.setSendSmsFlag("2"); // 标记为已发送短信
+ updatedEntities.add(updatedEntity); // 加入到需更新的实体列表中
+ }
+ }
+ // 若存在需更新的实体,则批量更新这些实体的状态
+ if (!updatedEntities.isEmpty()) {
+ taskPlaceSelfCheckService.updateBatchById(updatedEntities);
+ }
+ } catch (Exception e) {
+ // 处理发送短信过程中可能出现的异常,如记录日志
+ logger.error("Error occurred while sending SMS: " + e.getMessage(), e);
+ return false; // 根据异常处理逻辑决定是否返回false或其他值
+ }
+ return false; // 根据实际逻辑调整返回值
+ }
+
+ /**
+ * 获取六个月前的日期。
+ * 该方法不接受任何参数,仅返回当前日期减去六个月的结果。
+ *
+ * @return 返回一个LocalDate对象,表示六个月前的日期。
+ */
+ private LocalDate getSixMonthsAgo() {
+ // 获取当前日期并减去6个月
+ return LocalDate.now().minus(6, ChronoUnit.MONTHS);
+ }
+
+ /**
+ * 查询需要发送短信的居住证申请实体列表。
+ *
+ * @param sixMonthsAgo 六个月前的日期,用于筛选确认时间在六个月之前的申请记录。
+ * @return 返回一个包含所有符合条件的居住证申请实体的列表。
+ */
+ private List<TaskResidencePermitApplyEntity> queryEntitiesToSms(LocalDate sixMonthsAgo) {
+ // 使用LambdaQueryWrapper构建查询条件,筛选出确认状态为2(即确认),且未发送过短信(发送短信标志为1),确认时间在指定日期(sixMonthsAgo)之前的所有申请记录。
+ return residencePermitApplyService.list(new LambdaQueryWrapper<TaskResidencePermitApplyEntity>()
+ .eq(TaskResidencePermitApplyEntity::getConfirmFlag, 2)
+ .eq(TaskResidencePermitApplyEntity::getSendSmsFlag, 1)
+ .le(TaskResidencePermitApplyEntity::getConfirmTime, sixMonthsAgo));
+ }
+
+ /**
+ * 发送短信并更新实体状态
+ *
+ * @param entitiesToSms 需要发送短信并更新状态的实体列表,每个实体代表一个居住证申请任务。
+ * 实体列表中每个元素应包含至少一个ID属性,用于标识申请任务。
+ */
+ private void sendSmsAndUpdateEntities(List<TaskResidencePermitApplyEntity> entitiesToSms) {
+ List<TaskResidencePermitApplyEntity> updatedEntities = new ArrayList<>(); // 用于收集成功发送短信并需更新状态的实体列表
+
+ for (TaskResidencePermitApplyEntity entity : entitiesToSms) {
+ // 尝试发送短信,发送成功则更新实体状态
+ Boolean smsSent = smsSendService.sendNotice(SMS_TEMPLATE_ID, entity.getId());
+ if (smsSent) {
+ entity.setSendSmsFlag(2); // 标记为已发送短信
+ updatedEntities.add(entity); // 加入到需更新的实体列表中
+ }
+ }
+
+ // 若存在需更新的实体,则批量更新这些实体的状态
+ if (!updatedEntities.isEmpty()) {
+ residencePermitApplyService.updateBatchById(updatedEntities);
+ }
+ }
}
--
Gitblit v1.9.3