Selaa lähdekoodia

sz 人员设备查询等

xiao547607 5 vuotta sitten
vanhempi
commit
ed0a56d463

+ 1 - 0
common/src/main/java/com/jpsoft/smart/modules/base/dao/PersonDeviceRelationDAO.java

@@ -19,6 +19,7 @@ public interface PersonDeviceRelationDAO {
 	List<PersonDeviceRelation> list();
 	List<PersonDeviceRelation> findByPersonId(Long personId);
     List<PersonDeviceRelation> findByDeviceId(String deviceId);
+	List<Long> findByDerviceName(String derviceName);
     PersonDeviceRelation findByDeviceIdAndPersonId(String deviceId,Long personId);
 	List<PersonDeviceRelation> search(Map<String, Object> searchParams, List<Sort> sortList);
     List<DeviceInfo> findDeviceByPersonId(Long personId);

+ 2 - 0
common/src/main/java/com/jpsoft/smart/modules/base/dto/CompanyInfoDTO.java

@@ -56,4 +56,6 @@ public class CompanyInfoDTO {
     private String type;
     @ApiModelProperty(value = "单位性质翻译")
     private String typeN;
+    @ApiModelProperty(value = "大屏公示墙网址")
+    private String wallUrl;
 }

+ 2 - 0
common/src/main/java/com/jpsoft/smart/modules/base/entity/CompanyInfo.java

@@ -50,4 +50,6 @@ public class CompanyInfo {
 	private String type;
 	@ApiModelProperty(value = "单位性质翻译")
 	private String typeN;
+	@ApiModelProperty(value = "大屏公示墙网址")
+	private String wallUrl;
 }

+ 1 - 0
common/src/main/java/com/jpsoft/smart/modules/base/service/PersonDeviceRelationService.java

@@ -20,6 +20,7 @@ public interface PersonDeviceRelationService {
 	List<PersonDeviceRelation> list();
 	List<PersonDeviceRelation> findByPersonId(Long personId);
 	List<PersonDeviceRelation> findByDeviceId(String deviceId);
+	List<Long> findByDerviceName(String derviceName);
 	PersonDeviceRelation findByDeviceIdAndPersonId(String deviceId,Long personId);
 	Page<PersonDeviceRelation> pageSearch(Map<String, Object> searchParams, int pageNum, int pageSize,boolean count, List<Sort> sortList);
 

+ 5 - 0
common/src/main/java/com/jpsoft/smart/modules/base/service/impl/PersonDeviceRelationServiceImpl.java

@@ -94,6 +94,11 @@ public class PersonDeviceRelationServiceImpl implements PersonDeviceRelationServ
 		return personDeviceRelationDAO.findByDeviceId(deviceId);
 	}
 
+	@Override
+	public List<Long> findByDerviceName(String derviceName){
+		return personDeviceRelationDAO.findByDerviceName(derviceName);
+	}
+
 	@Override
 	public PersonDeviceRelation findByDeviceIdAndPersonId(String deviceId,Long personId){
 		return personDeviceRelationDAO.findByDeviceIdAndPersonId(deviceId,personId);

+ 8 - 1
common/src/main/resources/mapper/base/CompanyInfo.xml

@@ -18,6 +18,7 @@
         <result property="code" column="code_"/>
         <result property="parentName" column="parent_name"/>
         <result property="type" column="type_"/>
+        <result property="wallUrl" column="wall_url" />
     </resultMap>
     <insert id="insert" parameterType="com.jpsoft.smart.modules.base.entity.CompanyInfo">
         <!--
@@ -27,7 +28,9 @@
         -->
         <![CDATA[
 		insert into base_company_info
-	    (id_,sort_no,name_,logo_,remark_,create_by,create_time,update_by,update_time,del_flag,parent_id,code_,type_)
+	    (id_,sort_no,name_,logo_,remark_,create_by,create_time,
+	    update_by,update_time,del_flag,parent_id,code_,type_,
+	    wall_url)
 		values
 		(
 			#{id,jdbcType=VARCHAR}
@@ -43,6 +46,7 @@
 			,#{parentId,jdbcType=VARCHAR}
 			,#{code,jdbcType=VARCHAR}
 			,#{type,jdbcType=VARCHAR}
+            ,#{wallUrl,jdbcType=VARCHAR}
 		)
 	]]>
     </insert>
@@ -88,6 +92,9 @@
             <if test="type!=null">
                 type_=#{type,jdbcType=VARCHAR},
             </if>
+            <if test="wallUrl!=null">
+                wall_url=#{wallUrl,jdbcType= VARCHAR },
+            </if>
         </set>
         where id_=#{id}
     </update>

+ 4 - 1
common/src/main/resources/mapper/base/DeviceInfo.xml

@@ -36,7 +36,10 @@
 	-->
 	<![CDATA[
 		insert into base_device_info
-	    (id_,header_,device_no,alias_name,address_,is_online,company_id,unlock_password,code_address,ip_address,port_,type_,is_auto_update,del_flag,create_by,create_time,update_by,update_time,default_face_library_id,heartbeat_update_time,abnormal_reason)
+	    (id_,header_,device_no,alias_name,address_,is_online,company_id,
+	    unlock_password,code_address,ip_address,port_,type_,is_auto_update,
+	    del_flag,create_by,create_time,update_by,update_time,
+	    default_face_library_id,heartbeat_update_time,abnormal_reason)
 		values
 		(
 			#{id,jdbcType=VARCHAR}

+ 7 - 0
common/src/main/resources/mapper/base/PersonDeviceRelation.xml

@@ -175,4 +175,11 @@ id_,device_id,person_id,del_flag,create_by,create_time,update_by,update_time		fr
 		</set>
 		where id_=#{id}
 	</update>
+	<select id="findByDerviceName" resultType="Long">
+		select a.person_id from base_person_device_relation a,base_device_info b
+		where a.device_id = b.id_
+		and a.del_flag=false
+		and b.alias_name like #{derviceName}
+	</select>
+
 </mapper>

+ 5 - 1
common/src/main/resources/mapper/base/PersonInfo.xml

@@ -230,7 +230,11 @@
                 )
                 ]]>
             </if>
-
+            <if test="searchParams.relationPersonIds != null">
+                <foreach item="relationPersonId" collection="searchParams.relationPersonIds" open="and a.id_ in (" separator="," close=")">
+                    #{relationPersonId}
+                </foreach>
+            </if>
         </where>
         <foreach item="sort" collection="sortList" open="order by" separator=",">
             ${sort.name} ${sort.order}

+ 15 - 0
web/src/main/java/com/jpsoft/smart/modules/base/controller/DeviceInfoController.java

@@ -203,6 +203,21 @@ public class DeviceInfoController {
                     int affectCount = deviceInfoService.update(deviceInfo);
 
                     if (affectCount > 0) {
+                        //判断是否修改公司
+                        //不相同为修改
+                        if(!item.getCompanyId().equals(deviceInfo.getCompanyId())) {
+                            //添加信息到设备与公司关联表
+                            //先删除
+                            companyDeviceRelationService.deleteByCompanyIdAndDeviceId(item.getCompanyId(), item.getId());
+
+                            CompanyDeviceRelation companyDeviceRelation = new CompanyDeviceRelation();
+                            companyDeviceRelation.setId(UUID.randomUUID().toString());
+                            companyDeviceRelation.setCompanyId(deviceInfo.getCompanyId());
+                            companyDeviceRelation.setDeviceId(deviceInfo.getId());
+                            //保存人脸库ID
+                            companyDeviceRelation.setLibraryId("");
+                            companyDeviceRelationService.insert(companyDeviceRelation);
+                        }
                         msgResult.setResult(true);
                         msgResult.setData(deviceInfo);
                     } else {

+ 6 - 0
web/src/main/java/com/jpsoft/smart/modules/base/controller/PersonDeviceRelationController.java

@@ -87,6 +87,7 @@ public class PersonDeviceRelationController {
                 personDeviceRelation.setDelFlag(false);
                 personDeviceRelation.setCreateBy(subject);
                 personDeviceRelation.setCreateTime(new Date());
+                personDeviceRelation.setIsBound(true);//绑定设备默认true
 
                 affectCount = personDeviceRelationService.insert(personDeviceRelation);
             }
@@ -160,6 +161,7 @@ public class PersonDeviceRelationController {
                        item.setDelFlag(false);
                        item.setCreateBy(subject);
                        item.setCreateTime(new Date());
+                       item.setIsBound(true);//绑定设备默认true
 
                        affectCount += personDeviceRelationService.insert(item);
                    }
@@ -200,6 +202,7 @@ public class PersonDeviceRelationController {
                         personDeviceRelation.setDelFlag(true);
                         personDeviceRelation.setUpdateBy(subject);
                         personDeviceRelation.setUpdateTime(new Date());
+                        personDeviceRelation.setIsBound(false);
 
                         personDeviceRelationService.update(personDeviceRelation);
                         addCount++;
@@ -277,6 +280,7 @@ public class PersonDeviceRelationController {
                         item.setDelFlag(false);
                         item.setCreateBy(subject);
                         item.setCreateTime(new Date());
+                        item.setIsBound(true);//绑定设备默认true
 
                         affectCount += personDeviceRelationService.insert(item);
                         //往设备库传输人脸信息
@@ -326,6 +330,7 @@ public class PersonDeviceRelationController {
                                 item.setDelFlag(true);
                                 item.setUpdateBy(subject);
                                 item.setUpdateTime(new Date());
+                                item.setIsBound(false);//绑定设备默认true
                                 personDeviceRelationService.update(item);
                                 addCount ++;
                             }
@@ -390,6 +395,7 @@ public class PersonDeviceRelationController {
                         item.setDelFlag(true);
                         item.setUpdateBy(subject);
                         item.setUpdateTime(new Date());
+                        item.setIsBound(false);//绑定设备默认true
                         affectCount += personDeviceRelationService.update(item);
                         //删除设备上的信息
                         new Thread(()->{

+ 11 - 0
web/src/main/java/com/jpsoft/smart/modules/base/controller/PersonInfoController.java

@@ -432,6 +432,7 @@ public class PersonInfoController {
             @ApiImplicitParam(name = "phone",value = "手机号", required = false, paramType = "form",dataType = "String"),
             @ApiImplicitParam(name = "companyCode",value = "企业编码", required = false, paramType = "form",dataType = "String"),
             @ApiImplicitParam(name = "subordinate",value = "会否保护下级单位", required = false, paramType = "form",dataType = "String"),
+            @ApiImplicitParam(name = "derviceName",value = "设备名称", required = false, paramType = "form",dataType = "String"),
             @ApiImplicitParam(name = "position1",value = "一级位置", required = false, paramType = "form",dataType = "String"),
             @ApiImplicitParam(name = "position2",value = "二级位置", required = false, paramType = "form",dataType = "String"),
             @ApiImplicitParam(name = "position3",value = "三级位置", required = false, paramType = "form",dataType = "String"),
@@ -446,6 +447,7 @@ public class PersonInfoController {
             @RequestParam(value="phone",defaultValue="") String phone,
             @RequestParam(value="companyCode",defaultValue="")  String companyCode,
             @RequestParam(value="subordinate",defaultValue="false")  Boolean subordinate,
+            @RequestParam(value="derviceName",defaultValue="") String derviceName,
             @RequestParam(value="position1",defaultValue="") String position1,
             @RequestParam(value="position2",defaultValue="") String position2,
             @RequestParam(value="position3",defaultValue="") String position3,
@@ -524,6 +526,15 @@ public class PersonInfoController {
             searchParams.put("isUploadPhoto", isUploadPhoto);
         }
 
+        if(StringUtils.isNotEmpty(derviceName)){
+            List<Long> personDeviceRelation = personDeviceRelationService.findByDerviceName("%" + derviceName + "%");
+            //String relationPersonIds = String.join(",",personDeviceRelation);
+            searchParams.put("relationPersonIds", personDeviceRelation);
+        }
+
+
+
+
         Page<PersonInfo> page = personInfoService.pageSearch(searchParams,pageIndex,pageSize,true,sortList);
         Page<PersonInfoDTO> pageDTO = PojoUtils.convertPage(page, PersonInfoDTO.class);
 

+ 12 - 12
web/src/main/java/com/jpsoft/smart/modules/mobile/controller/PersonInfoApiController.java

@@ -398,18 +398,18 @@ public class PersonInfoApiController {
                 //插入后,会将自增id写到id属性中
                 int affectCount = personInfoService.insert(personInfo);
 
-                //todo 关联设备
-                String[] deviceIds = bindDevices.split(",");
-                for(String deviceId : deviceIds){
-                    PersonDeviceRelation personDeviceRelation = new PersonDeviceRelation();
-                    personDeviceRelation.setId(UUID.randomUUID().toString());
-                    personDeviceRelation.setDeviceId(deviceId);
-                    personDeviceRelation.setPersonId(personInfo.getId());
-                    personDeviceRelation.setDelFlag(false);
-                    personDeviceRelation.setCreateBy(subject);
-                    personDeviceRelation.setCreateTime(new Date());
-                    personDeviceRelationService.insert(personDeviceRelation);
-                }
+//                //todo 关联设备
+//                String[] deviceIds = bindDevices.split(",");
+//                for(String deviceId : deviceIds){
+//                    PersonDeviceRelation personDeviceRelation = new PersonDeviceRelation();
+//                    personDeviceRelation.setId(UUID.randomUUID().toString());
+//                    personDeviceRelation.setDeviceId(deviceId);
+//                    personDeviceRelation.setPersonId(personInfo.getId());
+//                    personDeviceRelation.setDelFlag(false);
+//                    personDeviceRelation.setCreateBy(subject);
+//                    personDeviceRelation.setCreateTime(new Date());
+//                    personDeviceRelationService.insert(personDeviceRelation);
+//                }
 
                 if(affectCount>0) {
                     //todo 加入到导入图片队列中