| | |
| | | import com.alibaba.fastjson.JSON; |
| | | import com.alibaba.fastjson.JSONObject; |
| | | import com.baomidou.mybatisplus.mapper.EntityWrapper; |
| | | import com.core.common.Cools; |
| | | import com.core.common.DateUtils; |
| | | import com.core.common.SnowflakeIdWorker; |
| | | import com.core.common.SpringUtils; |
| | | import com.core.common.*; |
| | | import com.core.exception.CoolException; |
| | | import com.zy.asrs.entity.*; |
| | | import com.zy.asrs.entity.param.*; |
| | |
| | | import com.zy.common.constant.AgvConstant; |
| | | import com.zy.common.constant.ArmConstant; |
| | | import com.zy.common.model.DetlDto; |
| | | import com.zy.common.model.LocDetlDto; |
| | | import com.zy.common.model.enums.WorkNoType; |
| | | import com.zy.common.service.CommonService; |
| | | import com.zy.common.utils.HttpHandler; |
| | | import com.zy.common.utils.NodeUtils; |
| | | import com.zy.erp.kingdee.utils.PostMesDataUtils; |
| | | 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 org.springframework.transaction.annotation.Transactional; |
| | | |
| | | import javax.rmi.CORBA.Util; |
| | | import java.util.ArrayList; |
| | | import java.util.Date; |
| | | import java.util.List; |
| | | import java.util.Objects; |
| | | import java.util.*; |
| | | |
| | | /** |
| | | * Created by vincent on 2022/4/9 |
| | |
| | | private LocMastServiceImpl locMastService; |
| | | @Autowired |
| | | private WrkDetlService wrkDetlService; |
| | | @Autowired |
| | | private BasDevpServiceImpl basDevpService; |
| | | @Autowired |
| | | private StaDescServiceImpl staDescService; |
| | | @Value("${mes.url}") |
| | | private String mesUrl; |
| | | @Value("${mes.stationaddress}") |
| | | private String stationAddress; |
| | | @Autowired |
| | | private WaitPakinService waitPakinService; |
| | | @Autowired |
| | | private WrkMastService wrkMastService; |
| | | |
| | | @Override |
| | | @Transactional |
| | | public void pakinOrderCreate(OpenOrderPakinParam param) { |
| | |
| | | throw new CoolException("未能绑定"); |
| | | } |
| | | } |
| | | |
| | | @Override |
| | | @Transactional |
| | | public List<PickWrkDetlListParam> getPickList(PdaPickListParam param) { |
| | |
| | | |
| | | return result; |
| | | } |
| | | |
| | | |
| | | @Override |
| | | @Transactional |
| | |
| | | } catch (Exception e) { |
| | | throw new CoolException(e.getMessage()); |
| | | } |
| | | } else {} |
| | | } else { |
| | | } |
| | | return true; |
| | | } |
| | | |
| | | |
| | | |
| | | |
| | | @Override |
| | |
| | | agvBindCtnrAndBinTwoParam.setReqCode(String.valueOf(snowflakeIdWorker.nextId())); |
| | | agvBindCtnrAndBinTwoParam.setPodcode(basAgvMast.getBarcode()); |
| | | agvBindCtnrAndBinTwoParam.setPositionCode(basAgvMast.getStaNo().toString()); |
| | | agvBindCtnrAndBinTwoParam.setIndBind("0");; |
| | | agvBindCtnrAndBinTwoParam.setIndBind("0"); |
| | | ; |
| | | ReturnT<String> resultBind = new PostMesDataUtils().postMesDataArmGrating("AGV容器解绑", |
| | | AgvConstant.AGV_URL+"/"+AgvConstant.AGV_hikRpcService,AgvConstant.getAGVADAPTOR(2), agvBindCtnrAndBinTwoParam); |
| | | if (resultBind.getCode()!=1){ |
| | |
| | | |
| | | } |
| | | |
| | | @Override |
| | | @Transactional |
| | | public R stationAll() { |
| | | List<StationParam> stationParams = new ArrayList<>(); |
| | | List<BasDevp> basDevps = basDevpService.selectList(new EntityWrapper<BasDevp>()); |
| | | for (BasDevp basDevp : basDevps) { |
| | | StationParam stationParam = new StationParam(); |
| | | Boolean boo1 = false; |
| | | Boolean boo2 = false; |
| | | StaDesc staDescIn = staDescService.selectOne(new EntityWrapper<StaDesc>().eq("stn_no", basDevp.getDevNo()).eq("type_no", 1)); |
| | | if (!Cools.isEmpty(staDescIn)) { |
| | | stationParam.setStationId(basDevp.getDevNo() + ""); |
| | | stationParam.setStationType("1"); |
| | | stationParam.setStationName(basDevp.getDevNo() + ""); |
| | | stationParam.setOperateType(1); |
| | | boo1 = true; |
| | | } |
| | | StaDesc staDescOut = staDescService.selectOne(new EntityWrapper<StaDesc>().eq("stn_no", basDevp.getDevNo()).eq("type_no", 101)); |
| | | if (!Cools.isEmpty(staDescOut)) { |
| | | stationParam.setStationId(basDevp.getDevNo() + ""); |
| | | stationParam.setStationType("1"); |
| | | stationParam.setStationName(basDevp.getDevNo() + ""); |
| | | stationParam.setOperateType(2); |
| | | if (boo1) { |
| | | stationParam.setOperateType(3); |
| | | } |
| | | boo2 = true; |
| | | } |
| | | if (boo1 || boo2) { |
| | | stationParams.add(stationParam); |
| | | } |
| | | } |
| | | String response = ""; |
| | | try { |
| | | //获取Cookie值 |
| | | HashMap<String, Object> headers = new HashMap<>(); |
| | | // headers.put("accesstoken", erpSecret.getAccessToken()); |
| | | // headers.put("x-acgw-identity", xAcfwIdentity); // 自定义请求头 |
| | | response = new HttpHandler.Builder() |
| | | .setHeaders(headers) |
| | | .setUri(mesUrl) |
| | | .setPath(stationAddress) |
| | | .setJson(JSON.toJSONString(stationParams)) |
| | | .build() |
| | | .doPost(); |
| | | JSONObject jsonResponse = JSON.parseObject(response); |
| | | if (jsonResponse.getInteger("code") == 200) { |
| | | |
| | | } else { |
| | | return R.error(); |
| | | } |
| | | } catch (Exception e) { |
| | | e.printStackTrace(); |
| | | } |
| | | return R.ok(); |
| | | } |
| | | |
| | | @Override |
| | | public R mesToComb(MesToCombParam param) { |
| | | if (Cools.isEmpty(param.getPalletId())) { |
| | | throw new CoolException(BaseRes.PARAM); |
| | | } |
| | | Date now = new Date(); |
| | | |
| | | Mat mat = matService.selectByMatnr(param.getMatnr()); |
| | | if (Cools.isEmpty(mat)) { |
| | | if (param.getFull()==1){ |
| | | //满托盘 |
| | | mat = matService.selectByMatnr("1"); |
| | | }else if (param.getFull()==0){ |
| | | //空托盘 |
| | | mat = matService.selectByMatnr("0"); |
| | | } |
| | | |
| | | } |
| | | WaitPakin waitPakin = new WaitPakin(); |
| | | waitPakin.sync(mat); |
| | | waitPakin.setBatch(String.valueOf(param.getBatchId())); |
| | | waitPakin.setZpallet(param.getPalletId()); // 托盘码 |
| | | waitPakin.setIoStatus("N"); // 入出状态 |
| | | waitPakin.setAnfme(param.getAnfme()); // 数量 |
| | | waitPakin.setStatus("Y"); // 状态 |
| | | waitPakin.setAppeUser(9995L); |
| | | waitPakin.setAppeTime(now); |
| | | waitPakin.setModiUser(9995L); |
| | | waitPakin.setModiTime(now); |
| | | waitPakin.setOrderNo(String.valueOf(param.getOrderId())); |
| | | waitPakin.setOrigin(String.valueOf(param.getStorageArea()));//建议入库区域 |
| | | waitPakin.setManu(String.valueOf(param.getLocId()));//mes具体库位编号 |
| | | waitPakin.setThreeCode(param.getBizNo()); |
| | | if (!waitPakinService.insert(waitPakin)) { |
| | | throw new CoolException("保存入库通知档失败"); |
| | | } |
| | | return null; |
| | | } |
| | | |
| | | @Override |
| | | public R outOrder(OutTaskParam param) { |
| | | LocMast locMast = locMastService.selectOne(new EntityWrapper<LocMast>().eq("loc_sts", "F").eq("barcode", param.getPalletId())); |
| | | if (locMast == null) { |
| | | return R.error("没有找到托盘码="+param.getPalletId()+"对应的库位"); |
| | | } |
| | | Integer ioType = 101; |
| | | // 获取路径 |
| | | StaDesc staDesc = staDescService.queryCrnStn(ioType, locMast.getCrnNo(), Integer.valueOf(param.getStationId())); |
| | | Date now = new Date(); |
| | | // 生成工作号 |
| | | int workNo = commonService.getWorkNo(WorkNoType.getWorkNoType(ioType)); |
| | | // 生成工作档 |
| | | WrkMast wrkMast = new WrkMast(); |
| | | wrkMast.setWrkNo(workNo); |
| | | wrkMast.setIoTime(now); |
| | | wrkMast.setWrkSts(11L); // 工作状态:11.生成出库ID |
| | | wrkMast.setIoType(ioType); // 入出库状态 |
| | | wrkMast.setIoPri(13D); // 优先级:13 |
| | | wrkMast.setCrnNo(locMast.getCrnNo()); |
| | | wrkMast.setSourceStaNo(staDesc.getCrnStn()); // 源站 |
| | | wrkMast.setStaNo(staDesc.getStnNo()); // 目标站 |
| | | wrkMast.setSourceLocNo(locMast.getLocNo()); // 源库位 |
| | | wrkMast.setBarcode(locMast.getBarcode()); |
| | | wrkMast.setFullPlt("Y"); // 满板:Y |
| | | wrkMast.setPicking("N"); // 拣料 |
| | | wrkMast.setExitMk("N"); // 退出 |
| | | wrkMast.setEmptyMk("N"); // 空板 |
| | | wrkMast.setLinkMis("N"); |
| | | wrkMast.setUserNo(param.getOrderId());//订单号 |
| | | wrkMast.setPltType(param.getSeq());//出库顺序,从1开始 |
| | | wrkMast.setTakeNone("0"); //0非自动 |
| | | wrkMast.setAppeUser(9995L); // 操作人员数据 |
| | | wrkMast.setAppeTime(now); |
| | | wrkMast.setModiUser(9995L); |
| | | wrkMast.setModiTime(now); |
| | | if (!wrkMastService.insert(wrkMast)) { |
| | | throw new CoolException("保存工作档失败,出库库位号:"+locMast.getLocNo()); |
| | | } |
| | | List<LocDetl> locNo = locDetlService.selectList(new EntityWrapper<LocDetl>().eq("loc_no", locMast.getLocNo())); |
| | | if (locNo == null || locNo.size() == 0) { |
| | | throw new CoolException("查询库存明细失败,出库库位号:"+locMast.getLocNo()); |
| | | } |
| | | // 生成工作档明细 |
| | | for (LocDetl locDetl : locNo) { |
| | | WrkDetl wrkDetl = new WrkDetl(); |
| | | wrkDetl.sync(locDetl); |
| | | wrkDetl.setOrderNo(param.getOrderId()); // 手动出库不需要带出库存中的单据编号 |
| | | wrkDetl.setWrkNo(workNo); |
| | | wrkDetl.setIoTime(now); |
| | | Double anfme = locDetl.getAnfme(); |
| | | wrkDetl.setAnfme(anfme); // 数量 |
| | | wrkDetl.setAppeTime(now); |
| | | wrkDetl.setAppeUser(9995L); |
| | | wrkDetl.setModiTime(now); |
| | | wrkDetl.setModiUser(9995L); |
| | | |
| | | if (!wrkDetlService.insert(wrkDetl)) { |
| | | throw new CoolException("保存工作档明细失败"); |
| | | } |
| | | } |
| | | // 修改库位状态: F.在库 ====>>> R.出库预约/P.拣料/盘点/并板出库中 |
| | | locMast = locMastService.selectById(locMast.getLocNo()); |
| | | if (locMast.getLocSts().equals("F")) { |
| | | locMast.setLocSts("R"); |
| | | locMast.setModiUser(9995L); |
| | | locMast.setModiTime(now); |
| | | if (!locMastService.updateById(locMast)) { |
| | | throw new CoolException("预约库位状态失败,库位号:"+locMast.getLocNo()); |
| | | } |
| | | } else { |
| | | log.error(locMast.getLocNo() + "库位不是在库状态"); |
| | | throw new CoolException(locMast.getLocNo() + "库位不是在库状态"); |
| | | } |
| | | return R.ok(); |
| | | } |
| | | } |