|
@@ -2,12 +2,17 @@ package com.welampiot.controller;
|
|
|
|
|
|
import com.welampiot.common.BaseResult;
|
|
import com.welampiot.common.BaseResult;
|
|
import com.welampiot.common.InterfaceResultEnum;
|
|
import com.welampiot.common.InterfaceResultEnum;
|
|
|
|
+import com.welampiot.dto.LightStripCollectorDTO;
|
|
import com.welampiot.dto.LightStripDevDTO;
|
|
import com.welampiot.dto.LightStripDevDTO;
|
|
import com.welampiot.dto.LightStripDevLogDTO;
|
|
import com.welampiot.dto.LightStripDevLogDTO;
|
|
|
|
+import com.welampiot.dto.SolarDevDTO;
|
|
|
|
+import com.welampiot.service.LightStripCollectorService;
|
|
import com.welampiot.service.LightStripDevLogService;
|
|
import com.welampiot.service.LightStripDevLogService;
|
|
import com.welampiot.service.LightStripDevService;
|
|
import com.welampiot.service.LightStripDevService;
|
|
|
|
+import com.welampiot.service.SolarDevService;
|
|
import com.welampiot.utils.ExcelUtil;
|
|
import com.welampiot.utils.ExcelUtil;
|
|
import com.welampiot.utils.ToolUtils;
|
|
import com.welampiot.utils.ToolUtils;
|
|
|
|
+import com.welampiot.vo.LightStripDetailsVO;
|
|
import com.welampiot.vo.LightStripDevLogVO;
|
|
import com.welampiot.vo.LightStripDevLogVO;
|
|
import com.welampiot.vo.LightStripDevVO;
|
|
import com.welampiot.vo.LightStripDevVO;
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
@@ -43,6 +48,12 @@ public class LightStripController {
|
|
@Autowired
|
|
@Autowired
|
|
private ToolUtils toolUtils;
|
|
private ToolUtils toolUtils;
|
|
|
|
|
|
|
|
+ @Autowired
|
|
|
|
+ private LightStripCollectorService lightStripCollectorService;
|
|
|
|
+
|
|
|
|
+ @Autowired
|
|
|
|
+ private SolarDevService solarDevService;
|
|
|
|
+
|
|
/**
|
|
/**
|
|
* 获取灯带设备概述
|
|
* 获取灯带设备概述
|
|
* @param request
|
|
* @param request
|
|
@@ -296,4 +307,120 @@ public class LightStripController {
|
|
lightStripDevService.updateLightStripVoltage(lightStripDevDTO);
|
|
lightStripDevService.updateLightStripVoltage(lightStripDevDTO);
|
|
return toolUtils.response(InterfaceResultEnum.OPERATION_SUCCESS,version);
|
|
return toolUtils.response(InterfaceResultEnum.OPERATION_SUCCESS,version);
|
|
}
|
|
}
|
|
|
|
+
|
|
|
|
+ /**
|
|
|
|
+ * 编辑灯带设备
|
|
|
|
+ * @param vo 灯带,太阳能,灯带电量采集器
|
|
|
|
+ * @return 编辑设备
|
|
|
|
+ */
|
|
|
|
+ @RequestMapping(value = "/save", method = RequestMethod.POST)
|
|
|
|
+ public BaseResult<?> save(LightStripDetailsVO vo) {
|
|
|
|
+ LightStripDetailsVO detailsVO = LightStripDetailsVO.getLightStripDetailsVO(vo);
|
|
|
|
+ Integer version = detailsVO.getVersion();
|
|
|
|
+
|
|
|
|
+ // 编辑灯带
|
|
|
|
+ Integer id = detailsVO.getId();
|
|
|
|
+ if (id == 0) return toolUtils.response(InterfaceResultEnum.LACK_PARAM_ERROR,version);
|
|
|
|
+ String address = detailsVO.getAddress();
|
|
|
|
+ if (address == null || address.length() == 0)
|
|
|
|
+ return toolUtils.response(InterfaceResultEnum.LACK_DEV_ADDRESS_ERROR,version);
|
|
|
|
+ Integer factory = detailsVO.getFactory();
|
|
|
|
+ if (factory == null)
|
|
|
|
+ return toolUtils.response(InterfaceResultEnum.LACK_FACTORY_ERROR,version);
|
|
|
|
+ Integer model = detailsVO.getModel();
|
|
|
|
+ if (model == null)
|
|
|
|
+ return toolUtils.response(InterfaceResultEnum.LACK_DEV_MODEL_ERROR,version);
|
|
|
|
+ Integer netType = detailsVO.getNetType();
|
|
|
|
+ if (netType == null)
|
|
|
|
+ return toolUtils.response(InterfaceResultEnum.LACK_PROTOCOL_TYPE_ERROR,version);
|
|
|
|
+ String name = detailsVO.getName();
|
|
|
|
+ if (name == null || name.length() == 0)
|
|
|
|
+ return toolUtils.response(InterfaceResultEnum.LACK_DEV_NAME_ERROR,version);
|
|
|
|
+ Integer serialPort = detailsVO.getSerialPort();
|
|
|
|
+ String imei = detailsVO.getImei();
|
|
|
|
+ String installDate = detailsVO.getInstallDate();
|
|
|
|
+ String expirationDate = detailsVO.getExpirationDate();
|
|
|
|
+ LightStripDevDTO lightStripDevDTO = new LightStripDevDTO();
|
|
|
|
+ lightStripDevDTO.setName(name);
|
|
|
|
+ lightStripDevDTO.setId(id);
|
|
|
|
+ lightStripDevDTO.setAddress(address);
|
|
|
|
+ lightStripDevDTO.setFactory(factory);
|
|
|
|
+ lightStripDevDTO.setModel(model);
|
|
|
|
+ lightStripDevDTO.setNetType(netType);
|
|
|
|
+ lightStripDevDTO.setSerialPort(serialPort);
|
|
|
|
+ lightStripDevDTO.setImei(imei);
|
|
|
|
+ lightStripDevDTO.setInstallDate(installDate);
|
|
|
|
+ lightStripDevDTO.setExpirationDate(expirationDate);
|
|
|
|
+
|
|
|
|
+ // 编辑灯带电量采集器
|
|
|
|
+ String powerCollectorAddress = detailsVO.getPowerCollectorAddress();
|
|
|
|
+ String powerCollectorName = detailsVO.getPowerCollectorName();
|
|
|
|
+ String powerCollectorNumber = detailsVO.getPowerCollectorNumber();
|
|
|
|
+ Integer powerCollectorModel = detailsVO.getPowerCollectorModel();
|
|
|
|
+ Integer powerCollectorFactory = detailsVO.getPowerCollectorFactory();
|
|
|
|
+ LightStripCollectorDTO lightStripCollectorDTO = new LightStripCollectorDTO();
|
|
|
|
+ lightStripCollectorDTO.setAddress(powerCollectorAddress);
|
|
|
|
+ lightStripCollectorDTO.setName(powerCollectorName);
|
|
|
|
+ lightStripCollectorDTO.setAddress(powerCollectorNumber);
|
|
|
|
+ lightStripCollectorDTO.setModel(powerCollectorModel);
|
|
|
|
+ lightStripCollectorDTO.setFactory(powerCollectorFactory);
|
|
|
|
+ lightStripCollectorDTO.setLightStripId(id);
|
|
|
|
+
|
|
|
|
+ // 编辑太阳能设备
|
|
|
|
+ Integer solarId = detailsVO.getSolarId();
|
|
|
|
+ if (solarId == null) return toolUtils.response(InterfaceResultEnum.LACK_PARAM_ERROR,version);
|
|
|
|
+ String mpptDevAddress = detailsVO.getMpptDevAddress();
|
|
|
|
+ if (mpptDevAddress == null || mpptDevAddress.length() == 0)
|
|
|
|
+ return toolUtils.response(InterfaceResultEnum.LACK_DEV_ADDRESS_ERROR,version);
|
|
|
|
+ Integer mpptDevType = detailsVO.getMpptDevType();
|
|
|
|
+ if (mpptDevType == null)
|
|
|
|
+ return toolUtils.response(InterfaceResultEnum.LACK_DEV_TYPE_ERROR,version);
|
|
|
|
+ Integer mpptDevSerialPort = detailsVO.getMpptDevSerialPort();
|
|
|
|
+ if (mpptDevSerialPort == null)
|
|
|
|
+ return toolUtils.response(InterfaceResultEnum.LACK_SERIAL_PORT_ERROR,version);
|
|
|
|
+ String mpptDevNumber = detailsVO.getMpptDevNumber();
|
|
|
|
+ if (mpptDevNumber == null || mpptDevNumber.length() == 0)
|
|
|
|
+ return toolUtils.response(InterfaceResultEnum.LACK_NUMBER_ERROR,version);
|
|
|
|
+ String mpptDevName = detailsVO.getMpptDevName();
|
|
|
|
+ if (mpptDevName == null || mpptDevName.length() == 0)
|
|
|
|
+ return toolUtils.response(InterfaceResultEnum.LACK_DEV_NAME_ERROR,version);
|
|
|
|
+ SolarDevDTO solarDevDTO = new SolarDevDTO();
|
|
|
|
+ solarDevDTO.setId(solarId);
|
|
|
|
+ solarDevDTO.setAddress(mpptDevAddress);
|
|
|
|
+ solarDevDTO.setType(mpptDevType);
|
|
|
|
+ solarDevDTO.setSerialPort(mpptDevSerialPort);
|
|
|
|
+ solarDevDTO.setNumber(mpptDevNumber);
|
|
|
|
+ solarDevDTO.setName(mpptDevName);
|
|
|
|
+
|
|
|
|
+ long l = System.currentTimeMillis();
|
|
|
|
+ SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
|
|
|
|
+ String format = simpleDateFormat.format(l);
|
|
|
|
+ lightStripDevDTO.setUpdateTime(format);
|
|
|
|
+ lightStripDevService.updateLightStripData(lightStripDevDTO);
|
|
|
|
+ lightStripCollectorDTO.setUpdateTime(format);
|
|
|
|
+ lightStripCollectorService.updateLightStripCollectorDataByStripId(lightStripCollectorDTO);
|
|
|
|
+ solarDevService.updateSolarDevData(solarDevDTO);
|
|
|
|
+ return toolUtils.response(InterfaceResultEnum.OPERATION_SUCCESS,version);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ /**
|
|
|
|
+ * 删除灯带
|
|
|
|
+ * @param vo 灯带id
|
|
|
|
+ * @return 删除灯带
|
|
|
|
+ */
|
|
|
|
+ @RequestMapping(value = "/del", method = RequestMethod.POST)
|
|
|
|
+ public BaseResult<?> del(LightStripDevVO vo) {
|
|
|
|
+ LightStripDevVO lightStripDevVO = LightStripDevVO.getLightStripDevVO(vo);
|
|
|
|
+ Integer version = lightStripDevVO.getVersion();
|
|
|
|
+ String id = lightStripDevVO.getId();
|
|
|
|
+ if (id.length() == 0) return toolUtils.response(InterfaceResultEnum.LACK_PARAM_ERROR,version);
|
|
|
|
+ String[] split = id.split(",");
|
|
|
|
+ for (String s : split) {
|
|
|
|
+ Integer integer = Integer.valueOf(s);
|
|
|
|
+ lightStripDevService.deleteLightStripDevData(integer);
|
|
|
|
+ lightStripCollectorService.deleteLightStripCollectorByStripId(integer);
|
|
|
|
+ lightStripDevLogService.deleteLightStripLogDataByStripId(integer);
|
|
|
|
+ }
|
|
|
|
+ return toolUtils.response(InterfaceResultEnum.OPERATION_SUCCESS,version);
|
|
|
|
+ }
|
|
}
|
|
}
|