张延森 3 anni fa
parent
commit
0c55db6135
44 ha cambiato i file con 558 aggiunte e 178 eliminazioni
  1. 23
    2
      src/main/java/com/yunzhi/nanyang/common/BaseController.java
  2. 11
    11
      src/main/java/com/yunzhi/nanyang/config/AliyunConfig.java
  3. 87
    0
      src/main/java/com/yunzhi/nanyang/controller/MobileController.java
  4. 63
    0
      src/main/java/com/yunzhi/nanyang/controller/StatisController.java
  5. 4
    7
      src/main/java/com/yunzhi/nanyang/controller/SysUserController.java
  6. 17
    4
      src/main/java/com/yunzhi/nanyang/controller/TaAccountLogController.java
  7. 6
    27
      src/main/java/com/yunzhi/nanyang/controller/TaDispatchController.java
  8. 4
    21
      src/main/java/com/yunzhi/nanyang/controller/TaMachineryController.java
  9. 1
    6
      src/main/java/com/yunzhi/nanyang/controller/TaOrderController.java
  10. 64
    25
      src/main/java/com/yunzhi/nanyang/controller/TaPersonController.java
  11. 2
    8
      src/main/java/com/yunzhi/nanyang/controller/TaUserMachineryController.java
  12. 8
    31
      src/main/java/com/yunzhi/nanyang/controller/TaWithdrawalController.java
  13. 2
    8
      src/main/java/com/yunzhi/nanyang/controller/TaWorkJobController.java
  14. 4
    3
      src/main/java/com/yunzhi/nanyang/controller/WxMaController.java
  15. 3
    0
      src/main/java/com/yunzhi/nanyang/entity/TaPerson.java
  16. 10
    1
      src/main/java/com/yunzhi/nanyang/mapper/TaAccountLogMapper.java
  17. 5
    0
      src/main/java/com/yunzhi/nanyang/mapper/TaMachineryMapper.java
  18. 9
    0
      src/main/java/com/yunzhi/nanyang/mapper/TaOrderMapper.java
  19. 5
    0
      src/main/java/com/yunzhi/nanyang/mapper/TaOrgMapper.java
  20. 7
    0
      src/main/java/com/yunzhi/nanyang/mapper/TaPersonMapper.java
  21. 3
    1
      src/main/java/com/yunzhi/nanyang/mapper/TaWithdrawalMapper.java
  22. 1
    0
      src/main/java/com/yunzhi/nanyang/service/ISysUserService.java
  23. 3
    2
      src/main/java/com/yunzhi/nanyang/service/ITaAccountLogService.java
  24. 3
    0
      src/main/java/com/yunzhi/nanyang/service/ITaDispatchService.java
  25. 3
    0
      src/main/java/com/yunzhi/nanyang/service/ITaMachineryService.java
  26. 3
    0
      src/main/java/com/yunzhi/nanyang/service/ITaOrderService.java
  27. 3
    0
      src/main/java/com/yunzhi/nanyang/service/ITaOrgService.java
  28. 5
    0
      src/main/java/com/yunzhi/nanyang/service/ITaPersonService.java
  29. 3
    2
      src/main/java/com/yunzhi/nanyang/service/ITaWithdrawalService.java
  30. 4
    3
      src/main/java/com/yunzhi/nanyang/service/impl/TaAccountLogServiceImpl.java
  31. 46
    0
      src/main/java/com/yunzhi/nanyang/service/impl/TaDispatchServiceImpl.java
  32. 6
    0
      src/main/java/com/yunzhi/nanyang/service/impl/TaMachineryServiceImpl.java
  33. 5
    0
      src/main/java/com/yunzhi/nanyang/service/impl/TaMessageServiceImpl.java
  34. 6
    0
      src/main/java/com/yunzhi/nanyang/service/impl/TaOrderServiceImpl.java
  35. 6
    0
      src/main/java/com/yunzhi/nanyang/service/impl/TaOrgServiceImpl.java
  36. 11
    0
      src/main/java/com/yunzhi/nanyang/service/impl/TaPersonServiceImpl.java
  37. 58
    3
      src/main/java/com/yunzhi/nanyang/service/impl/TaWithdrawalServiceImpl.java
  38. 2
    2
      src/main/java/com/yunzhi/nanyang/shiro/filters/JWTFilter.java
  39. 0
    1
      src/main/java/com/yunzhi/nanyang/shiro/filters/MiniappFilter.java
  40. 2
    2
      src/main/java/com/yunzhi/nanyang/shiro/utils/JWTUtil.java
  41. 16
    0
      src/main/java/com/yunzhi/nanyang/vo/ChartParam.java
  42. 8
    8
      src/main/resources/application.yml
  43. 20
    0
      src/main/resources/mapper/TaAccountLogMapper.xml
  44. 6
    0
      src/main/resources/mapper/TaWithdrawalMapper.xml

+ 23
- 2
src/main/java/com/yunzhi/nanyang/common/BaseController.java Vedi File

66
         return taPerson;
66
         return taPerson;
67
     }
67
     }
68
 
68
 
69
-    public boolean checkOrgAccess(String orgId, String userId) {
70
-        return iSysUserDataScopeService.checkOrgAccess(orgId, userId);
69
+    public void checkOrgAccess(String orgId) throws Exception {
70
+        SysUser user = currentUser();
71
+
72
+        // 如果是管理员
73
+        if (Constants.ADMIN_ID.equals(user.getUserId())) return;
74
+
75
+        // 空机构
76
+        if (StringUtils.isEmpty(orgId)) return;
77
+
78
+        boolean canAccess = iSysUserDataScopeService.checkOrgAccess(orgId, user.getUserId());
79
+        if (!canAccess) {
80
+            throw new Exception("暂无机构数据权限");
81
+        }
71
     }
82
     }
72
 
83
 
73
     public SysUser checkWorker(TaPerson taPerson) throws Exception {
84
     public SysUser checkWorker(TaPerson taPerson) throws Exception {
83
         return sysUser;
94
         return sysUser;
84
     }
95
     }
85
 
96
 
97
+    public void checkMClient(String client) throws Exception {
98
+        if (StringUtils.isEmpty(client)) {
99
+            throw new Exception("暂不支持的客户端");
100
+        }
101
+
102
+        if (!"android".equals(client) && !"ios".equals(client)) {
103
+            throw new Exception("暂不支持的客户端");
104
+        }
105
+    }
106
+
86
     public List<String> getAccessOrgs(String userId) {
107
     public List<String> getAccessOrgs(String userId) {
87
         return iSysUserDataScopeService.getAccessOrgs(userId);
108
         return iSysUserDataScopeService.getAccessOrgs(userId);
88
     }
109
     }

+ 11
- 11
src/main/java/com/yunzhi/nanyang/config/AliyunConfig.java Vedi File

13
 
13
 
14
     private Oss oss;
14
     private Oss oss;
15
 
15
 
16
-    private Sms sms;
16
+//    private Sms sms;
17
 
17
 
18
     @Data
18
     @Data
19
     public  static class Oss {
19
     public  static class Oss {
27
         private String bucketURL;
27
         private String bucketURL;
28
     }
28
     }
29
 
29
 
30
-    @Data
31
-    public static class Sms {
32
-        private Captcha captcha;
33
-    }
34
-
35
-    @Data
36
-    public static class Captcha {
37
-        private String code;
38
-        private String sign;
39
-    }
30
+//    @Data
31
+//    public static class Sms {
32
+//        private Captcha captcha;
33
+//    }
34
+//
35
+//    @Data
36
+//    public static class Captcha {
37
+//        private String code;
38
+//        private String sign;
39
+//    }
40
 }
40
 }

+ 87
- 0
src/main/java/com/yunzhi/nanyang/controller/MobileController.java Vedi File

1
+package com.yunzhi.nanyang.controller;
2
+
3
+import com.yunzhi.nanyang.common.*;
4
+import com.yunzhi.nanyang.entity.SysUser;
5
+import com.yunzhi.nanyang.entity.TaPerson;
6
+import com.yunzhi.nanyang.service.ISysUserService;
7
+import com.yunzhi.nanyang.service.ITaPersonService;
8
+import com.yunzhi.nanyang.shiro.utils.JWTUtil;
9
+import com.yunzhi.nanyang.vo.LoginParam;
10
+import io.swagger.annotations.Api;
11
+import io.swagger.annotations.ApiOperation;
12
+import io.swagger.annotations.ApiParam;
13
+import org.springframework.beans.factory.annotation.Autowired;
14
+import org.springframework.web.bind.annotation.*;
15
+
16
+import java.time.LocalDateTime;
17
+import java.util.HashMap;
18
+import java.util.Map;
19
+
20
+
21
+@Api(tags = "手机端登入/登出")
22
+@RestController
23
+@RequestMapping("/{client}/{clientId}")
24
+public class MobileController extends BaseController {
25
+
26
+    @Autowired
27
+    public ITaPersonService iTaPersonService;
28
+
29
+    @Autowired
30
+    public ISysUserService iSysUserService;
31
+
32
+    @Autowired
33
+    public SMSCaptcha smsCaptcha;
34
+
35
+    @PostMapping("/login")
36
+    @ApiOperation(value="app登录", notes = "app登录", httpMethod = "POST", response = ResponseBean.class)
37
+    public ResponseBean login(@ApiParam("客户端") @PathVariable String client,
38
+                              @ApiParam("客户端") @PathVariable String clientId,
39
+                              @ApiParam("登录参数") @RequestBody LoginParam loginParam) throws Exception {
40
+
41
+        checkMClient(client);
42
+
43
+        String phone = loginParam.getUserName();
44
+        if (StringUtils.isEmpty(phone)) {
45
+            return ResponseBean.error("请设置登录手机号");
46
+        }
47
+
48
+        String captchaCode = loginParam.getPassword();
49
+        if (StringUtils.isEmpty(captchaCode)) {
50
+            return ResponseBean.error("请设置登录验证码");
51
+        }
52
+
53
+        boolean isOk = smsCaptcha.validate(phone, captchaCode);
54
+        if (!isOk) {
55
+            return ResponseBean.error("验证码不正确或者已过期");
56
+        }
57
+
58
+        SysUser sysUser = iSysUserService.getExistBy("phone", phone, false, true);
59
+        if (null == sysUser) {
60
+            return ResponseBean.error("未找到对应手机号的农机手信息");
61
+        }
62
+
63
+        TaPerson taPerson = iTaPersonService.getByPhone(clientId, phone);
64
+        if (null == taPerson) {
65
+            taPerson = new TaPerson();
66
+            taPerson.setPhone(phone);
67
+            taPerson.setIdentity(clientId);
68
+            taPerson.setStatus(Constants.STATUS_NORMAL);
69
+            taPerson.setCreateDate(LocalDateTime.now());
70
+            iTaPersonService.save(taPerson);
71
+        }
72
+
73
+        // 如果是农机手
74
+        if (Constants.CLIENT_WORKER.equals(clientId)) {
75
+            iTaPersonService.tryBindUser(taPerson);
76
+        }
77
+
78
+        // 生成 token
79
+        String token = JWTUtil.sign(taPerson.getPersonId(), taPerson.getPersonId());
80
+
81
+        Map<String, Object> res = new HashMap<>();
82
+        res.put("person", taPerson);
83
+        res.put("token", token);
84
+
85
+        return ResponseBean.success(res);
86
+    }
87
+}

+ 63
- 0
src/main/java/com/yunzhi/nanyang/controller/StatisController.java Vedi File

1
+package com.yunzhi.nanyang.controller;
2
+
3
+import com.yunzhi.nanyang.common.BaseController;
4
+import com.yunzhi.nanyang.common.ResponseBean;
5
+import com.yunzhi.nanyang.service.ITaMachineryService;
6
+import com.yunzhi.nanyang.service.ITaOrderService;
7
+import com.yunzhi.nanyang.service.ITaOrgService;
8
+import com.yunzhi.nanyang.service.ITaPersonService;
9
+import com.yunzhi.nanyang.vo.ChartParam;
10
+import io.swagger.annotations.Api;
11
+import io.swagger.annotations.ApiOperation;
12
+import org.springframework.beans.factory.annotation.Autowired;
13
+import org.springframework.web.bind.annotation.GetMapping;
14
+import org.springframework.web.bind.annotation.RequestMapping;
15
+import org.springframework.web.bind.annotation.RestController;
16
+
17
+import java.util.ArrayList;
18
+import java.util.HashMap;
19
+import java.util.List;
20
+
21
+@Api(tags = "统计查询")
22
+@RestController
23
+@RequestMapping("/admin")
24
+public class StatisController extends BaseController {
25
+
26
+    @Autowired
27
+    ITaPersonService iTaPersonService;
28
+
29
+    @Autowired
30
+    ITaOrgService iTaOrgService;
31
+
32
+    @Autowired
33
+    ITaMachineryService iTaMachineryService;
34
+
35
+    @Autowired
36
+    ITaOrderService iTaOrderService;
37
+
38
+
39
+    @GetMapping("/summary")
40
+    @ApiOperation(value="登录", notes = "登录", httpMethod = "POST", response = ResponseBean.class)
41
+    public ResponseBean summary() throws Exception {
42
+
43
+        List<ChartParam> resp = new ArrayList<>();
44
+
45
+        // 统计注册用户
46
+        ChartParam personNum = iTaPersonService.statisTotal();
47
+        resp.add(personNum);
48
+
49
+        // 合作社数
50
+        ChartParam orgNum = iTaOrgService.statisTotal();
51
+        resp.add(orgNum);
52
+
53
+        // 农机数
54
+        ChartParam machineryNum = iTaMachineryService.statisTotal();
55
+        resp.add(machineryNum);
56
+
57
+        // 订单数
58
+        ChartParam orderNum = iTaOrderService.statisTotal();
59
+        resp.add(orderNum);
60
+
61
+        return ResponseBean.success(resp);
62
+    }
63
+}

+ 4
- 7
src/main/java/com/yunzhi/nanyang/controller/SysUserController.java Vedi File

94
         sysUser.setUserId(null);
94
         sysUser.setUserId(null);
95
         sysUser.setCreateUser(userId);
95
         sysUser.setCreateUser(userId);
96
 
96
 
97
+        checkOrgAccess(sysUser.getOrgId());
98
+
97
         if (StringUtils.isEmpty(sysUser.getUserName()) || StringUtils.isEmpty(sysUser.getPhone())) {
99
         if (StringUtils.isEmpty(sysUser.getUserName()) || StringUtils.isEmpty(sysUser.getPhone())) {
98
             return ResponseBean.error("姓名或者手机不能为空");
100
             return ResponseBean.error("姓名或者手机不能为空");
99
         }
101
         }
102
             return ResponseBean.error("所属机构不能为空");
104
             return ResponseBean.error("所属机构不能为空");
103
         }
105
         }
104
 
106
 
105
-        if (!checkOrgAccess(sysUser.getOrgId(), userId)) {
106
-            return ResponseBean.error("无权限进行此操作");
107
-        }
108
-
109
         int cntPhone = iSysUserService.countBy("phone", sysUser.getPhone(), true);
107
         int cntPhone = iSysUserService.countBy("phone", sysUser.getPhone(), true);
110
         if (cntPhone > 0) {
108
         if (cntPhone > 0) {
111
             return ResponseBean.error("手机号码重复");
109
             return ResponseBean.error("手机号码重复");
174
         // 不支持更新创建人
172
         // 不支持更新创建人
175
         sysUser.setCreateUser(null);
173
         sysUser.setCreateUser(null);
176
 
174
 
175
+        checkOrgAccess(sysUser.getOrgId());
176
+
177
         if (StringUtils.isEmpty(sysUser.getUserName()) || StringUtils.isEmpty(sysUser.getPhone())) {
177
         if (StringUtils.isEmpty(sysUser.getUserName()) || StringUtils.isEmpty(sysUser.getPhone())) {
178
             return ResponseBean.error("姓名或者手机不能为空");
178
             return ResponseBean.error("姓名或者手机不能为空");
179
         }
179
         }
181
         if (StringUtils.isEmpty(sysUser.getOrgId())) {
181
         if (StringUtils.isEmpty(sysUser.getOrgId())) {
182
             return ResponseBean.error("所属机构不能为空");
182
             return ResponseBean.error("所属机构不能为空");
183
         }
183
         }
184
-        if (!checkOrgAccess(sysUser.getOrgId(), userId)) {
185
-            return ResponseBean.error("无权限进行此操作");
186
-        }
187
 
184
 
188
         SysUser origin = iSysUserService.getByButNot("phone", sysUser.getPhone(), "user_id", id,true);
185
         SysUser origin = iSysUserService.getByButNot("phone", sysUser.getPhone(), "user_id", id,true);
189
         if (origin != null) {
186
         if (origin != null) {

+ 17
- 4
src/main/java/com/yunzhi/nanyang/controller/TaAccountLogController.java Vedi File

3
 import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
3
 import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
4
 import com.baomidou.mybatisplus.core.metadata.IPage;
4
 import com.baomidou.mybatisplus.core.metadata.IPage;
5
 import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
5
 import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
6
-import com.yunzhi.nanyang.common.BaseController;
7
-import com.yunzhi.nanyang.common.ResponseBean;
6
+import com.yunzhi.nanyang.common.*;
8
 import com.yunzhi.nanyang.entity.SysUser;
7
 import com.yunzhi.nanyang.entity.SysUser;
9
 import com.yunzhi.nanyang.entity.TaAccount;
8
 import com.yunzhi.nanyang.entity.TaAccount;
10
 import com.yunzhi.nanyang.entity.TaPerson;
9
 import com.yunzhi.nanyang.entity.TaPerson;
26
 import com.yunzhi.nanyang.entity.TaAccountLog;
25
 import com.yunzhi.nanyang.entity.TaAccountLog;
27
 import org.springframework.web.bind.annotation.RestController;
26
 import org.springframework.web.bind.annotation.RestController;
28
 
27
 
28
+import java.time.LocalDateTime;
29
+
29
 /**
30
 /**
30
  * <p>
31
  * <p>
31
     * 流水表 前端控制器
32
     * 流水表 前端控制器
58
     @ApiOperation(value="列表", notes = "列表", httpMethod = "GET", response = ResponseBean.class)
59
     @ApiOperation(value="列表", notes = "列表", httpMethod = "GET", response = ResponseBean.class)
59
     @RequiresPermissions("fi-system:view")
60
     @RequiresPermissions("fi-system:view")
60
     public ResponseBean taAccountLogList(@ApiParam("页码") @RequestParam(value ="pageNum",defaultValue = "1") Integer pageNum,
61
     public ResponseBean taAccountLogList(@ApiParam("页码") @RequestParam(value ="pageNum",defaultValue = "1") Integer pageNum,
61
-                                         @ApiParam("单页数据量") @RequestParam(value ="pageSize",defaultValue = "10") Integer pageSize) throws Exception{
62
+                                         @ApiParam("单页数据量") @RequestParam(value ="pageSize",defaultValue = "10") Integer pageSize,
63
+                                         @ApiParam(value = "合作社ID") @RequestParam(value ="orgId", required = false) String orgId,
64
+                                         @ApiParam(value = "起始时间", example = "2022-03-01") @RequestParam(value ="start", required = false) String start,
65
+                                         @ApiParam(value = "结束时间", example = "2022-03-31") @RequestParam(value ="end", required = false) String end,
66
+                                         @ApiParam(value = "订单号") @RequestParam(value ="orderNo", required = false) String orderNo,
67
+                                         @ApiParam(value = "收支类型") @RequestParam(value ="feeType", required = false) Integer feeType,
68
+                                         @ApiParam(value = "消费类型") @RequestParam(value ="chargeType", required = false) String chargeType) throws Exception{
69
+
70
+        checkOrgAccess(orgId);
71
+
72
+        LocalDateTime startDate = DateUtils.getDayStart(start);
73
+        LocalDateTime endDate = DateUtils.getDayEnd(end);
74
+
62
 
75
 
63
         IPage<AccountRecord> pg = new Page<>(pageNum, pageSize);
76
         IPage<AccountRecord> pg = new Page<>(pageNum, pageSize);
64
 
77
 
65
-        IPage<AccountRecord> result = iTaAccountLogService.getPageBy(pg);
78
+        IPage<AccountRecord> result = iTaAccountLogService.getPageBy(pg, orgId, startDate, endDate, orderNo, feeType, chargeType);
66
         return ResponseBean.success(result);
79
         return ResponseBean.success(result);
67
     }
80
     }
68
 
81
 

+ 6
- 27
src/main/java/com/yunzhi/nanyang/controller/TaDispatchController.java Vedi File

87
                                        @ApiParam("状态") @RequestParam(value ="status", required = false) String status,
87
                                        @ApiParam("状态") @RequestParam(value ="status", required = false) String status,
88
                                        @ApiParam("状态") @RequestParam(value ="isWarn", defaultValue = "false") Boolean isWarn) throws Exception{
88
                                        @ApiParam("状态") @RequestParam(value ="isWarn", defaultValue = "false") Boolean isWarn) throws Exception{
89
 
89
 
90
-        SysUser user = currentUser();
91
-        if (!Constants.ADMIN_ID.equals(user.getUserId()) && !StringUtils.isEmpty(orgId)) {
92
-            if (!checkOrgAccess(user.getOrgId(), user.getUserId())) {
93
-                return ResponseBean.error("无权查询机构内容");
94
-            }
95
-        }
90
+        checkOrgAccess(orgId);
96
 
91
 
97
         IPage<TaOrder> pg = new Page<>(pageNum, pageSize);
92
         IPage<TaOrder> pg = new Page<>(pageNum, pageSize);
98
 
93
 
112
     @ApiOperation(value="保存", notes = "保存", httpMethod = "POST", response = ResponseBean.class)
107
     @ApiOperation(value="保存", notes = "保存", httpMethod = "POST", response = ResponseBean.class)
113
     @RequiresPermissions("orderjob:add")
108
     @RequiresPermissions("orderjob:add")
114
     public ResponseBean taDispatchAdd(@ApiParam("保存内容") @RequestBody TaDispatch taDispatch) throws Exception{
109
     public ResponseBean taDispatchAdd(@ApiParam("保存内容") @RequestBody TaDispatch taDispatch) throws Exception{
115
-        SysUser user = currentUser();
116
-
117
         taDispatch.setDispatchId(null);
110
         taDispatch.setDispatchId(null);
118
 
111
 
112
+        checkOrgAccess(taDispatch.getOrgId());
113
+
119
         if (StringUtils.isEmpty(taDispatch.getOrderId()) || StringUtils.isEmpty(taDispatch.getOrderId())) {
114
         if (StringUtils.isEmpty(taDispatch.getOrderId()) || StringUtils.isEmpty(taDispatch.getOrderId())) {
120
             return ResponseBean.error("订单或者接单机构为空");
115
             return ResponseBean.error("订单或者接单机构为空");
121
         }
116
         }
124
             return ResponseBean.error("验证订单信息异常");
119
             return ResponseBean.error("验证订单信息异常");
125
         }
120
         }
126
 
121
 
127
-        if (!checkOrgAccess(taDispatch.getOrgId(), user.getUserId())) {
128
-            return ResponseBean.error("无操作权限");
129
-        }
130
-
131
         taDispatch.setOrgName(iTaOrgService.getById(taDispatch.getOrgId()).getName());
122
         taDispatch.setOrgName(iTaOrgService.getById(taDispatch.getOrgId()).getName());
132
 
123
 
133
         if (!StringUtils.isEmpty(taDispatch.getMachineryId())) {
124
         if (!StringUtils.isEmpty(taDispatch.getMachineryId())) {
144
 
135
 
145
         taDispatch.setStatus(Constants.STATUS_NORMAL);
136
         taDispatch.setStatus(Constants.STATUS_NORMAL);
146
 
137
 
147
-
148
-        if (iTaDispatchService.save(taDispatch)){
149
-
150
-            // 生成作业信息
151
-            TaWorkJob taWorkJob = iTaWorkJobService.createByDispatch(taDispatch, taOrder);
152
-
153
-            // 更新订单状态
154
-            iTaOrderService.updateStatus(taDispatch.getOrderId(), "dispatch_status", Constants.DISPATCH_DONE);
155
-
138
+        TaWorkJob taWorkJob = iTaDispatchService.createNew(taDispatch, taOrder);
139
+        if (null != taWorkJob){
156
             // 发送通知
140
             // 发送通知
157
             applicationEventPublisher.publishEvent(new WorkDispatchEvent(this, taWorkJob, taOrder));
141
             applicationEventPublisher.publishEvent(new WorkDispatchEvent(this, taWorkJob, taOrder));
158
-
159
             return ResponseBean.success(taDispatch);
142
             return ResponseBean.success(taDispatch);
160
         }else {
143
         }else {
161
             return ResponseBean.error("保存失败, 请重试", ResponseBean.ERROR_UNAVAILABLE);
144
             return ResponseBean.error("保存失败, 请重试", ResponseBean.ERROR_UNAVAILABLE);
172
     public ResponseBean taDispatchDelete(@ApiParam("对象ID") @PathVariable String id) throws Exception{
155
     public ResponseBean taDispatchDelete(@ApiParam("对象ID") @PathVariable String id) throws Exception{
173
         TaDispatch taDispatch = iTaDispatchService.getById(id);
156
         TaDispatch taDispatch = iTaDispatchService.getById(id);
174
 
157
 
175
-        SysUser user = currentUser();
176
-
177
-        if (!checkOrgAccess(taDispatch.getOrgId(), user.getUserId())) {
178
-            return ResponseBean.error("无操作权限");
179
-        }
158
+        checkOrgAccess(taDispatch.getOrgId());
180
 
159
 
181
         TaWorkJob taWorkJob = iTaWorkJobService.getExistBy("dispatch_id", id, false, true);
160
         TaWorkJob taWorkJob = iTaWorkJobService.getExistBy("dispatch_id", id, false, true);
182
         if (null == taWorkJob) {
161
         if (null == taWorkJob) {

+ 4
- 21
src/main/java/com/yunzhi/nanyang/controller/TaMachineryController.java Vedi File

71
                                         @ApiParam("类型") @RequestParam(value ="typeId", required = false) String typeId,
71
                                         @ApiParam("类型") @RequestParam(value ="typeId", required = false) String typeId,
72
                                         @ApiParam("机构ID") @RequestParam(value ="orgId", required = false) String orgId,
72
                                         @ApiParam("机构ID") @RequestParam(value ="orgId", required = false) String orgId,
73
                                         @ApiParam("状态") @RequestParam(value ="status", required = false) Integer status) throws Exception{
73
                                         @ApiParam("状态") @RequestParam(value ="status", required = false) Integer status) throws Exception{
74
-        SysUser sysUser = currentUser();
75
-        boolean isAdmin = Constants.ADMIN_ID.equals(sysUser.getUserId());
76
-
77
-        if (!StringUtils.isEmpty(orgId) && !isAdmin) {
78
-            if (!checkOrgAccess(orgId, sysUser.getUserId())) {
79
-                return ResponseBean.error("无权限操作");
80
-            }
81
-        }
74
+        checkOrgAccess(orgId);
82
 
75
 
83
         IPage<TaMachinery> pg = new Page<>(pageNum, pageSize);
76
         IPage<TaMachinery> pg = new Page<>(pageNum, pageSize);
84
 
77
 
139
             return ResponseBean.error("请设置农机归属");
132
             return ResponseBean.error("请设置农机归属");
140
         }
133
         }
141
 
134
 
142
-        if (!checkOrgAccess(taMachinery.getOrgId(), sysUser.getUserId())) {
143
-            return ResponseBean.error("无权进行此操作");
144
-        }
135
+        checkOrgAccess(taMachinery.getOrgId());
145
 
136
 
146
         taMachinery.setMachineryId(null);
137
         taMachinery.setMachineryId(null);
147
         taMachinery.setCreateUser(sysUser.getUserId());
138
         taMachinery.setCreateUser(sysUser.getUserId());
161
     @ApiOperation(value="删除", notes = "删除", httpMethod = "DELETE", response = ResponseBean.class)
152
     @ApiOperation(value="删除", notes = "删除", httpMethod = "DELETE", response = ResponseBean.class)
162
     @RequiresPermissions("machinery:delete")
153
     @RequiresPermissions("machinery:delete")
163
     public ResponseBean taMachineryDelete(@ApiParam("对象ID") @PathVariable String id) throws Exception{
154
     public ResponseBean taMachineryDelete(@ApiParam("对象ID") @PathVariable String id) throws Exception{
164
-        SysUser sysUser = currentUser();
165
-
166
         TaMachinery taMachinery = iTaMachineryService.getExistBy("machinery_id", id, false, true);
155
         TaMachinery taMachinery = iTaMachineryService.getExistBy("machinery_id", id, false, true);
167
         if (null == taMachinery) {
156
         if (null == taMachinery) {
168
             return ResponseBean.success("success");
157
             return ResponseBean.success("success");
169
         }
158
         }
170
 
159
 
171
-        if (!checkOrgAccess(taMachinery.getOrgId(), sysUser.getUserId())) {
172
-            return ResponseBean.error("无权进行此操作");
173
-        }
160
+        checkOrgAccess(taMachinery.getOrgId());
174
 
161
 
175
         if(iTaMachineryService.removeLogicById(id)){
162
         if(iTaMachineryService.removeLogicById(id)){
176
             return ResponseBean.success("success");
163
             return ResponseBean.success("success");
190
     @RequiresPermissions("machinery:update")
177
     @RequiresPermissions("machinery:update")
191
     public ResponseBean taMachineryUpdate(@ApiParam("对象ID") @PathVariable String id,
178
     public ResponseBean taMachineryUpdate(@ApiParam("对象ID") @PathVariable String id,
192
                                         @ApiParam("更新内容") @RequestBody TaMachinery taMachinery) throws Exception{
179
                                         @ApiParam("更新内容") @RequestBody TaMachinery taMachinery) throws Exception{
193
-        SysUser sysUser = currentUser();
194
-
195
         if (StringUtils.isEmpty(taMachinery.getOrgId())) {
180
         if (StringUtils.isEmpty(taMachinery.getOrgId())) {
196
             return ResponseBean.error("请设置农机归属");
181
             return ResponseBean.error("请设置农机归属");
197
         }
182
         }
198
 
183
 
199
-        if (!checkOrgAccess(taMachinery.getOrgId(), sysUser.getUserId())) {
200
-            return ResponseBean.error("无权进行此操作");
201
-        }
184
+        checkOrgAccess(taMachinery.getOrgId());
202
 
185
 
203
         taMachinery.setMachineryId(id);
186
         taMachinery.setMachineryId(id);
204
 
187
 

+ 1
- 6
src/main/java/com/yunzhi/nanyang/controller/TaOrderController.java Vedi File

82
                                 @ApiParam("评价状态") @RequestParam(value ="isEvaluated", required = false) Integer isEvaluated) throws Exception{
82
                                 @ApiParam("评价状态") @RequestParam(value ="isEvaluated", required = false) Integer isEvaluated) throws Exception{
83
         SysUser current = currentUser();
83
         SysUser current = currentUser();
84
         boolean isAdmin = Constants.ADMIN_ID.equals(current.getUserId());
84
         boolean isAdmin = Constants.ADMIN_ID.equals(current.getUserId());
85
-
86
-        if (!isAdmin && !StringUtils.isEmpty(orgId)) {
87
-            if (!checkOrgAccess(orgId, current.getUserId())) {
88
-                return ResponseBean.error("无机构查询权限");
89
-            }
90
-        }
85
+        checkOrgAccess(orgId);
91
 
86
 
92
         IPage<TaOrder> pg = new Page<>(pageNum, pageSize);
87
         IPage<TaOrder> pg = new Page<>(pageNum, pageSize);
93
         IPage<TaOrder> result = iTaOrderService.getAdminPage(pg,
88
         IPage<TaOrder> result = iTaOrderService.getAdminPage(pg,

+ 64
- 25
src/main/java/com/yunzhi/nanyang/controller/TaPersonController.java Vedi File

3
 import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
3
 import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
4
 import com.baomidou.mybatisplus.core.metadata.IPage;
4
 import com.baomidou.mybatisplus.core.metadata.IPage;
5
 import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
5
 import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
6
-import com.yunzhi.nanyang.common.BaseController;
7
-import com.yunzhi.nanyang.common.ResponseBean;
8
-import com.yunzhi.nanyang.common.SMSCaptcha;
9
-import com.yunzhi.nanyang.common.StringUtils;
6
+import com.yunzhi.nanyang.common.*;
10
 import com.yunzhi.nanyang.entity.SysUser;
7
 import com.yunzhi.nanyang.entity.SysUser;
11
 import com.yunzhi.nanyang.service.ISysUserService;
8
 import com.yunzhi.nanyang.service.ISysUserService;
9
+import com.yunzhi.nanyang.shiro.utils.JWTUtil;
12
 import com.yunzhi.nanyang.vo.PhoneParam;
10
 import com.yunzhi.nanyang.vo.PhoneParam;
13
 import io.swagger.annotations.Api;
11
 import io.swagger.annotations.Api;
14
 import io.swagger.annotations.ApiOperation;
12
 import io.swagger.annotations.ApiOperation;
25
 import com.yunzhi.nanyang.entity.TaPerson;
23
 import com.yunzhi.nanyang.entity.TaPerson;
26
 import org.springframework.web.bind.annotation.RestController;
24
 import org.springframework.web.bind.annotation.RestController;
27
 
25
 
26
+import java.util.HashMap;
27
+import java.util.Map;
28
+
28
 /**
29
 /**
29
  * <p>
30
  * <p>
30
     * 人员表 前端控制器
31
     * 人员表 前端控制器
136
 
137
 
137
         taPerson.setPersonId(id);
138
         taPerson.setPersonId(id);
138
 
139
 
139
-        // 关联系统人员
140
-        SysUser sysUser = iSysUserService.getExistBy("phone", taPerson.getPhone(), false, true);
141
-        if (sysUser != null && StringUtils.isEmpty(taPerson.getUserId())) {
142
-            taPerson.setUserId(sysUser.getUserId());
140
+        // 如果是农机手
141
+        if (Constants.CLIENT_WORKER.equals(clientId)) {
142
+            // 关联系统人员
143
+            SysUser sysUser = iSysUserService.getExistBy("phone", taPerson.getPhone(), false, true);
144
+            if (sysUser != null && StringUtils.isEmpty(taPerson.getUserId())) {
145
+                taPerson.setUserId(sysUser.getUserId());
146
+            }
143
         }
147
         }
144
 
148
 
145
         if (iTaPersonService.updateById(taPerson)){
149
         if (iTaPersonService.updateById(taPerson)){
176
             return ResponseBean.error("验证码不正确或者已过期");
180
             return ResponseBean.error("验证码不正确或者已过期");
177
         }
181
         }
178
 
182
 
179
-        taPerson.setPhone(phoneParam.getPhone());
183
+        if (!StringUtils.isEmpty(taPerson.getPhone())) {
184
+            return ResponseBean.error("暂不支持手机号修改");
185
+        }
180
 
186
 
181
-        // 关联系统人员
182
-        SysUser sysUser = iSysUserService.getExistBy("phone", phoneParam.getPhone(), false, true);
183
-        if (sysUser != null && StringUtils.isEmpty(taPerson.getUserId())) {
184
-            taPerson.setUserId(sysUser.getUserId());
187
+        // 先去查询是否已经注册过
188
+        TaPerson origin = iTaPersonService.getByPhone(clientId, phoneParam.getPhone());
189
+        if (origin != null && !origin.getPersonId().equals(id)) {
190
+            // 找到同手机号人员, 说明是 app 端注册过的
191
+            // 那么把小程序端人员信息移植到 app 端人员上去
192
+            origin.setAppId(taPerson.getAppId());
193
+            origin.setOpenid(taPerson.getOpenid());
194
+
195
+            if (StringUtils.isEmpty(origin.getNickName())) {
196
+                origin.setNickName(taPerson.getNickName());
197
+            }
198
+            if (StringUtils.isEmpty(origin.getAvatar())) {
199
+                origin.setAvatar(taPerson.getAvatar());
200
+            }
201
+            if (null != origin.getSex()) {
202
+                origin.setSex(taPerson.getSex());
203
+            }
204
+
205
+            // 先把小程序端人员删除
206
+            taPerson.setOpenid("deleted");
207
+            taPerson.setStatus(Constants.STATUS_DELETE);
208
+            iTaPersonService.updateById(taPerson);
209
+            // 再赋值 taPerson , 后续再处理 taPerson 实际上就是处理的 app 人员了
210
+            taPerson = origin;
185
         }
211
         }
186
 
212
 
187
-        if (iTaPersonService.updateById(taPerson)){
213
+        taPerson.setPhone(phoneParam.getPhone());
188
 
214
 
215
+        // 如果是农机手
216
+        if (Constants.CLIENT_WORKER.equals(clientId)) {
217
+            // 关联系统人员
218
+            SysUser sysUser = iSysUserService.getExistBy("phone", phoneParam.getPhone(), false, true);
219
+            if (sysUser != null && StringUtils.isEmpty(taPerson.getUserId())) {
220
+                taPerson.setUserId(sysUser.getUserId());
221
+            }
222
+        }
189
 
223
 
190
-            return ResponseBean.success(taPerson);
224
+        if (iTaPersonService.updateById(taPerson)){
225
+            // 因为有可能修改 person 为 app 端的人员, 所以此处刷新一次 token
226
+            String token = JWTUtil.sign(taPerson.getPersonId(), taPerson.getPersonId());
227
+            Map<String, Object> res = new HashMap<>();
228
+            res.put("person", taPerson);
229
+            res.put("token", token);
230
+            return ResponseBean.success(res);
191
         }else {
231
         }else {
192
             return ResponseBean.error("修改失败, 请重试", ResponseBean.ERROR_UNAVAILABLE);
232
             return ResponseBean.error("修改失败, 请重试", ResponseBean.ERROR_UNAVAILABLE);
193
         }
233
         }
194
     }
234
     }
195
-//
196
-//    /**
197
-//     * 根据id查询对象
198
-//     * @param id  实体ID
199
-//     */
200
-//    @RequestMapping(value="/taPerson/{id}",method= RequestMethod.GET)
201
-//    @ApiOperation(value="详情", notes = "详情", httpMethod = "GET", response = ResponseBean.class)
202
-//    public ResponseBean taPersonGet(@ApiParam("对象ID") @PathVariable Integer id) throws Exception{
203
-//        return ResponseBean.success(iTaPersonService.getById(id));
204
-//    }
235
+
236
+    /**
237
+     * 根据id查询对象
238
+     */
239
+    @RequestMapping(value="/{client}/{clientId}/person/current",method= RequestMethod.GET)
240
+    @ApiOperation(value="详情", notes = "详情", httpMethod = "GET", response = ResponseBean.class)
241
+    public ResponseBean taPersonGet() throws Exception{
242
+        return ResponseBean.success(currentPerson());
243
+    }
205
 }
244
 }

+ 2
- 8
src/main/java/com/yunzhi/nanyang/controller/TaUserMachineryController.java Vedi File

63
             return ResponseBean.error("未找到指定人员");
63
             return ResponseBean.error("未找到指定人员");
64
         }
64
         }
65
 
65
 
66
-        SysUser current = currentUser();
67
-        if (!checkOrgAccess(sysUser.getOrgId(), current.getUserId())) {
68
-            return ResponseBean.error("暂无权限");
69
-        }
66
+        checkOrgAccess(sysUser.getOrgId());
70
 
67
 
71
         List<TaUserMachinery> result = iTaUserMachineryService.getByUser(userId);
68
         List<TaUserMachinery> result = iTaUserMachineryService.getByUser(userId);
72
         return ResponseBean.success(result);
69
         return ResponseBean.success(result);
88
             return ResponseBean.error("未找到指定人员");
85
             return ResponseBean.error("未找到指定人员");
89
         }
86
         }
90
 
87
 
91
-        SysUser current = currentUser();
92
-        if (!checkOrgAccess(sysUser.getOrgId(), current.getUserId())) {
93
-            return ResponseBean.error("暂无权限");
94
-        }
88
+        checkOrgAccess(sysUser.getOrgId());
95
 
89
 
96
         if (iTaUserMachineryService.editWithUser(userId, userMachineryList)){
90
         if (iTaUserMachineryService.editWithUser(userId, userMachineryList)){
97
             return ResponseBean.success(userMachineryList);
91
             return ResponseBean.success(userMachineryList);

+ 8
- 31
src/main/java/com/yunzhi/nanyang/controller/TaWithdrawalController.java Vedi File

65
                                          @ApiParam("单页数据量") @RequestParam(value ="pageSize",defaultValue = "10") Integer pageSize,
65
                                          @ApiParam("单页数据量") @RequestParam(value ="pageSize",defaultValue = "10") Integer pageSize,
66
                                          @ApiParam("机构ID") @RequestParam(value ="orgId", required = false) String orgId,
66
                                          @ApiParam("机构ID") @RequestParam(value ="orgId", required = false) String orgId,
67
                                          @ApiParam(value = "开始日期", example = "2022-03-01") @RequestParam(value ="start",required = false) String start,
67
                                          @ApiParam(value = "开始日期", example = "2022-03-01") @RequestParam(value ="start",required = false) String start,
68
-                                         @ApiParam(value = "结束日期", example = "2022-03-31") @RequestParam(value ="end",required = false) String end) throws Exception{
68
+                                         @ApiParam(value = "结束日期", example = "2022-03-31") @RequestParam(value ="end",required = false) String end,
69
+                                         @ApiParam("申请人") @RequestParam(value ="userName", required = false) String userName,
70
+                                         @ApiParam("审批状态") @RequestParam(value ="auditStatus", required = false) Integer auditStatus) throws Exception{
69
 
71
 
70
-        SysUser sysUser = currentUser();
71
-        boolean isAdmin = Constants.ADMIN_ID.equals(sysUser.getUserId());
72
-        if (!isAdmin) {
73
-            if (StringUtils.isEmpty(orgId)) {
74
-                orgId = sysUser.getOrgId();
75
-            } else {
76
-                if (!checkOrgAccess(orgId, sysUser.getUserId())) {
77
-                    return ResponseBean.error("暂无机构数据查询权限");
78
-                }
79
-            }
80
-        }
72
+        checkOrgAccess(orgId);
81
 
73
 
82
         LocalDateTime startDate = DateUtils.getDayStart(start);
74
         LocalDateTime startDate = DateUtils.getDayStart(start);
83
         LocalDateTime endDate = DateUtils.getDayEnd(end);
75
         LocalDateTime endDate = DateUtils.getDayEnd(end);
84
 
76
 
85
         IPage<TaWithdrawal> pg = new Page<>(pageNum, pageSize);
77
         IPage<TaWithdrawal> pg = new Page<>(pageNum, pageSize);
86
-        IPage<TaWithdrawal> result = iTaWithdrawalService.getPageBy(pg, orgId, startDate, endDate);
78
+        IPage<TaWithdrawal> result = iTaWithdrawalService.getPageBy(pg, orgId, startDate, endDate, userName, auditStatus);
87
         return ResponseBean.success(result);
79
         return ResponseBean.success(result);
88
     }
80
     }
89
 
81
 
235
         }
227
         }
236
 
228
 
237
         String orgId = origin.getOrgId();
229
         String orgId = origin.getOrgId();
238
-        boolean isAdmin = Constants.ADMIN_ID.equals(sysUser.getUserId());
239
-        if (!isAdmin) {
240
-            if (!checkOrgAccess(orgId, sysUser.getUserId())) {
241
-                return ResponseBean.error("暂无操作权限");
242
-            }
243
-        }
230
+        checkOrgAccess(orgId);
244
 
231
 
245
         // 不能重复审批, 因为审批有账户操作
232
         // 不能重复审批, 因为审批有账户操作
246
         Integer auditStatus = origin.getAuditStatus();
233
         Integer auditStatus = origin.getAuditStatus();
259
         origin.setAuditRemark(taWithdrawal.getAuditRemark());
246
         origin.setAuditRemark(taWithdrawal.getAuditRemark());
260
         origin.setAuditDate(LocalDateTime.now());
247
         origin.setAuditDate(LocalDateTime.now());
261
 
248
 
262
-        if (iTaWithdrawalService.updateById(origin)){
263
-
264
-            // 处理账户信息
265
-            iTaAccountService.withdraw(origin);
266
-
249
+        if (iTaWithdrawalService.audit(origin)){
267
             return ResponseBean.success(iTaWithdrawalService.getById(id));
250
             return ResponseBean.success(iTaWithdrawalService.getById(id));
268
         }else {
251
         }else {
269
             return ResponseBean.error("修改失败, 请重试", ResponseBean.ERROR_UNAVAILABLE);
252
             return ResponseBean.error("修改失败, 请重试", ResponseBean.ERROR_UNAVAILABLE);
285
         SysUser user = iSysUserService.getById(taWithdrawal.getUserId());
268
         SysUser user = iSysUserService.getById(taWithdrawal.getUserId());
286
         taWithdrawal.setPhone(user.getPhone());
269
         taWithdrawal.setPhone(user.getPhone());
287
 
270
 
288
-        SysUser sysUser = currentUser();
289
         String orgId = taWithdrawal.getOrgId();
271
         String orgId = taWithdrawal.getOrgId();
290
-        boolean isAdmin = Constants.ADMIN_ID.equals(sysUser.getUserId());
291
-        if (!isAdmin) {
292
-            if (!checkOrgAccess(orgId, sysUser.getUserId())) {
293
-                return ResponseBean.error("暂无数据查询权限");
294
-            }
295
-        }
272
+        checkOrgAccess(orgId);
296
 
273
 
297
         TaOrg taOrg = iTaOrgService.getById(orgId);
274
         TaOrg taOrg = iTaOrgService.getById(orgId);
298
         taWithdrawal.setOrgName(taOrg.getName());
275
         taWithdrawal.setOrgName(taOrg.getName());

+ 2
- 8
src/main/java/com/yunzhi/nanyang/controller/TaWorkJobController.java Vedi File

70
                                 @ApiParam(value = "农机型号ID") @RequestParam(value ="machineryTypeId", required = false) String machineryTypeId,
70
                                 @ApiParam(value = "农机型号ID") @RequestParam(value ="machineryTypeId", required = false) String machineryTypeId,
71
                                 @ApiParam(value = "农机ID") @RequestParam(value ="machineryId", required = false) String machineryId,
71
                                 @ApiParam(value = "农机ID") @RequestParam(value ="machineryId", required = false) String machineryId,
72
                                 @ApiParam(value = "农机手名称") @RequestParam(value ="workerName", required = false) String workerName) throws Exception{
72
                                 @ApiParam(value = "农机手名称") @RequestParam(value ="workerName", required = false) String workerName) throws Exception{
73
-        SysUser sysUser = currentUser();
74
-        if (!Constants.ADMIN_ID.equals(sysUser.getUserId()) && !StringUtils.isEmpty(orgId)) {
75
-            if (checkOrgAccess(orgId, sysUser.getUserId())) {
76
-                return ResponseBean.error("暂无合作设数据权限");
77
-            }
78
-        }
73
+        checkOrgAccess(orgId);
79
 
74
 
80
         LocalDateTime startDate = DateUtils.getDayStart(start);
75
         LocalDateTime startDate = DateUtils.getDayStart(start);
81
         LocalDateTime endDate = DateUtils.getDayEnd(end);
76
         LocalDateTime endDate = DateUtils.getDayEnd(end);
116
     /**
111
     /**
117
      * 暂停/开启
112
      * 暂停/开启
118
      * @param id  实体ID
113
      * @param id  实体ID
119
-     * @param taWorkJob 实体对象
114
+     * @param mode 实体对象
120
      * @return
115
      * @return
121
      */
116
      */
122
     @RequestMapping(value="/{client}/worker/work-job/{id}/pause",method= RequestMethod.PUT)
117
     @RequestMapping(value="/{client}/worker/work-job/{id}/pause",method= RequestMethod.PUT)
123
     @ApiOperation(value="暂停/开启", notes = "暂停/开启", httpMethod = "PUT", response = ResponseBean.class)
118
     @ApiOperation(value="暂停/开启", notes = "暂停/开启", httpMethod = "PUT", response = ResponseBean.class)
124
     public ResponseBean taWorkJobUpdate(@ApiParam("客户端") @PathVariable String client,
119
     public ResponseBean taWorkJobUpdate(@ApiParam("客户端") @PathVariable String client,
125
-//                                      @ApiParam("客户端ID") @PathVariable String clientId,
126
                                         @ApiParam("对象ID") @PathVariable String id,
120
                                         @ApiParam("对象ID") @PathVariable String id,
127
                                         @ApiParam("是否暂停") @RequestParam("mode") Boolean mode) throws Exception{
121
                                         @ApiParam("是否暂停") @RequestParam("mode") Boolean mode) throws Exception{
128
 
122
 

+ 4
- 3
src/main/java/com/yunzhi/nanyang/controller/WxMaController.java Vedi File

64
     @GetMapping("/preload")
64
     @GetMapping("/preload")
65
     @ApiOperation(value="小程序登录", notes = "小程序登录", httpMethod = "POST", response = ResponseBean.class)
65
     @ApiOperation(value="小程序登录", notes = "小程序登录", httpMethod = "POST", response = ResponseBean.class)
66
     public ResponseBean preload(@ApiParam("客户端ID") @PathVariable String clientId,
66
     public ResponseBean preload(@ApiParam("客户端ID") @PathVariable String clientId,
67
-                                @ApiParam("小程序预加载参数") @RequestParam WxMaPreload wxMaPreload) throws Exception {
67
+                                @ApiParam("小程序预加载参数") @RequestParam(required = false) WxMaPreload wxMaPreload) throws Exception {
68
 
68
 
69
         if (Constants.CLIENT_WORKER.equals(clientId)) {
69
         if (Constants.CLIENT_WORKER.equals(clientId)) {
70
             List<TaMessageTemplate> list = iTaMessageTemplateService.getByTplType(Constants.MESSAGE_MINIAPP);
70
             List<TaMessageTemplate> list = iTaMessageTemplateService.getByTplType(Constants.MESSAGE_MINIAPP);
71
-            ResponseBean.success(new HashMap<String, Object>(){{
71
+            return ResponseBean.success(new HashMap<String, Object>(){{
72
                 put("tpls", list);
72
                 put("tpls", list);
73
             }});
73
             }});
74
         }
74
         }
103
             taPerson = new TaPerson();
103
             taPerson = new TaPerson();
104
             taPerson.setAppId(miniapp.getAppId());
104
             taPerson.setAppId(miniapp.getAppId());
105
             taPerson.setOpenid(openid);
105
             taPerson.setOpenid(openid);
106
+            taPerson.setIdentity(clientId);
106
             taPerson.setStatus(Constants.STATUS_NORMAL);
107
             taPerson.setStatus(Constants.STATUS_NORMAL);
107
             taPerson.setCreateDate(LocalDateTime.now());
108
             taPerson.setCreateDate(LocalDateTime.now());
108
             iTaPersonService.save(taPerson);
109
             iTaPersonService.save(taPerson);
109
         }
110
         }
110
 
111
 
111
         // 如果是农机手
112
         // 如果是农机手
112
-        if (Constants.CLIENT_WORKER.equals(miniapp.getClient())) {
113
+        if (Constants.CLIENT_WORKER.equals(clientId)) {
113
             iTaPersonService.tryBindUser(taPerson);
114
             iTaPersonService.tryBindUser(taPerson);
114
         }
115
         }
115
 
116
 

+ 3
- 0
src/main/java/com/yunzhi/nanyang/entity/TaPerson.java Vedi File

50
     @ApiModelProperty(value = "手机号")
50
     @ApiModelProperty(value = "手机号")
51
     private String phone;
51
     private String phone;
52
 
52
 
53
+    @ApiModelProperty(value = "身份")
54
+    private String identity;
55
+
53
     @ApiModelProperty(value = "绑定人员")
56
     @ApiModelProperty(value = "绑定人员")
54
     private String userId;
57
     private String userId;
55
 
58
 

+ 10
- 1
src/main/java/com/yunzhi/nanyang/mapper/TaAccountLogMapper.java Vedi File

5
 import com.baomidou.mybatisplus.core.mapper.BaseMapper;
5
 import com.baomidou.mybatisplus.core.mapper.BaseMapper;
6
 import com.yunzhi.nanyang.vo.AccountRecord;
6
 import com.yunzhi.nanyang.vo.AccountRecord;
7
 import org.apache.ibatis.annotations.Mapper;
7
 import org.apache.ibatis.annotations.Mapper;
8
+import org.apache.ibatis.annotations.Param;
9
+
10
+import java.time.LocalDateTime;
8
 
11
 
9
 /**
12
 /**
10
  * <p>
13
  * <p>
17
 @Mapper
20
 @Mapper
18
 public interface TaAccountLogMapper extends BaseMapper<TaAccountLog> {
21
 public interface TaAccountLogMapper extends BaseMapper<TaAccountLog> {
19
 
22
 
20
-    IPage<AccountRecord> getPageBy(IPage<AccountRecord> pg);
23
+    IPage<AccountRecord> getPageBy(IPage<AccountRecord> pg,
24
+                                   @Param("orgId") String orgId,
25
+                                   @Param("startDate") LocalDateTime startDate,
26
+                                   @Param("endDate") LocalDateTime endDate,
27
+                                   @Param("orderNo") String orderNo,
28
+                                   @Param("feeType") Integer feeType,
29
+                                   @Param("chargeType") String chargeType);
21
 }
30
 }

+ 5
- 0
src/main/java/com/yunzhi/nanyang/mapper/TaMachineryMapper.java Vedi File

3
 import com.baomidou.mybatisplus.core.metadata.IPage;
3
 import com.baomidou.mybatisplus.core.metadata.IPage;
4
 import com.yunzhi.nanyang.entity.TaMachinery;
4
 import com.yunzhi.nanyang.entity.TaMachinery;
5
 import com.baomidou.mybatisplus.core.mapper.BaseMapper;
5
 import com.baomidou.mybatisplus.core.mapper.BaseMapper;
6
+import com.yunzhi.nanyang.vo.ChartParam;
6
 import com.yunzhi.nanyang.vo.MachineSummary;
7
 import com.yunzhi.nanyang.vo.MachineSummary;
7
 import org.apache.ibatis.annotations.Mapper;
8
 import org.apache.ibatis.annotations.Mapper;
8
 import org.apache.ibatis.annotations.Param;
9
 import org.apache.ibatis.annotations.Param;
10
+import org.apache.ibatis.annotations.Select;
9
 import org.apache.ibatis.annotations.Update;
11
 import org.apache.ibatis.annotations.Update;
10
 
12
 
11
 /**
13
 /**
42
                                  @Param("typeId") String typeId,
44
                                  @Param("typeId") String typeId,
43
                                  @Param("orgId") String orgId,
45
                                  @Param("orgId") String orgId,
44
                                  @Param("status") Integer status);
46
                                  @Param("status") Integer status);
47
+
48
+    @Select("SELECT 'machinery' as `name`, count(*) as `value` FROM ta_machinery WHERE `status` > -1")
49
+    ChartParam statisTotal();
45
 }
50
 }

+ 9
- 0
src/main/java/com/yunzhi/nanyang/mapper/TaOrderMapper.java Vedi File

3
 import com.baomidou.mybatisplus.core.metadata.IPage;
3
 import com.baomidou.mybatisplus.core.metadata.IPage;
4
 import com.yunzhi.nanyang.entity.TaOrder;
4
 import com.yunzhi.nanyang.entity.TaOrder;
5
 import com.baomidou.mybatisplus.core.mapper.BaseMapper;
5
 import com.baomidou.mybatisplus.core.mapper.BaseMapper;
6
+import com.yunzhi.nanyang.vo.ChartParam;
6
 import org.apache.ibatis.annotations.Mapper;
7
 import org.apache.ibatis.annotations.Mapper;
7
 import org.apache.ibatis.annotations.Param;
8
 import org.apache.ibatis.annotations.Param;
8
 import org.apache.ibatis.annotations.Select;
9
 import org.apache.ibatis.annotations.Select;
10
+import org.apache.ibatis.annotations.Update;
9
 
11
 
10
 import java.util.List;
12
 import java.util.List;
11
 
13
 
48
 
50
 
49
     List<TaOrder> checkMachineryDuty(@Param("machineryId") String machineryId,@Param("appointmentDate") String appointmentDate);
51
     List<TaOrder> checkMachineryDuty(@Param("machineryId") String machineryId,@Param("appointmentDate") String appointmentDate);
50
 
52
 
53
+    @Update("UPDATE ta_order SET pay_status = #{payStatus} WHERE order_id = #{orderId}")
51
     int updatePayStatus(@Param("orderId") String orderId, @Param("payStatus") int payStatus);
54
     int updatePayStatus(@Param("orderId") String orderId, @Param("payStatus") int payStatus);
55
+
56
+    @Update("UPDATE ta_order SET dispatch_status = #{dispatchStatus} WHERE order_id = #{orderId}")
57
+    int updateDispatchStatus(@Param("orderId") String orderId, @Param("dispatchStatus") int dispatchStatus);
58
+
59
+    @Select("SELECT 'order' as `name`, count(*) as `value` FROM ta_order WHERE `status` > -1")
60
+    ChartParam statisTotal();
52
 }
61
 }

+ 5
- 0
src/main/java/com/yunzhi/nanyang/mapper/TaOrgMapper.java Vedi File

3
 import com.baomidou.mybatisplus.core.metadata.IPage;
3
 import com.baomidou.mybatisplus.core.metadata.IPage;
4
 import com.yunzhi.nanyang.entity.TaOrg;
4
 import com.yunzhi.nanyang.entity.TaOrg;
5
 import com.baomidou.mybatisplus.core.mapper.BaseMapper;
5
 import com.baomidou.mybatisplus.core.mapper.BaseMapper;
6
+import com.yunzhi.nanyang.vo.ChartParam;
6
 import org.apache.ibatis.annotations.Mapper;
7
 import org.apache.ibatis.annotations.Mapper;
7
 import org.apache.ibatis.annotations.Param;
8
 import org.apache.ibatis.annotations.Param;
9
+import org.apache.ibatis.annotations.Select;
8
 
10
 
9
 /**
11
 /**
10
  * <p>
12
  * <p>
18
 public interface TaOrgMapper extends BaseMapper<TaOrg> {
20
 public interface TaOrgMapper extends BaseMapper<TaOrg> {
19
 
21
 
20
     IPage<TaOrg> getPageBy(IPage<TaOrg> pg, @Param("userId") String userId, @Param("name") String name);
22
     IPage<TaOrg> getPageBy(IPage<TaOrg> pg, @Param("userId") String userId, @Param("name") String name);
23
+
24
+    @Select("SELECT 'org' as `name`, count(*) as `value`  FROM ta_org t WHERE t.`status` > -1")
25
+    ChartParam statisTotal();
21
 }
26
 }

+ 7
- 0
src/main/java/com/yunzhi/nanyang/mapper/TaPersonMapper.java Vedi File

2
 
2
 
3
 import com.yunzhi.nanyang.entity.TaPerson;
3
 import com.yunzhi.nanyang.entity.TaPerson;
4
 import com.baomidou.mybatisplus.core.mapper.BaseMapper;
4
 import com.baomidou.mybatisplus.core.mapper.BaseMapper;
5
+import com.yunzhi.nanyang.vo.ChartParam;
5
 import org.apache.ibatis.annotations.Mapper;
6
 import org.apache.ibatis.annotations.Mapper;
6
 import org.apache.ibatis.annotations.Param;
7
 import org.apache.ibatis.annotations.Param;
7
 import org.apache.ibatis.annotations.Select;
8
 import org.apache.ibatis.annotations.Select;
22
 
23
 
23
     @Select("SELECT * FROM ta_person t WHERE t.user_id = #{userId} AND t.`status` > -1")
24
     @Select("SELECT * FROM ta_person t WHERE t.user_id = #{userId} AND t.`status` > -1")
24
     TaPerson getByUserId(@Param("userId") String userId);
25
     TaPerson getByUserId(@Param("userId") String userId);
26
+    
27
+    @Select("SELECT 'person' as `name`, count(*) as `value`  FROM ta_person t WHERE t.phone is not null AND t.`status` > -1")
28
+    ChartParam statisTotal();
29
+
30
+    @Select("SELECT * FROM ta_person t WHERE t.phone = #{phone} AND t.identity = #{clientId} AND t.`status` > -1")
31
+    TaPerson getByPhone(@Param("clientId") String clientId,@Param("phone")  String phone);
25
 }
32
 }

+ 3
- 1
src/main/java/com/yunzhi/nanyang/mapper/TaWithdrawalMapper.java Vedi File

22
     IPage<TaWithdrawal> getPageBy(IPage<TaWithdrawal> pg,
22
     IPage<TaWithdrawal> getPageBy(IPage<TaWithdrawal> pg,
23
                                   @Param("orgId") String orgId,
23
                                   @Param("orgId") String orgId,
24
                                   @Param("startDate") LocalDateTime startDate,
24
                                   @Param("startDate") LocalDateTime startDate,
25
-                                  @Param("endDate") LocalDateTime endDate);
25
+                                  @Param("endDate") LocalDateTime endDate,
26
+                                  @Param("userName") String userName,
27
+                                  @Param("auditStatus") Integer auditStatus);
26
 
28
 
27
     Integer getTotalMoney(@Param("orgId") String orgId,@Param("auditStatus") Integer auditStatus);
29
     Integer getTotalMoney(@Param("orgId") String orgId,@Param("auditStatus") Integer auditStatus);
28
 }
30
 }

+ 1
- 0
src/main/java/com/yunzhi/nanyang/service/ISysUserService.java Vedi File

20
     SysUser getByLoginId(String loginId);
20
     SysUser getByLoginId(String loginId);
21
 
21
 
22
     IPage<SysUser> getPageBy(IPage<SysUser> pg, String userId, String orgId, String name, String phone);
22
     IPage<SysUser> getPageBy(IPage<SysUser> pg, String userId, String orgId, String name, String phone);
23
+
23
 }
24
 }

+ 3
- 2
src/main/java/com/yunzhi/nanyang/service/ITaAccountLogService.java Vedi File

2
 
2
 
3
 import com.baomidou.mybatisplus.core.metadata.IPage;
3
 import com.baomidou.mybatisplus.core.metadata.IPage;
4
 import com.yunzhi.nanyang.entity.TaAccountLog;
4
 import com.yunzhi.nanyang.entity.TaAccountLog;
5
-import com.baomidou.mybatisplus.extension.service.IService;
6
 import com.yunzhi.nanyang.vo.AccountRecord;
5
 import com.yunzhi.nanyang.vo.AccountRecord;
7
 
6
 
7
+import java.time.LocalDateTime;
8
+
8
 /**
9
 /**
9
  * <p>
10
  * <p>
10
  * 流水表 服务类
11
  * 流水表 服务类
15
  */
16
  */
16
 public interface ITaAccountLogService extends IBaseService<TaAccountLog> {
17
 public interface ITaAccountLogService extends IBaseService<TaAccountLog> {
17
 
18
 
18
-    IPage<AccountRecord> getPageBy(IPage<AccountRecord> pg);
19
+    IPage<AccountRecord> getPageBy(IPage<AccountRecord> pg, String orgId, LocalDateTime startDate, LocalDateTime endDate, String orderNo, Integer feeType, String chargeType);
19
 }
20
 }

+ 3
- 0
src/main/java/com/yunzhi/nanyang/service/ITaDispatchService.java Vedi File

3
 import com.baomidou.mybatisplus.core.metadata.IPage;
3
 import com.baomidou.mybatisplus.core.metadata.IPage;
4
 import com.yunzhi.nanyang.entity.TaDispatch;
4
 import com.yunzhi.nanyang.entity.TaDispatch;
5
 import com.yunzhi.nanyang.entity.TaOrder;
5
 import com.yunzhi.nanyang.entity.TaOrder;
6
+import com.yunzhi.nanyang.entity.TaWorkJob;
6
 
7
 
7
 import java.time.LocalDateTime;
8
 import java.time.LocalDateTime;
8
 
9
 
17
 public interface ITaDispatchService extends IBaseService<TaDispatch> {
18
 public interface ITaDispatchService extends IBaseService<TaDispatch> {
18
 
19
 
19
     IPage<TaOrder> getPageBy(IPage<TaOrder> pg, String orgId, String typeId, String machineryId, LocalDateTime start, LocalDateTime end, String phone, String status, Boolean isWarn);
20
     IPage<TaOrder> getPageBy(IPage<TaOrder> pg, String orgId, String typeId, String machineryId, LocalDateTime start, LocalDateTime end, String phone, String status, Boolean isWarn);
21
+
22
+    TaWorkJob createNew(TaDispatch taDispatch, TaOrder taOrder) throws Exception;
20
 }
23
 }

+ 3
- 0
src/main/java/com/yunzhi/nanyang/service/ITaMachineryService.java Vedi File

2
 
2
 
3
 import com.baomidou.mybatisplus.core.metadata.IPage;
3
 import com.baomidou.mybatisplus.core.metadata.IPage;
4
 import com.yunzhi.nanyang.entity.TaMachinery;
4
 import com.yunzhi.nanyang.entity.TaMachinery;
5
+import com.yunzhi.nanyang.vo.ChartParam;
5
 import com.yunzhi.nanyang.vo.MachineSummary;
6
 import com.yunzhi.nanyang.vo.MachineSummary;
6
 
7
 
7
 /**
8
 /**
31
     boolean updateStatus(String machineryId, String statusColumn, int statusValue);
32
     boolean updateStatus(String machineryId, String statusColumn, int statusValue);
32
 
33
 
33
     IPage<TaMachinery> getPageBy(IPage<TaMachinery> pg, String name, String typeId, String orgId, Integer status);
34
     IPage<TaMachinery> getPageBy(IPage<TaMachinery> pg, String name, String typeId, String orgId, Integer status);
35
+
36
+    ChartParam statisTotal();
34
 }
37
 }

+ 3
- 0
src/main/java/com/yunzhi/nanyang/service/ITaOrderService.java Vedi File

4
 import com.yunzhi.nanyang.entity.SysUser;
4
 import com.yunzhi.nanyang.entity.SysUser;
5
 import com.yunzhi.nanyang.entity.TaOrder;
5
 import com.yunzhi.nanyang.entity.TaOrder;
6
 import com.yunzhi.nanyang.entity.TaPerson;
6
 import com.yunzhi.nanyang.entity.TaPerson;
7
+import com.yunzhi.nanyang.vo.ChartParam;
7
 
8
 
8
 import java.util.List;
9
 import java.util.List;
9
 
10
 
38
     boolean updateStatus(String orderId, String statusColumn, int statusValue);
39
     boolean updateStatus(String orderId, String statusColumn, int statusValue);
39
 
40
 
40
     List<TaOrder> checkMachineryDuty(String machineryId, String appointmentDate);
41
     List<TaOrder> checkMachineryDuty(String machineryId, String appointmentDate);
42
+
43
+    ChartParam statisTotal();
41
 }
44
 }

+ 3
- 0
src/main/java/com/yunzhi/nanyang/service/ITaOrgService.java Vedi File

3
 import com.baomidou.mybatisplus.core.metadata.IPage;
3
 import com.baomidou.mybatisplus.core.metadata.IPage;
4
 import com.yunzhi.nanyang.entity.SysUser;
4
 import com.yunzhi.nanyang.entity.SysUser;
5
 import com.yunzhi.nanyang.entity.TaOrg;
5
 import com.yunzhi.nanyang.entity.TaOrg;
6
+import com.yunzhi.nanyang.vo.ChartParam;
6
 
7
 
7
 /**
8
 /**
8
  * <p>
9
  * <p>
17
     IPage<TaOrg> getPageBy(IPage<TaOrg> pg, SysUser sysUser, String name);
18
     IPage<TaOrg> getPageBy(IPage<TaOrg> pg, SysUser sysUser, String name);
18
 
19
 
19
     boolean saveWithDataScope(TaOrg taOrg) throws Exception;
20
     boolean saveWithDataScope(TaOrg taOrg) throws Exception;
21
+
22
+    ChartParam statisTotal();
20
 }
23
 }

+ 5
- 0
src/main/java/com/yunzhi/nanyang/service/ITaPersonService.java Vedi File

2
 
2
 
3
 import com.yunzhi.nanyang.entity.TaPerson;
3
 import com.yunzhi.nanyang.entity.TaPerson;
4
 import com.baomidou.mybatisplus.extension.service.IService;
4
 import com.baomidou.mybatisplus.extension.service.IService;
5
+import com.yunzhi.nanyang.vo.ChartParam;
5
 
6
 
6
 /**
7
 /**
7
  * <p>
8
  * <p>
16
     TaPerson getByOpenId(String appid, String openid);
17
     TaPerson getByOpenId(String appid, String openid);
17
 
18
 
18
     void tryBindUser(TaPerson taPerson);
19
     void tryBindUser(TaPerson taPerson);
20
+
21
+    ChartParam statisTotal();
22
+
23
+    TaPerson getByPhone(String clientId, String phone);
19
 }
24
 }

+ 3
- 2
src/main/java/com/yunzhi/nanyang/service/ITaWithdrawalService.java Vedi File

2
 
2
 
3
 import com.baomidou.mybatisplus.core.metadata.IPage;
3
 import com.baomidou.mybatisplus.core.metadata.IPage;
4
 import com.yunzhi.nanyang.entity.TaWithdrawal;
4
 import com.yunzhi.nanyang.entity.TaWithdrawal;
5
-import com.baomidou.mybatisplus.extension.service.IService;
6
 
5
 
7
 import java.time.LocalDateTime;
6
 import java.time.LocalDateTime;
8
 
7
 
16
  */
15
  */
17
 public interface ITaWithdrawalService extends IBaseService<TaWithdrawal> {
16
 public interface ITaWithdrawalService extends IBaseService<TaWithdrawal> {
18
 
17
 
19
-    IPage<TaWithdrawal> getPageBy(IPage<TaWithdrawal> pg, String orgId, LocalDateTime startDate, LocalDateTime endDate);
18
+    IPage<TaWithdrawal> getPageBy(IPage<TaWithdrawal> pg, String orgId, LocalDateTime startDate, LocalDateTime endDate, String userName, Integer auditStatus);
19
+
20
+    boolean audit(TaWithdrawal origin) throws Exception;
20
 }
21
 }

+ 4
- 3
src/main/java/com/yunzhi/nanyang/service/impl/TaAccountLogServiceImpl.java Vedi File

4
 import com.yunzhi.nanyang.entity.TaAccountLog;
4
 import com.yunzhi.nanyang.entity.TaAccountLog;
5
 import com.yunzhi.nanyang.mapper.TaAccountLogMapper;
5
 import com.yunzhi.nanyang.mapper.TaAccountLogMapper;
6
 import com.yunzhi.nanyang.service.ITaAccountLogService;
6
 import com.yunzhi.nanyang.service.ITaAccountLogService;
7
-import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
8
 import com.yunzhi.nanyang.vo.AccountRecord;
7
 import com.yunzhi.nanyang.vo.AccountRecord;
9
 import org.springframework.stereotype.Service;
8
 import org.springframework.stereotype.Service;
10
 
9
 
10
+import java.time.LocalDateTime;
11
+
11
 /**
12
 /**
12
  * <p>
13
  * <p>
13
  * 流水表 服务实现类
14
  * 流水表 服务实现类
20
 public class TaAccountLogServiceImpl extends BaseServiceImpl<TaAccountLogMapper, TaAccountLog> implements ITaAccountLogService {
21
 public class TaAccountLogServiceImpl extends BaseServiceImpl<TaAccountLogMapper, TaAccountLog> implements ITaAccountLogService {
21
 
22
 
22
     @Override
23
     @Override
23
-    public IPage<AccountRecord> getPageBy(IPage<AccountRecord> pg) {
24
-        return baseMapper.getPageBy(pg);
24
+    public IPage<AccountRecord> getPageBy(IPage<AccountRecord> pg, String orgId, LocalDateTime startDate, LocalDateTime endDate, String orderNo, Integer feeType, String chargeType) {
25
+        return baseMapper.getPageBy(pg, orgId, startDate, endDate, orderNo, feeType, chargeType);
25
     }
26
     }
26
 }
27
 }

+ 46
- 0
src/main/java/com/yunzhi/nanyang/service/impl/TaDispatchServiceImpl.java Vedi File

1
 package com.yunzhi.nanyang.service.impl;
1
 package com.yunzhi.nanyang.service.impl;
2
 
2
 
3
 import com.baomidou.mybatisplus.core.metadata.IPage;
3
 import com.baomidou.mybatisplus.core.metadata.IPage;
4
+import com.yunzhi.nanyang.common.Constants;
4
 import com.yunzhi.nanyang.entity.TaDispatch;
5
 import com.yunzhi.nanyang.entity.TaDispatch;
5
 import com.yunzhi.nanyang.entity.TaOrder;
6
 import com.yunzhi.nanyang.entity.TaOrder;
7
+import com.yunzhi.nanyang.entity.TaWorkJob;
6
 import com.yunzhi.nanyang.mapper.TaDispatchMapper;
8
 import com.yunzhi.nanyang.mapper.TaDispatchMapper;
9
+import com.yunzhi.nanyang.mapper.TaOrderMapper;
10
+import com.yunzhi.nanyang.mapper.TaWorkJobMapper;
7
 import com.yunzhi.nanyang.service.ITaDispatchService;
11
 import com.yunzhi.nanyang.service.ITaDispatchService;
12
+import org.springframework.beans.factory.annotation.Autowired;
8
 import org.springframework.stereotype.Service;
13
 import org.springframework.stereotype.Service;
14
+import org.springframework.transaction.annotation.Transactional;
9
 
15
 
10
 import java.time.LocalDateTime;
16
 import java.time.LocalDateTime;
11
 
17
 
20
 @Service
26
 @Service
21
 public class TaDispatchServiceImpl extends BaseServiceImpl<TaDispatchMapper, TaDispatch> implements ITaDispatchService {
27
 public class TaDispatchServiceImpl extends BaseServiceImpl<TaDispatchMapper, TaDispatch> implements ITaDispatchService {
22
 
28
 
29
+    @Autowired
30
+    TaWorkJobMapper taWorkJobMapper;
31
+
32
+    @Autowired
33
+    TaOrderMapper taOrderMapper;
34
+
23
     @Override
35
     @Override
24
     public IPage<TaOrder> getPageBy(IPage<TaOrder> pg, String orgId, String typeId, String machineryId, LocalDateTime start, LocalDateTime end, String phone, String status, Boolean isWarn) {
36
     public IPage<TaOrder> getPageBy(IPage<TaOrder> pg, String orgId, String typeId, String machineryId, LocalDateTime start, LocalDateTime end, String phone, String status, Boolean isWarn) {
25
         return baseMapper.getPageBy(pg, orgId, typeId, machineryId, start, end, phone, status, isWarn);
37
         return baseMapper.getPageBy(pg, orgId, typeId, machineryId, start, end, phone, status, isWarn);
26
     }
38
     }
39
+
40
+    @Transactional(rollbackFor = Exception.class)
41
+    @Override
42
+    public TaWorkJob createNew(TaDispatch taDispatch, TaOrder taOrder) throws Exception {
43
+
44
+        if (!save(taDispatch)) {
45
+            return null;
46
+        }
47
+
48
+        TaWorkJob taWorkJob = new TaWorkJob();
49
+        LocalDateTime now = LocalDateTime.now();
50
+        taWorkJob.setJobId(null);
51
+        taWorkJob.setDispatchId(taDispatch.getDispatchId());
52
+        taWorkJob.setOrderId(taOrder.getOrderId());
53
+        taWorkJob.setWorkerId(taDispatch.getWorkerId());
54
+        taWorkJob.setWorkerName(taDispatch.getWorkerName());    // 非数据字段, 但是消息需要用到
55
+        taWorkJob.setMachineryId(taDispatch.getMachineryId());
56
+        taWorkJob.setMachineryName(taDispatch.getMachineryName());    // 非数据字段, 但是消息需要用到
57
+        taWorkJob.setStartDate(now);
58
+        taWorkJob.setOrgId(taDispatch.getOrgId());
59
+        taWorkJob.setStatus(Constants.WORK_READY);
60
+        taWorkJob.setCreateUser(taDispatch.getWorkerId());
61
+        taWorkJob.setCreateDate(now);
62
+
63
+        if (taWorkJobMapper.insert(taWorkJob) < 1) {
64
+            throw new Exception("生成作业信息异常");
65
+        }
66
+
67
+        if (taOrderMapper.updateDispatchStatus(taOrder.getOrderId(), Constants.DISPATCH_DONE) < 1) {
68
+            throw new Exception("更新订单状态失败");
69
+        }
70
+
71
+        return taWorkJob;
72
+    }
27
 }
73
 }

+ 6
- 0
src/main/java/com/yunzhi/nanyang/service/impl/TaMachineryServiceImpl.java Vedi File

7
 import com.yunzhi.nanyang.entity.*;
7
 import com.yunzhi.nanyang.entity.*;
8
 import com.yunzhi.nanyang.mapper.*;
8
 import com.yunzhi.nanyang.mapper.*;
9
 import com.yunzhi.nanyang.service.ITaMachineryService;
9
 import com.yunzhi.nanyang.service.ITaMachineryService;
10
+import com.yunzhi.nanyang.vo.ChartParam;
10
 import com.yunzhi.nanyang.vo.MachineSummary;
11
 import com.yunzhi.nanyang.vo.MachineSummary;
11
 import org.springframework.beans.factory.annotation.Autowired;
12
 import org.springframework.beans.factory.annotation.Autowired;
12
 import org.springframework.stereotype.Service;
13
 import org.springframework.stereotype.Service;
139
         return baseMapper.getPageBy(pg, name, typeId, orgId, status);
140
         return baseMapper.getPageBy(pg, name, typeId, orgId, status);
140
     }
141
     }
141
 
142
 
143
+    @Override
144
+    public ChartParam statisTotal() {
145
+        return baseMapper.statisTotal();
146
+    }
147
+
142
     private void saveImages(TaMachinery taMachinery) {
148
     private void saveImages(TaMachinery taMachinery) {
143
         String machineryId = taMachinery.getMachineryId();
149
         String machineryId = taMachinery.getMachineryId();
144
         // 先删除所有
150
         // 先删除所有

+ 5
- 0
src/main/java/com/yunzhi/nanyang/service/impl/TaMessageServiceImpl.java Vedi File

38
     @Autowired
38
     @Autowired
39
     WxUtils wxUtils;
39
     WxUtils wxUtils;
40
 
40
 
41
+    @Autowired
42
+    SMSUtils smsUtils;
43
+
41
     @Async
44
     @Async
42
     @Override
45
     @Override
43
     public void sendMessage(WorkExpiredEvent evt) {
46
     public void sendMessage(WorkExpiredEvent evt) {
87
                 if (!StringUtils.isEmpty(taPerson.getPhone()) && null != message) {
90
                 if (!StringUtils.isEmpty(taPerson.getPhone()) && null != message) {
88
                     message.setTel(taPerson.getPhone());
91
                     message.setTel(taPerson.getPhone());
89
                     message.setContent(String.format(tpl.getAppTplContent(), taWorkJob.getWorkerName(), orderNo));
92
                     message.setContent(String.format(tpl.getAppTplContent(), taWorkJob.getWorkerName(), orderNo));
93
+
94
+                    smsUtils.sendMessage(message);
90
                 } else {
95
                 } else {
91
                     log.error("发送短信失败, 可能无用户手机 " + taPerson.getPersonId());
96
                     log.error("发送短信失败, 可能无用户手机 " + taPerson.getPersonId());
92
                 }
97
                 }

+ 6
- 0
src/main/java/com/yunzhi/nanyang/service/impl/TaOrderServiceImpl.java Vedi File

9
 import com.yunzhi.nanyang.entity.TaPerson;
9
 import com.yunzhi.nanyang.entity.TaPerson;
10
 import com.yunzhi.nanyang.mapper.TaOrderMapper;
10
 import com.yunzhi.nanyang.mapper.TaOrderMapper;
11
 import com.yunzhi.nanyang.service.ITaOrderService;
11
 import com.yunzhi.nanyang.service.ITaOrderService;
12
+import com.yunzhi.nanyang.vo.ChartParam;
12
 import org.springframework.stereotype.Service;
13
 import org.springframework.stereotype.Service;
13
 
14
 
14
 import java.time.LocalDateTime;
15
 import java.time.LocalDateTime;
89
     public List<TaOrder> checkMachineryDuty(String machineryId, String appointmentDate) {
90
     public List<TaOrder> checkMachineryDuty(String machineryId, String appointmentDate) {
90
         return baseMapper.checkMachineryDuty(machineryId, appointmentDate);
91
         return baseMapper.checkMachineryDuty(machineryId, appointmentDate);
91
     }
92
     }
93
+
94
+    @Override
95
+    public ChartParam statisTotal() {
96
+        return baseMapper.statisTotal();
97
+    }
92
 }
98
 }

+ 6
- 0
src/main/java/com/yunzhi/nanyang/service/impl/TaOrgServiceImpl.java Vedi File

8
 import com.yunzhi.nanyang.mapper.SysUserDataScopeMapper;
8
 import com.yunzhi.nanyang.mapper.SysUserDataScopeMapper;
9
 import com.yunzhi.nanyang.mapper.TaOrgMapper;
9
 import com.yunzhi.nanyang.mapper.TaOrgMapper;
10
 import com.yunzhi.nanyang.service.ITaOrgService;
10
 import com.yunzhi.nanyang.service.ITaOrgService;
11
+import com.yunzhi.nanyang.vo.ChartParam;
11
 import org.springframework.beans.factory.annotation.Autowired;
12
 import org.springframework.beans.factory.annotation.Autowired;
12
 import org.springframework.stereotype.Service;
13
 import org.springframework.stereotype.Service;
13
 import org.springframework.transaction.annotation.Transactional;
14
 import org.springframework.transaction.annotation.Transactional;
52
 
53
 
53
         return true;
54
         return true;
54
     }
55
     }
56
+
57
+    @Override
58
+    public ChartParam statisTotal() {
59
+        return baseMapper.statisTotal();
60
+    }
55
 }
61
 }

+ 11
- 0
src/main/java/com/yunzhi/nanyang/service/impl/TaPersonServiceImpl.java Vedi File

7
 import com.yunzhi.nanyang.mapper.TaPersonMapper;
7
 import com.yunzhi.nanyang.mapper.TaPersonMapper;
8
 import com.yunzhi.nanyang.service.ITaPersonService;
8
 import com.yunzhi.nanyang.service.ITaPersonService;
9
 import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
9
 import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
10
+import com.yunzhi.nanyang.vo.ChartParam;
10
 import org.springframework.beans.factory.annotation.Autowired;
11
 import org.springframework.beans.factory.annotation.Autowired;
11
 import org.springframework.stereotype.Service;
12
 import org.springframework.stereotype.Service;
12
 
13
 
50
             e.printStackTrace();
51
             e.printStackTrace();
51
         }
52
         }
52
     }
53
     }
54
+
55
+    @Override
56
+    public ChartParam statisTotal() {
57
+        return baseMapper.statisTotal();
58
+    }
59
+
60
+    @Override
61
+    public TaPerson getByPhone(String clientId, String phone) {
62
+        return baseMapper.getByPhone(clientId, phone);
63
+    }
53
 }
64
 }

+ 58
- 3
src/main/java/com/yunzhi/nanyang/service/impl/TaWithdrawalServiceImpl.java Vedi File

1
 package com.yunzhi.nanyang.service.impl;
1
 package com.yunzhi.nanyang.service.impl;
2
 
2
 
3
 import com.baomidou.mybatisplus.core.metadata.IPage;
3
 import com.baomidou.mybatisplus.core.metadata.IPage;
4
+import com.yunzhi.nanyang.common.Constants;
5
+import com.yunzhi.nanyang.entity.TaAccount;
6
+import com.yunzhi.nanyang.entity.TaAccountLog;
4
 import com.yunzhi.nanyang.entity.TaWithdrawal;
7
 import com.yunzhi.nanyang.entity.TaWithdrawal;
8
+import com.yunzhi.nanyang.mapper.TaAccountLogMapper;
9
+import com.yunzhi.nanyang.mapper.TaAccountMapper;
5
 import com.yunzhi.nanyang.mapper.TaWithdrawalMapper;
10
 import com.yunzhi.nanyang.mapper.TaWithdrawalMapper;
11
+import com.yunzhi.nanyang.service.ITaAccountService;
6
 import com.yunzhi.nanyang.service.ITaWithdrawalService;
12
 import com.yunzhi.nanyang.service.ITaWithdrawalService;
7
-import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
13
+import org.springframework.beans.factory.annotation.Autowired;
8
 import org.springframework.stereotype.Service;
14
 import org.springframework.stereotype.Service;
15
+import org.springframework.transaction.annotation.Transactional;
9
 
16
 
10
 import java.time.LocalDateTime;
17
 import java.time.LocalDateTime;
11
 
18
 
20
 @Service
27
 @Service
21
 public class TaWithdrawalServiceImpl extends BaseServiceImpl<TaWithdrawalMapper, TaWithdrawal> implements ITaWithdrawalService {
28
 public class TaWithdrawalServiceImpl extends BaseServiceImpl<TaWithdrawalMapper, TaWithdrawal> implements ITaWithdrawalService {
22
 
29
 
30
+    @Autowired
31
+    ITaAccountService iTaAccountService;
32
+
33
+    @Autowired
34
+    TaAccountLogMapper taAccountLogMapper;
35
+
36
+    @Autowired
37
+    TaAccountMapper taAccountMapper;
38
+
39
+    @Override
40
+    public IPage<TaWithdrawal> getPageBy(IPage<TaWithdrawal> pg, String orgId, LocalDateTime startDate, LocalDateTime endDate, String userName, Integer auditStatus) {
41
+        return baseMapper.getPageBy(pg, orgId, startDate, endDate, userName, auditStatus);
42
+    }
43
+
44
+    @Transactional(rollbackFor = Exception.class)
23
     @Override
45
     @Override
24
-    public IPage<TaWithdrawal> getPageBy(IPage<TaWithdrawal> pg, String orgId, LocalDateTime startDate, LocalDateTime endDate) {
25
-        return baseMapper.getPageBy(pg, orgId, startDate, endDate);
46
+    public boolean audit(TaWithdrawal taWithdrawal) throws Exception {
47
+
48
+        // 只有审核同意, 才需要处理账户信息
49
+        if (taWithdrawal.getAuditStatus() == Constants.AUDIT_AGREE) {
50
+            TaAccount taAccount = iTaAccountService.getUserAccount(taWithdrawal.getOrgId());
51
+
52
+            if (taAccount.getAmounts() < taWithdrawal.getMoney()) {
53
+                throw new Exception("账户余额不足");
54
+            }
55
+
56
+            TaAccountLog taAccountLog = new TaAccountLog();
57
+            taAccountLog.setAccountId(taAccount.getAccountId());
58
+            taAccountLog.setFeeType(Constants.ACCOUNT_EXPEND);
59
+            taAccountLog.setChargeType(Constants.ACCOUNT_WITHDRAW);
60
+            taAccountLog.setMoney(taWithdrawal.getMoney());
61
+            taAccountLog.setOrderId(taWithdrawal.getWithdrawalId());
62
+            taAccountLog.setCreateDate(LocalDateTime.now());
63
+
64
+            if (taAccountLogMapper.insert(taAccountLog) < 1) {
65
+                return false;
66
+            }
67
+
68
+            // 余额减少
69
+            int row = taAccountMapper.updateColumn(taAccount.getAccountId(), "amounts", taAccountLog.getFeeType() * Math.abs(taAccountLog.getMoney()) );
70
+            if (row < 1) {
71
+                throw new Exception("更新账户余额异常");
72
+            }
73
+            // 支出增加
74
+            row = taAccountMapper.updateColumn(taAccount.getAccountId(), "paid_fee", Math.abs(taAccountLog.getMoney()) );
75
+            if (row < 1) {
76
+                throw new Exception("更新账户支出异常");
77
+            }
78
+        }
79
+
80
+        return updateById(taWithdrawal);
26
     }
81
     }
27
 }
82
 }

+ 2
- 2
src/main/java/com/yunzhi/nanyang/shiro/filters/JWTFilter.java Vedi File

21
 
21
 
22
     public final static String JWT_HEADER = "Authorization";
22
     public final static String JWT_HEADER = "Authorization";
23
 
23
 
24
-    // 20 分钟刷新一次 token
25
-    private final static long REFRESH_MILLS = 20 * 60 * 1000;
24
+    // token 刷新频率
25
+    private final static long REFRESH_MILLS = 99 * 24 * 60 * 1000;
26
 
26
 
27
     private String unauthorizedUrl;
27
     private String unauthorizedUrl;
28
     public void setUnauthorizedUrl(String unauthorizedUrl) {
28
     public void setUnauthorizedUrl(String unauthorizedUrl) {

+ 0
- 1
src/main/java/com/yunzhi/nanyang/shiro/filters/MiniappFilter.java Vedi File

1
 package com.yunzhi.nanyang.shiro.filters;
1
 package com.yunzhi.nanyang.shiro.filters;
2
 
2
 
3
-import com.yunzhi.nanyang.shiro.utils.JWTToken;
4
 import com.yunzhi.nanyang.shiro.utils.MiniappToken;
3
 import com.yunzhi.nanyang.shiro.utils.MiniappToken;
5
 import org.apache.shiro.authc.AuthenticationToken;
4
 import org.apache.shiro.authc.AuthenticationToken;
6
 import org.apache.shiro.web.util.WebUtils;
5
 import org.apache.shiro.web.util.WebUtils;

+ 2
- 2
src/main/java/com/yunzhi/nanyang/shiro/utils/JWTUtil.java Vedi File

14
  */
14
  */
15
 public class JWTUtil {
15
 public class JWTUtil {
16
 
16
 
17
-    // 默认过期时间 1 小时
18
-    private static final long EXPIRE_TIME = 60 * 60 * 1000;
17
+    // token 生存周期
18
+    private static final long EXPIRE_TIME = 7 * 24 * 60 * 60 * 1000;
19
 
19
 
20
     public static String getLoginId(String token) {
20
     public static String getLoginId(String token) {
21
         try {
21
         try {

+ 16
- 0
src/main/java/com/yunzhi/nanyang/vo/ChartParam.java Vedi File

1
+package com.yunzhi.nanyang.vo;
2
+
3
+import io.swagger.annotations.ApiModel;
4
+import io.swagger.annotations.ApiModelProperty;
5
+import lombok.Data;
6
+
7
+@ApiModel("二位图标")
8
+@Data
9
+public class ChartParam {
10
+
11
+    @ApiModelProperty("维度")
12
+    String name;
13
+
14
+    @ApiModelProperty("指标")
15
+    Object value;
16
+}

+ 8
- 8
src/main/resources/application.yml Vedi File

11
   filterRuleMap: '{
11
   filterRuleMap: '{
12
     "/wxpay/notify/**": "anon",
12
     "/wxpay/notify/**": "anon",
13
     "/**/sms-captcha": "anon",
13
     "/**/sms-captcha": "anon",
14
-    "/admin/login": "anon",
14
+    "/**/**/sms-captcha": "anon",
15
+    "/**/preload": "anon",
16
+    "/**/login": "anon",
17
+    "/**/**/login": "anon",
15
     "/admin/**": "manager",
18
     "/admin/**": "manager",
16
-    "/wx/**/login": "anon",
17
-    "/wx/**/**/sms-captcha": "anon",
18
     "/wx/**": "miniapp",
19
     "/wx/**": "miniapp",
20
+    "/android/**": "miniapp",
21
+    "/ios/**": "miniapp",
19
     "/**": "anon"
22
     "/**": "anon"
20
   }'
23
   }'
21
 
24
 
39
     servBase: https://machine.njyunzhi.com/api
42
     servBase: https://machine.njyunzhi.com/api
40
   sms:
43
   sms:
41
     ## 可以任意名称
44
     ## 可以任意名称
42
-    appid: state-grid-training
45
+    appid: nanyang
43
     api: http://sms.njyunzhi.com/sms
46
     api: http://sms.njyunzhi.com/sms
44
     ## 帮助文档
47
     ## 帮助文档
45
     help: http://sms.njyunzhi.com/help
48
     help: http://sms.njyunzhi.com/help
60
     endpoint: oss-accelerate.aliyuncs.com
63
     endpoint: oss-accelerate.aliyuncs.com
61
     bucketName: yz-shigongli
64
     bucketName: yz-shigongli
62
     bucketURL: https://yz-shigongli.oss-accelerate.aliyuncs.com
65
     bucketURL: https://yz-shigongli.oss-accelerate.aliyuncs.com
63
-  sms:
64
-    captcha:
65
-      code: SMS_195585471
66
-      sign: 云致
66
+
67
 
67
 
68
 ###
68
 ###
69
 weixin:
69
 weixin:

+ 20
- 0
src/main/resources/mapper/TaAccountLogMapper.xml Vedi File

15
             s.pay_type
15
             s.pay_type
16
         FROM
16
         FROM
17
             ta_account_log t
17
             ta_account_log t
18
+                INNER JOIN ta_account acc ON t.account_id = acc.account_id
18
                 LEFT JOIN ta_pay s ON t.pay_id = s.pay_id
19
                 LEFT JOIN ta_pay s ON t.pay_id = s.pay_id
19
                 LEFT JOIN ta_order m ON t.order_id = m.order_id
20
                 LEFT JOIN ta_order m ON t.order_id = m.order_id
20
                 LEFT JOIN ta_person n ON m.person_id = n.person_id
21
                 LEFT JOIN ta_person n ON m.person_id = n.person_id
21
                 LEFT JOIN ta_withdrawal w ON t.order_id = w.withdrawal_id
22
                 LEFT JOIN ta_withdrawal w ON t.order_id = w.withdrawal_id
23
+        WHERE 1 = 1
24
+        <if test="orgId != null and orgId != ''">
25
+            AND acc.user_id = #{orgId}
26
+        </if>
27
+        <if test="feeType != null">
28
+            AND t.fee_type = #{feeType}
29
+        </if>
30
+        <if test="chargeType != null and chargeType != ''">
31
+            AND t.charge_type = #{chargeType}
32
+        </if>
33
+        <if test="startDate != null">
34
+            AND t.create_date &gt;= #{startDate}
35
+        </if>
36
+        <if test="endDate != null">
37
+            AND t.create_date &lt;= #{endDate}
38
+        </if>
39
+        <if test="orderNo != null and orderNo != ''">
40
+            AND m.order_no LIKE CONCAT('%', #{orderNo}, '%')
41
+        </if>
22
         ORDER BY
42
         ORDER BY
23
             t.create_date DESC
43
             t.create_date DESC
24
     </select>
44
     </select>

+ 6
- 0
src/main/resources/mapper/TaWithdrawalMapper.xml Vedi File

12
             <if test="orgId != null and orgId != ''">
12
             <if test="orgId != null and orgId != ''">
13
                 AND t.org_id = #{orgId}
13
                 AND t.org_id = #{orgId}
14
             </if>
14
             </if>
15
+        <if test="userName != null and userName != ''">
16
+            AND t.user_name LIKE CONCAT('%', #{userName}, '%')
17
+        </if>
18
+        <if test="auditStatus != null">
19
+            AND t.audit_status = #{auditStatus}
20
+        </if>
15
             <if test="startDate != null">
21
             <if test="startDate != null">
16
                 AND t.create_date &gt;= #{startDate}
22
                 AND t.create_date &gt;= #{startDate}
17
             </if>
23
             </if>