|
|
@ -12,12 +12,16 @@ import com.ruoyi.tc.regular.entity.AssetDbxx;
|
|
|
|
import com.ruoyi.tc.regular.entity.AssetJcxx;
|
|
|
|
import com.ruoyi.tc.regular.entity.AssetJcxx;
|
|
|
|
import com.ruoyi.tc.service.AssetCurrentService;
|
|
|
|
import com.ruoyi.tc.service.AssetCurrentService;
|
|
|
|
import org.springframework.beans.factory.annotation.Value;
|
|
|
|
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.stereotype.Component;
|
|
|
|
import org.springframework.transaction.annotation.Transactional;
|
|
|
|
import org.springframework.transaction.annotation.Transactional;
|
|
|
|
|
|
|
|
|
|
|
|
import javax.annotation.Resource;
|
|
|
|
import javax.annotation.Resource;
|
|
|
|
import java.time.Duration;
|
|
|
|
import java.time.Duration;
|
|
|
|
import java.time.LocalDateTime;
|
|
|
|
import java.time.LocalDateTime;
|
|
|
|
|
|
|
|
import java.util.Date;
|
|
|
|
import java.util.HashMap;
|
|
|
|
import java.util.HashMap;
|
|
|
|
import java.util.Map;
|
|
|
|
import java.util.Map;
|
|
|
|
|
|
|
|
|
|
|
@ -27,9 +31,8 @@ import java.util.Map;
|
|
|
|
* @author du
|
|
|
|
* @author du
|
|
|
|
* @since 2024/12/3 17:06
|
|
|
|
* @since 2024/12/3 17:06
|
|
|
|
*/
|
|
|
|
*/
|
|
|
|
//@Configuration
|
|
|
|
@Configuration
|
|
|
|
//@EnableScheduling
|
|
|
|
@EnableScheduling
|
|
|
|
@Component
|
|
|
|
|
|
|
|
public class AssetCurrentChange {
|
|
|
|
public class AssetCurrentChange {
|
|
|
|
|
|
|
|
|
|
|
|
@Value("${isTime}")
|
|
|
|
@Value("${isTime}")
|
|
|
@ -47,7 +50,7 @@ public class AssetCurrentChange {
|
|
|
|
/**
|
|
|
|
/**
|
|
|
|
* 定时更新系统基础信息
|
|
|
|
* 定时更新系统基础信息
|
|
|
|
*/
|
|
|
|
*/
|
|
|
|
// @Scheduled(cron = "0 0 3 * * *")
|
|
|
|
@Scheduled(cron = "0 0 3 * * *")
|
|
|
|
@Transactional(rollbackFor = Exception.class)
|
|
|
|
@Transactional(rollbackFor = Exception.class)
|
|
|
|
public void assetTotal() {
|
|
|
|
public void assetTotal() {
|
|
|
|
if (isTime) {
|
|
|
|
if (isTime) {
|
|
|
@ -61,10 +64,8 @@ public class AssetCurrentChange {
|
|
|
|
.header("Content-Type", "application/json;charset=utf-8")
|
|
|
|
.header("Content-Type", "application/json;charset=utf-8")
|
|
|
|
.formStr(new HashMap<>())
|
|
|
|
.formStr(new HashMap<>())
|
|
|
|
.execute();
|
|
|
|
.execute();
|
|
|
|
System.out.println(response.getStatus());
|
|
|
|
|
|
|
|
if (response.getStatus() == 200) {
|
|
|
|
if (response.getStatus() == 200) {
|
|
|
|
JSONObject jsonObj = JSONUtil.parseObj(response.body());
|
|
|
|
JSONObject jsonObj = JSONUtil.parseObj(response.body());
|
|
|
|
System.out.println(jsonObj);
|
|
|
|
|
|
|
|
if ("200".equals(jsonObj.get("code").toString())) {
|
|
|
|
if ("200".equals(jsonObj.get("code").toString())) {
|
|
|
|
JSONObject reqData = JSONUtil.parseObj(jsonObj.get("data"));
|
|
|
|
JSONObject reqData = JSONUtil.parseObj(jsonObj.get("data"));
|
|
|
|
JSONArray arr = reqData.getJSONArray("result"); // 直接获取数组,无需再次解析
|
|
|
|
JSONArray arr = reqData.getJSONArray("result"); // 直接获取数组,无需再次解析
|
|
|
@ -192,10 +193,8 @@ public class AssetCurrentChange {
|
|
|
|
.formStr(new HashMap<>())
|
|
|
|
.formStr(new HashMap<>())
|
|
|
|
.body(jo.toString())
|
|
|
|
.body(jo.toString())
|
|
|
|
.execute();
|
|
|
|
.execute();
|
|
|
|
System.out.println(response.getStatus());
|
|
|
|
|
|
|
|
if (response.getStatus() == 200) {
|
|
|
|
if (response.getStatus() == 200) {
|
|
|
|
JSONObject jsonObj = JSONUtil.parseObj(response.body());
|
|
|
|
JSONObject jsonObj = JSONUtil.parseObj(response.body());
|
|
|
|
System.out.println(jsonObj);
|
|
|
|
|
|
|
|
if ("200".equals(jsonObj.get("code").toString())) {
|
|
|
|
if ("200".equals(jsonObj.get("code").toString())) {
|
|
|
|
JSONArray arr = jsonObj.getJSONArray("data"); // 直接获取数组,无需再次解析
|
|
|
|
JSONArray arr = jsonObj.getJSONArray("data"); // 直接获取数组,无需再次解析
|
|
|
|
if (arr.size() > 0) {
|
|
|
|
if (arr.size() > 0) {
|
|
|
@ -216,19 +215,12 @@ public class AssetCurrentChange {
|
|
|
|
/**
|
|
|
|
/**
|
|
|
|
* 判断两个LocalDateTime哪个离现在时间最近
|
|
|
|
* 判断两个LocalDateTime哪个离现在时间最近
|
|
|
|
*/
|
|
|
|
*/
|
|
|
|
public Boolean getDateBoolean(LocalDateTime a, LocalDateTime b) {
|
|
|
|
public Boolean getDateBoolean(Date a, Date b) {
|
|
|
|
LocalDateTime now = LocalDateTime.now();
|
|
|
|
long diff1 = Math.abs(System.currentTimeMillis() - a.getTime());
|
|
|
|
Duration duration1 = Duration.between(now, a);
|
|
|
|
long diff2 = Math.abs(System.currentTimeMillis() - b.getTime());
|
|
|
|
Duration duration2 = Duration.between(now, b);
|
|
|
|
if (diff1 < diff2) {
|
|
|
|
if (duration1.isNegative()) {
|
|
|
|
|
|
|
|
duration1 = duration1.negated();
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
if (duration2.isNegative()) {
|
|
|
|
|
|
|
|
duration2 = duration2.negated();
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
if (duration1.compareTo(duration2) < 0) {
|
|
|
|
|
|
|
|
return true;
|
|
|
|
return true;
|
|
|
|
} else if (duration1.compareTo(duration2) > 0) {
|
|
|
|
} else if (diff1 > diff2) {
|
|
|
|
return false;
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return false;
|
|
|
|
return false;
|
|
|
|