|
@@ -58,6 +58,9 @@ public class DmpProductInfoServiceImpl extends AbstractCrudService<DmpProductInf
|
|
|
@Autowired
|
|
|
private RemoteTransferService remoteTransferService;
|
|
|
|
|
|
+ @Autowired
|
|
|
+ private DmpProductCommandService dmpProductCommandService;
|
|
|
+
|
|
|
@Override
|
|
|
public void add(List<DmpProductInfo> dmpProductInfo) {
|
|
|
if (CollectionUtils.isEmpty(dmpProductInfo)) {
|
|
@@ -70,7 +73,7 @@ public class DmpProductInfoServiceImpl extends AbstractCrudService<DmpProductInf
|
|
|
}
|
|
|
int deviceType = dmpProductInfo.get(k).getDeviceType();
|
|
|
LambdaQueryWrapper<DmpDeviceType> queryWrapper = Wrappers.lambdaQuery();
|
|
|
- queryWrapper.select(DmpDeviceType::getDataField)
|
|
|
+ queryWrapper.select(DmpDeviceType::getDataField,DmpDeviceType::getCommandField)
|
|
|
.eq(DmpDeviceType::getTypeCode,deviceType);
|
|
|
DmpDeviceType one = dmpDeviceTypeService.getOne(queryWrapper);
|
|
|
String dd = one.getDataField();
|
|
@@ -95,37 +98,75 @@ public class DmpProductInfoServiceImpl extends AbstractCrudService<DmpProductInf
|
|
|
|
|
|
int productId = dmpProductInfo.get(k).getId();
|
|
|
if(null != one){
|
|
|
- String dataField = one.getDataField();
|
|
|
- JSONArray array = new JSONArray();
|
|
|
- array = JSONArray.parseArray(dataField);
|
|
|
- if(array.size()>0){
|
|
|
- for(int i=0;i<array.size();i++){
|
|
|
- JSONObject obj = JSONObject.parseObject(array.getString(i));
|
|
|
- String attribute_name = obj.getString("attribute_name");
|
|
|
- String attribute_code = obj.getString("attribute_code");
|
|
|
- int attribute_port = obj.getInteger("attribute_port");
|
|
|
- int data_type = obj.getInteger("data_type");
|
|
|
- int attribute_length = obj.getInteger("attribute_length");
|
|
|
- String attribute_unit = obj.getString("attribute_unit");
|
|
|
- int maximum = obj.getInteger("maximum");
|
|
|
- int minimum = obj.getInteger("minimum");
|
|
|
-
|
|
|
- DmpProductAttribute dmpProductAttribute = new DmpProductAttribute();
|
|
|
- dmpProductAttribute.setProductId(productId);
|
|
|
- dmpProductAttribute.setAttributeName(attribute_name);
|
|
|
- dmpProductAttribute.setAttributeCode(attribute_code);
|
|
|
- dmpProductAttribute.setAttributePort(attribute_port);
|
|
|
- dmpProductAttribute.setAttributeType(1);
|
|
|
- dmpProductAttribute.setDataType(data_type);
|
|
|
- dmpProductAttribute.setAttributeLength(attribute_length);
|
|
|
- dmpProductAttribute.setAttributeUnit(attribute_unit);
|
|
|
- dmpProductAttribute.setMaximum(BigDecimal.valueOf(maximum));
|
|
|
- dmpProductAttribute.setMinimum(BigDecimal.valueOf(minimum));
|
|
|
- dmpProductAttribute.setDeleteFlag(0);
|
|
|
- dmpProductAttribute.setCreatedBy(SecurityUtils.getUsername());
|
|
|
- dmpProductAttribute.setCreatedTime(new Date());
|
|
|
- dmpProductAttribute.setTenantId(SecurityUtils.getTenantId());
|
|
|
- dmpProductAttributeService.save(dmpProductAttribute);
|
|
|
+ if(Objects.nonNull(one.getDataField())){
|
|
|
+ String dataField = one.getDataField();
|
|
|
+ JSONArray array = new JSONArray();
|
|
|
+ array = JSONArray.parseArray(dataField);
|
|
|
+ if(array.size()>0){
|
|
|
+ for(int i=0;i<array.size();i++){
|
|
|
+ JSONObject obj = JSONObject.parseObject(array.getString(i));
|
|
|
+ String attribute_name = obj.getString("attribute_name");
|
|
|
+ String attribute_code = obj.getString("attribute_code");
|
|
|
+ int attribute_port = obj.getInteger("attribute_port");
|
|
|
+ int data_type = obj.getInteger("data_type");
|
|
|
+ int attribute_length = obj.getInteger("attribute_length");
|
|
|
+ String attribute_unit = obj.getString("attribute_unit");
|
|
|
+ int maximum = obj.getInteger("maximum");
|
|
|
+ int minimum = obj.getInteger("minimum");
|
|
|
+
|
|
|
+ DmpProductAttribute dmpProductAttribute = new DmpProductAttribute();
|
|
|
+ dmpProductAttribute.setProductId(productId);
|
|
|
+ dmpProductAttribute.setAttributeName(attribute_name);
|
|
|
+ dmpProductAttribute.setAttributeCode(attribute_code);
|
|
|
+ dmpProductAttribute.setAttributePort(attribute_port);
|
|
|
+ dmpProductAttribute.setAttributeType(1);
|
|
|
+ dmpProductAttribute.setDataType(data_type);
|
|
|
+ dmpProductAttribute.setAttributeLength(attribute_length);
|
|
|
+ dmpProductAttribute.setAttributeUnit(attribute_unit);
|
|
|
+ dmpProductAttribute.setMaximum(BigDecimal.valueOf(maximum));
|
|
|
+ dmpProductAttribute.setMinimum(BigDecimal.valueOf(minimum));
|
|
|
+ dmpProductAttribute.setDeleteFlag(0);
|
|
|
+ dmpProductAttribute.setCreatedBy(SecurityUtils.getUsername());
|
|
|
+ dmpProductAttribute.setCreatedTime(new Date());
|
|
|
+ dmpProductAttribute.setTenantId(SecurityUtils.getTenantId());
|
|
|
+ dmpProductAttributeService.save(dmpProductAttribute);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ if(Objects.nonNull(one.getCommandField())){
|
|
|
+ String commandField = one.getCommandField();
|
|
|
+ JSONArray array = JSONArray.parseArray(commandField);
|
|
|
+ if(array.size()>0){
|
|
|
+ for(int i=0;i<array.size();i++){
|
|
|
+ JSONObject obj = JSONObject.parseObject(array.getString(i));
|
|
|
+ String command_name = obj.getString("command_name");
|
|
|
+ String command_code = obj.getString("command_code");
|
|
|
+ int data_type = obj.getInteger("data_type");
|
|
|
+
|
|
|
+ DmpProductCommand dmpProductCommand = new DmpProductCommand();
|
|
|
+ dmpProductCommand.setProductCode(productCode);
|
|
|
+ dmpProductCommand.setCommandName(command_name);
|
|
|
+ dmpProductCommand.setCommandCode(command_code);
|
|
|
+ dmpProductCommand.setDataType(data_type);
|
|
|
+ if(!(obj.getString("command_dict")).equals("")){
|
|
|
+ dmpProductCommand.setCommandDict(obj.getString("command_dict"));
|
|
|
+ }
|
|
|
+ if(!(obj.getString("command_unit")).equals("")){
|
|
|
+ dmpProductCommand.setCommandUnit(obj.getString("command_unit"));
|
|
|
+ }
|
|
|
+ if(!(obj.getString("maximum")).equals("")){
|
|
|
+ dmpProductCommand.setMaximum(BigDecimal.valueOf(Long.parseLong(obj.getString("maximum"))));
|
|
|
+ }
|
|
|
+ if(!(obj.getString("minimum")).equals("")){
|
|
|
+ dmpProductCommand.setMinimum(BigDecimal.valueOf(Long.parseLong(obj.getString("minimum"))));
|
|
|
+ }
|
|
|
+ dmpProductCommand.setDeleteFlag(0);
|
|
|
+ dmpProductCommand.setCreatedBy(SecurityUtils.getUsername());
|
|
|
+ dmpProductCommand.setCreatedTime(LocalDateTime.now());
|
|
|
+ dmpProductCommand.setTenantId(SecurityUtils.getTenantId());
|
|
|
+ dmpProductCommandService.save(dmpProductCommand);
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
}
|