package com.zy.asrs.service.impl; import com.alibaba.fastjson.JSON; import com.alibaba.fastjson.JSONObject; import com.baomidou.mybatisplus.mapper.EntityWrapper; import com.baomidou.mybatisplus.service.impl.ServiceImpl; import com.core.common.Cools; import com.core.common.R; import com.zy.asrs.entity.LocMast; import com.zy.asrs.entity.WmsLocStatus; import com.zy.asrs.entity.param.TaskOverToWms; import com.zy.asrs.entity.param.WMSAndAGVInterfaceParam; import com.zy.asrs.mapper.LocMastMapper; import com.zy.asrs.service.ApiLogService; import com.zy.asrs.service.LocMastService; import com.zy.asrs.utils.Utils; 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.HashMap; import java.util.List; import java.util.Map; @Slf4j @Service("locMastService") public class LocMastServiceImpl extends ServiceImpl implements LocMastService { @Value("${wms.url}") private String wmsUrl; @Autowired private ApiLogService apiLogService; @Override public List selectLocMastListSix(String locNo,Long whsType,Integer crnNo,Integer row1,Integer bay1,Integer lev1,Integer curr,Integer limit) { return this.baseMapper.selectLocMastListSix(locNo,whsType,crnNo,row1,bay1,lev1,curr,limit); } @Override public Long selectLocMastListTotalSix(String locNo,Long whsType,Integer crnNo,Integer row1,Integer bay1,Integer lev1) { return this.baseMapper.selectLocMastListTotalSix(locNo,whsType,crnNo,row1,bay1,lev1); } @Override public List selectLocMastList(String locNo,Integer curr,Integer limit) { return this.baseMapper.selectLocMastList(locNo,curr,limit); } @Override public Long selectLocMastListTotal(String locNo) { return this.baseMapper.selectLocMastListTotal(locNo); } @Override public List queryDistinctRow(Integer crnNo) { return this.baseMapper.queryDistinctRow(crnNo); } @Override public LocMast queryFreeLocMast(Integer row, Short locType1) { return this.baseMapper.queryFreeLocMast(row, locType1); } @Override public List queryGroupEmptyStock(String sourceLocNo) { if (Cools.isEmpty(sourceLocNo)) { return null; } LocMast sourceStock = this.selectById(sourceLocNo); if (Cools.isEmpty(sourceStock)) { return null; } return this.baseMapper.queryGroupEmptyStock(sourceStock.getCrnNo()); } @Override public LocMast queryDemoSourceLoc(Integer crn) { return this.baseMapper.queryDemoSourceLoc(crn); } @Override public LocMast queryDemoLoc(Integer crn) { return this.baseMapper.queryDemoLoc(crn); } @Override public Boolean checkEmptyCount(LocMast locMast) { if (locMast == null) { return false; } return this.baseMapper.selectEmptyLocCount(locMast.getLocType1(), locMast.getCrnNo()) > 1; } @Override public LocMast selectByLocNo(String locNo) { return this.selectOne(new EntityWrapper().eq("loc_no",locNo)); //return this.baseMapper.selectByLocNo(locNo); } @Override public List selectLocByLev(Integer lev) { return this.baseMapper.selectLocByLev(lev); } @Override public R toWmsLocStatus(LocMast locMast) { String response = null; Map map = new HashMap<>(); map.put("x-api-key","7a15b5db-29b6-552c-8cff-0cfec3756da2"); WmsLocStatus param = new WmsLocStatus(); param.setWarehouseId("1688469798893297665"); param.setLocationCode(Utils.getWmsLocNo(locMast.getLocNo())); param.setEmptyContainer(locMast.getEmptyContainer$()); if (locMast.getLocSts().equals("Z")){ param.setStatus("JY"); }else { param.setStatus("QY"); } if (Cools.isEmpty(locMast.getBarcode()) || locMast.getLocSts().equals("O")){ param.setContainerCode(""); param.setContainerTypeCode(""); }else { param.setContainerCode(locMast.getBarcode()); param.setContainerTypeCode(locMast.getContainerTypeCode()); } try { response = new HttpHandler.Builder() .setHeaders(map) .setUri(wmsUrl) .setPath("wcsManager/wcsInterface/locationUpdate") .setJson(JSON.toJSONString(param)) .build() .doPost(); }catch (Exception e){ log.error("堆垛机任务完成,请求wms任务完成接口失败"); } JSONObject jsonObject = JSON.parseObject(response); apiLogService.save("Wms变更货位状态" ,wmsUrl+"wcsManager/wcsInterface/inboundTaskApply" ,null ,"127.0.0.1" ,JSON.toJSONString(param) ,response ,true ); return null; } }