|
|
|
@ -22,6 +22,7 @@ import org.springframework.web.multipart.MultipartFile; |
|
|
|
|
|
|
|
|
|
import javax.annotation.Resource; |
|
|
|
|
import java.io.InputStream; |
|
|
|
|
import java.security.cert.TrustAnchor; |
|
|
|
|
import java.util.ArrayList; |
|
|
|
|
import java.util.Date; |
|
|
|
|
import java.util.HashMap; |
|
|
|
@ -297,7 +298,9 @@ public class PsdcDeviceServiceImpl implements IPsdcDeviceService { |
|
|
|
|
* @return |
|
|
|
|
*/ |
|
|
|
|
@Override |
|
|
|
|
public int executiveStrategy(Integer strategyCode) { |
|
|
|
|
public String executiveStrategy(Integer strategyCode) { |
|
|
|
|
int success = 0 ; |
|
|
|
|
int lose = 0; |
|
|
|
|
List<PsdcScene> psdcScenes = psdcSceneMapper.queryBySceneCode(strategyCode); |
|
|
|
|
//根据策略码查询策略列表
|
|
|
|
|
for (PsdcScene psdcScene: psdcScenes ) { |
|
|
|
@ -307,15 +310,25 @@ public class PsdcDeviceServiceImpl implements IPsdcDeviceService { |
|
|
|
|
String controlContext = ControlKeyEnum.getControlContext(controlKey); |
|
|
|
|
|
|
|
|
|
String deviceName = psdcDeviceMapper.queryDeviceNameByDeviceId(psdcScene.getDeviceId()); |
|
|
|
|
Boolean flag = Boolean.FALSE; |
|
|
|
|
//TODO 发送MQTT指令
|
|
|
|
|
// psdcControlLogMapper.insert(new PsdcControlLog(deviceId,psdcDevice.getDeviceName(),psdcDevice.getDeviceSn(),controlContext,controlValue,controlMethod,2,"控制成功",controlBy));
|
|
|
|
|
// psdcControlLogMapper.insert(new PsdcControlLog(deviceId,psdcDevice.getDeviceName(),psdcDevice.getDeviceSn(),controlContext,controlValue,controlMethod,3,"等待终端响应超时",controlBy));
|
|
|
|
|
//发送成功
|
|
|
|
|
psdcControlLogMapper.insert(new PsdcControlLog(psdcScene.getDeviceId(),deviceName, psdcScene.getDeviceSn(), controlContext, controlValue, 3, 2, "控制成功", SecurityUtils.getUsername())); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
flag = Boolean.TRUE; |
|
|
|
|
if (flag) |
|
|
|
|
{ |
|
|
|
|
//发送成功
|
|
|
|
|
int insert = psdcControlLogMapper.insert(new PsdcControlLog(psdcScene.getDeviceId(), deviceName, psdcScene.getDeviceSn(), controlContext, controlValue, 3, 2, "控制成功", SecurityUtils.getUsername())); |
|
|
|
|
success = success + insert; |
|
|
|
|
} else { |
|
|
|
|
// psdcControlLogMapper.insert(new PsdcControlLog(deviceId,psdcDevice.getDeviceName(),psdcDevice.getDeviceSn(),controlContext,controlValue,controlMethod,2,"控制成功",controlBy));
|
|
|
|
|
// psdcControlLogMapper.insert(new PsdcControlLog(deviceId,psdcDevice.getDeviceName(),psdcDevice.getDeviceSn(),controlContext,controlValue,controlMethod,3,"等待终端响应超时",controlBy));
|
|
|
|
|
// lose = lose + i;
|
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
if(success == psdcScenes.size()){ |
|
|
|
|
return "控制成功,控制数量:" + success; |
|
|
|
|
} else { |
|
|
|
|
return "部分失败,成功:" + success + "条,失败:" + lose + "条"; |
|
|
|
|
} |
|
|
|
|
return 0; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
private String coverStr(String s, int i) { |
|
|
|
|