#task_content
{
"begin":xxx,
"end":xxx,
"deviceIds":["uuid1","uuid2"]
}
#file_url
[
{"uuid1":"fileid"},{"uuid2":"fileid2"}
]
@Override
public List<UploadTaskCenterVO> uploadTaskCenter(UploadTaskCenterDto uploadTaskCenterDto) {
String tenantId = RequestContext.getCurrentSession().getTenantId();
TaskCenterDO taskCenterDO = taskCenterManager.getByIdAndTenantId(uploadTaskCenterDto.getId(), tenantId);
List<Object> list = new ArrayList<>();
String taskContent = taskCenterDO.getTaskContent();
JSONObject jsonObject1 = JSONObject.parseObject(taskContent);
JSONArray deviceIds = jsonObject1.getJSONArray("deviceIds");
for (int j = 0; j < deviceIds.size(); j++) {
Object o = deviceIds.get(j);
list.add(o);
}
String fileUrl = taskCenterDO.getFileUrl();
JSONArray jsonArray = JSON.parseArray(fileUrl);
List<String> fileIdList = new ArrayList<>();
for (int i = 0; i < jsonArray.size(); i++) {
JSONObject jsonObject = jsonArray.getJSONObject(i);
String uuid = (String) list.get(i);
String fileId = jsonObject.getString(uuid);
fileIdList.add(fileId);
}
List<FileDto> listFileIds = fileInfoFacade.getListFileIds(fileIdList, expireTimeInSecond);
List<UploadTaskCenterVO> uploadTaskCenterVOS = BeanUtil.mapList(listFileIds, UploadTaskCenterVO.class);
return uploadTaskCenterVOS;
}
public List<ButtonConfigDeviceVO> listDeviceType(String code) {
JSONArray jsonArray = JSON.parseArray(dataListenerConfiguration.getButtonCategory());
for (int i = 0; i < jsonArray.size(); i++) {
JSONObject jsonObject = jsonArray.getJSONObject(i);
if (jsonObject.getString("code").equalsIgnoreCase(code)) {
return GtsBeanUtils.copyListProperties(jsonObject.getJSONArray("deviceType"), ButtonConfigDeviceVO::new, (s, t) -> {
t.setCategoryCode(code);
}, "deviceModels");
}
}
return Collections.emptyList();
}
public List<String> listDeviceModel(String code, String thingModel) {
JSONArray jsonArray = JSON.parseArray(dataListenerConfiguration.getButtonCategory());
for (int i = 0; i < jsonArray.size(); i++) {
JSONObject jsonObject = jsonArray.getJSONObject(i);
if (jsonObject.getString("code").equalsIgnoreCase(code)) {
JSONArray jsonArray1 = jsonObject.getJSONArray("deviceType");
for (int i1 = 0; i1 < jsonArray1.size(); i1++) {
JSONObject jsonObject1 = jsonArray1.getJSONObject(i1);
if (jsonObject1.getString("thingModel").equalsIgnoreCase(thingModel)) {
return JSON.parseArray(jsonObject1.getJSONArray("deviceModels").toJSONString(), String.class);
}
}
}
}
return Collections.emptyList();
}
public String getCodeByThingModel(String thingModel) {
JSONArray jsonArray = JSON.parseArray(dataListenerConfiguration.getButtonCategory());
for (int i = 0; i < jsonArray.size(); i++) {
JSONObject jsonObject = jsonArray.getJSONObject(i);
String code = jsonObject.getString("code");
JSONArray jsonArray1 = jsonObject.getJSONArray("deviceType");
for (int i1 = 0; i1 < jsonArray1.size(); i1++) {
JSONObject jsonObject1 = jsonArray1.getJSONObject(i1);
List<String> deviceModels = JSON.parseArray(jsonObject1.getJSONArray("deviceModels").toJSONString(), String.class);
for (String deviceModel : deviceModels) {
if (thingModel.equalsIgnoreCase(deviceModel)) {
return code;
}
}
}
}
return "smartSwitch";
}