package com.zy.asrs.wms.asrs.controller;
|
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
import com.zy.asrs.common.domain.CodeRes;
|
import com.zy.asrs.common.domain.enums.LoginSystemType;
|
import com.zy.asrs.framework.annotations.ManagerAuth;
|
import com.zy.asrs.framework.common.Cools;
|
import com.zy.asrs.framework.common.R;
|
import com.zy.asrs.wms.asrs.entity.Order;
|
import com.zy.asrs.wms.asrs.entity.dto.OrderInfoDto;
|
import com.zy.asrs.wms.asrs.entity.param.BatchMergeOrdersParam;
|
import com.zy.asrs.wms.asrs.service.MobileService;
|
import com.zy.asrs.wms.asrs.service.OrderService;
|
import com.zy.asrs.wms.system.controller.BaseController;
|
import com.zy.asrs.wms.system.entity.User;
|
import com.zy.asrs.wms.system.entity.UserLogin;
|
import com.zy.asrs.wms.system.service.UserLoginService;
|
import com.zy.asrs.wms.system.service.UserService;
|
import io.jsonwebtoken.lang.Collections;
|
import io.netty.util.internal.StringUtil;
|
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Value;
|
import org.springframework.web.bind.annotation.*;
|
|
import java.util.*;
|
|
@RequestMapping("/pda")
|
@RestController
|
public class MobileController extends BaseController {
|
|
@Value("${super.pwd}")
|
private String superPwd;
|
|
@Autowired
|
private UserService userService;
|
@Autowired
|
private UserLoginService userLoginService;
|
@Autowired
|
private OrderService orderService;
|
@Autowired
|
private MobileService mobileService;
|
|
|
/**
|
* 入库单据--扫码获取订单明细列表
|
* @param barcode
|
* @return
|
*/
|
@PostMapping("/mat/auth")
|
public R getProductForBarcode(@RequestBody Map<String, String> barcode) {
|
if (StringUtil.isNullOrEmpty(barcode.get("barcode"))) {
|
return R.error("条码不能为空!!");
|
}
|
Order order = orderService.selectByBarcode(barcode.get("barcode"));
|
|
if (!(order.getOrderType() == 1)) {
|
return R.error("非入库订单, 不可操作!!");
|
}
|
if (order.getOrderSettle() > 2) {
|
return R.error("单据当前状态不可做入库操作!!");
|
}
|
List<OrderInfoDto> orders = orderService.getDetlForOrderId(order.getId());
|
|
return R.ok(orders);
|
|
}
|
|
|
@GetMapping("/login.action")
|
@ManagerAuth(value = ManagerAuth.Auth.NONE, memo = "登录")
|
public R loginAction(String username, String password, Boolean wms) {
|
if (username.equals("super") && password.equals(Cools.md5(superPwd))) {
|
Map<String, Object> res = new HashMap<>();
|
res.put("username", username);
|
res.put("token", Cools.enToken(System.currentTimeMillis() + username, superPwd));
|
return R.ok(res);
|
}
|
LambdaQueryWrapper<User> userWrapper = new LambdaQueryWrapper<>();
|
userWrapper.eq(User::getUsername, username);
|
User user = userService.getOne(userWrapper);
|
if (Cools.isEmpty(user)) {
|
return R.parse(CodeRes.USER_10001);
|
}
|
if (user.getStatus() != 1) {
|
return R.parse(CodeRes.USER_10002);
|
}
|
if (!user.getPassword().equals(password)) {
|
return R.parse(CodeRes.USER_10003);
|
}
|
String system = null;//登陆系统
|
if (wms) {
|
system = String.valueOf(LoginSystemType.WMS);
|
}else {
|
system = String.valueOf(LoginSystemType.WCS);
|
}
|
String token = Cools.enToken(System.currentTimeMillis() + username, user.getPassword());
|
userLoginService.remove(new LambdaQueryWrapper<UserLogin>().eq(UserLogin::getUserId, user.getId()).eq(UserLogin::getSystemCode, system));
|
UserLogin userLogin = new UserLogin();
|
userLogin.setUserId(user.getId());
|
userLogin.setToken(token);
|
userLogin.setCreateTime(new Date());
|
userLogin.setSystemCode(system);
|
// if (user.getRoleId() == 2) {
|
// userLogin.setHostId(hostService.getTop1().getId());
|
// }
|
userLoginService.save(userLogin);
|
Map<String, Object> res = new HashMap<>();
|
res.put("username", user.getUsername());
|
res.put("token", token);
|
return R.ok(res);
|
}
|
|
|
@PostMapping("/comb/auth")
|
public R combMats(@RequestBody BatchMergeOrdersParam ordersParam) {
|
if (StringUtil.isNullOrEmpty(ordersParam.getOrderNo())) {
|
return R.error("订单号不能为空!!");
|
}
|
if (StringUtil.isNullOrEmpty(ordersParam.getMergeNo())) {
|
return R.error("托盘码不能为空!!");
|
}
|
if (Collections.isEmpty(ordersParam.getOrderDetls())) {
|
return R.error("订单明细不能为空!!");
|
}
|
|
boolean result = mobileService.batchMergeOrders(ordersParam);
|
if (result) {
|
return R.ok("组托成功!!");
|
} else {
|
return R.ok("组托失败!!");
|
}
|
}
|
}
|