|
|
@@ -7,12 +7,16 @@ import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
|
|
import com.baomidou.mybatisplus.core.toolkit.IdWorker;
|
|
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
|
|
import com.xunmei.common.core.domain.iot.domain.IotAlarmSubsystem;
|
|
|
+import com.xunmei.common.core.domain.iot.domain.IotServerInfo;
|
|
|
import com.xunmei.common.core.domain.work.domain.IotWorkRule;
|
|
|
import com.xunmei.common.core.domain.work.domain.IotWorkRuleItem;
|
|
|
import com.xunmei.common.core.domain.work.dto.WorkRuleItemReq;
|
|
|
import com.xunmei.common.core.domain.work.dto.WorkRuleReq;
|
|
|
import com.xunmei.common.core.utils.JacksonUtils;
|
|
|
+import com.xunmei.common.core.utils.RsaHelper;
|
|
|
+import com.xunmei.common.core.utils.StringUtils;
|
|
|
import com.xunmei.host.protection.service.IotAlarmSubsystemService;
|
|
|
+import com.xunmei.host.server.service.IotServerInfoService;
|
|
|
import com.xunmei.host.websocket.constant.WebSocketConstants;
|
|
|
import com.xunmei.host.websocket.dto.WebsocketExecuteReq;
|
|
|
import com.xunmei.host.websocket.enums.ProductEnums;
|
|
|
@@ -36,6 +40,9 @@ public class IotWorkRuleServiceImpl extends ServiceImpl<IotWorkRuleMapper, IotWo
|
|
|
@Resource
|
|
|
private IotAlarmSubsystemService subsystemService;
|
|
|
|
|
|
+ @Resource
|
|
|
+ private IotServerInfoService iotServerInfoService;
|
|
|
+
|
|
|
|
|
|
@Override
|
|
|
public void deleteWorkRule(IotWorkRule iotWorkRule) {
|
|
|
@@ -81,7 +88,7 @@ public class IotWorkRuleServiceImpl extends ServiceImpl<IotWorkRuleMapper, IotWo
|
|
|
}
|
|
|
|
|
|
@Transactional(rollbackFor = Exception.class)
|
|
|
- public void saveBatchWorkRule(WebsocketExecuteReq req){
|
|
|
+ public void saveBatchWorkRule(WebsocketExecuteReq req) {
|
|
|
Object data = req.getData();
|
|
|
JSONArray dataArray = (JSONArray) data;
|
|
|
List<WorkRuleReq> dataList = dataArray.toJavaList(WorkRuleReq.class);
|
|
|
@@ -118,7 +125,7 @@ public class IotWorkRuleServiceImpl extends ServiceImpl<IotWorkRuleMapper, IotWo
|
|
|
}
|
|
|
|
|
|
@Transactional(rollbackFor = Exception.class)
|
|
|
- public void saveOrUpdateWorkRule(WebsocketExecuteReq req){
|
|
|
+ public void saveOrUpdateWorkRule(WebsocketExecuteReq req) {
|
|
|
Object data = req.getData();
|
|
|
WorkRuleReq workRuleReq = JSON.parseObject(data.toString(), WorkRuleReq.class);
|
|
|
saveData(workRuleReq,req.getServerInfo().getIotCode());
|
|
|
@@ -134,7 +141,7 @@ public class IotWorkRuleServiceImpl extends ServiceImpl<IotWorkRuleMapper, IotWo
|
|
|
}
|
|
|
|
|
|
@Transactional(rollbackFor = Exception.class)
|
|
|
- public void saveData(WorkRuleReq workRuleReq,String iotToken){
|
|
|
+ public void saveData(WorkRuleReq workRuleReq,String iotToken) {
|
|
|
IotWorkRule workRule = getWorkRule(workRuleReq, iotToken);
|
|
|
List<IotWorkRuleItem> deleteList = new ArrayList<>();
|
|
|
List<IotWorkRuleItem> updateList = new ArrayList<>();
|
|
|
@@ -223,6 +230,22 @@ public class IotWorkRuleServiceImpl extends ServiceImpl<IotWorkRuleMapper, IotWo
|
|
|
ruleItemService.removeBatchByIds(deleteList);
|
|
|
}
|
|
|
|
|
|
+ String password = null;
|
|
|
+ //修改操作密码
|
|
|
+ if (StringUtils.isNotEmpty(workRuleReq.getPassword())){
|
|
|
+ try {
|
|
|
+ password = RsaHelper.decodeStr(workRuleReq.getPassword());
|
|
|
+ }catch (Exception e){
|
|
|
+ throw new RuntimeException("密码解密失败");
|
|
|
+ }
|
|
|
+ }
|
|
|
+ QueryWrapper<IotServerInfo> wrapper = new QueryWrapper<>();
|
|
|
+ wrapper.lambda().eq(IotServerInfo::getIotCode, iotToken);
|
|
|
+ IotServerInfo serverInfo = iotServerInfoService.getOne(wrapper);
|
|
|
+ if (null != serverInfo){
|
|
|
+ serverInfo.setPassword(password);
|
|
|
+ iotServerInfoService.updateById(serverInfo);
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
private IotWorkRule getWorkRule(WorkRuleReq workRuleReq,String iotToken){
|