diff --git a/huaheng-wms-core/src/main/java/org/jeecg/modules/wms/api/mobile/controller/MobileController.java b/huaheng-wms-core/src/main/java/org/jeecg/modules/wms/api/mobile/controller/MobileController.java index 6fce763..c639d1a 100644 --- a/huaheng-wms-core/src/main/java/org/jeecg/modules/wms/api/mobile/controller/MobileController.java +++ b/huaheng-wms-core/src/main/java/org/jeecg/modules/wms/api/mobile/controller/MobileController.java @@ -1,123 +1,123 @@ -package org.jeecg.modules.wms.api.mobile.controller; - -import com.alibaba.fastjson.JSONException; -import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; -import com.baomidou.mybatisplus.core.toolkit.Wrappers; -import io.swagger.annotations.Api; -import io.swagger.annotations.ApiOperation; -import org.jeecg.common.api.vo.Result; -import org.jeecg.modules.system.entity.SysDictItem; -import org.jeecg.modules.system.service.impl.SysDictItemServiceImpl; -import org.jeecg.modules.wms.api.mobile.entity.TvTaskVo; -import org.jeecg.modules.wms.monitor.apkinfo.entity.ApkInfo; -import org.jeecg.modules.wms.monitor.apkinfo.service.IApkInfoService; -import org.jeecg.modules.wms.task.taskHeader.entity.TaskDetail; -import org.jeecg.modules.wms.task.taskHeader.entity.TaskHeader; -import org.jeecg.modules.wms.task.taskHeader.service.impl.TaskDetailServiceImpl; -import org.jeecg.modules.wms.task.taskHeader.service.impl.TaskHeaderServiceImpl; -import org.jeecg.utils.StringUtils; -import org.jeecg.utils.constant.QuantityConstant; -import org.springframework.beans.factory.annotation.Value; -import org.springframework.web.bind.annotation.*; - -import javax.annotation.Resource; -import java.util.*; - -/** - */ -@Api(tags = "Mobile") -@RestController -@RequestMapping("/api/mobile") -public class MobileController { - - @Value(value = "${server.servlet.context-path}") - private String ctx; - - @Resource - private IApkInfoService apkInfoService; - - @Resource - private TaskHeaderServiceImpl taskHeaderService; - - @Resource - private SysDictItemServiceImpl sysDictItemService; - - @Resource - private TaskDetailServiceImpl taskDetailService; - - @GetMapping("taskOfStation") - public Result<List<TvTaskVo>> importExcel(String code) { - List<String> stationList = new ArrayList<>(); - if (StringUtils.isNotEmpty(code)) { - stationList = Arrays.asList(code.split(",")); - } - - HashMap<String, String> typeMap = new HashMap<>(); - typeMap.put("100", "整盘入库"); - typeMap.put("200", "补充入库"); - typeMap.put("300", "整盘出库"); - typeMap.put("400", "分拣出库"); - typeMap.put("500", "空容器入库"); - typeMap.put("600", "空容器出库"); - typeMap.put("700", "盘点"); - typeMap.put("800", "移库"); - typeMap.put("900", "出库查看"); - typeMap.put("1000", "换站"); - typeMap.put("1100", "空托盘组入库"); - typeMap.put("1200", "空托盘组出库"); - typeMap.put("1300", "空托盘组换站"); - - HashMap<String, String> statusMap = new HashMap<>(); - statusMap.put("1", "生成任务"); - statusMap.put("10", "下发任务"); - statusMap.put("50", "到达拣选台"); - statusMap.put("100", "任务完成"); - - LambdaQueryWrapper<TaskHeader> hQuery = Wrappers.lambdaQuery(); - hQuery.eq(TaskHeader::getStatus, QuantityConstant.TASK_STATUS_ARRIVED_STATION) - .in(stationList.size() > 0, TaskHeader::getToPortCode, stationList); - List<TaskHeader> headers = taskHeaderService.list(hQuery); - - List<TvTaskVo> list = new ArrayList<>(); - for (TaskHeader header : headers) { - header.setUserdef1(typeMap.get(header.getTaskType().toString())); - header.setUserdef2(statusMap.get(header.getStatus().toString())); - TvTaskVo vo = new TvTaskVo(); - LambdaQueryWrapper<TaskDetail> dQuery = Wrappers.lambdaQuery(); - dQuery.eq(TaskDetail::getTaskHeaderId, header.getId()); - List<TaskDetail> details = taskDetailService.list(dQuery); - - vo.setTaskHeader(header); - vo.setTaskDetailList(details); - list.add(vo); - } - return Result.OK("", list); - } - - @PostMapping("/getUpdateApkInfo") - @ApiOperation("获取apk更新信息") - public Result getUpdateApkInfo(@RequestBody Map<String, String> param) { - System.out.println("getUpdateApkInfo pkgName:" + param.get("pkgName")); - String pkgName = param.get("pkgName"); - String versionCode = param.get("versionCode"); - if (StringUtils.isEmpty(pkgName)) { - throw new JSONException("pkgName不能为空"); - } - if (StringUtils.isEmpty(versionCode)) { - throw new JSONException("versionCode不能为空"); - } - - LambdaQueryWrapper<ApkInfo> query = Wrappers.lambdaQuery(); - query.eq(ApkInfo::getPkgname, pkgName) - .orderByDesc(ApkInfo::getVersioncode) - .last(" limit 1"); - ApkInfo apkInfo = apkInfoService.getOne(query); - if (apkInfo == null ){ - return Result.error("服务器上找不到安装包:" + pkgName); - }else if(apkInfo.getVersioncode() <= Integer.parseInt(versionCode)){ - return Result.ok("当前已经是最新版本"); - } - apkInfo.setUrl(ctx + apkInfo.getUrl()); - return Result.ok(apkInfo); - } -} +package org.jeecg.modules.wms.api.mobile.controller; + +import com.alibaba.fastjson.JSONException; +import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; +import com.baomidou.mybatisplus.core.toolkit.Wrappers; +import io.swagger.annotations.Api; +import io.swagger.annotations.ApiOperation; +import org.jeecg.common.api.vo.Result; +import org.jeecg.modules.system.entity.SysDictItem; +import org.jeecg.modules.system.service.impl.SysDictItemServiceImpl; +import org.jeecg.modules.wms.api.mobile.entity.TvTaskVo; +import org.jeecg.modules.wms.monitor.apkinfo.entity.ApkInfo; +import org.jeecg.modules.wms.monitor.apkinfo.service.IApkInfoService; +import org.jeecg.modules.wms.task.taskHeader.entity.TaskDetail; +import org.jeecg.modules.wms.task.taskHeader.entity.TaskHeader; +import org.jeecg.modules.wms.task.taskHeader.service.impl.TaskDetailServiceImpl; +import org.jeecg.modules.wms.task.taskHeader.service.impl.TaskHeaderServiceImpl; +import org.jeecg.utils.StringUtils; +import org.jeecg.utils.constant.QuantityConstant; +import org.springframework.beans.factory.annotation.Value; +import org.springframework.web.bind.annotation.*; + +import javax.annotation.Resource; +import java.util.*; + +/** + */ +@Api(tags = "Mobile") +@RestController +@RequestMapping("/api/mobile") +public class MobileController { + + @Value(value = "${server.servlet.context-path}") + private String ctx; + + @Resource + private IApkInfoService apkInfoService; + + @Resource + private TaskHeaderServiceImpl taskHeaderService; + + @Resource + private SysDictItemServiceImpl sysDictItemService; + + @Resource + private TaskDetailServiceImpl taskDetailService; + + @GetMapping("taskOfStation") + public Result<List<TvTaskVo>> importExcel(String code) { + List<String> stationList = new ArrayList<>(); + if (StringUtils.isNotEmpty(code)) { + stationList = Arrays.asList(code.split(",")); + } + + HashMap<String, String> typeMap = new HashMap<>(); + typeMap.put("100", "整盘入库"); + typeMap.put("200", "补充入库"); + typeMap.put("300", "整盘出库"); + typeMap.put("400", "分拣出库"); + typeMap.put("500", "空容器入库"); + typeMap.put("600", "空容器出库"); + typeMap.put("700", "盘点"); + typeMap.put("800", "移库"); + typeMap.put("900", "出库查看"); + typeMap.put("1000", "换站"); + typeMap.put("1100", "空托盘组入库"); + typeMap.put("1200", "空托盘组出库"); + typeMap.put("1300", "空托盘组换站"); + + HashMap<String, String> statusMap = new HashMap<>(); + statusMap.put("1", "生成任务"); + statusMap.put("10", "下发任务"); + statusMap.put("50", "到达拣选台"); + statusMap.put("100", "任务完成"); + + LambdaQueryWrapper<TaskHeader> hQuery = Wrappers.lambdaQuery(); + hQuery.eq(TaskHeader::getStatus, QuantityConstant.TASK_STATUS_ARRIVED_STATION) + .in(stationList.size() > 0, TaskHeader::getToPortCode, stationList); + List<TaskHeader> headers = taskHeaderService.list(hQuery); + + List<TvTaskVo> list = new ArrayList<>(); + for (TaskHeader header : headers) { + header.setUserdef1(typeMap.get(header.getTaskType().toString())); + header.setUserdef2(statusMap.get(header.getStatus().toString())); + TvTaskVo vo = new TvTaskVo(); + LambdaQueryWrapper<TaskDetail> dQuery = Wrappers.lambdaQuery(); + dQuery.eq(TaskDetail::getTaskHeaderId, header.getId()); + List<TaskDetail> details = taskDetailService.list(dQuery); + + vo.setTaskHeader(header); + vo.setTaskDetailList(details); + list.add(vo); + } + return Result.OK("", list); + } + + @PostMapping("/getUpdateApkInfo") + @ApiOperation("获取apk更新信息") + public Result getUpdateApkInfo(@RequestBody Map<String, String> param) { + System.out.println("getUpdateApkInfo pkgName:" + param.get("pkgName")); + String pkgName = param.get("pkgName"); + String versionCode = param.get("versionCode"); + if (StringUtils.isEmpty(pkgName)) { + throw new JSONException("pkgName不能为空"); + } + if (StringUtils.isEmpty(versionCode)) { + throw new JSONException("versionCode不能为空"); + } + + LambdaQueryWrapper<ApkInfo> query = Wrappers.lambdaQuery(); + query.eq(ApkInfo::getPkgname, pkgName) + .orderByDesc(ApkInfo::getVersioncode) + .last(" limit 1"); + ApkInfo apkInfo = apkInfoService.getOne(query); + if (apkInfo == null ){ + return new Result(400, "服务器上找不到安装包:" + pkgName); + }else if(apkInfo.getVersioncode() <= Integer.parseInt(versionCode)){ + return new Result(400, "当前已经是最新版本"); + } + apkInfo.setUrl(ctx + apkInfo.getUrl()); + return Result.ok(apkInfo); + } +}