2024-07-30 17:24:38 +08:00
|
|
|
|
package com.whdc.controller;
|
|
|
|
|
|
|
|
|
|
|
|
import com.baomidou.mybatisplus.core.metadata.IPage;
|
|
|
|
|
|
import com.baomidou.mybatisplus.extension.conditions.query.LambdaQueryChainWrapper;
|
|
|
|
|
|
import com.whdc.exception.MyException;
|
2024-07-31 13:26:01 +08:00
|
|
|
|
import com.whdc.model.dto.ShAddressBookDto;
|
2024-07-30 17:24:38 +08:00
|
|
|
|
import com.whdc.model.dto.ShCallsDto;
|
|
|
|
|
|
import com.whdc.model.entity.ShAddressBook;
|
|
|
|
|
|
import com.whdc.model.entity.ShCallWord;
|
|
|
|
|
|
import com.whdc.model.entity.ShCalls;
|
|
|
|
|
|
import com.whdc.model.group.Insert;
|
2024-07-31 13:26:01 +08:00
|
|
|
|
import com.whdc.model.vo.ShCallsVo;
|
2024-07-30 17:24:38 +08:00
|
|
|
|
import com.whdc.service.ShAddressBookService;
|
|
|
|
|
|
import com.whdc.service.ShCallsService;
|
2024-07-31 13:26:01 +08:00
|
|
|
|
import com.whdc.utils.DateUtils;
|
|
|
|
|
|
import com.whdc.utils.ExcelCommon;
|
2024-07-30 17:24:38 +08:00
|
|
|
|
import com.whdc.utils.ResultJson;
|
2024-07-31 17:55:05 +08:00
|
|
|
|
import io.swagger.annotations.Api;
|
|
|
|
|
|
import io.swagger.annotations.ApiOperation;
|
2024-07-30 17:24:38 +08:00
|
|
|
|
import org.apache.commons.lang3.StringUtils;
|
|
|
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
|
|
|
import org.springframework.validation.annotation.Validated;
|
|
|
|
|
|
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;
|
|
|
|
|
|
|
2024-07-31 13:26:01 +08:00
|
|
|
|
import javax.servlet.http.HttpServletResponse;
|
|
|
|
|
|
import java.time.format.DateTimeFormatter;
|
2024-07-30 17:24:38 +08:00
|
|
|
|
import java.util.Date;
|
|
|
|
|
|
import java.util.List;
|
|
|
|
|
|
import java.util.Objects;
|
2024-07-31 13:26:01 +08:00
|
|
|
|
import java.util.stream.Collectors;
|
2024-07-30 17:24:38 +08:00
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
|
* 描述: 抽查日志
|
|
|
|
|
|
* author: xusan
|
|
|
|
|
|
* date: 2024-07-29 17:27:25
|
|
|
|
|
|
*/
|
2024-07-31 17:55:05 +08:00
|
|
|
|
@Api(tags = "抽查日志")
|
2024-07-30 17:24:38 +08:00
|
|
|
|
@RestController
|
|
|
|
|
|
@RequestMapping(value="/shCalls")
|
|
|
|
|
|
public class ShCallsController {
|
|
|
|
|
|
|
|
|
|
|
|
@Autowired
|
|
|
|
|
|
private ShCallsService service;
|
|
|
|
|
|
|
|
|
|
|
|
@Autowired
|
|
|
|
|
|
private ShAddressBookService shAddressBookService;
|
|
|
|
|
|
|
|
|
|
|
|
|
2024-07-31 17:55:05 +08:00
|
|
|
|
@ApiOperation(value = "新增")
|
2024-07-30 17:24:38 +08:00
|
|
|
|
@PostMapping("/insert")
|
|
|
|
|
|
public ResultJson<ShCallWord> insert(@Validated(Insert.class) @RequestBody ShCalls dto) {
|
|
|
|
|
|
if (shAddressBookService.lambdaQuery().eq(ShAddressBook::getId, dto.getShAbId()).count() != 1){
|
|
|
|
|
|
throw new MyException("当前通讯录不存在");
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
if (StringUtils.isNotBlank(dto.getStatus()) && "0".equals(dto.getCallType())){
|
|
|
|
|
|
boolean update = shAddressBookService.lambdaUpdate()
|
|
|
|
|
|
.set(ShAddressBook::getCallStatus, dto.getCallType())
|
|
|
|
|
|
.eq(ShAddressBook::getId, dto.getShAbId())
|
|
|
|
|
|
.update();
|
|
|
|
|
|
if (!update){
|
|
|
|
|
|
throw new MyException("更新通讯录状态失败");
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
boolean result = service.save(dto);
|
|
|
|
|
|
return ResultJson.ok(result ? dto : null);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2024-07-31 17:55:05 +08:00
|
|
|
|
@ApiOperation(value = "列表")
|
2024-07-30 17:24:38 +08:00
|
|
|
|
@PostMapping("/list")
|
|
|
|
|
|
public ResultJson<List<ShCalls>> list(@RequestBody ShCallsDto dto) {
|
|
|
|
|
|
LambdaQueryChainWrapper<ShCalls> query = service.lambdaQuery();
|
|
|
|
|
|
if (Objects.nonNull(dto.getDate())){
|
|
|
|
|
|
|
|
|
|
|
|
query.between(ShCalls::getCallTime, dto.getDate() + " 00:00:00",dto.getDate() + " 23:59:59");
|
|
|
|
|
|
}
|
|
|
|
|
|
if (Objects.nonNull(dto.getShAbId())){
|
|
|
|
|
|
query.eq(ShCalls::getShAbId, dto.getShAbId());
|
|
|
|
|
|
}else{
|
2024-07-31 17:55:05 +08:00
|
|
|
|
throw new MyException("山洪通讯录编号不能为空");
|
2024-07-30 17:24:38 +08:00
|
|
|
|
}
|
|
|
|
|
|
return ResultJson.ok(query.list());
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2024-07-31 17:55:05 +08:00
|
|
|
|
@ApiOperation(value = "抽查日志分页")
|
2024-07-31 13:26:01 +08:00
|
|
|
|
@PostMapping("/page")
|
|
|
|
|
|
public ResultJson<IPage<ShCallsVo>> page(@RequestBody ShCallsDto dto) {
|
2024-07-30 17:24:38 +08:00
|
|
|
|
return ResultJson.ok(service.page(dto));
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2024-07-31 17:55:05 +08:00
|
|
|
|
@ApiOperation(value = "综述")
|
2024-07-31 13:26:01 +08:00
|
|
|
|
@PostMapping("/statistics")
|
|
|
|
|
|
public ResultJson<String> statistics(@RequestBody ShCallsDto dto) {
|
|
|
|
|
|
|
|
|
|
|
|
List<ShCallsVo> list = service.list(dto);
|
|
|
|
|
|
|
|
|
|
|
|
String dateStr = dto.getDate().format(DateTimeFormatter.ofPattern(DateUtils.DATE_PATTERN));
|
|
|
|
|
|
List<String> citys = list.stream().map(ShCallsVo::getCity).distinct().collect(Collectors.toList());
|
|
|
|
|
|
List<String> countys = list.stream().map(ShCallsVo::getCounty).distinct().collect(Collectors.toList());
|
|
|
|
|
|
|
|
|
|
|
|
return ResultJson.ok(String.format("%%抽查了%%个市(%%)%%个县(%%)县乡村山洪灾害防御责任人和包保责任人共计%%人。",
|
|
|
|
|
|
dateStr,
|
|
|
|
|
|
citys.size(),
|
|
|
|
|
|
StringUtils.join(citys, ","),
|
|
|
|
|
|
countys.size(),
|
|
|
|
|
|
StringUtils.join(countys, ","),
|
|
|
|
|
|
list.stream().map(ShCallsVo::getPhone).distinct().count()
|
|
|
|
|
|
));
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2024-07-31 17:55:05 +08:00
|
|
|
|
@ApiOperation(value = "抽查日志导出(未完成)")
|
2024-07-31 13:26:01 +08:00
|
|
|
|
@PostMapping("/export")
|
|
|
|
|
|
public void export(@RequestBody ShAddressBookDto dto, HttpServletResponse response) {
|
2024-07-30 17:24:38 +08:00
|
|
|
|
|
|
|
|
|
|
LambdaQueryChainWrapper<ShCalls> query = service.lambdaQuery();
|
2024-07-31 13:26:01 +08:00
|
|
|
|
|
|
|
|
|
|
query.orderByDesc(ShCalls::getCallTime);
|
|
|
|
|
|
|
|
|
|
|
|
List<ShCalls> list = service.list(query);
|
|
|
|
|
|
|
|
|
|
|
|
ExcelCommon.exportExcel(list,
|
|
|
|
|
|
null, "抽查日志", ShCalls.class, "抽查日志.xlsx",
|
|
|
|
|
|
response);
|
2024-07-30 17:24:38 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|