|
@@ -230,35 +230,86 @@ public class TLabelController {
|
|
|
label.setModifyDate(new Date());
|
|
|
label.setEquipmentIds(JSON.toJSON(list).toString());
|
|
|
String equipmentNames = label.getEquipmentNames();
|
|
|
-// char a = equipmentNames.charAt(1);
|
|
|
List<String> stringList = new ArrayList<>();
|
|
|
-// if(a!= 34){
|
|
|
-// equipmentNames=equipmentNames.substring(1,equipmentNames.length()-1);
|
|
|
-// String[] split1 = equipmentNames.split(",");
|
|
|
-// stringList = new ArrayList<>(Arrays.asList(split1));
|
|
|
-// String name = tEquipment.getName();
|
|
|
-// if(StringUtils.isNotEmpty(name)){
|
|
|
-// stringList.add(name);
|
|
|
-// }
|
|
|
-//
|
|
|
-// }else {
|
|
|
-// stringList = JSON.parseArray(equipmentNames, String.class);
|
|
|
-// if(StringUtils.isNotEmpty(tEquipment.getName())){
|
|
|
-// stringList.add(tEquipment.getName());
|
|
|
-// }
|
|
|
-// }
|
|
|
- stringList = JSON.parseArray(equipmentNames, String.class);
|
|
|
- if(StringUtils.isNotEmpty(tEquipment.getName())){
|
|
|
- stringList.add(tEquipment.getName());
|
|
|
+// stringList = JSON.parseArray(equipmentNames, String.class);
|
|
|
+ for(String eid:list){
|
|
|
+ TEquipment byId = equipmentService.getById(eid);
|
|
|
+ stringList.add(byId.getName());
|
|
|
}
|
|
|
+// if(StringUtils.isNotEmpty(tEquipment.getName())){
|
|
|
+// stringList.add(tEquipment.getName());
|
|
|
+// }
|
|
|
label.setEquipmentNames(JSON.toJSON(stringList).toString());
|
|
|
labelService.updateById(label);
|
|
|
}
|
|
|
-
|
|
|
+ List<String> stringList = new ArrayList<>();
|
|
|
+ for(String eid:list){
|
|
|
+ TEquipment byId = equipmentService.getById(eid);
|
|
|
+ stringList.add(byId.getName());
|
|
|
+ }
|
|
|
+ label.setEquipmentNames(JSON.toJSON(stringList).toString());
|
|
|
+ labelService.updateById(label);
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
- return R.ok();
|
|
|
+ //清空没有的标签
|
|
|
+ LambdaQueryWrapper<TLabel> query = Wrappers.lambdaQuery();
|
|
|
+ query.eq(TLabel::getAdminId,tEquipment.getAdminId());
|
|
|
+ query.eq(TLabel::getType,1);
|
|
|
+ List<TLabel> list = labelService.list(query);
|
|
|
+ List<TLabel> returnList = new ArrayList<>();
|
|
|
+ if(list.size()>0){
|
|
|
+ for(TLabel tLabel:list){
|
|
|
+ int i = 0;
|
|
|
+ String equipmentIds = tLabel.getEquipmentIds();
|
|
|
+ equipmentIds = equipmentIds.replace("\"", "").replace("[","").replace("]","");
|
|
|
+ String[] split1 = equipmentIds.split(",");
|
|
|
+ if(split1.length>0){
|
|
|
+ for(int j=0;j<split1.length;j++){
|
|
|
+ if(split1[j].equals(equipmentId)){
|
|
|
+ i++;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ returnList.add(tLabel);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if(returnList.size()>0){
|
|
|
+ if(labelIdList.size()!=returnList.size()){
|
|
|
+ for(TLabel tLabel:list){
|
|
|
+ int i = 0;
|
|
|
+ for(String id:labelIdList){
|
|
|
+ if(id.equals(tLabel.getId().toString())){
|
|
|
+ i++;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if(i==0){
|
|
|
+ String equipmentIds = tLabel.getEquipmentIds();
|
|
|
+ equipmentIds = equipmentIds.replace("\"", "").replace("[","").replace("]","");
|
|
|
+ String[] split1 = equipmentIds.split(",");
|
|
|
+ List<String> stringList = new ArrayList<>();
|
|
|
+ for(int j=0;j<split1.length;j++){
|
|
|
+ if(!split1[j].equals(equipmentId)){
|
|
|
+ stringList.add(split1[j]);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ List<String> newNames = new ArrayList<>();
|
|
|
+ List<String> nameList = new ArrayList<>();
|
|
|
+ String equipmentNames = tLabel.getEquipmentNames();
|
|
|
+ nameList = JSON.parseArray(equipmentNames, String.class);
|
|
|
+ for(String name : nameList){
|
|
|
+ if(!name.equals(tEquipment.getName())){
|
|
|
+ newNames.add(name);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ tLabel.setEquipmentNames(JSON.toJSON(newNames).toString());
|
|
|
+ tLabel.setEquipmentIds(JSON.toJSON(stringList).toString());
|
|
|
+ labelService.updateById(tLabel);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return R.ok(null,"绑定成功");
|
|
|
}
|
|
|
@ApiOperation(value = "单个机器标签")
|
|
|
@GetMapping("/getEquipmentToLabel")
|
|
@@ -276,6 +327,7 @@ public class TLabelController {
|
|
|
for(TLabel tLabel:list){
|
|
|
int i = 0;
|
|
|
String equipmentIds = tLabel.getEquipmentIds();
|
|
|
+ equipmentIds = equipmentIds.replace("\"", "").replace("[","").replace("]","");
|
|
|
String[] split = equipmentIds.split(",");
|
|
|
if(split.length>0){
|
|
|
for(int j=0;j<split.length;j++){
|