Procházet zdrojové kódy

移动端查询增加人员单位多对多关联。

zhengqiang před 5 roky
rodič
revize
988e32e37a

+ 3 - 1
common/src/main/java/com/jpsoft/smart/modules/base/dao/CompanyInfoDAO.java

@@ -26,7 +26,9 @@ public interface CompanyInfoDAO {
 
 	long countByParentId(String parentId);
 
-	long countByCompanyCode(String code);
+	long countByCompanyCode(String code,Long personId);
 
 	int updateCode(String oldCode,int startIndex, String newCode);
+
+    List<CompanyInfo> findByCompanyCode(String code, Long personId);
 }

+ 3 - 3
common/src/main/java/com/jpsoft/smart/modules/base/dao/PersonDeviceFilterLogDAO.java

@@ -38,7 +38,7 @@ public interface PersonDeviceFilterLogDAO {
 
     List<PersonDeviceFilterLog> list();
 
-    List<Map<String, Object>> unusualStatistics(String companyCode, BigDecimal temperature, Date startDate, Date endDate);
+    List<Map<String, Object>> unusualStatistics(String companyCode,Long personId, BigDecimal temperature, Date startDate, Date endDate);
 
     PersonDeviceFilterLog lastPersonLog(Long personId);
 
@@ -46,9 +46,9 @@ public interface PersonDeviceFilterLogDAO {
 
     PersonDeviceFilterLog get(Long id);
 
-    long countByTimeRangeAndCompanyCode(String companyCode,int status, Date startDate, Date endDate);
+    long countByTimeRangeAndCompanyCode(String companyCode,Long personId,int status, Date startDate, Date endDate);
 
     List<PersonInfo> queryUnmeasuredList(String companyId, Date startTime, Date endTime);
 
-    long countUndetectedByCompanyCode(String companyCode, Date startTime, Date endTime);
+    long countUndetectedByCompanyCode(String companyCode,Long personId, Date startTime, Date endTime);
 }

+ 1 - 5
common/src/main/java/com/jpsoft/smart/modules/base/dao/PersonInfoDAO.java

@@ -15,12 +15,8 @@ public interface PersonInfoDAO {
 	int delete(Long id);
 	List<PersonInfo> list();
 	List<PersonInfo> search(Map<String, Object> searchParams, List<Sort> sortList);
-
     PersonInfo findByNameAndPhone(String name, String phone);
-
 	PersonInfo findByOpenId(String openId);
-
     List<PersonInfo> findByCompanyId(String companyId);
-
-    long countByCompanyCode(String code);
+    long countByCompanyCode(String code,Long companyId);
 }

+ 2 - 4
common/src/main/java/com/jpsoft/smart/modules/base/service/CompanyInfoService.java

@@ -14,10 +14,8 @@ public interface CompanyInfoService {
 	int delete(String id);
 	List<CompanyInfo> list();
 	Page<CompanyInfo> pageSearch(Map<String, Object> searchParams,int pageNum,int pageSize,List<Sort> sortList);
-    List<CompanyInfo> findByCompanyCode(String code);
+    List<CompanyInfo> findByCompanyCode(String code,Long personId);
     long countByParentId(String parentId);
-
-    long countByCompanyCode(String code);
-
+    long countByCompanyCode(String code,Long personId);
     int updateCode(String oldCode, String newCode);
 }

+ 3 - 3
common/src/main/java/com/jpsoft/smart/modules/base/service/PersonDeviceFilterLogService.java

@@ -39,7 +39,7 @@ public interface PersonDeviceFilterLogService {
 
     List<PersonDeviceFilterLog> temperatureUnusualStatistics(String companyCode,BigDecimal temperature,Date startDate,Date endDate);
 
-    List<Map<String, Object>> unusualStatistics(String companyCode,BigDecimal temperature,Date startDate,Date endDate);
+    List<Map<String, Object>> unusualStatistics(String companyCode,Long personId,BigDecimal temperature,Date startDate,Date endDate);
 
     PersonDeviceFilterLog lastPersonLog(Long personId);
 
@@ -47,9 +47,9 @@ public interface PersonDeviceFilterLogService {
 
     PersonDeviceFilterLog get(Long id);
 
-    long countByTimeRangeAndCompanyCode(String companyCode,int status,Date startTime, Date endTime);
+    long countByTimeRangeAndCompanyCode(String companyCode,Long personId,int status,Date startTime, Date endTime);
 
     List<PersonInfo> queryUnmeasuredList(String companyId, Date startTime, Date endTime);
 
-    long countUndetectedByCompanyCode(String companyCode, Date startTime, Date endTime);
+    long countUndetectedByCompanyCode(String companyCode,Long personId, Date startTime, Date endTime);
 }

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

@@ -20,5 +20,5 @@ public interface PersonInfoService {
 
     List<PersonInfo> findByCompanyId(String companyId);
 
-    long countByCompanyCode(String code);
+    long countByCompanyCode(String code,Long personId);
 }

+ 4 - 4
common/src/main/java/com/jpsoft/smart/modules/base/service/impl/CompanyInfoServiceImpl.java

@@ -69,8 +69,8 @@ public class CompanyInfoServiceImpl implements CompanyInfoService {
 	}
 
 	@Override
-	public List<CompanyInfo> findByCompanyCode(String code) {
-		return companyInfoDAO.findByCompanyCode(code);
+	public List<CompanyInfo> findByCompanyCode(String code,Long personId) {
+		return companyInfoDAO.findByCompanyCode(code,personId);
 	}
 
 	@Override
@@ -79,8 +79,8 @@ public class CompanyInfoServiceImpl implements CompanyInfoService {
 	}
 
 	@Override
-	public long countByCompanyCode(String code) {
-		return companyInfoDAO.countByCompanyCode(code);
+	public long countByCompanyCode(String code,Long personId) {
+		return companyInfoDAO.countByCompanyCode(code,personId);
 	}
 
 	@Override

+ 6 - 6
common/src/main/java/com/jpsoft/smart/modules/base/service/impl/PersonDeviceFilterLogServiceImpl.java

@@ -178,8 +178,8 @@ public class PersonDeviceFilterLogServiceImpl implements PersonDeviceFilterLogSe
     }
 
     @Override
-    public long countByTimeRangeAndCompanyCode(String companyCode,int status, Date startDate, Date endDate) {
-        return personDeviceFilterLogDAO.countByTimeRangeAndCompanyCode(companyCode,status,startDate,endDate);
+    public long countByTimeRangeAndCompanyCode(String companyCode,Long personId,int status, Date startDate, Date endDate) {
+        return personDeviceFilterLogDAO.countByTimeRangeAndCompanyCode(companyCode,personId,status,startDate,endDate);
     }
 
     @Override
@@ -194,8 +194,8 @@ public class PersonDeviceFilterLogServiceImpl implements PersonDeviceFilterLogSe
     }
 
     @Override
-    public List<Map<String, Object>> unusualStatistics(String companyCode, BigDecimal temperature, Date startDate, Date endDate) {
-        return personDeviceFilterLogDAO.unusualStatistics(companyCode,temperature,startDate,endDate);
+    public List<Map<String, Object>> unusualStatistics(String companyCode,Long personId, BigDecimal temperature, Date startDate, Date endDate) {
+        return personDeviceFilterLogDAO.unusualStatistics(companyCode,personId,temperature,startDate,endDate);
     }
 
     @Override
@@ -204,7 +204,7 @@ public class PersonDeviceFilterLogServiceImpl implements PersonDeviceFilterLogSe
     }
 
     @Override
-    public long countUndetectedByCompanyCode(String companyCode, Date startTime, Date endTime) {
-        return personDeviceFilterLogDAO.countUndetectedByCompanyCode(companyCode,startTime,endTime);
+    public long countUndetectedByCompanyCode(String companyCode,Long personId, Date startTime, Date endTime) {
+        return personDeviceFilterLogDAO.countUndetectedByCompanyCode(companyCode,personId,startTime,endTime);
     }
 }

+ 2 - 2
common/src/main/java/com/jpsoft/smart/modules/base/service/impl/PersonInfoServiceImpl.java

@@ -84,7 +84,7 @@ public class PersonInfoServiceImpl implements PersonInfoService {
 	}
 
 	@Override
-	public long countByCompanyCode(String code) {
-		return personInfoDAO.countByCompanyCode(code);
+	public long countByCompanyCode(String code,Long personId) {
+		return personInfoDAO.countByCompanyCode(code,personId);
 	}
 }

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

@@ -123,7 +123,14 @@
         select a.*,b.name_ as parent_name
         from base_company_info a
         left join base_company_info b on a.parent_id = b.id_
-        where a.code_ like #{code} and a.del_flag=0 order by a.id_ asc
+        where a.code_ like #{code}
+        and a.del_flag=0
+        <if test="personId!=null">
+        and a.id_ in (
+            select c.id_ from base_person_company c where c.person_id = #{personId}
+        )
+        </if>
+        order by a.id_ asc
     </select>
     <select id="countByParentId" resultType="long">
         select count(*) from base_company_info
@@ -141,5 +148,10 @@
         select count(*)
         from base_company_info
         where code_ like #{code} and del_flag=0
+        <if test="personId!=null">
+            and a.id_ in (
+                select c.id_ from base_person_company c where c.person_id = #{personId}
+            )
+        </if>
     </select>
 </mapper>

+ 17 - 3
common/src/main/resources/mapper/base/PersonDeviceFilterLog.xml

@@ -207,10 +207,9 @@
             and a.record_time <= #{endDate}
         ]]>
     </select>
-    <select id="list"   resultMap="PersonDeviceFilterLogMap">
+    <select id="list" resultMap="PersonDeviceFilterLogMap">
         select * from base_person_device_filter_log where del_flag=false
     </select>
-
     <select id="unusualStatistics"   resultType="java.util.HashMap">
         <![CDATA[
         select
@@ -226,8 +225,13 @@
             and a.temperature_ >= #{temperature}
             and a.record_time >= #{startDate}
             and a.record_time < #{endDate}
-        GROUP BY c.id_,date_format(a.record_time,'%Y-%m-%d')
         ]]>
+        <if test="personId!=null">
+            and c.id_ in (
+                select d.id_ from base_person_company d where d.person_id = #{personId}
+            )
+        </if>
+        GROUP BY c.id_,date_format(a.record_time,'%Y-%m-%d')
     </select>
     <select id="lastPersonLog"   resultMap="PersonDeviceFilterLogMap">
         SELECT * FROM base_person_device_filter_log
@@ -252,6 +256,11 @@
             and record_time >= #{startDate}
             and record_time <= #{endDate}
         ]]>
+        <if test="personId!=null">
+            and c.id_ in (
+                select d.id_ from base_person_company d where d.person_id = #{personId}
+            )
+        </if>
         <if test="status==-1">
         <![CDATA[
             and a.temperature_>=37
@@ -288,5 +297,10 @@
                 and record_time <= #{endTime}
             )
         ]]>
+        <if test="personId!=null">
+            and b.id_ in (
+                select d.id_ from base_person_company d where d.person_id = #{personId}
+            )
+        </if>
     </select>
 </mapper>

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

@@ -257,5 +257,10 @@
         left join base_company_info b on a.company_id = b.id_
         where a.del_flag = 0
         and b.code_ like #{0}
+        <if test="personId!=null">
+            and b.id_ in (
+                select c.id_ from base_person_company c where c.person_id = #{personId}
+            )
+        </if>
     </select>
 </mapper>

+ 9 - 9
web/src/main/java/com/jpsoft/smart/modules/mobile/controller/PersonDeviceLogApiController.java

@@ -309,7 +309,7 @@ public class PersonDeviceLogApiController {
 
             CompanyInfo companyInfo = companyInfoService.get(personInfo.getCompanyId());
 
-            List<CompanyInfo> companyList = companyInfoService.findByCompanyCode(companyInfo.getCode() + "%");
+            List<CompanyInfo> companyList = companyInfoService.findByCompanyCode(companyInfo.getCode() + "%",personInfo.getId());
 
             messageResult.setData(companyList);
             messageResult.setResult(true);
@@ -423,9 +423,9 @@ public class PersonDeviceLogApiController {
                 endTime = new DateTime(endTime).plusDays(1).toDate();
             }
 
-            long normalCount = personDeviceFilterLogService.countByTimeRangeAndCompanyCode(companyInfo.getCode() + "%",1,startTime,endTime);
-            long abnormalCount = personDeviceFilterLogService.countByTimeRangeAndCompanyCode(companyInfo.getCode() + "%",-1,startTime,endTime);
-            long undetectedCount = personDeviceFilterLogService.countUndetectedByCompanyCode(companyInfo.getCode() + "%", startTime,endTime);
+            long normalCount = personDeviceFilterLogService.countByTimeRangeAndCompanyCode(companyInfo.getCode() + "%",personInfo.getId(),1,startTime,endTime);
+            long abnormalCount = personDeviceFilterLogService.countByTimeRangeAndCompanyCode(companyInfo.getCode() + "%",personInfo.getId(),-1,startTime,endTime);
+            long undetectedCount = personDeviceFilterLogService.countUndetectedByCompanyCode(companyInfo.getCode() + "%",personInfo.getId(), startTime,endTime);
 
             Map<String,Object> map1 = new HashMap();
 
@@ -490,15 +490,15 @@ public class PersonDeviceLogApiController {
                 endTime = new DateTime(endTime).plusDays(1).toDate();
             }
 
-            long detected = personDeviceFilterLogService.countByTimeRangeAndCompanyCode(companyInfo.getCode() + "%",0,startTime,endTime);
+            long detected = personDeviceFilterLogService.countByTimeRangeAndCompanyCode(companyInfo.getCode() + "%",personInfo.getId(),0,startTime,endTime);
 
             Map map = new HashMap();
             map.put("detected",detected);
 
-            long companyCount = companyInfoService.countByCompanyCode(companyInfo.getCode() + "%");
+            long companyCount = companyInfoService.countByCompanyCode(companyInfo.getCode() + "%",personInfo.getId());
             map.put("companyCount",companyCount);
 
-            long personCount = personInfoService.countByCompanyCode(companyInfo.getCode() + "%");
+            long personCount = personInfoService.countByCompanyCode(companyInfo.getCode() + "%",personInfo.getId());
             map.put("personCount",personCount);
 
             listMap.add(map);
@@ -553,7 +553,7 @@ public class PersonDeviceLogApiController {
                 endTime = new DateTime(endTime).plusDays(1).toDate();
             }
 
-            List<Map<String, Object>> mapList = personDeviceFilterLogService.unusualStatistics(companyInfo.getCode() + "%",standard,startTime,endTime);
+            List<Map<String, Object>> mapList = personDeviceFilterLogService.unusualStatistics(companyInfo.getCode() + "%",personInfo.getId(),standard,startTime,endTime);
             List<Map<String, Object>> list = new ArrayList<>();
 
             int companyTotalCount = 0;
@@ -574,7 +574,7 @@ public class PersonDeviceLogApiController {
                 }
             }
 
-            long undetectedCount = personDeviceFilterLogService.countUndetectedByCompanyCode(companyInfo.getCode() + "%",startTime,endTime);
+            long undetectedCount = personDeviceFilterLogService.countUndetectedByCompanyCode(companyInfo.getCode() + "%",personInfo.getId(),startTime,endTime);
 
             map.put("companyTotalCount",companyTotalCount);
             map.put("personTotalCount",personTotalCount);