Browse Source

Merge branch 'usky-zyj' of uskycloud/usky-modules into master

gez 3 weeks ago
parent
commit
b8d4c6f0df

+ 12 - 0
service-eg/service-eg-biz/src/main/java/com/usky/eg/domain/EgDevice.java

@@ -123,6 +123,18 @@ public class EgDevice implements Serializable {
      */
     private String openMode;
 
+    /**
+     * 密码
+     */
+    private String password;
+
+    /**
+     * 工作状态
+     */
+    private String workStatus;
+
+    /**
+
     /**
      * 用户人脸信息记录
      */

+ 2 - 1
service-eg/service-eg-biz/src/main/java/com/usky/eg/service/impl/EgDeviceServiceImpl.java

@@ -74,7 +74,8 @@ public class EgDeviceServiceImpl extends AbstractCrudService<EgDeviceMapper, EgD
         if(page.getRecords().size() > 0){
 
             LambdaQueryWrapper<MeetingFace> meetingFaceQuery = Wrappers.lambdaQuery();
-            meetingFaceQuery.eq(MeetingFace::getTenantId,tenantId);
+            meetingFaceQuery.select(MeetingFace::getFid,MeetingFace::getCreateTime,MeetingFace::getVefNum,MeetingFace::getFaceName,MeetingFace::getRemark,MeetingFace::getFaceStatus,MeetingFace::getCardNum,MeetingFace::getBindDevice,MeetingFace::getDeptId,MeetingFace::getTenantId,MeetingFace::getUserId)
+                    .eq(MeetingFace::getTenantId,tenantId);
             List<MeetingFace> meetingAllFaceList = meetingFaceMapper.selectList(meetingFaceQuery);
 
             for (int i = 0; i < page.getRecords().size(); i++) {

+ 2 - 0
service-eg/service-eg-biz/src/main/resources/mapper/eg/EgDeviceMapper.xml

@@ -23,6 +23,8 @@
         <result column="img_path" property="imgPath" />
         <result column="remark" property="remark" />
         <result column="open_mode" property="openMode" />
+        <result column="password" property="password" />
+        <result column="work_status" property="workStatus" />
     </resultMap>
     <insert id="insertMeetingFaceDevice" parameterType="integer">
         insert into meeting_face_device (face_id,device_id) value (#{fid}, #{egDeviceId});

+ 1 - 1
service-iot/service-iot-biz/src/main/java/com/usky/iot/controller/web/DmpProductInfoController.java

@@ -34,7 +34,7 @@ public class DmpProductInfoController {
      * @return
      */
     @PostMapping
-    public ApiResult<Void> add(@RequestBody DmpProductInfo dmpProductInfo){
+    public ApiResult<Void> add(@RequestBody List<DmpProductInfo> dmpProductInfo){
         dmpProductInfoService.add(dmpProductInfo);
         return ApiResult.success();
     }

+ 5 - 0
service-iot/service-iot-biz/src/main/java/com/usky/iot/domain/DmpDeviceType.java

@@ -87,5 +87,10 @@ public class DmpDeviceType implements Serializable {
      */
     private LocalDateTime updatedTime;
 
+    /**
+     * 命令字段
+     */
+    private String commandField;
+
 
 }

+ 1 - 1
service-iot/service-iot-biz/src/main/java/com/usky/iot/service/DmpProductInfoService.java

@@ -19,7 +19,7 @@ import java.util.Map;
 public interface DmpProductInfoService extends CrudService<DmpProductInfo> {
 
 
-    void add(DmpProductInfo dmpProductInfo);
+    void add(List<DmpProductInfo> dmpProductInfo);
 
     void update(DmpProductInfo dmpProductInfo);
 

+ 106 - 58
service-iot/service-iot-biz/src/main/java/com/usky/iot/service/impl/DmpProductInfoServiceImpl.java

@@ -58,72 +58,120 @@ public class DmpProductInfoServiceImpl extends AbstractCrudService<DmpProductInf
     @Autowired
     private RemoteTransferService remoteTransferService;
 
+    @Autowired
+    private DmpProductCommandService dmpProductCommandService;
+
     @Override
-    public void add(DmpProductInfo dmpProductInfo) {
-        if (checkNameUnique(dmpProductInfo)){
-            throw new BusinessException("新增产品信息'" + dmpProductInfo.getProductCode() + "'失败,产品信息已存在");
+    public void add(List<DmpProductInfo> dmpProductInfo) {
+        if (CollectionUtils.isEmpty(dmpProductInfo)) {
+            throw new BusinessException("数据不能为空");
         }
-        int deviceType = dmpProductInfo.getDeviceType();
-        LambdaQueryWrapper<DmpDeviceType> queryWrapper = Wrappers.lambdaQuery();
-        queryWrapper.select(DmpDeviceType::getDataField)
-                .eq(DmpDeviceType::getTypeCode,deviceType);
-        DmpDeviceType one  = dmpDeviceTypeService.getOne(queryWrapper);
-        String dd = one.getDataField();
-        if (StringUtils.isBlank(dd) || dd.length() == 0){
-            throw new BusinessException("新增产品信息'" + dmpProductInfo.getProductCode() + "'失败,设备类型缺少属性");
-        }
-
-        QueryWrapper<DmpProductInfo> query = Wrappers.query();
-        query.select("max(id) as id");
-        DmpProductInfo info1 = this.getOne(query);
-        int id = info1.getId()+1;
-        String productCode = String.format("%03d",deviceType)+"_"+String.format("%04d",id);
-        dmpProductInfo.setProductCode(productCode);
 
-        dmpProductInfo.setCreatedBy(SecurityUtils.getUsername());
-        dmpProductInfo.setCreatedTime(new Date());
-        dmpProductInfo.setDeleteFlag(0);
-        dmpProductInfo.setTenantId(SecurityUtils.getTenantId());
-        this.save(dmpProductInfo);
+        for (int k = 0; k < dmpProductInfo.size(); k++) {
+            if (checkNameUnique(dmpProductInfo.get(k))){
+                throw new BusinessException("新增产品信息'" + dmpProductInfo.get(k).getProductCode() + "'失败,产品信息已存在");
+            }
+            int deviceType = dmpProductInfo.get(k).getDeviceType();
+            LambdaQueryWrapper<DmpDeviceType> queryWrapper = Wrappers.lambdaQuery();
+            queryWrapper.select(DmpDeviceType::getDataField,DmpDeviceType::getCommandField)
+                    .eq(DmpDeviceType::getTypeCode,deviceType);
+            DmpDeviceType one  = dmpDeviceTypeService.getOne(queryWrapper);
+            String dd = one.getDataField();
+            if (StringUtils.isBlank(dd) || dd.length() == 0){
+                throw new BusinessException("新增产品信息'" + dmpProductInfo.get(k).getProductCode() + "'失败,设备类型缺少属性");
+            }
 
-        remoteTransferService.deleteProductCache();
+            QueryWrapper<DmpProductInfo> query = Wrappers.query();
+            query.select("max(id) as id");
+            DmpProductInfo info1 = this.getOne(query);
+            int id = info1.getId()+1;
+            String productCode = String.format("%03d",deviceType)+"_"+id;
+            dmpProductInfo.get(k).setProductCode(productCode);
+
+            dmpProductInfo.get(k).setCreatedBy(SecurityUtils.getUsername());
+            dmpProductInfo.get(k).setCreatedTime(new Date());
+            dmpProductInfo.get(k).setDeleteFlag(0);
+            dmpProductInfo.get(k).setTenantId(SecurityUtils.getTenantId());
+            this.save(dmpProductInfo.get(k));
+
+            remoteTransferService.deleteProductCache();
+
+            int productId = dmpProductInfo.get(k).getId();
+            if(null != one){
+                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);
+                        }
+                    }
+                }
 
-        int productId = dmpProductInfo.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.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);
+                        }
+                    }
                 }
             }
         }
+
     }
 
     @Override

+ 1 - 0
service-iot/service-iot-biz/src/main/resources/mapper/iot/DmpDeviceTypeMapper.xml

@@ -17,6 +17,7 @@
         <result column="created_time" property="createdTime" />
         <result column="updated_by" property="updatedBy" />
         <result column="updated_time" property="updatedTime" />
+        <result column="command_field" property="commandField" />
     </resultMap>
     <select id="getProductInfo" resultType="com.usky.iot.domain.DmpProductInfo">
         select