|
@@ -22,6 +22,7 @@ import com.huimv.env.manage.utils.ResultCode;
|
|
|
import com.huimv.env.manage.utils.ResultUtil;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
+import org.springframework.transaction.annotation.Transactional;
|
|
|
|
|
|
import javax.servlet.http.HttpServletRequest;
|
|
|
import java.util.ArrayList;
|
|
@@ -52,6 +53,8 @@ public class LampConfigServiceImpl extends ServiceImpl<LampConfigMapper, LampCon
|
|
|
public Result savelampConfig( LampConfig lampConfig, HttpServletRequest request) {
|
|
|
String deviceId = lampConfig.getDeviceId();
|
|
|
Integer unitId = lampConfig.getUnitId();
|
|
|
+ deviceId = deviceId.substring(2);
|
|
|
+ lampConfig.setDeviceId(deviceId);
|
|
|
String location = lampConfig.getLocation();
|
|
|
if (lampConfigMapper.exists(new QueryWrapper<LampConfig>().eq("device_id",deviceId))){
|
|
|
return new Result(10001,"保温灯已存在",false);
|
|
@@ -145,42 +148,46 @@ public class LampConfigServiceImpl extends ServiceImpl<LampConfigMapper, LampCon
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
- public Result allToConfig(Map<String, String> map, HttpServletRequest request) {
|
|
|
+ @Transactional
|
|
|
+ public Result allToConfig(Map<String, Object> map, HttpServletRequest request) {
|
|
|
try {
|
|
|
- String initDayAge = map.get("initDayAge");
|
|
|
- String dayAgeList = map.get("dayAgeList");
|
|
|
+ Integer initDayAge = (Integer) map.get("initDayAge");
|
|
|
+ List<String> dayAgeList = (List<String> )map.get("dayAgeList");
|
|
|
//
|
|
|
- String boardGear = map.get("boardGear");
|
|
|
- String unitId = map.get("unitId");
|
|
|
- String id = map.get("id");
|
|
|
-
|
|
|
- JSONArray jsonArray = JSONUtil.parseArray(dayAgeList);
|
|
|
+ Integer boardGear =(Integer) map.get("boardGear");
|
|
|
+ String unitId =(String) map.get("unitId");
|
|
|
+ String id = (String)map.get("id");
|
|
|
|
|
|
LampConfig lampConfig = new LampConfig();
|
|
|
- lampConfig.setInitAge(Integer.parseInt(initDayAge));
|
|
|
- lampConfig.setBoardGear(Integer.parseInt(boardGear));
|
|
|
+ lampConfig.setInitAge(initDayAge);
|
|
|
+ lampConfig.setBoardGear(boardGear);
|
|
|
StringBuilder dayAgeListStr = new StringBuilder();
|
|
|
- for (Object o : jsonArray) {
|
|
|
- dayAgeListStr.append(o.toString()).append(";");
|
|
|
+ for (String s : dayAgeList) {
|
|
|
+ dayAgeListStr.append(s).append(";");
|
|
|
}
|
|
|
+ String temp = updateTemp(dayAgeListStr.toString(), initDayAge);
|
|
|
+ lampConfig.setTempSet(temp);
|
|
|
+
|
|
|
lampConfig.setAgeList(dayAgeListStr.toString());
|
|
|
UpdateWrapper<LampConfig> wrapper = new UpdateWrapper<>();
|
|
|
if (StringUtils.isBlank(id)){
|
|
|
LampConfigAll lampConfigAll = new LampConfigAll();
|
|
|
- lampConfigAll.setBoardGear(Integer.parseInt(boardGear));
|
|
|
-// lampConfigAll.setListDayage();
|
|
|
- lampConfigAll.setInitDayage(Integer.parseInt(initDayAge));
|
|
|
-// lampConfigAll.setFarmCode();
|
|
|
-// lampConfigAll.setUnitId();
|
|
|
+ lampConfigAll.setBoardGear(boardGear);
|
|
|
+ lampConfigAll.setInitDayage((initDayAge));
|
|
|
+ lampConfigAll.setListDayage((dayAgeListStr.toString()));
|
|
|
+
|
|
|
+ lampConfigAllMapper.update(lampConfigAll,new UpdateWrapper<LampConfigAll>().eq("unit_id",unitId));
|
|
|
wrapper.eq("unit_id",unitId);
|
|
|
+ lampConfigMapper.update(lampConfig,wrapper);
|
|
|
+ return new Result(10000,"全局配置成功",true);
|
|
|
}else {
|
|
|
wrapper.eq("id",id);
|
|
|
+ lampConfigMapper.update(lampConfig,wrapper);
|
|
|
+ return new Result(10000,"配置成功",true);
|
|
|
}
|
|
|
- lampConfigMapper.update(lampConfig,wrapper);
|
|
|
|
|
|
- return new Result(10000,"全局配置成功",true);
|
|
|
}catch (Exception e){
|
|
|
- System.out.println(e);
|
|
|
+ System.out.println("----------->"+e);
|
|
|
return new Result(10001,"配置失败",true);
|
|
|
}
|
|
|
|
|
@@ -201,7 +208,7 @@ public class LampConfigServiceImpl extends ServiceImpl<LampConfigMapper, LampCon
|
|
|
QueryWrapper<LampConfig> wrapper = new QueryWrapper<>();
|
|
|
wrapper.eq("unit_id",unitId);
|
|
|
Long countAll = lampConfigMapper.selectCount(wrapper);
|
|
|
- wrapper.eq("open_start",1);
|
|
|
+ wrapper.eq("upload_start",1);
|
|
|
Long countStart = lampConfigMapper.selectCount(wrapper);
|
|
|
Long countClose =countAll -countStart;
|
|
|
Map endMap = new HashMap();
|
|
@@ -218,16 +225,26 @@ public class LampConfigServiceImpl extends ServiceImpl<LampConfigMapper, LampCon
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
- public Result updateLamp(Map<String, Integer> map, HttpServletRequest request) {
|
|
|
- Integer uploadStart = map.get("uploadStart");
|
|
|
- Integer id = map.get("id");
|
|
|
- Integer unitId = map.get("unitId");
|
|
|
+ public Result updateLamp(Map<String, Object> map, HttpServletRequest request) {
|
|
|
+ Integer uploadStart = (Integer) map.get("uploadStart");
|
|
|
+ String id = (String) map.get("id");
|
|
|
+ String unitId = (String)map.get("unitId");
|
|
|
LampConfig lampConfig = new LampConfig();
|
|
|
lampConfig.setUploadStart(uploadStart);
|
|
|
+
|
|
|
if (ObjectUtil.isNotEmpty(unitId)){
|
|
|
+ if (uploadStart ==1 && lampConfigMapper.exists(new QueryWrapper<LampConfig>().isNull("temp_set").eq("unit_id",unitId))) {
|
|
|
+ return new Result(10001,"有设备未配置,请先进行配置",false);
|
|
|
+
|
|
|
+ }
|
|
|
lampConfigMapper.update(lampConfig,new QueryWrapper<LampConfig>().eq("unit_id",unitId));
|
|
|
}else {
|
|
|
- lampConfig.setId(id);
|
|
|
+ if (uploadStart ==1 && lampConfigMapper.exists(new QueryWrapper<LampConfig>().isNull("temp_set").eq("id",id))) {
|
|
|
+ return new Result(10001,"设备未配置,请先进行配置",false);
|
|
|
+
|
|
|
+ }
|
|
|
+ lampConfig.setId(Integer.parseInt(id));
|
|
|
+
|
|
|
lampConfigMapper.updateById(lampConfig);
|
|
|
}
|
|
|
|
|
@@ -239,16 +256,24 @@ public class LampConfigServiceImpl extends ServiceImpl<LampConfigMapper, LampCon
|
|
|
String lampId = map.get("lampId");
|
|
|
LampConfig lampConfig = lampConfigMapper.selectById(lampId);
|
|
|
if (ObjectUtil.isEmpty(lampConfig)){
|
|
|
- lampConfig = new LampConfig();
|
|
|
- lampConfig.setInitAge(0);
|
|
|
- lampConfig.setAgeList("0,33;");
|
|
|
+ return new Result(10001,"设备不存在",false);
|
|
|
}
|
|
|
+
|
|
|
Map endMap =new HashMap();
|
|
|
endMap.put("initDayage",lampConfig.getInitAge());
|
|
|
endMap.put("listDayage",lampConfig.getAgeList().split(";"));
|
|
|
endMap.put("id",lampConfig.getId());
|
|
|
endMap.put("lampName",lampConfig.getLampName());
|
|
|
endMap.put("deviceId",lampConfig.getDeviceId());
|
|
|
+ endMap.put("openStrart",lampConfig.getOpenStart());
|
|
|
+ endMap.put("uploadStart",lampConfig.getUploadStart());
|
|
|
+ endMap.put("boardGear",lampConfig.getBoardGear());
|
|
|
+ endMap.put("tempSet",lampConfig.getTempSet());
|
|
|
+ endMap.put("location",lampConfig.getLocation());
|
|
|
+ endMap.put("dayage",lampConfig.getDayAge());
|
|
|
+ endMap.put("unitId",lampConfig.getUnitId());
|
|
|
+ endMap.put("farmCode",lampConfig.getFarmCode());
|
|
|
+ endMap.put("binding",lampConfig.getBinding());
|
|
|
return new Result(ResultCode.SUCCESS,endMap);
|
|
|
}
|
|
|
-}
|
|
|
+}
|