自动化立体仓库 - WMS系统
dubin
2 天以前 dd76858f35bb4fdd76d5976465e9bd96267b0f0b
src/main/java/com/zy/asrs/task/handler/GhlnHandler.java
@@ -2,19 +2,21 @@
import com.alibaba.fastjson.JSONObject;
import com.baomidou.mybatisplus.mapper.EntityWrapper;
import com.baomidou.mybatisplus.plugins.Page;
import com.core.common.Cools;
import com.zy.asrs.entity.BasDevp;
import com.zy.asrs.entity.Mat;
import com.zy.asrs.entity.WrkDetl;
import com.zy.asrs.entity.WrkMast;
import com.core.common.DateUtils;
import com.zy.asrs.entity.*;
import com.zy.asrs.service.*;
import com.zy.asrs.task.core.ReturnT;
import com.zy.common.constant.OpenApiAddressConstant;
import com.zy.common.utils.HttpHandler;
import com.zy.system.entity.Config;
import com.zy.system.service.ConfigService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import javax.annotation.PostConstruct;
import javax.annotation.Resource;
import java.time.LocalDateTime;
import java.time.format.DateTimeFormatter;
@@ -49,6 +51,12 @@
    @Resource
    private MatService matService;
    @Autowired
    private LocDetlService locDetlService;
    @Autowired
    private ConfigService configService;
    /**
     * 调用金蝶同步物料接口,增量同步每小时产生的新物料
     */
@@ -60,8 +68,8 @@
        //条件和需要获得的结果拼接
        JSONObject jsonObject = new JSONObject();
        jsonObject.put("FormId", "BD_MATERIAL");
        jsonObject.put("OrderString","");
        jsonObject.put("TopRowCount",0);
        jsonObject.put("OrderString", "");
        jsonObject.put("TopRowCount", 0);
        jsonObject.put("Limit", 3000);
        jsonObject.put("StartRow", "0");
        jsonObject.put("SubSystemId", "");
@@ -108,18 +116,18 @@
                        mat.setMatnr(tempstr[0].substring(1));  //物料编码
                    }
                    mat.setMaktx(tempstr[1]); //  物料名称
                    mat.setTagId(Long.valueOf(tempstr[3].substring(0,1))); // 物料分类
                    mat.setTagId(Long.valueOf(tempstr[3].substring(0, 1))); // 物料分类
                    mat.setCreateTime(new Date());//商品创建时间
                    mat.setUpdateTime(new Date());
                    mat.setStatus(1);
                    try {
                        matService.insert(mat);
                        count++;
                    }catch (Exception e){
                    } catch (Exception e) {
                        log.error("金蝶同步物料异常:{}", mat);
                    }
                }
                log.info("----调用金蝶同步物料信息结果:总{},成{}--------",returnstr.length, count);
                log.info("----调用金蝶同步物料信息结果:总{},成{}--------", returnstr.length, count);
                success = true;
            }
        } catch (Exception e) {
@@ -146,17 +154,16 @@
     * 到达出库口,呼叫agv
     */
    public void OutboundCallAGV() {
        BasDevp basDevp = basDevpService.selectOne(new EntityWrapper<BasDevp>().eq("dev_no", 305));
        if (basDevp.getWrkNo() > 6000 && basDevp.getWrkNo() <= 9000 && basDevp.getLoading().equals("Y") && basDevp.getAutoing().equals("Y")
        &&basDevp.getOutEnable().equals("Y")) { // 出库工作档
        BasDevp basDevp = basDevpService.selectOne(new EntityWrapper<BasDevp>().setSqlSelect("wrk_no as wrkNo", "loading", "autoing", "out_enable as outEnable").eq("dev_no", 210));
        if (basDevp.getWrkNo() > 6000 && basDevp.getWrkNo() <= 9000 && basDevp.getLoading().equals("Y") && basDevp.getAutoing().equals("Y")) { // 出库工作档
            WrkMast wrkMast = wrkMastService.selectById(basDevp.getWrkNo());
            if(wrkMast.getWhsType() == null) {
            if (wrkMast.getWhsType() == null) {
                WrkDetl wrkDetl = wrkDetlService.selectOne(new EntityWrapper<WrkDetl>().eq("wrk_no", basDevp.getWrkNo()));
                // 调用结果
                boolean success = false;
                // 构造请求头
                Map<String,Object> headers = new HashMap<>();
                headers.put("Content-Type","application/json;charset=UTF-8");
                Map<String, Object> headers = new HashMap<>();
                headers.put("Content-Type", "application/json;charset=UTF-8");
                // 构造请求体
                JSONObject jsonObject = new JSONObject();
                jsonObject.put("matnr", wrkDetl.getMatnr()); // 物料编码
@@ -164,9 +171,9 @@
                jsonObject.put("batch", wrkDetl.getBatch()); // 批次
                jsonObject.put("specs", wrkDetl.getSpecs()); // 膜类型
                jsonObject.put("manuDate", wrkDetl.getManuDate()); // 生产日期
                jsonObject.put("length", wrkDetl.getLength()+""); // 长
                jsonObject.put("weight", wrkDetl.getWeight()+""); // 宽
                jsonObject.put("volume", wrkDetl.getVolume()+""); // 面积
                jsonObject.put("length", wrkDetl.getLength() + ""); // 长
                jsonObject.put("weight", wrkDetl.getWeight() + ""); // 宽
                jsonObject.put("volume", wrkDetl.getVolume() + ""); // 面积
                String body = jsonObject.toString();
                String response = "";
                try {
@@ -179,7 +186,7 @@
                            .doPost();
                    if (!Cools.isEmpty(response)) {
                        JSONObject jsonObject1 = JSONObject.parseObject(response);
                        if ((Integer) jsonObject1.get("code") == 200){
                        if ((Integer) jsonObject1.get("code") == 200) {
                            success = true;
                            wrkMast.setWhsType(1);
                            wrkMastService.updateById(wrkMast);
@@ -208,4 +215,51 @@
            }
        }
    }
    public void start() {
        long time = System.currentTimeMillis();
        Config config = configService.selectConfigByCode("EXPIREDDAY");
        long day = 180;
        if (config != null) {
            day = Long.parseLong(config.getValue());
        }
        Config config2 = configService.selectConfigByCode("durationOfFilmRollControl");
        long day2 = Long.parseLong(config2.getValue());
        Page<LocDetl> frozen = locDetlService.selectPage(new Page<>(0, 10000), new EntityWrapper<LocDetl>().isNull("sku").orderBy("manu_date"));
        for (LocDetl locDetl : frozen.getRecords()) {
            String manuDate = locDetl.getManuDate();
            Date yyyyMMdd = DateUtils.convert(manuDate, "yyyyMMdd");
            if ((time - yyyyMMdd.getTime()) > day * 24 * 60 * 60 * 1000) {
                locDetl.setFrozen(1);
                locDetlService.update(locDetl, new EntityWrapper<LocDetl>().eq("loc_no", locDetl.getLocNo()).eq("matnr", locDetl.getMatnr()).eq("batch", locDetl.getBatch()));
            } else if ((time - yyyyMMdd.getTime()) > day2 * 24 * 60 * 60 * 1000) {
                locDetl.setFrozen(2);
                locDetlService.update(locDetl, new EntityWrapper<LocDetl>().eq("loc_no", locDetl.getLocNo()).eq("matnr", locDetl.getMatnr()).eq("batch", locDetl.getBatch()));
            }
        }
    }
    @PostConstruct
    public void start2() {
        long time = System.currentTimeMillis();
        Config config = configService.selectConfigByCode("EXPIREDDAY");
        long day = 180;
        if (config != null) {
            day = Long.parseLong(config.getValue());
        }
        Config config2 = configService.selectConfigByCode("durationOfFilmRollControl");
        long day2 = Long.parseLong(config2.getValue());
        Page<LocDetl> frozen = locDetlService.selectPage(new Page<>(0, 10000), new EntityWrapper<LocDetl>().isNull("sku").orderBy("manu_date"));
        for (LocDetl locDetl : frozen.getRecords()) {
            String manuDate = locDetl.getManuDate();
            Date yyyyMMdd = DateUtils.convert(manuDate, "yyyyMMdd");
            if ((time - yyyyMMdd.getTime()) > day * 24 * 60 * 60 * 1000) {
                locDetl.setFrozen(1);
                locDetlService.update(locDetl, new EntityWrapper<LocDetl>().eq("loc_no", locDetl.getLocNo()).eq("matnr", locDetl.getMatnr()).eq("batch", locDetl.getBatch()));
            } else if ((time - yyyyMMdd.getTime()) > day2 * 24 * 60 * 60 * 1000) {
                locDetl.setFrozen(2);
                locDetlService.update(locDetl, new EntityWrapper<LocDetl>().eq("loc_no", locDetl.getLocNo()).eq("matnr", locDetl.getMatnr()).eq("batch", locDetl.getBatch()));
            }
        }
    }
}