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

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

@ -0,0 +1,236 @@
package com.mosty.yjzl.controller;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.mosty.base.model.dto.yjzl.TbZdxlFgdwBddSaveDTO;
import com.mosty.base.model.dto.yjzl.TbZdxlFgdwBddUpdateDTO;
import com.mosty.base.model.entity.yjzl.zddw.TbZdxlFgdwBdd;
import com.mosty.base.model.query.yjzl.TbZdxlFgdwBddQuery;
import com.mosty.base.model.vo.yjzl.TbZdxlFgdwBddVO;
import com.mosty.base.model.vo.yjzl.TbZdxlFgdwVO;
import com.mosty.base.utils.Kit;
import com.mosty.base.utils.MessageUtils;
import com.mosty.base.utils.spring.SpringValidUtils;
import com.mosty.common.base.domain.ResponseResult;
import com.mosty.common.base.entity.log.BusinessType;
import com.mosty.common.base.entity.log.Log;
import com.mosty.common.token.JwtSysUser;
import com.mosty.yjzl.service.TbZdxlFgdwBddService;
import com.mosty.yjzl.service.TbZdxlFgdwService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.AllArgsConstructor;
import org.apache.commons.lang3.ObjectUtils;
import org.apache.commons.lang3.StringUtils;
import org.locationtech.jts.geom.Coordinate;
import org.springframework.validation.BindingResult;
import org.springframework.web.bind.annotation.*;
import javax.validation.Valid;
import java.math.BigDecimal;
import java.util.List;
/**
* @author zhangzhao
* @description 指导巡逻方格点位必到点接口
* @modifier zhangzhao
* @modifiedTime 2025/09/06 12:00
* @since 2025/09/06 12:00
*/
@Api(tags = {"指导巡逻-方格点位必到点接口"})
@RestController
@AllArgsConstructor
@RequestMapping("/tbZdxlFgdwBdd")
public class TbZdxlFgdwBddController {
/**
* 指导巡逻方格点位必到点表Service
*/
private final TbZdxlFgdwBddService tbZdxlFgdwBddService;
/**
* 指导巡逻方格点位表Service
*/
private final TbZdxlFgdwService tbZdxlFgdwService;
/**
* 查询单条根据主键ID
* @param id 主键ID
* @return ResponseResult 实体信息
*/
@ApiOperation(value = "查询单条根据主键ID")
@GetMapping("{id}")
@JwtSysUser
@Log(title = "指导巡逻-方格点位必到点接口-查询单条根据主键ID", businessType = BusinessType.OTHER)
public ResponseResult<TbZdxlFgdwBdd> selectById(@PathVariable("id") String id) {
return ResponseResult.success(tbZdxlFgdwBddService.selectById(id));
}
/**
* 查询分页
* @param query 实体查询对象
* @return ResponseResult 实体信息分页列表
*/
@ApiOperation(value = "查询分页")
@GetMapping("/selectPage")
@JwtSysUser
@Log(title = "指导巡逻-方格点位必到点接口-查询分页", businessType = BusinessType.OTHER)
public ResponseResult<IPage<TbZdxlFgdwBddVO>> selectPage(TbZdxlFgdwBddQuery query) {
return ResponseResult.success(tbZdxlFgdwBddService.selectPage(query));
}
/**
* 查询列表
* @param query 实体查询对象
* @return ResponseResult 实体信息列表
*/
@ApiOperation(value = "查询列表")
@GetMapping("/selectList")
@JwtSysUser
@Log(title = "指导巡逻-方格点位必到点接口-查询列表", businessType = BusinessType.OTHER)
public ResponseResult<List<TbZdxlFgdwBddVO>> selectList(TbZdxlFgdwBddQuery query) {
return ResponseResult.success(tbZdxlFgdwBddService.selectList(query));
}
/**
* 保存单条
* @param dto 保存DTO对象
* @param bindResult 校验对象
* @return ResponseResult 实体主键ID
*/
@ApiOperation(value = "保存单条")
@PostMapping("save")
@JwtSysUser
@Log(title = "指导巡逻-方格点位必到点接口-保存单条", businessType = BusinessType.INSERT)
public ResponseResult<String> save(@RequestBody @Valid TbZdxlFgdwBddSaveDTO dto, BindingResult bindResult) {
try {
//基础信息校验
String message = SpringValidUtils.getErrorsMsg(bindResult);
if (StringUtils.isNotBlank(message)) {
return ResponseResult.fail(MessageUtils.getSaveFailMsg() + message);
}
//校验点位是否在方格内
TbZdxlFgdwVO fgdwVO = tbZdxlFgdwService.selectById(dto.getFgdwId());
if(ObjectUtils.isEmpty(fgdwVO)){
return ResponseResult.fail(MessageUtils.getSaveFailMsg() + "方格信息不存在,请退出页面后重新选择");
}
if(ObjectUtils.isEmpty(fgdwVO.getX1()) || ObjectUtils.isEmpty(fgdwVO.getY1()) || ObjectUtils.isEmpty(fgdwVO.getX2()) || ObjectUtils.isEmpty(fgdwVO.getY2())){
return ResponseResult.fail(MessageUtils.getSaveFailMsg() + "方格信息不准确,请选择其他方格");
}
boolean isInGeometry = this.isInGeometry(fgdwVO, dto.getJd(), dto.getWd());
if(!isInGeometry){
return ResponseResult.fail(MessageUtils.getSaveFailMsg() + "点位不在方格内,请重新选点");
}
//保存
String resultId = tbZdxlFgdwBddService.saveEntity(dto);
if(StringUtils.isNotBlank(resultId)){
return ResponseResult.success(resultId);
}
return ResponseResult.fail(MessageUtils.getSaveFailMsg());
} catch (Exception e) {
return ResponseResult.fail(MessageUtils.getSaveServerErrorMsg());
}
}
/**
* 修改单条
* @param dto 修改DTO对象
* @param bindResult 校验对象
* @return ResponseResult 实体主键ID
*/
@ApiOperation(value = "修改单条")
@PostMapping("update")
@JwtSysUser
@Log(title = "指导巡逻-方格点位必到点接口-修改单条", businessType = BusinessType.UPDATE)
public ResponseResult<String> update(@RequestBody @Valid TbZdxlFgdwBddUpdateDTO dto, BindingResult bindResult){
try {
//基础信息校验
String message = SpringValidUtils.getErrorsMsg(bindResult);
if (StringUtils.isNotBlank(message)) {
return ResponseResult.fail(MessageUtils.getEditFailMsg() + message);
}
//校验数据是否存在
TbZdxlFgdwBdd baseEntity = tbZdxlFgdwBddService.selectById(dto.getId());
if(ObjectUtils.isEmpty(baseEntity)){
return ResponseResult.fail(MessageUtils.getEditDataNotFoundMsg());
}
//校验点位是否在方格内
TbZdxlFgdwVO fgdwVO = tbZdxlFgdwService.selectById(dto.getFgdwId());
if(ObjectUtils.isEmpty(fgdwVO)){
return ResponseResult.fail(MessageUtils.getEditFailMsg() + "方格信息不存在,请退出页面后重新选择");
}
if(ObjectUtils.isEmpty(fgdwVO.getX1()) || ObjectUtils.isEmpty(fgdwVO.getY1()) || ObjectUtils.isEmpty(fgdwVO.getX2()) || ObjectUtils.isEmpty(fgdwVO.getY2())){
return ResponseResult.fail(MessageUtils.getEditFailMsg() + "方格信息不准确,请选择其他方格");
}
boolean isInGeometry = this.isInGeometry(fgdwVO, dto.getJd(), dto.getWd());
if(!isInGeometry){
return ResponseResult.fail(MessageUtils.getEditFailMsg() + "点位不在方格内,请重新选点");
}
//修改
String resultId = tbZdxlFgdwBddService.updateEntity(dto);
if(StringUtils.isNotBlank(resultId)){
return ResponseResult.success(resultId);
}
return ResponseResult.fail(MessageUtils.getEditFailMsg());
} catch (Exception e) {
e.printStackTrace();
return ResponseResult.fail(MessageUtils.getEditServerErrorMsg());
}
}
/**
* 注销单条
* @param id 主键ID
* @return ResponseResult 注销条数
*/
@ApiOperation(value = "注销单条")
@DeleteMapping("{id}")
@JwtSysUser
@Log(title = "指导巡逻-方格点位必到点接口-注销单条", businessType = BusinessType.DELETE)
public ResponseResult<Integer> cancelById(@PathVariable("id") String id) {
try {
//如果传入的ID为空返回失败
if(StringUtils.isBlank(id)){
return ResponseResult.fail(MessageUtils.getCancelFailMsg() + MessageUtils.message("id.bnwk"));
}
//如果该实体已经被注销,则返回成功
TbZdxlFgdwBdd entity = tbZdxlFgdwBddService.selectById(id);
if(entity == null){
return ResponseResult.success(0);
}
return ResponseResult.success(tbZdxlFgdwBddService.cancelEntity(entity));
} catch (Exception e) {
return ResponseResult.fail(MessageUtils.getCancelServerErrorMsg());
}
}
/**
* 校验点位是否在方格中
* @param fgdwVO 方格信息
* @param jd 经度
* @param wd 纬度
* @return 是否在方格中
*/
private boolean isInGeometry(TbZdxlFgdwVO fgdwVO, BigDecimal jd, BigDecimal wd){
if(ObjectUtils.isEmpty(fgdwVO) || ObjectUtils.isEmpty(jd) || ObjectUtils.isEmpty(wd)){
return false;
}
Coordinate leftTop = new Coordinate(fgdwVO.getX1().doubleValue(), fgdwVO.getY2().doubleValue());
Coordinate rightTop = new Coordinate(fgdwVO.getX2().doubleValue(), fgdwVO.getY2().doubleValue());
Coordinate leftBottom = new Coordinate(fgdwVO.getX1().doubleValue(), fgdwVO.getY1().doubleValue());
Coordinate rightBottom = new Coordinate(fgdwVO.getX2().doubleValue(), fgdwVO.getY1().doubleValue());
Coordinate[] coordinates = new Coordinate[4];
coordinates[0] = leftTop;
coordinates[1] = rightTop;
coordinates[2] = rightBottom;
coordinates[3] = leftBottom;
return Kit.isInGeometryByRay(coordinates, jd + "," + wd);
}
}

View File

@ -0,0 +1,26 @@
package com.mosty.yjzl.controller;
import io.swagger.annotations.Api;
import lombok.AllArgsConstructor;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
/**
* @author zhangzhao
* @description 指导巡逻方格点位必到点巡逻任务接口
* @modifier zhangzhao
* @modifiedTime 2025/09/06 19:38
* @since 2025/09/06 19:38
*/
@Api(tags = {"指导巡逻-方格点位必到点巡逻任务接口"})
@RestController
@AllArgsConstructor
@RequestMapping("/tbZdxlFgdwBddxlrw")
public class TbZdxlFgdwBddxlrwController {
}

View File

@ -0,0 +1,133 @@
package com.mosty.yjzl.controller;
import com.mosty.base.model.dto.yjzl.TbZdxlFgdwBddxlrwJlClockInDTO;
import com.mosty.base.model.entity.yjzl.zddw.TbZdxlFgdwBddxlrwJl;
import com.mosty.base.utils.MessageUtils;
import com.mosty.base.utils.spring.SpringValidUtils;
import com.mosty.common.base.domain.ResponseResult;
import com.mosty.common.base.entity.log.BusinessType;
import com.mosty.common.base.entity.log.Log;
import com.mosty.common.token.JwtSysUser;
import com.mosty.common.token.UserInfo;
import com.mosty.common.token.UserInfoManager;
import com.mosty.yjzl.service.TbZdxlFgdwBddxlrwJlService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.AllArgsConstructor;
import org.apache.commons.lang3.ObjectUtils;
import org.apache.commons.lang3.StringUtils;
import org.springframework.validation.BindingResult;
import org.springframework.web.bind.annotation.*;
import javax.validation.Valid;
import java.util.Date;
import java.util.List;
/**
* @author zhangzhao
* @description 指导巡逻方格点位必到点巡逻任务记录接口
* @modifier zhangzhao
* @modifiedTime 2025/09/07 19:55
* @since 2025/09/07 19:55
*/
@Api(tags = {"指导巡逻-方格点位必到点巡逻任务记录接口"})
@RestController
@AllArgsConstructor
@RequestMapping("/tbZdxlFgdwBddxlrwJl")
public class TbZdxlFgdwBddxlrwJlController {
/**
* 指导巡逻方格点位必到点巡逻任务记录表Service
*/
private final TbZdxlFgdwBddxlrwJlService tbZdxlFgdwBddxlrwJlService;
/**
* 查询列表根据必到点巡逻任务ID
* @param bddxlrwId 必到点巡逻任务ID
* @return ResponseResult 实体信息列表
*/
@ApiOperation(value = "查询列表根据必到点巡逻任务ID")
@GetMapping("/selectListByBddxlrwId")
@JwtSysUser
@Log(title = "指导巡逻-方格点位必到点接口-查询列表根据必到点巡逻任务ID", businessType = BusinessType.OTHER)
public ResponseResult<List<TbZdxlFgdwBddxlrwJl>> selectListByBddxlrwId(String bddxlrwId) {
return ResponseResult.success(tbZdxlFgdwBddxlrwJlService.selectListByBddxlrwId(bddxlrwId));
}
/**
* 创建列表根据方格巡逻任务ID
* @param fgxlrwId 方格巡逻任务ID
* @return ResponseResult 实体信息列表
*/
@ApiOperation(value = "创建列表根据方格巡逻任务ID")
@GetMapping("/createListByFgxlrwId")
@JwtSysUser
@Log(title = "指导巡逻-方格点位必到点接口-创建列表根据方格巡逻任务ID", businessType = BusinessType.OTHER)
public ResponseResult<Integer> createListByFgxlrwId(String fgxlrwId) {
return ResponseResult.success(tbZdxlFgdwBddxlrwJlService.createListByFgxlrwId(fgxlrwId));
}
/**
* 保存单条
* @param dto 打卡DTO对象
* @param bindResult 校验对象
* @return ResponseResult 实体主键ID
*/
@ApiOperation(value = "打卡")
@PostMapping("clockIn")
@JwtSysUser
@Log(title = "指导巡逻-方格点位必到点接口-打卡", businessType = BusinessType.INSERT)
public ResponseResult<String> clockIn(@RequestBody @Valid TbZdxlFgdwBddxlrwJlClockInDTO dto, BindingResult bindResult) {
try {
//基础信息校验
String message = SpringValidUtils.getErrorsMsg(bindResult);
if (StringUtils.isNotBlank(message)) {
return ResponseResult.fail(MessageUtils.getSaveFailMsg() + message);
}
TbZdxlFgdwBddxlrwJl baseEntity = tbZdxlFgdwBddxlrwJlService.selectById(dto.getId());
if(ObjectUtils.isEmpty(baseEntity)){
return ResponseResult.fail(MessageUtils.getSaveFailMsg() + "打卡记录不存在,请退出页面重新进入");
}
//打卡时间
Date dksj = new Date();
// TODO: 2025/9/7 需要加上方格内部和打卡点附近的坐标验证
//校验上一次打卡情况
int lastSx = baseEntity.getDkSx() - 1;
if(lastSx > 0){
TbZdxlFgdwBddxlrwJl lastEntity = tbZdxlFgdwBddxlrwJlService.selectByBddxlrwIdAndDkSx(baseEntity.getBddxlrwId(), lastSx);
if(ObjectUtils.isNotEmpty(lastEntity) && ObjectUtils.isEmpty(lastEntity.getDkJsSj())){
return ResponseResult.fail(MessageUtils.getSaveFailMsg() + "请完成上一次打卡后,再进行本次打卡");
}
}
//如果是打结束卡,需要进行以下验证
UserInfo user = UserInfoManager.get();
if(ObjectUtils.isNotEmpty(baseEntity.getDkKsSj())){
//开始和结束是否是同一个人
if(!user.getIdEntityCard().equals(baseEntity.getDkrSfzh())){
return ResponseResult.fail(MessageUtils.getSaveFailMsg() + "您不是此记录的打卡人,不能进行打卡");
}
//是否待满10分钟
if(dksj.getTime()-baseEntity.getDkKsSj().getTime() < 10*60*1000){
return ResponseResult.fail(MessageUtils.getSaveFailMsg() + "请在开始10分后再打卡结束");
}
}
//打卡
String resultId = tbZdxlFgdwBddxlrwJlService.clockIn(baseEntity, dto, user, dksj);
if(StringUtils.isNotBlank(resultId)){
return ResponseResult.success(resultId);
}
return ResponseResult.fail(MessageUtils.getSaveFailMsg());
} catch (Exception e) {
e.printStackTrace();
return ResponseResult.fail(MessageUtils.getSaveServerErrorMsg());
}
}
}

View File

@ -1,6 +1,8 @@
package com.mosty.yjzl.controller;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.mosty.base.model.dto.yjzl.TbZdxlFgdwUpdateDTO;
import com.mosty.base.model.query.yjzl.TbZdxlFgdwQuery;
import com.mosty.base.model.vo.yjzl.TbZdxlFgdwVO;
import com.mosty.base.utils.MessageUtils;
import com.mosty.base.utils.spring.SpringValidUtils;
@ -38,7 +40,6 @@ public class TbZdxlFgdwController {
*/
private final TbZdxlFgdwService tbZdxlFgdwService;
/**
* 查询单条根据主键ID
* @param id 主键ID
@ -48,7 +49,7 @@ public class TbZdxlFgdwController {
@GetMapping("{id}")
@JwtSysUser
@Log(title = "指导巡逻-方格点位接口-查询单条根据主键ID", businessType = BusinessType.OTHER)
public ResponseResult<TbZdxlFgdwVO> selectById(@PathVariable("id") Integer id) {
public ResponseResult<TbZdxlFgdwVO> selectById(@PathVariable("id") Long id) {
return ResponseResult.success(tbZdxlFgdwService.selectById(id));
}
@ -64,6 +65,32 @@ public class TbZdxlFgdwController {
return ResponseResult.success(tbZdxlFgdwService.selectAllList());
}
/**
* 查询分页
* @param query 实体查询对象
* @return ResponseResult 实体信息分页列表
*/
@ApiOperation(value = "查询分页")
@GetMapping("/selectPage")
@JwtSysUser
@Log(title = "指导巡逻-方格点位接口-查询分页", businessType = BusinessType.OTHER)
public ResponseResult<IPage<TbZdxlFgdwVO>> selectPage(TbZdxlFgdwQuery query) {
return ResponseResult.success(tbZdxlFgdwService.selectPage(query));
}
/**
* 查询列表
* @param query 实体查询对象
* @return ResponseResult 实体信息列表
*/
@ApiOperation(value = "查询列表")
@GetMapping("/selectList")
@JwtSysUser
@Log(title = "指导巡逻-方格点位接口-查询列表", businessType = BusinessType.OTHER)
public ResponseResult<List<TbZdxlFgdwVO>> selectList(TbZdxlFgdwQuery query) {
return ResponseResult.success(tbZdxlFgdwService.selectList(query));
}
/**
* 修改单条
* @param dto 修改DTO对象
@ -74,7 +101,7 @@ public class TbZdxlFgdwController {
@PostMapping("update")
@JwtSysUser
@Log(title = "指导巡逻-方格点位接口-修改单条", businessType = BusinessType.UPDATE)
public ResponseResult<Integer> update(@RequestBody @Valid TbZdxlFgdwUpdateDTO dto, BindingResult bindResult){
public ResponseResult<Long> update(@RequestBody @Valid TbZdxlFgdwUpdateDTO dto, BindingResult bindResult){
try {
//基础信息校验
String message = SpringValidUtils.getErrorsMsg(bindResult);
@ -83,7 +110,7 @@ public class TbZdxlFgdwController {
}
//修改
Integer resultId = tbZdxlFgdwService.updateEntity(dto);
Long resultId = tbZdxlFgdwService.updateEntity(dto);
if(ObjectUtils.isNotEmpty(resultId)){
return ResponseResult.success(resultId);
}

View File

@ -0,0 +1,71 @@
package com.mosty.yjzl.controller;
import com.mosty.base.model.dto.yjzl.TbZdxlFgmrpzUpdateDTO;
import com.mosty.base.utils.MessageUtils;
import com.mosty.base.utils.spring.SpringValidUtils;
import com.mosty.common.base.domain.ResponseResult;
import com.mosty.common.base.entity.log.BusinessType;
import com.mosty.common.base.entity.log.Log;
import com.mosty.common.base.util.StringUtils;
import com.mosty.common.token.JwtSysUser;
import com.mosty.yjzl.service.TbZdxlFgmrpzService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.AllArgsConstructor;
import org.springframework.validation.BindingResult;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import javax.validation.Valid;
/**
* @author zhangzhao
* @description 指导巡逻方格默认配置接口
* @modifier zhangzhao
* @modifiedTime 2025/09/05 18:58
* @since 2025/09/05 18:58
*/
@Api(tags = {"指导巡逻-方格默认配置接口"})
@RestController
@AllArgsConstructor
@RequestMapping("/tbZdxlFgmrpz")
public class TbZdxlFgmrpzController {
/**
* 指导巡逻方格默认配置表Service
*/
private final TbZdxlFgmrpzService tbZdxlFgmrpzService;
/**
* 修改单条
* @param dto 修改DTO对象
* @param bindResult 校验对象
* @return ResponseResult 实体主键ID
*/
@ApiOperation(value = "修改单条")
@PostMapping("update")
@JwtSysUser
@Log(title = "指导巡逻-方格默认配置接口-修改单条", businessType = BusinessType.UPDATE)
public ResponseResult<String> update(@RequestBody @Valid TbZdxlFgmrpzUpdateDTO dto, BindingResult bindResult){
try {
//基础信息校验
String message = SpringValidUtils.getErrorsMsg(bindResult);
if (StringUtils.isNotBlank(message)) {
return ResponseResult.fail(MessageUtils.getEditFailMsg() + message);
}
//修改
String resultId = tbZdxlFgmrpzService.updateEntity(dto);
if(StringUtils.isNotBlank(resultId)){
return ResponseResult.success(resultId);
}
return ResponseResult.fail(MessageUtils.getEditFailMsg());
} catch (Exception e) {
e.printStackTrace();
return ResponseResult.fail(MessageUtils.getEditServerErrorMsg());
}
}
}

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());
}
}
}

View File

@ -0,0 +1,17 @@
package com.mosty.yjzl.mapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.mosty.base.model.entity.yjzl.zddw.TbZdxlFgdwBdd;
import org.apache.ibatis.annotations.Mapper;
/**
* @author zhangzhao
* @description 指导巡逻方格点位必到点表Mapper
* @modifier zhangzhao
* @modifiedTime 2025/09/06 14:17
* @since 2025/09/06 14:17
*/
@Mapper
public interface TbZdxlFgdwBddMapper extends BaseMapper<TbZdxlFgdwBdd> {
}

View File

@ -0,0 +1,17 @@
package com.mosty.yjzl.mapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.mosty.base.model.entity.yjzl.zddw.TbZdxlFgdwBddxlrwJl;
import org.apache.ibatis.annotations.Mapper;
/**
* @author zhangzhao
* @description 指导巡逻方格点位必到点巡逻任务记录表Mapper
* @modifier zhangzhao
* @modifiedTime 2025/09/07 19:58
* @since 2025/09/07 19:58
*/
@Mapper
public interface TbZdxlFgdwBddxlrwJlMapper extends BaseMapper<TbZdxlFgdwBddxlrwJl> {
}

View File

@ -0,0 +1,17 @@
package com.mosty.yjzl.mapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.mosty.base.model.entity.yjzl.zddw.TbZdxlFgdwBddxlrw;
import org.apache.ibatis.annotations.Mapper;
/**
* @author zhangzhao
* @description 指导巡逻方格点位必到点巡逻任务表Mapper
* @modifier zhangzhao
* @modifiedTime 2025/09/06 19:50
* @since 2025/09/06 19:50
*/
@Mapper
public interface TbZdxlFgdwBddxlrwMapper extends BaseMapper<TbZdxlFgdwBddxlrw> {
}

View File

@ -0,0 +1,17 @@
package com.mosty.yjzl.mapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.mosty.base.model.entity.yjzl.zddw.TbZdxlFgmrpz;
import org.apache.ibatis.annotations.Mapper;
/**
* @author zhangzhao
* @description 指导巡逻方格默认配置表Mapper
* @modifier zhangzhao
* @modifiedTime 2025/09/05 19:03
* @since 2025/09/05 19:03
*/
@Mapper
public interface TbZdxlFgmrpzMapper extends BaseMapper<TbZdxlFgmrpz> {
}

View File

@ -0,0 +1,247 @@
package com.mosty.yjzl.service.Impl;
import cn.hutool.core.bean.BeanUtil;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.mosty.base.model.dto.yjzl.TbZdxlFgdwBddSaveDTO;
import com.mosty.base.model.dto.yjzl.TbZdxlFgdwBddUpdateDTO;
import com.mosty.base.model.entity.yjzl.zddw.TbZdxlFgdw;
import com.mosty.base.model.entity.yjzl.zddw.TbZdxlFgdwBdd;
import com.mosty.base.model.query.yjzl.TbZdxlFgdwBddQuery;
import com.mosty.base.model.vo.yjzl.TbZdxlFgdwBddVO;
import com.mosty.base.utils.PageUtils;
import com.mosty.base.utils.QueryWrapperUtils;
import com.mosty.base.utils.UUIDGenerator;
import com.mosty.yjzl.mapper.TbZdxlFgdwBddMapper;
import com.mosty.yjzl.service.TbZdxlFgdwBddService;
import com.mosty.yjzl.service.TbZdxlFgdwService;
import lombok.AllArgsConstructor;
import org.apache.commons.collections4.CollectionUtils;
import org.apache.commons.lang3.ObjectUtils;
import org.apache.commons.lang3.StringUtils;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import java.util.ArrayList;
import java.util.List;
/**
* @author zhangzhao
* @description 指导巡逻方格点位必到点表Service实现类
* @modifier zhangzhao
* @modifiedTime 2025/09/06 14:16
* @since 2025/09/06 14:16
*/
@Service
@AllArgsConstructor
public class TbZdxlFgdwBddServiceImpl extends ServiceImpl<TbZdxlFgdwBddMapper, TbZdxlFgdwBdd> implements TbZdxlFgdwBddService {
/**
* 指导巡逻方格点位表Service
*/
private final TbZdxlFgdwService tbZdxlFgdwService;
@Override
public TbZdxlFgdwBdd selectById(String id) {
if (StringUtils.isBlank(id)) {
return null;
}
return this.baseMapper.selectOne(new QueryWrapper<TbZdxlFgdwBdd>()
.eq(TbZdxlFgdwBdd.ID_FIELD, id)
.eq("xt_sjzt", "1")
.eq("xt_scbz", "0")
);
}
@Override
public IPage<TbZdxlFgdwBddVO> selectPage(TbZdxlFgdwBddQuery query) {
IPage<TbZdxlFgdwBdd> page = PageUtils.buildPage(query.getPageSize(), query.getPageCurrent());
QueryWrapper<TbZdxlFgdwBdd> qw = new QueryWrapper<>();
//组装查询参数
this.buildListSelectQueryWrapper(qw, query);
//返回Page
IPage<TbZdxlFgdwBddVO> resultPage = new Page<>(query.getPageCurrent(), query.getPageSize());
//查询数据
page = this.baseMapper.selectPage(page, qw);
List<TbZdxlFgdwBdd> list = page.getRecords();
if(CollectionUtils.isEmpty(list)){
return resultPage;
}
//转为VO
List<TbZdxlFgdwBddVO> resultList = this.buildAllInfoListByEntityList(list);
//组装VO
resultPage.setRecords(resultList);
resultPage.setTotal(page.getTotal());
return resultPage;
}
@Override
public List<TbZdxlFgdwBddVO> selectList(TbZdxlFgdwBddQuery query) {
QueryWrapper<TbZdxlFgdwBdd> qw = new QueryWrapper<>();
//组装查询参数
this.buildListSelectQueryWrapper(qw, query);
//查询数据
List<TbZdxlFgdwBdd> list = this.baseMapper.selectList(qw);
if(CollectionUtils.isEmpty(list)){
return null;
}
//转为VO返回
return this.buildAllInfoListByEntityList(list);
}
@Override
public List<TbZdxlFgdwBdd> selectListByIdList(List<String> idList) {
if(CollectionUtils.isEmpty(idList)){
return null;
}
//查询数据
return this.baseMapper.selectList(new QueryWrapper<TbZdxlFgdwBdd>()
.in(TbZdxlFgdwBdd.ID_FIELD, idList)
.eq("xt_sjzt", "1")
.eq("xt_scbz", "0")
);
}
@Override
public List<TbZdxlFgdwBdd> selectListByFgdwId(Long fgdwId) {
if(ObjectUtils.isEmpty(fgdwId)){
return null;
}
//查询数据
return this.baseMapper.selectList(new QueryWrapper<TbZdxlFgdwBdd>()
.eq(TbZdxlFgdwBdd.FGDW_ID_FIELD, fgdwId)
.eq("xt_sjzt", "1")
.eq("xt_scbz", "0")
);
}
@Override
public List<TbZdxlFgdwBdd> selectListByFgxlrwId(String fgxlrwId) {
if(ObjectUtils.isEmpty(fgxlrwId)){
return null;
}
//查询数据
return this.baseMapper.selectList(new QueryWrapper<TbZdxlFgdwBdd>()
.inSql(TbZdxlFgdwBdd.FGDW_ID_FIELD, "select fg_id from tb_zdxl_fgxlrw where xt_sjzt = '1' and xt_scbz = '0' and id = '" + fgxlrwId + "'")
.eq("xt_sjzt", "1")
.eq("xt_scbz", "0")
);
}
@Override
@Transactional(rollbackFor = Exception.class)
public String saveEntity(TbZdxlFgdwBddSaveDTO dto) {
//复制参数至实体
TbZdxlFgdwBdd entity = BeanUtil.copyProperties(dto, TbZdxlFgdwBdd.class);
//组装参数
entity.setId(UUIDGenerator.getUUID());
entity.setXtSjly("1");
//保存实体
int resultInt = this.baseMapper.insert(entity);
if(resultInt > 0){
//返回主键
return entity.getId();
}
return null;
}
@Override
@Transactional(rollbackFor = Exception.class)
public String updateEntity(TbZdxlFgdwBddUpdateDTO dto) {
//复制参数至实体
TbZdxlFgdwBdd entity = BeanUtil.copyProperties(dto, TbZdxlFgdwBdd.class);
//修改实体
int resultInt = this.baseMapper.updateById(entity);
if(resultInt > 0){
//返回主键
return entity.getId();
}
return null;
}
@Override
@Transactional(rollbackFor = Exception.class)
public int cancelEntity(TbZdxlFgdwBdd entity) {
//先修改系统字段
TbZdxlFgdwBdd cancelEntity = new TbZdxlFgdwBdd();
cancelEntity.setId(entity.getId());
this.baseMapper.updateById(cancelEntity);
//再注销
return this.baseMapper.deleteById(entity.getId());
}
/**
* 组装查询参数
* @param qw QueryWrapper
* @param query 查询对象
*/
private void buildListSelectQueryWrapper(QueryWrapper<TbZdxlFgdwBdd> qw, TbZdxlFgdwBddQuery query){
//组装其他排序方式
QueryWrapperUtils.buildQueryWrapperOrder(qw, query.getSort(), query.getOrder());
//未注销数据
qw.eq("xt_sjzt", "1").eq("xt_scbz", "0");
//方格点位ID
qw.like(ObjectUtils.isNotEmpty(query.getFgdwId()), TbZdxlFgdwBdd.FGDW_ID_FIELD, query.getFgdwId());
//必到点名称
qw.like(StringUtils.isNotBlank(query.getBddMc()), TbZdxlFgdwBdd.BDD_MC_FIELD, query.getBddMc());
//必到点地址
qw.like(StringUtils.isNotBlank(query.getBddDz()), TbZdxlFgdwBdd.BDD_DZ_FIELD, query.getBddDz());
}
/**
* 组装全量信息列表(根据实体列表)
* @param entityList 实体列表
* @return 全量信息列表
*/
private List<TbZdxlFgdwBddVO> buildAllInfoListByEntityList(List<TbZdxlFgdwBdd> entityList){
List<TbZdxlFgdwBddVO> allInfoVOList = new ArrayList<>();
//组装返回数据
for(TbZdxlFgdwBdd entity : entityList){
TbZdxlFgdwBddVO resultVO = this.buildAllInfoByEntity(entity);
allInfoVOList.add(resultVO);
}
//返回列表
if(CollectionUtils.isEmpty(allInfoVOList)){
return null;
}
return allInfoVOList;
}
/**
* 组装全量信息(根据实体信息)
* @param entity 实体信息
* @return 全量信息
*/
private TbZdxlFgdwBddVO buildAllInfoByEntity(TbZdxlFgdwBdd entity){
TbZdxlFgdwBddVO resultVO = BeanUtil.copyProperties(entity, TbZdxlFgdwBddVO.class);
if(ObjectUtils.isNotEmpty(resultVO.getFgdwId())){
//组装方格数据
TbZdxlFgdw fg = tbZdxlFgdwService.selectById(resultVO.getFgdwId());
if(ObjectUtils.isNotEmpty(fg)){
resultVO.setFgdwMc(fg.getMc1());
}
}
return resultVO;
}
}

View File

@ -0,0 +1,150 @@
package com.mosty.yjzl.service.Impl;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.mosty.base.model.dto.yjzl.TbZdxlFgdwBddxlrwJlClockInDTO;
import com.mosty.base.model.entity.yjzl.zddw.TbZdxlFgdwBddxlrw;
import com.mosty.base.model.entity.yjzl.zddw.TbZdxlFgdwBddxlrwJl;
import com.mosty.base.utils.UUIDGenerator;
import com.mosty.common.token.UserInfo;
import com.mosty.yjzl.mapper.TbZdxlFgdwBddxlrwJlMapper;
import com.mosty.yjzl.service.TbZdxlFgdwBddxlrwJlService;
import com.mosty.yjzl.service.TbZdxlFgdwBddxlrwService;
import lombok.AllArgsConstructor;
import org.apache.commons.collections4.CollectionUtils;
import org.apache.commons.lang3.ObjectUtils;
import org.apache.commons.lang3.StringUtils;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
/**
* @author zhangzhao
* @description 指导巡逻方格点位必到点巡逻任务记录表Service实现类
* @modifier zhangzhao
* @modifiedTime 2025/09/07 19:57
* @since 2025/09/07 19:57
*/
@Service
@AllArgsConstructor
public class TbZdxlFgdwBddxlrwJlServiceImpl extends ServiceImpl<TbZdxlFgdwBddxlrwJlMapper, TbZdxlFgdwBddxlrwJl> implements TbZdxlFgdwBddxlrwJlService {
/**
* 指导巡逻方格点位必到点巡逻任务表Service
*/
private final TbZdxlFgdwBddxlrwService tbZdxlFgdwBddxlrwService;
@Override
public TbZdxlFgdwBddxlrwJl selectById(String id) {
if (StringUtils.isBlank(id)) {
return null;
}
return this.baseMapper.selectOne(new QueryWrapper<TbZdxlFgdwBddxlrwJl>()
.eq(TbZdxlFgdwBddxlrwJl.ID_FIELD, id)
.eq("xt_sjzt", "1")
.eq("xt_scbz", "0")
);
}
@Override
public TbZdxlFgdwBddxlrwJl selectByBddxlrwIdAndDkSx(String bddxlrwId, int dkSx) {
if(StringUtils.isBlank(bddxlrwId)){
return null;
}
return this.baseMapper.selectOne(new QueryWrapper<TbZdxlFgdwBddxlrwJl>()
.eq(TbZdxlFgdwBddxlrwJl.BDDXLRW_ID_FIELD, bddxlrwId)
.eq(TbZdxlFgdwBddxlrwJl.DK_SX_FIELD, dkSx)
.eq("xt_sjzt", "1")
.eq("xt_scbz", "0")
);
}
@Override
public List<TbZdxlFgdwBddxlrwJl> selectListByBddxlrwId(String bddxlrwId) {
if(ObjectUtils.isEmpty(bddxlrwId)){
return null;
}
return this.baseMapper.selectList(new QueryWrapper<TbZdxlFgdwBddxlrwJl>()
.eq(TbZdxlFgdwBddxlrwJl.BDDXLRW_ID_FIELD, bddxlrwId)
.eq("xt_sjzt", "1")
.eq("xt_scbz", "0")
.orderByAsc(TbZdxlFgdwBddxlrwJl.DK_SX_FIELD)
);
}
@Override
@Transactional(rollbackFor = Exception.class)
public int createListByFgxlrwId(String fgxlrwId) {
if(StringUtils.isBlank(fgxlrwId)){
return -1;
}
List<TbZdxlFgdwBddxlrw> bddxlrwList = tbZdxlFgdwBddxlrwService.selectListByFgxlrwId(fgxlrwId);
if(CollectionUtils.isEmpty(bddxlrwList)){
return -2;
}
//循环组装数据
List<TbZdxlFgdwBddxlrwJl> saveList = new ArrayList<>();
for(TbZdxlFgdwBddxlrw bbdxlrw : bddxlrwList){
if(ObjectUtils.isEmpty(bbdxlrw.getXlghDkcs())){
continue;
}
for(int i = 1 ; i <= bbdxlrw.getXlghDkcs() ; i++){
TbZdxlFgdwBddxlrwJl entity = new TbZdxlFgdwBddxlrwJl();
entity.setId(UUIDGenerator.getUUID());
entity.setBddxlrwId(bbdxlrw.getId());
entity.setDkSx(i);
entity.setXtSjly("1");
saveList.add(entity);
}
}
boolean success = this.saveBatch(saveList);
if(success){
return saveList.size();
}
return 0;
}
@Override
@Transactional(rollbackFor = Exception.class)
public String clockIn(TbZdxlFgdwBddxlrwJl baseEntity, TbZdxlFgdwBddxlrwJlClockInDTO dto, UserInfo user, Date dksj) {
if(ObjectUtils.isEmpty(baseEntity) || ObjectUtils.isEmpty(dto) || ObjectUtils.isEmpty(user)){
return null;
}
boolean start = ObjectUtils.isEmpty(baseEntity.getDkKsSj());
if(start){
//开始
baseEntity.setDkKsSj(dksj);
baseEntity.setDkKsFj(dto.getDkFj());
baseEntity.setDkKsJd(dto.getDkJd());
baseEntity.setDkKsWd(dto.getDkWd());
baseEntity.setDkrXm(user.getUserName());
baseEntity.setDkrSfzh(user.getIdEntityCard());
}else{
//结束
baseEntity.setDkJsSj(dksj);
baseEntity.setDkJsFj(dto.getDkFj());
baseEntity.setDkJsJd(dto.getDkJd());
baseEntity.setDkJsWd(dto.getDkWd());
}
int resultInt = this.baseMapper.updateById(baseEntity);
if(resultInt > 0){
//保存成功后,同步必到点状态
tbZdxlFgdwBddxlrwService.clockInByJl(baseEntity, start);
//返回
return baseEntity.getId();
}
return null;
}
}

View File

@ -0,0 +1,344 @@
package com.mosty.yjzl.service.Impl;
import cn.hutool.core.bean.BeanUtil;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.mosty.base.model.dto.yjzl.TbZdxlFgdwBddxlrwHandleDTO;
import com.mosty.base.model.entity.yjzl.zddw.*;
import com.mosty.base.model.vo.yjzl.TbZdxlFgdwBddxlrwVO;
import com.mosty.base.utils.Constant;
import com.mosty.base.utils.MathUtils;
import com.mosty.base.utils.UUIDGenerator;
import com.mosty.yjzl.mapper.TbZdxlFgdwBddxlrwMapper;
import com.mosty.yjzl.service.TbZdxlFgdwBddService;
import com.mosty.yjzl.service.TbZdxlFgdwBddxlrwService;
import com.mosty.yjzl.service.TbZdxlFgmrpzService;
import lombok.AllArgsConstructor;
import org.apache.commons.collections4.CollectionUtils;
import org.apache.commons.lang3.ObjectUtils;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.function.Function;
import java.util.stream.Collectors;
/**
* @author zhangzhao
* @description 指导巡逻方格点位必到点巡逻任务表Service实现类
* @modifier zhangzhao
* @modifiedTime 2025/09/06 19:49
* @since 2025/09/06 19:49
*/
@Service
@AllArgsConstructor
public class TbZdxlFgdwBddxlrwServiceImpl extends ServiceImpl<TbZdxlFgdwBddxlrwMapper, TbZdxlFgdwBddxlrw> implements TbZdxlFgdwBddxlrwService {
/**
* 指导巡逻方格点位必到点表Service
*/
private final TbZdxlFgdwBddService tbZdxlFgdwBddService;
/**
* 指导巡逻方格默认配置表Service
*/
private final TbZdxlFgmrpzService tbZdxlFgmrpzService;
@Override
public TbZdxlFgdwBddxlrw selectById(String id) {
if(ObjectUtils.isEmpty(id)){
return null;
}
//查询已配置的任务数据
return this.baseMapper.selectOne(new QueryWrapper<TbZdxlFgdwBddxlrw>()
.eq(TbZdxlFgdwBddxlrw.ID_FIELD, id)
.eq("xt_sjzt", "1")
.eq("xt_scbz", "0")
);
}
@Override
public List<TbZdxlFgdwBddxlrw> selectListByFgxlrwId(String fgxlrwId) {
if(ObjectUtils.isEmpty(fgxlrwId)){
return null;
}
//查询已配置的任务数据
return this.baseMapper.selectList(new QueryWrapper<TbZdxlFgdwBddxlrw>()
.eq(TbZdxlFgdwBddxlrw.FGXLRW_ID_FIELD, fgxlrwId)
.eq("xt_sjzt", "1")
.eq("xt_scbz", "0")
);
}
@Override
public List<TbZdxlFgdwBddxlrwVO> selectVoListByYxfFgxlrwId(String fgxlrwId) {
if(ObjectUtils.isEmpty(fgxlrwId)){
return null;
}
//查询已配置的任务数据
List<TbZdxlFgdwBddxlrw> entityList = this.baseMapper.selectList(new QueryWrapper<TbZdxlFgdwBddxlrw>()
.eq(TbZdxlFgdwBddxlrw.FGXLRW_ID_FIELD, fgxlrwId)
.eq("xt_sjzt", "1")
.eq("xt_scbz", "0")
);
//组装并返回数据
return this.buildAllInfoList(entityList, null, fgxlrwId);
}
@Override
public List<TbZdxlFgdwBddxlrwVO> selectVoListByFgxlrwId(String fgxlrwId) {
if(ObjectUtils.isEmpty(fgxlrwId)){
return null;
}
//查询已配置的任务数据
List<TbZdxlFgdwBddxlrw> entityList = this.baseMapper.selectList(new QueryWrapper<TbZdxlFgdwBddxlrw>()
.eq(TbZdxlFgdwBddxlrw.FGXLRW_ID_FIELD, fgxlrwId)
.eq("xt_sjzt", "1")
.eq("xt_scbz", "0")
);
//查询所有必到点
List<TbZdxlFgdwBdd> bddList = tbZdxlFgdwBddService.selectListByFgxlrwId(fgxlrwId);
//组装并返回数据
return this.buildAllInfoList(entityList, bddList, fgxlrwId);
}
@Override
@Transactional(rollbackFor = Exception.class)
public int handleList(List<TbZdxlFgdwBddxlrwHandleDTO> handleList) {
if(CollectionUtils.isEmpty(handleList)){
return -1;
}
//筛选数据
List<TbZdxlFgdwBddxlrwHandleDTO> saveDtoList = handleList.stream().filter(dto -> ObjectUtils.isEmpty(dto.getId())).collect(Collectors.toList());
List<TbZdxlFgdwBddxlrwHandleDTO> updateDtoList = handleList.stream().filter(dto -> ObjectUtils.isNotEmpty(dto.getId())).collect(Collectors.toList());
List<TbZdxlFgdwBddxlrw> saveList = new ArrayList<>(), updateList = new ArrayList<>();
//组装保存列表
if(CollectionUtils.isNotEmpty(saveDtoList)){
for(TbZdxlFgdwBddxlrwHandleDTO dto : saveDtoList){
TbZdxlFgdwBddxlrw entity = BeanUtil.copyProperties(dto, TbZdxlFgdwBddxlrw.class);
//组装参数
entity.setId(UUIDGenerator.getUUID());
entity.setXtSjly("1");
saveList.add(entity);
}
}
//组装修改列表
if(CollectionUtils.isNotEmpty(updateDtoList)){
for(TbZdxlFgdwBddxlrwHandleDTO dto : saveDtoList){
TbZdxlFgdwBddxlrw entity = new TbZdxlFgdwBddxlrw();
entity.setId(dto.getId());
entity.setXlghDkcs(dto.getXlghDkcs());
updateList.add(entity);
}
}
//保存或修改信息
int resultInt = 0;
if(CollectionUtils.isNotEmpty(saveList)){
boolean success = this.saveBatch(saveList);
if(success){
resultInt += saveList.size();
}
}
if(CollectionUtils.isNotEmpty(updateList)){
boolean success = this.updateBatchById(updateList);
if(success){
resultInt += updateList.size();
}
}
return resultInt;
}
@Override
@Transactional(rollbackFor = Exception.class)
public int handleListByFgxlrwList(List<TbZdxlFgxlrw> fgxlrwList) {
if(CollectionUtils.isEmpty(fgxlrwList)){
return -1;
}
//通过查询vo列表组装成dto列表进行保存
int resultInt = 0;
for(TbZdxlFgxlrw fgxlrw : fgxlrwList){
List<TbZdxlFgdwBddxlrwVO> voList = this.selectVoListByFgxlrwId(fgxlrw.getId());
if(CollectionUtils.isEmpty(voList)){
continue;
}
List<TbZdxlFgdwBddxlrwHandleDTO> dtoList = new ArrayList<>();
for(TbZdxlFgdwBddxlrwVO vo : voList){
TbZdxlFgdwBddxlrwHandleDTO dto = BeanUtil.copyProperties(vo, TbZdxlFgdwBddxlrwHandleDTO.class);
dtoList.add(dto);
}
resultInt += this.handleList(dtoList);
}
return resultInt;
}
@Override
@Transactional(rollbackFor = Exception.class)
public String clockInByJl(TbZdxlFgdwBddxlrwJl jl, boolean start) {
if(ObjectUtils.isEmpty(jl) || ObjectUtils.isEmpty(jl.getBddxlrwId())){
return null;
}
TbZdxlFgdwBddxlrw baseEntity = this.selectById(jl.getBddxlrwId());
if(ObjectUtils.isEmpty(baseEntity)){
return null;
}
TbZdxlFgdwBddxlrw updateEntity = new TbZdxlFgdwBddxlrw();
updateEntity.setId(baseEntity.getId());
//修改开始状态
if(Constant.DICT_ITEM_D_BZ_SF_NO.equals(baseEntity.getSfKs())){
updateEntity.setSfKs(Constant.DICT_ITEM_D_BZ_SF_YES);
}
//判断是否修改结束状态
if(baseEntity.getXlghDkcs().equals(jl.getDkSx()) && !start){
//规划打卡次数与记录打卡相同,则表示是最后一次打卡,如果是结束打卡,则可以将状态改为结束
updateEntity.setSfJs(Constant.DICT_ITEM_D_BZ_SF_YES);
}
//结束打卡,增加次数
if(!start){
int newSjDkCs = baseEntity.getXlsjDkcs() + 1;
if(newSjDkCs > baseEntity.getXlghDkcs()){
newSjDkCs = baseEntity.getXlghDkcs();
}
updateEntity.setXlsjDkcs(newSjDkCs);
}
int resultInt = this.baseMapper.updateById(updateEntity);
if(resultInt > 0){
return baseEntity.getId();
}
return null;
}
/**
* 组装全量信息列表(根据实体列表、必到点列表)
* @param entityList 实体列表
* @param bddList 必到点列表
* @param fgxlrwId 方格巡逻任务ID
* @return 全量信息列表
*/
private List<TbZdxlFgdwBddxlrwVO> buildAllInfoList(List<TbZdxlFgdwBddxlrw> entityList, List<TbZdxlFgdwBdd> bddList, String fgxlrwId){
if(CollectionUtils.isEmpty(entityList) && CollectionUtils.isEmpty(bddList)){
return null;
}
//组装实体数据
Map<String, TbZdxlFgdwBddxlrw> entityMap = new HashMap<>();
List<TbZdxlFgdwBddxlrwVO> allInfoVoList = new ArrayList<>();
if(CollectionUtils.isNotEmpty(entityList)){
List<TbZdxlFgdwBddxlrwVO> entityAllInfoList = this.buildAllInfoListByEntityList(entityList);
if(CollectionUtils.isNotEmpty(entityAllInfoList)){
allInfoVoList.addAll(entityAllInfoList);
}
entityMap = entityList.stream().collect(Collectors.toMap(TbZdxlFgdwBddxlrw::getBddId, Function.identity(), (key1, key2) -> key2));
}
//组装必到点数据
if(CollectionUtils.isNotEmpty(bddList)){
Map<String, TbZdxlFgdwBddxlrw> finalEntityMap = entityMap;
List<TbZdxlFgdwBdd> bddNotCreateList = bddList.stream().filter(bdd -> !finalEntityMap.containsKey(bdd.getId())).collect(Collectors.toList());
if(CollectionUtils.isNotEmpty(bddNotCreateList)){
List<TbZdxlFgdwBddxlrwVO> bddAllInfoList = this.buildAllInfoListByBddList(bddNotCreateList, fgxlrwId);
if(CollectionUtils.isNotEmpty(bddAllInfoList)){
allInfoVoList.addAll(bddAllInfoList);
}
}
}
return allInfoVoList;
}
/**
* 组装全量信息列表(根据必到点列表)
* @param bddList 必到点列表
* @param fgxlrwId 方格巡逻任务ID
* @return 全量信息列表
*/
private List<TbZdxlFgdwBddxlrwVO> buildAllInfoListByBddList(List<TbZdxlFgdwBdd> bddList, String fgxlrwId){
if(CollectionUtils.isEmpty(bddList)){
return null;
}
TbZdxlFgmrpz mrpz = tbZdxlFgmrpzService.selectDefault();
if(ObjectUtils.isEmpty(mrpz)){
return null;
}
List<TbZdxlFgdwBddxlrwVO> allInfoVOList = new ArrayList<>();
for(TbZdxlFgdwBdd bdd : bddList){
TbZdxlFgdwBddxlrwVO vo = new TbZdxlFgdwBddxlrwVO();
vo.setBddMc(bdd.getBddMc());
vo.setBddId(bdd.getId());
vo.setFgxlrwId(fgxlrwId);
vo.setXlghDkcs(mrpz.getFgDkcs());
vo.setXlsjDkcs(0);
vo.setSfKs(Constant.DICT_ITEM_D_BZ_SF_NO);
vo.setSfJs(Constant.DICT_ITEM_D_BZ_SF_NO);
allInfoVOList.add(vo);
}
return allInfoVOList;
}
/**
* 组装全量信息列表(根据实体列表)
* @param entityList 实体列表
* @return 全量信息列表
*/
private List<TbZdxlFgdwBddxlrwVO> buildAllInfoListByEntityList(List<TbZdxlFgdwBddxlrw> entityList){
List<TbZdxlFgdwBddxlrwVO> allInfoVOList = new ArrayList<>();
//组装返回数据
for(TbZdxlFgdwBddxlrw entity : entityList){
TbZdxlFgdwBddxlrwVO resultVO = this.buildAllInfoByEntity(entity);
allInfoVOList.add(resultVO);
}
//返回列表
if(CollectionUtils.isEmpty(allInfoVOList)){
return null;
}
return allInfoVOList;
}
/**
* 组装全量信息(根据实体信息)
* @param entity 实体信息
* @return 全量信息
*/
private TbZdxlFgdwBddxlrwVO buildAllInfoByEntity(TbZdxlFgdwBddxlrw entity){
TbZdxlFgdwBddxlrwVO resultVO = BeanUtil.copyProperties(entity, TbZdxlFgdwBddxlrwVO.class);
//组装必到点信息
if(ObjectUtils.isNotEmpty(resultVO.getBddId())){
TbZdxlFgdwBdd bdd = tbZdxlFgdwBddService.selectById(resultVO.getBddId());
if(ObjectUtils.isNotEmpty(bdd)){
resultVO.setBddMc(bdd.getBddMc());
}
}
//计算进度
resultVO.setBddProgress(MathUtils.percentage(entity.getXlsjDkcs(), entity.getXlghDkcs()));
return resultVO;
}
}

View File

@ -2,10 +2,16 @@ package com.mosty.yjzl.service.Impl;
import cn.hutool.core.bean.BeanUtil;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.mosty.base.model.dto.yjzl.TbZdxlFgdwUpdateDTO;
import com.mosty.base.model.entity.yjzl.zddw.TbZdxlFgdw;
import com.mosty.base.model.entity.yjzl.zddw.TbZdxlFgdw;
import com.mosty.base.model.query.yjzl.TbZdxlFgdwQuery;
import com.mosty.base.model.vo.yjzl.TbZdxlFgdwVO;
import com.mosty.base.utils.PageUtils;
import com.mosty.base.utils.QueryWrapperUtils;
import com.mosty.yjzl.mapper.TbZdxlFgdwMapper;
import com.mosty.yjzl.service.TbZdxlFgdwService;
import lombok.AllArgsConstructor;
@ -14,9 +20,8 @@ import org.apache.commons.lang3.ObjectUtils;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import java.math.BigDecimal;
import java.util.*;
import java.util.stream.Collectors;
import java.util.ArrayList;
import java.util.List;
/**
* @author zhangzhao
@ -30,7 +35,7 @@ import java.util.stream.Collectors;
public class TbZdxlFgdwServiceImpl extends ServiceImpl<TbZdxlFgdwMapper, TbZdxlFgdw> implements TbZdxlFgdwService {
@Override
public TbZdxlFgdwVO selectById(Integer id) {
public TbZdxlFgdwVO selectById(Long id) {
if(ObjectUtils.isEmpty(id)){
return null;
}
@ -49,96 +54,52 @@ public class TbZdxlFgdwServiceImpl extends ServiceImpl<TbZdxlFgdwMapper, TbZdxlF
}
@Override
public int saveListByGenerate(List<TbZdxlFgdw> saveList, String firstMc) {
if(CollectionUtils.isEmpty(saveList)){
return -1;
public IPage<TbZdxlFgdwVO> selectPage(TbZdxlFgdwQuery query) {
IPage<TbZdxlFgdw> page = PageUtils.buildPage(query.getPageSize(), query.getPageCurrent());
QueryWrapper<TbZdxlFgdw> qw = new QueryWrapper<>();
//组装查询参数
this.buildListSelectQueryWrapper(qw, query);
//返回Page
IPage<TbZdxlFgdwVO> resultPage = new Page<>(query.getPageCurrent(), query.getPageSize());
//查询数据
page = this.baseMapper.selectPage(page, qw);
List<TbZdxlFgdw> list = page.getRecords();
if(CollectionUtils.isEmpty(list)){
return resultPage;
}
//获取基准方格baseLeftTopDw表示最左侧一列从上向下第一个方格baseTopLeftDw表示最上一行从左向右第一个方格
TbZdxlFgdw baseLeftTopDw = new TbZdxlFgdw(), baseTopLeftDw = new TbZdxlFgdw();
for(TbZdxlFgdw dw : saveList){
//x11取最小值y11取最大值
if(ObjectUtils.isEmpty(baseLeftTopDw.getX11()) && ObjectUtils.isEmpty(baseLeftTopDw.getY11())){
baseLeftTopDw = dw;
} else if (dw.getX11().compareTo(baseLeftTopDw.getX11()) < 0){
baseLeftTopDw = dw;
} else if (dw.getX11().compareTo(baseLeftTopDw.getX11()) == 0 && dw.getY11().compareTo(baseLeftTopDw.getY11()) >= 0){
baseLeftTopDw = dw;
}
//转为VO
List<TbZdxlFgdwVO> resultList = this.buildAllInfoListByEntityList(list);
//y21取最大值x21取最小值
if(ObjectUtils.isEmpty(baseTopLeftDw.getX21()) && ObjectUtils.isEmpty(baseTopLeftDw.getY21())){
baseTopLeftDw = dw;
}else if (dw.getY21().compareTo(baseTopLeftDw.getY21()) > 0){
baseTopLeftDw = dw;
}else if (dw.getY21().compareTo(baseTopLeftDw.getY21()) == 0 && dw.getX21().compareTo(baseTopLeftDw.getX21()) <= 0){
baseTopLeftDw = dw;
}
//组装VO
resultPage.setRecords(resultList);
resultPage.setTotal(page.getTotal());
return resultPage;
}
@Override
public List<TbZdxlFgdwVO> selectList(TbZdxlFgdwQuery query) {
QueryWrapper<TbZdxlFgdw> qw = new QueryWrapper<>();
//组装查询参数
this.buildListSelectQueryWrapper(qw, query);
//查询数据
List<TbZdxlFgdw> list = this.baseMapper.selectList(qw);
if(CollectionUtils.isEmpty(list)){
return null;
}
//按列循环赋值中间名从基准方格中取x11的值为开始
Map<String, TbZdxlFgdw> entityMap = new HashMap<>();
BigDecimal baseLeftTopDwX11 = baseLeftTopDw.getX11();
char letter = 'A';
while (baseLeftTopDwX11 != null) {
BigDecimal finalBaseLeftTopDwX11 = baseLeftTopDwX11;
//查询x11相同的方格按y11正序排列开始取名
List<TbZdxlFgdw> dwList = saveList.stream()
.filter(entity -> entity.getX11().compareTo(finalBaseLeftTopDwX11) == 0)
.sorted(Comparator.comparing(TbZdxlFgdw::getY11))
.collect(Collectors.toList());
if(CollectionUtils.isNotEmpty(dwList)){
//如果查询出来的列表不为空则需要将列表中的x21赋值给baseLeftTopDwX11以进行下次循环
baseLeftTopDwX11 = dwList.get(0).getX21();
//同一列的名称,中间名相同
for(TbZdxlFgdw entity : dwList){
entity.setMc1(firstMc + "-" + letter);
entityMap.put("" + entity.getX11() + entity.getY11(), entity);
}
letter++;
if(letter > 'Z'){
letter = 'A';
}
}else{
baseLeftTopDwX11 = null;
}
}
//按行循环赋值尾名从基准方格中取y21的值为开始
BigDecimal baseTopLeftDwY21 = baseTopLeftDw.getY21();
int i = 1;
while (baseTopLeftDwY21 != null) {
BigDecimal finalBaseTopLeftDwY21 = baseTopLeftDwY21;
//查询y21相同的方格按x21正序排列开始取名
List<TbZdxlFgdw> dwList = saveList.stream()
.filter(entity -> entity.getY21().compareTo(finalBaseTopLeftDwY21) == 0)
.sorted(Comparator.comparing(TbZdxlFgdw::getX21))
.collect(Collectors.toList());
if(CollectionUtils.isNotEmpty(dwList)){
//如果查询出来的列表不为空则需要将列表中的y11赋值给baseTopLeftDwY21以进行下次循环
baseTopLeftDwY21 = dwList.get(0).getY11();
//同一行的名称,尾名相同
for(TbZdxlFgdw entity : dwList){
TbZdxlFgdw mcEntity = entityMap.get("" + entity.getX11() + entity.getY11());
mcEntity.setMc1(entity.getMc1() + "-" + i);
entityMap.put("" + entity.getX11() + entity.getY11(), mcEntity);
}
i++;
}else{
baseTopLeftDwY21 = null;
}
}
boolean success = this.saveBatch(entityMap.values());
if(success){
return entityMap.values().size();
}
return 0;
//转为VO返回
return this.buildAllInfoListByEntityList(list);
}
@Override
@Transactional(rollbackFor = Exception.class)
public Integer updateEntity(TbZdxlFgdwUpdateDTO dto) {
public Long updateEntity(TbZdxlFgdwUpdateDTO dto) {
//复制参数至实体
TbZdxlFgdw entity = BeanUtil.copyProperties(dto, TbZdxlFgdw.class);
entity.setMc1(dto.getMc());
@ -152,6 +113,22 @@ public class TbZdxlFgdwServiceImpl extends ServiceImpl<TbZdxlFgdwMapper, TbZdxlF
return null;
}
/**
* 组装查询参数
* @param qw QueryWrapper
* @param query 查询对象
*/
private void buildListSelectQueryWrapper(QueryWrapper<TbZdxlFgdw> qw, TbZdxlFgdwQuery query){
//组装其他排序方式
QueryWrapperUtils.buildQueryWrapperOrder(qw, query.getSort(), query.getOrder());
//未注销数据
qw.eq("xt_sjzt", "1").eq("xt_scbz", "0");
//方格点位ID
qw.like(ObjectUtils.isNotEmpty(query.getMc()), TbZdxlFgdw.MC, query.getMc());
}
/**
* 组装全量信息列表(根据实体列表)
* @param entityList 实体列表

View File

@ -0,0 +1,58 @@
package com.mosty.yjzl.service.Impl;
import cn.hutool.core.bean.BeanUtil;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.mosty.base.model.dto.yjzl.TbZdxlFgmrpzUpdateDTO;
import com.mosty.base.model.entity.yjzl.zddw.TbZdxlFgmrpz;
import com.mosty.yjzl.mapper.TbZdxlFgmrpzMapper;
import com.mosty.yjzl.service.TbZdxlFgmrpzService;
import lombok.AllArgsConstructor;
import org.apache.commons.lang3.ObjectUtils;
import org.springframework.stereotype.Service;
/**
* @author zhangzhao
* @description 指导巡逻方格默认配置表Service实现类
* @modifier zhangzhao
* @modifiedTime 2025/09/05 19:02
* @since 2025/09/05 19:02
*/
@Service
@AllArgsConstructor
public class TbZdxlFgmrpzServiceImpl extends ServiceImpl<TbZdxlFgmrpzMapper, TbZdxlFgmrpz> implements TbZdxlFgmrpzService {
@Override
public TbZdxlFgmrpz selectDefault() {
return this.baseMapper.selectOne(new QueryWrapper<>());
}
@Override
public String updateEntity(TbZdxlFgmrpzUpdateDTO dto) {
//复制参数至实体
TbZdxlFgmrpz entity = BeanUtil.copyProperties(dto, TbZdxlFgmrpz.class);
//如果参数为空则设置默认值为0
if(ObjectUtils.isEmpty(entity.getPcCl())){
entity.setPcCl(0);
}
if(ObjectUtils.isEmpty(entity.getPcRy())){
entity.setPcRy(0);
}
if(ObjectUtils.isEmpty(entity.getXlSc())){
entity.setXlSc(0.0);
}
if(ObjectUtils.isEmpty(entity.getXlLc())){
entity.setXlLc(0.0);
}
//修改实体
int resultInt = this.baseMapper.updateById(entity);
if(resultInt > 0){
//返回主键
return entity.getId();
}
return null;
}
}

View File

@ -5,16 +5,25 @@ import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.mosty.base.feign.remote.MostyQwzxFeignServiceRemote;
import com.mosty.base.model.dto.qwzx.TbQwXfbbVo;
import com.mosty.base.model.dto.yjzl.TbZdxlFgxlrwUpdateDTO;
import com.mosty.base.model.entity.qwzx.TbQwXfbb;
import com.mosty.base.model.entity.yjzl.zddw.TbZdxlFgdw;
import com.mosty.base.model.entity.yjzl.zddw.TbZdxlFgmrpz;
import com.mosty.base.model.entity.yjzl.zddw.TbZdxlFgxlrw;
import com.mosty.base.model.query.yjzl.TbZdxlFgxlrwQuery;
import com.mosty.base.model.vo.yjzl.TbZdxlFgdwBddxlrwVO;
import com.mosty.base.model.vo.yjzl.TbZdxlFgxlrwVO;
import com.mosty.base.utils.Constant;
import com.mosty.base.utils.MathUtils;
import com.mosty.base.utils.PageUtils;
import com.mosty.base.utils.QueryWrapperUtils;
import com.mosty.common.base.util.StringUtils;
import com.mosty.yjzl.mapper.TbZdxlFgxlrwMapper;
import com.mosty.yjzl.service.TbZdxlFgdwBddxlrwService;
import com.mosty.yjzl.service.TbZdxlFgdwService;
import com.mosty.yjzl.service.TbZdxlFgmrpzService;
import com.mosty.yjzl.service.TbZdxlFgxlrwService;
import com.mosty.yjzl.utils.TbZdxlFgxlrwUtils;
import lombok.AllArgsConstructor;
@ -24,8 +33,10 @@ import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Date;
import java.util.List;
import java.util.stream.Collectors;
/**
* @author zhangzhao
@ -43,6 +54,16 @@ public class TbZdxlFgxlrwServiceImpl extends ServiceImpl<TbZdxlFgxlrwMapper, TbZ
*/
private final TbZdxlFgdwService tbZdxlFgdwService;
/**
* 指导巡逻方格默认配置表Service
*/
private final TbZdxlFgmrpzService tbZdxlFgmrpzService;
/**
* 指导巡逻方格点位必到点巡逻任务表Service
*/
private final TbZdxlFgdwBddxlrwService tbZdxlFgdwBddxlrwService;
@Override
public TbZdxlFgxlrw selectById(String id) {
if(StringUtils.isBlank(id)){
@ -82,6 +103,43 @@ public class TbZdxlFgxlrwServiceImpl extends ServiceImpl<TbZdxlFgxlrwMapper, TbZ
return resultPage;
}
@Override
public IPage<TbZdxlFgxlrwVO> selectRwPage(TbZdxlFgxlrwQuery query) {
IPage<TbZdxlFgxlrw> page = PageUtils.buildPage(query.getPageSize(), query.getPageCurrent());
QueryWrapper<TbZdxlFgxlrw> qw = new QueryWrapper<>();
//组装查询参数
this.buildListSelectQueryWrapper(qw, query);
//组装本人所在巡组需要打卡或者没有指定巡组的任务
qw.and(qw1 -> {
TbQwXfbb xfbb = MostyQwzxFeignServiceRemote.getMyXfbbTodayNew(null);
if(ObjectUtils.isNotEmpty(xfbb)){
qw1.eq(TbZdxlFgxlrw.XFBB_ID_FIELD, xfbb.getId()).or();
}
//组装其他需要打卡的任务
qw1.isNull(TbZdxlFgxlrw.XFBB_ID_FIELD);
});
//返回Page
IPage<TbZdxlFgxlrwVO> resultPage = new Page<>(query.getPageCurrent(), query.getPageSize());
//查询数据
page = this.baseMapper.selectPage(page, qw);
List<TbZdxlFgxlrw> list = page.getRecords();
if(CollectionUtils.isEmpty(list)){
return resultPage;
}
//转为VO
List<TbZdxlFgxlrwVO> resultList = this.buildAllInfoListByEntityList(list);
//组装VO
resultPage.setRecords(resultList);
resultPage.setTotal(page.getTotal());
return resultPage;
}
@Override
public List<TbZdxlFgxlrwVO> selectList(TbZdxlFgxlrwQuery query) {
QueryWrapper<TbZdxlFgxlrw> qw = new QueryWrapper<>();
@ -99,6 +157,19 @@ public class TbZdxlFgxlrwServiceImpl extends ServiceImpl<TbZdxlFgxlrwMapper, TbZ
return this.buildAllInfoListByEntityList(list);
}
@Override
public List<TbZdxlFgxlrw> selectListByIds(String ids) {
if(StringUtils.isBlank(ids)){
return null;
}
return this.baseMapper.selectList(new QueryWrapper<TbZdxlFgxlrw>()
.in(TbZdxlFgxlrw.ID_FIELD, Arrays.asList(ids.split(Constant.SEPARATOR_ENGLISH_COMMA)))
.eq("xt_sjzt", "1")
.eq("xt_scbz", "0")
);
}
@Override
public List<TbZdxlFgxlrw> selectListByRwRq(Date rwRq) {
if (ObjectUtils.isEmpty(rwRq)) {
@ -112,6 +183,7 @@ public class TbZdxlFgxlrwServiceImpl extends ServiceImpl<TbZdxlFgxlrwMapper, TbZ
}
@Override
@Transactional(rollbackFor = Exception.class)
public String updateEntity(TbZdxlFgxlrwUpdateDTO dto) {
//复制参数至实体
TbZdxlFgxlrw entity = BeanUtil.copyProperties(dto, TbZdxlFgxlrw.class);
@ -119,6 +191,8 @@ public class TbZdxlFgxlrwServiceImpl extends ServiceImpl<TbZdxlFgxlrwMapper, TbZ
//修改实体
int resultInt = this.baseMapper.updateById(entity);
if(resultInt > 0){
//保存必到点信息
tbZdxlFgdwBddxlrwService.handleList(dto.getBddList());
//返回主键
return entity.getId();
}
@ -157,11 +231,27 @@ public class TbZdxlFgxlrwServiceImpl extends ServiceImpl<TbZdxlFgxlrwMapper, TbZ
return -1;
}
//查询默认配置
TbZdxlFgmrpz mrpz = tbZdxlFgmrpzService.selectDefault();
if(ObjectUtils.isEmpty(mrpz)){
mrpz = new TbZdxlFgmrpz();
mrpz.setPcCl(0);
mrpz.setPcRy(0);
mrpz.setXlSc(0.0);
mrpz.setXlLc(0.0);
}
//筛选保存和修改列表
List<TbZdxlFgxlrw> saveList = new ArrayList<>(), updateList = new ArrayList<>();
for(TbZdxlFgxlrw entity : entityList){
TbZdxlFgxlrw baseEntity = this.selectById(entity.getId());
if(ObjectUtils.isEmpty(baseEntity)){
//设置默认值
entity.setXlghSc(mrpz.getXlSc());
entity.setXlghXllc(mrpz.getXlLc());
entity.setXlghPcCl(mrpz.getPcCl());
entity.setXlghPcRy(mrpz.getPcRy());
//保存
saveList.add(entity);
}else{
@ -191,6 +281,31 @@ public class TbZdxlFgxlrwServiceImpl extends ServiceImpl<TbZdxlFgxlrwMapper, TbZ
return resultInt;
}
@Override
@Transactional(rollbackFor = Exception.class)
public int issueList(List<TbZdxlFgxlrw> entityList) {
if(CollectionUtils.isEmpty(entityList)){
return -1;
}
List<TbZdxlFgxlrw> updateList = new ArrayList<>();
for(TbZdxlFgxlrw entity : entityList){
TbZdxlFgxlrw updateEntity = new TbZdxlFgxlrw();
updateEntity.setId(entity.getId());
updateEntity.setRwZt(TbZdxlFgxlrwUtils.DICT_ITEM_D_ZDXL_FGXLRW_RWZT_YXF);
updateList.add(updateEntity);
}
boolean success = this.updateBatchById(updateList);
if(success){
//再保存一次打卡点信息
tbZdxlFgdwBddxlrwService.handleListByFgxlrwList(entityList);
//返回
return updateList.size();
}
return 0;
}
/**
* 组装查询参数
* @param qw QueryWrapper
@ -208,6 +323,13 @@ public class TbZdxlFgxlrwServiceImpl extends ServiceImpl<TbZdxlFgxlrwMapper, TbZ
qw.eq("xt_sjzt", "1").eq("xt_scbz", "0");
//方格ID
qw.eq(ObjectUtils.isNotEmpty(query.getFgId()), TbZdxlFgxlrw.FG_ID_FIELD, query.getFgId());
//方格名称
qw.inSql(StringUtils.isNotBlank(query.getFgMc()), TbZdxlFgxlrw.FG_ID_FIELD, "select id from tb_zdxl_fgdw where mc1 like '%" + query.getFgMc() + "%' ");
//方格预警等级
if(StringUtils.isNotBlank(query.getFgYjdj())){
qw.in(TbZdxlFgxlrw.FG_YJDJ_FIELD, Arrays.stream(query.getFgYjdj().split(",")).filter(org.apache.commons.lang3.StringUtils::isNotBlank).collect(Collectors.toList()));
}
//任务日期
qw.eq(ObjectUtils.isNotEmpty(query.getRwRq()), TbZdxlFgxlrw.RW_RQ_FIELD, query.getRwRq());
}
@ -239,11 +361,11 @@ public class TbZdxlFgxlrwServiceImpl extends ServiceImpl<TbZdxlFgxlrwMapper, TbZ
private TbZdxlFgxlrwVO buildAllInfoByEntity(TbZdxlFgxlrw entity){
TbZdxlFgxlrwVO resultVO = BeanUtil.copyProperties(entity, TbZdxlFgxlrwVO.class);
//组装方格数据
if(ObjectUtils.isNotEmpty(resultVO.getFgId())){
//组装方格数据
TbZdxlFgdw fg = tbZdxlFgdwService.selectById(resultVO.getFgId());
if(ObjectUtils.isNotEmpty(fg)){
resultVO.setMc(fg.getMc1());
resultVO.setFgMc(fg.getMc1());
resultVO.setX1(fg.getX11());
resultVO.setY1(fg.getY11());
resultVO.setX2(fg.getX21());
@ -251,6 +373,30 @@ public class TbZdxlFgxlrwServiceImpl extends ServiceImpl<TbZdxlFgxlrwMapper, TbZ
resultVO.setZxX(fg.getZxX());
resultVO.setZxY(fg.getZxY());
}
//组装必到点信息
List<TbZdxlFgdwBddxlrwVO> bddList;
if(TbZdxlFgxlrwUtils.DICT_ITEM_D_ZDXL_FGXLRW_RWZT_CJ.equals(resultVO.getRwZt()) || TbZdxlFgxlrwUtils.DICT_ITEM_D_ZDXL_FGXLRW_RWZT_YDC.equals(resultVO.getRwZt())){
//未下发查询实时必到点
bddList = tbZdxlFgdwBddxlrwService.selectVoListByFgxlrwId(resultVO.getId());
}else{
//已下发查询固定必到点
bddList = tbZdxlFgdwBddxlrwService.selectVoListByYxfFgxlrwId(resultVO.getId());
}
if(CollectionUtils.isNotEmpty(bddList)){
int totalGhCs = bddList.stream().mapToInt(TbZdxlFgdwBddxlrwVO::getXlghDkcs).sum();
int totalSjCs = bddList.stream().mapToInt(TbZdxlFgdwBddxlrwVO::getXlsjDkcs).sum();
resultVO.setBddAllProgress(MathUtils.percentage(totalSjCs, totalGhCs));
resultVO.setBddList(bddList);
}
}
//组装巡防报备信息
if(StringUtils.isNotBlank(resultVO.getXfbbId())){
TbQwXfbbVo xfbb = MostyQwzxFeignServiceRemote.getXfbbInfo(resultVO.getXfbbId());
if(ObjectUtils.isNotEmpty(xfbb)){
resultVO.setXfbb(xfbb);
}
}
return resultVO;

View File

@ -0,0 +1,84 @@
package com.mosty.yjzl.service;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.mosty.base.model.dto.yjzl.TbZdxlFgdwBddSaveDTO;
import com.mosty.base.model.dto.yjzl.TbZdxlFgdwBddUpdateDTO;
import com.mosty.base.model.entity.yjzl.zddw.TbZdxlFgdwBdd;
import com.mosty.base.model.query.yjzl.TbZdxlFgdwBddQuery;
import com.mosty.base.model.vo.yjzl.TbZdxlFgdwBddVO;
import java.util.List;
/**
* @author zhangzhao
* @description 指导巡逻方格点位必到点表Service
* @modifier zhangzhao
* @modifiedTime 2025/09/06 12:01
* @since 2025/09/06 12:01
*/
public interface TbZdxlFgdwBddService {
/**
* 查询单条根据主键ID
* @param id 主键ID
* @return 实体信息
*/
TbZdxlFgdwBdd selectById(String id);
/**
* 查询分页
* @param query 实体查询对象
* @return 实体信息分页列表
*/
IPage<TbZdxlFgdwBddVO> selectPage(TbZdxlFgdwBddQuery query);
/**
* 查询列表
* @param query 实体查询对象
* @return 实体信息列表
*/
List<TbZdxlFgdwBddVO> selectList(TbZdxlFgdwBddQuery query);
/**
* 查询列表根据ID列表
* @param idList ID列表
* @return 实体信息列表
*/
List<TbZdxlFgdwBdd> selectListByIdList(List<String> idList);
/**
* 查询列表根据方格点位ID
* @param fgdwId 方格点位ID
* @return 实体信息列表
*/
List<TbZdxlFgdwBdd> selectListByFgdwId(Long fgdwId);
/**
* 查询列表根据方格巡逻任务ID
* @param fgxlrwId 方格巡逻任务ID
* @return 实体信息列表
*/
List<TbZdxlFgdwBdd> selectListByFgxlrwId(String fgxlrwId);
/**
* 保存单条
* @param dto 保存DTO对象
* @return 实体主键ID
*/
String saveEntity(TbZdxlFgdwBddSaveDTO dto);
/**
* 修改单条
* @param dto 修改DTO对象
* @return 实体主键ID
*/
String updateEntity(TbZdxlFgdwBddUpdateDTO dto);
/**
* 注销单条
* @param entity 实体信息
* @return 注销条数
*/
int cancelEntity(TbZdxlFgdwBdd entity);
}

View File

@ -0,0 +1,58 @@
package com.mosty.yjzl.service;
import com.mosty.base.model.dto.yjzl.TbZdxlFgdwBddxlrwJlClockInDTO;
import com.mosty.base.model.entity.yjzl.zddw.TbZdxlFgdwBddxlrwJl;
import com.mosty.common.token.UserInfo;
import java.util.Date;
import java.util.List;
/**
* @author zhangzhao
* @description 指导巡逻方格点位必到点巡逻任务记录表Service
* @modifier zhangzhao
* @modifiedTime 2025/09/07 19:56
* @since 2025/09/07 19:56
*/
public interface TbZdxlFgdwBddxlrwJlService {
/**
* 查询单条根据主键ID
* @param id 主键ID
* @return 实体信息
*/
TbZdxlFgdwBddxlrwJl selectById(String id);
/**
* 查询单条根据必到点巡逻任务ID和顺序
* @param bddxlrwId 必到点巡逻任务ID
* @param dkSx 顺序
* @return 实体信息
*/
TbZdxlFgdwBddxlrwJl selectByBddxlrwIdAndDkSx(String bddxlrwId, int dkSx);
/**
* 查询列表根据必到点巡逻任务ID
* @param bddxlrwId 必到点巡逻任务ID
* @return 实体列表
*/
List<TbZdxlFgdwBddxlrwJl> selectListByBddxlrwId(String bddxlrwId);
/**
* 创建列表根据方格巡逻任务ID
* @param fgxlrwId 方格巡逻任务ID
* @return 操作条数
*/
int createListByFgxlrwId(String fgxlrwId);
/**
* 打卡
* @param baseEntity 实体信息
* @param dto 打卡DTO对象
* @param user 当前登录人员信息
* @param dksj 打卡时间
* @return 主键ID
*/
String clockIn(TbZdxlFgdwBddxlrwJl baseEntity, TbZdxlFgdwBddxlrwJlClockInDTO dto, UserInfo user, Date dksj);
}

View File

@ -0,0 +1,70 @@
package com.mosty.yjzl.service;
import com.mosty.base.model.dto.yjzl.TbZdxlFgdwBddxlrwHandleDTO;
import com.mosty.base.model.entity.yjzl.zddw.TbZdxlFgdwBddxlrw;
import com.mosty.base.model.entity.yjzl.zddw.TbZdxlFgdwBddxlrwJl;
import com.mosty.base.model.entity.yjzl.zddw.TbZdxlFgxlrw;
import com.mosty.base.model.vo.yjzl.TbZdxlFgdwBddxlrwVO;
import java.util.List;
/**
* @author zhangzhao
* @description 指导巡逻方格点位必到点巡逻任务表Service
* @modifier zhangzhao
* @modifiedTime 2025/09/06 19:43
* @since 2025/09/06 19:43
*/
public interface TbZdxlFgdwBddxlrwService {
/**
* 查询单条根据主键ID
* @param id 主键ID
* @return 实体信息
*/
TbZdxlFgdwBddxlrw selectById(String id);
/**
* 查询列表根据方格巡逻任务ID
* @param fgxlrwId 方格巡逻任务ID
* @return 实体信息列表
*/
List<TbZdxlFgdwBddxlrw> selectListByFgxlrwId(String fgxlrwId);
/**
* 查询返回信息列表根据方格巡逻任务ID
* @param fgxlrwId 方格巡逻任务ID
* @return 返回信息列表
*/
List<TbZdxlFgdwBddxlrwVO> selectVoListByYxfFgxlrwId(String fgxlrwId);
/**
* 查询返回信息列表根据方格巡逻任务ID
* @param fgxlrwId 方格巡逻任务ID
* @return 返回信息列表
*/
List<TbZdxlFgdwBddxlrwVO> selectVoListByFgxlrwId(String fgxlrwId);
/**
* 保存列表
* @param handleList 操作列表
* @return 操作条数
*/
int handleList(List<TbZdxlFgdwBddxlrwHandleDTO> handleList);
/**
* 保存列表(根据方格巡逻任务列表)
* @param fgxlrwList 方格巡逻任务列表
* @return 操作条数
*/
int handleListByFgxlrwList(List<TbZdxlFgxlrw> fgxlrwList);
/**
* 打卡(根据打卡记录)
* @param jl 打卡记录
* @param start 是否是开始打卡
* @return 主键ID
*/
String clockInByJl(TbZdxlFgdwBddxlrwJl jl, boolean start);
}

View File

@ -1,7 +1,8 @@
package com.mosty.yjzl.service;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.mosty.base.model.dto.yjzl.TbZdxlFgdwUpdateDTO;
import com.mosty.base.model.entity.yjzl.zddw.TbZdxlFgdw;
import com.mosty.base.model.query.yjzl.TbZdxlFgdwQuery;
import com.mosty.base.model.vo.yjzl.TbZdxlFgdwVO;
import java.util.List;
@ -20,7 +21,7 @@ public interface TbZdxlFgdwService {
* @param id 主键ID
* @return 实体信息
*/
TbZdxlFgdwVO selectById(Integer id);
TbZdxlFgdwVO selectById(Long id);
/**
* 查询全量列表
@ -29,17 +30,24 @@ public interface TbZdxlFgdwService {
List<TbZdxlFgdwVO> selectAllList();
/**
* 保存列表(根据生成数据)
* @param saveList 生成数据列表
* @return 保存数量
* 查询分页
* @param query 实体查询对象
* @return 实体信息分页列表
*/
int saveListByGenerate(List<TbZdxlFgdw> saveList, String firstMc);
IPage<TbZdxlFgdwVO> selectPage(TbZdxlFgdwQuery query);
/**
* 查询列表
* @param query 实体查询对象
* @return 实体信息列表
*/
List<TbZdxlFgdwVO> selectList(TbZdxlFgdwQuery query);
/**
* 修改单条
* @param dto 修改DTO对象
* @return 实体主键ID
*/
Integer updateEntity(TbZdxlFgdwUpdateDTO dto);
Long updateEntity(TbZdxlFgdwUpdateDTO dto);
}

View File

@ -0,0 +1,29 @@
package com.mosty.yjzl.service;
import com.mosty.base.model.dto.yjzl.TbZdxlFgdwUpdateDTO;
import com.mosty.base.model.dto.yjzl.TbZdxlFgmrpzUpdateDTO;
import com.mosty.base.model.entity.yjzl.zddw.TbZdxlFgmrpz;
/**
* @author zhangzhao
* @description 指导巡逻方格默认配置表Service
* @modifier zhangzhao
* @modifiedTime 2025/09/05 19:00
* @since 2025/09/05 19:00
*/
public interface TbZdxlFgmrpzService {
/**
* 查询单条(默认数据)
* @return 实体信息
*/
TbZdxlFgmrpz selectDefault();
/**
* 修改单条
* @param dto 修改DTO对象
* @return 实体主键ID
*/
String updateEntity(TbZdxlFgmrpzUpdateDTO dto);
}

View File

@ -32,6 +32,13 @@ public interface TbZdxlFgxlrwService {
*/
IPage<TbZdxlFgxlrwVO> selectPage(TbZdxlFgxlrwQuery query);
/**
* 查询分页(需要执行的任务)
* @param query 实体查询对象
* @return 实体返回信息分页列表
*/
IPage<TbZdxlFgxlrwVO> selectRwPage(TbZdxlFgxlrwQuery query);
/**
* 查询列表
* @param query 实体查询对象
@ -39,6 +46,13 @@ public interface TbZdxlFgxlrwService {
*/
List<TbZdxlFgxlrwVO> selectList(TbZdxlFgxlrwQuery query);
/**
* 查询列表根据主键ID字符串
* @param ids 主键ID字符串
* @return 实体返回信息列表
*/
List<TbZdxlFgxlrw> selectListByIds(String ids);
/**
* 查询列表(根据任务日期)
* @param rwRq 任务日期
@ -67,4 +81,11 @@ public interface TbZdxlFgxlrwService {
*/
int importListByMb(List<TbZdxlFgxlrw> entityList);
/**
* 下发列表
* @param entityList 需下发的列表
* @return 操作条数
*/
int issueList(List<TbZdxlFgxlrw> entityList);
}

View File

@ -109,6 +109,11 @@ public class TbZdxlFgxlrwUtils {
*/
public final static String DICT_ITEM_D_ZDXL_FGXLRW_RWZT_YDC = "02";
/**
* 字典项-指导巡逻方格巡逻任务状态-已下发
*/
public final static String DICT_ITEM_D_ZDXL_FGXLRW_RWZT_YXF = "03";
/**
* 系统配置配置键-方格巡逻任务警情配置-报警细类
*/

View File

@ -42,6 +42,9 @@ spring:
jedis:
pool:
max-active: 50
messages:
basename: i18n/messages
encoding: utf-8
swagger:
host: 80.155.0.84