自动化立体仓库 - WMS系统
*
lsh
昨天 aacf537c160d210beea3c37a18f43f3183414ac0
src/main/java/com/zy/asrs/controller/LocDetlController.java
@@ -9,21 +9,15 @@
import com.baomidou.mybatisplus.mapper.Wrapper;
import com.baomidou.mybatisplus.plugins.Page;
import com.core.annotations.ManagerAuth;
import com.core.common.BaseRes;
import com.core.common.Cools;
import com.core.common.DateUtils;
import com.core.common.R;
import com.zy.asrs.entity.LocDetl;
import com.zy.asrs.entity.ManLocDetl;
import com.zy.asrs.entity.Mat;
import com.core.common.*;
import com.zy.asrs.entity.*;
import com.zy.asrs.entity.param.OrderInspectionRollParam;
import com.zy.asrs.entity.param.OrderMesXGHYParam;
import com.zy.asrs.entity.param.QualityGroupListParam;
import com.zy.asrs.entity.result.OrderPakoutDetailVo;
import com.zy.asrs.mapper.LocDetlMapper;
import com.zy.asrs.service.ApiLogService;
import com.zy.asrs.service.LocDetlService;
import com.zy.asrs.service.ManLocDetlService;
import com.zy.asrs.service.MatService;
import com.zy.asrs.service.*;
import com.zy.asrs.service.impl.LocMastServiceImpl;
import com.zy.common.utils.HttpHandler;
import com.zy.common.web.BaseController;
import org.springframework.beans.factory.annotation.Autowired;
@@ -40,18 +34,26 @@
    @Autowired
    private LocDetlService locDetlService;
    @Autowired
    private LocDetlMapper locDetlMapper;
    @Autowired
    private MatService matService;
    @Autowired
    private ApiLogService apiLogService;
    @Autowired
    private SnowflakeIdWorker snowflakeIdWorker;
    @Value("${srXghyMes.qualityFinishedCheckoutUrl}")
    private String qualityFinishedCheckoutUrl;
    @Value("${srXghyMes.qualityFinishedCheckout}")
    private String qualityFinishedCheckout;
    @Value("${srXghyMes.productInventoryUrlSaveListDto}")
    private String productInventoryUrlSaveListDto;
    @Value("${srXghyMes.productInventorySaveListDto}")
    private String productInventorySaveListDto;
    @Autowired
    private LocMastServiceImpl locMastService;
    @RequestMapping(value = "/locDetl/update")
    public R update1() {
@@ -330,10 +332,11 @@
            return R.error("用户异常").add("用户异常");
        }
        List<LocDetl> locDetlList = locDetlService.selectList(new EntityWrapper<LocDetl>().eq("model", model));
        OrderInspectionRollParam orderInspectionRollParam = new OrderInspectionRollParam(model);
//        OrderInspectionRollParam orderInspectionRollParam = new OrderInspectionRollParam(model);
        String response = "";
        boolean success = false;
        Map<String, Object> params = JSON.parseObject(JSON.toJSONString(orderInspectionRollParam), Map.class);
        Map<String, Object> params = new HashMap<>();
        params.put("batchNo", model);
        try {
            response = new HttpHandler.Builder()
                    .setUri(qualityFinishedCheckoutUrl)
@@ -375,7 +378,7 @@
                        qualityFinishedCheckoutUrl+"/"+qualityFinishedCheckout,
                        null,
                        "127.0.0.1",
                        JSON.toJSONString(orderInspectionRollParam),
                        JSON.toJSONString(params),
                        response,
                        success
                );
@@ -384,4 +387,63 @@
        return R.error("上报失败").add("上报失败");
    }
    @RequestMapping(value = "/synchronize/mes/locDetl/report/auth")
    @ManagerAuth(memo = "同步库存至MES")
    public R synchronizeLocDetlMes() {
        try{
            List<LocMast> locMastList = locMastService.selectList(new EntityWrapper<LocMast>().eq("loc_sts", "F"));
            List<OrderMesXGHYParam> orderMesXGHYParams = new ArrayList<>();
            for (LocMast locMast : locMastList) {
                List<LocDetl> locDetlList = locDetlService.selectList(new EntityWrapper<LocDetl>().eq("loc_no",locMast.getLocNo()));
                if (locDetlList.isEmpty()) {
                    continue;
                }
                OrderMesXGHYParam orderMesXGHYParam = new OrderMesXGHYParam(locDetlList,"in","成品入库");
                orderMesXGHYParam.setBarcode(String.valueOf(snowflakeIdWorker.nextId()));
                orderMesXGHYParam.setPalletizingNo(1);
                orderMesXGHYParams.add(orderMesXGHYParam);
            }
            if (orderMesXGHYParams.isEmpty()) {
                return R.error("库存为空!!!");
            }
            String response = "";
            boolean success = false;
            try {
                response = new HttpHandler.Builder()
                        .setUri(productInventoryUrlSaveListDto)
                        .setPath(productInventorySaveListDto)
                        .setJson(JSON.toJSONString(orderMesXGHYParams))
                        .build()
                        .doPost();
                JSONObject jsonObject = JSON.parseObject(response);
                if (jsonObject.getBoolean("state")) {
                    success = true;
                } else {
                    return R.error("同步库存至MES");
                }
            } catch (Exception e) {
                return R.error("同步库存至MES"+e.getMessage());
            } finally {
                try {
                    // 保存接口日志
                    apiLogService.save(
                            "同步库存至MES",
                            productInventoryUrlSaveListDto+"/"+productInventorySaveListDto,
                            null,
                            "127.0.0.1",
                            JSON.toJSONString(orderMesXGHYParams),
                            response,
                            success
                    );
                } catch (Exception e) { }
            }
        } catch (Exception e) {
            return R.error("上报失败"+e.getMessage()).add("上报失败"+e.getMessage());
        }
        return R.error("上报失败").add("上报失败");
    }
}