|
@@ -15,9 +15,13 @@ import cn.iocoder.yudao.module.pms.dal.dataobject.iotmodel.IotModelDO;
|
|
|
import cn.iocoder.yudao.module.pms.dal.dataobject.iotmodeltemplateattrs.IotModelTemplateAttrsDO;
|
|
|
import cn.iocoder.yudao.module.pms.dal.dataobject.iotmodeltemplateattrs.IotThingsModelDO;
|
|
|
import cn.iocoder.yudao.module.pms.dal.dataobject.iotopeationfill.IotOpeationFillDO;
|
|
|
+import cn.iocoder.yudao.module.pms.dal.dataobject.iotopeationfill.IotOpeationFillOrderDO;
|
|
|
+import cn.iocoder.yudao.module.pms.dal.dataobject.yanfan.YfDeviceDO;
|
|
|
import cn.iocoder.yudao.module.pms.service.IDeviceService;
|
|
|
import cn.iocoder.yudao.module.pms.service.iotopeationfill.IotOpeationFillService;
|
|
|
+import cn.iocoder.yudao.module.pms.service.yanfan.YfDeviceService;
|
|
|
import com.aliyun.tea.utils.StringUtils;
|
|
|
+import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.web.bind.annotation.*;
|
|
|
import javax.annotation.Resource;
|
|
|
import org.springframework.validation.annotation.Validated;
|
|
@@ -30,6 +34,7 @@ import javax.annotation.security.PermitAll;
|
|
|
import javax.validation.constraints.*;
|
|
|
import javax.validation.*;
|
|
|
import javax.servlet.http.*;
|
|
|
+import java.sql.SQLException;
|
|
|
import java.time.LocalDate;
|
|
|
import java.time.LocalDateTime;
|
|
|
import java.util.*;
|
|
@@ -57,6 +62,8 @@ public class IotOpeationFillController {
|
|
|
private IotOpeationFillService iotOpeationFillService;
|
|
|
@Resource
|
|
|
private IDeviceService iDeviceService;
|
|
|
+ @Autowired
|
|
|
+ private YfDeviceService yfDeviceService;
|
|
|
|
|
|
@PostMapping("/create")
|
|
|
@Operation(summary = "创建运行记录填报")
|
|
@@ -116,23 +123,29 @@ public class IotOpeationFillController {
|
|
|
@Operation(summary = "获得运行记录填报分页")
|
|
|
@PreAuthorize("@ss.hasPermission('rq:iot-opeation-fill:query')")
|
|
|
public CommonResult<List<IotOpeationFillDO>> getIotOpeationFillPage(@Valid IotOpeationFillPageReqVO pageReqVO) {
|
|
|
- List<IotOpeationFillDO> fillList = iotOpeationFillService.fillList(pageReqVO);
|
|
|
- List<IotOpeationFillDO> pageResult = iotOpeationFillService.getFillDevices(pageReqVO);
|
|
|
- if(fillList.size()==0){
|
|
|
- for (IotOpeationFillDO re:pageResult) {
|
|
|
- re.setDeviceId(re.getId());
|
|
|
- }
|
|
|
- iotOpeationFillService.insertFill(pageResult);
|
|
|
+ List<IotOpeationFillDO> fillList = new ArrayList<>();
|
|
|
+ List<IotOpeationFillDO> deviceList = iotOpeationFillService.deviceList(pageReqVO);
|
|
|
+ if(deviceList.size()==0){
|
|
|
+ fillList = iotOpeationFillService.fillListByDeptId(pageReqVO);
|
|
|
+ }else{
|
|
|
+ fillList = iotOpeationFillService.fillListByUserId(pageReqVO);
|
|
|
}
|
|
|
- fillList = iotOpeationFillService.fillList(pageReqVO);
|
|
|
return success(BeanUtils.toBean(fillList, IotOpeationFillDO.class));
|
|
|
}
|
|
|
|
|
|
+ @GetMapping("/page1")
|
|
|
+ @Operation(summary = "获得运行记录填报分页")
|
|
|
+ @PreAuthorize("@ss.hasPermission('rq:iot-opeation-fill:query')")
|
|
|
+ public CommonResult<PageResult<IotOpeationFillOrderDO>> getIotOpeationFillPage1(@Valid IotOpeationFillPageReqVO pageReqVO) {
|
|
|
+ PageResult<IotOpeationFillOrderDO> fillList = iotOpeationFillService.fillList1(pageReqVO);
|
|
|
+ return success(BeanUtils.toBean(fillList, IotOpeationFillOrderDO.class));
|
|
|
+ }
|
|
|
+
|
|
|
@GetMapping("/getAttrs")
|
|
|
@PermitAll
|
|
|
@Operation(summary = "获得PMS 功能优化 设备模板属性")
|
|
|
@Parameter(name = "deviceCategoryName", description = "名称", required = true, example = "1024")
|
|
|
- public CommonResult<List<IotModelTemplateAttrsDO>> getModelAttrs(@Valid IotModelTemplateAttrsRespVO vo) {
|
|
|
+ public CommonResult<List<IotModelTemplateAttrsDO>> getModelAttrs(@Valid IotModelTemplateAttrsRespVO vo) throws SQLException{
|
|
|
List<IotModelTemplateAttrsDO> list = iotOpeationFillService.getAttrsById(vo );
|
|
|
|
|
|
/**
|
|
@@ -142,14 +155,21 @@ public class IotOpeationFillController {
|
|
|
* 3、数采无值,已填写 满足
|
|
|
* 4、数采无值,未填写 满足
|
|
|
*/
|
|
|
- for (IotModelTemplateAttrsDO attrsDO:list) {
|
|
|
- DeviceVO dv= new DeviceVO();
|
|
|
- dv.setDeviceName(vo.getDeviceCode().toLowerCase());
|
|
|
- dv.setColName(attrsDO.getModelAttr());
|
|
|
- DeviceVO deviceVO = iDeviceService.getYesInfo(dv);
|
|
|
- if(!StringUtils.isEmpty(deviceVO)){
|
|
|
- attrsDO.setFillContent(
|
|
|
- String.valueOf(Double.parseDouble(deviceVO.getLatestData())-Double.parseDouble(deviceVO.getEarliestData())));
|
|
|
+ List<YfDeviceDO> allDevice = yfDeviceService.getAllDevice();
|
|
|
+
|
|
|
+ boolean exists = allDevice.stream()
|
|
|
+ .anyMatch(yfDeviceDO -> yfDeviceDO.getSerialNumber().equals(vo.getDeviceCode()));
|
|
|
+
|
|
|
+ if(exists){
|
|
|
+ for (IotModelTemplateAttrsDO attrsDO:list) {
|
|
|
+ DeviceVO dv= new DeviceVO();
|
|
|
+ dv.setDeviceName(vo.getDeviceCode().toLowerCase());
|
|
|
+ dv.setColName(attrsDO.getModelAttr());
|
|
|
+ DeviceVO deviceVO = iDeviceService.getYesInfo(dv);
|
|
|
+ if(!StringUtils.isEmpty(deviceVO)){
|
|
|
+ attrsDO.setFillContent(
|
|
|
+ String.valueOf(Double.parseDouble(deviceVO.getLatestData())-Double.parseDouble(deviceVO.getEarliestData())));
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
|