增加点位打卡功能,以及关联功能

This commit is contained in:
2025-09-08 20:00:30 +08:00
parent 98eb02a007
commit d32e8436a5
50 changed files with 5281 additions and 185 deletions

View File

@ -2,6 +2,7 @@ package com.mosty.yjzl.controller;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.mosty.base.model.dto.yjzl.TbZdxlFgxlrwCreateDTO;
import com.mosty.base.model.dto.yjzl.TbZdxlFgxlrwIssueDTO;
import com.mosty.base.model.dto.yjzl.TbZdxlFgxlrwUpdateDTO;
import com.mosty.base.model.entity.yjzl.zddw.TbZdxlFgxlrw;
import com.mosty.base.model.query.yjzl.TbZdxlFgxlrwQuery;
@ -14,11 +15,14 @@ import com.mosty.common.base.entity.log.Log;
import com.mosty.common.base.util.StringUtils;
import com.mosty.common.config.Excel.ExcelUtil;
import com.mosty.common.token.JwtSysUser;
import com.mosty.yjzl.service.TbZdxlFgdwBddxlrwJlService;
import com.mosty.yjzl.service.TbZdxlFgxlrwService;
import com.mosty.yjzl.utils.TbZdxlFgxlrwUtils;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.AllArgsConstructor;
import org.apache.commons.collections4.CollectionUtils;
import org.apache.commons.lang3.ObjectUtils;
import org.springframework.validation.BindingResult;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;
@ -26,6 +30,7 @@ import org.springframework.web.multipart.MultipartFile;
import javax.servlet.http.HttpServletResponse;
import javax.validation.Valid;
import java.util.List;
import java.util.stream.Collectors;
/**
* @author zhangzhao
@ -45,6 +50,11 @@ public class TbZdxlFgxlrwController {
*/
private final TbZdxlFgxlrwService tbZdxlFgxlrwService;
/**
* 指导巡逻方格点位必到点巡逻任务记录表Service
*/
private final TbZdxlFgdwBddxlrwJlService tbZdxlFgdwBddxlrwJlService;
/**
* 查询分页
* @param query 实体查询对象
@ -58,6 +68,19 @@ public class TbZdxlFgxlrwController {
return ResponseResult.success(tbZdxlFgxlrwService.selectPage(query));
}
/**
* 查询分页(需要执行的任务)
* @param query 实体查询对象
* @return ResponseResult 实体返回信息分页列表
*/
@ApiOperation(value = "查询分页(需要执行的任务)")
@GetMapping("/selectRwPage")
@JwtSysUser
@Log(title = "指导巡逻-方格巡逻任务接口-查询分页(需要执行的任务)", businessType = BusinessType.OTHER)
public ResponseResult<IPage<TbZdxlFgxlrwVO>> selectRwPage(TbZdxlFgxlrwQuery query) {
return ResponseResult.success(tbZdxlFgxlrwService.selectRwPage(query));
}
/**
* 查询列表
* @param query 实体查询对象
@ -89,6 +112,14 @@ public class TbZdxlFgxlrwController {
return ResponseResult.fail(MessageUtils.getEditFailMsg() + message);
}
TbZdxlFgxlrw baseEntity = tbZdxlFgxlrwService.selectById(dto.getId());
if(ObjectUtils.isEmpty(baseEntity)){
return ResponseResult.fail(MessageUtils.getEditDataNotFoundMsg());
}
if(!(TbZdxlFgxlrwUtils.DICT_ITEM_D_ZDXL_FGXLRW_RWZT_CJ.equals(baseEntity.getRwZt()) || TbZdxlFgxlrwUtils.DICT_ITEM_D_ZDXL_FGXLRW_RWZT_YDC.equals(baseEntity.getRwZt()))){
return ResponseResult.fail(MessageUtils.getEditFailMsg() + "任务已下发,不能再进行修改");
}
//修改
String resultId = tbZdxlFgxlrwService.updateEntity(dto);
if(StringUtils.isNotBlank(resultId)){
@ -145,12 +176,13 @@ public class TbZdxlFgxlrwController {
public ResponseResult<Integer> importListByMb(MultipartFile file) {
try {
ExcelUtil<TbZdxlFgxlrw> util = new ExcelUtil<>(TbZdxlFgxlrw.class);
List<TbZdxlFgxlrw> fgxlrwList = util.importExcel(file.getInputStream());
List<TbZdxlFgxlrw> fgxlrwList = util.importExcel(file.getInputStream(), 1);
if(CollectionUtils.isEmpty(fgxlrwList)){
int resultInt = tbZdxlFgxlrwService.importListByMb(fgxlrwList);
if(resultInt > 0){
return ResponseResult.success(resultInt);
}
return ResponseResult.fail(MessageUtils.getImportFailMsg() + "表格数据获取为空");
}
int resultInt = tbZdxlFgxlrwService.importListByMb(fgxlrwList);
if(resultInt > 0){
return ResponseResult.success(resultInt);
}
return ResponseResult.fail(MessageUtils.getImportFailMsg());
} catch (Exception e) {
@ -158,4 +190,49 @@ public class TbZdxlFgxlrwController {
}
}
/**
* 下发任务
* @param dto 下发DTO对象
* @return ResponseResult 实体主键ID
*/
@ApiOperation(value = "下发任务")
@PostMapping("issueList")
@JwtSysUser
@Log(title = "指导巡逻-方格巡逻任务接口-下发任务", businessType = BusinessType.UPDATE)
public ResponseResult<Integer> issueList(@RequestBody TbZdxlFgxlrwIssueDTO dto){
try {
//基础信息校验
if(ObjectUtils.isEmpty(dto) || StringUtils.isBlank(dto.getIds())){
return ResponseResult.fail(MessageUtils.getSaveFailMsg() + "请选择需要下发的任务");
}
List<TbZdxlFgxlrw> entityList = tbZdxlFgxlrwService.selectListByIds(dto.getIds());
if(CollectionUtils.isEmpty(entityList)){
return ResponseResult.fail(MessageUtils.getSaveFailMsg() + "您选择的任务不存在,请刷新页面后重新下发");
}
List<TbZdxlFgxlrw> issueList = entityList.stream()
.filter(entity -> TbZdxlFgxlrwUtils.DICT_ITEM_D_ZDXL_FGXLRW_RWZT_CJ.equals(entity.getRwZt()) || TbZdxlFgxlrwUtils.DICT_ITEM_D_ZDXL_FGXLRW_RWZT_YDC.equals(entity.getRwZt()))
.collect(Collectors.toList());
if(CollectionUtils.isEmpty(issueList)){
return ResponseResult.fail(MessageUtils.getSaveFailMsg() + "您选择的任务都已下发,请选择其他任务");
}
//下发
int resultInt = tbZdxlFgxlrwService.issueList(issueList);
if(resultInt > 0){
//新建打卡记录
for(TbZdxlFgxlrw entity : issueList){
tbZdxlFgdwBddxlrwJlService.createListByFgxlrwId(entity.getId());
}
//返回
return ResponseResult.success(resultInt);
}
return ResponseResult.fail(MessageUtils.getSaveFailMsg());
} catch (Exception e) {
e.printStackTrace();
return ResponseResult.fail(MessageUtils.getSaveServerErrorMsg());
}
}
}