| | |
| | | <version>1.16.22</version> |
| | | <scope>provided</scope> |
| | | </dependency> |
| | | <!-- okHttp3 --> |
| | | <dependency> |
| | | <groupId>com.squareup.okhttp3</groupId> |
| | | <artifactId>okhttp</artifactId> |
| | | <version>3.10.0</version> |
| | | </dependency> |
| | | </dependencies> |
| | | |
| | | <build> |
| | |
| | | dto.setLocDetl(locDetl); |
| | | dto.setCount(issued>=locDetl.getAnfme()?locDetl.getAnfme():issued); |
| | | detlDtos.add(dto); |
| | | workService.stockOut(staNo, detlDtos, 101, 9527L, param.getAllotNo()); |
| | | workService.stockOut(staNo, detlDtos, 101, 9527L, param.getAllotNo(), Cools.isEmpty(param.getAllotNo())); |
| | | // 拣料 |
| | | } else { |
| | | BasDevp staNo = basDevpService.checkSiteStatus(107); |
| | |
| | | dto.setLocDetl(locDetl); |
| | | dto.setCount(issued>=locDetl.getAnfme()?locDetl.getAnfme():issued); |
| | | detlDtos.add(dto); |
| | | workService.stockOut(staNo, detlDtos, 103, 9527L, param.getAllotNo()); |
| | | workService.stockOut(staNo, detlDtos, 103, 9527L, param.getAllotNo(), Cools.isEmpty(param.getAllotNo())); |
| | | } |
| | | |
| | | PakoutVo pakoutVo = new PakoutVo(); |
| | |
| | | private BasDevpService basDevpService; |
| | | |
| | | @RequestMapping("/available/put/site") |
| | | @ManagerAuth(memo = "获取入库站点") |
| | | @ManagerAuth() |
| | | public R availablePutSite(){ |
| | | return R.ok().add(basDevpService.getAvailableInSite()); |
| | | } |
| | | |
| | | @RequestMapping("/available/empty/put/site") |
| | | @ManagerAuth(memo = "获取空板入库站点") |
| | | @ManagerAuth() |
| | | public R availableEmptyPutSite(){ |
| | | return R.ok().add(basDevpService.getAvailableEmptyInSite()); |
| | | } |
| | | |
| | | @RequestMapping("/available/take/site") |
| | | @ManagerAuth(memo = "获取出库站点") |
| | | @ManagerAuth() |
| | | public R availableTakeSite(){ |
| | | List<Map<String, Object>> result = new ArrayList<>(); |
| | | List<Integer> outSite = basDevpService.getAvailableOutSite(101); |
| | |
| | | } |
| | | |
| | | @RequestMapping("/available/take/check/site") |
| | | @ManagerAuth(memo = "获取盘点出库站点") |
| | | @ManagerAuth() |
| | | public R availableTakeCheckSite(){ |
| | | return R.ok().add(basDevpService.getAvailableOutSite(107)); |
| | | } |
| | | |
| | | @RequestMapping("/available/empty/take/site") |
| | | @ManagerAuth(memo = "获取空板出库站点") |
| | | @ManagerAuth() |
| | | public R availableEmptyTakeSite(){ |
| | | return R.ok().add(basDevpService.getAvailableEmptyOutSite()); |
| | | } |
| | |
| | | * @param locDetls 待出库物料 |
| | | * @param ioType 入出库类型 |
| | | */ |
| | | void stockOut(BasDevp staNo, List<LocDetlDto> locDetls, Integer ioType, Long userId, String allotNo); |
| | | void stockOut(BasDevp staNo, List<LocDetlDto> locDetls, Integer ioType, Long userId, String allotNo, Boolean sell); |
| | | |
| | | /** |
| | | * 空板入库 |
| | |
| | | } |
| | | if (!locDetlDtos.isEmpty()) { |
| | | // 启动出库开始 101.出库 |
| | | stockOut(staNo, locDetlDtos, null, userId, null); |
| | | stockOut(staNo, locDetlDtos, null, userId, null, false); |
| | | } else { |
| | | throw new CoolException("库位物料不存在"); |
| | | } |
| | |
| | | |
| | | @Override |
| | | @Transactional |
| | | public void stockOut(BasDevp staNo, List<LocDetlDto> locDetlDtos, Integer ioType, Long userId, String allotNo) { |
| | | public void stockOut(BasDevp staNo, List<LocDetlDto> locDetlDtos, Integer ioType, Long userId, String allotNo, Boolean sell) { |
| | | // 合并同类项 |
| | | Set<String> locNos = new HashSet<>(); |
| | | locDetlDtos.forEach(dto -> locNos.add(dto.getLocDetl().getLocNo())); |
| | |
| | | wrkMast.setEmptyMk("N"); // 空板 |
| | | wrkMast.setLinkMis("N"); |
| | | wrkMast.setPacked(allotNo); // 平仓补仓单号 |
| | | wrkMast.setPdcType(sell?"Y":"N"); // ERP销售订单出库任务 |
| | | wrkMast.setAppeUser(userId); // 操作人员数据 |
| | | wrkMast.setAppeTime(new Date()); |
| | | wrkMast.setModiUser(userId); |
| | |
| | | } |
| | | if (!locDetlDtos.isEmpty()) { |
| | | // 启动出库开始 107.盘点出库 |
| | | stockOut(staNo, locDetlDtos, 107, userId, null); |
| | | stockOut(staNo, locDetlDtos, 107, userId, null, false); |
| | | } else { |
| | | throw new CoolException("库位物料不存在"); |
| | | } |
| | |
| | | package com.zy.asrs.task; |
| | | |
| | | import com.core.exception.CoolException; |
| | | import com.zy.asrs.task.core.AsrsException; |
| | | import com.zy.asrs.task.core.ReturnT; |
| | | |
| | |
| | | } |
| | | |
| | | protected void exceptionHandle(String errorMsg, Object... args){ |
| | | throw new AsrsException(MessageFormat.format(errorMsg, args)); |
| | | throw new CoolException(MessageFormat.format(errorMsg, args)); |
| | | } |
| | | |
| | | } |
| | |
| | | |
| | | import com.baomidou.mybatisplus.mapper.EntityWrapper; |
| | | import com.core.common.Cools; |
| | | import com.core.common.SnowflakeIdWorker; |
| | | import com.zy.asrs.entity.WaitPakin; |
| | | import com.zy.asrs.entity.WrkDetl; |
| | | import com.zy.asrs.entity.WrkMast; |
| | | import com.zy.asrs.service.*; |
| | | import com.zy.asrs.task.AbstractHandler; |
| | | import com.zy.asrs.task.core.ReturnT; |
| | | import com.zy.common.model.BillDto; |
| | | import com.zy.common.model.MatnrDto; |
| | | import com.zy.common.service.ErpService; |
| | | import com.zy.common.service.wms.ReplenishDto; |
| | | import com.zy.common.service.wms.Result; |
| | | import com.zy.common.service.wms.WmsService; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.stereotype.Service; |
| | | import org.springframework.transaction.annotation.Transactional; |
| | | import org.springframework.transaction.interceptor.TransactionAspectSupport; |
| | | |
| | | import java.util.ArrayList; |
| | | import java.util.List; |
| | | |
| | | /** |
| | | * Created by vincent on 2020/7/6 |
| | |
| | | private WaitPakinService waitPakinService; |
| | | @Autowired |
| | | private WaitPakinLogService waitPakinLogService; |
| | | @Autowired |
| | | private ErpService erpService; |
| | | @Autowired |
| | | private SnowflakeIdWorker snowflakeIdWorker; |
| | | @Autowired |
| | | private WmsService wmsService; |
| | | |
| | | @Transactional |
| | | public ReturnT<String> start(WrkMast wrkMast) { |
| | | try { |
| | | |
| | | if (!Cools.isEmpty(wrkMast.getBarcode())) { |
| | | // 保存入库通知档历史档 |
| | | waitPakinLogService.save(wrkMast.getBarcode()); |
| | | // 删除入库通知档 |
| | | waitPakinService.delete(new EntityWrapper<WaitPakin>().eq("zpallet", wrkMast.getBarcode())); |
| | | // 入库 |
| | | if (wrkMast.getWrkSts() == 5) { |
| | | |
| | | // 全板入库 |
| | | if (wrkMast.getIoType() == 1) { |
| | | String docNum = "PU-" + String.valueOf(snowflakeIdWorker.nextId()).substring(0, 15); |
| | | // 上报给erp |
| | | List<MatnrDto> matnrDtos = new ArrayList<>(); |
| | | List<WrkDetl> wrkDetls = wrkDetlService.selectList(new EntityWrapper<WrkDetl>().eq("wrk_no", wrkMast.getWrkNo())); |
| | | for (WrkDetl wrkDetl : wrkDetls) { |
| | | MatnrDto dto = new MatnrDto(); |
| | | dto.setMatnr(wrkDetl.getMatnr()); |
| | | dto.setCount(wrkDetl.getAnfme()); |
| | | matnrDtos.add(dto); |
| | | } |
| | | List<BillDto> dtos = new ArrayList<>(); |
| | | for (MatnrDto dto : matnrDtos) { |
| | | BillDto billDto = new BillDto(); |
| | | billDto.setMatnr(dto.getMatnr()); |
| | | billDto.setQty(dto.getCount()); |
| | | dtos.add(billDto); |
| | | } |
| | | if (!erpService.uploadBill(dtos, 34, docNum)) { |
| | | exceptionHandle("无法上报至erp[workNo={0}]失败", wrkMast.getWrkNo()); |
| | | } |
| | | |
| | | // 入库通知单 |
| | | if (!Cools.isEmpty(wrkMast.getBarcode())) { |
| | | // 保存入库通知档历史档 |
| | | if (!waitPakinLogService.save(wrkMast.getBarcode())) { |
| | | exceptionHandle("保存入库通知档历史档[workNo={0}]失败", wrkMast.getWrkNo()); |
| | | } |
| | | // 删除入库通知档 |
| | | if (!waitPakinService.delete(new EntityWrapper<WaitPakin>().eq("zpallet", wrkMast.getBarcode()))) { |
| | | exceptionHandle("删除入库通知档[workNo={0}]失败", wrkMast.getWrkNo()); |
| | | } |
| | | } |
| | | // 拣料再入库 |
| | | } else if (wrkMast.getIoType() == 53) { |
| | | // 非销售订单出库,需要补货到平仓 |
| | | if (!wrkMast.getPdcType().equals("Y")) { |
| | | List<ReplenishDto> replenishDtos = new ArrayList<>(); |
| | | List<WrkDetl> wrkDetls = wrkDetlService.selectList(new EntityWrapper<WrkDetl>().eq("wrk_no", wrkMast.getWrkNo())); |
| | | for (WrkDetl wrkDetl : wrkDetls) { |
| | | ReplenishDto param = new ReplenishDto(); |
| | | param.setMatnr(wrkDetl.getMatnr()); |
| | | param.setCount(wrkDetl.getAnfme()); |
| | | replenishDtos.add(param); |
| | | } |
| | | Result result = wmsService.replenish(replenishDtos); |
| | | if (result.getCode() != 200) { |
| | | exceptionHandle("补货到平仓[workNo={0}]失败", wrkMast.getWrkNo()); |
| | | } |
| | | } |
| | | |
| | | } |
| | | |
| | | // 出库 |
| | | } else if (wrkMast.getWrkSts() == 15) { |
| | | // 非销售订单出库,需要补货到平仓 |
| | | if (!wrkMast.getPdcType().equals("Y")) { |
| | | List<ReplenishDto> replenishDtos = new ArrayList<>(); |
| | | List<WrkDetl> wrkDetls = wrkDetlService.selectList(new EntityWrapper<WrkDetl>().eq("wrk_no", wrkMast.getWrkNo())); |
| | | for (WrkDetl wrkDetl : wrkDetls) { |
| | | ReplenishDto param = new ReplenishDto(); |
| | | param.setMatnr(wrkDetl.getMatnr()); |
| | | param.setCount(wrkDetl.getAnfme()); |
| | | replenishDtos.add(param); |
| | | } |
| | | Result result = wmsService.replenish(replenishDtos); |
| | | if (result.getCode() != 200) { |
| | | exceptionHandle("补货到平仓[workNo={0}]失败", wrkMast.getWrkNo()); |
| | | } |
| | | } |
| | | } |
| | | |
| | | |
| | | |
| | | // 保存工作主档历史档 |
| | | if (!wrkMastLogService.save(wrkMast.getWrkNo())) { |
| | | exceptionHandle("保存工作历史档[workNo={0}]失败", wrkMast.getWrkNo()); |
New file |
| | |
| | | package com.zy.common.model; |
| | | |
| | | import lombok.Data; |
| | | |
| | | /** |
| | | * Created by vincent on 2021/3/23 |
| | | */ |
| | | @Data |
| | | public class BillDto { |
| | | |
| | | private String matnr; |
| | | |
| | | private Double qty; |
| | | |
| | | } |
New file |
| | |
| | | package com.zy.common.model; |
| | | |
| | | import lombok.Data; |
| | | |
| | | /** |
| | | * Created by vincent on 2021/3/31 |
| | | */ |
| | | @Data |
| | | public class MatnrDto { |
| | | |
| | | private String matnr; |
| | | |
| | | private Double count; |
| | | |
| | | } |
New file |
| | |
| | | package com.zy.common.model; |
| | | |
| | | import lombok.Data; |
| | | |
| | | import java.util.List; |
| | | |
| | | /** |
| | | * Created by vincent on 2021/3/23 |
| | | */ |
| | | @Data |
| | | public class UploadBill { |
| | | |
| | | private String number; |
| | | |
| | | private Integer vchType; |
| | | |
| | | private String billDate; |
| | | |
| | | private String bTypeID; |
| | | |
| | | private String kTypeID; |
| | | |
| | | private String summary; |
| | | |
| | | // 自增 |
| | | private Double Vchcode; |
| | | |
| | | private Integer difAtype; |
| | | |
| | | private List<UploadBillDetail> detail; |
| | | |
| | | } |
New file |
| | |
| | | package com.zy.common.model; |
| | | |
| | | import lombok.Data; |
| | | |
| | | /** |
| | | * Created by vincent on 2021/3/23 |
| | | */ |
| | | @Data |
| | | public class UploadBillDetail { |
| | | |
| | | private String userCode; |
| | | |
| | | private Double qty; |
| | | |
| | | private Integer Price; |
| | | |
| | | private String comment; |
| | | |
| | | private String unit; |
| | | |
| | | // 商品明细行号 |
| | | private Double RowNo; |
| | | |
| | | } |
New file |
| | |
| | | package com.zy.common.service; |
| | | |
| | | import com.alibaba.fastjson.JSON; |
| | | import com.core.common.Cools; |
| | | import com.core.common.DateUtils; |
| | | import com.zy.asrs.entity.MatCode; |
| | | import com.zy.asrs.service.MatCodeService; |
| | | import com.zy.common.model.BillDto; |
| | | import com.zy.common.model.UploadBill; |
| | | import com.zy.common.model.UploadBillDetail; |
| | | import com.zy.common.utils.HttpHandler; |
| | | import lombok.extern.slf4j.Slf4j; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.beans.factory.annotation.Value; |
| | | import org.springframework.stereotype.Service; |
| | | |
| | | import java.util.ArrayList; |
| | | import java.util.Date; |
| | | import java.util.List; |
| | | |
| | | /** |
| | | * Created by vincent on 2021/3/23 |
| | | */ |
| | | @Slf4j |
| | | @Service("erpService") |
| | | public class ErpService { |
| | | |
| | | @Value("${erp.url}") |
| | | private String url; |
| | | |
| | | public static final String UPLOAD_BILL = "cM/basis/uploadBill"; |
| | | |
| | | @Autowired |
| | | private MatCodeService matCodeService; |
| | | /** |
| | | * 单据上报 |
| | | */ |
| | | public Boolean uploadBill(List<BillDto> dtos, Integer docId, String docNumber){ |
| | | try { |
| | | if (Cools.isEmpty(dtos)) { |
| | | return false; |
| | | } |
| | | |
| | | UploadBill uploadBill = new UploadBill(); |
| | | uploadBill.setNumber(docNumber); |
| | | uploadBill.setBillDate(DateUtils.convert(new Date(), DateUtils.yyyyMMdd_F)); |
| | | uploadBill.setBTypeID("SHHT"); |
| | | uploadBill.setKTypeID("宏挺仓库"); |
| | | uploadBill.setVchType(docId); |
| | | if (docId == 9) { |
| | | uploadBill.setDifAtype(22); |
| | | } else if (docId == 14) { |
| | | uploadBill.setDifAtype(23); |
| | | } |
| | | uploadBill.setSummary("采购单 - " + DateUtils.convert(new Date(), "yyyy-MM-dd HH:mm")); |
| | | List<UploadBillDetail> detail = new ArrayList<>(); |
| | | uploadBill.setDetail(detail); |
| | | for (BillDto dto : dtos) { |
| | | MatCode mat = matCodeService.selectById(dto.getMatnr()); |
| | | UploadBillDetail detl = new UploadBillDetail(); |
| | | detl.setUserCode(dto.getMatnr()); |
| | | detl.setQty(dto.getQty()); |
| | | detl.setPrice(0); |
| | | detl.setUnit(mat==null?"暂无":"箱"); |
| | | detail.add(detl); |
| | | } |
| | | System.out.println(JSON.toJSONString(uploadBill)); |
| | | String response = new HttpHandler.Builder() |
| | | .setUri(url) |
| | | .setPath(UPLOAD_BILL) |
| | | .setJson(JSON.toJSONString(uploadBill)) |
| | | .build() |
| | | .doPost(); |
| | | |
| | | if (!Cools.isEmpty(response)) { |
| | | log.warn(response); |
| | | Result result = JSON.parseObject(response, Result.class); |
| | | if (result.getCode() != 1) { |
| | | return false; |
| | | } |
| | | } |
| | | } catch (Exception e) { |
| | | e.printStackTrace(); |
| | | return false; |
| | | } |
| | | return Boolean.TRUE; |
| | | } |
| | | |
| | | |
| | | } |
New file |
| | |
| | | package com.zy.common.service; |
| | | |
| | | import lombok.Data; |
| | | |
| | | /** |
| | | * Created by vincent on 2021/3/1 |
| | | */ |
| | | @Data |
| | | public class Result { |
| | | |
| | | private Integer code; |
| | | |
| | | private String msg; |
| | | |
| | | private String data; |
| | | |
| | | } |
| | | |
New file |
| | |
| | | package com.zy.common.service.wms; |
| | | |
| | | import lombok.Data; |
| | | |
| | | /** |
| | | * Created by vincent on 2021/5/27 |
| | | */ |
| | | @Data |
| | | public class ReplenishDto { |
| | | |
| | | private String matnr; |
| | | |
| | | private Double count; |
| | | |
| | | } |
New file |
| | |
| | | package com.zy.common.service.wms; |
| | | |
| | | import lombok.Data; |
| | | |
| | | import java.util.List; |
| | | |
| | | /** |
| | | * Created by vincent on 2021/5/27 |
| | | */ |
| | | @Data |
| | | public class ReplenishParam { |
| | | |
| | | private List<ReplenishDto> list; |
| | | |
| | | } |
New file |
| | |
| | | package com.zy.common.service.wms; |
| | | |
| | | import lombok.Data; |
| | | |
| | | /** |
| | | * Created by vincent on 2021/3/20 |
| | | */ |
| | | @Data |
| | | public class Result { |
| | | |
| | | private Integer code; |
| | | |
| | | private String msg; |
| | | |
| | | private Object data; |
| | | |
| | | public Result() { |
| | | } |
| | | |
| | | public Result(Integer code, String msg, Object data) { |
| | | this.code = code; |
| | | this.msg = msg; |
| | | this.data = data; |
| | | } |
| | | } |
New file |
| | |
| | | package com.zy.common.service.wms; |
| | | |
| | | import com.alibaba.fastjson.JSON; |
| | | import com.zy.common.utils.HttpHandler; |
| | | import org.springframework.beans.factory.annotation.Value; |
| | | import org.springframework.stereotype.Component; |
| | | |
| | | import java.io.IOException; |
| | | import java.util.List; |
| | | |
| | | /** |
| | | * Created by vincent on 2021/5/27 |
| | | */ |
| | | @Component |
| | | public class WmsService { |
| | | |
| | | @Value("${wms.url}") |
| | | private String wmsUrl; |
| | | |
| | | public Result replenish(List<ReplenishDto> dtos) { |
| | | try { |
| | | ReplenishParam param = new ReplenishParam(); |
| | | param.setList(dtos); |
| | | String response = new HttpHandler.Builder() |
| | | .setUri(wmsUrl) |
| | | .setPath("/open/api/replenish") |
| | | .setJson(JSON.toJSONString(param)) |
| | | .build() |
| | | .doPost(); |
| | | return JSON.parseObject(response, Result.class); |
| | | } catch (IOException e) { |
| | | e.printStackTrace(); |
| | | return new Result(500, "服务器异常", null); |
| | | } |
| | | } |
| | | |
| | | } |
New file |
| | |
| | | package com.zy.common.utils; |
| | | |
| | | |
| | | import okhttp3.*; |
| | | |
| | | import java.io.IOException; |
| | | import java.util.Map; |
| | | import java.util.Optional; |
| | | import java.util.concurrent.TimeUnit; |
| | | |
| | | /** |
| | | * Http协议客户端 |
| | | * @author luxiaotao |
| | | * @date 2018-9-27 |
| | | */ |
| | | public class HttpHandler { |
| | | |
| | | private static final Integer DEFAULT_TIMEOUT_SECONDS = 5; |
| | | private static final MediaType MEDIA_TYPE = MediaType.parse("application/json;charset=utf-8"); |
| | | |
| | | private String uri; |
| | | private String path; |
| | | private String json; |
| | | private Map<String, Object> params; |
| | | private Map<String, Object> headers; |
| | | private boolean https; |
| | | private Integer timeout; |
| | | private TimeUnit timeUnit; |
| | | |
| | | public HttpHandler(Builder builder){ |
| | | this.uri = builder.uri; |
| | | this.path = builder.path; |
| | | this.json = builder.json; |
| | | this.params = builder.params; |
| | | this.headers = builder.headers; |
| | | this.https = builder.https; |
| | | this.timeout = builder.timeout; |
| | | this.timeUnit = builder.timeUnit; |
| | | } |
| | | |
| | | /** |
| | | * GET请求执行 |
| | | * @return the HttpHandler response |
| | | */ |
| | | public String doGet() throws IOException { |
| | | String url = paramsToUrl(uri, path, params, https); |
| | | Request.Builder headerBuilder = new Request.Builder(); |
| | | if (headers != null && headers.size()>0){ |
| | | for (Map.Entry<String, Object> entry : headers.entrySet()){ |
| | | headerBuilder.addHeader(entry.getKey(), String.valueOf(entry.getValue())); |
| | | } |
| | | } |
| | | Request request = headerBuilder.url(url).build(); |
| | | Response response = getClient(timeout, timeUnit).newCall(request).execute(); |
| | | return response.isSuccessful() ? response.body().string() : null; |
| | | } |
| | | |
| | | /** |
| | | * POST请求执行 |
| | | * @return the HttpHandler response |
| | | */ |
| | | public String doPost() throws IOException { |
| | | Request request; |
| | | Request.Builder headerBuilder = new Request.Builder(); |
| | | if (headers != null && headers.size()>0){ |
| | | for (Map.Entry<String, Object> entry : headers.entrySet()){ |
| | | headerBuilder.addHeader(entry.getKey(), String.valueOf(entry.getValue())); |
| | | } |
| | | } |
| | | if (json == null || "".equals(json)){ |
| | | FormBody.Builder builder = new FormBody.Builder(); |
| | | for (Map.Entry<String, Object> entry : params.entrySet()){ |
| | | builder.add(entry.getKey(), String.valueOf(entry.getValue())); |
| | | } |
| | | FormBody body = builder.build(); |
| | | request = headerBuilder |
| | | .url((https?"https://":"http://")+uri+path) |
| | | .post(body) |
| | | .build(); |
| | | } else { |
| | | RequestBody body = RequestBody.create(MEDIA_TYPE, json); |
| | | Request.Builder builder = headerBuilder.url((https?"https://":"http://")+uri+path); |
| | | builder.header("Content-Type", "application/json;charset=UTF-8"); |
| | | request = builder.post(body).build(); |
| | | |
| | | } |
| | | Call call = getClient(timeout, timeUnit).newCall(request); |
| | | Response response = call.execute(); |
| | | return response.body().string(); |
| | | |
| | | } |
| | | |
| | | /** |
| | | * get请求参数拼接方法 |
| | | * @return 请求行 |
| | | */ |
| | | private String paramsToUrl(String uri, String path, Map<String, Object> params, boolean isHttps) { |
| | | StringBuilder res = new StringBuilder(); |
| | | res.append(isHttps ? "https://" : "http://"); |
| | | res.append(uri); |
| | | if (path.length() > 0 && !(path.charAt(0) == '/')){ |
| | | res.append("/"); |
| | | } |
| | | res.append(path); |
| | | Optional.ofNullable(params).ifPresent( |
| | | args -> { |
| | | res.append("?"); |
| | | args.forEach((key, value) -> { |
| | | res.append(key); |
| | | res.append("="); |
| | | res.append(value); |
| | | res.append("&"); |
| | | }); |
| | | } |
| | | ); |
| | | String url = res.toString(); |
| | | if ("&".equals(url.substring(url.length()-1, url.length()))){ |
| | | url = url.substring(0, url.length()-1); |
| | | } |
| | | return url; |
| | | } |
| | | |
| | | /** |
| | | * 获取 okHttpClient |
| | | * @return the HttpHandler instance |
| | | */ |
| | | private OkHttpClient getClient(Integer timeout, TimeUnit timeUnit){ |
| | | return new OkHttpClient |
| | | .Builder() |
| | | .connectTimeout(timeout, timeUnit) |
| | | .readTimeout(timeout, timeUnit) |
| | | .build(); |
| | | } |
| | | |
| | | /** |
| | | * Http协议报文建造者 |
| | | */ |
| | | public static class Builder { |
| | | |
| | | private String uri; |
| | | private String path; |
| | | private String json; |
| | | private Map<String, Object> params; |
| | | private Map<String, Object> headers; |
| | | private boolean https; |
| | | private Integer timeout; |
| | | private TimeUnit timeUnit; |
| | | |
| | | { |
| | | // 默认5s超时 |
| | | timeout = DEFAULT_TIMEOUT_SECONDS; |
| | | timeUnit = TimeUnit.SECONDS; |
| | | path = ""; |
| | | } |
| | | |
| | | /** |
| | | * 建造器 |
| | | * @return the HttpHandler instance |
| | | */ |
| | | public HttpHandler build(){ |
| | | if (null == this.uri || "".equals(this.uri)){ |
| | | throw new RuntimeException("uri is null"); |
| | | } |
| | | if (this.uri.startsWith("http://")){ |
| | | this.uri = this.uri.substring(6,uri.length()); |
| | | } else if (this.uri.startsWith("https://")){ |
| | | this.uri = this.uri.substring(7,uri.length()); |
| | | } |
| | | return new HttpHandler(this); |
| | | } |
| | | |
| | | public Builder setUri(String uri) { |
| | | this.uri = uri; |
| | | return this; |
| | | } |
| | | |
| | | public Builder setPath(String path) { |
| | | if (!path.startsWith("/")){ |
| | | path = "/" + path; |
| | | } |
| | | this.path = path; |
| | | return this; |
| | | } |
| | | |
| | | public Builder setTimeout(Integer timeout, TimeUnit timeUnit) { |
| | | this.timeout = timeout; |
| | | this.timeUnit = timeUnit; |
| | | return this; |
| | | } |
| | | |
| | | public Builder setParams(Map<String, Object> params) { |
| | | this.params = params; |
| | | return this; |
| | | } |
| | | |
| | | public Builder setHeaders(Map<String, Object> headers) { |
| | | this.headers = headers; |
| | | return this; |
| | | } |
| | | |
| | | public Builder setHttps(boolean https) { |
| | | this.https = https; |
| | | return this; |
| | | } |
| | | |
| | | public Builder setJson(String json) { |
| | | this.json = json; |
| | | return this; |
| | | } |
| | | |
| | | } |
| | | |
| | | } |
| | |
| | | # 双深库位排号 |
| | | doubleLocs: 1,4,5,8 |
| | | # 一个堆垛机负责的货架排数 |
| | | groupCount: 4 |
| | | groupCount: 4 |
| | | |
| | | wms: |
| | | url: http://192.168.110.57:8080/wms |
| | | |
| | | erp: |
| | | url: http://8.133.182.21:6220/api |