|
@@ -16,9 +16,12 @@ import cn.iocoder.yudao.module.pms.dal.dataobject.iotmodeltemplateattrs.IotModel
|
|
|
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;
|
|
@@ -31,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.*;
|
|
@@ -58,6 +62,8 @@ public class IotOpeationFillController {
|
|
|
private IotOpeationFillService iotOpeationFillService;
|
|
|
@Resource
|
|
|
private IDeviceService iDeviceService;
|
|
|
+ @Autowired
|
|
|
+ private YfDeviceService yfDeviceService;
|
|
|
|
|
|
@PostMapping("/create")
|
|
|
@Operation(summary = "创建运行记录填报")
|
|
@@ -117,7 +123,13 @@ 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> fillList = new ArrayList<>();
|
|
|
+ List<IotOpeationFillDO> deviceList = iotOpeationFillService.deviceList(pageReqVO);
|
|
|
+ if(deviceList.size()==0){
|
|
|
+ fillList = iotOpeationFillService.fillListByDeptId(pageReqVO);
|
|
|
+ }else{
|
|
|
+ fillList = iotOpeationFillService.fillListByUserId(pageReqVO);
|
|
|
+ }
|
|
|
return success(BeanUtils.toBean(fillList, IotOpeationFillDO.class));
|
|
|
}
|
|
|
|
|
@@ -133,7 +145,7 @@ public class IotOpeationFillController {
|
|
|
@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 );
|
|
|
|
|
|
/**
|
|
@@ -143,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())));
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
|