|
@@ -15,6 +15,7 @@ import org.springframework.web.bind.annotation.RequestMethod;
|
|
|
import org.springframework.web.bind.annotation.RestController;
|
|
|
|
|
|
import javax.servlet.http.HttpServletRequest;
|
|
|
+import java.text.SimpleDateFormat;
|
|
|
import java.util.ArrayList;
|
|
|
import java.util.Arrays;
|
|
|
import java.util.List;
|
|
@@ -105,4 +106,83 @@ public class LightStripGroupController {
|
|
|
if (lightStripGroupDetailsVO == null) return toolUtils.response(InterfaceResultEnum.PARAM_FAIL,version);
|
|
|
return toolUtils.response(InterfaceResultEnum.OPERATION_SUCCESS,version,lightStripGroupDetailsVO);
|
|
|
}
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 添加编辑分组
|
|
|
+ * @param request 分组属性
|
|
|
+ * @return 添加编辑分组
|
|
|
+ */
|
|
|
+ @RequestMapping(value = "/save", method = RequestMethod.POST)
|
|
|
+ public BaseResult<?> save(HttpServletRequest request) {
|
|
|
+ Integer version = (Integer) toolUtils.getRequestContent(request,"version",1);
|
|
|
+ Integer id = (Integer) toolUtils.getRequestContent(request,"id",1);
|
|
|
+ Integer areaId = (Integer) toolUtils.getRequestContent(request,"areaId",1);
|
|
|
+ Integer sectionId = (Integer) toolUtils.getRequestContent(request,"sectionId",1);
|
|
|
+ String name = (String) toolUtils.getRequestContent(request,"name",2);
|
|
|
+ String number = (String) toolUtils.getRequestContent(request,"number",2);
|
|
|
+ String lightStripIds = (String) toolUtils.getRequestContent(request,"lightStripIds",2);
|
|
|
+ if (areaId == 0) return toolUtils.response(InterfaceResultEnum.LACK_AREA_ERROR,version);
|
|
|
+ if (sectionId == 0) return toolUtils.response(InterfaceResultEnum.LACK_SECTION_ERROR,version);
|
|
|
+ if (name.length() == 0 || number.length() == 0)
|
|
|
+ return toolUtils.response(InterfaceResultEnum.LACK_NEED_PARAM,version);
|
|
|
+ LightStripGroupDTO lightStripGroupDTO = new LightStripGroupDTO();
|
|
|
+ lightStripGroupDTO.setAreaId(areaId);
|
|
|
+ lightStripGroupDTO.setSectionId(sectionId);
|
|
|
+ lightStripGroupDTO.setName(name);
|
|
|
+ lightStripGroupDTO.setNumber(number);
|
|
|
+ lightStripGroupDTO.setLightStripIds(lightStripIds);
|
|
|
+ if (id == 0) { // 添加
|
|
|
+ LightStripGroupDTO dto = new LightStripGroupDTO();
|
|
|
+ dto.setName(name);
|
|
|
+ dto.setSectionId(sectionId);
|
|
|
+ if (lightStripGroupService.checkLightStripGroupData(dto) > 0)
|
|
|
+ return toolUtils.response(InterfaceResultEnum.STRIP_GROUP_NAME_UNIQUE_ERROR,version);
|
|
|
+ dto = new LightStripGroupDTO();
|
|
|
+ dto.setNumber(number);
|
|
|
+ dto.setSectionId(sectionId);
|
|
|
+ if (lightStripGroupService.checkLightStripGroupData(dto) > 0)
|
|
|
+ return toolUtils.response(InterfaceResultEnum.STRIP_GROUP_NUMBER_UNIQUE_ERROR,version);
|
|
|
+ long l = System.currentTimeMillis();
|
|
|
+ SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
|
|
|
+ String format = simpleDateFormat.format(l);
|
|
|
+ lightStripGroupDTO.setCreateTime(format);
|
|
|
+ lightStripGroupDTO.setUpdateTime(format);
|
|
|
+ lightStripGroupService.addLightStripGroupData(lightStripGroupDTO);
|
|
|
+ } else { // 编辑
|
|
|
+ lightStripGroupDTO.setId(id);
|
|
|
+ LightStripGroupDTO dto = new LightStripGroupDTO();
|
|
|
+ dto.setId(id);
|
|
|
+ dto.setName(name);
|
|
|
+ dto.setSectionId(sectionId);
|
|
|
+ if (lightStripGroupService.checkLightStripGroupData(dto) > 0)
|
|
|
+ return toolUtils.response(InterfaceResultEnum.STRIP_GROUP_NAME_UNIQUE_ERROR,version);
|
|
|
+ dto = new LightStripGroupDTO();
|
|
|
+ dto.setId(id);
|
|
|
+ dto.setNumber(number);
|
|
|
+ dto.setSectionId(sectionId);
|
|
|
+ if (lightStripGroupService.checkLightStripGroupData(dto) > 0)
|
|
|
+ return toolUtils.response(InterfaceResultEnum.STRIP_GROUP_NUMBER_UNIQUE_ERROR,version);
|
|
|
+ long l = System.currentTimeMillis();
|
|
|
+ SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
|
|
|
+ String format = simpleDateFormat.format(l);
|
|
|
+ lightStripGroupDTO.setUpdateTime(format);
|
|
|
+ lightStripGroupService.updateLightStripGroupData(lightStripGroupDTO);
|
|
|
+ }
|
|
|
+ return toolUtils.response(InterfaceResultEnum.OPERATION_SUCCESS,version);
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 删除灯带分组
|
|
|
+ * @param request 灯带分组id
|
|
|
+ * @return 删除灯带分组
|
|
|
+ */
|
|
|
+ @RequestMapping(value = "/del", method = RequestMethod.POST)
|
|
|
+ public BaseResult<?> del(HttpServletRequest request){
|
|
|
+ Integer version = (Integer) toolUtils.getRequestContent(request,"version",1);
|
|
|
+ String id = (String) toolUtils.getRequestContent(request,"id",2);
|
|
|
+ if (id.length() == 0) return toolUtils.response(InterfaceResultEnum.LACK_PARAM_ERROR,version);
|
|
|
+ List<String> ids = Arrays.asList(id.split(","));
|
|
|
+ lightStripGroupService.deleteLightStripGroupDataByIds(ids);
|
|
|
+ return toolUtils.response(InterfaceResultEnum.OPERATION_SUCCESS,version);
|
|
|
+ }
|
|
|
}
|