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.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<LocMastMapper, LocMast> implements LocMastService {
|
@Value("${wms.url}")
|
private String wmsUrl;
|
@Autowired
|
private ApiLogService apiLogService;
|
|
@Override
|
public List<Integer> 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<String> 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<LocMast>().eq("loc_no",locNo));
|
|
//return this.baseMapper.selectByLocNo(locNo);
|
}
|
|
@Override
|
public List<LocMast> selectLocByLev(Integer lev) {
|
return this.baseMapper.selectLocByLev(lev);
|
}
|
|
@Override
|
public R toWmsLocStatus(LocMast locMast) {
|
String response = null;
|
Map<String, Object> 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;
|
}
|
}
|