|
|
@@ -8,16 +8,22 @@ import com.github.pagehelper.PageInfo;
|
|
|
import com.sckw.core.exception.BusinessException;
|
|
|
import com.sckw.core.model.constant.NumberConstant;
|
|
|
import com.sckw.core.model.enums.DeviceEnum;
|
|
|
+import com.sckw.core.model.enums.DictEnum;
|
|
|
+import com.sckw.core.model.enums.DictItemEnum;
|
|
|
import com.sckw.core.model.page.PageRes;
|
|
|
import com.sckw.core.utils.IdWorker;
|
|
|
import com.sckw.core.utils.RegularUtils;
|
|
|
import com.sckw.core.utils.StringUtils;
|
|
|
import com.sckw.core.web.constant.HttpStatus;
|
|
|
import com.sckw.core.web.response.HttpResult;
|
|
|
+import com.sckw.excel.utils.DateUtil;
|
|
|
import com.sckw.slope.detection.dao.mysql.*;
|
|
|
+import com.sckw.slope.detection.dao.tdengine.SlopeDataMapper;
|
|
|
import com.sckw.slope.detection.model.dos.mysql.*;
|
|
|
+import com.sckw.slope.detection.model.dos.tdengine.SlopeData;
|
|
|
import com.sckw.slope.detection.model.dto.*;
|
|
|
import com.sckw.slope.detection.model.param.DeviceQuery;
|
|
|
+import com.sckw.slope.detection.model.param.ProjectChartLogParam;
|
|
|
import com.sckw.slope.detection.model.param.ProjectQuery;
|
|
|
import com.sckw.slope.detection.model.vo.*;
|
|
|
import com.sckw.slope.detection.service.repository.KwsDeviceRelationRepository;
|
|
|
@@ -30,9 +36,11 @@ import org.springframework.stereotype.Service;
|
|
|
import org.springframework.transaction.annotation.Transactional;
|
|
|
import org.springframework.util.CollectionUtils;
|
|
|
|
|
|
+import java.math.BigDecimal;
|
|
|
+import java.time.LocalDate;
|
|
|
import java.time.LocalDateTime;
|
|
|
-import java.util.ArrayList;
|
|
|
-import java.util.List;
|
|
|
+import java.util.*;
|
|
|
+import java.util.stream.Collectors;
|
|
|
|
|
|
/**
|
|
|
* @author lfdc
|
|
|
@@ -43,6 +51,8 @@ import java.util.List;
|
|
|
@Service
|
|
|
public class ProjectService {
|
|
|
|
|
|
+ private static final Long equatorial_circumference = 40075020000L;
|
|
|
+
|
|
|
@Autowired
|
|
|
CommonService commonService;
|
|
|
|
|
|
@@ -52,9 +62,15 @@ public class ProjectService {
|
|
|
@Autowired
|
|
|
KwsProjectAreaMapper projectAreaMapper;
|
|
|
|
|
|
+ @Autowired
|
|
|
+ KwsDeviceIntegrationMapper deviceIntegrationMapper;
|
|
|
+
|
|
|
@Autowired
|
|
|
KwsDeviceMapper deviceMapper;
|
|
|
|
|
|
+ @Autowired
|
|
|
+ SlopeDataMapper slopeDataMapper;
|
|
|
+
|
|
|
@Autowired
|
|
|
KwsProjectDeviceMapper projectDeviceMapper;
|
|
|
|
|
|
@@ -199,7 +215,8 @@ public class ProjectService {
|
|
|
return HttpResult.ok(jsonObject);
|
|
|
}
|
|
|
|
|
|
- public PageRes selectDevice(DeviceQuery deviceQuery) {
|
|
|
+ public PageRes selectDevice(DeviceQuery deviceQuery, HttpServletRequest request) {
|
|
|
+ HeaderData headerData = commonService.getHeaderData(request);
|
|
|
PageHelper.startPage(deviceQuery.getPage(), deviceQuery.getPageSize());
|
|
|
// List<ProjectDeviceVO> list = projectMapper.selectDeviceByProjectId(Long.parseLong(deviceQuery.getProjectId()));
|
|
|
List<ProjectDeviceVO> list = projectMapper.selectDeviceList(deviceQuery);
|
|
|
@@ -208,9 +225,22 @@ public class ProjectService {
|
|
|
return PageRes.build(info, list);
|
|
|
}
|
|
|
// 后期要数据翻译产品类型
|
|
|
-// for (ProjectDeviceDTO projectDeviceDTO : list) {
|
|
|
-//
|
|
|
-// }
|
|
|
+ for (ProjectDeviceVO projectDeviceDTO : list) {
|
|
|
+ Long id = projectDeviceDTO.getDeviceRelationId();
|
|
|
+ KwsDeviceRelation deviceRelation = deviceRelationMapper.selectOne(new LambdaQueryWrapper<KwsDeviceRelation>()
|
|
|
+ .eq(KwsDeviceRelation::getId, id)
|
|
|
+ .eq(KwsDeviceRelation::getMountainId, headerData.getMountainId())
|
|
|
+ .eq(KwsDeviceRelation::getDelFlag, 0)
|
|
|
+ );
|
|
|
+ if (deviceRelation != null) {
|
|
|
+ projectDeviceDTO.setParentId(deviceRelation.getDeviceId().toString());
|
|
|
+ KwsDevice kwsDevice = deviceMapper.selectByPrimaryKey(deviceRelation.getDeviceId());
|
|
|
+ projectDeviceDTO.setParentName(kwsDevice == null ? null : kwsDevice.getName());
|
|
|
+ }
|
|
|
+ if (projectDeviceDTO.getId().equals(projectDeviceDTO.getProjectId())) {
|
|
|
+ projectDeviceDTO.setParentName(null);
|
|
|
+ }
|
|
|
+ }
|
|
|
return PageRes.build(info, list);
|
|
|
}
|
|
|
|
|
|
@@ -223,31 +253,37 @@ public class ProjectService {
|
|
|
List<Long> list = StringUtils.splitStrToList(bindDevice.getDeviceIds(), Long.class);
|
|
|
String bindDeviceId = bindDevice.getBindDeviceId();
|
|
|
//设备主从绑定
|
|
|
- if (org.apache.commons.lang3.StringUtils.isNotBlank(bindDeviceId)) {
|
|
|
- List<KwsDeviceRelation> saveList = new ArrayList<>();
|
|
|
- list.forEach(id -> {
|
|
|
- KwsDeviceRelation deviceRelation = new KwsDeviceRelation();
|
|
|
- deviceRelation.setId(new IdWorker(NumberConstant.ONE).nextId());
|
|
|
- deviceRelation.setDeviceId(Long.parseLong(bindDeviceId));
|
|
|
- deviceRelation.setCompanyId(companyId);
|
|
|
- deviceRelation.setRelateDeviceId(id);
|
|
|
- deviceRelation.setStatus(NumberConstant.ZERO);
|
|
|
- deviceRelation.setCreateBy(headerData.getCreateBy() == null ? null : Long.parseLong(headerData.getCreateBy()));
|
|
|
- LocalDateTime now = LocalDateTime.now();
|
|
|
- deviceRelation.setCreateTime(now);
|
|
|
- deviceRelation.setUpdateBy(headerData.getCreateBy() == null ? null : Long.parseLong(headerData.getCreateBy()));
|
|
|
- deviceRelation.setUpdateTime(now);
|
|
|
- deviceRelation.setDelFlag(NumberConstant.ZERO);
|
|
|
- saveList.add(deviceRelation);
|
|
|
- });
|
|
|
- deviceRelationRepository.saveBatch(saveList);
|
|
|
- }
|
|
|
+ List<KwsDeviceRelation> saveList = new ArrayList<>();
|
|
|
+ list.forEach(id -> {
|
|
|
+ String deviceId = "";
|
|
|
+ if (bindDeviceId == null) {
|
|
|
+ //当主设备设置关联时,未关联主设备,即当前设备为主设备
|
|
|
+ deviceId = String.valueOf(id);
|
|
|
+ } else {
|
|
|
+ deviceId = bindDeviceId;
|
|
|
+ }
|
|
|
+ KwsDeviceRelation deviceRelation = new KwsDeviceRelation();
|
|
|
+ deviceRelation.setId(new IdWorker(NumberConstant.ONE).nextId());
|
|
|
+ deviceRelation.setDeviceId(Long.parseLong(deviceId));
|
|
|
+ deviceRelation.setMountainId(headerData.getMountainId());
|
|
|
+ deviceRelation.setRelateDeviceId(id);
|
|
|
+ deviceRelation.setStatus(NumberConstant.ZERO);
|
|
|
+ deviceRelation.setCreateBy(headerData.getCreateBy() == null ? null : Long.parseLong(headerData.getCreateBy()));
|
|
|
+ LocalDateTime now = LocalDateTime.now();
|
|
|
+ deviceRelation.setCreateTime(now);
|
|
|
+ deviceRelation.setUpdateBy(headerData.getCreateBy() == null ? null : Long.parseLong(headerData.getCreateBy()));
|
|
|
+ deviceRelation.setUpdateTime(now);
|
|
|
+ deviceRelation.setDelFlag(NumberConstant.ZERO);
|
|
|
+ saveList.add(deviceRelation);
|
|
|
+ });
|
|
|
+ deviceRelationRepository.saveBatch(saveList);
|
|
|
//矿山与设备绑定
|
|
|
if (!CollectionUtils.isEmpty(list)) {
|
|
|
list.forEach(id -> {
|
|
|
KwsProjectDevice device = new KwsProjectDevice();
|
|
|
device.setId(new IdWorker(NumberConstant.ONE).nextId());
|
|
|
device.setProjectId(projectId);
|
|
|
+ device.setMountainId(headerData.getMountainId());
|
|
|
device.setDeviceId(id);
|
|
|
device.setStatus(NumberConstant.ONE);
|
|
|
device.setCreateBy(headerData.getCreateBy() == null ? null : Long.parseLong(headerData.getCreateBy()));
|
|
|
@@ -262,9 +298,21 @@ public class ProjectService {
|
|
|
//设备修改状态
|
|
|
if (!CollectionUtils.isEmpty(list)) {
|
|
|
list.forEach(id -> {
|
|
|
+ String level = "1";
|
|
|
+ if (bindDeviceId != null) {
|
|
|
+ KwsDevice kwsDevice = deviceMapper.selectByPrimaryKey(Long.parseLong(bindDeviceId));
|
|
|
+ if (kwsDevice == null) {
|
|
|
+ throw new BusinessException("所属主设备id错误!");
|
|
|
+ }
|
|
|
+ kwsDevice.setRelevanceLevel(level);
|
|
|
+ kwsDevice.setUpdateTime(LocalDateTime.now());
|
|
|
+ kwsDevice.setUpdateBy(headerData.getUpdateBy() == null ? null : Long.parseLong(headerData.getUpdateBy()));
|
|
|
+ level = "2";
|
|
|
+ }
|
|
|
KwsDevice kwsDevice = deviceMapper.selectByPrimaryKey(id);
|
|
|
deviceMapper.update(null, new LambdaUpdateWrapper<KwsDevice>()
|
|
|
.eq(KwsDevice::getId, id)
|
|
|
+ .set(KwsDevice::getRelevanceLevel, level)
|
|
|
.set(KwsDevice::getStatus, DeviceEnum.BE_CHECKING.getCode())
|
|
|
.set(KwsDevice::getAlias, bindDevice.getAlias() == null ? kwsDevice.getName() : bindDevice.getAlias())
|
|
|
.set(KwsDevice::getUpdateTime, LocalDateTime.now())
|
|
|
@@ -277,7 +325,7 @@ public class ProjectService {
|
|
|
|
|
|
public PageRes deviceBindSelect(DeviceQuery deviceQuery, HttpServletRequest request) {
|
|
|
PageHelper.startPage(deviceQuery.getPage(), deviceQuery.getPageSize());
|
|
|
- List<ProjectDeviceVO> list = projectMapper.selectDeviceNotBindList(deviceQuery);
|
|
|
+ List<ProjectDeviceVO> list = projectMapper.selectNotBindDeviceList(deviceQuery);
|
|
|
PageInfo<ProjectDeviceVO> info = new PageInfo<>(list);
|
|
|
if (CollectionUtils.isEmpty(list)) {
|
|
|
return PageRes.build(info, list);
|
|
|
@@ -304,4 +352,225 @@ public class ProjectService {
|
|
|
vo.setDeviceList(list);
|
|
|
return HttpResult.ok(vo);
|
|
|
}
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 边坡详情-设备要素折线图
|
|
|
+ *
|
|
|
+ * @param param 请求参数
|
|
|
+ * @param request 请求头信息
|
|
|
+ * @return 数据响应
|
|
|
+ */
|
|
|
+ public HttpResult chartLog(ProjectChartLogParam param, HttpServletRequest request) {
|
|
|
+ HeaderData headerData = commonService.getHeaderData(request);
|
|
|
+ String latitude = param.getLatitude();
|
|
|
+ String projectId = param.getProjectId();
|
|
|
+ if (String.valueOf(NumberConstant.FOUR).equals(latitude)) {
|
|
|
+ Map<String, SystemDict> dictList = commonService.getDictList(null, new HashMap<String, String>() {{
|
|
|
+ put("code", DictEnum.MODEL_PART.getCodeType());
|
|
|
+ put("type", "1");
|
|
|
+ }});
|
|
|
+ String deviceId = param.getDeviceId();
|
|
|
+ String mountainId = headerData.getMountainId();
|
|
|
+ KwsDevice kwsDevice = deviceMapper.selectOne(new LambdaQueryWrapper<KwsDevice>()
|
|
|
+ .eq(KwsDevice::getId, Long.parseLong(deviceId))
|
|
|
+ .eq(KwsDevice::getMountainId, mountainId)
|
|
|
+ .eq(KwsDevice::getDelFlag, NumberConstant.ZERO)
|
|
|
+ );
|
|
|
+ if (kwsDevice == null) {
|
|
|
+ return HttpResult.ok();
|
|
|
+ }
|
|
|
+ //集成要素
|
|
|
+ List<DeviceElementDTO> integratedElementList = deviceIntegrationMapper.selectIntegratedElement(projectId,
|
|
|
+ mountainId, null, Long.parseLong(deviceId));
|
|
|
+ //集成要素
|
|
|
+ List<KwsDeviceIntegration> deviceIntegrations = deviceIntegrationMapper.selectList(new LambdaQueryWrapper<KwsDeviceIntegration>()
|
|
|
+ .eq(KwsDeviceIntegration::getMountainId, mountainId)
|
|
|
+ .eq(KwsDeviceIntegration::getDeviceId, deviceId)
|
|
|
+ );
|
|
|
+
|
|
|
+ //当前设备下的所有基本要素
|
|
|
+ List<ProjectDeviceVO> projectDeviceList = projectMapper.selectDeviceByProjectId(mountainId, Long.parseLong(projectId), Long.parseLong(deviceId));
|
|
|
+ if (!CollectionUtils.isEmpty(projectDeviceList)) {
|
|
|
+ for (ProjectDeviceVO projectDeviceVO : projectDeviceList) {
|
|
|
+ String partName = projectDeviceVO.getPartName();
|
|
|
+ //设置过阈值的基本要素
|
|
|
+ List<KwsDeviceReference> references = deviceReferenceMapper.selectList(new LambdaQueryWrapper<KwsDeviceReference>()
|
|
|
+ .eq(KwsDeviceReference::getDeviceId, deviceId)
|
|
|
+ .eq(KwsDeviceReference::getMountainId, mountainId)
|
|
|
+ .eq(KwsDeviceReference::getType, 1)
|
|
|
+ .eq(KwsDeviceReference::getItem, partName)
|
|
|
+ .eq(KwsDeviceReference::getDelFlag, NumberConstant.ZERO)
|
|
|
+ );
|
|
|
+ KwsDeviceReference deviceReference = new KwsDeviceReference();
|
|
|
+ if (!CollectionUtils.isEmpty(references)) {
|
|
|
+ deviceReference = references.get(0);
|
|
|
+ }
|
|
|
+ SlopeData slopeData = slopeDataMapper.selectListByLine(kwsDevice.getSnCode(), partName);
|
|
|
+ String val = slopeData == null ? null : slopeData.getVal();
|
|
|
+ //基准值
|
|
|
+ BigDecimal currentValue = deviceReference.getCurrentValue();
|
|
|
+ BigDecimal offsetValue = new BigDecimal("0.00");
|
|
|
+ if (currentValue != null) {
|
|
|
+ /**存在经纬度海拔值的需要公式计算*/
|
|
|
+ List<String> itemList = new ArrayList<>();
|
|
|
+ itemList.add(DictItemEnum.LONGITUDE_X.getValue());
|
|
|
+ Date date = new Date();
|
|
|
+ String dateStart = DateUtil.getDateTimeToHour(date, 24);
|
|
|
+ String dateEnd = DateUtil.localDateTimeFormat(LocalDateTime.now());
|
|
|
+ List<SlopeData> selected = slopeDataMapper.selectLineList(kwsDevice.getSnCode(), partName, dateStart, dateEnd);
|
|
|
+ if (!CollectionUtils.isEmpty(selected)){
|
|
|
+ for (SlopeData message : selected) {
|
|
|
+ String line = message.getLine();
|
|
|
+ String val1 = message.getVal();
|
|
|
+ if (itemList.contains(partName)) {
|
|
|
+ if (Objects.nonNull(currentValue)) {
|
|
|
+ SlopeData selectListByLine = slopeDataMapper.selectListByLine(kwsDevice.getSnCode(), "2");
|
|
|
+ double angleInRadians = Math.toRadians(selected == null ? 0L : Double.parseDouble(selectListByLine.getVal()));
|
|
|
+ double cosValue = Math.cos(angleInRadians);
|
|
|
+ if (org.apache.commons.lang3.StringUtils.isNotBlank(val)) {
|
|
|
+ double doubleValue = (new BigDecimal(val).subtract(currentValue)).divide(new BigDecimal(360)).doubleValue();
|
|
|
+ offsetValue = new BigDecimal(equatorial_circumference).multiply(new BigDecimal(cosValue)).multiply(new BigDecimal(doubleValue));
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ itemList.add(DictItemEnum.LATITUDE_Y.getValue());
|
|
|
+ if (itemList.contains(partName)) {
|
|
|
+ if (Objects.nonNull(currentValue)) {
|
|
|
+ if (org.apache.commons.lang3.StringUtils.isNotBlank(val)) {
|
|
|
+ offsetValue = new BigDecimal(val).subtract(currentValue);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ itemList.clear();
|
|
|
+ itemList.add(DictItemEnum.ALTITUDE_Z.getValue());
|
|
|
+ if (itemList.contains(partName)) {
|
|
|
+ if (Objects.nonNull(currentValue)) {
|
|
|
+ if (org.apache.commons.lang3.StringUtils.isNotBlank(val)) {
|
|
|
+ offsetValue = new BigDecimal(val).divide(new BigDecimal(1000));
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ LocalDateTime localDateTime = DateUtil.localDateToLocalDateTimeStart(LocalDate.now());
|
|
|
+ } else if (String.valueOf(NumberConstant.THREE).equals(latitude)) {
|
|
|
+// //开始时间
|
|
|
+// dateStart = DateUtil.getLastWeekDateStartToString(LocalDate.now(), 6);
|
|
|
+// //结束时间
|
|
|
+// dateEnd = DateUtil.getLastWeekDateEndToString(0);
|
|
|
+ List<String> dateTimeDay = DateUtil.getDateTimeDay(LocalDateTime.now(), 7, new ArrayList<String>());
|
|
|
+ for (String dateTime : dateTimeDay) {
|
|
|
+
|
|
|
+ }
|
|
|
+ /**下面是查询当天每小时数据总量的代码示例:
|
|
|
+
|
|
|
+ SELECT DATE_FORMAT(timestamp, '%Y-%m-%d %H:00:00') AS hour,
|
|
|
+ COUNT(*) AS count
|
|
|
+ FROM data
|
|
|
+ WHERE DATE(timestamp) = CURDATE()
|
|
|
+ GROUP BY hour;*/
|
|
|
+
|
|
|
+ /** 下面是查询当天每小时某个字段平均值的代码示例:
|
|
|
+
|
|
|
+
|
|
|
+ SELECT DATE_FORMAT(timestamp, '%Y-%m-%d %H:00:00') AS hour,
|
|
|
+ AVG(value) AS average
|
|
|
+ FROM data
|
|
|
+ WHERE DATE(timestamp) = CURDATE()
|
|
|
+ GROUP BY hour;*/
|
|
|
+
|
|
|
+ } else if (String.valueOf(NumberConstant.TWO).equals(latitude)) {
|
|
|
+ } else if (String.valueOf(NumberConstant.ONE).equals(latitude)) {
|
|
|
+ } else {
|
|
|
+ throw new BusinessException("数据传输异常");
|
|
|
+ }
|
|
|
+ return null;
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 项目关联设备删除
|
|
|
+ *
|
|
|
+ * @param deviceDelete 设备id
|
|
|
+ * @param request 请求数据
|
|
|
+ * @return 返回数据
|
|
|
+ */
|
|
|
+ public HttpResult deviceDelete(DeviceDeleteDTO deviceDelete, HttpServletRequest request) {
|
|
|
+ HeaderData headerData = commonService.getHeaderData(request);
|
|
|
+ Long projectId = Long.parseLong(deviceDelete.getProjectId());
|
|
|
+ KwsProject project = projectMapper.selectOne(new LambdaQueryWrapper<KwsProject>().eq(KwsProject::getId, projectId));
|
|
|
+ String deviceId = deviceDelete.getDeviceId();
|
|
|
+ String bindDeviceId = deviceDelete.getDeviceRelationId();
|
|
|
+ String deviceParentId = deviceDelete.getParentId();
|
|
|
+ //设备主从解绑
|
|
|
+ //如果删除主设备 子设备也要删除
|
|
|
+ //id集合
|
|
|
+ List<Long> deleteList = new ArrayList<>();
|
|
|
+ if (deviceId.equals(deviceParentId)) {
|
|
|
+ List<KwsDeviceRelation> deviceRelationList = deviceRelationMapper.selectList(
|
|
|
+ new LambdaQueryWrapper<KwsDeviceRelation>()
|
|
|
+ .eq(KwsDeviceRelation::getDeviceId, deviceId)
|
|
|
+ .eq(KwsDeviceRelation::getDelFlag, 0)
|
|
|
+ .eq(KwsDeviceRelation::getMountainId, headerData.getMountainId())
|
|
|
+ .ne(KwsDeviceRelation::getRelateDeviceId, deviceId)
|
|
|
+ );
|
|
|
+ //主设备数据
|
|
|
+ KwsDeviceRelation deviceRelation = deviceRelationMapper.selectOne(
|
|
|
+ new LambdaQueryWrapper<KwsDeviceRelation>()
|
|
|
+ .eq(KwsDeviceRelation::getDeviceId, deviceId)
|
|
|
+ .eq(KwsDeviceRelation::getDelFlag, 0)
|
|
|
+ .eq(KwsDeviceRelation::getMountainId, headerData.getMountainId())
|
|
|
+ .eq(KwsDeviceRelation::getRelateDeviceId, deviceId)
|
|
|
+ );
|
|
|
+ if (deviceRelation != null) {
|
|
|
+ deleteList.add(deviceRelation.getId());
|
|
|
+ }
|
|
|
+ if (!CollectionUtils.isEmpty(deviceRelationList)) {
|
|
|
+ deleteList = deviceRelationList.stream().map(KwsDeviceRelation::getId).collect(Collectors.toList());
|
|
|
+ deleteList.add(Long.parseLong(bindDeviceId));
|
|
|
+ }
|
|
|
+ deviceRelationMapper.update(null, new LambdaUpdateWrapper<KwsDeviceRelation>()
|
|
|
+ .eq(KwsDeviceRelation::getMountainId, headerData.getMountainId())
|
|
|
+ .set(KwsDeviceRelation::getDelFlag, 1)
|
|
|
+ .in(KwsDeviceRelation::getRelateDeviceId, deleteList)
|
|
|
+ );
|
|
|
+ } else {
|
|
|
+ deleteList.add(Long.parseLong(deviceId));
|
|
|
+ deviceRelationMapper.update(null, new LambdaUpdateWrapper<KwsDeviceRelation>()
|
|
|
+ .eq(KwsDeviceRelation::getMountainId, headerData.getMountainId())
|
|
|
+ .set(KwsDeviceRelation::getDelFlag, 1)
|
|
|
+ .in(KwsDeviceRelation::getRelateDeviceId, deleteList)
|
|
|
+ );
|
|
|
+ }
|
|
|
+ //矿山与设备解绑
|
|
|
+ if (!CollectionUtils.isEmpty(deleteList)) {
|
|
|
+ projectDeviceMapper.update(null, new LambdaUpdateWrapper<KwsProjectDevice>()
|
|
|
+ .set(KwsProjectDevice::getDelFlag, 1)
|
|
|
+ .set(KwsProjectDevice::getUpdateBy, headerData.getUpdateBy() == null ? null : Long.parseLong(headerData.getUpdateBy()))
|
|
|
+ .set(KwsProjectDevice::getUpdateTime, LocalDateTime.now())
|
|
|
+ .eq(KwsProjectDevice::getDelFlag, 0)
|
|
|
+ .eq(KwsProjectDevice::getProjectId, projectId)
|
|
|
+ .eq(KwsProjectDevice::getMountainId, headerData.getMountainId())
|
|
|
+ .in(KwsProjectDevice::getDeviceId, deleteList)
|
|
|
+ );
|
|
|
+ }
|
|
|
+ //设备修改状态
|
|
|
+ if (!CollectionUtils.isEmpty(deleteList)) {
|
|
|
+ deviceMapper.update(null, new LambdaUpdateWrapper<KwsDevice>()
|
|
|
+ .in(KwsDevice::getId, deleteList)
|
|
|
+ .eq(KwsDevice::getMountainId, headerData.getMountainId())
|
|
|
+ .eq(KwsDevice::getDelFlag, 0)
|
|
|
+ .set(KwsDevice::getRelevanceLevel, 0)
|
|
|
+ .set(KwsDevice::getStatus, DeviceEnum.NOT_IN_USE.getCode())
|
|
|
+ .set(KwsDevice::getUpdateTime, LocalDateTime.now())
|
|
|
+ .set(KwsDevice::getUpdateBy, headerData.getUpdateBy() == null ? Long.parseLong(headerData.getCreateBy()) : Long.parseLong(headerData.getUpdateBy()))
|
|
|
+ );
|
|
|
+ }
|
|
|
+ return HttpResult.ok("删除关联设备成功!");
|
|
|
+ }
|
|
|
}
|