张延森 3 vuotta sitten
vanhempi
commit
fd55d08f71
34 muutettua tiedostoa jossa 949 lisäystä ja 171 poistoa
  1. 8
    0
      src/main/java/com/yunzhi/nanyang/common/Constants.java
  2. 13
    13
      src/main/java/com/yunzhi/nanyang/config/CorsConfig.java
  3. 30
    0
      src/main/java/com/yunzhi/nanyang/config/DateConverterConfig.java
  4. 71
    0
      src/main/java/com/yunzhi/nanyang/config/JacksonConfig.java
  5. 129
    39
      src/main/java/com/yunzhi/nanyang/controller/TaDispatchController.java
  6. 98
    51
      src/main/java/com/yunzhi/nanyang/controller/TaEvaluationController.java
  7. 4
    4
      src/main/java/com/yunzhi/nanyang/controller/TaMachineryController.java
  8. 51
    1
      src/main/java/com/yunzhi/nanyang/controller/TaNewsController.java
  9. 98
    12
      src/main/java/com/yunzhi/nanyang/controller/TaOrderController.java
  10. 94
    37
      src/main/java/com/yunzhi/nanyang/controller/TaWorkJobController.java
  11. 16
    1
      src/main/java/com/yunzhi/nanyang/entity/TaDispatch.java
  12. 7
    1
      src/main/java/com/yunzhi/nanyang/entity/TaEvaluation.java
  13. 3
    0
      src/main/java/com/yunzhi/nanyang/entity/TaMessage.java
  14. 19
    0
      src/main/java/com/yunzhi/nanyang/entity/TaOrder.java
  15. 31
    1
      src/main/java/com/yunzhi/nanyang/entity/TaWorkJob.java
  16. 15
    0
      src/main/java/com/yunzhi/nanyang/event/WorkExpiredEvent.java
  17. 18
    0
      src/main/java/com/yunzhi/nanyang/event/listener/WorkExpiredEventListener.java
  18. 7
    1
      src/main/java/com/yunzhi/nanyang/exception/GlobalExceptionHandler.java
  19. 4
    1
      src/main/java/com/yunzhi/nanyang/mapper/TaMachineryMapper.java
  20. 12
    0
      src/main/java/com/yunzhi/nanyang/mapper/TaOrderMapper.java
  21. 3
    0
      src/main/java/com/yunzhi/nanyang/mapper/TaWorkJobMapper.java
  22. 1
    1
      src/main/java/com/yunzhi/nanyang/service/ITaMachineryService.java
  23. 2
    0
      src/main/java/com/yunzhi/nanyang/service/ITaMessageService.java
  24. 9
    1
      src/main/java/com/yunzhi/nanyang/service/ITaOrderService.java
  25. 6
    0
      src/main/java/com/yunzhi/nanyang/service/ITaWorkJobService.java
  26. 2
    2
      src/main/java/com/yunzhi/nanyang/service/impl/TaMachineryServiceImpl.java
  27. 8
    0
      src/main/java/com/yunzhi/nanyang/service/impl/TaMessageServiceImpl.java
  28. 30
    1
      src/main/java/com/yunzhi/nanyang/service/impl/TaOrderServiceImpl.java
  29. 33
    0
      src/main/java/com/yunzhi/nanyang/service/impl/TaWorkJobServiceImpl.java
  30. 16
    0
      src/main/java/com/yunzhi/nanyang/task/WorkExpire.java
  31. 3
    0
      src/main/resources/application.yml
  32. 12
    4
      src/main/resources/mapper/TaMachineryMapper.xml
  33. 72
    0
      src/main/resources/mapper/TaOrderMapper.xml
  34. 24
    0
      src/main/resources/mapper/TaWorkJobMapper.xml

+ 8
- 0
src/main/java/com/yunzhi/nanyang/common/Constants.java Näytä tiedosto

@@ -20,6 +20,14 @@ public class Constants {
20 20
     public final static int PAY_PAID = 1;  // 已支付
21 21
     public final static int PAY_REFUND = -1;  // 已退款
22 22
 
23
+    // 是否调度
24
+    public final static int DISPATCH_READY = 0; // 待调度
25
+    public final static int DISPATCH_DONE = 1; // 已调度
26
+
23 27
     // 工作状态
24 28
     public final static int WORK_READY = 0;   // 预备中
29
+    public final static int WORK_DOING = 1;   // 工作中
30
+    public final static int WORK_PAUSE = 2;   // 暂停
31
+    public final static int WORK_DONE = 3;   // 已完成
32
+
25 33
 }

+ 13
- 13
src/main/java/com/yunzhi/nanyang/config/CorsConfig.java Näytä tiedosto

@@ -8,19 +8,19 @@ import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;
8 8
 public class CorsConfig implements WebMvcConfigurer {
9 9
     @Override
10 10
     public void addCorsMappings(CorsRegistry registry) {
11
-        //添加映射路径
12
-        registry.addMapping("/**")
13
-                //是否发送Cookie
14
-                .allowCredentials(true)
15
-                //设置放行哪些原始域
16
-                .allowedOrigins("*")
17
-                //放行哪些请求方式
18
-                .allowedMethods("GET", "POST", "PUT", "DELETE")
19
-                //.allowedMethods("*") //或者放行全部
20
-                //放行哪些原始请求头部信息
21
-                .allowedHeaders("*")
22
-                //暴露哪些原始请求头部信息
23
-                .exposedHeaders("X-Authorization-JWT");
11
+//        //添加映射路径
12
+//        registry.addMapping("/**")
13
+//                //是否发送Cookie
14
+//                .allowCredentials(true)
15
+//                //设置放行哪些原始域
16
+//                .allowedOrigins("*")
17
+//                //放行哪些请求方式
18
+//                .allowedMethods("GET", "POST", "PUT", "DELETE")
19
+//                //.allowedMethods("*") //或者放行全部
20
+//                //放行哪些原始请求头部信息
21
+//                .allowedHeaders("*")
22
+//                //暴露哪些原始请求头部信息
23
+//                .exposedHeaders("X-Authorization-JWT");
24 24
     }
25 25
 }
26 26
 

+ 30
- 0
src/main/java/com/yunzhi/nanyang/config/DateConverterConfig.java Näytä tiedosto

@@ -0,0 +1,30 @@
1
+package com.yunzhi.nanyang.config;
2
+
3
+import org.springframework.context.annotation.Bean;
4
+import org.springframework.context.annotation.Configuration;
5
+import org.springframework.core.convert.converter.Converter;
6
+
7
+import java.time.LocalDateTime;
8
+import java.time.format.DateTimeFormatter;
9
+
10
+/**
11
+ * 处理 ResquestParam 中的日期格式
12
+ */
13
+
14
+@Configuration
15
+public class DateConverterConfig {
16
+    @Bean
17
+    public Converter<String, LocalDateTime> localDateTimeConverter() {
18
+        return new Converter<String, LocalDateTime>() {
19
+            @Override
20
+            public LocalDateTime convert(String source) {
21
+                if ("".equals(source)) {
22
+                    return null;
23
+                }
24
+
25
+                String dt = source + "+0800";
26
+                return LocalDateTime.parse(dt, DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ssZ"));
27
+            }
28
+        };
29
+    }
30
+}

+ 71
- 0
src/main/java/com/yunzhi/nanyang/config/JacksonConfig.java Näytä tiedosto

@@ -0,0 +1,71 @@
1
+package com.yunzhi.nanyang.config;
2
+
3
+import com.fasterxml.jackson.annotation.JsonInclude;
4
+import com.fasterxml.jackson.databind.DeserializationFeature;
5
+import com.fasterxml.jackson.databind.ObjectMapper;
6
+import com.fasterxml.jackson.databind.SerializationFeature;
7
+import com.fasterxml.jackson.datatype.jsr310.JavaTimeModule;
8
+import com.fasterxml.jackson.datatype.jsr310.deser.LocalDateDeserializer;
9
+import com.fasterxml.jackson.datatype.jsr310.deser.LocalDateTimeDeserializer;
10
+import com.fasterxml.jackson.datatype.jsr310.deser.LocalTimeDeserializer;
11
+import com.fasterxml.jackson.datatype.jsr310.ser.LocalDateSerializer;
12
+import com.fasterxml.jackson.datatype.jsr310.ser.LocalDateTimeSerializer;
13
+import com.fasterxml.jackson.datatype.jsr310.ser.LocalTimeSerializer;
14
+import org.springframework.context.annotation.Bean;
15
+import org.springframework.context.annotation.Configuration;
16
+import org.springframework.http.converter.json.MappingJackson2HttpMessageConverter;
17
+
18
+import java.text.SimpleDateFormat;
19
+import java.time.LocalDate;
20
+import java.time.LocalDateTime;
21
+import java.time.LocalTime;
22
+import java.time.format.DateTimeFormatter;
23
+import java.util.TimeZone;
24
+
25
+/**
26
+ * 处理 RequestBody 中的日期
27
+ */
28
+
29
+@Configuration
30
+public class JacksonConfig {
31
+
32
+    /** 默认日期时间格式 */
33
+    public static final String DEFAULT_DATE_TIME_FORMAT = "yyyy-MM-dd HH:mm:ss";
34
+    /** 默认日期格式 */
35
+    public static final String DEFAULT_DATE_FORMAT = "yyyy-MM-dd";
36
+    /** 默认时间格式 */
37
+    public static final String DEFAULT_TIME_FORMAT = "HH:mm:ss";
38
+
39
+    @Bean
40
+    public MappingJackson2HttpMessageConverter mappingJackson2HttpMessageConverter() {
41
+        MappingJackson2HttpMessageConverter converter = new MappingJackson2HttpMessageConverter();
42
+        ObjectMapper objectMapper = new ObjectMapper();
43
+
44
+        // 忽略json字符串中不识别的属性
45
+        objectMapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
46
+        // 忽略无法转换的对象
47
+        objectMapper.configure(SerializationFeature.FAIL_ON_EMPTY_BEANS, false);
48
+        // PrettyPrinter 格式化输出
49
+        objectMapper.configure(SerializationFeature.INDENT_OUTPUT, true);
50
+        // NULL不参与序列化
51
+        objectMapper.setSerializationInclusion(JsonInclude.Include.NON_NULL);
52
+
53
+        // 指定时区
54
+        objectMapper.setTimeZone(TimeZone.getTimeZone("GMT+8:00"));
55
+        // 日期类型字符串处理
56
+        objectMapper.setDateFormat(new SimpleDateFormat(DEFAULT_DATE_TIME_FORMAT));
57
+
58
+        // java8日期日期处理
59
+        JavaTimeModule javaTimeModule = new JavaTimeModule();
60
+        javaTimeModule.addSerializer(LocalDateTime.class, new LocalDateTimeSerializer(DateTimeFormatter.ofPattern(DEFAULT_DATE_TIME_FORMAT)));
61
+        javaTimeModule.addSerializer(LocalDate.class, new LocalDateSerializer(DateTimeFormatter.ofPattern(DEFAULT_DATE_FORMAT)));
62
+        javaTimeModule.addSerializer(LocalTime.class, new LocalTimeSerializer(DateTimeFormatter.ofPattern(DEFAULT_TIME_FORMAT)));
63
+        javaTimeModule.addDeserializer(LocalDateTime.class, new LocalDateTimeDeserializer(DateTimeFormatter.ofPattern(DEFAULT_DATE_TIME_FORMAT)));
64
+        javaTimeModule.addDeserializer(LocalDate.class, new LocalDateDeserializer(DateTimeFormatter.ofPattern(DEFAULT_DATE_FORMAT)));
65
+        javaTimeModule.addDeserializer(LocalTime.class, new LocalTimeDeserializer(DateTimeFormatter.ofPattern(DEFAULT_TIME_FORMAT)));
66
+        objectMapper.registerModule(javaTimeModule);
67
+
68
+        converter.setObjectMapper(objectMapper);
69
+        return converter;
70
+    }
71
+}

+ 129
- 39
src/main/java/com/yunzhi/nanyang/controller/TaDispatchController.java Näytä tiedosto

@@ -4,10 +4,17 @@ import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
4 4
 import com.baomidou.mybatisplus.core.metadata.IPage;
5 5
 import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
6 6
 import com.yunzhi.nanyang.common.BaseController;
7
+import com.yunzhi.nanyang.common.Constants;
7 8
 import com.yunzhi.nanyang.common.ResponseBean;
9
+import com.yunzhi.nanyang.common.StringUtils;
10
+import com.yunzhi.nanyang.entity.SysUser;
11
+import com.yunzhi.nanyang.entity.TaOrder;
12
+import com.yunzhi.nanyang.entity.TaWorkJob;
13
+import com.yunzhi.nanyang.service.*;
8 14
 import io.swagger.annotations.Api;
9 15
 import io.swagger.annotations.ApiOperation;
10 16
 import io.swagger.annotations.ApiParam;
17
+import org.apache.shiro.authz.annotation.RequiresPermissions;
11 18
 import org.slf4j.Logger;
12 19
 import org.slf4j.LoggerFactory;
13 20
 import org.springframework.beans.factory.annotation.Autowired;
@@ -16,7 +23,6 @@ import org.springframework.web.bind.annotation.RequestBody;
16 23
 import org.springframework.web.bind.annotation.RequestMapping;
17 24
 import org.springframework.web.bind.annotation.RequestMethod;
18 25
 import org.springframework.web.bind.annotation.RequestParam;
19
-import com.yunzhi.nanyang.service.ITaDispatchService;
20 26
 import com.yunzhi.nanyang.entity.TaDispatch;
21 27
 import org.springframework.web.bind.annotation.RestController;
22 28
 
@@ -36,39 +42,90 @@ public class TaDispatchController extends BaseController {
36 42
 
37 43
     private final Logger logger = LoggerFactory.getLogger(TaDispatchController.class);
38 44
 
45
+    @Autowired
46
+    ITaOrgService iTaOrgService;
47
+
39 48
     @Autowired
40 49
     public ITaDispatchService iTaDispatchService;
41 50
 
51
+    @Autowired
52
+    public ITaOrderService iTaOrderService;
42 53
 
43
-    /**
44
-     * 分页查询列表
45
-     * @param pageNum
46
-     * @param pageSize
47
-     * @return
48
-     */
49
-    @RequestMapping(value="/taDispatch",method= RequestMethod.GET)
50
-    @ApiOperation(value="列表", notes = "列表", httpMethod = "GET", response = ResponseBean.class)
51
-    public ResponseBean taDispatchList(@ApiParam("页码") @RequestParam(value ="pageNum",defaultValue = "1") Integer pageNum,
52
-									 @ApiParam("单页数据量") @RequestParam(value ="pageSize",defaultValue = "10") Integer pageSize) throws Exception{
54
+    @Autowired
55
+    public ITaMachineryService iTaMachineryService;
53 56
 
54
-		    IPage<TaDispatch> pg = new Page<>(pageNum, pageSize);
55
-            QueryWrapper<TaDispatch> queryWrapper = new QueryWrapper<>();
56
-            queryWrapper.orderByDesc("create_date");
57
+    @Autowired
58
+    public ITdMachineryTypeService iTdMachineryTypeService;
59
+
60
+    @Autowired
61
+    public ITaWorkJobService iTaWorkJobService;
57 62
 
58
-            IPage<TaDispatch> result = iTaDispatchService.page(pg, queryWrapper);
59
-            return ResponseBean.success(result);
60
-    }
63
+
64
+//    /**
65
+//     * 分页查询列表
66
+//     * @param pageNum
67
+//     * @param pageSize
68
+//     * @return
69
+//     */
70
+//    @RequestMapping(value="/admin/dispatch",method= RequestMethod.GET)
71
+//    @ApiOperation(value="列表", notes = "列表", httpMethod = "GET", response = ResponseBean.class)
72
+//    public ResponseBean taDispatchList(@ApiParam("页码") @RequestParam(value ="pageNum",defaultValue = "1") Integer pageNum,
73
+//									 @ApiParam("单页数据量") @RequestParam(value ="pageSize",defaultValue = "10") Integer pageSize) throws Exception{
74
+//
75
+//        IPage<TaDispatch> pg = new Page<>(pageNum, pageSize);
76
+//        QueryWrapper<TaDispatch> queryWrapper = new QueryWrapper<>();
77
+//        queryWrapper.orderByDesc("create_date");
78
+//
79
+//        IPage<TaDispatch> result = iTaDispatchService.page(pg, queryWrapper);
80
+//        return ResponseBean.success(result);
81
+//    }
61 82
 
62 83
     /**
63 84
      * 保存对象
64 85
      * @param taDispatch 实体对象
65 86
      * @return
66 87
      */
67
-    @RequestMapping(value="/taDispatch",method= RequestMethod.POST)
88
+    @RequestMapping(value="/admin/dispatch",method= RequestMethod.POST)
68 89
     @ApiOperation(value="保存", notes = "保存", httpMethod = "POST", response = ResponseBean.class)
90
+    @RequiresPermissions("orderjob:add")
69 91
     public ResponseBean taDispatchAdd(@ApiParam("保存内容") @RequestBody TaDispatch taDispatch) throws Exception{
92
+        SysUser user = currentUser();
93
+
94
+        taDispatch.setDispatchId(null);
95
+
96
+        if (StringUtils.isEmpty(taDispatch.getOrderId()) || StringUtils.isEmpty(taDispatch.getOrderId())) {
97
+            return ResponseBean.error("订单或者接单机构为空");
98
+        }
99
+        TaOrder taOrder = iTaOrderService.getExistBy("order_id", taDispatch.getOrderId(), false, true);
100
+        if (null == taOrder) {
101
+            return ResponseBean.error("验证订单信息异常");
102
+        }
103
+
104
+        if (!checkOrgAccess(taDispatch.getOrgId(), user.getUserId())) {
105
+            return ResponseBean.error("无操作权限");
106
+        }
107
+
108
+        taDispatch.setOrgName(iTaOrgService.getById(taDispatch.getOrgId()).getName());
109
+
110
+        if (!StringUtils.isEmpty(taDispatch.getMachineryId())) {
111
+            taDispatch.setMachineryName(iTaMachineryService.getById(taDispatch.getMachineryId()).getName());
112
+        }
113
+
114
+        if (!StringUtils.isEmpty(taDispatch.getTypeId())) {
115
+            taDispatch.setTypeName(iTdMachineryTypeService.getById(taDispatch.getTypeId()).getName());
116
+        }
117
+
118
+        taDispatch.setStatus(Constants.STATUS_NORMAL);
119
+
70 120
 
71 121
         if (iTaDispatchService.save(taDispatch)){
122
+
123
+            // 生成作业信息
124
+            iTaWorkJobService.createByDispatch(taDispatch, taOrder);
125
+
126
+            // 更新订单状态
127
+            iTaOrderService.updateStatus(taDispatch.getOrderId(), "dispatch_status", Constants.DISPATCH_DONE);
128
+
72 129
             return ResponseBean.success(taDispatch);
73 130
         }else {
74 131
             return ResponseBean.error("保存失败, 请重试", ResponseBean.ERROR_UNAVAILABLE);
@@ -79,41 +136,74 @@ public class TaDispatchController extends BaseController {
79 136
      * 根据id删除对象
80 137
      * @param id  实体ID
81 138
      */
82
-    @RequestMapping(value="/taDispatch/{id}", method= RequestMethod.DELETE)
139
+    @RequestMapping(value="/admin/dispatch/{id}", method= RequestMethod.DELETE)
83 140
     @ApiOperation(value="删除", notes = "删除", httpMethod = "DELETE", response = ResponseBean.class)
84
-    public ResponseBean taDispatchDelete(@ApiParam("对象ID") @PathVariable Integer id) throws Exception{
85
-        if(iTaDispatchService.removeById(id)){
141
+    @RequiresPermissions("orderjob:delete")
142
+    public ResponseBean taDispatchDelete(@ApiParam("对象ID") @PathVariable String id) throws Exception{
143
+        TaDispatch taDispatch = iTaDispatchService.getById(id);
144
+
145
+        SysUser user = currentUser();
146
+
147
+        if (!checkOrgAccess(taDispatch.getOrgId(), user.getUserId())) {
148
+            return ResponseBean.error("无操作权限");
149
+        }
150
+
151
+        TaWorkJob taWorkJob = iTaWorkJobService.getExistBy("dispatch_id", id, false, true);
152
+        if (null == taWorkJob) {
153
+            return ResponseBean.error("校验作业信息失败");
154
+        }
155
+
156
+//        if (Constants.WORK_READY != taWorkJob.getStatus()) {
157
+//            return ResponseBean.error("作业已开始,不能删除");
158
+//        }
159
+
160
+        // 先清除原来的作业信息
161
+        iTaWorkJobService.removeLogicById(taWorkJob.getJobId());
162
+
163
+        if(iTaDispatchService.removeLogicById(id)){
164
+            // 更新订单状态
165
+            iTaOrderService.updateStatus(taDispatch.getOrderId(), "dispatch_status", Constants.DISPATCH_READY);
86 166
             return ResponseBean.success("success");
87
-        }else {
167
+        } else {
88 168
             return ResponseBean.error("删除失败, 请重试", ResponseBean.ERROR_UNAVAILABLE);
89 169
         }
90 170
     }
91 171
 
172
+//    /**
173
+//     * 修改对象
174
+//     * @param id  实体ID
175
+//     * @param taDispatch 实体对象
176
+//     * @return
177
+//     */
178
+//    @RequestMapping(value="/taDispatch/{id}",method= RequestMethod.PUT)
179
+//    @ApiOperation(value="更新", notes = "更新", httpMethod = "PUT", response = ResponseBean.class)
180
+//    public ResponseBean taDispatchUpdate(@ApiParam("对象ID") @PathVariable Integer id,
181
+//                                        @ApiParam("更新内容") @RequestBody TaDispatch taDispatch) throws Exception{
182
+//
183
+//        if (iTaDispatchService.updateById(taDispatch)){
184
+//            return ResponseBean.success(iTaDispatchService.getById(id));
185
+//        }else {
186
+//            return ResponseBean.error("修改失败, 请重试", ResponseBean.ERROR_UNAVAILABLE);
187
+//        }
188
+//    }
189
+
92 190
     /**
93
-     * 修改对象
191
+     * 根据id查询对象
94 192
      * @param id  实体ID
95
-     * @param taDispatch 实体对象
96
-     * @return
97 193
      */
98
-    @RequestMapping(value="/taDispatch/{id}",method= RequestMethod.PUT)
99
-    @ApiOperation(value="更新", notes = "更新", httpMethod = "PUT", response = ResponseBean.class)
100
-    public ResponseBean taDispatchUpdate(@ApiParam("对象ID") @PathVariable Integer id,
101
-                                        @ApiParam("更新内容") @RequestBody TaDispatch taDispatch) throws Exception{
102
-
103
-        if (iTaDispatchService.updateById(taDispatch)){
104
-            return ResponseBean.success(iTaDispatchService.getById(id));
105
-        }else {
106
-            return ResponseBean.error("修改失败, 请重试", ResponseBean.ERROR_UNAVAILABLE);
107
-        }
194
+    @RequestMapping(value="/admin/dispatch/{id}",method= RequestMethod.GET)
195
+    @ApiOperation(value="调度详情", notes = "调度详情", httpMethod = "GET", response = ResponseBean.class)
196
+    public ResponseBean getDetail(@ApiParam("调度ID") @PathVariable String id) throws Exception{
197
+        return ResponseBean.success(iTaDispatchService.getExistBy("dispatch_id", id, false, true));
108 198
     }
109 199
 
110 200
     /**
111 201
      * 根据id查询对象
112 202
      * @param id  实体ID
113 203
      */
114
-    @RequestMapping(value="/taDispatch/{id}",method= RequestMethod.GET)
115
-    @ApiOperation(value="详情", notes = "详情", httpMethod = "GET", response = ResponseBean.class)
116
-    public ResponseBean taDispatchGet(@ApiParam("对象ID") @PathVariable Integer id) throws Exception{
117
-        return ResponseBean.success(iTaDispatchService.getById(id));
204
+    @RequestMapping(value="/admin/order/{orderId}/dispatch",method= RequestMethod.GET)
205
+    @ApiOperation(value="调度详情", notes = "调度详情", httpMethod = "GET", response = ResponseBean.class)
206
+    public ResponseBean taDispatchGet(@ApiParam("订单ID") @PathVariable String orderId) throws Exception{
207
+        return ResponseBean.success(iTaDispatchService.getExistBy("order_id", orderId, false, true));
118 208
     }
119 209
 }

+ 98
- 51
src/main/java/com/yunzhi/nanyang/controller/TaEvaluationController.java Näytä tiedosto

@@ -4,7 +4,13 @@ import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
4 4
 import com.baomidou.mybatisplus.core.metadata.IPage;
5 5
 import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
6 6
 import com.yunzhi.nanyang.common.BaseController;
7
+import com.yunzhi.nanyang.common.Constants;
7 8
 import com.yunzhi.nanyang.common.ResponseBean;
9
+import com.yunzhi.nanyang.common.StringUtils;
10
+import com.yunzhi.nanyang.entity.TaOrder;
11
+import com.yunzhi.nanyang.entity.TaPerson;
12
+import com.yunzhi.nanyang.service.ITaOrderService;
13
+import com.yunzhi.nanyang.service.ITaPersonService;
8 14
 import io.swagger.annotations.Api;
9 15
 import io.swagger.annotations.ApiOperation;
10 16
 import io.swagger.annotations.ApiParam;
@@ -39,81 +45,122 @@ public class TaEvaluationController extends BaseController {
39 45
     @Autowired
40 46
     public ITaEvaluationService iTaEvaluationService;
41 47
 
48
+    @Autowired
49
+    public ITaOrderService iTaOrderService;
42 50
 
43
-    /**
44
-     * 分页查询列表
45
-     * @param pageNum
46
-     * @param pageSize
47
-     * @return
48
-     */
49
-    @RequestMapping(value="/taEvaluation",method= RequestMethod.GET)
50
-    @ApiOperation(value="列表", notes = "列表", httpMethod = "GET", response = ResponseBean.class)
51
-    public ResponseBean taEvaluationList(@ApiParam("页码") @RequestParam(value ="pageNum",defaultValue = "1") Integer pageNum,
52
-									 @ApiParam("单页数据量") @RequestParam(value ="pageSize",defaultValue = "10") Integer pageSize) throws Exception{
51
+    @Autowired
52
+    public ITaPersonService iTaPersonService;
53 53
 
54
-		    IPage<TaEvaluation> pg = new Page<>(pageNum, pageSize);
55
-            QueryWrapper<TaEvaluation> queryWrapper = new QueryWrapper<>();
56
-            queryWrapper.orderByDesc("create_date");
57 54
 
58
-            IPage<TaEvaluation> result = iTaEvaluationService.page(pg, queryWrapper);
59
-            return ResponseBean.success(result);
60
-    }
55
+//    /**
56
+//     * 分页查询列表
57
+//     * @param pageNum
58
+//     * @param pageSize
59
+//     * @return
60
+//     */
61
+//    @RequestMapping(value="/taEvaluation",method= RequestMethod.GET)
62
+//    @ApiOperation(value="列表", notes = "列表", httpMethod = "GET", response = ResponseBean.class)
63
+//    public ResponseBean taEvaluationList(@ApiParam("页码") @RequestParam(value ="pageNum",defaultValue = "1") Integer pageNum,
64
+//									 @ApiParam("单页数据量") @RequestParam(value ="pageSize",defaultValue = "10") Integer pageSize) throws Exception{
65
+//
66
+//		    IPage<TaEvaluation> pg = new Page<>(pageNum, pageSize);
67
+//            QueryWrapper<TaEvaluation> queryWrapper = new QueryWrapper<>();
68
+//            queryWrapper.orderByDesc("create_date");
69
+//
70
+//            IPage<TaEvaluation> result = iTaEvaluationService.page(pg, queryWrapper);
71
+//            return ResponseBean.success(result);
72
+//    }
61 73
 
62 74
     /**
63 75
      * 保存对象
64 76
      * @param taEvaluation 实体对象
65 77
      * @return
66 78
      */
67
-    @RequestMapping(value="/taEvaluation",method= RequestMethod.POST)
79
+    @RequestMapping(value="/{client}/{clientId}/evaluation",method= RequestMethod.POST)
68 80
     @ApiOperation(value="保存", notes = "保存", httpMethod = "POST", response = ResponseBean.class)
69
-    public ResponseBean taEvaluationAdd(@ApiParam("保存内容") @RequestBody TaEvaluation taEvaluation) throws Exception{
81
+    public ResponseBean taEvaluationAdd(@ApiParam("客户端") @PathVariable String client,
82
+                                        @ApiParam("客户端ID") @PathVariable String clientId,
83
+                                        @ApiParam("保存内容") @RequestBody TaEvaluation taEvaluation) throws Exception{
84
+
85
+        if (StringUtils.isEmpty(taEvaluation.getOrderId())) {
86
+            return ResponseBean.error("订单ID为空");
87
+        }
88
+
89
+        TaOrder taOrder = iTaOrderService.getExistBy("order_id", taEvaluation.getOrderId(), false, true);
90
+        if (taOrder == null) {
91
+            return ResponseBean.error("找不到订单");
92
+        }
93
+
94
+        String personId = currentPerson().getPersonId();
95
+        if (!taOrder.getPersonId().equals(personId)) {
96
+            return ResponseBean.error("非法操作");
97
+        }
98
+
99
+        if (Constants.PAY_PAID != taOrder.getPayStatus() || Constants.WORK_DONE != taOrder.getWorkStatus()) {
100
+            return ResponseBean.error("订单未支付或者未完成");
101
+        }
102
+
103
+        taEvaluation.setPersonId(personId);
70 104
 
71 105
         if (iTaEvaluationService.save(taEvaluation)){
106
+
107
+            iTaOrderService.updateStatus(taOrder.getOrderId(), "is_evaluated", 1);
108
+
72 109
             return ResponseBean.success(taEvaluation);
73 110
         }else {
74 111
             return ResponseBean.error("保存失败, 请重试", ResponseBean.ERROR_UNAVAILABLE);
75 112
         }
76 113
     }
77 114
 
115
+//    /**
116
+//     * 根据id删除对象
117
+//     * @param id  实体ID
118
+//     */
119
+//    @RequestMapping(value="/taEvaluation/{id}", method= RequestMethod.DELETE)
120
+//    @ApiOperation(value="删除", notes = "删除", httpMethod = "DELETE", response = ResponseBean.class)
121
+//    public ResponseBean taEvaluationDelete(@ApiParam("对象ID") @PathVariable Integer id) throws Exception{
122
+//        if(iTaEvaluationService.removeById(id)){
123
+//            return ResponseBean.success("success");
124
+//        }else {
125
+//            return ResponseBean.error("删除失败, 请重试", ResponseBean.ERROR_UNAVAILABLE);
126
+//        }
127
+//    }
128
+//
129
+//    /**
130
+//     * 修改对象
131
+//     * @param id  实体ID
132
+//     * @param taEvaluation 实体对象
133
+//     * @return
134
+//     */
135
+//    @RequestMapping(value="/taEvaluation/{id}",method= RequestMethod.PUT)
136
+//    @ApiOperation(value="更新", notes = "更新", httpMethod = "PUT", response = ResponseBean.class)
137
+//    public ResponseBean taEvaluationUpdate(@ApiParam("对象ID") @PathVariable Integer id,
138
+//                                        @ApiParam("更新内容") @RequestBody TaEvaluation taEvaluation) throws Exception{
139
+//
140
+//        if (iTaEvaluationService.updateById(taEvaluation)){
141
+//            return ResponseBean.success(iTaEvaluationService.getById(id));
142
+//        }else {
143
+//            return ResponseBean.error("修改失败, 请重试", ResponseBean.ERROR_UNAVAILABLE);
144
+//        }
145
+//    }
146
+//
78 147
     /**
79
-     * 根据id删除对象
148
+     * 根据id查询对象
80 149
      * @param id  实体ID
81 150
      */
82
-    @RequestMapping(value="/taEvaluation/{id}", method= RequestMethod.DELETE)
83
-    @ApiOperation(value="删除", notes = "删除", httpMethod = "DELETE", response = ResponseBean.class)
84
-    public ResponseBean taEvaluationDelete(@ApiParam("对象ID") @PathVariable Integer id) throws Exception{
85
-        if(iTaEvaluationService.removeById(id)){
86
-            return ResponseBean.success("success");
87
-        }else {
88
-            return ResponseBean.error("删除失败, 请重试", ResponseBean.ERROR_UNAVAILABLE);
151
+    @RequestMapping(value="/admin/order/{orderId}/evaluation",method= RequestMethod.GET)
152
+    @ApiOperation(value="依据订单查询", notes = "依据订单查询", httpMethod = "GET", response = ResponseBean.class)
153
+    public ResponseBean taEvaluationGet(@ApiParam("订单ID") @PathVariable String orderId) throws Exception{
154
+        TaEvaluation taEvaluation  = iTaEvaluationService.getExistBy("order_id", orderId, false, false);
155
+        if (null == taEvaluation) {
156
+            return ResponseBean.error("未找到评价内容");
89 157
         }
90
-    }
91
-
92
-    /**
93
-     * 修改对象
94
-     * @param id  实体ID
95
-     * @param taEvaluation 实体对象
96
-     * @return
97
-     */
98
-    @RequestMapping(value="/taEvaluation/{id}",method= RequestMethod.PUT)
99
-    @ApiOperation(value="更新", notes = "更新", httpMethod = "PUT", response = ResponseBean.class)
100
-    public ResponseBean taEvaluationUpdate(@ApiParam("对象ID") @PathVariable Integer id,
101
-                                        @ApiParam("更新内容") @RequestBody TaEvaluation taEvaluation) throws Exception{
102 158
 
103
-        if (iTaEvaluationService.updateById(taEvaluation)){
104
-            return ResponseBean.success(iTaEvaluationService.getById(id));
105
-        }else {
106
-            return ResponseBean.error("修改失败, 请重试", ResponseBean.ERROR_UNAVAILABLE);
159
+        TaPerson taPerson = iTaPersonService.getById(taEvaluation.getPersonId());
160
+        if (taPerson != null) {
161
+            taEvaluation.setPersonName(taPerson.getNickName());
107 162
         }
108
-    }
109 163
 
110
-    /**
111
-     * 根据id查询对象
112
-     * @param id  实体ID
113
-     */
114
-    @RequestMapping(value="/taEvaluation/{id}",method= RequestMethod.GET)
115
-    @ApiOperation(value="详情", notes = "详情", httpMethod = "GET", response = ResponseBean.class)
116
-    public ResponseBean taEvaluationGet(@ApiParam("对象ID") @PathVariable Integer id) throws Exception{
117
-        return ResponseBean.success(iTaEvaluationService.getById(id));
164
+        return ResponseBean.success(taEvaluation);
118 165
     }
119 166
 }

+ 4
- 4
src/main/java/com/yunzhi/nanyang/controller/TaMachineryController.java Näytä tiedosto

@@ -99,12 +99,13 @@ public class TaMachineryController extends BaseController {
99 99
                                        @ApiParam("页码") @RequestParam(value ="pageNum",defaultValue = "1") Integer pageNum,
100 100
                                        @ApiParam("单页数据量") @RequestParam(value ="pageSize",defaultValue = "10") Integer pageSize,
101 101
                                        @ApiParam("当前位置") @RequestParam(value ="location") String location,
102
-                                       @ApiParam("分类") @RequestParam(value = "typeId", required = false) String typeId) throws Exception{
102
+                                       @ApiParam("分类") @RequestParam(value = "typeId", required = false) String typeId,
103
+                                       @ApiParam("搜索关键词") @RequestParam(value = "q", required = false) String q) throws Exception{
103 104
 
104 105
         String orgId = null;
105 106
         TaPerson current = currentPerson();
106 107
         if (Constants.CLIENT_WORKER.equals(clientId)) {
107
-            // 农机手查询机器列表, 只能查询自己绑定的机器
108
+            // 农机手查询机器列表, 只能查询自己机构的机器
108 109
             if (StringUtils.isEmpty(current.getUserId())) {
109 110
                 return ResponseBean.error("未找到绑定农机手信息");
110 111
             }
@@ -116,10 +117,9 @@ public class TaMachineryController extends BaseController {
116 117
             orgId = user.getOrgId();
117 118
         }
118 119
 
119
-
120 120
         IPage<MachineSummary> pg = new Page<>(pageNum, pageSize);
121 121
 
122
-        IPage<MachineSummary> result = iTaMachineryService.getSummaryList(pg, location, typeId, orgId);
122
+        IPage<MachineSummary> result = iTaMachineryService.getSummaryList(pg, location, typeId, orgId, q);
123 123
         return ResponseBean.success(result);
124 124
     }
125 125
 

+ 51
- 1
src/main/java/com/yunzhi/nanyang/controller/TaNewsController.java Näytä tiedosto

@@ -82,6 +82,36 @@ public class TaNewsController extends BaseController {
82 82
         return ResponseBean.success(result);
83 83
     }
84 84
 
85
+    /**
86
+     * 分页查询列表
87
+     * @param pageNum
88
+     * @param pageSize
89
+     * @return
90
+     */
91
+    @RequestMapping(value="/{client}/{clientId}/news",method= RequestMethod.GET)
92
+    @ApiOperation(value="列表", notes = "列表", httpMethod = "GET", response = ResponseBean.class)
93
+    public ResponseBean taNewsList(@ApiParam("客户端") @PathVariable String client,
94
+                                   @ApiParam("客户端ID") @PathVariable String clientId,
95
+                                   @ApiParam("页码") @RequestParam(value ="pageNum",defaultValue = "1") Integer pageNum,
96
+                                   @ApiParam("单页数据量") @RequestParam(value ="pageSize",defaultValue = "10") Integer pageSize,
97
+                                   @ApiParam("名称") @RequestParam(value ="title", required = false) String title,
98
+                                   @ApiParam("类型") @RequestParam(value ="typeId", required = false) String typeId) throws Exception{
99
+//        SysUser sysUser = currentUser();
100
+//        boolean isAdmin = Constants.ADMIN_ID.equals(sysUser.getUserId());
101
+
102
+        IPage<TaNews> pg = new Page<>(pageNum, pageSize);
103
+        QueryWrapper<TaNews> queryWrapper = new QueryWrapper<>();
104
+        queryWrapper.like(!StringUtils.isEmpty(title), "title", "%" + title + "%");
105
+        queryWrapper.eq(!StringUtils.isEmpty(typeId), "type_id", typeId);
106
+//        queryWrapper.in(!isAdmin, "org_id", getAccessOrgs(sysUser.getUserId()));
107
+        queryWrapper.eq("status", Constants.STATUS_NORMAL);
108
+        queryWrapper.orderByDesc("create_date");
109
+
110
+        IPage<TaNews> result = iTaNewsService.page(pg, queryWrapper);
111
+        return ResponseBean.success(result);
112
+    }
113
+
114
+
85 115
     /**
86 116
      * 保存对象
87 117
      * @param taNews 实体对象
@@ -141,7 +171,7 @@ public class TaNewsController extends BaseController {
141 171
 
142 172
         taNews.setTypeName(iTaNewsTypeService.getById(taNews.getTypeId()).getName());
143 173
 
144
-        iTaExtendContentService.editContent(Constants.TARGET_NEWS, id, taNews.getContentList());
174
+//        iTaExtendContentService.editContent(Constants.TARGET_NEWS, id, taNews.getContentList());
145 175
 
146 176
         if (iTaNewsService.updateById(taNews)){
147 177
             return ResponseBean.success(taNews);
@@ -167,4 +197,24 @@ public class TaNewsController extends BaseController {
167 197
 
168 198
         return ResponseBean.success(taNews);
169 199
     }
200
+
201
+    /**
202
+     * 根据id查询对象
203
+     * @param id  实体ID
204
+     */
205
+    @RequestMapping(value="/{client}/{clientId}//news/{id}",method= RequestMethod.GET)
206
+    @ApiOperation(value="详情", notes = "详情", httpMethod = "GET", response = ResponseBean.class)
207
+    public ResponseBean getDetail(@ApiParam("客户端") @PathVariable String client,
208
+                                  @ApiParam("客户端ID") @PathVariable String clientId,
209
+                                  @ApiParam("对象ID") @PathVariable String id) throws Exception{
210
+        TaNews taNews = iTaNewsService.getExistBy("news_id", id, false, true);
211
+        if (null == taNews) {
212
+            return ResponseBean.error("内存不存在");
213
+        }
214
+
215
+        List<TaExtendContent> contentList = iTaExtendContentService.listByTarget(Constants.TARGET_NEWS, id);
216
+        taNews.setContentList(contentList);
217
+
218
+        return ResponseBean.success(taNews);
219
+    }
170 220
 }

+ 98
- 12
src/main/java/com/yunzhi/nanyang/controller/TaOrderController.java Näytä tiedosto

@@ -6,7 +6,9 @@ import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
6 6
 import com.yunzhi.nanyang.common.BaseController;
7 7
 import com.yunzhi.nanyang.common.Constants;
8 8
 import com.yunzhi.nanyang.common.ResponseBean;
9
-import com.yunzhi.nanyang.entity.TaPerson;
9
+import com.yunzhi.nanyang.common.StringUtils;
10
+import com.yunzhi.nanyang.entity.*;
11
+import com.yunzhi.nanyang.service.*;
10 12
 import io.swagger.annotations.Api;
11 13
 import io.swagger.annotations.ApiOperation;
12 14
 import io.swagger.annotations.ApiParam;
@@ -18,8 +20,6 @@ import org.springframework.web.bind.annotation.RequestBody;
18 20
 import org.springframework.web.bind.annotation.RequestMapping;
19 21
 import org.springframework.web.bind.annotation.RequestMethod;
20 22
 import org.springframework.web.bind.annotation.RequestParam;
21
-import com.yunzhi.nanyang.service.ITaOrderService;
22
-import com.yunzhi.nanyang.entity.TaOrder;
23 23
 import org.springframework.web.bind.annotation.RestController;
24 24
 
25 25
 /**
@@ -38,9 +38,39 @@ public class TaOrderController extends BaseController {
38 38
 
39 39
     private final Logger logger = LoggerFactory.getLogger(TaOrderController.class);
40 40
 
41
+    @Autowired
42
+    public ITaOrgService iTaOrgService;
43
+
41 44
     @Autowired
42 45
     public ITaOrderService iTaOrderService;
43 46
 
47
+    @Autowired
48
+    public ITaPersonService iTaPersonService;
49
+
50
+    @Autowired
51
+    public ISysUserService iSysUserService;
52
+
53
+    @Autowired
54
+    public ITaMachineryService iTaMachineryService;
55
+
56
+    /**
57
+     * 分页查询列表
58
+     * @param pageNum
59
+     * @param pageSize
60
+     * @return
61
+     */
62
+    @RequestMapping(value="/admin/order",method= RequestMethod.GET)
63
+    @ApiOperation(value="列表", notes = "列表", httpMethod = "GET", response = ResponseBean.class)
64
+    public ResponseBean getList(@ApiParam("页码") @RequestParam(value ="pageNum",defaultValue = "1") Integer pageNum,
65
+                                @ApiParam("单页数据量") @RequestParam(value ="pageSize",defaultValue = "10") Integer pageSize,
66
+                                @ApiParam("是否未调度") @RequestParam(value = "isNotDispatched", defaultValue = "false") Boolean isNotDispatched) throws Exception{
67
+        SysUser current = currentUser();
68
+        boolean isAdmin = Constants.ADMIN_ID.equals(current.getUserId());
69
+        IPage<TaOrder> pg = new Page<>(pageNum, pageSize);
70
+
71
+        IPage<TaOrder> result = iTaOrderService.getAdminPage(pg, isNotDispatched, isAdmin ? null : current);
72
+        return ResponseBean.success(result);
73
+    }
44 74
 
45 75
     /**
46 76
      * 分页查询列表
@@ -50,18 +80,33 @@ public class TaOrderController extends BaseController {
50 80
      */
51 81
     @RequestMapping(value="/{client}/{clientId}/order",method= RequestMethod.GET)
52 82
     @ApiOperation(value="列表", notes = "列表", httpMethod = "GET", response = ResponseBean.class)
53
-    public ResponseBean taOrderList(@ApiParam("页码") @RequestParam(value ="pageNum",defaultValue = "1") Integer pageNum,
54
-									 @ApiParam("单页数据量") @RequestParam(value ="pageSize",defaultValue = "10") Integer pageSize,
55
-                                    @ApiParam("我的") @RequestParam(value = "mine", defaultValue = "false") Boolean isMine) throws Exception{
83
+    public ResponseBean taOrderList(@ApiParam("客户端") @PathVariable String client,
84
+                                    @ApiParam("客户端ID") @PathVariable String clientId,
85
+                                    @ApiParam("页码") @RequestParam(value ="pageNum",defaultValue = "1") Integer pageNum,
86
+									@ApiParam("单页数据量") @RequestParam(value ="pageSize",defaultValue = "10") Integer pageSize,
87
+                                    @ApiParam("我的") @RequestParam(value = "mine", defaultValue = "false") Boolean isMine,
88
+                                    @ApiParam("作业状态") @RequestParam(value = "workStatus", required = false) Integer workStatus,
89
+                                    @ApiParam("关键字") @RequestParam(value = "q", required = false) String q) throws Exception{
56 90
         TaPerson taPerson = currentPerson();
57 91
 
92
+        SysUser sysUser = null;
93
+        if (Constants.CLIENT_WORKER.equals(clientId)) {
94
+            String userId = taPerson.getUserId();
95
+            if (StringUtils.isEmpty(userId)) {
96
+                return ResponseBean.error("未绑定农机手信息");
97
+            }
98
+
99
+            if (!Constants.ADMIN_ID.equals(userId)) {
100
+                sysUser = iSysUserService.getExistBy("user_id", userId, false, true);
101
+                if (null == sysUser) {
102
+                    return ResponseBean.error("未绑定农机手信息");
103
+                }
104
+            }
105
+        }
106
+
58 107
         IPage<TaOrder> pg = new Page<>(pageNum, pageSize);
59
-        QueryWrapper<TaOrder> queryWrapper = new QueryWrapper<>();
60
-        queryWrapper.eq(isMine, "person_id", taPerson.getPersonId());
61
-        queryWrapper.eq("status", Constants.STATUS_NORMAL);
62
-        queryWrapper.orderByDesc("create_date");
63 108
 
64
-        IPage<TaOrder> result = iTaOrderService.page(pg, queryWrapper);
109
+        IPage<TaOrder> result = iTaOrderService.getClientPage(pg, isMine ? taPerson : null, sysUser, workStatus, q);
65 110
         return ResponseBean.success(result);
66 111
     }
67 112
 
@@ -83,6 +128,18 @@ public class TaOrderController extends BaseController {
83 128
         taOrder.setOrderNo(orderNo);
84 129
         taOrder.setPersonId(taPerson.getPersonId());
85 130
 
131
+//        TaMachinery taMachinery = iTaMachineryService.getById(taOrder.getMachineryId());
132
+//        taOrder.setOrgId(taMachinery.getOrgId());
133
+
134
+        if (StringUtils.isEmpty(taOrder.getOrgId())) {
135
+            return ResponseBean.error("未找到接单机构");
136
+        }
137
+
138
+        TaOrg taOrg = iTaOrgService.getById(taOrder.getOrgId());
139
+        if (null == taOrg) {
140
+            return ResponseBean.error("未找到接单机构");
141
+        }
142
+
86 143
         if (iTaOrderService.save(taOrder)){
87 144
             return ResponseBean.success(taOrder);
88 145
         }else {
@@ -120,6 +177,16 @@ public class TaOrderController extends BaseController {
120 177
         }
121 178
     }
122 179
 
180
+    /**
181
+     * 根据id查询对象
182
+     * @param id  实体ID
183
+     */
184
+    @RequestMapping(value="/admin/order/{id}",method= RequestMethod.GET)
185
+    @ApiOperation(value="详情", notes = "详情", httpMethod = "GET", response = ResponseBean.class)
186
+    public ResponseBean getDetail(@ApiParam("对象ID") @PathVariable String id) throws Exception{
187
+        return ResponseBean.success(getOrder(id));
188
+    }
189
+
123 190
     /**
124 191
      * 根据id查询对象
125 192
      * @param id  实体ID
@@ -127,6 +194,25 @@ public class TaOrderController extends BaseController {
127 194
     @RequestMapping(value="/{client}/{clientId}/order/{id}",method= RequestMethod.GET)
128 195
     @ApiOperation(value="详情", notes = "详情", httpMethod = "GET", response = ResponseBean.class)
129 196
     public ResponseBean taOrderGet(@ApiParam("对象ID") @PathVariable String id) throws Exception{
130
-        return ResponseBean.success(iTaOrderService.getById(id));
197
+        return ResponseBean.success(getOrder(id));
198
+    }
199
+
200
+    private TaOrder getOrder(String id) throws Exception {
201
+        TaOrder taOrder = iTaOrderService.getExistBy("order_id", id, false, true);
202
+        if (null == taOrder) {
203
+            throw new Exception("订单不存在");
204
+        }
205
+
206
+        TaOrg taOrg = iTaOrgService.getById(taOrder.getOrgId());
207
+        if (null == taOrg) {
208
+            throw new Exception("订单机构不存在");
209
+        }
210
+
211
+        taOrder.setOrgName(taOrg.getName());
212
+
213
+        TaPerson taPerson = iTaPersonService.getById(taOrder.getPersonId());
214
+        taOrder.setPersonName(taPerson.getNickName());
215
+        taOrder.setPhone(taPerson.getPhone());
216
+        return taOrder;
131 217
     }
132 218
 }

+ 94
- 37
src/main/java/com/yunzhi/nanyang/controller/TaWorkJobController.java Näytä tiedosto

@@ -4,7 +4,13 @@ import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
4 4
 import com.baomidou.mybatisplus.core.metadata.IPage;
5 5
 import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
6 6
 import com.yunzhi.nanyang.common.BaseController;
7
+import com.yunzhi.nanyang.common.Constants;
7 8
 import com.yunzhi.nanyang.common.ResponseBean;
9
+import com.yunzhi.nanyang.common.StringUtils;
10
+import com.yunzhi.nanyang.entity.*;
11
+import com.yunzhi.nanyang.service.ITaDispatchService;
12
+import com.yunzhi.nanyang.service.ITaOrderService;
13
+import com.yunzhi.nanyang.service.ITaOrgService;
8 14
 import io.swagger.annotations.Api;
9 15
 import io.swagger.annotations.ApiOperation;
10 16
 import io.swagger.annotations.ApiParam;
@@ -17,9 +23,10 @@ import org.springframework.web.bind.annotation.RequestMapping;
17 23
 import org.springframework.web.bind.annotation.RequestMethod;
18 24
 import org.springframework.web.bind.annotation.RequestParam;
19 25
 import com.yunzhi.nanyang.service.ITaWorkJobService;
20
-import com.yunzhi.nanyang.entity.TaWorkJob;
21 26
 import org.springframework.web.bind.annotation.RestController;
22 27
 
28
+import java.time.LocalDateTime;
29
+
23 30
 /**
24 31
  * <p>
25 32
     * 作业表 前端控制器
@@ -39,6 +46,14 @@ public class TaWorkJobController extends BaseController {
39 46
     @Autowired
40 47
     public ITaWorkJobService iTaWorkJobService;
41 48
 
49
+    @Autowired
50
+    public ITaOrderService iTaOrderService;
51
+
52
+    @Autowired
53
+    public ITaDispatchService iTaDispatchService;
54
+
55
+    @Autowired
56
+    public ITaOrgService iTaOrgService;
42 57
 
43 58
     /**
44 59
      * 分页查询列表
@@ -46,62 +61,97 @@ public class TaWorkJobController extends BaseController {
46 61
      * @param pageSize
47 62
      * @return
48 63
      */
49
-    @RequestMapping(value="/taWorkJob",method= RequestMethod.GET)
64
+    @RequestMapping(value="/{client}/{clientId}/work-job",method= RequestMethod.GET)
50 65
     @ApiOperation(value="列表", notes = "列表", httpMethod = "GET", response = ResponseBean.class)
51
-    public ResponseBean taWorkJobList(@ApiParam("页码") @RequestParam(value ="pageNum",defaultValue = "1") Integer pageNum,
52
-									 @ApiParam("单页数据量") @RequestParam(value ="pageSize",defaultValue = "10") Integer pageSize) throws Exception{
66
+    public ResponseBean taWorkJobList(@ApiParam("客户端") @PathVariable String client,
67
+                                      @ApiParam("客户端ID") @PathVariable String clientId,
68
+                                      @ApiParam("页码") @RequestParam(value ="pageNum",defaultValue = "1") Integer pageNum,
69
+                                      @ApiParam("单页数据量") @RequestParam(value ="pageSize",defaultValue = "10") Integer pageSize,
70
+                                      @ApiParam("是否我的") @RequestParam(value ="mine", defaultValue = "true") Boolean isMine) throws Exception{
71
+        TaPerson taPerson = currentPerson();
72
+        if (isMine && StringUtils.isEmpty(taPerson.getUserId())) {
73
+            return ResponseBean.error("无权操作");
74
+        }
53 75
 
54
-		    IPage<TaWorkJob> pg = new Page<>(pageNum, pageSize);
55
-            QueryWrapper<TaWorkJob> queryWrapper = new QueryWrapper<>();
56
-            queryWrapper.orderByDesc("create_date");
76
+        String userId = isMine ? taPerson.getUserId() : null;
57 77
 
58
-            IPage<TaWorkJob> result = iTaWorkJobService.page(pg, queryWrapper);
59
-            return ResponseBean.success(result);
78
+        IPage<TaWorkJob> pg = new Page<>(pageNum, pageSize);
79
+        IPage<TaWorkJob> result = iTaWorkJobService.getPageBy(pg, userId);
80
+        return ResponseBean.success(result);
60 81
     }
61 82
 
62 83
     /**
63
-     * 保存对象
84
+     * 暂停/开启
85
+     * @param id  实体ID
64 86
      * @param taWorkJob 实体对象
65 87
      * @return
66 88
      */
67
-    @RequestMapping(value="/taWorkJob",method= RequestMethod.POST)
68
-    @ApiOperation(value="保存", notes = "保存", httpMethod = "POST", response = ResponseBean.class)
69
-    public ResponseBean taWorkJobAdd(@ApiParam("保存内容") @RequestBody TaWorkJob taWorkJob) throws Exception{
89
+    @RequestMapping(value="/{client}/worker/work-job/{id}/pause",method= RequestMethod.PUT)
90
+    @ApiOperation(value="暂停/开启", notes = "暂停/开启", httpMethod = "PUT", response = ResponseBean.class)
91
+    public ResponseBean taWorkJobUpdate(@ApiParam("客户端") @PathVariable String client,
92
+//                                      @ApiParam("客户端ID") @PathVariable String clientId,
93
+                                        @ApiParam("对象ID") @PathVariable String id,
94
+                                        @ApiParam("是否暂停") @RequestParam("mode") Boolean mode) throws Exception{
70 95
 
71
-        if (iTaWorkJobService.save(taWorkJob)){
72
-            return ResponseBean.success(taWorkJob);
73
-        }else {
74
-            return ResponseBean.error("保存失败, 请重试", ResponseBean.ERROR_UNAVAILABLE);
96
+        TaPerson taPerson = currentPerson();
97
+        if (StringUtils.isEmpty(taPerson.getUserId())) {
98
+            return ResponseBean.error("无权操作");
75 99
         }
76
-    }
77 100
 
78
-    /**
79
-     * 根据id删除对象
80
-     * @param id  实体ID
81
-     */
82
-    @RequestMapping(value="/taWorkJob/{id}", method= RequestMethod.DELETE)
83
-    @ApiOperation(value="删除", notes = "删除", httpMethod = "DELETE", response = ResponseBean.class)
84
-    public ResponseBean taWorkJobDelete(@ApiParam("对象ID") @PathVariable Integer id) throws Exception{
85
-        if(iTaWorkJobService.removeById(id)){
86
-            return ResponseBean.success("success");
101
+        TaWorkJob taWorkJob = iTaWorkJobService.getExistBy("job_id", id, false, true);
102
+        if (!taPerson.getUserId().equals(taWorkJob.getWorkerId())) {
103
+            return ResponseBean.error("无权操作");
104
+        }
105
+
106
+        if (Constants.WORK_PAUSE < taWorkJob.getStatus() || Constants.WORK_READY > taWorkJob.getStatus()) {
107
+            return ResponseBean.error("非工作状态, 不能操作");
108
+        }
109
+
110
+        int status = mode ? Constants.WORK_DOING : Constants.WORK_PAUSE;
111
+
112
+        // 暂停 不影响订单状态
113
+        taWorkJob.setStatus(status);
114
+
115
+        if (iTaWorkJobService.updateById(taWorkJob)){
116
+            return ResponseBean.success(taWorkJob);
87 117
         }else {
88
-            return ResponseBean.error("删除失败, 请重试", ResponseBean.ERROR_UNAVAILABLE);
118
+            return ResponseBean.error("修改失败, 请重试", ResponseBean.ERROR_UNAVAILABLE);
89 119
         }
90 120
     }
91 121
 
92 122
     /**
93
-     * 修改对象
123
+     * 暂停/开启
94 124
      * @param id  实体ID
95 125
      * @param taWorkJob 实体对象
96 126
      * @return
97 127
      */
98
-    @RequestMapping(value="/taWorkJob/{id}",method= RequestMethod.PUT)
99
-    @ApiOperation(value="更新", notes = "更新", httpMethod = "PUT", response = ResponseBean.class)
100
-    public ResponseBean taWorkJobUpdate(@ApiParam("对象ID") @PathVariable Integer id,
101
-                                        @ApiParam("更新内容") @RequestBody TaWorkJob taWorkJob) throws Exception{
128
+    @RequestMapping(value="/{client}/worker/work-job/{id}/stop",method= RequestMethod.PUT)
129
+    @ApiOperation(value="完成工作", notes = "完成工作", httpMethod = "PUT", response = ResponseBean.class)
130
+    public ResponseBean stopJob(@ApiParam("客户端") @PathVariable String client,
131
+//                              @ApiParam("客户端ID") @PathVariable String clientId,
132
+                                @ApiParam("对象ID") @PathVariable String id,
133
+                                @ApiParam("保存内容") @RequestBody TaWorkJob taWorkJob) throws Exception{
102 134
 
103
-        if (iTaWorkJobService.updateById(taWorkJob)){
104
-            return ResponseBean.success(iTaWorkJobService.getById(id));
135
+        TaPerson taPerson = currentPerson();
136
+        if (StringUtils.isEmpty(taPerson.getUserId())) {
137
+            return ResponseBean.error("无权操作");
138
+        }
139
+
140
+        TaWorkJob origin = iTaWorkJobService.getExistBy("job_id", id, false, true);
141
+        if (origin == null || !taPerson.getUserId().equals(taWorkJob.getWorkerId())) {
142
+            return ResponseBean.error("无权操作");
143
+        }
144
+
145
+        if (Constants.WORK_PAUSE != taWorkJob.getStatus() || Constants.WORK_DOING != taWorkJob.getStatus()) {
146
+            return ResponseBean.error("非工作状态, 不能操作");
147
+        }
148
+
149
+        // 暂停 不影响订单状态
150
+        origin.setStatus(Constants.WORK_DONE);
151
+        origin.setArea(taWorkJob.getArea());
152
+
153
+        if (iTaWorkJobService.updateById(origin)){
154
+            return ResponseBean.success(origin);
105 155
         }else {
106 156
             return ResponseBean.error("修改失败, 请重试", ResponseBean.ERROR_UNAVAILABLE);
107 157
         }
@@ -111,9 +161,16 @@ public class TaWorkJobController extends BaseController {
111 161
      * 根据id查询对象
112 162
      * @param id  实体ID
113 163
      */
114
-    @RequestMapping(value="/taWorkJob/{id}",method= RequestMethod.GET)
164
+    @RequestMapping(value="/{client}/{clientId}/work-job/{id}",method= RequestMethod.GET)
115 165
     @ApiOperation(value="详情", notes = "详情", httpMethod = "GET", response = ResponseBean.class)
116 166
     public ResponseBean taWorkJobGet(@ApiParam("对象ID") @PathVariable Integer id) throws Exception{
117
-        return ResponseBean.success(iTaWorkJobService.getById(id));
167
+        TaPerson taPerson = currentPerson();
168
+        if (StringUtils.isEmpty(taPerson.getUserId())) {
169
+            return ResponseBean.error("无权操作");
170
+        }
171
+
172
+        TaWorkJob taWorkJob = iTaWorkJobService.getExistBy("job_id", id, false, true);
173
+
174
+        return ResponseBean.success(taWorkJob);
118 175
     }
119 176
 }

+ 16
- 1
src/main/java/com/yunzhi/nanyang/entity/TaDispatch.java Näytä tiedosto

@@ -27,7 +27,7 @@ public class TaDispatch implements Serializable {
27 27
     private static final long serialVersionUID = 1L;
28 28
 
29 29
     @ApiModelProperty(value = "调度ID")
30
-    @TableId(value = "dispatch_id", type = IdType.INPUT)
30
+    @TableId(value = "dispatch_id", type = IdType.UUID)
31 31
     private String dispatchId;
32 32
 
33 33
     @ApiModelProperty(value = "订单ID")
@@ -36,12 +36,27 @@ public class TaDispatch implements Serializable {
36 36
     @ApiModelProperty(value = "机构ID")
37 37
     private String orgId;
38 38
 
39
+    @ApiModelProperty(value = "机构名称")
40
+    private String orgName;
41
+
39 42
     @ApiModelProperty(value = "农机手")
40 43
     private String workerId;
41 44
 
45
+    @ApiModelProperty(value = "农机手名称")
46
+    private String workerName;
47
+
42 48
     @ApiModelProperty(value = "农机ID")
43 49
     private String machineryId;
44 50
 
51
+    @ApiModelProperty(value = "农机名称")
52
+    private String machineryName;
53
+
54
+    @ApiModelProperty(value = "类型ID")
55
+    private String typeId;
56
+
57
+    @ApiModelProperty(value = "类型名称")
58
+    private String typeName;
59
+
45 60
     @ApiModelProperty(value = "状态")
46 61
     private Integer status;
47 62
 

+ 7
- 1
src/main/java/com/yunzhi/nanyang/entity/TaEvaluation.java Näytä tiedosto

@@ -2,6 +2,8 @@ package com.yunzhi.nanyang.entity;
2 2
 
3 3
 import com.baomidou.mybatisplus.annotation.IdType;
4 4
 import java.time.LocalDateTime;
5
+
6
+import com.baomidou.mybatisplus.annotation.TableField;
5 7
 import com.baomidou.mybatisplus.annotation.TableId;
6 8
 import java.io.Serializable;
7 9
 import io.swagger.annotations.ApiModel;
@@ -27,7 +29,7 @@ public class TaEvaluation implements Serializable {
27 29
     private static final long serialVersionUID = 1L;
28 30
 
29 31
     @ApiModelProperty(value = "评价id")
30
-    @TableId(value = "evaluate_id", type = IdType.INPUT)
32
+    @TableId(value = "evaluate_id", type = IdType.UUID)
31 33
     private String evaluateId;
32 34
 
33 35
     @ApiModelProperty(value = "订单Id")
@@ -42,6 +44,10 @@ public class TaEvaluation implements Serializable {
42 44
     @ApiModelProperty(value = "评价人")
43 45
     private String personId;
44 46
 
47
+    @TableField(exist = false)
48
+    @ApiModelProperty(value = "评价人姓名")
49
+    private String personName;
50
+
45 51
     @ApiModelProperty(value = "评价时间")
46 52
     private LocalDateTime createDate;
47 53
 

+ 3
- 0
src/main/java/com/yunzhi/nanyang/entity/TaMessage.java Näytä tiedosto

@@ -54,6 +54,9 @@ public class TaMessage implements Serializable {
54 54
     @ApiModelProperty(value = "推送结果")
55 55
     private String pushResult;
56 56
 
57
+    @ApiModelProperty(value = "关联动作")
58
+    private String action;
59
+
57 60
     @ApiModelProperty(value = "状态")
58 61
     private Integer status;
59 62
 

+ 19
- 0
src/main/java/com/yunzhi/nanyang/entity/TaOrder.java Näytä tiedosto

@@ -1,14 +1,21 @@
1 1
 package com.yunzhi.nanyang.entity;
2 2
 
3
+import com.alibaba.fastjson.annotation.JSONField;
3 4
 import com.baomidou.mybatisplus.annotation.IdType;
4 5
 import java.time.LocalDateTime;
6
+
7
+import com.baomidou.mybatisplus.annotation.TableField;
5 8
 import com.baomidou.mybatisplus.annotation.TableId;
6 9
 import java.io.Serializable;
10
+import java.util.Date;
11
+
12
+import com.fasterxml.jackson.annotation.JsonFormat;
7 13
 import io.swagger.annotations.ApiModel;
8 14
 import io.swagger.annotations.ApiModelProperty;
9 15
 import lombok.Data;
10 16
 import lombok.EqualsAndHashCode;
11 17
 import lombok.experimental.Accessors;
18
+import org.springframework.format.annotation.DateTimeFormat;
12 19
 
13 20
 /**
14 21
  * <p>
@@ -36,6 +43,14 @@ public class TaOrder implements Serializable {
36 43
     @ApiModelProperty(value = "下单人Id")
37 44
     private String personId;
38 45
 
46
+    @TableField(exist = false)
47
+    @ApiModelProperty(value = "下单人名称")
48
+    private String personName;
49
+
50
+    @TableField(exist = false)
51
+    @ApiModelProperty(value = "下单人手机号")
52
+    private String phone;
53
+
39 54
     @ApiModelProperty(value = "费用")
40 55
     private Integer charges;
41 56
 
@@ -81,6 +96,10 @@ public class TaOrder implements Serializable {
81 96
     @ApiModelProperty(value = "接单机构")
82 97
     private String orgId;
83 98
 
99
+    @TableField(exist = false)
100
+    @ApiModelProperty(value = "接单机构名称")
101
+    private String orgName;
102
+
84 103
     @ApiModelProperty(value = "状态")
85 104
     private Integer status;
86 105
 

+ 31
- 1
src/main/java/com/yunzhi/nanyang/entity/TaWorkJob.java Näytä tiedosto

@@ -2,8 +2,12 @@ package com.yunzhi.nanyang.entity;
2 2
 
3 3
 import com.baomidou.mybatisplus.annotation.IdType;
4 4
 import java.time.LocalDateTime;
5
+
6
+import com.baomidou.mybatisplus.annotation.TableField;
5 7
 import com.baomidou.mybatisplus.annotation.TableId;
6 8
 import java.io.Serializable;
9
+import java.util.Date;
10
+
7 11
 import io.swagger.annotations.ApiModel;
8 12
 import io.swagger.annotations.ApiModelProperty;
9 13
 import lombok.Data;
@@ -27,7 +31,7 @@ public class TaWorkJob implements Serializable {
27 31
     private static final long serialVersionUID = 1L;
28 32
 
29 33
     @ApiModelProperty(value = "作业ID")
30
-    @TableId(value = "job_id", type = IdType.INPUT)
34
+    @TableId(value = "job_id", type = IdType.UUID)
31 35
     private String jobId;
32 36
 
33 37
     @ApiModelProperty(value = "调度ID")
@@ -69,5 +73,31 @@ public class TaWorkJob implements Serializable {
69 73
     @ApiModelProperty(value = "创建时间")
70 74
     private LocalDateTime createDate;
71 75
 
76
+    @TableField(exist = false)
77
+    @ApiModelProperty(value = "下单人Id")
78
+    private String personId;
79
+
80
+    @TableField(exist = false)
81
+    @ApiModelProperty(value = "下单人名称")
82
+    private String personName;
83
+
84
+    @TableField(exist = false)
85
+    @ApiModelProperty(value = "下单人手机号")
86
+    private String phone;
87
+
88
+    @TableField(exist = false)
89
+    @ApiModelProperty(value = "费用")
90
+    private Integer charges;
91
+
92
+    @TableField(exist = false)
93
+    @ApiModelProperty(value = "预约时间")
94
+    private LocalDateTime appointmentDate;
95
+
96
+    @TableField(exist = false)
97
+    @ApiModelProperty(value = "下单时间")
98
+    private LocalDateTime orderDate;
72 99
 
100
+    @TableField(exist = false)
101
+    @ApiModelProperty(value = "农机名称")
102
+    private String machineryName;
73 103
 }

+ 15
- 0
src/main/java/com/yunzhi/nanyang/event/WorkExpiredEvent.java Näytä tiedosto

@@ -0,0 +1,15 @@
1
+package com.yunzhi.nanyang.event;
2
+
3
+import com.yunzhi.nanyang.entity.TaDispatch;
4
+import org.springframework.context.ApplicationEvent;
5
+
6
+public class WorkExpiredEvent extends ApplicationEvent {
7
+    private TaDispatch taDispatch;
8
+
9
+    public WorkExpiredEvent(Object source, TaDispatch taDispatch) {
10
+        super(source);
11
+        this.taDispatch = taDispatch;
12
+    }
13
+
14
+    public TaDispatch getTaDispatch() { return taDispatch; }
15
+}

+ 18
- 0
src/main/java/com/yunzhi/nanyang/event/listener/WorkExpiredEventListener.java Näytä tiedosto

@@ -0,0 +1,18 @@
1
+package com.yunzhi.nanyang.event.listener;
2
+
3
+import com.yunzhi.nanyang.event.WorkExpiredEvent;
4
+import com.yunzhi.nanyang.service.ITaMessageService;
5
+import org.springframework.beans.factory.annotation.Autowired;
6
+import org.springframework.context.ApplicationListener;
7
+import org.springframework.stereotype.Component;
8
+
9
+@Component
10
+public class WorkExpiredEventListener implements ApplicationListener<WorkExpiredEvent> {
11
+    @Autowired
12
+    ITaMessageService iTaMessageService;
13
+
14
+    @Override
15
+    public void onApplicationEvent(WorkExpiredEvent evt) {
16
+        iTaMessageService.sendMessage(evt);
17
+    }
18
+}

+ 7
- 1
src/main/java/com/yunzhi/nanyang/exception/GlobalExceptionHandler.java Näytä tiedosto

@@ -19,6 +19,12 @@ public class GlobalExceptionHandler {
19 19
         if (e instanceof UnauthorizedException) {
20 20
             return ResponseBean.error("暂无权限进行当前操作", ResponseBean.ERROR_UNAUTHORIZED);
21 21
         }
22
-        return ResponseBean.error(e.getMessage(), ResponseBean.ERROR_UNAVAILABLE);
22
+
23
+        String err = e.getMessage();
24
+        if (err.contains("java")) {
25
+            err = "系统内部异常";
26
+        }
27
+
28
+        return ResponseBean.error(err, ResponseBean.ERROR_UNAVAILABLE);
23 29
     }
24 30
 }

+ 4
- 1
src/main/java/com/yunzhi/nanyang/mapper/TaMachineryMapper.java Näytä tiedosto

@@ -32,5 +32,8 @@ public interface TaMachineryMapper extends BaseMapper<TaMachinery> {
32 32
 
33 33
     MachineSummary getSummaryDetail(@Param("machineryId") String machineryId, @Param("location") String location);
34 34
 
35
-    IPage<MachineSummary> getOneOfTypes(IPage<MachineSummary> pg, @Param("location") String location, @Param("typeId") String typeId);
35
+    IPage<MachineSummary> getOneOfTypes(IPage<MachineSummary> pg,
36
+                                        @Param("location") String location,
37
+                                        @Param("typeId") String typeId,
38
+                                        @Param("q") String q);
36 39
 }

+ 12
- 0
src/main/java/com/yunzhi/nanyang/mapper/TaOrderMapper.java Näytä tiedosto

@@ -1,5 +1,6 @@
1 1
 package com.yunzhi.nanyang.mapper;
2 2
 
3
+import com.baomidou.mybatisplus.core.metadata.IPage;
3 4
 import com.yunzhi.nanyang.entity.TaOrder;
4 5
 import com.baomidou.mybatisplus.core.mapper.BaseMapper;
5 6
 import org.apache.ibatis.annotations.Mapper;
@@ -19,4 +20,15 @@ public interface TaOrderMapper extends BaseMapper<TaOrder> {
19 20
 
20 21
     @Select("SELECT fn_nextval(#{name})")
21 22
     int getNextOrderNO(@Param("name") String name);
23
+
24
+    IPage<TaOrder> getAdminPage(IPage<TaOrder> pg, @Param("isNotDispatched") Boolean isNotDispatched, String userId);
25
+
26
+    IPage<TaOrder> getClientPage(IPage<TaOrder> pg,
27
+                                 @Param("personId") String personId,
28
+                                 @Param("q") String q);
29
+
30
+    IPage<TaOrder> getOrderDispatched(IPage<TaOrder> pg,
31
+                                      @Param("userId") String userId,
32
+                                      @Param("workStatus") Integer workStatus,
33
+                                      @Param("q") String q);
22 34
 }

+ 3
- 0
src/main/java/com/yunzhi/nanyang/mapper/TaWorkJobMapper.java Näytä tiedosto

@@ -1,8 +1,10 @@
1 1
 package com.yunzhi.nanyang.mapper;
2 2
 
3
+import com.baomidou.mybatisplus.core.metadata.IPage;
3 4
 import com.yunzhi.nanyang.entity.TaWorkJob;
4 5
 import com.baomidou.mybatisplus.core.mapper.BaseMapper;
5 6
 import org.apache.ibatis.annotations.Mapper;
7
+import org.apache.ibatis.annotations.Param;
6 8
 
7 9
 /**
8 10
  * <p>
@@ -15,4 +17,5 @@ import org.apache.ibatis.annotations.Mapper;
15 17
 @Mapper
16 18
 public interface TaWorkJobMapper extends BaseMapper<TaWorkJob> {
17 19
 
20
+    IPage<TaWorkJob> getPageBy(IPage<TaWorkJob> pg, @Param("userId") String userId);
18 21
 }

+ 1
- 1
src/main/java/com/yunzhi/nanyang/service/ITaMachineryService.java Näytä tiedosto

@@ -24,7 +24,7 @@ public interface ITaMachineryService extends IBaseService<TaMachinery> {
24 24
 
25 25
     boolean updateRegionName(String regionId, String regionName);
26 26
 
27
-    IPage<MachineSummary> getSummaryList(IPage<MachineSummary> pg, String location, String typeId, String orgId);
27
+    IPage<MachineSummary> getSummaryList(IPage<MachineSummary> pg, String location, String typeId, String orgId, String q);
28 28
 
29 29
     MachineSummary getSummaryDetail(String machineryId, String location, Boolean attached);
30 30
 }

+ 2
- 0
src/main/java/com/yunzhi/nanyang/service/ITaMessageService.java Näytä tiedosto

@@ -2,6 +2,7 @@ package com.yunzhi.nanyang.service;
2 2
 
3 3
 import com.yunzhi.nanyang.entity.TaMessage;
4 4
 import com.baomidou.mybatisplus.extension.service.IService;
5
+import com.yunzhi.nanyang.event.WorkExpiredEvent;
5 6
 
6 7
 /**
7 8
  * <p>
@@ -13,4 +14,5 @@ import com.baomidou.mybatisplus.extension.service.IService;
13 14
  */
14 15
 public interface ITaMessageService extends IBaseService<TaMessage> {
15 16
 
17
+    void sendMessage(WorkExpiredEvent evt);
16 18
 }

+ 9
- 1
src/main/java/com/yunzhi/nanyang/service/ITaOrderService.java Näytä tiedosto

@@ -1,7 +1,9 @@
1 1
 package com.yunzhi.nanyang.service;
2 2
 
3
+import com.baomidou.mybatisplus.core.metadata.IPage;
4
+import com.yunzhi.nanyang.entity.SysUser;
3 5
 import com.yunzhi.nanyang.entity.TaOrder;
4
-import com.baomidou.mybatisplus.extension.service.IService;
6
+import com.yunzhi.nanyang.entity.TaPerson;
5 7
 
6 8
 /**
7 9
  * <p>
@@ -14,4 +16,10 @@ import com.baomidou.mybatisplus.extension.service.IService;
14 16
 public interface ITaOrderService extends IBaseService<TaOrder> {
15 17
 
16 18
     String getNextOrderNO();
19
+
20
+    IPage<TaOrder> getAdminPage(IPage<TaOrder> pg, Boolean isNotDispatched, SysUser sysUser);
21
+
22
+    IPage<TaOrder> getClientPage(IPage<TaOrder> pg, TaPerson taPerson, SysUser sysUser, Integer workStatus, String q);
23
+
24
+    boolean updateStatus(String orderId, String statusColumn, int statusValue);
17 25
 }

+ 6
- 0
src/main/java/com/yunzhi/nanyang/service/ITaWorkJobService.java Näytä tiedosto

@@ -1,5 +1,8 @@
1 1
 package com.yunzhi.nanyang.service;
2 2
 
3
+import com.baomidou.mybatisplus.core.metadata.IPage;
4
+import com.yunzhi.nanyang.entity.TaDispatch;
5
+import com.yunzhi.nanyang.entity.TaOrder;
3 6
 import com.yunzhi.nanyang.entity.TaWorkJob;
4 7
 import com.baomidou.mybatisplus.extension.service.IService;
5 8
 
@@ -13,4 +16,7 @@ import com.baomidou.mybatisplus.extension.service.IService;
13 16
  */
14 17
 public interface ITaWorkJobService extends IBaseService<TaWorkJob> {
15 18
 
19
+    TaWorkJob createByDispatch(TaDispatch taDispatch, TaOrder taOrder) throws Exception;
20
+
21
+    IPage<TaWorkJob> getPageBy(IPage<TaWorkJob> pg, String userId);
16 22
 }

+ 2
- 2
src/main/java/com/yunzhi/nanyang/service/impl/TaMachineryServiceImpl.java Näytä tiedosto

@@ -96,12 +96,12 @@ public class TaMachineryServiceImpl extends BaseServiceImpl<TaMachineryMapper, T
96 96
     }
97 97
 
98 98
     @Override
99
-    public IPage<MachineSummary> getSummaryList(IPage<MachineSummary> pg, String location, String typeId, String orgId) {
99
+    public IPage<MachineSummary> getSummaryList(IPage<MachineSummary> pg, String location, String typeId, String orgId, String q) {
100 100
 
101 101
         // 有没有 orgId 实际上用来区分是否农机手端
102 102
         if (StringUtils.isEmpty(orgId)) {
103 103
             // 农户端, 实际上过滤的是所有组织下的所有分类的其中一个机器
104
-            return baseMapper.getOneOfTypes(pg, location, typeId);
104
+            return baseMapper.getOneOfTypes(pg, location, typeId, q);
105 105
         } else {
106 106
             // 农机手端
107 107
             return baseMapper.getSummaryList(pg, location, typeId, orgId);

+ 8
- 0
src/main/java/com/yunzhi/nanyang/service/impl/TaMessageServiceImpl.java Näytä tiedosto

@@ -1,9 +1,12 @@
1 1
 package com.yunzhi.nanyang.service.impl;
2 2
 
3
+import com.yunzhi.nanyang.entity.TaDispatch;
3 4
 import com.yunzhi.nanyang.entity.TaMessage;
5
+import com.yunzhi.nanyang.event.WorkExpiredEvent;
4 6
 import com.yunzhi.nanyang.mapper.TaMessageMapper;
5 7
 import com.yunzhi.nanyang.service.ITaMessageService;
6 8
 import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
9
+import org.springframework.scheduling.annotation.Async;
7 10
 import org.springframework.stereotype.Service;
8 11
 
9 12
 /**
@@ -17,4 +20,9 @@ import org.springframework.stereotype.Service;
17 20
 @Service
18 21
 public class TaMessageServiceImpl extends BaseServiceImpl<TaMessageMapper, TaMessage> implements ITaMessageService {
19 22
 
23
+    @Async
24
+    @Override
25
+    public void sendMessage(WorkExpiredEvent evt) {
26
+        evt.getTaDispatch();
27
+    }
20 28
 }

+ 30
- 1
src/main/java/com/yunzhi/nanyang/service/impl/TaOrderServiceImpl.java Näytä tiedosto

@@ -1,11 +1,14 @@
1 1
 package com.yunzhi.nanyang.service.impl;
2 2
 
3
+import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper;
4
+import com.baomidou.mybatisplus.core.metadata.IPage;
3 5
 import com.yunzhi.nanyang.common.DateUtils;
4 6
 import com.yunzhi.nanyang.common.StringUtils;
7
+import com.yunzhi.nanyang.entity.SysUser;
5 8
 import com.yunzhi.nanyang.entity.TaOrder;
9
+import com.yunzhi.nanyang.entity.TaPerson;
6 10
 import com.yunzhi.nanyang.mapper.TaOrderMapper;
7 11
 import com.yunzhi.nanyang.service.ITaOrderService;
8
-import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
9 12
 import org.springframework.stereotype.Service;
10 13
 
11 14
 import java.time.LocalDateTime;
@@ -29,4 +32,30 @@ public class TaOrderServiceImpl extends BaseServiceImpl<TaOrderMapper, TaOrder>
29 32
         int next = baseMapper.getNextOrderNO(prefix);
30 33
         return prefix + StringUtils.lpad(String.valueOf(next), "0", 6);
31 34
     }
35
+
36
+    @Override
37
+    public IPage<TaOrder> getAdminPage(IPage<TaOrder> pg, Boolean isNotDispatched, SysUser sysUser) {
38
+        return baseMapper.getAdminPage(pg, isNotDispatched, null == sysUser ? null : sysUser.getUserId());
39
+    }
40
+
41
+    @Override
42
+    public IPage<TaOrder> getClientPage(IPage<TaOrder> pg, TaPerson taPerson, SysUser sysUser, Integer workStatus, String q) {
43
+        String userId = null == sysUser ? null : sysUser.getUserId();
44
+        String personId = null == taPerson ? null : taPerson.getPersonId();
45
+
46
+        if (!StringUtils.isEmpty(userId)) {
47
+            return baseMapper.getOrderDispatched(pg, userId, workStatus, q);
48
+        }
49
+
50
+        return baseMapper.getClientPage(pg, personId, q);
51
+    }
52
+
53
+    @Override
54
+    public boolean updateStatus(String orderId, String statusColumn, int statusValue) {
55
+        UpdateWrapper<TaOrder> updateWrapper = new UpdateWrapper<>();
56
+        updateWrapper.set(statusColumn, statusValue);
57
+        updateWrapper.eq("order_id", orderId);
58
+
59
+        return update(updateWrapper);
60
+    }
32 61
 }

+ 33
- 0
src/main/java/com/yunzhi/nanyang/service/impl/TaWorkJobServiceImpl.java Näytä tiedosto

@@ -1,11 +1,17 @@
1 1
 package com.yunzhi.nanyang.service.impl;
2 2
 
3
+import com.baomidou.mybatisplus.core.metadata.IPage;
4
+import com.yunzhi.nanyang.common.Constants;
5
+import com.yunzhi.nanyang.entity.TaDispatch;
6
+import com.yunzhi.nanyang.entity.TaOrder;
3 7
 import com.yunzhi.nanyang.entity.TaWorkJob;
4 8
 import com.yunzhi.nanyang.mapper.TaWorkJobMapper;
5 9
 import com.yunzhi.nanyang.service.ITaWorkJobService;
6 10
 import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
7 11
 import org.springframework.stereotype.Service;
8 12
 
13
+import java.time.LocalDateTime;
14
+
9 15
 /**
10 16
  * <p>
11 17
  * 作业表 服务实现类
@@ -17,4 +23,31 @@ import org.springframework.stereotype.Service;
17 23
 @Service
18 24
 public class TaWorkJobServiceImpl extends BaseServiceImpl<TaWorkJobMapper, TaWorkJob> implements ITaWorkJobService {
19 25
 
26
+    @Override
27
+    public TaWorkJob createByDispatch(TaDispatch taDispatch, TaOrder taOrder) throws Exception {
28
+
29
+        TaWorkJob taWorkJob = new TaWorkJob();
30
+        LocalDateTime now = LocalDateTime.now();
31
+        taWorkJob.setJobId(null);
32
+        taWorkJob.setDispatchId(taDispatch.getDispatchId());
33
+        taWorkJob.setOrderId(taOrder.getOrderId());
34
+        taWorkJob.setWorkerId(taDispatch.getWorkerId());
35
+        taWorkJob.setMachineryId(taDispatch.getMachineryId());
36
+        taWorkJob.setStartDate(now);
37
+        taWorkJob.setOrgId(taDispatch.getOrgId());
38
+        taWorkJob.setStatus(Constants.WORK_READY);
39
+        taWorkJob.setCreateUser(taDispatch.getWorkerId());
40
+        taWorkJob.setCreateDate(now);
41
+
42
+        if (!save(taWorkJob)) {
43
+            throw new Exception("生成作业信息异常");
44
+        }
45
+
46
+        return taWorkJob;
47
+    }
48
+
49
+    @Override
50
+    public IPage<TaWorkJob> getPageBy(IPage<TaWorkJob> pg, String userId) {
51
+        return baseMapper.getPageBy(pg, userId);
52
+    }
20 53
 }

+ 16
- 0
src/main/java/com/yunzhi/nanyang/task/WorkExpire.java Näytä tiedosto

@@ -0,0 +1,16 @@
1
+package com.yunzhi.nanyang.task;
2
+
3
+import org.springframework.scheduling.annotation.Scheduled;
4
+import org.springframework.stereotype.Component;
5
+
6
+@Component
7
+public class WorkExpire {
8
+
9
+    /**
10
+     * 每天 9 点查询超时订单, 只提醒一次,昨天的
11
+     */
12
+    @Scheduled(cron = "0 0 9 * * ?")
13
+    public void execute() {
14
+
15
+    }
16
+}

+ 3
- 0
src/main/resources/application.yml Näytä tiedosto

@@ -76,6 +76,9 @@ weixin:
76 76
 spring:
77 77
   application:
78 78
     name: demo
79
+#  jackson:
80
+#    date-format: yyyy-MM-dd HH:mm:ss
81
+#    time-zone: GMT+8
79 82
   profiles:
80 83
     active: @profileActive@
81 84
 

+ 12
- 4
src/main/resources/mapper/TaMachineryMapper.xml Näytä tiedosto

@@ -41,13 +41,21 @@
41 41
             count( * ) AS num
42 42
         FROM
43 43
             ta_machinery t
44
-        INNER JOIN ta_machinery s ON t.org_id = s.org_id
45
-            AND t.type_id = s.type_id
46
-        INNER JOIN ta_org m ON m.org_id = t.org_id
44
+            INNER JOIN ta_machinery s ON t.org_id = s.org_id
45
+                AND t.type_id = s.type_id
46
+            INNER JOIN ta_org m ON m.org_id = t.org_id
47
+            INNER JOIN td_machinery_type n ON n.type_id = t.type_id
47 48
         WHERE
48
-            t.machinery_id &lt; s.machinery_id
49
+            t.`status` &gt; -1
50
+            AND t.machinery_id &lt;= s.machinery_id
49 51
         <if test="typeId != null and typeId != ''">
50 52
             AND t.type_id = #{typeId}
53
+        </if>
54
+        <if test="q != null and q != ''">
55
+            AND (
56
+                t.`name` LIKE CONCAT('%', #{q}, '%')
57
+                OR n.`name` LIKE CONCAT('%', #{q}, '%')
58
+            )
51 59
         </if>
52 60
          GROUP BY
53 61
             t.org_id,

+ 72
- 0
src/main/resources/mapper/TaOrderMapper.xml Näytä tiedosto

@@ -2,4 +2,76 @@
2 2
 <!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
3 3
 <mapper namespace="com.yunzhi.nanyang.mapper.TaOrderMapper">
4 4
 
5
+    <select id="getAdminPage" resultType="com.yunzhi.nanyang.entity.TaOrder">
6
+        SELECT DISTINCT
7
+            t.*,
8
+            m.`name` as org_name
9
+        FROM
10
+            ta_order t
11
+            <if test="userId != null and userId != ''">
12
+                INNER JOIN sys_user_data_scope s ON t.org_id = s.org_id
13
+                AND s.user_id = #{userId}
14
+            </if>
15
+            INNER JOIN ta_org m ON m.org_id = t.org_id
16
+        WHERE
17
+            t.`status` = 1
18
+          <if test="isNotDispatched">
19
+              AND t.pay_status = 1
20
+              AND t.dispatch_status = 0
21
+          </if>
22
+        ORDER BY
23
+            t.create_date DESC
24
+    </select>
25
+    <select id="getClientPage" resultType="com.yunzhi.nanyang.entity.TaOrder">
26
+        SELECT DISTINCT
27
+            t.*,
28
+            m.`name` as org_name,
29
+            n.nick_name as person_name,
30
+            n.phone as phone
31
+        FROM
32
+        ta_order t
33
+            INNER JOIN ta_org m ON m.org_id = t.org_id
34
+            INNER JOIN ta_person n ON n.person_id = t.person_id
35
+        WHERE
36
+            t.`status` = 1
37
+        <if test="personId != null and personId != ''">
38
+            AND t.person_id = #{personId}
39
+        </if>
40
+        <if test="q != null and q != ''">
41
+            AND (
42
+                n.nick_name LIKE CONCAT('%', #{q}, '%')
43
+                OR n.phone LIKE CONCAT('%', #{q}, '%')
44
+            )
45
+        </if>
46
+        ORDER BY
47
+            t.create_date DESC
48
+    </select>
49
+    <select id="getOrderDispatched" resultType="com.yunzhi.nanyang.entity.TaOrder">
50
+        SELECT DISTINCT
51
+            t.*,
52
+            m.`name` as org_name,
53
+            n.nick_name as person_name,
54
+            n.phone as phone
55
+        FROM
56
+            ta_order t
57
+        INNER JOIN ta_org m ON m.org_id = t.org_id
58
+        INNER JOIN ta_person n ON n.person_id = t.person_id
59
+        INNER JOIN ta_dispatch d ON d.order_id = t.order_id AND d.`status` = 1
60
+        WHERE
61
+            t.`status` = 1
62
+            AND d.worker_id = #{userId}
63
+        <if test="workStatus != null">
64
+            AND t.dispatch_status = 1
65
+            AND t.work_status = #{workStatus}
66
+        </if>
67
+        <if test="q != null and q != ''">
68
+            AND (
69
+                n.nick_name LIKE CONCAT('%', #{q}, '%')
70
+                OR n.phone LIKE CONCAT('%', #{q}, '%')
71
+            )
72
+        </if>
73
+        ORDER BY
74
+            t.work_status ASC,
75
+            t.create_date DESC
76
+    </select>
5 77
 </mapper>

+ 24
- 0
src/main/resources/mapper/TaWorkJobMapper.xml Näytä tiedosto

@@ -2,4 +2,28 @@
2 2
 <!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
3 3
 <mapper namespace="com.yunzhi.nanyang.mapper.TaWorkJobMapper">
4 4
 
5
+    <select id="getPageBy" resultType="com.yunzhi.nanyang.entity.TaWorkJob">
6
+        SELECT
7
+            t.*,
8
+            s.person_id,
9
+            s.appointment_date,
10
+            m.phone,
11
+            s.create_date as order_date,
12
+            s.charges,
13
+            m.nick_name as person_name,
14
+            s.machinery_name
15
+        FROM
16
+            ta_work_job t
17
+                INNER JOIN ta_order s ON t.order_id = s.order_id
18
+                INNER JOIN ta_person m on m.person_id = s.person_id
19
+                AND s.`status` = 1
20
+        WHERE
21
+            t.`status` &gt; -1
22
+          <if test="userId != null and userId != ''">
23
+              AND t.worker_id = #{userId}
24
+          </if>
25
+        ORDER BY
26
+            t.`status` ASC,
27
+            t.create_date DESC
28
+    </select>
5 29
 </mapper>