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 e991e16..e6f0f67 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 @@ -8,6 +8,7 @@ import lombok.Data; import org.springframework.format.annotation.DateTimeFormat; import java.time.LocalDateTime; +import java.util.Date; /** * 公共实体类 @@ -30,7 +31,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 LocalDateTime createTime; + private Date createTime; /** * 更新者 @@ -46,7 +47,7 @@ public class BaseClass { @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 LocalDateTime updateTime; + private Date updateTime; private String remark; diff --git a/ruoyi-admin/src/main/java/com/ruoyi/tc/controller/AssetAppController.java b/ruoyi-admin/src/main/java/com/ruoyi/tc/controller/AssetAppController.java index 635be26..b5259e4 100644 --- a/ruoyi-admin/src/main/java/com/ruoyi/tc/controller/AssetAppController.java +++ b/ruoyi-admin/src/main/java/com/ruoyi/tc/controller/AssetAppController.java @@ -88,7 +88,7 @@ public class AssetAppController extends BaseController { @ApiOperation(value = "编辑数据") @Log(title = "编辑app数据", businessType = BusinessType.UPDATE) @PutMapping - public AjaxResult edit(AssetApp assetApp) { + public AjaxResult edit(@RequestBody AssetApp assetApp) { return success(assetAppService.updateById(assetApp)); } diff --git a/ruoyi-admin/src/main/java/com/ruoyi/tc/controller/AssetEmailController.java b/ruoyi-admin/src/main/java/com/ruoyi/tc/controller/AssetEmailController.java index 002fbf6..31d17bb 100644 --- a/ruoyi-admin/src/main/java/com/ruoyi/tc/controller/AssetEmailController.java +++ b/ruoyi-admin/src/main/java/com/ruoyi/tc/controller/AssetEmailController.java @@ -86,7 +86,7 @@ public class AssetEmailController extends BaseController { @ApiOperation(value = "编辑email数据") @Log(title = "编辑email数据", businessType = BusinessType.UPDATE) @PutMapping - public AjaxResult edit(AssetEmail assetEmail) { + public AjaxResult edit(@RequestBody AssetEmail assetEmail) { return success(assetEmailService.updateById(assetEmail)); } diff --git a/ruoyi-admin/src/main/java/com/ruoyi/tc/controller/AssetMiniProgramsController.java b/ruoyi-admin/src/main/java/com/ruoyi/tc/controller/AssetMiniProgramsController.java index 38b71f7..4fb80e5 100644 --- a/ruoyi-admin/src/main/java/com/ruoyi/tc/controller/AssetMiniProgramsController.java +++ b/ruoyi-admin/src/main/java/com/ruoyi/tc/controller/AssetMiniProgramsController.java @@ -88,7 +88,7 @@ public class AssetMiniProgramsController extends BaseController { @ApiOperation(value = "编辑小程序数据") @Log(title = "编辑小程序数据", businessType = BusinessType.UPDATE) @PutMapping - public AjaxResult edit(AssetMiniPrograms assetMiniPrograms) { + public AjaxResult edit(@RequestBody AssetMiniPrograms assetMiniPrograms) { return success(assetMiniProgramsService.updateById(assetMiniPrograms)); } diff --git a/ruoyi-admin/src/main/java/com/ruoyi/tc/controller/AssetOfficialAccountController.java b/ruoyi-admin/src/main/java/com/ruoyi/tc/controller/AssetOfficialAccountController.java index 4a4fc23..ebba899 100644 --- a/ruoyi-admin/src/main/java/com/ruoyi/tc/controller/AssetOfficialAccountController.java +++ b/ruoyi-admin/src/main/java/com/ruoyi/tc/controller/AssetOfficialAccountController.java @@ -89,7 +89,7 @@ public class AssetOfficialAccountController { @ApiOperation(value = "编辑公众号数据") @Log(title = "编辑公众号数据", businessType = BusinessType.UPDATE) @PutMapping - public AjaxResult edit(AssetOfficialAccount assetOfficialAccount) { + public AjaxResult edit(@RequestBody AssetOfficialAccount assetOfficialAccount) { return success(assetOfficialAccountService.updateById(assetOfficialAccount)); } 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 1ac0508..5ab6772 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,9 +1,5 @@ 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; @@ -25,7 +21,6 @@ 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.*; @@ -44,7 +39,7 @@ import java.util.*; */ @Api(tags = "单位表控制层") @RestController -//@PreAuthorize("@ss.hasAnyRoles('admin,common')") +@PreAuthorize("@ss.hasAnyRoles('admin,common')") @RequestMapping("/tc/unit") public class UnitController { diff --git a/ruoyi-admin/src/main/java/com/ruoyi/tc/entity/AssetMiniPrograms.java b/ruoyi-admin/src/main/java/com/ruoyi/tc/entity/AssetMiniPrograms.java index 32608ec..f07a30f 100644 --- a/ruoyi-admin/src/main/java/com/ruoyi/tc/entity/AssetMiniPrograms.java +++ b/ruoyi-admin/src/main/java/com/ruoyi/tc/entity/AssetMiniPrograms.java @@ -1,6 +1,7 @@ package com.ruoyi.tc.entity; import com.baomidou.mybatisplus.annotation.IdType; +import com.baomidou.mybatisplus.annotation.TableField; import com.baomidou.mybatisplus.annotation.TableId; import com.baomidou.mybatisplus.annotation.TableName; import com.ruoyi.common.annotation.Excel; 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 index 5203d30..ba2a2ad 100644 --- a/ruoyi-admin/src/main/java/com/ruoyi/tc/regular/AssetCurrentChange.java +++ b/ruoyi-admin/src/main/java/com/ruoyi/tc/regular/AssetCurrentChange.java @@ -12,12 +12,16 @@ 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.context.annotation.Configuration; +import org.springframework.scheduling.annotation.EnableScheduling; +import org.springframework.scheduling.annotation.Scheduled; 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.Date; import java.util.HashMap; import java.util.Map; @@ -27,9 +31,8 @@ import java.util.Map; * @author du * @since 2024/12/3 17:06 */ -//@Configuration -//@EnableScheduling -@Component +@Configuration +@EnableScheduling public class AssetCurrentChange { @Value("${isTime}") @@ -47,7 +50,7 @@ public class AssetCurrentChange { /** * 定时更新系统基础信息 */ -// @Scheduled(cron = "0 0 3 * * *") + @Scheduled(cron = "0 0 3 * * *") @Transactional(rollbackFor = Exception.class) public void assetTotal() { if (isTime) { @@ -61,10 +64,8 @@ public class AssetCurrentChange { .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"); // 直接获取数组,无需再次解析 @@ -192,10 +193,8 @@ public class AssetCurrentChange { .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) { @@ -216,19 +215,12 @@ public class AssetCurrentChange { /** * 判断两个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) { + public Boolean getDateBoolean(Date a, Date b) { + long diff1 = Math.abs(System.currentTimeMillis() - a.getTime()); + long diff2 = Math.abs(System.currentTimeMillis() - b.getTime()); + if (diff1 < diff2) { return true; - } else if (duration1.compareTo(duration2) > 0) { + } else if (diff1 > diff2) { 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 index 3f4519c..da95942 100644 --- a/ruoyi-admin/src/main/java/com/ruoyi/tc/regular/UnitChange.java +++ b/ruoyi-admin/src/main/java/com/ruoyi/tc/regular/UnitChange.java @@ -14,12 +14,16 @@ 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.context.annotation.Configuration; +import org.springframework.scheduling.annotation.EnableScheduling; +import org.springframework.scheduling.annotation.Scheduled; 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.Date; import java.util.HashMap; import java.util.List; import java.util.Map; @@ -30,9 +34,8 @@ import java.util.Map; * @author du * @since 2024/12/3 10:59 */ -//@Configuration -//@EnableScheduling -@Component +@Configuration +@EnableScheduling public class UnitChange { @Value("${isTime}") @@ -53,7 +56,7 @@ public class UnitChange { /** * 定时更新单位档案信息 */ -// @Scheduled(cron = "0 0 2 * * *") + @Scheduled(cron = "0 0 2 * * *") @Transactional(rollbackFor = Exception.class) public void unitTotal() { if (isTime) { @@ -226,19 +229,12 @@ public class UnitChange { /** * 判断两个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) { + public Boolean getDateBoolean(Date a, Date b) { + long diff1 = Math.abs(System.currentTimeMillis() - a.getTime()); + long diff2 = Math.abs(System.currentTimeMillis() - b.getTime()); + if (diff1 < diff2) { return true; - } else if (duration1.compareTo(duration2) > 0) { + } else if (diff1 > diff2) { 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 index 9311738..55384ad 100644 --- 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 @@ -6,6 +6,7 @@ import lombok.Data; import org.springframework.format.annotation.DateTimeFormat; import java.time.LocalDateTime; +import java.util.Date; /** * 系统等保信息对接实体类 @@ -74,10 +75,10 @@ public class AssetDbxx { @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; + private Date 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; + private Date 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 index 3b3670d..f9af4a5 100644 --- 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 @@ -6,6 +6,7 @@ import lombok.Data; import org.springframework.format.annotation.DateTimeFormat; import java.time.LocalDateTime; +import java.util.Date; /** * 系统基础信息对接实体类 @@ -94,10 +95,10 @@ public class AssetJcxx { @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; + private Date 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; + private Date 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 index e42526a..6286ebf 100644 --- 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 @@ -6,6 +6,7 @@ import lombok.Data; import org.springframework.format.annotation.DateTimeFormat; import java.time.LocalDateTime; +import java.util.Date; /** * 单位接口对接 @@ -72,10 +73,10 @@ public class UnitArchives { @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; + private Date 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; + private Date 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 index 9ea3a6a..1a11929 100644 --- 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 @@ -6,6 +6,7 @@ import lombok.Data; import org.springframework.format.annotation.DateTimeFormat; import java.time.LocalDateTime; +import java.util.Date; /** * 单位联系人接口对接 @@ -35,10 +36,10 @@ public class UnitConcat { @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; + private Date 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; + private Date createtime; } diff --git a/ruoyi-admin/src/main/java/com/ruoyi/tc/service/impl/AssetCurrentServiceImpl.java b/ruoyi-admin/src/main/java/com/ruoyi/tc/service/impl/AssetCurrentServiceImpl.java index 92db5a2..f8b380c 100644 --- a/ruoyi-admin/src/main/java/com/ruoyi/tc/service/impl/AssetCurrentServiceImpl.java +++ b/ruoyi-admin/src/main/java/com/ruoyi/tc/service/impl/AssetCurrentServiceImpl.java @@ -73,19 +73,23 @@ public class AssetCurrentServiceImpl extends ServiceImpl a1 = new ArrayList<>(); - Arrays.asList(byId.getGlym().split(",")).forEach(x -> { - Acomma acomma = new Acomma(); - acomma.setKey(x); - a1.add(acomma); - }); - byId.setGlymList(a1); + if(byId.getGlym()!=null){ + Arrays.asList(byId.getGlym().split(",")).forEach(x -> { + Acomma acomma = new Acomma(); + acomma.setKey(x); + a1.add(acomma); + }); + byId.setGlymList(a1); + } List a2 = new ArrayList<>(); - Arrays.asList(byId.getGlIp().split(",")).forEach(x -> { - Acomma acomma = new Acomma(); - acomma.setKey(x); - a2.add(acomma); - }); - byId.setGlIpList(a2); + if(byId.getGlIp()!=null){ + Arrays.asList(byId.getGlIp().split(",")).forEach(x -> { + Acomma acomma = new Acomma(); + acomma.setKey(x); + a2.add(acomma); + }); + byId.setGlIpList(a2); + } return byId; }