wang-hao-jie
2022-08-25 57dcc73636bb7d8dce89c808eb8cc988a7512264
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
package com.ruoyi.web.controller.api;
 
 
import com.ruoyi.common.utils.IdUtils;
import com.ruoyi.common.utils.StringUtils;
import com.ruoyi.station.domain.MjTeamMember;
import com.ruoyi.station.domain.MjVisitLog;
import com.ruoyi.station.domain.MjWorkUser;
import com.ruoyi.station.service.*;
import org.apache.commons.collections.CollectionUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
 
import java.util.Date;
import java.util.List;
 
@Controller
@RequestMapping("/api/visit")
public class VisitLogController {
 
    @Autowired
    private IMjVisitLogService mjVisitLogService;
    @Autowired
    private IMjWorkUserService mjWorkUserService;
    @Autowired
    private IMjOrderDetailService mjOrderDetailService;
    @Autowired
    private IMjTeamMemberService mjTeamMemberService;
    @Autowired
    private IMjTeamService mjTeamService;
 
    @PostMapping("/addVisitInfo")
    @ResponseBody
    public void addVisitInfo(String ip, Long userId, Integer type) {
        if(type != 1) {
            return;
        }
        if(StringUtils.isEmpty(ip) || userId == null) {
            return;
        }
 
        MjVisitLog mjVisitLog = new MjVisitLog();
        mjVisitLog.setId(IdUtils.getUUIDInOrderId()+"");
        mjVisitLog.setJobNumber(userId.toString());
        mjVisitLog.setIpOrOther(ip);
        mjVisitLog.setCreateTime(new Date());
 
        MjWorkUser mjWorkUser = mjWorkUserService.selectMjWorkUserById(userId);
        if(mjWorkUser != null) {
            mjVisitLog.setUserName(mjWorkUser.getUserName());
            mjVisitLog.setDeptId(mjWorkUser.getDeptId());
            mjVisitLog.setDeptName(mjWorkUser.getDeptName());
            mjVisitLog.setOrganizationId(mjWorkUser.getOrganizationId());
            mjVisitLog.setOrganizationName(mjWorkUser.getOrganizationName());
            mjVisitLog.setExpandStatus(mjWorkUser.getExpandStatus());
            mjVisitLog.setExpandStatus1(mjWorkUser.getExpandStatus1());
        }
 
        MjTeamMember member = new MjTeamMember();
        member.setStatus(1);
        List<MjTeamMember> list = mjTeamMemberService.selectMjTeamMemberList(member);
        if(list != null && list.size() > 0) {
            mjVisitLog.setExpandStatus(1);
        }else {
            MjVisitLog m = mjOrderDetailService.selectOrderInfoByUserId(userId);
            if(m != null) {
                mjVisitLog.setDoorId(m.getDoorId());
                mjVisitLog.setDoorName(m.getDoorName());
                mjVisitLog.setWorkOrderId(m.getWorkOrderId());
                if(StringUtils.isNotEmpty(m.getWorkOrderName())) {
                    mjVisitLog.setWorkOrderName(m.getWorkOrderName());
                }
            }
        }
 
 
        mjVisitLogService.insertMjVisitLog(mjVisitLog);
    }
 
    @GetMapping("goLogQuery")
    public String goLogQuery(Integer type) {
        if(type!=null){
            return "logQuery?type="+type;
        }
        return "logQuery";
    }
 
    @GetMapping("areaUnlock")
    public String areaUnlock() {
        return "areaUnlock";
    }
 
    @GetMapping("searchIP")
    public String searchIP() {
        return "searchIP/searchIP";
    }
 
 
 
}