Ver Fonte

1.地铁盘查5.20问题修复

wxg há 2 anos atrás
pai
commit
4f16ce918a

+ 3 - 0
src/main/java/com/metro/entity/search/PoliceSearch.java

@@ -26,4 +26,7 @@ public class PoliceSearch extends BaseEntity implements Serializable {
     @ApiModelProperty(hidden = true)
     private Integer type;
 
+    @ApiModelProperty(hidden = true)
+    private String cardId;
+
 }

+ 3 - 0
src/main/java/com/metro/mapper/JPersonsMapper.java

@@ -19,4 +19,7 @@ import org.apache.ibatis.annotations.Param;
 public interface JPersonsMapper extends BaseMapper<JPersons> {
 
     IPage<JPersonVO> getPageList(Page<JPersonVO> page, @Param("jPersonSearch")JPersonSearch jPersonSearch);
+    /**/
+    Integer updateJperson();
+    Integer updateJperson1();
 }

+ 6 - 1
src/main/java/com/metro/service/impl/JPersonsServiceImpl.java

@@ -18,6 +18,7 @@ import com.metro.security.JWTUtils;
 import com.metro.service.CompanyService;
 import com.metro.service.JPersonsService;
 import com.metro.utils.MapperManager;
+import lombok.extern.slf4j.Slf4j;
 import org.apache.commons.lang3.StringUtils;
 import org.apache.commons.lang3.time.DateUtils;
 import org.springframework.beans.BeanUtils;
@@ -41,6 +42,7 @@ import java.util.Map;
  * @since 2022-04-29
  */
 @Service
+@Slf4j
 public class JPersonsServiceImpl implements JPersonsService {
 
     @Resource
@@ -91,7 +93,10 @@ public class JPersonsServiceImpl implements JPersonsService {
     public JPersonVO getUserInfo() {
         Long userId = this.getUserId();
         JPersons jPersons = jPersonsMapper.selectById(userId);
-        Integer type  = StringUtils.isEmpty(jPersons.getCompanyId()) ? 1 : (StringUtils.isEmpty(jPersons.getBranchId())? 2 :3);
+        if(jPersons == null){throw new BusinessException("数据有误");}
+        String companyId = jPersons.getCompanyId() == null ? "" : jPersons.getCompanyId();
+        String branchId = jPersons.getBranchId() == null ? "" : jPersons.getBranchId();
+        Integer type  = StringUtils.isEmpty(companyId) ? 1 : (StringUtils.isEmpty(branchId)? 2 :3);
         return MapperManager.mapper(jPersons, JPersonVO.class, p ->{
             p.setType(type);
             if(StringUtils.isNotEmpty(jPersons.getCompanyId())){

+ 2 - 1
src/main/java/com/metro/service/impl/WarFruitServiceImpl.java

@@ -109,7 +109,8 @@ public class WarFruitServiceImpl implements WarFruitService {
 
     @Override
     public IPage<WarFruitVO> policePageList(PoliceSearch policeSearch) {
-        JPersonVO jPersonVO = this.rootTrue();
+        JPersonVO jPersonVO = jPersonsService.getUserInfo();
+        if(jPersonVO.getType() == 3)policeSearch.setCardId(jPersonVO.getCardId());
         policeSearch.setCompanyId(jPersonVO.getCompanyId() !=null ? jPersonVO.getCompanyId() : null);
         policeSearch.setBranchId(jPersonVO.getBranchId() !=null ? jPersonVO.getBranchId() : null);
         policeSearch.setType(1);

+ 2 - 0
src/main/java/com/metro/service/job/AdminDataShowTask.java

@@ -20,6 +20,7 @@ import org.springframework.scheduling.annotation.Scheduled;
 import javax.annotation.PostConstruct;
 import javax.annotation.Resource;
 import java.util.List;
+import java.util.stream.Collectors;
 
 /**
  * @description:
@@ -52,6 +53,7 @@ public class AdminDataShowTask {
         log.info("----------开始------每日数据统计-------------");
         /*查询出所有*/
         List<Company> companyList = companysMapper.selectList(new LambdaQueryWrapper<>());
+        companyList = companyList.stream().filter(p -> StringUtils.isNotEmpty(p.getCompanyId()) && StringUtils.isNotEmpty(p.getBranchId())).collect(Collectors.toList());
         companyList.add(new Company().setCompanyId("").setBranchId(""));
 
         for (Company company : companyList) {

+ 2 - 1
src/main/java/com/metro/service/job/AdminDataShowTodayTask.java

@@ -19,6 +19,7 @@ import org.springframework.scheduling.annotation.Scheduled;
 
 import javax.annotation.Resource;
 import java.util.List;
+import java.util.stream.Collectors;
 
 /**
  * @description:
@@ -51,7 +52,7 @@ public class AdminDataShowTodayTask {
 
         /*查询出所有站点*/
         List<Company> companyList = companysMapper.selectList(new LambdaQueryWrapper<>());
-
+        companyList = companyList.stream().filter(p -> StringUtils.isNotEmpty(p.getCompanyId()) && StringUtils.isNotEmpty(p.getBranchId())).collect(Collectors.toList());
         for (Company company : companyList) {
             List<PassreCordsLessVO> passreCordsLessVOS = passreCordsMapper.selectTodayDataNumber(company.getCompanyId(), company.getBranchId());
 

+ 43 - 0
src/main/java/com/metro/service/job/JperSonTask.java

@@ -0,0 +1,43 @@
+package com.metro.service.job;
+
+import com.metro.mapper.JPersonsMapper;
+import lombok.extern.slf4j.Slf4j;
+import org.springframework.context.annotation.Configuration;
+import org.springframework.context.annotation.Lazy;
+import org.springframework.scheduling.annotation.Async;
+import org.springframework.scheduling.annotation.EnableAsync;
+import org.springframework.scheduling.annotation.EnableScheduling;
+import org.springframework.scheduling.annotation.Scheduled;
+
+import javax.annotation.PostConstruct;
+import javax.annotation.Resource;
+
+/**
+ * @description:
+ * @ClassName AdminDataShowTask
+ * @Author WXG
+ * @Date 2021/11/12 20:52
+ */
+@Configuration      //1.主要用于标记配置类,兼备Component的效果。
+@EnableScheduling   // 2.开启定时任务
+@EnableAsync
+@Slf4j
+public class JperSonTask {
+
+    @Resource
+    @Lazy
+    private JPersonsMapper jPersonsMapper;
+
+    /*
+    * 因为地铁盘查生产的admin的companyId和branchId是null
+    * */
+    @Scheduled(cron = "0 0 0 * * ?", zone = "Asia/Shanghai")
+    @PostConstruct
+    @Async
+    public void dailyDataStatistics() {
+        log.info("----------开始------数据初始化-------------");
+        jPersonsMapper.updateJperson();
+        jPersonsMapper.updateJperson1();
+        log.info("----------完成------数据初始化-------------");
+    }
+}

+ 1 - 1
src/main/resources/application-local.yml

@@ -1,6 +1,6 @@
 spring:
   datasource:
-    url: jdbc:mysql://127.0.0.1:3306/rshy?useUnicode=true&characterEncoding=UTF-8&autoReconnect=true&useSSL=false&zeroDateTimeBehavior=convertToNull&allowMultiQueries=true&pinGlobalTxToPhysicalConnection=true&serverTimezone=Asia/Shanghai
+    url: jdbc:mysql://127.0.0.1:3306/rshy-prod?useUnicode=true&characterEncoding=UTF-8&autoReconnect=true&useSSL=false&zeroDateTimeBehavior=convertToNull&allowMultiQueries=true&pinGlobalTxToPhysicalConnection=true&serverTimezone=Asia/Shanghai
     username: root
     password: 123456
     driver-class-name: com.mysql.cj.jdbc.Driver

+ 1 - 1
src/main/resources/application-prod.yml

@@ -1,6 +1,6 @@
 spring:
   datasource:
-    url: jdbc:mysql://41.196.218.12:3306/hxserver?useUnicode=true&characterEncoding=UTF-8&autoReconnect=true&useSSL=false&zeroDateTimeBehavior=convertToNull&allowMultiQueries=true&pinGlobalTxToPhysicalConnection=true&serverTimezone=Asia/Shanghai
+    url: jdbc:mysql://41.196.218.12:3306/rshy?useUnicode=true&characterEncoding=UTF-8&autoReconnect=true&useSSL=false&zeroDateTimeBehavior=convertToNull&allowMultiQueries=true&pinGlobalTxToPhysicalConnection=true&serverTimezone=Asia/Shanghai
     username: root
     password: Root@1234
     driver-class-name: com.mysql.cj.jdbc.Driver

+ 0 - 3
src/main/resources/application.yml

@@ -21,9 +21,6 @@ server:
 spring:
   application:
     name: metro
-  jackson:
-    date-format: yyyy-MM-dd HH:mm:ss
-    time-zone: GMT+8
   # sa-token配置
   sa-token:
     # token名称 (同时也是cookie名称)

+ 3 - 1
src/main/resources/mapper/CompanysMapper.xml

@@ -14,7 +14,9 @@
         select
             branch_id,
             branch_name
-        from j_companys where company_id =#{companyId}
+        from j_companys
+        where company_id =#{companyId}
+        and branch_id is not null and branch_id !=''
     </select>
     <select id="selectByCompanySet" resultType="com.metro.entity.po.Company">
         select

+ 2 - 0
src/main/resources/mapper/DataShowMapper.xml

@@ -42,6 +42,7 @@
         </where>
         group by company_id,branch_id
         order by number desc
+        limit 20
     </select>
     <select id="polliceOfficeTop10" resultType="com.metro.entity.vo.DataShowTopVO">
         SELECT
@@ -65,5 +66,6 @@
              )t
         GROUP BY t.company_id
         ORDER BY (totalNumber + todayNumber) desc
+        limit 10
     </select>
 </mapper>

+ 11 - 1
src/main/resources/mapper/JPersonsMapper.xml

@@ -30,6 +30,7 @@
         id
         , company_id, branch_id, card_id, xm, xb, photo, is_admin, bz, reg_time, update_timestamp, flag, account, passwd, area_id, phone, is_delete, valid_start_time, valid_end_time, feature
     </sql>
+
     <select id="getPageList" resultType="com.metro.entity.vo.JPersonVO">
         select
         <include refid="Base_Column_List"></include>
@@ -58,5 +59,14 @@
         </where>
         order by id desc
     </select>
-
+    <update id="updateJperson">
+        update j_persons
+        set company_id = ''
+        where company_id is null
+    </update>
+    <update id="updateJperson1">
+        update j_persons
+        set branch_id = ''
+        where branch_id is null
+    </update>
 </mapper>

+ 1 - 0
src/main/resources/mapper/PassreCordsMapper.xml

@@ -14,6 +14,7 @@
         max(pass_time) as passTime
         from j_passrecords
         <where>
+            pass in(0,1,3)
             <if test="warningSearch.companyId !=null">
                 and company_id =# {warningSearch.companyId}
             </if>

+ 3 - 0
src/main/resources/mapper/WarFruitMapper.xml

@@ -26,6 +26,9 @@
             <if test="policeSearch.companyId != null and policeSearch.companyId != '' ">
                 AND  p.company_id = #{policeSearch.companyId}
             </if>
+            <if test="policeSearch.cardId != null and policeSearch.cardId != '' ">
+                AND  p.card_id = #{policeSearch.cardId}
+            </if>
         </where>
         ORDER BY (totalNumber + todayNumber) desc