From fcea223b0523132ae529700b0d493149e9bc4777 Mon Sep 17 00:00:00 2001 From: Administrator <1923636941@qq.com> Date: Fri, 24 Mar 2023 10:57:16 +0800 Subject: [PATCH] =?UTF-8?q?feat=EF=BC=9A=E6=94=BF=E5=8A=A1=E6=95=B0?= =?UTF-8?q?=E6=8D=AE=E6=8E=A8=E9=80=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- pom.xml | 5 + .../zhgd/xmgl/async/AsyncSendAttendance.java | 4 + .../modules/govtapi/GovtOpenApiService.java | 146 ++++++++++++++++++ .../ProjectOperationsAnalysisServiceImpl.java | 9 +- ...WorkerMonthAttendanceStatisticsMapper.java | 2 + .../WorkerMonthAttendanceStatisticsMapper.xml | 8 + .../impl/WorkerAttendanceServiceImpl.java | 10 ++ .../service/impl/WorkerInfoServiceImpl.java | 10 ++ ...rMonthAttendanceStatisticsServiceImpl.java | 12 ++ .../java/com/zhgd/xmgl/task/GovtSyncTask.java | 77 +++++++++ src/main/resources/application-ljw.properties | 32 ++-- 11 files changed, 298 insertions(+), 17 deletions(-) create mode 100644 src/main/java/com/zhgd/xmgl/modules/govtapi/GovtOpenApiService.java create mode 100644 src/main/java/com/zhgd/xmgl/task/GovtSyncTask.java diff --git a/pom.xml b/pom.xml index ac4935a67..f322b7366 100644 --- a/pom.xml +++ b/pom.xml @@ -496,6 +496,11 @@ gexin-rp-sdk-http 4.1.1.4 + + com.gexin.platform + gexin-rp-fastjson + 1.0.0.7 + com.hikvision.ga diff --git a/src/main/java/com/zhgd/xmgl/async/AsyncSendAttendance.java b/src/main/java/com/zhgd/xmgl/async/AsyncSendAttendance.java index 0d81ec57d..ba75470f6 100644 --- a/src/main/java/com/zhgd/xmgl/async/AsyncSendAttendance.java +++ b/src/main/java/com/zhgd/xmgl/async/AsyncSendAttendance.java @@ -40,10 +40,14 @@ public class AsyncSendAttendance { private IWorkerAttendancePresenceService workerAttendancePresenceService; @Autowired private WkServiceuCall wkServiceuCall; + @Autowired + private GovtOpenApiService govtOpenApiService; @Async("sendAttendanceExecutor") public void saveAndSendAttendance(WorkerAttendance workerAttendance, WorkerInfo info){ try { + // 向政务平台发送数据 + govtOpenApiService.workerAttendanceSync(workerAttendance); //计算在场 workerAttendancePresenceService.addWorkerAttendancePresence(workerAttendance); //上传住建 diff --git a/src/main/java/com/zhgd/xmgl/modules/govtapi/GovtOpenApiService.java b/src/main/java/com/zhgd/xmgl/modules/govtapi/GovtOpenApiService.java new file mode 100644 index 000000000..9bcd170df --- /dev/null +++ b/src/main/java/com/zhgd/xmgl/modules/govtapi/GovtOpenApiService.java @@ -0,0 +1,146 @@ +package com.zhgd.xmgl.modules.govtapi; + +import cn.hutool.core.collection.CollUtil; +import cn.hutool.http.HttpUtil; +import cn.hutool.json.JSONObject; +import cn.hutool.json.JSONUtil; +import com.zhgd.xmgl.modules.realnamestatistics.entity.ProjectOperationsAnalysis; +import com.zhgd.xmgl.modules.worker.entity.WorkerAttendance; +import com.zhgd.xmgl.modules.worker.entity.WorkerInfo; +import com.zhgd.xmgl.modules.worker.entity.WorkerMonthAttendanceStatistics; +import lombok.RequiredArgsConstructor; +import lombok.extern.slf4j.Slf4j; +import org.springframework.beans.factory.annotation.Value; +import org.springframework.stereotype.Service; + +import java.util.List; + +/** + * 湖里政务平台开放api调用 + * + * @author HZI.HUI + */ +@Slf4j +@Service +@RequiredArgsConstructor +public class GovtOpenApiService { + + + @Value("${govt.host}") + public String govtHost; + + + /** + * 考勤打卡 + * + * @param workerAttendance + */ + public void workerAttendanceSync(WorkerAttendance workerAttendance) { + try { + String result = HttpUtil.post(govtHost + "/openapi/labour/worker/attendance/sync", JSONUtil.toJsonStr(workerAttendance), 6000); + JSONObject jsonObject = JSONUtil.parseObj(result); + String code = jsonObject.getStr("code"); + if ("200".equals(code)) { + log.info("[劳务管理-考勤打卡-同步到政务] 成功,数据:{}", JSONUtil.toJsonStr(workerAttendance)); + return; + } + log.error("[劳务管理-考勤打卡-同步到政务] 失败,数据:{}, 错误:{}", JSONUtil.toJsonStr(workerAttendance), result); + } catch (Exception e) { + log.error("[劳务管理-考勤打卡-同步到政务] 失败,数据:{}, 异常:", JSONUtil.toJsonStr(workerAttendance), e); + } + } + + + /** + * 劳务管理-考情统计-同步到政务 + * + * @param statistics + */ + public void workerMonthAttendanceStatisticsSync(WorkerMonthAttendanceStatistics statistics) { + try { + String result = HttpUtil.post(govtHost + "/openapi/labour/worker/month/attendance/statistics/sync", JSONUtil.toJsonStr(statistics), 6000); + JSONObject jsonObject = JSONUtil.parseObj(result); + String code = jsonObject.getStr("code"); + if ("200".equals(code)) { + log.info("[劳务管理-考情统计-同步到政务] 成功,数据:{}", JSONUtil.toJsonStr(statistics)); + return; + } + log.error("[劳务管理-考情统计-同步到政务] 失败,数据:{}, 错误:{}", JSONUtil.toJsonStr(statistics), result); + } catch (Exception e) { + log.error("[劳务管理-考情统计-同步到政务] 失败,数据:{}, 异常:", JSONUtil.toJsonStr(statistics), e); + } + } + + /** + * 劳务管理-开放api-实名制统计 + * + * @param analysisList + */ + public void projectOperationsAnalysisUpdateSync(List analysisList) { + if (CollUtil.isEmpty(analysisList)) { + return; + } + for (ProjectOperationsAnalysis projectOperationsAnalysis : analysisList) { + try { + String result = HttpUtil.post(govtHost + "/openapi/labour/project/operations/analysis/update", JSONUtil.toJsonStr(projectOperationsAnalysis), 20000); + JSONObject jsonObject = JSONUtil.parseObj(result); + String code = jsonObject.getStr("code"); + if ("200".equals(code)) { + log.info("[劳务管理-实名制统计-同步到政务] 成功,数据:{}", JSONUtil.toJsonStr(projectOperationsAnalysis)); + continue; + } + log.error("[劳务管理-实名制统计-同步到政务] 失败,数据:{}, 错误:{}", JSONUtil.toJsonStr(projectOperationsAnalysis), result); + } catch (Exception e) { + log.error("[劳务管理-实名制统计-同步到政务] 失败,数据:{}, 异常:", JSONUtil.toJsonStr(projectOperationsAnalysis), e); + } + } + + } + + + /** + * 劳务管理-开放api-劳务人员新增 + * + * @param workerInfo + */ + public void workerInfoAddSync(WorkerInfo workerInfo) { + try { + String result = HttpUtil.post(govtHost + "/openapi/labour/worker/info/add", JSONUtil.toJsonStr(workerInfo), 6000); + JSONObject jsonObject = JSONUtil.parseObj(result); + String code = jsonObject.getStr("code"); + if ("200".equals(code)) { + log.info("[劳务管理-劳务人员新增-同步到政务] 成功,数据:{}", JSONUtil.toJsonStr(workerInfo)); + return; + } + log.error("[劳务管理-劳务人员新增-同步到政务] 失败,数据:{}, 错误:{}", JSONUtil.toJsonStr(workerInfo), result); + } catch (Exception e) { + log.error("[劳务管理-劳务人员新增-同步到政务] 失败,数据:{}, 异常:", JSONUtil.toJsonStr(workerInfo), e); + } + } + + + /** + * 劳务管理-开放api-劳务人员新增 + * + * @param workerInfo + */ + public void workerInfoDelSync(WorkerInfo workerInfo) { + try { + String result = HttpUtil.post(govtHost + "/openapi/labour/worker/info/del/sync", JSONUtil.toJsonStr(workerInfo), 6000); + JSONObject jsonObject = JSONUtil.parseObj(result); + String code = jsonObject.getStr("code"); + if ("200".equals(code)) { + log.info("[劳务管理-劳务人员删除-同步到政务] 成功,数据:{}", JSONUtil.toJsonStr(workerInfo)); + return; + } + log.error("[劳务管理-劳务人员删除-同步到政务] 失败,数据:{}, 错误:{}", JSONUtil.toJsonStr(workerInfo), result); + } catch (Exception e) { + log.error("[劳务管理-劳务人员删除-同步到政务] 失败,数据:{}, 异常:", JSONUtil.toJsonStr(workerInfo), e); + } + } + + + + + +} diff --git a/src/main/java/com/zhgd/xmgl/modules/realnamestatistics/service/impl/ProjectOperationsAnalysisServiceImpl.java b/src/main/java/com/zhgd/xmgl/modules/realnamestatistics/service/impl/ProjectOperationsAnalysisServiceImpl.java index 42a9463db..bac39515f 100644 --- a/src/main/java/com/zhgd/xmgl/modules/realnamestatistics/service/impl/ProjectOperationsAnalysisServiceImpl.java +++ b/src/main/java/com/zhgd/xmgl/modules/realnamestatistics/service/impl/ProjectOperationsAnalysisServiceImpl.java @@ -4,6 +4,7 @@ package com.zhgd.xmgl.modules.realnamestatistics.service.impl; import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; +import com.zhgd.xmgl.modules.govtapi.GovtOpenApiService; import com.zhgd.xmgl.modules.realnamestatistics.entity.ProjectOperationsAnalysis; import com.zhgd.xmgl.modules.realnamestatistics.entity.ProjectTotalStatistics; import com.zhgd.xmgl.modules.realnamestatistics.entity.vo.TodayAttendance; @@ -48,13 +49,15 @@ public class ProjectOperationsAnalysisServiceImpl extends ServiceImpl analysisList = projectOperationsAnalysisMapper.getAllDetails(); for (ProjectOperationsAnalysis projectOperationsAnalysis : analysisList) { String projectSn = projectOperationsAnalysis.getProjectSn(); @@ -73,7 +76,9 @@ public class ProjectOperationsAnalysisServiceImpl extends ServiceImpl selectProjectMonthAttendanceList(HashMap param); List getListByProjectSn(String projectSn); + + WorkerMonthAttendanceStatistics selectByCondition(Map param); } diff --git a/src/main/java/com/zhgd/xmgl/modules/worker/mapper/xml/WorkerMonthAttendanceStatisticsMapper.xml b/src/main/java/com/zhgd/xmgl/modules/worker/mapper/xml/WorkerMonthAttendanceStatisticsMapper.xml index acb6b7bc1..8bf10c066 100644 --- a/src/main/java/com/zhgd/xmgl/modules/worker/mapper/xml/WorkerMonthAttendanceStatisticsMapper.xml +++ b/src/main/java/com/zhgd/xmgl/modules/worker/mapper/xml/WorkerMonthAttendanceStatisticsMapper.xml @@ -185,4 +185,12 @@ inner join worker_info wi on wi.person_sn = wmas.person_sn where wi.project_sn = #{projectSn} + + \ No newline at end of file diff --git a/src/main/java/com/zhgd/xmgl/modules/worker/service/impl/WorkerAttendanceServiceImpl.java b/src/main/java/com/zhgd/xmgl/modules/worker/service/impl/WorkerAttendanceServiceImpl.java index 2eacb9d54..98d17686a 100644 --- a/src/main/java/com/zhgd/xmgl/modules/worker/service/impl/WorkerAttendanceServiceImpl.java +++ b/src/main/java/com/zhgd/xmgl/modules/worker/service/impl/WorkerAttendanceServiceImpl.java @@ -14,6 +14,7 @@ import com.zhgd.jeecg.common.mybatis.EntityMap; import com.zhgd.xmgl.async.AsyncSendAttendance; import com.zhgd.xmgl.modules.basicdata.service.ICompanyService; import com.zhgd.xmgl.modules.basicdata.service.UploadFileService; +import com.zhgd.xmgl.modules.govtapi.GovtOpenApiService; import com.zhgd.xmgl.modules.project.entity.ProjectUfaceConfig; import com.zhgd.xmgl.modules.project.mapper.ProjectUfaceConfigMapper; import com.zhgd.xmgl.modules.worker.entity.*; @@ -78,6 +79,9 @@ public class WorkerAttendanceServiceImpl extends ServiceImpl list = workerInfoService.list(Wrappers.lambdaQuery() + .in(WorkerInfo::getProjectSn, "29E5B97B246544E0B0EF18534FA7C78D")); + for (WorkerInfo workerInfo : list) { + govtOpenApiService.workerInfoAddSync(workerInfo); + } + initSyncWorkerAttendanceData(); + initProjectOperationsAnalysisData(); + getMonthAttendanceStatistics(); + } + + + public void initSyncWorkerAttendanceData() { + List list = workerAttendanceService.list(Wrappers.lambdaQuery() + .in(WorkerAttendance::getProjectSn, "29E5B97B246544E0B0EF18534FA7C78D")); + for (WorkerAttendance workerAttendance : list) { + govtOpenApiService.workerAttendanceSync(workerAttendance); + } + } + + + + public void initProjectOperationsAnalysisData() { + List list = projectOperationsAnalysisService.list(Wrappers.lambdaQuery() + .in(ProjectOperationsAnalysis::getProjectSn, "29E5B97B246544E0B0EF18534FA7C78D")); + govtOpenApiService.projectOperationsAnalysisUpdateSync(list); + } + + + + public void getMonthAttendanceStatistics() { + List list = workerMonthAttendanceStatisticsService.list(Wrappers.lambdaQuery() + .in(WorkerMonthAttendanceStatistics::getProjectSn, "29E5B97B246544E0B0EF18534FA7C78D")); + for (WorkerMonthAttendanceStatistics workerAttendance : list) { + govtOpenApiService.workerMonthAttendanceStatisticsSync(workerAttendance); + } + } +} diff --git a/src/main/resources/application-ljw.properties b/src/main/resources/application-ljw.properties index 576e0eec2..50149904c 100644 --- a/src/main/resources/application-ljw.properties +++ b/src/main/resources/application-ljw.properties @@ -27,7 +27,7 @@ isGetEnvironmentData=false isGetFaceFeatureDate=false -#海康视频报警图片IP端口替换 +#\u6D77\u5EB7\u89C6\u9891\u62A5\u8B66\u56FE\u7247IP\u7AEF\u53E3\u66FF\u6362 video.alarm.newUrl=223.82.100.80:6040 wx-appid= @@ -37,29 +37,29 @@ mqtt-scope=devTopic serverUrl=http://47.97.202.104:6023 #serverUrl=http://127.0.0.1:6023 -#视频分析url +#\u89C6\u9891\u5206\u6790url video-analysis-url= -#默认政务创建项目所属企? +#\u9ED8\u8BA4\u653F\u52A1\u521B\u5EFA\u9879\u76EE\u6240\u5C5E\u4F01\uFFFD? defaultZwComapnySn= -#文件存储配置 -#默认使用的存储平? +#\u6587\u4EF6\u5B58\u50A8\u914D\u7F6E +#\u9ED8\u8BA4\u4F7F\u7528\u7684\u5B58\u50A8\u5E73\uFFFD? spring.file-storage.default-platform=local -#".min.jpg" #缩略图后缀,例如?min.jpg】?png? +#".min.jpg" #\u7F29\u7565\u56FE\u540E\u7F00\uFF0C\u4F8B\u5982\uFFFD?min.jpg\u3011\uFFFD?png\uFFFD? spring.file-storage.thumbnail-suffix=.jpg -# 本地存储,不使用的情况下可以不写 -# 存储平台标识 +# \u672C\u5730\u5B58\u50A8\uFF0C\u4E0D\u4F7F\u7528\u7684\u60C5\u51B5\u4E0B\u53EF\u4EE5\u4E0D\u5199 +# \u5B58\u50A8\u5E73\u53F0\u6807\u8BC6 spring.file-storage.local[0].platform=local -#启用存储 +#\u542F\u7528\u5B58\u50A8 spring.file-storage.local[0].enable-storage=true -#启用访问(线上请使用 Nginx 配置,效率更高) +#\u542F\u7528\u8BBF\u95EE\uFF08\u7EBF\u4E0A\u8BF7\u4F7F\u7528 Nginx \u914D\u7F6E\uFF0C\u6548\u7387\u66F4\u9AD8\uFF09 spring.file-storage.local[0].enable-access=false -# 访问域名,例如:“http://127.0.0.1:6023/image/”,注意后面要和 path-patterns 保持一致,?”结尾,本地存储建议使用相对路径,方便后期更换域? +# \u8BBF\u95EE\u57DF\u540D\uFF0C\u4F8B\u5982\uFF1A\u201Chttp://127.0.0.1:6023/image/\u201D\uFF0C\u6CE8\u610F\u540E\u9762\u8981\u548C path-patterns \u4FDD\u6301\u4E00\u81F4\uFF0C\uFFFD?\u201D\u7ED3\u5C3E\uFF0C\u672C\u5730\u5B58\u50A8\u5EFA\u8BAE\u4F7F\u7528\u76F8\u5BF9\u8DEF\u5F84\uFF0C\u65B9\u4FBF\u540E\u671F\u66F4\u6362\u57DF\uFFFD? spring.file-storage.local[0].domain= -# 存储地址 +# \u5B58\u50A8\u5730\u5740 spring.file-storage.local[0].base-path=C:/itbgpImage/ -# 访问路径,开?enable-access 后,通过此路径可以访问到上传的文? +# \u8BBF\u95EE\u8DEF\u5F84\uFF0C\u5F00\uFFFD?enable-access \u540E\uFF0C\u901A\u8FC7\u6B64\u8DEF\u5F84\u53EF\u4EE5\u8BBF\u95EE\u5230\u4E0A\u4F20\u7684\u6587\uFFFD? spring.file-storage.local[0].path-patterns= spring.file-storage.aliyun-oss[0].platform=aliyun-oss @@ -68,11 +68,13 @@ spring.file-storage.aliyun-oss[0].access-key= spring.file-storage.aliyun-oss[0].secret-key= spring.file-storage.aliyun-oss[0].end-point= spring.file-storage.aliyun-oss[0].bucket-name= -# 访问域名,注意?”结尾,例如:https://abc.oss-cn-shanghai.aliyuncs.com/ +# \u8BBF\u95EE\u57DF\u540D\uFF0C\u6CE8\u610F\uFFFD?\u201D\u7ED3\u5C3E\uFF0C\u4F8B\u5982\uFF1Ahttps://abc.oss-cn-shanghai.aliyuncs.com/ spring.file-storage.aliyun-oss[0].domain= spring.file-storage.aliyun-oss[0].base-path= -#ͻ License +#\uFFFD\u037B\uFFFD\uFFFD\uFFFD License\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD license.licensePath=C:/license/license.lic license.publicKeysStorePath=C:/license/publicCerts.keystore +# ???? +govt.host=http://47.96.183.143/uatapi