|
@@ -4,15 +4,22 @@ package com.boman.web.core.service.accounting;
|
|
|
* @Date: 2022/05/13/11:14
|
|
|
*/
|
|
|
|
|
|
+import com.alibaba.fastjson.JSONArray;
|
|
|
+import com.alibaba.fastjson.JSONObject;
|
|
|
+import com.boman.common.core.exception.BaseException;
|
|
|
+import com.boman.domain.*;
|
|
|
import com.alibaba.fastjson.JSON;
|
|
|
import com.boman.common.core.utils.DateUtils;
|
|
|
import com.boman.common.core.utils.StringUtils;
|
|
|
import com.boman.domain.Czrk;
|
|
|
import com.boman.domain.SysUser;
|
|
|
+import com.boman.domain.dto.AjaxResult;
|
|
|
+import com.boman.system.api.RemoteDeptService;
|
|
|
import com.boman.web.core.domain.AccountingData;
|
|
|
import com.boman.web.core.domain.vo.AccountingDataVo;
|
|
|
import com.boman.web.core.mapper.AccountingDataMapper;
|
|
|
import com.boman.web.core.mapper.CzrkMapper;
|
|
|
+import com.boman.web.core.utils.*;
|
|
|
import com.boman.web.core.utils.AuthUtils;
|
|
|
import com.boman.web.core.utils.CzrkUtils;
|
|
|
import lombok.extern.slf4j.Slf4j;
|
|
@@ -22,11 +29,13 @@ import org.apache.ibatis.session.SqlSessionFactory;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
|
|
|
import javax.annotation.Resource;
|
|
|
-import java.util.Date;
|
|
|
-import java.util.HashMap;
|
|
|
-import java.util.List;
|
|
|
-import java.util.Map;
|
|
|
+import java.io.IOException;
|
|
|
+import java.util.*;
|
|
|
|
|
|
+import static com.boman.common.core.utils.obj.ObjectUtils.map;
|
|
|
+import static com.boman.web.core.utils.CzrkUtils.setQueryRole;
|
|
|
+
|
|
|
+import static com.boman.web.core.utils.CzrkUtils.setAgeScope;
|
|
|
import static com.boman.web.core.utils.CzrkUtils.setQueryRole;
|
|
|
|
|
|
/**
|
|
@@ -35,10 +44,12 @@ import static com.boman.web.core.utils.CzrkUtils.setQueryRole;
|
|
|
*/
|
|
|
@Service
|
|
|
@Slf4j
|
|
|
-public class AccountingDataServiceImpl implements IAccountingDataService{
|
|
|
+public class AccountingDataServiceImpl implements IAccountingDataService {
|
|
|
|
|
|
@Resource
|
|
|
private AccountingDataMapper accountingDataMapper;
|
|
|
+ @Resource
|
|
|
+ private RemoteDeptService remoteDeptService;
|
|
|
|
|
|
@Resource
|
|
|
private SqlSessionFactory sqlSessionFactory;
|
|
@@ -48,6 +59,7 @@ public class AccountingDataServiceImpl implements IAccountingDataService{
|
|
|
|
|
|
/**
|
|
|
* 潜山核酸数据列表页(户籍地址)
|
|
|
+ *
|
|
|
* @param accountingData
|
|
|
* @return
|
|
|
*/
|
|
@@ -56,16 +68,33 @@ public class AccountingDataServiceImpl implements IAccountingDataService{
|
|
|
SysUser sysUser = AuthUtils.getLoginUser().getSysUser();
|
|
|
log.info("{}于{}查询核酸户籍人口列表,查询条件:{}"
|
|
|
, sysUser.getUserName(), DateUtils.dateTimeNow(), JSON.toJSONString(accountingData));
|
|
|
+ //获取时段
|
|
|
+ String timeSlot = accountingData.getTimeSlot();
|
|
|
+ if (StringUtils.isNotBlank(timeSlot)) {
|
|
|
+ //开始时间
|
|
|
+ String startTime = DateUtils.minusDayOfDate(Integer.parseInt(timeSlot));
|
|
|
+ Date endTime = DateUtils.getNowDate();
|
|
|
+ Map<String, Object> map = new HashMap<>();
|
|
|
+ map.put("startTime", startTime);
|
|
|
+ map.put("endTime", endTime);
|
|
|
+ accountingData.setParams(map);
|
|
|
+ }
|
|
|
|
|
|
//设置查询列表权限
|
|
|
setQueryRole(accountingData, sysUser, Czrk.HJ);
|
|
|
List<AccountingDataVo> list = accountingDataMapper.selectAccountingDataHjList(accountingData);
|
|
|
+ list.forEach(e -> {
|
|
|
+ if (StringUtils.isNotBlank(e.getJcsj())) {
|
|
|
+ e.setIsNucleicAcid("Y");
|
|
|
+ }
|
|
|
+ });
|
|
|
CzrkUtils.packAddrNucleicAcid(list);
|
|
|
return list;
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* 潜山核酸数据列表页(居住地址)
|
|
|
+ *
|
|
|
* @param accountingData
|
|
|
* @return
|
|
|
*/
|
|
@@ -74,6 +103,17 @@ public class AccountingDataServiceImpl implements IAccountingDataService{
|
|
|
SysUser sysUser = AuthUtils.getLoginUser().getSysUser();
|
|
|
log.info("{}于{}查询核酸居住人口列表,查询条件:{}"
|
|
|
, sysUser.getUserName(), DateUtils.dateTimeNow(), JSON.toJSONString(accountingData));
|
|
|
+ //获取时段
|
|
|
+ String timeSlot = accountingData.getTimeSlot();
|
|
|
+ if (StringUtils.isNotBlank(timeSlot)) {
|
|
|
+ //开始时间
|
|
|
+ String startTime = DateUtils.minusDayOfDate(Integer.parseInt(timeSlot));
|
|
|
+ Date endTime = DateUtils.getNowDate();
|
|
|
+ Map<String, Object> map = new HashMap<>();
|
|
|
+ map.put("startTime", startTime);
|
|
|
+ map.put("endTime", endTime);
|
|
|
+ accountingData.setParams(map);
|
|
|
+ }
|
|
|
//设置查询列表权限
|
|
|
setQueryRole(accountingData, sysUser, Czrk.CZ);
|
|
|
List<AccountingDataVo> list = accountingDataMapper.selectAccountingDataJzdzList(accountingData);
|
|
@@ -81,6 +121,142 @@ public class AccountingDataServiceImpl implements IAccountingDataService{
|
|
|
return list;
|
|
|
}
|
|
|
|
|
|
+ /**
|
|
|
+ * 核酸数据导出
|
|
|
+ *
|
|
|
+ * @param accountingData
|
|
|
+ * @throws IOException
|
|
|
+ */
|
|
|
+ @Override
|
|
|
+ public List<AccountingData> getExport(AccountingData accountingData) {
|
|
|
+
|
|
|
+ //SysUser sysUser = AuthUtils.getLoginUser().getSysUser();
|
|
|
+ //setQueryRole(czrk,sysUser, Czrk.HJ);
|
|
|
+ //setAgeScope(czrk);
|
|
|
+ List<AccountingData> accountingDataList = accountingDataMapper.getExport(accountingData);
|
|
|
+
|
|
|
+ /* List<Czrk> czrkListp = czrkList.stream().sorted(
|
|
|
+ //以户籍号排序
|
|
|
+ Comparator.comparing(Czrk::getCode, Comparator.reverseOrder())
|
|
|
+ //户主排序
|
|
|
+ .thenComparing(Czrk::getHouseType, Comparator.reverseOrder())
|
|
|
+
|
|
|
+ ).collect(Collectors.toList());*/
|
|
|
+
|
|
|
+ //CzrkUtils.packAddr(accountingDataList);
|
|
|
+ if (accountingDataList == null || accountingDataList.size() <= 0) {
|
|
|
+ throw new BaseException("请下载属于本乡镇数据");
|
|
|
+ }
|
|
|
+ //packAddr(czrkList);
|
|
|
+ return accountingDataList;
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public AjaxResult toQianshan(String rc, String djsjqs, String djsjjs, String name, String sfzhm) {
|
|
|
+
|
|
|
+ //判断传入的地区在不在账号权限内
|
|
|
+ //获取账号区划权限
|
|
|
+ /*SysUser sysUser = AuthUtils.getLoginUser().getSysUser();
|
|
|
+ SysDept dept = sysUser.getDept();
|
|
|
+ if (StringUtils.isEmpty(rc) && StringUtils.isEmpty(sfzhm)) {
|
|
|
+ rc = dept.getDeptName();
|
|
|
+ }
|
|
|
+ if (StringUtils.isNotEmpty(rc)) {
|
|
|
+ //判断账号权限
|
|
|
+ List<String> roleKeySets = map(sysUser.getRoles(), SysRole::getRoleKey);
|
|
|
+ if (roleKeySets.contains("province") || roleKeySets.contains("city") || roleKeySets.contains("region") || roleKeySets.contains("admin") || roleKeySets.contains("yanshi")) {
|
|
|
+ // 市领导可查看所有人员,不做处理
|
|
|
+
|
|
|
+ } else if (roleKeySets.contains("villageTowns")) {
|
|
|
+ // 镇领导,只能查看本镇下人员
|
|
|
+ //获取本镇下所有乡村
|
|
|
+ List<SysDept> allDepts = remoteDeptService.listChildrenDepts(dept.getId());
|
|
|
+ List<String> qhList = Arrays.asList(rc.split(","));
|
|
|
+ //取最后一级区划
|
|
|
+ String qu = qhList.get(allDepts.size() - 1);
|
|
|
+ boolean b = false;
|
|
|
+ if (qu.equals(dept.getAreaName())) {
|
|
|
+ b = true;
|
|
|
+ } else {
|
|
|
+ for (SysDept allDept : allDepts) {
|
|
|
+ if (qu.equals(allDept.getAreaName())) {
|
|
|
+ b = true;
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if (!b) {
|
|
|
+ return AjaxResult.error("无权限查询该地区数据");
|
|
|
+ }
|
|
|
+ } else if (roleKeySets.contains("village")) {
|
|
|
+ // 村领导
|
|
|
+ }
|
|
|
+
|
|
|
+ }*/
|
|
|
+
|
|
|
+ djsjqs = djsjqs.replace(" ","%20");
|
|
|
+ djsjjs = djsjjs.replace(" ","%20");
|
|
|
+
|
|
|
+ //查询前先获取tocken
|
|
|
+ String access_token =null;
|
|
|
+ Map<String, String> paramMapT = new HashMap<>();
|
|
|
+ paramMapT.put("client_id", "acdf50bd13be4901b64c62b1fee862c0");
|
|
|
+ paramMapT.put("client_secret", "a3650d67fc034b2d8ea259182b3d99f3");
|
|
|
+ String httpt = "http://60.171.171.235:9090/oauth/token";
|
|
|
+ try {
|
|
|
+ String datas = HttpClientUtils.doGet(httpt, paramMapT);
|
|
|
+ JSONObject jsonT = JSON.parseObject(datas);
|
|
|
+ access_token = (String) jsonT.get("access_token");
|
|
|
+ } catch (IOException e) {
|
|
|
+ e.printStackTrace();
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ Map<String, String> paramMap = new HashMap<>();
|
|
|
+ String http = null;
|
|
|
+ //当区划为空的时候根据姓名,身份证查询
|
|
|
+ if(StringUtils.isNotEmpty(sfzhm)){
|
|
|
+ //潜山来宜人员数据(姓名 身份证 时间段)
|
|
|
+ paramMap.put("client_id", "acdf50bd13be4901b64c62b1fee862c0");
|
|
|
+ paramMap.put("access_token", access_token);
|
|
|
+ paramMap.put("name", name);
|
|
|
+ paramMap.put("sfzhm", sfzhm);
|
|
|
+ paramMap.put("djsjqs", djsjqs);
|
|
|
+ paramMap.put("djsjjs", djsjjs);
|
|
|
+
|
|
|
+ http = "http://60.171.171.235:9090/service/api/rkk/qslyrysjcx";
|
|
|
+ }else{
|
|
|
+ //潜山来宜人员数据(区划 时间段)
|
|
|
+ paramMap.put("client_id", "acdf50bd13be4901b64c62b1fee862c0");
|
|
|
+ paramMap.put("access_token", access_token);
|
|
|
+ if(StringUtils.isEmpty(rc)){
|
|
|
+ rc = "潜山市";
|
|
|
+ }
|
|
|
+ paramMap.put("rc", rc);
|
|
|
+ paramMap.put("djsjqs", djsjqs);
|
|
|
+ paramMap.put("djsjjs", djsjjs);
|
|
|
+
|
|
|
+ http = "http://60.171.171.235:9090/service/api/rkk/qslyrysj";
|
|
|
+ }
|
|
|
+
|
|
|
+ try {
|
|
|
+ if (StringUtils.isEmpty(http)) {
|
|
|
+ return AjaxResult.error("参数错误");
|
|
|
+ }
|
|
|
+ String data = HttpClientUtils.doGet(http, paramMap);
|
|
|
+
|
|
|
+ //List list = new ArrayList();
|
|
|
+ List<JSONObject> list= JSON.parseArray(data, JSONObject.class);
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ return AjaxResult.success("数据返回成功", list);
|
|
|
+ } catch (IOException e) {
|
|
|
+ e.printStackTrace();
|
|
|
+ return AjaxResult.error("数据返回失败");
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
/**
|
|
|
* 新增
|
|
|
* @param accountingDataList
|