4 Комити c1bea5e9ff ... a289b60a02

Аутор SHA1 Порука Датум
  guozhaoshun a289b60a02 fix пре 6 година
  guozhaoshun 5cd503d862 用户标签报表 пре 6 година
  guozhaoshun fa5d2f2cce 用户标签报表 пре 6 година
  guozhaoshun e3f939a710 fix пре 6 година

+ 37 - 0
rankin-cms-web/src/main/java/cn/rankin/cmsweb/controller/stmt/StmtUserTagController.java

@@ -0,0 +1,37 @@
+package cn.rankin.cmsweb.controller.stmt;
+
+import cn.rankin.cmsweb.assist.resolver.NeedUser;
+import cn.rankin.cmsweb.entity.UserDetails;
+import cn.rankin.cmsweb.service.stmt.StmtUserTagService;
+import cn.rankin.common.utils.api.model.APIResult;
+import cn.rankin.common.utils.api.page.Page;
+import cn.rankin.common.utils.util.BeanUtil;
+import cn.rankin.data.api.cms.vo.UserTagStmt;
+import cn.rankin.data.api.user.dto.UserTagSearchDTO;
+import lombok.extern.slf4j.Slf4j;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RequestMethod;
+import org.springframework.web.bind.annotation.RestController;
+
+
+
+@Slf4j
+@RestController
+@RequestMapping(value = "/stmt/userTagStmt")
+public class StmtUserTagController
+{
+    @Autowired
+    private StmtUserTagService stmtService;
+
+    @RequestMapping(value = "/list", method = RequestMethod.GET)
+    public APIResult<Page<UserTagStmt>> search(@NeedUser UserDetails user, UserTagSearchDTO searchDTO) {
+        if (!user.isPlatForm()) {
+            searchDTO.setMerchantId(user.getMerchantId());
+        }
+        return stmtService.UserTagStmtPage(BeanUtil.convertToMap(searchDTO));
+
+    }
+
+
+}

+ 23 - 0
rankin-cms-web/src/main/java/cn/rankin/cmsweb/service/stmt/StmtUserTagService.java

@@ -0,0 +1,23 @@
+package cn.rankin.cmsweb.service.stmt;
+
+import cn.rankin.common.utils.api.model.APIResult;
+import cn.rankin.common.utils.api.page.Page;
+import cn.rankin.data.api.cms.vo.UserTagStmt;
+import org.springframework.cloud.netflix.feign.FeignClient;
+import org.springframework.web.bind.annotation.*;
+
+import java.util.Map;
+
+@FeignClient(value = "${service.user.name}")
+public interface StmtUserTagService {
+
+    /**
+     * 条件查询
+     * 已配置用户标签   终端信息
+     * @param searchDTO
+     * @return
+     */
+    @RequestMapping(value = "/stmt/userTagStmt/list", method = RequestMethod.GET)
+    APIResult<Page<UserTagStmt>> UserTagStmtPage(@RequestParam Map<String,Object> searchDTO);
+
+}

+ 27 - 0
rankin-data-api/src/main/java/cn/rankin/data/api/cms/vo/UserTagStmt.java

@@ -0,0 +1,27 @@
+package cn.rankin.data.api.cms.vo;
+
+import cn.rankin.data.api.user.entity.UserTag;
+import lombok.Data;
+import lombok.ToString;
+
+import javax.persistence.Entity;
+import java.io.Serializable;
+import java.util.List;
+
+@Data
+@ToString
+@Entity
+public class UserTagStmt implements Serializable {
+
+    private String cName;
+
+    private String uid;
+
+    private String uName;
+
+    private String uCode;
+
+    private List<UserTag> userTags;
+
+
+}

+ 2 - 0
rankin-data-api/src/main/java/cn/rankin/data/api/user/dto/TerminalUserSearchDTO.java

@@ -2,10 +2,12 @@ package cn.rankin.data.api.user.dto;
 
 import cn.rankin.common.utils.enums.BaseStatusEnum;
 import lombok.Data;
+import lombok.ToString;
 
 import java.io.Serializable;
 
 @Data
+@ToString
 public class TerminalUserSearchDTO implements Serializable
 {
 

+ 4 - 0
rankin-data-api/src/main/java/cn/rankin/data/api/user/dto/UserTagSearchDTO.java

@@ -9,6 +9,10 @@ import java.io.Serializable;
 @ToString
 public class UserTagSearchDTO implements Serializable {
 
+    private String merchantId;
+
+    private String campusId;
+
     private String name;
 
     private String uid;

+ 88 - 0
rankin-data-api/src/main/java/cn/rankin/data/api/user/entity/LocationInfo.java

@@ -0,0 +1,88 @@
+package cn.rankin.data.api.user.entity;
+
+import cn.rankin.common.utils.enums.BaseStatusEnum;
+import lombok.Data;
+import lombok.ToString;
+import org.hibernate.annotations.DynamicInsert;
+import org.hibernate.annotations.DynamicUpdate;
+
+import javax.persistence.*;
+import java.io.Serializable;
+import java.util.Date;
+
+
+@Data
+@ToString
+@Entity
+@Table(name = "u_location_info")
+@DynamicInsert
+@DynamicUpdate
+public class LocationInfo implements Serializable {
+    @Id
+    @Column(name="id")
+    private String id;
+
+    @Column(name="eid")
+    private String eid;
+
+    @Column(name="simple")
+    private String simple;
+
+    @Column(name="time")
+    private Date time;
+
+    //位置信息
+    @Column(name="lat")
+    private String lat;                 //经纬度
+
+    @Column(name="lng")
+    private String lng;                 //经纬度
+
+    @Column(name="precise")
+    private String precise;             //说明
+
+    @Column(name="address")
+    private String address;             //地址
+
+    //老师信息
+    @Column(name="t_real_name")
+    private String tRealName;
+
+    @Column(name="t_mobile")
+    private String tMobile;
+
+    @Column(name="t_position")
+    private String tPosition;
+
+    @Column(name="t_en_code")
+    private String tEnCode;
+
+    //校区信息
+    @Column(name="campus_name")
+    private String campusName;
+
+    @Column(name="c_en_code")
+    private String cEnCode;
+
+    @Column(name="c_lat")
+    private String cLat;
+
+    @Column(name="c_lng")
+    private String cLng;
+
+    @Enumerated(EnumType.ORDINAL)
+    @Column(name="status")
+    private BaseStatusEnum status;
+
+    @Column(name = "gmt_created", updatable = false, insertable = false, columnDefinition = "timestamp NULL DEFAULT CURRENT_TIMESTAMP")
+    @Temporal(TemporalType.TIMESTAMP)
+    private Date gmtCreated;
+
+    @Column(name = "gmt_modified", updatable = false, insertable = false, columnDefinition = "timestamp NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP")
+    @Temporal(TemporalType.TIMESTAMP)
+    private Date gmtModified;
+
+}
+
+
+

+ 33 - 30
rankin-user-service/src/main/java/cn/rankin/userservice/controller/QRCodeController.java

@@ -44,38 +44,41 @@ public class QRCodeController {
     public APIResult callback(@RequestParam("data") String data)
     {
 
-        Map<String, Object> requestMap = FastJsonUtils.stringToCollect(data);
-
-        boolean status = (boolean) requestMap.get("status");
-        Map<String, Object> dataMap = (Map<String, Object>) requestMap.get("data");
-
-
-        Map<String, Object> qrcodeMap = (Map<String, Object>) dataMap.get("qrcode");
-        String eid = (String) qrcodeMap.get("user");
-        long time = (long) qrcodeMap.get("time");
-
-        QRCode qrcode = new QRCode();
-        qrcode.setEid(eid);
-        //qrcode.setTime(new Date(time));
-
-        QRCode entity = qrcodeService.findFirst(qrcode);
-
-        if(null == entity){
-            log.error("qrcode/callback  error ,qrcode is null");
-            return APIResult.ok("扫码失败,未找到二维码信息");
-        }
-
-        if(status){
-            qrcodeCallback(eid, entity.getSimple(), dataMap);
-            entity.setStatus(2);
-            qrcodeService.update(entity);
-            return APIResult.ok("扫码成功");
-        }else{
-            entity.setStatus(1);
-            qrcodeService.update(entity);
+        try{
+            Map<String, Object> requestMap = FastJsonUtils.stringToCollect(data);
+
+            boolean status = (boolean) requestMap.get("status");
+            Map<String, Object> dataMap = (Map<String, Object>) requestMap.get("data");
+
+
+            Map<String, Object> qrcodeMap = (Map<String, Object>) dataMap.get("qrcode");
+            String eid = (String) qrcodeMap.get("user");
+            long time = (long) qrcodeMap.get("time");
+
+            QRCode qrcode = new QRCode();
+            qrcode.setEid(eid);
+            //qrcode.setTime(new Date(time));
+
+            QRCode entity = qrcodeService.findFirst(qrcode);
+
+            if(null == entity){
+                log.error("qrcode/callback  error ,qrcode is null");
+                return APIResult.ok("扫码失败,未找到二维码信息");
+            }
+
+            if(status){
+                qrcodeCallback(eid, entity.getSimple(), dataMap);
+                entity.setStatus(2);
+                qrcodeService.update(entity);
+                return APIResult.ok("扫码成功");
+            }else{
+                entity.setStatus(1);
+                qrcodeService.update(entity);
+                return APIResult.ok("扫码失败");
+            }
+        }catch(Exception e){
             return APIResult.ok("扫码失败");
         }
-
     }
 
     /**

+ 32 - 0
rankin-user-service/src/main/java/cn/rankin/userservice/controller/StmtUserTagController.java

@@ -0,0 +1,32 @@
+package cn.rankin.userservice.controller;
+
+import cn.rankin.common.utils.api.model.APIResult;
+import cn.rankin.common.utils.api.page.Page;
+import cn.rankin.data.api.cms.vo.UserTagStmt;
+import cn.rankin.data.api.user.dto.UserTagSearchDTO;
+import cn.rankin.userservice.service.StmtService;
+import lombok.extern.slf4j.Slf4j;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RequestMethod;
+import org.springframework.web.bind.annotation.RestController;
+
+
+
+@Slf4j
+@RestController
+@RequestMapping(value = "/stmt/userTagStmt")
+public class StmtUserTagController
+{
+    @Autowired
+    private StmtService stmtService;
+
+    @RequestMapping(value = "/list", method = RequestMethod.GET)
+    public APIResult<Page<UserTagStmt>> UserTagStmtPage(UserTagSearchDTO searchDTO) {
+        return stmtService.userTagStmtPage(searchDTO.getMerchantId(),searchDTO.getCampusId(),searchDTO.getPageSize(),searchDTO.getPageNo());
+    }
+
+
+
+
+}

+ 27 - 0
rankin-user-service/src/main/java/cn/rankin/userservice/repository/StmtRepository.java

@@ -0,0 +1,27 @@
+package cn.rankin.userservice.repository;
+
+import cn.rankin.common.utils.jpa.BasicJpaRepository;
+import cn.rankin.data.api.user.entity.UserTag;
+import org.springframework.data.jpa.repository.Query;
+
+import java.util.List;
+
+public interface StmtRepository extends BasicJpaRepository<UserTag, String> {
+
+    /**
+     * 配置用户标签的终端数量
+     * @param merchantId
+     * @param campusId
+     * @return
+     */
+    @Query(value = "SELECT COUNT(1) FROM u_terminal_user tu " +
+            " WHERE tu.id IN ( SELECT tag.uid FROM u_user_tag tag WHERE tag.status = 0 )" +
+            " AND if(?1 !='',tu.merchant_id=?1,1=1) AND if(?2 !='',tu.campus_id=?2,1=1) ",nativeQuery = true)
+    int userCount(String merchantId, String campusId);
+
+    @Query(value = "SELECT  tu.id  FROM u_terminal_user tu " +
+            " WHERE tu.id IN ( SELECT tag.uid FROM u_user_tag tag WHERE tag.status = 0 ) " +
+            " AND if(?1 !='',tu.merchant_id=?1,1=1) AND if(?2 !='',tu.campus_id=?2,1=1)  " +
+            " ORDER BY tu.gmt_created DESC LIMIT ?3,?4 ",nativeQuery = true)
+    List<String> uidList(String merchantId, String campusId, long start, Integer pageSize);
+}

+ 3 - 0
rankin-user-service/src/main/java/cn/rankin/userservice/repository/UserTagRepository.java

@@ -30,4 +30,7 @@ public interface UserTagRepository extends BasicJpaRepository<UserTag, String> {
 
     @Query(value = "select t from UserTag t where t.uid = ?1  order by t.sort")
     List<UserTag> findUserTagByUid(String uid);
+
+    @Query(value = "select t from UserTag t where t.uid = ?1 and t.status = ?2 order by t.sort")
+    List<UserTag> findUserTagByUidStatus(String uid,BaseStatusEnum status);
 }

+ 78 - 0
rankin-user-service/src/main/java/cn/rankin/userservice/service/StmtService.java

@@ -0,0 +1,78 @@
+package cn.rankin.userservice.service;
+
+import cn.rankin.common.utils.api.model.APIResult;
+import cn.rankin.common.utils.api.page.Page;
+import cn.rankin.common.utils.enums.BaseOrderEnum;
+import cn.rankin.common.utils.enums.BaseStatusEnum;
+import cn.rankin.common.utils.util.JpaSortUtil;
+import cn.rankin.data.api.cms.vo.UserTagStmt;
+import cn.rankin.data.api.user.dto.UserTagDTO;
+import cn.rankin.data.api.user.entity.Campus;
+import cn.rankin.data.api.user.entity.TerminalUser;
+import cn.rankin.data.api.user.entity.UserTag;
+import cn.rankin.userservice.repository.CampusRepository;
+import cn.rankin.userservice.repository.StmtRepository;
+import cn.rankin.userservice.repository.TerminalUserRepository;
+import cn.rankin.userservice.repository.UserTagRepository;
+import lombok.extern.slf4j.Slf4j;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Service;
+import org.springframework.transaction.annotation.Transactional;
+import org.springframework.util.CollectionUtils;
+
+import java.util.ArrayList;
+import java.util.LinkedHashMap;
+import java.util.List;
+
+import static cn.rankin.userservice.utils.DTOConverter.convert;
+
+@Slf4j
+@Service
+public class StmtService {
+
+    @Autowired
+    private StmtRepository stmtRepository;
+
+    @Autowired
+    private TerminalUserRepository terminalUserRepository;
+    @Autowired
+    private CampusRepository campusRepository;
+    @Autowired
+    private UserTagRepository userTagRepository;
+
+
+    public APIResult<Page<UserTagStmt>> userTagStmtPage(String merchantId, String campusId, Integer pageSize, Integer pageNo) {
+
+
+        long count = (long)stmtRepository.userCount(merchantId, campusId);
+
+        Page<UserTagStmt> page = new Page(count, pageNo, pageSize);
+        if (count == 0) {
+            return APIResult.ok(page);
+        }
+
+        List<String> uids = stmtRepository.uidList(merchantId, campusId, page.getStart() , page.getPageSize());
+
+        List<UserTagStmt> data = new ArrayList<>();
+        uids.forEach(uid -> {
+            TerminalUser terminalUser = terminalUserRepository.find(uid);
+            if(null != terminalUser){
+                UserTagStmt stmt = new UserTagStmt();
+                stmt.setUCode(terminalUser.getCode());
+                stmt.setUid(uid);
+                stmt.setUName(terminalUser.getName());
+                Campus campus = campusRepository.find(terminalUser.getCampusId());
+                if(null != campus){
+                    stmt.setCName(campus.getName());
+                }
+
+                stmt.setUserTags(userTagRepository.findUserTagByUidStatus(uid, BaseStatusEnum.NORMAL));
+
+                data.add(stmt);
+            }
+        });
+
+        page.setList(data);
+        return APIResult.ok(page);
+    }
+}