|
@@ -4,6 +4,9 @@ import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
|
import lombok.extern.slf4j.Slf4j;
|
|
import lombok.extern.slf4j.Slf4j;
|
|
import org.jeecg.modules.fpgJob.entity.FpgLeanModel;
|
|
import org.jeecg.modules.fpgJob.entity.FpgLeanModel;
|
|
import org.jeecg.modules.fpgJob.service.IFpgLeanModelService;
|
|
import org.jeecg.modules.fpgJob.service.IFpgLeanModelService;
|
|
|
|
+import org.jeecg.modules.gatherData.entity.FpgGatherData;
|
|
|
|
+import org.jeecg.modules.gatherData.entity.FpgStatiscsModelData;
|
|
|
|
+import org.jeecg.modules.gatherData.service.IFpgGatherDataService;
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
import org.springframework.data.mongodb.core.MongoTemplate;
|
|
import org.springframework.data.mongodb.core.MongoTemplate;
|
|
import org.springframework.data.redis.core.RedisTemplate;
|
|
import org.springframework.data.redis.core.RedisTemplate;
|
|
@@ -11,6 +14,7 @@ import org.springframework.scheduling.annotation.EnableAsync;
|
|
import org.springframework.scheduling.annotation.Scheduled;
|
|
import org.springframework.scheduling.annotation.Scheduled;
|
|
import org.springframework.stereotype.Component;
|
|
import org.springframework.stereotype.Component;
|
|
|
|
|
|
|
|
+import java.text.SimpleDateFormat;
|
|
import java.util.Date;
|
|
import java.util.Date;
|
|
import java.util.List;
|
|
import java.util.List;
|
|
|
|
|
|
@@ -23,6 +27,9 @@ public class LeanModelStatistics {
|
|
@Autowired
|
|
@Autowired
|
|
IFpgLeanModelService fpgLeanModelService;
|
|
IFpgLeanModelService fpgLeanModelService;
|
|
|
|
|
|
|
|
+ @Autowired
|
|
|
|
+ IFpgGatherDataService fpgGatherDataService;
|
|
|
|
+
|
|
@Autowired
|
|
@Autowired
|
|
MongoTemplate mongoTemplate;
|
|
MongoTemplate mongoTemplate;
|
|
|
|
|
|
@@ -38,24 +45,43 @@ public class LeanModelStatistics {
|
|
public void opc(String freq){
|
|
public void opc(String freq){
|
|
// 峰平谷精益模型配置获取
|
|
// 峰平谷精益模型配置获取
|
|
LambdaQueryWrapper<FpgLeanModel> leanmodelQuery = new LambdaQueryWrapper<FpgLeanModel>().eq(FpgLeanModel::getStatus, "1");
|
|
LambdaQueryWrapper<FpgLeanModel> leanmodelQuery = new LambdaQueryWrapper<FpgLeanModel>().eq(FpgLeanModel::getStatus, "1");
|
|
- List<FpgLeanModel> opclist = fpgLeanModelService.list(leanmodelQuery);
|
|
|
|
|
|
+ List<FpgLeanModel> fpgLeanModellist = fpgLeanModelService.list(leanmodelQuery);
|
|
log.info("峰平谷模型");
|
|
log.info("峰平谷模型");
|
|
-
|
|
|
|
//获取当前时间
|
|
//获取当前时间
|
|
Date curentDate = new Date();
|
|
Date curentDate = new Date();
|
|
- /* //遍历设备集合
|
|
|
|
- opclist.forEach(opcConn -> {
|
|
|
|
- //获取设备下所有点位
|
|
|
|
- List<DevicePoint> opcPoints = devicePointService.list( new LambdaQueryWrapper<DevicePoint>().eq(DevicePoint::getDeviceId,opcConn.getId()));
|
|
|
|
- OpcUaClient opcUaClient = null;
|
|
|
|
- String readText = "";
|
|
|
|
|
|
+ //遍历设备集合
|
|
|
|
+ fpgLeanModellist.forEach(fpgLeanModeInfo -> {
|
|
|
|
+ String datestr = "";
|
|
|
|
+ String classs = "night";
|
|
try {
|
|
try {
|
|
-
|
|
|
|
|
|
+ // 统计单位
|
|
|
|
+ if("hour". equals(fpgLeanModeInfo.getTotalUnit())){ // 小时
|
|
|
|
+ datestr = new SimpleDateFormat("H").format(curentDate);
|
|
|
|
+ } else if("day". equals(fpgLeanModeInfo.getTotalUnit())){ //
|
|
|
|
+ datestr = new SimpleDateFormat("dd").format(curentDate);
|
|
|
|
+ } else if("week". equals(fpgLeanModeInfo.getTotalUnit())){ //
|
|
|
|
+ datestr = new SimpleDateFormat("").format(curentDate);
|
|
|
|
+ } else if("month". equals(fpgLeanModeInfo.getTotalUnit())){ //
|
|
|
|
+ datestr = new SimpleDateFormat("MM").format(curentDate);
|
|
|
|
+ }
|
|
|
|
+ // 班次处理
|
|
|
|
+ if(fpgLeanModeInfo.getClassUnit() == 1){ // 开启了班次统计
|
|
|
|
+ if("night". equals(fpgLeanModeInfo.getTotalUnit())){ // 夜班
|
|
|
|
+ classs = "";
|
|
|
|
+ } else if("white". equals(fpgLeanModeInfo.getTotalUnit())){ // 白班
|
|
|
|
+ classs = "";
|
|
|
|
+ } else if("center". equals(fpgLeanModeInfo.getTotalUnit())){ // 中班
|
|
|
|
+ classs = "";
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ FpgGatherData FpgGatherData = fpgGatherDataService.getById("1836591252581129108");
|
|
|
|
+ //将点位数据存入mongo中
|
|
|
|
+ mongoTemplate.insert(new FpgStatiscsModelData(FpgGatherData, fpgLeanModeInfo, datestr, new SimpleDateFormat("yyyy-MM-dd").format(curentDate), classs, curentDate, curentDate), fpgLeanModeInfo.getLeanModelCode());
|
|
} catch (Exception e) {
|
|
} catch (Exception e) {
|
|
log.error(e.getMessage());
|
|
log.error(e.getMessage());
|
|
} finally {
|
|
} finally {
|
|
|
|
|
|
}
|
|
}
|
|
- });*/
|
|
|
|
|
|
+ });
|
|
}
|
|
}
|
|
}
|
|
}
|