合并代码
This commit is contained in:
@ -0,0 +1,161 @@
|
||||
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.TbZdxlFgxlrwUpdateDTO;
|
||||
import com.mosty.base.model.entity.yjzl.zddw.TbZdxlFgxlrw;
|
||||
import com.mosty.base.model.query.yjzl.TbZdxlFgxlrwQuery;
|
||||
import com.mosty.base.model.vo.yjzl.TbZdxlFgxlrwVO;
|
||||
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.config.Excel.ExcelUtil;
|
||||
import com.mosty.common.token.JwtSysUser;
|
||||
import com.mosty.yjzl.service.TbZdxlFgxlrwService;
|
||||
import io.swagger.annotations.Api;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import lombok.AllArgsConstructor;
|
||||
import org.apache.commons.collections4.CollectionUtils;
|
||||
import org.springframework.validation.BindingResult;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
import org.springframework.web.multipart.MultipartFile;
|
||||
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import javax.validation.Valid;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @author zhangzhao
|
||||
* @description 指导巡逻方格巡逻任务接口
|
||||
* @modifier zhangzhao
|
||||
* @modifiedTime 2025/05/10 21:52
|
||||
* @since 2025/05/10 21:52
|
||||
*/
|
||||
@Api(tags = {"指导巡逻-方格巡逻任务接口"})
|
||||
@RestController
|
||||
@AllArgsConstructor
|
||||
@RequestMapping("/tbZdxlFgxlrw")
|
||||
public class TbZdxlFgxlrwController {
|
||||
|
||||
/**
|
||||
* 指导巡逻方格巡逻任务表Service
|
||||
*/
|
||||
private final TbZdxlFgxlrwService tbZdxlFgxlrwService;
|
||||
|
||||
/**
|
||||
* 查询分页
|
||||
* @param query 实体查询对象
|
||||
* @return ResponseResult 实体返回信息分页列表
|
||||
*/
|
||||
@ApiOperation(value = "查询分页")
|
||||
@GetMapping("/selectPage")
|
||||
@JwtSysUser
|
||||
@Log(title = "指导巡逻-方格巡逻任务接口-查询分页", businessType = BusinessType.OTHER)
|
||||
public ResponseResult<IPage<TbZdxlFgxlrwVO>> selectPage(TbZdxlFgxlrwQuery query) {
|
||||
return ResponseResult.success(tbZdxlFgxlrwService.selectPage(query));
|
||||
}
|
||||
|
||||
/**
|
||||
* 查询列表
|
||||
* @param query 实体查询对象
|
||||
* @return ResponseResult 实体返回信息列表
|
||||
*/
|
||||
@ApiOperation(value = "查询列表")
|
||||
@GetMapping("/selectList")
|
||||
@JwtSysUser
|
||||
@Log(title = "指导巡逻-方格巡逻任务接口-查询列表", businessType = BusinessType.OTHER)
|
||||
public ResponseResult<List<TbZdxlFgxlrwVO>> selectList(TbZdxlFgxlrwQuery query) {
|
||||
return ResponseResult.success(tbZdxlFgxlrwService.selectList(query));
|
||||
}
|
||||
|
||||
/**
|
||||
* 修改单条
|
||||
* @param dto 修改DTO对象
|
||||
* @param bindResult 校验对象
|
||||
* @return ResponseResult 实体主键ID
|
||||
*/
|
||||
@ApiOperation(value = "修改单条")
|
||||
@PostMapping("update")
|
||||
@JwtSysUser
|
||||
@Log(title = "指导巡逻-方格巡逻任务接口-修改单条", businessType = BusinessType.UPDATE)
|
||||
public ResponseResult<String> update(@RequestBody @Valid TbZdxlFgxlrwUpdateDTO dto, BindingResult bindResult){
|
||||
try {
|
||||
//基础信息校验
|
||||
String message = SpringValidUtils.getErrorsMsg(bindResult);
|
||||
if (StringUtils.isNotBlank(message)) {
|
||||
return ResponseResult.fail(MessageUtils.getEditFailMsg() + message);
|
||||
}
|
||||
|
||||
//修改
|
||||
String resultId = tbZdxlFgxlrwService.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 response 返回体
|
||||
* @param dto 任务日期DTO
|
||||
* @param bindResult 校验对象
|
||||
*/
|
||||
@PostMapping("/exportByRwRq")
|
||||
@ApiOperation("导出任务(根据任务日期)")
|
||||
@Log(title = "指导巡逻-方格巡逻任务接口-导出任务(根据任务日期)", businessType = BusinessType.OTHER)
|
||||
public void exportByRwRq(HttpServletResponse response, @RequestBody @Valid TbZdxlFgxlrwCreateDTO dto, BindingResult bindResult) {
|
||||
try {
|
||||
//基础信息校验
|
||||
String message = SpringValidUtils.getErrorsMsg(bindResult);
|
||||
if (StringUtils.isNotBlank(message)) {
|
||||
System.out.println(MessageUtils.getExportFailMsg() + message);
|
||||
}
|
||||
|
||||
//查询列表
|
||||
List<TbZdxlFgxlrw> baseList = tbZdxlFgxlrwService.selectListByRwRq(dto.getRwRq());
|
||||
if(CollectionUtils.isEmpty(baseList)){
|
||||
System.out.println(MessageUtils.getExportFailMsg() + MessageUtils.message("zdxl.fgxlrw.rwRq.export.queryNull"));
|
||||
}else{
|
||||
tbZdxlFgxlrwService.updateListRwZtToYdc(baseList);
|
||||
ExcelUtil<TbZdxlFgxlrw> util = new ExcelUtil<>(TbZdxlFgxlrw.class);
|
||||
util.exportExcel(response, baseList, "任务列表", "方格巡逻任务");
|
||||
System.out.println(baseList.size() + "");
|
||||
}
|
||||
} catch (Exception e) {
|
||||
System.out.println(MessageUtils.getExportServerErrorMsg());
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 导入列表(根据导出的模板)
|
||||
* @param file 导入文件
|
||||
* @return ResponseResult 导入条数
|
||||
*/
|
||||
@ApiOperation(value = "导入列表(根据导出的模板)")
|
||||
@PostMapping("/importListByMb")
|
||||
@JwtSysUser
|
||||
@Log(title = "指导巡逻-方格巡逻任务接口-导入列表(根据导出的模板)", businessType = BusinessType.IMPORT)
|
||||
public ResponseResult<Integer> importListByMb(MultipartFile file) {
|
||||
try {
|
||||
ExcelUtil<TbZdxlFgxlrw> util = new ExcelUtil<>(TbZdxlFgxlrw.class);
|
||||
List<TbZdxlFgxlrw> fgxlrwList = util.importExcel(file.getInputStream());
|
||||
if(CollectionUtils.isEmpty(fgxlrwList)){
|
||||
int resultInt = tbZdxlFgxlrwService.importListByMb(fgxlrwList);
|
||||
if(resultInt > 0){
|
||||
return ResponseResult.success(resultInt);
|
||||
}
|
||||
}
|
||||
return ResponseResult.fail(MessageUtils.getImportFailMsg());
|
||||
} catch (Exception e) {
|
||||
return ResponseResult.fail(MessageUtils.getImportServerErrorMsg());
|
||||
}
|
||||
}
|
||||
|
||||
}
|
Reference in New Issue
Block a user