增加责任人抽查批量匹配相关接口

master
cxw 2025-07-17 15:13:18 +08:00
parent bc4bc1c96b
commit 6ff12c4931
9 changed files with 178 additions and 5 deletions

View File

@ -7,6 +7,7 @@ import com.whdc.model.dto.ShAddressBookDto;
import com.whdc.model.entity.ShAddressBook; import com.whdc.model.entity.ShAddressBook;
import com.whdc.model.group.Update; import com.whdc.model.group.Update;
import com.whdc.model.vo.AdcdTree; import com.whdc.model.vo.AdcdTree;
import com.whdc.model.vo.ShAddressBookVo;
import com.whdc.service.ShAddressBookService; import com.whdc.service.ShAddressBookService;
import com.whdc.utils.ExcelCommon; import com.whdc.utils.ExcelCommon;
import com.whdc.utils.ResultJson; import com.whdc.utils.ResultJson;
@ -24,6 +25,7 @@ import org.springframework.web.multipart.MultipartFile;
import javax.servlet.http.HttpServletResponse; import javax.servlet.http.HttpServletResponse;
import javax.validation.constraints.Pattern; import javax.validation.constraints.Pattern;
import java.util.List; import java.util.List;
import java.util.Map;
import java.util.Objects; import java.util.Objects;
import java.util.concurrent.atomic.AtomicInteger; import java.util.concurrent.atomic.AtomicInteger;
import java.util.stream.Collectors; import java.util.stream.Collectors;
@ -303,4 +305,22 @@ public class ShAddressBookController {
} }
@ApiOperation(value = "抽查责任人批量匹配")
@PostMapping("/importBatchMatch")
public ResultJson importBatchMatch(MultipartFile file) {
List<ShAddressBookVo> shAddressBooks = ExcelCommon.importExcel(file, 0, 1, ShAddressBookVo.class);
if (CollectionUtils.isEmpty(shAddressBooks)) {
throw new MyException("文件解析数据为空");
}
Map<String, Object> map = service.importBatchMatch(shAddressBooks);
return ResultJson.ok(map);
}
@ApiOperation(value = "下载批量匹配模板")
@GetMapping("/downloadMatchTemplate")
public void downloadMatchTemplate(HttpServletResponse response) {
ExcelCommon.exportExcel(Lists.newArrayList(), null, "责任人", ShAddressBookVo.class, "责任人批量匹配模板.xlsx", response);
}
} }

View File

@ -211,5 +211,13 @@ public class ShCallsController {
response); response);
} }
@ApiOperation(value = "日志日期统计")
@PostMapping("/logDateStatistics")
public ResultJson<Map<String, Long>> logDateStatistics(@RequestBody @Validated ShCallsDto dto) {
if (StringUtils.isBlank(dto.getStiStartTime()) || StringUtils.isBlank(dto.getStiEndTime())) {
throw new MyException("开始时间和结束时间参数必填!");
}
Map<String, Long> retMap = service.logDateStatistics(dto);
return ResultJson.ok(retMap);
}
} }

View File

@ -35,4 +35,10 @@ public class ShCallsDto extends ShAddressBookDto {
@Schema(description="山洪通讯录编号") @Schema(description="山洪通讯录编号")
private Integer shAbId; private Integer shAbId;
@Schema(description="统计抽查开始日期")
private String stiStartTime;
@Schema(description="统计抽查结束日期")
private String stiEndTime;
} }

View File

@ -0,0 +1,46 @@
package com.whdc.model.vo;
import cn.afterturn.easypoi.excel.annotation.Excel;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;
import java.io.Serializable;
/**
* : Vo
*/
@Schema(description = "山洪责任人通讯录")
@Data
public class ShAddressBookVo implements Serializable {
/**
*
*/
@Schema(description = "县")
@Excel(name = "县", width = 20, orderNum = "1")
private String county;
/**
*
*/
@Schema(description = "乡")
@Excel(name = "乡", width = 20, orderNum = "2")
private String area;
/**
*
*/
@Schema(description = "行政村")
@Excel(name = "行政村", width = 20, orderNum = "3")
private String village;
/**
* ,,, ,
*/
@Schema(description = "责任人类型2 县级,乡级,村级, 县干部,乡干部")
@Excel(name = "责任人类型", width = 20, orderNum = "4")
private String type2;
}

View File

@ -6,8 +6,10 @@ import com.baomidou.mybatisplus.extension.service.IService;
import com.whdc.model.dto.ShAddressBookDto; import com.whdc.model.dto.ShAddressBookDto;
import com.whdc.model.entity.ShAddressBook; import com.whdc.model.entity.ShAddressBook;
import com.whdc.model.vo.AdcdTree; import com.whdc.model.vo.AdcdTree;
import com.whdc.model.vo.ShAddressBookVo;
import java.util.List; import java.util.List;
import java.util.Map;
/** /**
* : * :
@ -21,6 +23,15 @@ public interface ShAddressBookService extends IService<ShAddressBook>
void updateAll(String type1, List<ShAddressBook> appends); void updateAll(String type1, List<ShAddressBook> appends);
List<AdcdTree> tree(); List<AdcdTree> tree();
/**
* @param shAddressBooks
* @description:
* @return: java.util.Map
* @auther: cxw
* @date: 2025-07-14, , 13:11:33
*/
Map<String, Object> importBatchMatch(List<ShAddressBookVo> shAddressBooks);
} }

View File

@ -9,6 +9,7 @@ import com.whdc.model.entity.ShCalls;
import com.whdc.model.vo.ShCallsVo; import com.whdc.model.vo.ShCallsVo;
import java.util.List; import java.util.List;
import java.util.Map;
/** /**
* : * :
@ -23,6 +24,8 @@ public interface ShCallsService extends IService<ShCalls>
List<ShAddressBook> list(ShCallsDto dto); List<ShAddressBook> list(ShCallsDto dto);
List<ShCallsVo> listVo(ShCallsDto dto); List<ShCallsVo> listVo(ShCallsDto dto);
Map<String, Long> logDateStatistics(ShCallsDto dto);
} }

View File

@ -1,12 +1,15 @@
package com.whdc.service.impl; package com.whdc.service.impl;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage; import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.google.common.collect.Maps;
import com.whdc.exception.MyException; import com.whdc.exception.MyException;
import com.whdc.mapper.ShAddressBookMapper; import com.whdc.mapper.ShAddressBookMapper;
import com.whdc.model.dto.ShAddressBookDto; import com.whdc.model.dto.ShAddressBookDto;
import com.whdc.model.entity.ShAddressBook; import com.whdc.model.entity.ShAddressBook;
import com.whdc.model.vo.AdcdTree; import com.whdc.model.vo.AdcdTree;
import com.whdc.model.vo.ShAddressBookVo;
import com.whdc.service.ShAddressBookService; import com.whdc.service.ShAddressBookService;
import org.apache.commons.collections.CollectionUtils; import org.apache.commons.collections.CollectionUtils;
import org.apache.commons.compress.utils.Lists; import org.apache.commons.compress.utils.Lists;
@ -322,4 +325,56 @@ public class ShAddressBookServiceImpl extends ServiceImpl<ShAddressBookMapper, S
return sorteds; return sorteds;
} }
@Override
public Map<String, Object> importBatchMatch(List<ShAddressBookVo> shAddressBooksMatch) {
Map<String, Object> map = Maps.newHashMap();
map.put("ppAllCount", shAddressBooksMatch.size());// 总数
map.put("ppOneList", new ArrayList<>());// 精确匹配
map.put("ppManyRownum", "");// 匹配到多条
map.put("ppZeroRownum", "");// 未匹配到
// 根据区划和责任人类型匹配,返回匹配成功数据和未匹配的信息
List<ShAddressBook> shAddressBooksAll = baseMapper.selectList(new QueryWrapper<ShAddressBook>().eq("DEL", REC));
// 责任人类型分组
Map<String, List<ShAddressBook>> zrrMaps = shAddressBooksAll.stream().collect(Collectors.groupingBy(ShAddressBook::getType2));
for (int i = 0; i < shAddressBooksMatch.size(); i++) {
ShAddressBookVo vo = shAddressBooksMatch.get(i);
String county = vo.getCounty(); // 县
String area = vo.getArea(); // 乡
String village = vo.getVillage(); // 村
String type2 = vo.getType2(); // 责任人类型
if (StringUtils.isNotBlank(type2) && zrrMaps.containsKey(type2)) {
List<ShAddressBook> typeBooks = zrrMaps.get(type2);
List<ShAddressBook> ppResult = typeBooks.stream()
.filter(o -> Objects.equals(county, o.getCounty())
&& Objects.equals(area, o.getArea())
&& Objects.equals(village, o.getVillage())
&& Objects.equals(type2, o.getType2())).collect(Collectors.toList());
if (CollectionUtils.isNotEmpty(ppResult)) {
if (ppResult.size() == 1) {
// 匹配单条(正确匹配)
List<ShAddressBook> ppOneList = (List<ShAddressBook>) map.get("ppOneList");
ppOneList.add(ppResult.get(0));
map.put("ppOneList", ppOneList);
} else {
// 匹配多条
map.put("ppManyRownum", map.get("ppManyRownum").toString() + (i + 2) + "、");
}
} else {
// 未匹配
map.put("ppZeroRownum", map.get("ppZeroRownum").toString() + (i + 2) + "、");
}
} else {
// 未匹配
map.put("ppZeroRownum", map.get("ppZeroRownum").toString() + (i + 2) + "、");
}
}
if(map.get("ppZeroRownum").toString().length()> 0 && map.get("ppZeroRownum").toString().endsWith("、")){
map.put("ppZeroRownum", map.get("ppZeroRownum").toString().substring(0, map.get("ppZeroRownum").toString().length() - 1));
}
if(map.get("ppManyRownum").toString().length()> 0 && map.get("ppManyRownum").toString().endsWith("、")){
map.put("ppManyRownum", map.get("ppManyRownum").toString().substring(0, map.get("ppManyRownum").toString().length() - 1));
}
return map;
}
} }

View File

@ -1,5 +1,6 @@
package com.whdc.service.impl; package com.whdc.service.impl;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage; import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.whdc.mapper.ShCallsMapper; import com.whdc.mapper.ShCallsMapper;
@ -8,9 +9,15 @@ import com.whdc.model.entity.ShAddressBook;
import com.whdc.model.entity.ShCalls; import com.whdc.model.entity.ShCalls;
import com.whdc.model.vo.ShCallsVo; import com.whdc.model.vo.ShCallsVo;
import com.whdc.service.ShCallsService; import com.whdc.service.ShCallsService;
import org.apache.commons.collections.CollectionUtils;
import org.apache.commons.lang3.StringUtils;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import java.text.SimpleDateFormat;
import java.util.HashMap;
import java.util.List; import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;
import static com.whdc.model.MyConstant.REDIS_KEY; import static com.whdc.model.MyConstant.REDIS_KEY;
@ -24,6 +31,7 @@ import static com.whdc.model.MyConstant.REDIS_KEY;
public class ShCallsServiceImpl extends ServiceImpl<ShCallsMapper, ShCalls> implements ShCallsService { public class ShCallsServiceImpl extends ServiceImpl<ShCallsMapper, ShCalls> implements ShCallsService {
private static final String THIS_REDIS_KEY = REDIS_KEY + ShCalls.thisTableName + ":"; private static final String THIS_REDIS_KEY = REDIS_KEY + ShCalls.thisTableName + ":";
private static final SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
@Override @Override
public IPage<ShCallsVo> page(ShCallsDto dto) { public IPage<ShCallsVo> page(ShCallsDto dto) {
@ -39,4 +47,20 @@ public class ShCallsServiceImpl extends ServiceImpl<ShCallsMapper, ShCalls> impl
public List<ShCallsVo> listVo(ShCallsDto dto) { public List<ShCallsVo> listVo(ShCallsDto dto) {
return this.getBaseMapper().listVo(dto); return this.getBaseMapper().listVo(dto);
} }
@Override
public Map<String, Long> logDateStatistics(ShCallsDto dto) {
Map<String, Long> retMap = new HashMap<>();
List<ShCalls> shCalls = baseMapper.selectList(new QueryWrapper<ShCalls>()
.ge(StringUtils.isNotBlank(dto.getStiStartTime()), "CALL_TIME", dto.getStiStartTime().length() < 11 ? dto.getStiStartTime() + "00:00:00" : dto.getStiStartTime())
.le(StringUtils.isNotBlank(dto.getStiEndTime()), "CALL_TIME", dto.getStiEndTime().length() < 11 ? dto.getStiEndTime() + "23:59:59" : dto.getStiEndTime()).orderByAsc("CALL_TIME"));
if (CollectionUtils.isNotEmpty(shCalls)) {
retMap = shCalls.stream()
.collect(Collectors.groupingBy(
r -> sdf.format(r.getCallTime()),
Collectors.counting()
));
}
return retMap;
}
} }

View File

@ -58,9 +58,9 @@
T."TYPE1" , T."TYPE1" ,
T."TYPE2" T."TYPE2"
) T1 ) T1
LEFT JOIN "FXKH_TXL"."SH_ADDRESS_BOOK" T ON T.ID = T1.ID LEFT JOIN "FXKH_TXL"."SH_ADDRESS_BOOK" T ON T.ID = T1.ID AND DEL = 1
WHERE WHERE
DEL = 1 1 = 1
<if test="dto.type1 != null and dto.type1 != '' "> <if test="dto.type1 != null and dto.type1 != '' ">
AND T.TYPE1 = #{dto.type1} AND T.TYPE1 = #{dto.type1}
</if> </if>