2023-12-02 11:10:52 +08:00
|
|
|
|
package com.zhgd.xmgl.task;
|
|
|
|
|
|
|
|
|
|
|
|
import cn.hutool.core.bean.BeanUtil;
|
|
|
|
|
|
import com.alibaba.fastjson.JSON;
|
2023-12-02 17:16:10 +08:00
|
|
|
|
import com.alibaba.fastjson.JSONArray;
|
2023-12-02 11:10:52 +08:00
|
|
|
|
import com.alibaba.fastjson.JSONObject;
|
2023-12-02 17:16:10 +08:00
|
|
|
|
import com.zhgd.xmgl.modules.stablewater.entity.StableWaterMixStationData;
|
|
|
|
|
|
import com.zhgd.xmgl.modules.stablewater.entity.StableWaterMixStationRawMaterialData;
|
|
|
|
|
|
import com.zhgd.xmgl.modules.stablewater.entity.StableWaterMixStationSetData;
|
|
|
|
|
|
import com.zhgd.xmgl.modules.stablewater.service.IStableWaterMixStationDataService;
|
2023-12-02 11:10:52 +08:00
|
|
|
|
import com.zhgd.xmgl.util.ThirdPartRequestUtil;
|
|
|
|
|
|
import lombok.extern.log4j.Log4j;
|
|
|
|
|
|
import net.javacrumbs.shedlock.core.SchedulerLock;
|
|
|
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
|
|
|
import org.springframework.scheduling.annotation.Scheduled;
|
|
|
|
|
|
import org.springframework.stereotype.Component;
|
|
|
|
|
|
|
2023-12-02 17:16:10 +08:00
|
|
|
|
import java.util.ArrayList;
|
|
|
|
|
|
import java.util.List;
|
2023-12-02 11:10:52 +08:00
|
|
|
|
import java.util.Objects;
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
|
* 水稳拌合站任务
|
|
|
|
|
|
*/
|
|
|
|
|
|
@Log4j
|
|
|
|
|
|
@Component
|
|
|
|
|
|
public class StableWaterMixStationTask {
|
|
|
|
|
|
@Autowired
|
|
|
|
|
|
ThirdPartRequestUtil thirdPartRequestUtil;
|
2023-12-02 17:16:10 +08:00
|
|
|
|
@Autowired
|
|
|
|
|
|
IStableWaterMixStationDataService stableWaterMixStationDataService;
|
|
|
|
|
|
|
2023-12-02 11:10:52 +08:00
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
|
* 定时拉取广联达的搅拌站数据,https://xmgl.glodon.com/wl/docs/third_help/part2/openapi/pull/mixTotal.html
|
|
|
|
|
|
*/
|
|
|
|
|
|
@Scheduled(cron = "0 2 0 * * ?")
|
|
|
|
|
|
@SchedulerLock(name = "executeStableWaterMixStationTask", lockAtMostFor = 1000 * 60 * 2, lockAtLeastFor = 1000 * 60 * 1)
|
|
|
|
|
|
public void executeTask() {
|
|
|
|
|
|
log.info("定时拉取广联达的搅拌站数据任务开始");
|
|
|
|
|
|
//String url = "/api/mix/v1.0/mix/product/getMachineProductList?projectId=1460369&beginTimestamp=20170710101010000";
|
|
|
|
|
|
//String rs = thirdPartRequestUtil.get(url);
|
|
|
|
|
|
//JSONObject jo = JSON.parseObject(rs);
|
|
|
|
|
|
//if (Objects.equals(jo.getBoolean("success"), true)) {
|
2023-12-02 17:16:10 +08:00
|
|
|
|
// JSONObject dataJson = jo.getJSONObject("data");
|
|
|
|
|
|
// JSONArray bills = dataJson.getJSONArray("Bills");
|
|
|
|
|
|
// for (Object bill : bills) {
|
|
|
|
|
|
// StableWaterMixStationData data = new StableWaterMixStationData();
|
|
|
|
|
|
// List<StableWaterMixStationSetData> setDataList = new ArrayList<>();
|
|
|
|
|
|
// data.setSetDataList(setDataList);
|
|
|
|
|
|
// BeanUtil.copyProperties(bill, data, true);
|
|
|
|
|
|
// JSONArray pcList = ((JSONObject) bill).getJSONArray("PCList");
|
|
|
|
|
|
// for (Object pc : pcList) {
|
|
|
|
|
|
// StableWaterMixStationSetData setData = new StableWaterMixStationSetData();
|
|
|
|
|
|
// BeanUtil.copyProperties(pc, setData, true);
|
|
|
|
|
|
// setDataList.add(setData);
|
|
|
|
|
|
// List<StableWaterMixStationRawMaterialData> rawMaterialDataList = new ArrayList<>();
|
|
|
|
|
|
// setData.setRawMaterialDataList(rawMaterialDataList);
|
|
|
|
|
|
// JSONArray ycList = ((JSONObject) pc).getJSONArray("YCList");
|
|
|
|
|
|
// for (Object yc : ycList) {
|
|
|
|
|
|
// StableWaterMixStationRawMaterialData rawMaterialData = new StableWaterMixStationRawMaterialData();
|
|
|
|
|
|
// BeanUtil.copyProperties(yc, rawMaterialData, true);
|
|
|
|
|
|
// rawMaterialDataList.add(rawMaterialData);
|
|
|
|
|
|
// }
|
|
|
|
|
|
// }
|
|
|
|
|
|
// stableWaterMixStationDataService.add(data);
|
|
|
|
|
|
// }
|
2023-12-02 11:10:52 +08:00
|
|
|
|
//}
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|