Browse Source

凌云集团更改公司

peiguo 5 years ago
parent
commit
5abacd24c4

+ 9 - 1
whepi-doc/login.sql

@@ -265,4 +265,12 @@ CREATE TABLE sys_uptown_door  (
   time_create       datetime(0) NOT NULL DEFAULT CURRENT_TIMESTAMP(0) COMMENT '新增时间',
   time_update       datetime(0) NOT NULL DEFAULT CURRENT_TIMESTAMP(0) ON UPDATE CURRENT_TIMESTAMP(0) COMMENT '修改时间',
   PRIMARY KEY (door_id) USING BTREE
-) ENGINE = InnoDB default charset=utf8mb4 comment = '小区大门表';
+) ENGINE = InnoDB default charset=utf8mb4 comment = '小区大门表';
+
+DROP TABLE IF EXISTS return_work_ly;
+CREATE TABLE return_work_ly  (
+  rw_id             bigint(20) NOT NULL DEFAULT 0 COMMENT '主键ID',
+  user_id           bigint(20) NOT NULL DEFAULT 0 COMMENT '人员ID',
+  time_create       datetime(0) NOT NULL DEFAULT CURRENT_TIMESTAMP(0) COMMENT '新增时间',
+  PRIMARY KEY (rw_id) USING BTREE
+) ENGINE = InnoDB default charset=utf8mb4 comment = '凌云复工人员';

+ 18 - 11
whepi-web/src/main/java/com/bofeng/controller/EpiAdminController.java

@@ -6,10 +6,7 @@ import com.bofeng.dao.UserRoleMapper;
 import com.bofeng.entity.UptownHome;
 import com.bofeng.entity.UserOpen;
 import com.bofeng.entity.UserRole;
-import com.bofeng.service.EpiAdminService;
-import com.bofeng.service.EpiTemplateMessageService;
-import com.bofeng.service.MsReportService;
-import com.bofeng.service.TemplateMessageService;
+import com.bofeng.service.*;
 import com.yvan.ModelOps;
 import com.yvan.mvc.Pd;
 import com.yvan.platform.StringUtils;
@@ -20,6 +17,7 @@ import org.springframework.web.bind.annotation.GetMapping;
 import org.springframework.web.bind.annotation.PostMapping;
 import org.springframework.web.bind.annotation.RestController;
 
+import java.text.ParseException;
 import java.util.List;
 
 @RestController
@@ -38,10 +36,12 @@ public class EpiAdminController {
 
     @Autowired
     private MsReportService msReportService;
+    @Autowired
+    private ScanService scanService;
 
     @ApiOperation("升级业委会角色")
     @PostMapping("/whepi/epi/admin/addRole")
-    public ModelOps adminAddRole(@Pd(name = "we", desc = "手机号码") String we){
+    public ModelOps adminAddRole(@Pd(name = "we", desc = "手机号码") String we) {
         if (!StringUtils.isNullOrEmpty(we)) {
             List<UptownHome> list = uptownHomeMapper.getUptownHomeByPhone(we);
             if (list.size() != 1) {
@@ -58,7 +58,7 @@ public class EpiAdminController {
         return null;
     }
 
-//    @Scheduled(cron = "0 44 12 * * ?") //每天19点执行一次
+    //    @Scheduled(cron = "0 44 12 * * ?") //每天19点执行一次
     @Scheduled(cron = "0 0 11 * * ?") //每天19点执行一次
     public void scheduledTaskByFixedDelay() {
         System.out.println("==============执行定时任务开始================");
@@ -69,9 +69,9 @@ public class EpiAdminController {
             for (UserOpen userOpen : userOpens) {
                 re += epiTemplateMessageService.systemSendRemindMessage(userOpen.getUserId(), userOpen.getOpenId());
             }
-            System.out.println("==============执行定时任务"+re+"================");
+            System.out.println("==============执行定时任务" + re + "================");
             start += count;
-            if (userOpens == null || userOpens.size()<count) {
+            if (userOpens == null || userOpens.size() < count) {
                 break;
             }
         }
@@ -89,9 +89,9 @@ public class EpiAdminController {
             for (UserOpen userOpen : userOpens) {
                 re += epiTemplateMessageService.systemSendRemindMessage(userOpen.getUserId(), userOpen.getOpenId());
             }
-            System.out.println("==============执行定时任务"+re+"================");
+            System.out.println("==============执行定时任务" + re + "================");
             start += count;
-            if (userOpens == null || userOpens.size()<count) {
+            if (userOpens == null || userOpens.size() < count) {
                 break;
             }
         }
@@ -99,7 +99,14 @@ public class EpiAdminController {
         System.out.println("==============执行定时任务完毕================");
     }
 
-//    @Scheduled(cron = "0 0 0 * * ?") //每天0点执行一次
+    @Scheduled(cron = "0 25 22 * * ?")
+    public void returnWorkTaskByFixedDelay() {
+        System.out.println("==============执行定时任务开始================");
+        scanService.returnWorkLY();
+        System.out.println("==============执行定时任务完毕================");
+    }
+
+    //    @Scheduled(cron = "0 0 0 * * ?") //每天0点执行一次
     public void scheduledReportByFixedDelay() {
         System.out.println("==============执行定时任务开始================");
         msReportService.getNowByYesterdayDate();

+ 19 - 0
whepi-web/src/main/java/com/bofeng/dao/ReturnWorkLyMapper.java

@@ -0,0 +1,19 @@
+package com.bofeng.dao;
+
+import com.baomidou.mybatisplus.mapper.BaseMapper;
+import com.bofeng.entity.ReturnWorkLy;
+import com.yvan.PageDb;
+import org.apache.ibatis.annotations.Mapper;
+import org.springframework.stereotype.Repository;
+
+import java.util.List;
+import java.util.Map;
+
+@Mapper
+@Repository
+public interface ReturnWorkLyMapper extends BaseMapper<ReturnWorkLy> {
+
+    List<ReturnWorkLy> getAllUser(PageDb pageDb, Map<String, Object> queryParam);
+
+    int deleteReturnWork();
+}

+ 30 - 0
whepi-web/src/main/java/com/bofeng/entity/ReturnWorkLy.java

@@ -0,0 +1,30 @@
+package com.bofeng.entity;
+
+import com.baomidou.mybatisplus.annotations.TableField;
+import com.baomidou.mybatisplus.annotations.TableId;
+import com.baomidou.mybatisplus.annotations.TableName;
+import io.swagger.annotations.ApiModelProperty;
+import lombok.Getter;
+import lombok.Setter;
+import org.joda.time.DateTime;
+
+import java.util.Date;
+
+/**
+ * 用户外出扫码信息
+ */
+@Getter
+@Setter
+@TableName("return_work_ly")
+public class ReturnWorkLy {
+
+    @TableId("rw_id")
+    private Long rwId;
+
+    @ApiModelProperty("用户ID")
+    @TableField("user_id")
+    private Long userId;
+
+    @TableField(exist = false)
+    private DateTime timeCreate;
+}

+ 115 - 4
whepi-web/src/main/java/com/bofeng/service/ScanService.java

@@ -1,20 +1,23 @@
 package com.bofeng.service;
 
 import com.baomidou.mybatisplus.toolkit.IdWorker;
-import com.bofeng.dao.OutScanEstateMapper;
-import com.bofeng.dao.OutScanMapper;
-import com.bofeng.entity.OutScan;
-import com.bofeng.entity.OutScanEstate;
+import com.bofeng.dao.*;
+import com.bofeng.entity.*;
+import lombok.SneakyThrows;
 import org.gavaghan.geodesy.Ellipsoid;
 import org.gavaghan.geodesy.GeodeticCalculator;
 import org.gavaghan.geodesy.GlobalCoordinates;
 import org.joda.time.DateTime;
 import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.scheduling.annotation.Async;
 import org.springframework.stereotype.Service;
 import org.springframework.transaction.annotation.Propagation;
 import org.springframework.transaction.annotation.Transactional;
 
+import java.text.ParseException;
+import java.text.SimpleDateFormat;
 import java.util.Date;
+import java.util.List;
 
 @Service
 @Transactional(readOnly = true)
@@ -24,6 +27,14 @@ public class ScanService {
     private OutScanMapper outScanMapper;
     @Autowired
     private OutScanEstateMapper outScanEstateMapper;
+    @Autowired
+    private UserOpenMapper userOpenMapper;
+    @Autowired
+    private OutUserMapper outUserMapper;
+    @Autowired
+    private MsReportMapper msReportMapper;
+    @Autowired
+    private ReturnWorkLyMapper returnWorkLyMapper;
 
     @Transactional(rollbackFor = Exception.class, propagation = Propagation.REQUIRED)
     public void saveOutScan(Long userId, Integer inType, String coord, String address, Long uptownId, Long doorId, Integer status, String errorInfo) {
@@ -68,6 +79,7 @@ public class ScanService {
 
     /**
      * 根据经纬度查询距离
+     *
      * @param longitudeFrom
      * @param latitudeFrom
      * @param longitudeTo
@@ -79,4 +91,103 @@ public class ScanService {
         GlobalCoordinates target = new GlobalCoordinates(latitudeTo, longitudeTo);
         return new GeodeticCalculator().calculateGeodeticCurve(Ellipsoid.Sphere, source, target).getEllipsoidalDistance();
     }
+
+    //    @Async
+    @Transactional(rollbackFor = Exception.class, propagation = Propagation.REQUIRED)
+    public void returnWorkLY() {
+        new Runnable() {
+            @SneakyThrows
+            @Override
+            public void run() {
+                returnWorkLyMapper.deleteReturnWork();
+                SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
+                SimpleDateFormat s = new SimpleDateFormat("yyyy-MM-dd");
+                List<UserOpen> opens = userOpenMapper.getUsersByUptownId(1238790987234L);
+                ReturnWorkLy r = new ReturnWorkLy();
+                for (int i = 0; i < opens.size(); i++) {
+                    OutUser outUser1 = outUserMapper.getOutUserByPhone(4, opens.get(i).getLinkman(), Long.parseLong(opens.get(i).getPhone()));
+                    if (outUser1 != null) {
+                        continue;
+                    }
+                    OutUser outUser = outUserMapper.getOutUserByPhone(1, opens.get(i).getLinkman(), Long.parseLong(opens.get(i).getPhone()));
+                    if (outUser != null) {
+                        r.setRwId(IdWorker.getId());
+                        r.setUserId(opens.get(i).getUserId());
+                        r.setTimeCreate(new DateTime());
+                        returnWorkLyMapper.insert(r);
+                        continue;
+                    }
+                    Boolean ly2 = false;
+                    String startDate = "";
+                    int intSize = 4;
+                    OutUser outUser2 = outUserMapper.getOutUserByPhoneNotTime(5, opens.get(i).getLinkman(), Long.parseLong(opens.get(i).getPhone()));
+                    if (outUser2 != null) {
+                        ly2 = true;
+                        startDate = s.format(outUser2.getStartDate());
+                        Long day = (new Date().getTime() - outUser2.getStartDate().getTime()) / (1000 * 60 * 60 * 24);
+                        intSize = Integer.parseInt(Long.toString(day)) < 4 ? Integer.parseInt(Long.toString(day)) : 4;
+                    }
+                    MsReport msReport = msReportMapper.queryMsReportIsXG(opens.get(i).getUserId());
+                    if (msReport != null) {
+                        if (ly2 && outUser2.getStartDate().getTime() < msReport.getReportDate().getTime()) {
+                            continue;
+                        } else if (!ly2) {
+                            continue;
+                        }
+                    }
+                    List<MsReport> msReportList = msReportMapper.queryMsReportIsXGHome(opens.get(i).getUserId());
+                    if (msReportList.size() > 0) {
+                        if (ly2 && outUser2.getStartDate().getTime() < msReportList.get(0).getReportDate().getTime()) {
+                            continue;
+                        } else if (!ly2) {
+                            continue;
+                        }
+                    }
+                    List<MsReport> msReports = msReportMapper.selectMsReportLate(opens.get(i).getUserId(), startDate);
+                    if (msReports.size() < intSize) {
+                        continue;
+                    }
+                    List<MsReport> msReports2 = msReportMapper.selectMsReportThereError(opens.get(i).getUserId(), startDate);
+                    if (msReports2.size() > 0) {
+                        continue;
+                    }
+                    List<MsReport> msReports3 = msReportMapper.selectMsReportThereErrorFamily(opens.get(i).getUserId(), startDate);
+                    if (msReports3.size() > 0) {
+                        continue;
+                    }
+                    MsTripDet work = msReportMapper.returnWork(opens.get(i).getUserId());
+                    if (work != null) {
+                        if (ly2 && outUser2.getStartDate().getTime() < s.parse(work.getReturnWork()).getTime()) {
+                            if (sdf.parse(work.getReturnWork() + " 00:00:00").getTime() + 1000L * 3600 * 24 * 15 > sdf.parse(s.format(new Date()) + " 00:00:00").getTime()) {
+                                continue;
+                            }
+                        } else if (!ly2) {
+                            if (sdf.parse(work.getReturnWork() + " 00:00:00").getTime() + 1000L * 3600 * 24 * 15 > sdf.parse(s.format(new Date()) + " 00:00:00").getTime()) {
+                                continue;
+                            }
+                        }
+                    }
+                    MsReport msReport1 = msReportMapper.msAddr(opens.get(i).getUserId());
+                    if (msReport1 != null && !msReport1.getWorkMsg().equals(msReport1.getTodayMsg()) && !compareWhere(msReport1.getWorkMsg(), msReport1.getTodayMsg())) {
+                        continue;
+                    }
+                    r.setRwId(IdWorker.getId());
+                    r.setUserId(opens.get(i).getUserId());
+                    r.setTimeCreate(new DateTime());
+                    returnWorkLyMapper.insert(r);
+                }
+            }
+        }.run();
+    }
+
+    /**
+     * 比较出发地和目地地是否一样, 一样返回true,不一样返回false
+     */
+    public Boolean compareWhere(String str1, String str2) {
+        Boolean type = false;
+        if ((str1.equals("2") || str1.equals("3")) && (str2.equals("2") || str2.equals("3"))) {
+            type = true;
+        }
+        return type;
+    }
 }

+ 9 - 0
whepi-web/src/main/java/com/bofeng/wx/controller/ScanAdminController.java

@@ -8,6 +8,7 @@ import com.bofeng.entity.*;
 import com.bofeng.excel.ExcelUtils;
 import com.bofeng.service.MsReportService;
 import com.bofeng.service.ScanAdminService;
+import com.bofeng.service.ScanService;
 import com.bofeng.service.SweepCodeService;
 import com.bofeng.unit.QRCode;
 import com.google.zxing.BarcodeFormat;
@@ -71,6 +72,8 @@ public class ScanAdminController {
     private RbMapper rbMapper;
     @Autowired
     private MsReportService msReportService;
+    @Autowired
+    private ScanService scanService;
 
     @ApiOperation("出入查询")
     @PostMapping("/whepi/sweepCode/selectCode")
@@ -424,6 +427,12 @@ public class ScanAdminController {
         return Model.newSuccess(pagination, uptownMapper.getUptowns(pagination, parser.getMap()));
     }
 
+    @ApiOperation("获取小区大门详细")
+    @GetMapping("/whepi/returnWork/returnWork")
+    public void returnWork(HttpParameterParser parser) throws ParseException {
+        scanService.returnWorkLY();
+    }
+
     // 获取code
     private static final String oauth2 = "https://open.weixin.qq.com/connect/oauth2/authorize?appid=";
     private static final String moreUrl = "&response_type=code&scope=snsapi_userinfo&state=STATE#wechat_redirect";

+ 28 - 0
whepi-web/src/main/resources/mapper/ReturnWorkLyMapper.xml

@@ -0,0 +1,28 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
+<mapper namespace="com.bofeng.dao.ReturnWorkLyMapper">
+
+    <select id="getAllUser" resultType="com.bofeng.entity.ReturnWorkLy">
+        select u.rw_id,u.user_id as userId,su.uptown_name as uptownName,CONCAT(uu.ridgepole,uu.unit) as unit,uh.linkman,uh.phone,suh.doorplate
+        from return_work_ly u
+        left join sys_user_role ur on ur.user_id = u.user_id and ur.role_id = 1
+        left join sys_uptown_home uh on uh.house_id = ur.property_id
+        left join sys_uptown_house suh on suh.house_id = ur.property_id
+        left join sys_uptown_unit uu on uu.unit_id = suh.unit_id
+        left join sys_uptown su on su.uptown_id = uu.uptown_id
+        <where>
+            <if test="queryProperties != null and queryProperties != ''">
+                (uh.phone = #{phone} or uh.linkman like concat('%',#{queryProperties},'%'))
+            </if>
+            <if test="unitId != null and unitId !=''">
+                and uu.unit_id = #{unitId}
+            </if>
+        </where>
+        order by u.user_id desc
+    </select>
+
+    <delete id="deleteReturnWork">
+        delete from return_work_ly
+    </delete>
+
+</mapper>

+ 2 - 1
whepi-web/src/main/resources/mapper/UserOpen.xml

@@ -21,9 +21,10 @@
     </select>
 
     <select id="getUsersByUptownId" resultType="com.bofeng.entity.UserOpen">
-        select uo.*,uu.unit,uu.uptown_id from sys_user_open uo
+        select uo.*,uu.unit,uu.uptown_id,uh2.linkman,uh2.phone from sys_user_open uo
           inner join sys_user_role ur on ur.user_id = uo.user_id and ur.role_id = 1
           inner join sys_uptown_house uh on uh.house_id = ur.property_id
+          inner join sys_uptown_home uh2 on uh2.house_id = ur.property_id
           inner join sys_uptown_unit uu on uu.unit_id = uh.unit_id
           inner join sys_uptown u on u.uptown_id = uu.uptown_id
         where u.uptown_id = #{uptownId}