From 43b9f15d440822392928cde339795274efd50f77 Mon Sep 17 00:00:00 2001 From: du <1725534722@qq.com> Date: Wed, 4 Dec 2024 17:09:40 +0800 Subject: [PATCH] =?UTF-8?q?=E5=AF=B9=E6=8E=A5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../com/ruoyi/tc/baseClass/BaseClass.java | 8 +- .../ruoyi/tc/controller/UnitController.java | 67 ++++- .../main/java/com/ruoyi/tc/entity/Unit.java | 7 +- .../ruoyi/tc/regular/AssetCurrentChange.java | 237 +++++++++++++++++ .../java/com/ruoyi/tc/regular/UnitChange.java | 247 ++++++++++++++++++ .../ruoyi/tc/regular/entity/AssetDbxx.java | 83 ++++++ .../ruoyi/tc/regular/entity/AssetJcxx.java | 103 ++++++++ .../ruoyi/tc/regular/entity/UnitArchives.java | 81 ++++++ .../ruoyi/tc/regular/entity/UnitConcat.java | 44 ++++ .../src/main/resources/application.yml | 11 + 10 files changed, 875 insertions(+), 13 deletions(-) create mode 100644 ruoyi-admin/src/main/java/com/ruoyi/tc/regular/AssetCurrentChange.java create mode 100644 ruoyi-admin/src/main/java/com/ruoyi/tc/regular/UnitChange.java create mode 100644 ruoyi-admin/src/main/java/com/ruoyi/tc/regular/entity/AssetDbxx.java create mode 100644 ruoyi-admin/src/main/java/com/ruoyi/tc/regular/entity/AssetJcxx.java create mode 100644 ruoyi-admin/src/main/java/com/ruoyi/tc/regular/entity/UnitArchives.java create mode 100644 ruoyi-admin/src/main/java/com/ruoyi/tc/regular/entity/UnitConcat.java diff --git a/ruoyi-admin/src/main/java/com/ruoyi/tc/baseClass/BaseClass.java b/ruoyi-admin/src/main/java/com/ruoyi/tc/baseClass/BaseClass.java index e326b21..e991e16 100644 --- a/ruoyi-admin/src/main/java/com/ruoyi/tc/baseClass/BaseClass.java +++ b/ruoyi-admin/src/main/java/com/ruoyi/tc/baseClass/BaseClass.java @@ -7,7 +7,7 @@ import io.swagger.annotations.ApiModelProperty; import lombok.Data; import org.springframework.format.annotation.DateTimeFormat; -import java.util.Date; +import java.time.LocalDateTime; /** * 公共实体类 @@ -30,7 +30,7 @@ public class BaseClass { @JsonFormat(shape = JsonFormat.Shape.STRING, pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8") @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss") @TableField(fill = FieldFill.INSERT) - private Date createTime; + private LocalDateTime createTime; /** * 更新者 @@ -43,10 +43,10 @@ public class BaseClass { * 更新时间 */ @ApiModelProperty("更新时间") - @TableField(fill = FieldFill.UPDATE) + @TableField(fill = FieldFill.INSERT_UPDATE) @JsonFormat(shape = JsonFormat.Shape.STRING, pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8") @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss") - private Date updateTime; + private LocalDateTime updateTime; private String remark; diff --git a/ruoyi-admin/src/main/java/com/ruoyi/tc/controller/UnitController.java b/ruoyi-admin/src/main/java/com/ruoyi/tc/controller/UnitController.java index 93cc74f..357216a 100644 --- a/ruoyi-admin/src/main/java/com/ruoyi/tc/controller/UnitController.java +++ b/ruoyi-admin/src/main/java/com/ruoyi/tc/controller/UnitController.java @@ -1,21 +1,31 @@ package com.ruoyi.tc.controller; +import cn.hutool.http.HttpRequest; +import cn.hutool.http.HttpResponse; +import cn.hutool.json.JSONObject; +import cn.hutool.json.JSONUtil; import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import com.ruoyi.common.annotation.Log; import com.ruoyi.common.core.domain.AjaxResult; import com.ruoyi.common.core.domain.entity.SysDept; +import com.ruoyi.common.core.domain.entity.SysUser; import com.ruoyi.common.enums.BusinessType; import com.ruoyi.common.exception.ServiceException; +import com.ruoyi.common.utils.PasswordGenerator; +import com.ruoyi.common.utils.SecurityUtils; import com.ruoyi.common.utils.poi.ExcelUtil; import com.ruoyi.system.service.ISysDeptService; import com.ruoyi.system.service.ISysUserService; import com.ruoyi.tc.entity.Unit; import com.ruoyi.tc.entity.request.UnitRequest; +import com.ruoyi.tc.regular.AssetCurrentChange; +import com.ruoyi.tc.regular.UnitChange; import com.ruoyi.tc.service.ExamineInfoService; import com.ruoyi.tc.service.UnitOtherConcatService; import com.ruoyi.tc.service.UnitService; import io.swagger.annotations.Api; import io.swagger.annotations.ApiOperation; +import org.springframework.beans.factory.annotation.Value; import org.springframework.security.access.prepost.PreAuthorize; import org.springframework.transaction.annotation.Transactional; import org.springframework.web.bind.annotation.*; @@ -48,10 +58,17 @@ public class UnitController { private ExamineInfoService examineInfoService; @Resource - private ISysUserService iSysUserService; + private ISysDeptService iSysDeptService; @Resource - private ISysDeptService iSysDeptService; + private ISysUserService userService; + @Resource + private UnitChange unitChange; + + @Resource + private AssetCurrentChange assetCurrentChange; + + /** * 获取单位列表 @@ -65,6 +82,27 @@ public class UnitController { return AjaxResult.success(unitService.page(page, unit)); } + /** + * l1 + */ + @ApiOperation(value = "单位对接") + @GetMapping("/l1") + public AjaxResult l1() { + unitChange.unitTotal(); + return AjaxResult.success(); + } + + /** + * l2 + */ + @ApiOperation(value = "系统对接") + @GetMapping("/l2") + public AjaxResult l2() { + assetCurrentChange.assetTotal(); + return AjaxResult.success(); + } + + /** * 获取所有单位列表 */ @@ -162,14 +200,14 @@ public class UnitController { //新增单位到单位信息表 unitService.save(unit); //新增其他联系人 - if (unit.getOtherConcat()!=null) { + if (unit.getOtherConcat() != null) { unit.getOtherConcat().forEach(x -> { x.setUnitId(unit.getId()); }); unitOtherConcatService.saveBatch(unit.getOtherConcat()); } //新增检查信息 - if (unit.getJcxxList()!=null) { + if (unit.getJcxxList() != null) { unit.getJcxxList().forEach(x -> { x.setUnitId(unit.getId()); }); @@ -179,6 +217,23 @@ public class UnitController { return AjaxResult.success(s); } + /** + * 修改单位密码 + */ + @ApiOperation(value = "修改单位密码") + @Log(title = "用户管理", businessType = BusinessType.UPDATE) + @GetMapping("/edit/{id}") + @PreAuthorize("@ss.hasAnyRoles('admin')") + @Transactional(rollbackFor = Exception.class) + public AjaxResult editPassword(@PathVariable Long id) { + String password = PasswordGenerator.password(); + Unit byId = unitService.getById(id); + SysUser user = userService.selectUserByUserName(byId.getUserName()); + user.setPassword(SecurityUtils.encryptPassword(password)); + userService.updateUserProfile(user); + return AjaxResult.success(password); + } + /** * 修改用户 */ @@ -197,14 +252,14 @@ public class UnitController { examineInfoService.deleteByUnitIds(x.getId()); unitService.validUser(x); - if (x.getOtherConcat()!=null) { + if (x.getOtherConcat() != null) { x.getOtherConcat().forEach(y -> { y.setUnitId(x.getId()); y.setConcatId(null); }); unitOtherConcatService.saveBatch(x.getOtherConcat()); } - if (x.getJcxxList()!=null) { + if (x.getJcxxList() != null) { x.getJcxxList().forEach(y -> { y.setUnitId(x.getId()); y.setJcid(null); diff --git a/ruoyi-admin/src/main/java/com/ruoyi/tc/entity/Unit.java b/ruoyi-admin/src/main/java/com/ruoyi/tc/entity/Unit.java index 5152c0a..42d7d67 100644 --- a/ruoyi-admin/src/main/java/com/ruoyi/tc/entity/Unit.java +++ b/ruoyi-admin/src/main/java/com/ruoyi/tc/entity/Unit.java @@ -13,6 +13,7 @@ import javax.validation.Valid; import javax.validation.constraints.NotBlank; import javax.validation.constraints.NotNull; import java.io.Serializable; +import java.time.LocalDateTime; import java.util.Date; import java.util.List; @@ -222,7 +223,7 @@ public class Unit implements Serializable { @JsonFormat(shape = JsonFormat.Shape.STRING, pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8") @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss") @TableField(fill = FieldFill.INSERT) - private Date createTime; + private LocalDateTime createTime; /** * 更新者 @@ -235,10 +236,10 @@ public class Unit implements Serializable { * 更新时间 */ @ApiModelProperty("更新时间") - @TableField(fill = FieldFill.UPDATE) + @TableField(fill = FieldFill.INSERT_UPDATE) @JsonFormat(shape = JsonFormat.Shape.STRING, pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8") @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss") - private Date updateTime; + private LocalDateTime updateTime; @ApiModelProperty("备注") @Excel(name = "备注") diff --git a/ruoyi-admin/src/main/java/com/ruoyi/tc/regular/AssetCurrentChange.java b/ruoyi-admin/src/main/java/com/ruoyi/tc/regular/AssetCurrentChange.java new file mode 100644 index 0000000..5203d30 --- /dev/null +++ b/ruoyi-admin/src/main/java/com/ruoyi/tc/regular/AssetCurrentChange.java @@ -0,0 +1,237 @@ +package com.ruoyi.tc.regular; + +import cn.hutool.core.bean.BeanUtil; +import cn.hutool.http.HttpRequest; +import cn.hutool.http.HttpResponse; +import cn.hutool.json.JSONArray; +import cn.hutool.json.JSONConfig; +import cn.hutool.json.JSONObject; +import cn.hutool.json.JSONUtil; +import com.ruoyi.tc.entity.AssetCurrent; +import com.ruoyi.tc.regular.entity.AssetDbxx; +import com.ruoyi.tc.regular.entity.AssetJcxx; +import com.ruoyi.tc.service.AssetCurrentService; +import org.springframework.beans.factory.annotation.Value; +import org.springframework.stereotype.Component; +import org.springframework.transaction.annotation.Transactional; + +import javax.annotation.Resource; +import java.time.Duration; +import java.time.LocalDateTime; +import java.util.HashMap; +import java.util.Map; + +/** + * 系统定时任务 + * + * @author du + * @since 2024/12/3 17:06 + */ +//@Configuration +//@EnableScheduling +@Component +public class AssetCurrentChange { + + @Value("${isTime}") + private Boolean isTime; + + @Value("${systemInfo}") + private String systemInfo; + + @Value("${systemDb}") + private String systemDb; + + @Resource + private AssetCurrentService assetCurrentService; + + /** + * 定时更新系统基础信息 + */ +// @Scheduled(cron = "0 0 3 * * *") + @Transactional(rollbackFor = Exception.class) + public void assetTotal() { + if (isTime) { + Map params = new HashMap<>(); + params.put("sign", "1BAE256B66FE09BFCFC3436930C2C986"); + params.put("resourceName", "org_dm_xtxgxxb"); + params.put("userName", "wxb_tc"); + params.put("subResourceName", "wxb001"); + params.put("offset", "1"); + HttpResponse response = HttpRequest.post(systemInfo + "?" + urlEdit(params)) + .header("Content-Type", "application/json;charset=utf-8") + .formStr(new HashMap<>()) + .execute(); + System.out.println(response.getStatus()); + if (response.getStatus() == 200) { + JSONObject jsonObj = JSONUtil.parseObj(response.body()); + System.out.println(jsonObj); + if ("200".equals(jsonObj.get("code").toString())) { + JSONObject reqData = JSONUtil.parseObj(jsonObj.get("data")); + JSONArray arr = reqData.getJSONArray("result"); // 直接获取数组,无需再次解析 + int total = reqData.getInt("total"); // 只需解析一次total并转换为整数 + changeAsset(arr); + if (total / 1000 > 1) { + for (int i = 1; i < (total / 1000) + 1; i++) { + assetFor(1 + 1000 * i); + } + } + } + } + } + } + + /** + * 根据页数进行系统基础信息下次循环 + */ + public void assetFor(Integer offset) { + Map params = new HashMap<>(); + params.put("sign", "1BAE256B66FE09BFCFC3436930C2C986"); + params.put("resourceName", "org_dm_xtxgxxb"); + params.put("userName", "wxb_tc"); + params.put("subResourceName", "wxb001"); + params.put("offset", offset); + HttpResponse response = HttpRequest.post(systemInfo + "?" + urlEdit(params)) + .header("Content-Type", "application/json;charset=utf-8") + .formStr(new HashMap<>()) + .execute(); + if (response.getStatus() == 200) { + JSONObject jsonObj = JSONUtil.parseObj(response.body()); + if ("200".equals(jsonObj.get("code").toString())) { + JSONObject reqData = JSONUtil.parseObj(jsonObj.get("data")); + JSONArray arr = reqData.getJSONArray("result"); // 直接获取数组,无需再次解析 + changeAsset(arr); + } + } + } + + /** + * url地址修改 + */ + public String urlEdit(Map params) { + StringBuilder queryParamBuilder = new StringBuilder(); + for (Map.Entry entry : params.entrySet()) { + if (queryParamBuilder.length() > 0) { + queryParamBuilder.append("&"); + } + queryParamBuilder.append(entry.getKey()).append("=").append(entry.getValue()); + } + return queryParamBuilder.toString(); + } + + + /** + * 解析系统基础信息数据 + */ + public void changeAsset(JSONArray arr) { + //解析数据 + for (Object o : arr) { + JSONConfig jsonConfig = new JSONConfig(); + jsonConfig.setIgnoreCase(true); + AssetJcxx res = JSONUtil.toBean(o.toString(),jsonConfig, AssetJcxx.class); + //根据现有资产表单位名称和系统名称查询对应的数据 + AssetCurrent one = assetCurrentService.lambdaQuery() + .eq(AssetCurrent::getDwmc, res.getBmmc()) + .eq(AssetCurrent::getXtmc, res.getXtmc()).one(); + //准备要新增或者修改的数据 + AssetCurrent na = new AssetCurrent(); + BeanUtil.copyProperties(res, na, "id"); + na.setDwmc(res.getBmmc()); + na.setXtym(res.getYm()); + na.setGjxt(res.getSfgjxt()); + na.setDgzkf(res.getSfdgzkf()); + //查询对接的系统基础信息对应的系统等保信息 + AssetDbxx assetDbxx = searchDbxx(res.getId()); + if (assetDbxx != null) { + na.setDbxxDjsj(assetDbxx.getDjsj()); + na.setDbxxDbdj(assetDbxx.getDbjb()); + na.setDbxxDbcpbah(assetDbxx.getDbcpbah()); + na.setDbxxDbcpbah(assetDbxx.getDbcpbah()); + na.setDbxxCpdf(assetDbxx.getDbcpdf()); + na.setMpSfmpxt(assetDbxx.getSfmmcp()); + na.setMpMpdf(assetDbxx.getMpdf()); + na.setIpcSfba(assetDbxx.getIcpsfba()); + na.setIpcSfba(assetDbxx.getIcpsfba()); + na.setIpcIpcbabh(assetDbxx.getIcpbabh()); + na.setIpcIpcbabh(assetDbxx.getIcpbabh()); + na.setGajgSfba(assetDbxx.getSfgaba()); + na.setGajgBajg(assetDbxx.getBajg()); + na.setGajgBah(assetDbxx.getGajgbah()); + na.setGajgBah(assetDbxx.getGajgbah()); + na.setGajgBarq(assetDbxx.getBarq()); + } + if (one != null) { + //修改 + if (one.getUpdateTime() != null && res.getUpdatetime() != null) { + if (!getDateBoolean(one.getUpdateTime(), res.getUpdatetime())) { + na.setId(one.getId()); + assetCurrentService.updateById(na); + } + } else { + na.setId(one.getId()); + assetCurrentService.updateById(na); + } + } else { + assetCurrentService.save(na); + } + } + } + + /** + * 根据系统档案的id获取对应的系统等保信息 + */ + public AssetDbxx searchDbxx(String xtid) { + Map params = new HashMap<>(); + params.put("sign", "9D0DBC61467D4C2D2087266DF4CA7BCF"); + params.put("resourceName", "org_dm_xtdbxxb"); + params.put("userName", "wxb_tc"); + params.put("subResourceName", "wxb001"); + JSONObject jo = new JSONObject();//存放参数 + jo.set("xtid", xtid); + HttpResponse response = HttpRequest.post(systemDb + "?" + urlEdit(params)) + .header("Content-Type", "application/json;charset=utf-8") + .formStr(new HashMap<>()) + .body(jo.toString()) + .execute(); + System.out.println(response.getStatus()); + if (response.getStatus() == 200) { + JSONObject jsonObj = JSONUtil.parseObj(response.body()); + System.out.println(jsonObj); + if ("200".equals(jsonObj.get("code").toString())) { + JSONArray arr = jsonObj.getJSONArray("data"); // 直接获取数组,无需再次解析 + if (arr.size() > 0) { + JSONConfig jsonConfig = new JSONConfig(); + jsonConfig.setIgnoreCase(true); + return JSONUtil.toBean(arr.get(0).toString(),jsonConfig, AssetDbxx.class); + } else { + return null; + } + } else { + return null; + } + } else { + return null; + } + } + + /** + * 判断两个LocalDateTime哪个离现在时间最近 + */ + public Boolean getDateBoolean(LocalDateTime a, LocalDateTime b) { + LocalDateTime now = LocalDateTime.now(); + Duration duration1 = Duration.between(now, a); + Duration duration2 = Duration.between(now, b); + if (duration1.isNegative()) { + duration1 = duration1.negated(); + } + if (duration2.isNegative()) { + duration2 = duration2.negated(); + } + if (duration1.compareTo(duration2) < 0) { + return true; + } else if (duration1.compareTo(duration2) > 0) { + return false; + } + return false; + } + +} diff --git a/ruoyi-admin/src/main/java/com/ruoyi/tc/regular/UnitChange.java b/ruoyi-admin/src/main/java/com/ruoyi/tc/regular/UnitChange.java new file mode 100644 index 0000000..3f4519c --- /dev/null +++ b/ruoyi-admin/src/main/java/com/ruoyi/tc/regular/UnitChange.java @@ -0,0 +1,247 @@ +package com.ruoyi.tc.regular; + +import cn.hutool.core.bean.BeanUtil; +import cn.hutool.http.HttpRequest; +import cn.hutool.http.HttpResponse; +import cn.hutool.json.JSONArray; +import cn.hutool.json.JSONConfig; +import cn.hutool.json.JSONObject; +import cn.hutool.json.JSONUtil; +import com.ruoyi.tc.entity.Unit; +import com.ruoyi.tc.entity.UnitOtherConcat; +import com.ruoyi.tc.regular.entity.UnitArchives; +import com.ruoyi.tc.regular.entity.UnitConcat; +import com.ruoyi.tc.service.UnitOtherConcatService; +import com.ruoyi.tc.service.UnitService; +import org.springframework.beans.factory.annotation.Value; +import org.springframework.stereotype.Component; +import org.springframework.transaction.annotation.Transactional; + +import javax.annotation.Resource; +import java.time.Duration; +import java.time.LocalDateTime; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +/** + * 单位对接定时任务 + * + * @author du + * @since 2024/12/3 10:59 + */ +//@Configuration +//@EnableScheduling +@Component +public class UnitChange { + + @Value("${isTime}") + private Boolean isTime; + + @Value("${unitDocking}") + private String unitDocking; + + @Value("${unitDockingContact}") + private String unitDockingContact; + + @Resource + private UnitService unitService; + + @Resource + private UnitOtherConcatService unitOtherConcatService; + + /** + * 定时更新单位档案信息 + */ +// @Scheduled(cron = "0 0 2 * * *") + @Transactional(rollbackFor = Exception.class) + public void unitTotal() { + if (isTime) { + Map params = new HashMap<>(); + params.put("sign", "D46D877537EA76E1D4EDC8DF5C95F040"); + params.put("resourceName", "org_dm_dwdaxxb"); + params.put("userName", "wxb_tc"); + params.put("subResourceName", "wxb001"); + params.put("offset", "1"); + HttpResponse response = HttpRequest.post(unitDocking + "?" + urlEdit(params)) + .header("Content-Type", "application/json;charset=utf-8") + .formStr(new HashMap<>()) + .execute(); + if (response.getStatus() == 200) { + JSONObject jsonObj = JSONUtil.parseObj(response.body()); + if ("200".equals(jsonObj.get("code").toString())) { + JSONObject reqData = JSONUtil.parseObj(jsonObj.get("data")); + JSONArray arr = reqData.getJSONArray("result"); // 直接获取数组,无需再次解析 + int total = reqData.getInt("total"); // 只需解析一次total并转换为整数 + changeUnit(arr); + if (total / 1000 > 1) { + for (int i = 1; i < (total / 1000) + 1; i++) { + unitFor(1 + 1000 * i); + } + } + } + } + } + } + + /** + * url地址修改 + */ + public String urlEdit(Map params) { + StringBuilder queryParamBuilder = new StringBuilder(); + for (Map.Entry entry : params.entrySet()) { + if (queryParamBuilder.length() > 0) { + queryParamBuilder.append("&"); + } + queryParamBuilder.append(entry.getKey()).append("=").append(entry.getValue()); + } + return queryParamBuilder.toString(); + } + + + /** + * 根据页数进行下次循环 + */ + public void unitFor(Integer offset) { + Map params = new HashMap<>(); + params.put("sign", "D46D877537EA76E1D4EDC8DF5C95F040"); + params.put("resourceName", "org_dm_dwdaxxb"); + params.put("userName", "wxb_tc"); + params.put("subResourceName", "wxb001"); + params.put("offset", offset); + HttpResponse response = HttpRequest.post(unitDocking + "?" + urlEdit(params)) + .header("Content-Type", "application/json;charset=utf-8") + .formStr(new HashMap<>()) + .execute(); + if (response.getStatus() == 200) { + JSONObject jsonObj = JSONUtil.parseObj(response.body()); + if ("200".equals(jsonObj.get("code").toString())) { + JSONObject reqData = JSONUtil.parseObj(jsonObj.get("data")); + JSONArray arr = reqData.getJSONArray("result"); // 直接获取数组,无需再次解析 + changeUnit(arr); + } + } + } + + /** + * 解析单位数据 + */ + public void changeUnit(JSONArray arr) { + //解析数据 + for (Object o : arr) { + JSONConfig jsonConfig = new JSONConfig(); + jsonConfig.setIgnoreCase(true); + UnitArchives res = JSONUtil.toBean(o.toString(), jsonConfig, UnitArchives.class); + Unit one = unitService.lambdaQuery().eq(Unit::getNickName, res.getDwmc()) + .eq(Unit::getUserName, res.getTyshxydm()).one(); + //需要新增或者修改的单位 + Unit djUnit = new Unit(); + BeanUtil.copyProperties(res, djUnit, "id"); + djUnit.setUserName(res.getTyshxydm()); + djUnit.setNickName(res.getDwmc()); + djUnit.setGjdw(res.getSfgjdw()); + djUnit.setGw(res.getWz()); + djUnit.setDtjd(res.getJd()); + djUnit.setDtwd(res.getWd()); + if (one != null) { + //修改 + if (one.getUpdateTime() != null && res.getUpdatetime() != null) { + if (!getDateBoolean(one.getUpdateTime(), res.getUpdatetime())) { + djUnit.setId(one.getId()); + unitService.updateById(djUnit); + } + } else { + djUnit.setId(one.getId()); + unitService.updateById(djUnit); + } + updateUnitConcat(one.getId(), res.getId()); + } else { + //添加 + unitService.save(djUnit); + unitService.validUser(djUnit); + updateUnitConcat(djUnit.getId(), res.getId()); + } + + } + } + + /** + * 修改单位的联系人 + */ + public void updateUnitConcat(Long id1, String id2) { + //我们单位联系人 + List list = unitOtherConcatService.lambdaQuery().eq(UnitOtherConcat::getUnitId, id1).list(); + //对接联系人 + Map params = new HashMap<>(); + params.put("sign", "DB84C68B1B6D3E2E937E97406394EB7C"); + params.put("resourceName", "org_dm_dwlxrb"); + params.put("userName", "wxb_tc"); + params.put("subResourceName", "wxb001"); + JSONObject jo = new JSONObject();//存放参数 + jo.set("dwid", id2); + HttpResponse response = HttpRequest.post(unitDockingContact + "?" + urlEdit(params)) + .header("Content-Type", "application/json;charset=utf-8") + .formStr(new HashMap<>()) + .body(jo.toString()) + .execute(); + if (response.getStatus() == 200) { + JSONObject jsonObj = JSONUtil.parseObj(response.body()); + if ("200".equals(jsonObj.get("code").toString())) { + JSONArray arr = jsonObj.getJSONArray("data"); // 直接获取数组,无需再次解析 + for (Object o : arr) { + JSONConfig jsonConfig = new JSONConfig(); + jsonConfig.setIgnoreCase(true); + UnitConcat res = JSONUtil.toBean(o.toString(), jsonConfig, UnitConcat.class); + UnitOtherConcat uc = new UnitOtherConcat(); + uc.setUnitId(id1); + uc.setQtlxrxm(res.getXm()); + uc.setQtlxrlxfs(res.getLxfs()); + uc.setQtlxrzwzc(res.getZwzc()); + if (list != null && !list.isEmpty()) { + for (int i = 0; i < list.size(); i++) { + if (list.get(i).getQtlxrxm().equals(res.getXm())) { + if (list.get(i).getUpdateTime() != null && res.getUpdatetime() != null) { + if (!getDateBoolean(list.get(i).getUpdateTime(), res.getUpdatetime())) { + uc.setConcatId(list.get(i).getConcatId()); + unitOtherConcatService.updateById(list.get(i)); + } + } else { + uc.setConcatId(list.get(i).getConcatId()); + unitOtherConcatService.updateById(list.get(i)); + } + } else { + if (i == list.size() - 1 && !list.get(i).getQtlxrxm().equals(res.getXm())) { + unitOtherConcatService.save(uc); + } + } + } + } else { + unitOtherConcatService.save(uc); + } + } + } + } + } + + /** + * 判断两个LocalDateTime哪个离现在时间最近 + */ + public Boolean getDateBoolean(LocalDateTime a, LocalDateTime b) { + LocalDateTime now = LocalDateTime.now(); + Duration duration1 = Duration.between(now, a); + Duration duration2 = Duration.between(now, b); + if (duration1.isNegative()) { + duration1 = duration1.negated(); + } + if (duration2.isNegative()) { + duration2 = duration2.negated(); + } + if (duration1.compareTo(duration2) < 0) { + return true; + } else if (duration1.compareTo(duration2) > 0) { + return false; + } + return false; + } + +} diff --git a/ruoyi-admin/src/main/java/com/ruoyi/tc/regular/entity/AssetDbxx.java b/ruoyi-admin/src/main/java/com/ruoyi/tc/regular/entity/AssetDbxx.java new file mode 100644 index 0000000..9311738 --- /dev/null +++ b/ruoyi-admin/src/main/java/com/ruoyi/tc/regular/entity/AssetDbxx.java @@ -0,0 +1,83 @@ +package com.ruoyi.tc.regular.entity; + +import com.fasterxml.jackson.annotation.JsonFormat; +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; +import org.springframework.format.annotation.DateTimeFormat; + +import java.time.LocalDateTime; + +/** + * 系统等保信息对接实体类 + * @author du + * @since 2024/12/4 9:30 + */ +@Data +public class AssetDbxx { + @ApiModelProperty("id") + private String id; + + @ApiModelProperty("所属系统ID") + private String xtid; + + @ApiModelProperty("定级时间") + private String djsj; + + @ApiModelProperty("等保级别") + private String dbjb; + + @ApiModelProperty("等保测评备案号") + private String dbcpbah; + + @ApiModelProperty("等保测评得分") + private String dbcpdf; + + @ApiModelProperty("等保测评时间") + private String dbcpsj; + + + @ApiModelProperty("是否密码测评") + private String sfmmcp; + + @ApiModelProperty("密码测评时间") + private String mmcpsj; + + @ApiModelProperty("密码测评级别") + private String mmcpjb; + + @ApiModelProperty("密码测评编号") + private String mmcpbh; + + @ApiModelProperty("密评信息-密评得分") + private String mpdf; + + + @ApiModelProperty("ICP备案信息-是否备案") + private String icpsfba; + + + @ApiModelProperty("ICP备案信息-ICP备案编号") + private String icpbabh; + + @ApiModelProperty("公安机关备案信息-是否备案") + private String sfgaba; + + @ApiModelProperty("公安机关备案信息-备案机关") + private String bajg; + + @ApiModelProperty("公安机关备案信息-公安机关备案号") + private String gajgbah; + + @ApiModelProperty("公安机关备案信息-备案日期") + private String barq; + + @ApiModelProperty("更新时间") + @JsonFormat(shape = JsonFormat.Shape.STRING, pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8") + @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss") + private LocalDateTime updatetime; + + @ApiModelProperty("创建时间") + @JsonFormat(shape = JsonFormat.Shape.STRING, pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8") + @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss") + private LocalDateTime createtime; +} diff --git a/ruoyi-admin/src/main/java/com/ruoyi/tc/regular/entity/AssetJcxx.java b/ruoyi-admin/src/main/java/com/ruoyi/tc/regular/entity/AssetJcxx.java new file mode 100644 index 0000000..3b3670d --- /dev/null +++ b/ruoyi-admin/src/main/java/com/ruoyi/tc/regular/entity/AssetJcxx.java @@ -0,0 +1,103 @@ +package com.ruoyi.tc.regular.entity; + +import com.fasterxml.jackson.annotation.JsonFormat; +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; +import org.springframework.format.annotation.DateTimeFormat; + +import java.time.LocalDateTime; + +/** + * 系统基础信息对接实体类 + * @author du + * @since 2024/12/4 9:28 + */ +@Data +public class AssetJcxx { + @ApiModelProperty("id") + private String id; + + @ApiModelProperty("部门id") + private String bmid; + + @ApiModelProperty("部门名称") + private String bmmc; + + @ApiModelProperty("系统名称") + private String xtmc; + + @ApiModelProperty("系统简介") + private String xtjj; + + @ApiModelProperty("系统状态") + private String xtzt; + + @ApiModelProperty("系统领域") + private String xtly; + + @ApiModelProperty("系统类型") + private String xtlx; + + @ApiModelProperty("系统架构") + private String xtjg; + + @ApiModelProperty("网络环境") + private String wkhj; + + @ApiModelProperty("访问网址") + private String fwwz; + + @ApiModelProperty("域名") + private String ym; + + + @ApiModelProperty("是否垂管") + private String sfcg; + + @ApiModelProperty("月均访问数") + private String yjfws; + + @ApiModelProperty("系统重要性") + private String xtzyx; + + @ApiModelProperty("是否关基系统") + private String sfgjxt; + + + @ApiModelProperty("系统部署方式") + private String xtbsfs; + + @ApiModelProperty("未部署信息港的原因") + private String wbsxxgyy; + + @ApiModelProperty("是否对公众开放") + private String sfdgzkf; + + @ApiModelProperty("开发厂商") + private String kfcs; + + @ApiModelProperty("运维厂商") + private String ywcs; + + @ApiModelProperty("用户类型") + private String yhlx; + + @ApiModelProperty("用户范围") + private String yhfw; + + @ApiModelProperty("建设层级") + private String jscj; + + @ApiModelProperty("是否信创环境") + private String sfxchj; + + @ApiModelProperty("更新时间") + @JsonFormat(shape = JsonFormat.Shape.STRING, pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8") + @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss") + private LocalDateTime updatetime; + + @ApiModelProperty("创建时间") + @JsonFormat(shape = JsonFormat.Shape.STRING, pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8") + @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss") + private LocalDateTime createtime; +} diff --git a/ruoyi-admin/src/main/java/com/ruoyi/tc/regular/entity/UnitArchives.java b/ruoyi-admin/src/main/java/com/ruoyi/tc/regular/entity/UnitArchives.java new file mode 100644 index 0000000..e42526a --- /dev/null +++ b/ruoyi-admin/src/main/java/com/ruoyi/tc/regular/entity/UnitArchives.java @@ -0,0 +1,81 @@ +package com.ruoyi.tc.regular.entity; + +import com.fasterxml.jackson.annotation.JsonFormat; +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; +import org.springframework.format.annotation.DateTimeFormat; + +import java.time.LocalDateTime; + +/** + * 单位接口对接 + * @author du + * @since 2024/12/3 15:12 + */ +@Data +public class UnitArchives { + + @ApiModelProperty("id") + private String id; + + @ApiModelProperty("单位名称") + private String dwmc; + + @ApiModelProperty("单位简称") + private String dwjc; + + @ApiModelProperty("所属区域") + private String ssqy; + + @ApiModelProperty("单位详细地址") + private String dwxxdz; + + @ApiModelProperty("所属行业") + private String sshy; + + @ApiModelProperty("单位类型") + private String dwlx; + + @ApiModelProperty("单位标签") + private String dwbq; + + @ApiModelProperty("所属监管单位") + private String ssjgdw; + + @ApiModelProperty("单位角色") + private String dwjs; + + @ApiModelProperty("单位直属性质") + private String dwzsxz; + + @ApiModelProperty("统一社会信用代码") + private String tyshxydm; + + @ApiModelProperty("是否关基单位") + private String sfgjdw; + + @ApiModelProperty("日常运营负责部门") + private String rcyyfzbm; + + @ApiModelProperty("官网网址") + private String wz; + + @ApiModelProperty("地图经度") + private String jd; + + @ApiModelProperty("地图纬度") + private String wd; + + @ApiModelProperty("上级单位") + private String sjdw; + + @ApiModelProperty("更新时间") + @JsonFormat(shape = JsonFormat.Shape.STRING, pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8") + @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss") + private LocalDateTime updatetime; + + @ApiModelProperty("创建时间") + @JsonFormat(shape = JsonFormat.Shape.STRING, pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8") + @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss") + private LocalDateTime createtime; +} diff --git a/ruoyi-admin/src/main/java/com/ruoyi/tc/regular/entity/UnitConcat.java b/ruoyi-admin/src/main/java/com/ruoyi/tc/regular/entity/UnitConcat.java new file mode 100644 index 0000000..9ea3a6a --- /dev/null +++ b/ruoyi-admin/src/main/java/com/ruoyi/tc/regular/entity/UnitConcat.java @@ -0,0 +1,44 @@ +package com.ruoyi.tc.regular.entity; + +import com.fasterxml.jackson.annotation.JsonFormat; +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; +import org.springframework.format.annotation.DateTimeFormat; + +import java.time.LocalDateTime; + +/** + * 单位联系人接口对接 + * @author du + * @since 2024/12/3 17:23 + */ +@Data +public class UnitConcat { + @ApiModelProperty("id") + private String id; + + @ApiModelProperty("单位档案对应id") + private String dwid; + + @ApiModelProperty("姓名") + private String xm; + + @ApiModelProperty("联系方式") + private String lxfs; + + @ApiModelProperty("职务职称") + private String zwzc; + + @ApiModelProperty("联系人类型") + private String lxrlx; + + @ApiModelProperty("更新时间") + @JsonFormat(shape = JsonFormat.Shape.STRING, pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8") + @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss") + private LocalDateTime updatetime; + + @ApiModelProperty("创建时间") + @JsonFormat(shape = JsonFormat.Shape.STRING, pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8") + @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss") + private LocalDateTime createtime; +} diff --git a/ruoyi-admin/src/main/resources/application.yml b/ruoyi-admin/src/main/resources/application.yml index 656838e..826969c 100644 --- a/ruoyi-admin/src/main/resources/application.yml +++ b/ruoyi-admin/src/main/resources/application.yml @@ -134,3 +134,14 @@ xss: excludes: /system/notice # 匹配链接 urlPatterns: /system/*,/monitor/*,/tool/* + +#是否开启定时器 +isTime: false +#单位 +unitDocking: http://2.35.109.131:9193/outApiData/tcjczhapi/org_dm_dwdaxxb_7896 +#单位联系人 +unitDockingContact: http://2.35.109.131:9193/outApiData/tcjczhapi/org_dm_dwlxrb_9398 +#系统基础信息 +systemInfo: http://2.35.109.131:9193/outApiData/tcjczhapi/org_dm_xtxgxxb_1505 +#系统等保信息 +systemDb: http://2.35.109.131:9193/outApiData/tcjczhapi/org_dm_xtdbxxb_4446