Commit 8cafb4ba8fbce8f5e412ba31ed017d4b2cf9bb5e

Authored by 肖超群
2 parents dfd4e472 92e85e07

Merge branch 'develop' of http://www.huahengrobot.com:90/wms/wms4 into develop

huaheng-wms-core/src/main/java/org/jeecg/modules/wms/api/mobile/controller/MobileController.java
1   -package org.jeecg.modules.wms.api.mobile.controller;
2   -
3   -import com.alibaba.fastjson.JSONException;
4   -import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
5   -import com.baomidou.mybatisplus.core.toolkit.Wrappers;
6   -import io.swagger.annotations.Api;
7   -import io.swagger.annotations.ApiOperation;
8   -import org.jeecg.common.api.vo.Result;
9   -import org.jeecg.modules.system.entity.SysDictItem;
10   -import org.jeecg.modules.system.service.impl.SysDictItemServiceImpl;
11   -import org.jeecg.modules.wms.api.mobile.entity.TvTaskVo;
12   -import org.jeecg.modules.wms.monitor.apkinfo.entity.ApkInfo;
13   -import org.jeecg.modules.wms.monitor.apkinfo.service.IApkInfoService;
14   -import org.jeecg.modules.wms.task.taskHeader.entity.TaskDetail;
15   -import org.jeecg.modules.wms.task.taskHeader.entity.TaskHeader;
16   -import org.jeecg.modules.wms.task.taskHeader.service.impl.TaskDetailServiceImpl;
17   -import org.jeecg.modules.wms.task.taskHeader.service.impl.TaskHeaderServiceImpl;
18   -import org.jeecg.utils.StringUtils;
19   -import org.jeecg.utils.constant.QuantityConstant;
20   -import org.springframework.beans.factory.annotation.Value;
21   -import org.springframework.web.bind.annotation.*;
22   -
23   -import javax.annotation.Resource;
24   -import java.util.*;
25   -
26   -/**
27   - */
28   -@Api(tags = "Mobile")
29   -@RestController
30   -@RequestMapping("/api/mobile")
31   -public class MobileController {
32   -
33   - @Value(value = "${server.servlet.context-path}")
34   - private String ctx;
35   -
36   - @Resource
37   - private IApkInfoService apkInfoService;
38   -
39   - @Resource
40   - private TaskHeaderServiceImpl taskHeaderService;
41   -
42   - @Resource
43   - private SysDictItemServiceImpl sysDictItemService;
44   -
45   - @Resource
46   - private TaskDetailServiceImpl taskDetailService;
47   -
48   - @GetMapping("taskOfStation")
49   - public Result<List<TvTaskVo>> importExcel(String code) {
50   - List<String> stationList = new ArrayList<>();
51   - if (StringUtils.isNotEmpty(code)) {
52   - stationList = Arrays.asList(code.split(","));
53   - }
54   -
55   - HashMap<String, String> typeMap = new HashMap<>();
56   - typeMap.put("100", "整盘入库");
57   - typeMap.put("200", "补充入库");
58   - typeMap.put("300", "整盘出库");
59   - typeMap.put("400", "分拣出库");
60   - typeMap.put("500", "空容器入库");
61   - typeMap.put("600", "空容器出库");
62   - typeMap.put("700", "盘点");
63   - typeMap.put("800", "移库");
64   - typeMap.put("900", "出库查看");
65   - typeMap.put("1000", "换站");
66   - typeMap.put("1100", "空托盘组入库");
67   - typeMap.put("1200", "空托盘组出库");
68   - typeMap.put("1300", "空托盘组换站");
69   -
70   - HashMap<String, String> statusMap = new HashMap<>();
71   - statusMap.put("1", "生成任务");
72   - statusMap.put("10", "下发任务");
73   - statusMap.put("50", "到达拣选台");
74   - statusMap.put("100", "任务完成");
75   -
76   - LambdaQueryWrapper<TaskHeader> hQuery = Wrappers.lambdaQuery();
77   - hQuery.eq(TaskHeader::getStatus, QuantityConstant.TASK_STATUS_ARRIVED_STATION)
78   - .in(stationList.size() > 0, TaskHeader::getToPortCode, stationList);
79   - List<TaskHeader> headers = taskHeaderService.list(hQuery);
80   -
81   - List<TvTaskVo> list = new ArrayList<>();
82   - for (TaskHeader header : headers) {
83   - header.setUserdef1(typeMap.get(header.getTaskType().toString()));
84   - header.setUserdef2(statusMap.get(header.getStatus().toString()));
85   - TvTaskVo vo = new TvTaskVo();
86   - LambdaQueryWrapper<TaskDetail> dQuery = Wrappers.lambdaQuery();
87   - dQuery.eq(TaskDetail::getTaskHeaderId, header.getId());
88   - List<TaskDetail> details = taskDetailService.list(dQuery);
89   -
90   - vo.setTaskHeader(header);
91   - vo.setTaskDetailList(details);
92   - list.add(vo);
93   - }
94   - return Result.OK("", list);
95   - }
96   -
97   - @PostMapping("/getUpdateApkInfo")
98   - @ApiOperation("获取apk更新信息")
99   - public Result getUpdateApkInfo(@RequestBody Map<String, String> param) {
100   - System.out.println("getUpdateApkInfo pkgName:" + param.get("pkgName"));
101   - String pkgName = param.get("pkgName");
102   - String versionCode = param.get("versionCode");
103   - if (StringUtils.isEmpty(pkgName)) {
104   - throw new JSONException("pkgName不能为空");
105   - }
106   - if (StringUtils.isEmpty(versionCode)) {
107   - throw new JSONException("versionCode不能为空");
108   - }
109   -
110   - LambdaQueryWrapper<ApkInfo> query = Wrappers.lambdaQuery();
111   - query.eq(ApkInfo::getPkgname, pkgName)
112   - .orderByDesc(ApkInfo::getVersioncode)
113   - .last(" limit 1");
114   - ApkInfo apkInfo = apkInfoService.getOne(query);
115   - if (apkInfo == null ){
116   - return Result.error("服务器上找不到安装包:" + pkgName);
117   - }else if(apkInfo.getVersioncode() <= Integer.parseInt(versionCode)){
118   - return Result.ok("当前已经是最新版本");
119   - }
120   - apkInfo.setUrl(ctx + apkInfo.getUrl());
121   - return Result.ok(apkInfo);
122   - }
123   -}
  1 +package org.jeecg.modules.wms.api.mobile.controller;
  2 +
  3 +import com.alibaba.fastjson.JSONException;
  4 +import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
  5 +import com.baomidou.mybatisplus.core.toolkit.Wrappers;
  6 +import io.swagger.annotations.Api;
  7 +import io.swagger.annotations.ApiOperation;
  8 +import org.jeecg.common.api.vo.Result;
  9 +import org.jeecg.modules.system.entity.SysDictItem;
  10 +import org.jeecg.modules.system.service.impl.SysDictItemServiceImpl;
  11 +import org.jeecg.modules.wms.api.mobile.entity.TvTaskVo;
  12 +import org.jeecg.modules.wms.monitor.apkinfo.entity.ApkInfo;
  13 +import org.jeecg.modules.wms.monitor.apkinfo.service.IApkInfoService;
  14 +import org.jeecg.modules.wms.task.taskHeader.entity.TaskDetail;
  15 +import org.jeecg.modules.wms.task.taskHeader.entity.TaskHeader;
  16 +import org.jeecg.modules.wms.task.taskHeader.service.impl.TaskDetailServiceImpl;
  17 +import org.jeecg.modules.wms.task.taskHeader.service.impl.TaskHeaderServiceImpl;
  18 +import org.jeecg.utils.StringUtils;
  19 +import org.jeecg.utils.constant.QuantityConstant;
  20 +import org.springframework.beans.factory.annotation.Value;
  21 +import org.springframework.web.bind.annotation.*;
  22 +
  23 +import javax.annotation.Resource;
  24 +import java.util.*;
  25 +
  26 +/**
  27 + */
  28 +@Api(tags = "Mobile")
  29 +@RestController
  30 +@RequestMapping("/api/mobile")
  31 +public class MobileController {
  32 +
  33 + @Value(value = "${server.servlet.context-path}")
  34 + private String ctx;
  35 +
  36 + @Resource
  37 + private IApkInfoService apkInfoService;
  38 +
  39 + @Resource
  40 + private TaskHeaderServiceImpl taskHeaderService;
  41 +
  42 + @Resource
  43 + private SysDictItemServiceImpl sysDictItemService;
  44 +
  45 + @Resource
  46 + private TaskDetailServiceImpl taskDetailService;
  47 +
  48 + @GetMapping("taskOfStation")
  49 + public Result<List<TvTaskVo>> importExcel(String code) {
  50 + List<String> stationList = new ArrayList<>();
  51 + if (StringUtils.isNotEmpty(code)) {
  52 + stationList = Arrays.asList(code.split(","));
  53 + }
  54 +
  55 + HashMap<String, String> typeMap = new HashMap<>();
  56 + typeMap.put("100", "整盘入库");
  57 + typeMap.put("200", "补充入库");
  58 + typeMap.put("300", "整盘出库");
  59 + typeMap.put("400", "分拣出库");
  60 + typeMap.put("500", "空容器入库");
  61 + typeMap.put("600", "空容器出库");
  62 + typeMap.put("700", "盘点");
  63 + typeMap.put("800", "移库");
  64 + typeMap.put("900", "出库查看");
  65 + typeMap.put("1000", "换站");
  66 + typeMap.put("1100", "空托盘组入库");
  67 + typeMap.put("1200", "空托盘组出库");
  68 + typeMap.put("1300", "空托盘组换站");
  69 +
  70 + HashMap<String, String> statusMap = new HashMap<>();
  71 + statusMap.put("1", "生成任务");
  72 + statusMap.put("10", "下发任务");
  73 + statusMap.put("50", "到达拣选台");
  74 + statusMap.put("100", "任务完成");
  75 +
  76 + LambdaQueryWrapper<TaskHeader> hQuery = Wrappers.lambdaQuery();
  77 + hQuery.eq(TaskHeader::getStatus, QuantityConstant.TASK_STATUS_ARRIVED_STATION)
  78 + .in(stationList.size() > 0, TaskHeader::getToPortCode, stationList);
  79 + List<TaskHeader> headers = taskHeaderService.list(hQuery);
  80 +
  81 + List<TvTaskVo> list = new ArrayList<>();
  82 + for (TaskHeader header : headers) {
  83 + header.setUserdef1(typeMap.get(header.getTaskType().toString()));
  84 + header.setUserdef2(statusMap.get(header.getStatus().toString()));
  85 + TvTaskVo vo = new TvTaskVo();
  86 + LambdaQueryWrapper<TaskDetail> dQuery = Wrappers.lambdaQuery();
  87 + dQuery.eq(TaskDetail::getTaskHeaderId, header.getId());
  88 + List<TaskDetail> details = taskDetailService.list(dQuery);
  89 +
  90 + vo.setTaskHeader(header);
  91 + vo.setTaskDetailList(details);
  92 + list.add(vo);
  93 + }
  94 + return Result.OK("", list);
  95 + }
  96 +
  97 + @PostMapping("/getUpdateApkInfo")
  98 + @ApiOperation("获取apk更新信息")
  99 + public Result getUpdateApkInfo(@RequestBody Map<String, String> param) {
  100 + System.out.println("getUpdateApkInfo pkgName:" + param.get("pkgName"));
  101 + String pkgName = param.get("pkgName");
  102 + String versionCode = param.get("versionCode");
  103 + if (StringUtils.isEmpty(pkgName)) {
  104 + throw new JSONException("pkgName不能为空");
  105 + }
  106 + if (StringUtils.isEmpty(versionCode)) {
  107 + throw new JSONException("versionCode不能为空");
  108 + }
  109 +
  110 + LambdaQueryWrapper<ApkInfo> query = Wrappers.lambdaQuery();
  111 + query.eq(ApkInfo::getPkgname, pkgName)
  112 + .orderByDesc(ApkInfo::getVersioncode)
  113 + .last(" limit 1");
  114 + ApkInfo apkInfo = apkInfoService.getOne(query);
  115 + if (apkInfo == null ){
  116 + return new Result(400, "服务器上找不到安装包:" + pkgName);
  117 + }else if(apkInfo.getVersioncode() <= Integer.parseInt(versionCode)){
  118 + return new Result(400, "当前已经是最新版本");
  119 + }
  120 + apkInfo.setUrl(ctx + apkInfo.getUrl());
  121 + return Result.ok(apkInfo);
  122 + }
  123 +}
... ...