自动化立体仓库 - WMS系统
*
lsh
14 小时以前 a33764aa5b7c3e9b3bf55d1edc112e0ac79ece19
src/main/java/com/zy/asrs/controller/OrderPakoutController.java
@@ -1,5 +1,6 @@
package com.zy.asrs.controller;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import com.baomidou.mybatisplus.mapper.EntityWrapper;
import com.baomidou.mybatisplus.mapper.Wrapper;
@@ -9,10 +10,16 @@
import com.core.exception.CoolException;
import com.zy.asrs.entity.*;
import com.zy.asrs.entity.param.OrderDomainParam;
import com.zy.asrs.entity.param.QualityGroupListParam;
import com.zy.asrs.entity.result.OrderPakoutDetailVo;
import com.zy.asrs.entity.result.OrderPakoutMainVo;
import com.zy.asrs.entity.result.WrkTraceVo;
import com.zy.asrs.service.*;
import com.zy.common.constant.MesConstant;
import com.zy.common.model.DetlDto;
import com.zy.common.utils.HttpHandler;
import com.zy.common.web.BaseController;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.transaction.annotation.Transactional;
@@ -20,6 +27,7 @@
import java.util.*;
@Slf4j
@RestController
@RequestMapping("order/pakout")
public class OrderPakoutController extends BaseController {
@@ -42,6 +50,8 @@
    private WrkMastService wrkMastService;
    @Autowired
    private WrkMastLogService wrkMastLogService;
    @Autowired
    private ApiLogService apiLogService;
    @RequestMapping(value = "/order/nav/list/auth")
    @ManagerAuth
@@ -81,8 +91,10 @@
        EntityWrapper<OrderPakout> wrapper = new EntityWrapper<>();
        excludeTrash(param);
        convert(param, wrapper);
        if (!Cools.isEmpty(orderByField)){wrapper.orderBy(humpToLine(orderByField), "asc".equals(orderByType));} else {
            wrapper.orderBy("settle").orderBy("create_time", false);
        if (!Cools.isEmpty(orderByField)){
            wrapper.orderBy(humpToLine(orderByField), "asc".equals(orderByType));
        } else {
            wrapper.orderBy("update_time", false);
        }
        wrapper.eq("status", 1);
        return R.ok(orderService.selectPage(new Page<>(curr, limit), wrapper));
@@ -243,7 +255,7 @@
    }
    @RequestMapping(value = "/order/delete/auth")
    @ManagerAuth(memo = "手动删除订单")
    @ManagerAuth(memo = "手动删除计划组货单")
    @Transactional
    public R delete(@RequestParam Long orderId){
        orderService.remove(orderId);
@@ -255,6 +267,14 @@
//            throw new CoolException("删除订单失败");
//        }
//        orderDetlService.modifyStatus(orderId, 0);
        return R.ok();
    }
    @RequestMapping(value = "/order/abandoned/auth")
    @ManagerAuth(memo = "手动废弃计划组货单")
    @Transactional
    public R abandoned(@RequestParam Long orderId){
        orderService.updateSettle(orderId,99L,getUserId());
        return R.ok();
    }
@@ -302,15 +322,126 @@
                  @RequestParam(required = false)String orderByField,
                  @RequestParam(required = false)String orderByType,
                  @RequestParam Map<String, Object> param){
        EntityWrapper<OrderPakout> wrapper = new EntityWrapper<>();
        excludeTrash(param);
        convert(param, wrapper);
        if (!Cools.isEmpty(orderByField)){wrapper.orderBy(humpToLine(orderByField), "asc".equals(orderByType));} else {
            wrapper.orderBy("settle").orderBy("create_time", false);
        try{
            String itemName = null;
            String cstmrName = null;
            Integer settle = null;
            Integer status = null;
            Date modiTimeStart = null, modiTimeEnd = null;
            for (Map.Entry<String, Object> entry : param.entrySet()) {
                String val = String.valueOf(entry.getValue());
                if (Cools.isEmpty(val)) {
                    continue;
                }
                if (val.contains(RANGE_TIME_LINK)) {
                    String[] dates = val.split(RANGE_TIME_LINK);
                    modiTimeStart = DateUtils.convert(dates[0]);
                    modiTimeEnd = DateUtils.convert(dates[1]);
                } else if (entry.getKey().equals("settle")) {
                    settle = Integer.parseInt(val);
                } else if (entry.getKey().equals("status")) {
                    status = Integer.parseInt(val);
                }
//                else if (entry.getKey().equals("order_no")) {
//                    orderNo = val;
//                }
                else if (entry.getKey().equals("item_name")) {
                    itemName = val;
                } else if (entry.getKey().equals("cstmr_name")) {
                    cstmrName = val;
                }
            }
            List<OrderPakoutMainVo> orderPakoutMainVos = orderService.selectOrderPakoutMainVoList(itemName, cstmrName, settle, status, modiTimeStart, modiTimeEnd, curr, limit);
            Page<OrderPakoutMainVo> page = new Page<OrderPakoutMainVo>(curr, limit).setRecords(orderPakoutMainVos);
            page.setTotal(orderService.selectOrderPakoutMainVoListTotal(itemName, cstmrName, settle, status, modiTimeStart, modiTimeEnd));
            return R.ok(page);
        } catch (Exception e){
        }
        wrapper.eq("status", 1);
        return R.ok(orderService.selectPage(new Page<>(curr, limit), wrapper));
        return R.error();
    }
    @RequestMapping(value = "/actual/shipment/order/report/auth")
    @ManagerAuth(memo = "上报MES实际组货单")
    public R actualShipmentOrder(@RequestParam String itemName) {
        Long userId = null;
        try {
            userId = getUserId();
            if (Cools.isEmpty(userId)) {
                return R.error("用户异常").add("用户异常");
            }
        } catch (Exception e){
            return R.error("用户异常").add("用户异常");
        }
        List<OrderPakoutDetailVo> OrderPakoutDetailVoList = orderDetlService.selectOrderPakoutDetailVoListV1(itemName);
        if (OrderPakoutDetailVoList.isEmpty()) {
            return R.error("上报明细为空!!!").add("上报明细为空!!!");
        }
        List<String> boxList = new ArrayList<>();
        List<String> rollList = new ArrayList<>();
        for (OrderPakoutDetailVo orderDetl : OrderPakoutDetailVoList){
            if (!boxList.contains(orderDetl.getBatch())){
                boxList.add(orderDetl.getBatch());
            }
            if (!rollList.contains(orderDetl.getModel())){
                rollList.add(orderDetl.getModel());
            }
        }
        String box = String.join(",", boxList);
        String roll = String.join(",", rollList);
        QualityGroupListParam qualityGroupListParam = new QualityGroupListParam(itemName,box,roll);
        String response = "";
        boolean success = false;
        try {
            response = new HttpHandler.Builder()
                    .setUri(MesConstant.URL)
                    .setPath(MesConstant.PAKIN_URL)
                    .setJson(JSON.toJSONString(qualityGroupListParam))
                    .build()
                    .doPost();
            JSONObject jsonObject = JSON.parseObject(response);
            if (jsonObject.getBoolean("state")) {
                success = true;
                // 修改订单状态 4.完成 ===>> 16.已上报
                if (!orderService.updateItemName(itemName, 16L, userId)) {
                    throw new CoolException("服务器内部错误,请联系管理员");
                }
                return R.ok();
            } else {
                // 修改订单状态 4.完成 ===>> 17.已上报
                if (!orderService.updateItemName(itemName, 17L, userId)) {
                    throw new CoolException("服务器内部错误,请联系管理员");
                }
                log.error("请求接口失败!!!url:{};request:{};response:{}", MesConstant.URL+MesConstant.PAKIN_URL, JSON.toJSONString(qualityGroupListParam), response);
                throw new CoolException("上报mes系统失败");
            }
        } catch (Exception e) {
            // 修改订单状态 4.完成 ===>> 17.已上报
            if (!orderService.updateItemName(itemName, 17L, userId)) {
                throw new CoolException("服务器内部错误,请联系管理员");
            }
            log.error("fail", e);
        } finally {
            try {
                // 保存接口日志
                apiLogService.save(
                        "上报MES实际组货单",
                        MesConstant.URL + MesConstant.PAKIN_URL,
                        null,
                        "127.0.0.1",
                        JSON.toJSONString(qualityGroupListParam),
                        response,
                        success
                );
            } catch (Exception e) { log.error("", e); }
        }
        return R.error("上报失败").add("上报失败");
    }
}