| New file |
| | |
| | | package com.zy.asrs.service.impl; |
| | | |
| | | import com.alibaba.fastjson.JSON; |
| | | import com.alibaba.fastjson.JSONObject; |
| | | import com.zy.acs.framework.exception.CoolException; |
| | | import com.zy.asrs.controller.vo.ApplyInDto; |
| | | import com.zy.asrs.controller.vo.ApplyInRepsonseDto; |
| | | import com.zy.asrs.service.WmsMainService; |
| | | import com.zy.common.utils.HttpHandler; |
| | | import lombok.Data; |
| | | import lombok.extern.slf4j.Slf4j; |
| | | import org.springframework.beans.factory.annotation.Value; |
| | | import org.springframework.stereotype.Service; |
| | | import org.springframework.transaction.annotation.Transactional; |
| | | |
| | | import java.util.concurrent.TimeUnit; |
| | | |
| | | /** |
| | | * 立体仓库WCS系统主流程业务 |
| | | * Created by vincent on 2020/8/6 |
| | | */ |
| | | @Slf4j |
| | | @Service |
| | | @Transactional |
| | | @Data |
| | | public class WmsMainServiceImpl implements WmsMainService { |
| | | |
| | | |
| | | @Value("${wms.url}") |
| | | private String wmsUrl; |
| | | |
| | | |
| | | @Value("${wms.apply}") |
| | | private String apply; |
| | | |
| | | private String code = "code"; |
| | | |
| | | private String dataCode = "data"; |
| | | |
| | | private Integer codeValue = 200; |
| | | |
| | | private Integer timeout = 1200; |
| | | |
| | | |
| | | /** |
| | | * 检查站点状态 |
| | | * |
| | | * @param applyInDto 站点编号 |
| | | * @return 库位信息 |
| | | */ |
| | | public ApplyInRepsonseDto getLocOfWms(ApplyInDto applyInDto) { |
| | | String response = ""; |
| | | try { |
| | | response = new HttpHandler.Builder() |
| | | .setUri(wmsUrl) |
| | | .setPath(apply) |
| | | .setTimeout(timeout, TimeUnit.SECONDS) |
| | | .setJson(JSON.toJSONString(applyInDto)) |
| | | .build() |
| | | .doPost(); |
| | | log.info("WMS返回数据:{}", response); |
| | | JSONObject jsonObject = JSON.parseObject(response); |
| | | if (jsonObject.get(code) != null && jsonObject.getInteger(code).equals(codeValue)) { |
| | | return JSONObject.parseObject(jsonObject.getString(dataCode), ApplyInRepsonseDto.class); |
| | | } else { |
| | | log.error("调用下发任务接口报错,响应码:{},响应内容:{}", jsonObject.getInteger(code), response); |
| | | //throw new CoolException("调用下发任务接口报错,响应码:" + jsonObject.getInteger(code)); |
| | | } |
| | | } catch (CoolException e) { |
| | | log.error("调用站点状态接口异常", e); |
| | | //throw e; |
| | | } catch (Exception e) { |
| | | log.error("检查站点状态失败,条码编号:{},站点:{}", applyInDto.getBarcode(), applyInDto.getStaNo(), e); |
| | | } |
| | | return null; |
| | | } |
| | | |
| | | public static void main(String[] args) { |
| | | String s= "{\"msg\":\"Success\",\"code\":200,\"data\":{\"locNo\":\"A102400201\",\"batchNo\":\"TK2603104428\",\"taskNo\":\"TK2603104428\"}}"; |
| | | //System.out.println(JSON.parseObject(s).getString("data")); |
| | | ApplyInRepsonseDto applyInRepsonseDto = JSONObject.parseObject(JSON.parseObject(s).getString("data"), ApplyInRepsonseDto.class); |
| | | System.out.println(applyInRepsonseDto); |
| | | } |
| | | } |