|
|
|
@ -6,6 +6,7 @@ import com.wanhua.lng.daySale.model.SaleDaily;
|
|
|
|
|
import com.wanhua.lng.daySale.model.SaleDailyInfo;
|
|
|
|
|
import com.wanhua.lng.daySale.service.impl.SaleDailyInfoServiceImpl;
|
|
|
|
|
import com.wanhua.lng.daySale.service.impl.SaleDailyServiceImpl;
|
|
|
|
|
import com.wanhua.lng.daySale.utils.PaymentMethod;
|
|
|
|
|
import com.wanhua.stationservice.baseDaoService.service.impl.PumpServiceImpl;
|
|
|
|
|
import com.wanhua.stationservice.baseutils.security.CommonBasedAESUtil;
|
|
|
|
|
import com.wanhua.stationv3.data.collector.CollectorTest;
|
|
|
|
@ -19,6 +20,8 @@ import org.slf4j.LoggerFactory;
|
|
|
|
|
|
|
|
|
|
import java.time.LocalDate;
|
|
|
|
|
import java.time.format.DateTimeFormatter;
|
|
|
|
|
import java.util.ArrayList;
|
|
|
|
|
import java.util.List;
|
|
|
|
|
import java.util.Map;
|
|
|
|
|
import java.util.concurrent.TimeUnit;
|
|
|
|
|
|
|
|
|
@ -73,71 +76,115 @@ public class LngCollectorJob {
|
|
|
|
|
String start = times.split("/")[0];
|
|
|
|
|
String end = times.split("/")[1];
|
|
|
|
|
|
|
|
|
|
List<String> timeList = getDatesBetween(start,end);
|
|
|
|
|
for(String time : timeList){
|
|
|
|
|
String[] codes = code.split(",");
|
|
|
|
|
for (String codeParam : codes){
|
|
|
|
|
getInfo(codeParam,time,token);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}else{
|
|
|
|
|
String[] codes = code.split(",");
|
|
|
|
|
for (String codeParam : codes){
|
|
|
|
|
XxlJobHelper.log("start get data:"+codeParam+",time:"+formattedDate);
|
|
|
|
|
Map<String,Object> dataMap = LngCollector.getTankGunInfo(codeParam,formattedDate,token);
|
|
|
|
|
getInfo(codeParam,formattedDate,token);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
String businessDay = dataMap.get("businessDay").toString();
|
|
|
|
|
|
|
|
|
|
// 期初库存、本期进货、加气机发出量、数量、单价、本期损溢处理、期末库存
|
|
|
|
|
JSONArray gasSoldList =(JSONArray) dataMap.get("gasSoldList");
|
|
|
|
|
|
|
|
|
|
private static List<String> getDatesBetween(String startDateStr, String endDateStr) {
|
|
|
|
|
// 定义日期格式
|
|
|
|
|
DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd");
|
|
|
|
|
|
|
|
|
|
// 将字符串转换为 LocalDate
|
|
|
|
|
LocalDate startDate = LocalDate.parse(startDateStr, formatter);
|
|
|
|
|
LocalDate endDate = LocalDate.parse(endDateStr, formatter);
|
|
|
|
|
|
|
|
|
|
if(gasSoldList.size()>0){
|
|
|
|
|
JSONObject sold = gasSoldList.getJSONObject(0);
|
|
|
|
|
SaleDaily daily = new SaleDaily();
|
|
|
|
|
daily.setBusinessDay(businessDay);
|
|
|
|
|
daily.setStationCode(code);
|
|
|
|
|
daily.setStartVolume(sold.get("startVolume").toString());
|
|
|
|
|
daily.setEndVolume(sold.get("endVolume").toString());
|
|
|
|
|
daily.setPurchaseVolume(sold.get("purchaseVolume").toString());
|
|
|
|
|
daily.setIssuedVolume(sold.get("issuedVolume").toString());
|
|
|
|
|
daily.setProfitLossVolume(sold.get("profitLossVolume").toString());
|
|
|
|
|
|
|
|
|
|
JSONArray gasSoldItemList = sold.getJSONArray("gasSoldItemList");
|
|
|
|
|
if(gasSoldItemList.size()>0){
|
|
|
|
|
JSONObject gasSold = gasSoldItemList.getJSONObject(0);
|
|
|
|
|
daily.setUnitPrice(gasSold.get("unitPrice").toString());
|
|
|
|
|
daily.setSalesVolume(gasSold.get("salesVolume").toString());
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
dailyServiceImpl.saveOne(daily);
|
|
|
|
|
}
|
|
|
|
|
List<String> datesInRange = new ArrayList<>();
|
|
|
|
|
|
|
|
|
|
// 使用 while 循环获取范围内的所有日期
|
|
|
|
|
while (!startDate.isAfter(endDate)) {
|
|
|
|
|
// 将每个日期格式化为字符串并添加到列表中
|
|
|
|
|
datesInRange.add(startDate.format(formatter));
|
|
|
|
|
// 日期递增一天
|
|
|
|
|
startDate = startDate.plusDays(1);
|
|
|
|
|
}
|
|
|
|
|
return datesInRange;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//不同支付类型销售数据统计
|
|
|
|
|
JSONArray gasPaymentList =(JSONArray) dataMap.get("gasPaymentList");
|
|
|
|
|
if(gasSoldList.size()>0){
|
|
|
|
|
// for(Object info : gasPaymentList) {
|
|
|
|
|
// JSONObject sold = (JSONObject) JSONObject.toJSON(info);
|
|
|
|
|
// SaleDailyInfo daily = new SaleDailyInfo();
|
|
|
|
|
// daily.setBusinessDay(businessDay);
|
|
|
|
|
// daily.setStationCode(code);
|
|
|
|
|
// daily.setUnitPrice(sold.get("unitPrice"));
|
|
|
|
|
// daily.setEndVolume(sold.get("endVolume").toString());
|
|
|
|
|
// daily.setPurchaseVolume(sold.get("purchaseVolume").toString());
|
|
|
|
|
// daily.setIssuedVolume(sold.get("issuedVolume").toString());
|
|
|
|
|
// daily.setProfitLossVolume(sold.get("profitLossVolume").toString());
|
|
|
|
|
//
|
|
|
|
|
// JSONArray gasSoldItemList = sold.getJSONArray("gasSoldItemList");
|
|
|
|
|
// if (gasSoldItemList.size() > 0) {
|
|
|
|
|
// JSONObject gasSold = gasSoldItemList.getJSONObject(0);
|
|
|
|
|
// daily.setUnitPrice(gasSold.get("unitPrice").toString());
|
|
|
|
|
// daily.setSalesVolume(gasSold.get("salesVolume").toString());
|
|
|
|
|
// }
|
|
|
|
|
//
|
|
|
|
|
// dailyInfoServiceImpl.saveOne(daily);
|
|
|
|
|
// }
|
|
|
|
|
}
|
|
|
|
|
XxlJobHelper.log("start get data:"+codeParam+" end");
|
|
|
|
|
private void getInfo(String codeParam,String formattedDate,String token){
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
XxlJobHelper.log("start get data:"+codeParam+",time:"+formattedDate);
|
|
|
|
|
Map<String,Object> dataMap = LngCollector.getTankGunInfo(codeParam,formattedDate,token);
|
|
|
|
|
|
|
|
|
|
XxlJobHelper.log("get data info :"+JSONObject.toJSONString(dataMap));
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
String businessDay = dataMap.get("businessDay").toString();
|
|
|
|
|
|
|
|
|
|
// 期初库存、本期进货、加气机发出量、数量、单价、本期损溢处理、期末库存
|
|
|
|
|
JSONArray gasSoldList =(JSONArray) dataMap.get("gasSoldList");
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if(gasSoldList.size()>0){
|
|
|
|
|
JSONObject sold = gasSoldList.getJSONObject(0);
|
|
|
|
|
SaleDaily daily = new SaleDaily();
|
|
|
|
|
daily.setBusinessDay(businessDay);
|
|
|
|
|
daily.setStationCode(codeParam);
|
|
|
|
|
daily.setStartVolume(sold.get("startVolume").toString());
|
|
|
|
|
daily.setFuelShortName(sold.get("fuelName").toString());
|
|
|
|
|
daily.setFuelNo(sold.get("fuelNo").toString());
|
|
|
|
|
daily.setEndVolume(sold.get("endVolume").toString());
|
|
|
|
|
daily.setPurchaseVolume(sold.get("purchaseVolume").toString());
|
|
|
|
|
daily.setIssuedVolume(sold.get("issuedVolume").toString());
|
|
|
|
|
daily.setProfitLossVolume(sold.get("profitLossVolume").toString());
|
|
|
|
|
|
|
|
|
|
JSONArray gasSoldItemList = sold.getJSONArray("gasSoldItemList");
|
|
|
|
|
if(gasSoldItemList.size()>0){
|
|
|
|
|
JSONObject gasSold = gasSoldItemList.getJSONObject(0);
|
|
|
|
|
daily.setUnitPrice(gasSold.get("unitPrice").toString());
|
|
|
|
|
daily.setSalesVolume(gasSold.get("salesVolume").toString());
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
dailyServiceImpl.saveOne(daily);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//不同支付类型销售数据统计
|
|
|
|
|
JSONArray gasPaymentList =(JSONArray) dataMap.get("gasPaymentList");
|
|
|
|
|
if(gasSoldList.size()>0){
|
|
|
|
|
for(Object info : gasPaymentList) {
|
|
|
|
|
JSONObject sold = (JSONObject) JSONObject.toJSON(info);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
JSONArray gasPaymentItemList =(JSONArray) sold.get("gasPaymentItemList");
|
|
|
|
|
|
|
|
|
|
XxlJobHelper.log("gasPaymentList get data info :"+JSONObject.toJSONString(sold));
|
|
|
|
|
|
|
|
|
|
for(Object item : gasPaymentItemList) {
|
|
|
|
|
|
|
|
|
|
JSONObject gasItem = (JSONObject) JSONObject.toJSON(item);
|
|
|
|
|
XxlJobHelper.log("gasPaymentItemList get data info :"+JSONObject.toJSONString(gasItem));
|
|
|
|
|
|
|
|
|
|
SaleDailyInfo daily = new SaleDailyInfo();
|
|
|
|
|
daily.setBusinessDay(businessDay);
|
|
|
|
|
daily.setStationCode(codeParam);
|
|
|
|
|
daily.setUnitPrice(gasItem.get("unitPrice").toString());
|
|
|
|
|
daily.setSalesVolume(gasItem.get("salesVolume").toString());
|
|
|
|
|
daily.setFuelNo(gasItem.get("fuelNo").toString());
|
|
|
|
|
daily.setFuelShortName(gasItem.get("fuelName").toString());
|
|
|
|
|
daily.setPaymentMethod(PaymentMethod.getName(sold.get("paymentMethod").toString()));
|
|
|
|
|
daily.setReceivedAmount(gasItem.get("receivedAmount").toString());
|
|
|
|
|
daily.setTotalPaymentAmount(sold.get("totalPaymentAmount").toString());
|
|
|
|
|
dailyInfoServiceImpl.saveOne(daily);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
XxlJobHelper.log("start get data:"+codeParam+" end");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|