Commit 868ac8a5 authored by 赵啸非's avatar 赵啸非

添加同步办件进度查询

parent 37eb0b5e
package com.mortals.xhx.busiz.rsp;
import lombok.Data;
/**
* @author karlhoo
*/
@Data
public class ApiDoworkResp<T> {
/**
* 结果编码
*/
private int res;
/**
* 结果描述
*/
private String messages;
/**
* 响应数据
*/
private T rows;
}
......@@ -4,11 +4,19 @@ import com.mortals.framework.service.ICacheService;
import com.mortals.framework.springcloud.service.IApplicationStartedService;
import com.mortals.framework.util.ThreadPool;
import com.mortals.xhx.base.system.user.service.UserService;
import com.mortals.xhx.module.dowork.model.DoworkStatQuery;
import com.mortals.xhx.module.dowork.service.DoworkStatService;
import com.mortals.xhx.module.process.model.ProcessResultQuery;
import com.mortals.xhx.module.process.service.ProcessResultService;
import com.mortals.xhx.module.site.model.SiteEntity;
import com.mortals.xhx.module.site.model.SiteQuery;
import com.mortals.xhx.module.site.service.SiteService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import java.util.List;
import static com.mortals.xhx.common.key.Constant.USER_SITE_TREE;
@Component
......@@ -18,9 +26,13 @@ public class DemoStartedService implements IApplicationStartedService {
@Autowired
private ICacheService cacheService;
@Autowired
private SiteService siteService;
private ProcessResultService processResultService;
@Autowired
private DoworkStatService doworkStatService;
@Autowired
private UserService userService;
@Autowired
private SiteService siteService;
@Override
public void start() {
......@@ -34,6 +46,25 @@ public class DemoStartedService implements IApplicationStartedService {
} catch (Exception e) {
log.error("获取所有站点用户失败", e);
}
try {
List<SiteEntity> siteEntities = siteService.find(new SiteQuery());
for (SiteEntity siteEntity : siteEntities) {
String areaCode = siteEntity.getAreaCode();
DoworkStatQuery doworkStatQuery = new DoworkStatQuery();
doworkStatQuery.setAreaCode(areaCode);
doworkStatService.queryListForWeb(doworkStatQuery);
doworkStatService.getForWeb(doworkStatQuery);
ProcessResultQuery processResultQuery = new ProcessResultQuery();
processResultQuery.setAreaCode(areaCode);
processResultService.queryListForWeb(processResultQuery);
}
} catch (Exception e) {
log.error("获取办件结果异常", e);
}
}
@Override
......
package com.mortals.xhx.module.dowork.model;
import com.mortals.framework.common.Rest;
import lombok.Data;
import org.apache.poi.ss.formula.functions.T;
@Data
public class DoworkInfo<T> {
......
......@@ -37,4 +37,5 @@ public interface DoworkStatService extends ICRUDService<DoworkStatEntity, Long>
Rest<DoworkStatEntity> getForWeb(DoworkStatEntity entity);
}
\ No newline at end of file
......@@ -4,10 +4,13 @@ import cn.hutool.core.date.DateTime;
import cn.hutool.core.date.DateUtil;
import cn.hutool.http.HttpUtil;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import com.alibaba.fastjson.TypeReference;
import com.mortals.framework.common.Rest;
import com.mortals.framework.model.PageInfo;
import com.mortals.xhx.busiz.rsp.ApiZwfwResp;
import com.mortals.xhx.module.area.model.AreaEntity;
import com.mortals.xhx.module.area.service.AreaService;
import com.mortals.xhx.module.dowork.model.*;
import org.springframework.beans.BeanUtils;
......@@ -16,6 +19,7 @@ import java.util.HashMap;
import java.util.List;
import java.util.function.Function;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Service;
import com.mortals.framework.service.impl.AbstractCRUDServiceImpl;
......@@ -40,16 +44,25 @@ public class DoworkStatServiceImpl extends AbstractCRUDServiceImpl<DoworkStatDao
@Value("${statUrl:https://tftb.sczwfw.gov.cn:8085}")
private String statUrl;
@Autowired
private AreaService areaService;
@Override
public Rest<List<DoworkStatEntity>> queryListForWeb(DoworkStatEntity entity) {
//创建 sign https://tftb.sczwfw.gov.cn:8085/api/jmas-api-gateway-server/createsign.do
String path = "/api/jmas-api-gateway-server/createsign.do";
String areaCode = entity.getAreaCode();
AreaEntity areaCache=areaService.getExtCache(areaCode);
HashMap<String, Object> paramsMap = new HashMap<>();
paramsMap.put("app_id", "gysqfyjqyyapp");
paramsMap.put("interface_id", "zj6ytjjk");
paramsMap.put("version", "1.0");
paramsMap.put("biz_content", "{\"code\":\"" + entity.getAreaCode() + "\"}");
JSONObject jsonObject = new JSONObject();
jsonObject.put("code", entity.getAreaCode());
paramsMap.put("biz_content", jsonObject.toJSONString());
paramsMap.put("charset", "UTF-8");
paramsMap.put("timestamp", new Date().getTime() + "");
paramsMap.put("origin", "1");
......@@ -87,6 +100,8 @@ public class DoworkStatServiceImpl extends AbstractCRUDServiceImpl<DoworkStatDao
DoworkStatEntity doworkStatEntity = this.selectOne(new DoworkStatQuery().areaCode(areaCode).year(year).month(months));
if (!ObjectUtils.isEmpty(doworkStatEntity)) {
doworkStatEntity.setDoworkNum(doworkStatInfo.getConclude());
doworkStatEntity.setUpdateTime(new Date());
this.update(doworkStatEntity);
} else {
......@@ -95,7 +110,13 @@ public class DoworkStatServiceImpl extends AbstractCRUDServiceImpl<DoworkStatDao
doworkStatEntity.setYear(year);
doworkStatEntity.setMonth(months);
doworkStatEntity.setAreaCode(areaCode);
doworkStatEntity.setAreaName(areaCache==null?"":areaCache.getName());
doworkStatEntity.setDoworkNum(doworkStatInfo.getConclude());
doworkStatEntity.setCreateTime(new Date());
doworkStatEntity.setCreateUserId(1L);
this.save(doworkStatEntity);
}
}
......@@ -117,12 +138,14 @@ public class DoworkStatServiceImpl extends AbstractCRUDServiceImpl<DoworkStatDao
//创建 sign https://tftb.sczwfw.gov.cn:8085/api/jmas-api-gateway-server/createsign.do
String path = "/api/jmas-api-gateway-server/createsign.do";
String areaCode = entity.getAreaCode();
AreaEntity areaCache=areaService.getExtCache(areaCode);
HashMap<String, Object> paramsMap = new HashMap<>();
paramsMap.put("app_id", "gysqfyjqyyapp");
paramsMap.put("interface_id", "tjtyjk");
paramsMap.put("version", "1.0");
paramsMap.put("biz_content", "{\"code\":\"" + areaCode + "\"}");
JSONObject jsonObject = new JSONObject();
jsonObject.put("code", entity.getAreaCode());
paramsMap.put("biz_content", jsonObject.toJSONString());
paramsMap.put("charset", "UTF-8");
paramsMap.put("timestamp", new Date().getTime() + "");
paramsMap.put("origin", "1");
......@@ -159,6 +182,7 @@ public class DoworkStatServiceImpl extends AbstractCRUDServiceImpl<DoworkStatDao
doworkStatEntity.setMatterNum(doworkStatInfo.getMatter());
doworkStatEntity.setSatisfactionRate(doworkStatInfo.getSatisfiedRate());
doworkStatEntity.setDoworkNum(doworkStatInfo.getConclude());
doworkStatEntity.setUpdateTime(new Date());
this.update(doworkStatEntity);
} else {
......@@ -169,7 +193,10 @@ public class DoworkStatServiceImpl extends AbstractCRUDServiceImpl<DoworkStatDao
doworkStatEntity.setAreaCode(areaCode);
doworkStatEntity.setMatterNum(doworkStatInfo.getMatter());
doworkStatEntity.setSatisfactionRate(doworkStatInfo.getSatisfiedRate());
doworkStatEntity.setAreaName(areaCache==null?"":areaCache.getName());
doworkStatEntity.setDoworkNum(doworkStatInfo.getConclude());
doworkStatEntity.setCreateTime(new Date());
doworkStatEntity.setCreateUserId(1L);
this.save(doworkStatEntity);
}
} else {
......
package com.mortals.xhx.module.dowork.web;
import com.mortals.framework.exception.AppException;
import com.mortals.framework.model.Context;
import com.mortals.framework.model.OrderCol;
import com.mortals.framework.util.ThreadPool;
import com.mortals.framework.web.BaseCRUDJsonBodyMappingController;
import com.mortals.xhx.base.system.param.service.ParamService;
import com.mortals.xhx.module.dowork.model.DoworkStatEntity;
import com.mortals.xhx.module.dowork.model.DoworkStatQuery;
import com.mortals.xhx.module.dowork.service.DoworkStatService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.util.ObjectUtils;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.bind.annotation.*;
import com.mortals.framework.model.Context;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import com.mortals.framework.web.BaseCRUDJsonBodyMappingController;
import com.mortals.xhx.module.dowork.model.DoworkStatEntity;
import com.mortals.xhx.module.dowork.service.DoworkStatService;
import org.apache.commons.lang3.ArrayUtils;
import com.mortals.framework.util.StringUtils;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;
import com.alibaba.fastjson.JSONObject;
import java.util.Arrays;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;
import static com.mortals.framework.ap.SysConstains.*;
import com.mortals.xhx.common.code.*;
import java.util.Map;
/**
*
* 办件统计
*
* @author zxfei
* @date 2025-06-10
*/
* 办件统计
*
* @author zxfei
* @date 2025-06-10
*/
@RestController
@RequestMapping("dowork/stat")
public class DoworkStatController extends BaseCRUDJsonBodyMappingController<DoworkStatService,DoworkStatEntity,Long> {
public class DoworkStatController extends BaseCRUDJsonBodyMappingController<DoworkStatService, DoworkStatEntity, Long> {
@Autowired
private ParamService paramService;
public DoworkStatController(){
super.setModuleDesc( "办件统计");
@Autowired
private DoworkStatService doworkStatService;
public DoworkStatController() {
super.setModuleDesc("办件统计");
}
@Override
protected void doListBefore(DoworkStatEntity query, Map<String, Object> model, Context context) throws AppException {
//todo 去请求外网 同步数据到数据库。
if (ObjectUtils.isEmpty(query.getOrderColList())) {
query.setOrderColList(Arrays.asList(new OrderCol("year"), new OrderCol("month")));
}
if (ObjectUtils.isEmpty(query.getAreaCode())) throw new AppException("区域编码不能为空!");
Runnable runnable = new Runnable() {
@Override
public void run() {
DoworkStatQuery doworkStatQuery = new DoworkStatQuery();
doworkStatQuery.setAreaCode(query.getAreaCode());
doworkStatService.queryListForWeb(doworkStatQuery);
doworkStatService.getForWeb(doworkStatQuery);
}
};
ThreadPool.getInstance().execute(runnable);
super.doListBefore(query, model, context);
}
......
package com.mortals.xhx.module.process.model;
import com.alibaba.fastjson.annotation.JSONField;
import lombok.Data;
import java.util.Date;
@Data
public class ProcessResultInfo {
/**
* 区域编码
*/
private String areaCode;
/**
* 区域名称
*/
private String areaName;
/**
* 字符串id
*/
private String idForStr;
/**
* 事件id
*/
private String eventId;
/**
* 事件编码
*/
private String eventCode;
/**
* 事件名称
*/
private String eventName;
/**
* 业务编码
*/
private String affairCode;
/**
* 应用名称
*/
private String applicantName;
/**
* 申请时间
*/
@JSONField(format = "yyyy-MM-dd")
private Date applyDate;
/**
* 创建时间
*/
@JSONField(format = "yyyy-MM-dd HH:mm:ss")
private Date createTimestamp;
/**
* 部门编码
*/
private String deptCode;
/**
* 部门名称
*/
private String deptName;
/**
* 一体化部门编码
*/
@JSONField(name = "yJDeptCode")
private String yjDeptCode;
/**
* 一体化部门名称
*/
@JSONField(name = "yjDeptName")
private String yjDeptName;
/**
* 办理状态
*/
private String handleStatus;
/**
* 办理状态名称
*/
private String handleStatusName;
/**
* 来源
*/
private String sysSource;
/**
* 删除标志
*/
private String deleteFlag;
}
package com.mortals.xhx.module.process.service;
import com.mortals.framework.common.Rest;
import com.mortals.framework.service.ICRUDService;
import com.mortals.xhx.module.dowork.model.DoworkStatEntity;
import com.mortals.xhx.module.process.model.ProcessResultEntity;
import com.mortals.xhx.module.process.dao.ProcessResultDao;
import java.util.List;
/**
* ProcessResultService
*
......@@ -13,4 +18,14 @@ import com.mortals.xhx.module.process.dao.ProcessResultDao;
public interface ProcessResultService extends ICRUDService<ProcessResultEntity,Long>{
ProcessResultDao getDao();
/**
* 同步查询办件结果
*
* @param entity
* @return
*/
Rest<List<ProcessResultEntity>> queryListForWeb(ProcessResultEntity entity);
}
\ No newline at end of file
package com.mortals.xhx.module.process.service.impl;
import cn.hutool.http.HttpUtil;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import com.alibaba.fastjson.TypeReference;
import com.mortals.framework.common.Rest;
import com.mortals.framework.model.PageInfo;
import com.mortals.xhx.busiz.rsp.ApiDoworkResp;
import com.mortals.xhx.module.area.model.AreaEntity;
import com.mortals.xhx.module.area.service.AreaService;
import com.mortals.xhx.module.dowork.model.DoworkStatInfo;
import com.mortals.xhx.module.process.model.ProcessResultInfo;
import com.mortals.xhx.module.process.model.ProcessResultQuery;
import org.springframework.beans.BeanUtils;
import java.util.Date;
import java.util.HashMap;
import java.util.List;
import java.util.function.Function;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Service;
import com.mortals.framework.service.impl.AbstractCRUDServiceImpl;
import com.mortals.framework.exception.AppException;
......@@ -10,15 +29,64 @@ import com.mortals.xhx.module.process.dao.ProcessResultDao;
import com.mortals.xhx.module.process.model.ProcessResultEntity;
import com.mortals.xhx.module.process.service.ProcessResultService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.util.ObjectUtils;
/**
* ProcessResultService
* 办件结果 service实现
*
* @author zxfei
* @date 2025-06-10
*/
* ProcessResultService
* 办件结果 service实现
*
* @author zxfei
* @date 2025-06-10
*/
@Service("processResultService")
@Slf4j
public class ProcessResultServiceImpl extends AbstractCRUDServiceImpl<ProcessResultDao, ProcessResultEntity, Long> implements ProcessResultService {
@Value("${doworkUrl:https://zxbl.sczwfw.gov.cn}")
private String doworkUrl;
@Autowired
private AreaService areaService;
@Override
public Rest<List<ProcessResultEntity>> queryListForWeb(ProcessResultEntity entity) {
String path = "/app/affairPublicity/getMainData/v3";
String areaCode = entity.getAreaCode();
AreaEntity areaCache = areaService.getExtCache(areaCode);
HashMap<String, Object> paramsMap = new HashMap<>();
JSONObject jsonObject = new JSONObject();
jsonObject.put("isRandCode", "0");
jsonObject.put("areaCode", areaCode);
paramsMap.put("postData", jsonObject.toJSONString());
String resp = HttpUtil.post(doworkUrl + path, paramsMap);
log.info("resp:{}", resp);
ApiDoworkResp<List<ProcessResultInfo>> apiDoworkResp = JSON.parseObject(resp, new TypeReference<ApiDoworkResp<List<ProcessResultInfo>>>() {
});
if (apiDoworkResp.getRes() == 0) {
List<ProcessResultInfo> rows = apiDoworkResp.getRows();
for (ProcessResultInfo row : rows) {
String idForStr = row.getIdForStr();
ProcessResultEntity processResultEntity = this.selectOne(new ProcessResultQuery().idForStr(idForStr));
if (ObjectUtils.isEmpty(processResultEntity)) {
processResultEntity = new ProcessResultEntity();
processResultEntity.initAttrValue();
BeanUtils.copyProperties(row, processResultEntity, new String[]{"id"});
processResultEntity.setUpdateTime(new Date());
processResultEntity.setAreaName(areaCache == null ? "" : areaCache.getName());
this.save(processResultEntity);
} else {
BeanUtils.copyProperties(row, processResultEntity, new String[]{"id"});
processResultEntity.setCreateTime(new Date());
processResultEntity.setCreateUserId(1L);
this.update(processResultEntity);
}
}
return Rest.ok(apiDoworkResp.getMessages());
} else {
return Rest.fail(apiDoworkResp.getMessages());
}
}
}
\ No newline at end of file
package com.mortals.xhx.module.process.web;
import com.mortals.framework.exception.AppException;
import com.mortals.framework.model.OrderCol;
import com.mortals.framework.util.ThreadPool;
import com.mortals.framework.web.BaseCRUDJsonBodyMappingController;
import com.mortals.xhx.base.system.param.service.ParamService;
import com.mortals.xhx.module.dowork.model.DoworkStatQuery;
import com.mortals.xhx.module.process.model.ProcessResultQuery;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.util.ObjectUtils;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.bind.annotation.*;
import com.mortals.framework.model.Context;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import com.mortals.framework.web.BaseCRUDJsonBodyMappingController;
import com.mortals.xhx.module.process.model.ProcessResultEntity;
import com.mortals.xhx.module.process.service.ProcessResultService;
import org.apache.commons.lang3.ArrayUtils;
import com.mortals.framework.util.StringUtils;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;
import com.alibaba.fastjson.JSONObject;
import java.util.Arrays;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;
import static com.mortals.framework.ap.SysConstains.*;
import com.mortals.xhx.common.code.*;
/**
*
* 办件结果
*
* @author zxfei
* @date 2025-06-10
*/
* 办件结果
*
* @author zxfei
* @date 2025-06-10
*/
@RestController
@RequestMapping("process/result")
public class ProcessResultController extends BaseCRUDJsonBodyMappingController<ProcessResultService,ProcessResultEntity,Long> {
public class ProcessResultController extends BaseCRUDJsonBodyMappingController<ProcessResultService, ProcessResultEntity, Long> {
@Autowired
private ParamService paramService;
public ProcessResultController(){
super.setModuleDesc( "办件结果");
@Autowired
private ProcessResultService processResultService;
public ProcessResultController() {
super.setModuleDesc("办件结果");
}
@Override
......@@ -47,4 +65,24 @@ public class ProcessResultController extends BaseCRUDJsonBodyMappingController<P
}
@Override
protected void doListBefore(ProcessResultEntity query, Map<String, Object> model, Context context) throws AppException {
if (ObjectUtils.isEmpty(query.getOrderColList())) {
query.setOrderColList(Arrays.asList(new OrderCol("create_timestamp", "DESC")));
}
if (ObjectUtils.isEmpty(query.getAreaCode())) throw new AppException("区域编码不能为空!");
Runnable runnable = new Runnable() {
@Override
public void run() {
ProcessResultQuery processResultQuery = new ProcessResultQuery();
processResultQuery.setAreaCode(query.getAreaCode());
processResultService.queryListForWeb(processResultQuery);
}
};
ThreadPool.getInstance().execute(runnable);
super.doListBefore(query, model, context);
}
}
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment