opt: 优化代码,更新logo展示
This commit is contained in:
@@ -18,6 +18,7 @@ public enum RegionEnum {
|
||||
WXJG("外协加工区","WXJGZCQ"),
|
||||
ZDZWQ("自动折弯区","ZDZWQ"),
|
||||
NBGD("内部过道加工区","NBGDJGQ"),
|
||||
QTJG("其他加工送料暂存区","111-22"),
|
||||
;
|
||||
private final String region_name;
|
||||
private final String region_code;
|
||||
|
||||
@@ -5,6 +5,7 @@ import cn.hutool.core.collection.CollUtil;
|
||||
import cn.hutool.core.lang.Assert;
|
||||
import cn.hutool.core.util.ObjectUtil;
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import cn.hutool.http.HttpUtil;
|
||||
import com.alibaba.fastjson.JSON;
|
||||
import com.alibaba.fastjson.JSONArray;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
@@ -34,6 +35,7 @@ import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import java.util.*;
|
||||
import java.util.concurrent.atomic.AtomicReference;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
@RestController
|
||||
@Api(tags = "fab相关接口")
|
||||
@@ -52,6 +54,7 @@ public class FabController {
|
||||
private ISchBaseVehiclematerialgroupService iSchBaseVehiclematerialgroupService;
|
||||
@Autowired
|
||||
private WmsToConnectorService wmsToConnectorService;
|
||||
private static final HashMap REGION_CODE = MapOf.of("货架", "1", "外协加工", "2", "内部加工", "3", "内部过道", "4","其他加工","5");
|
||||
|
||||
|
||||
/**
|
||||
@@ -222,60 +225,76 @@ public class FabController {
|
||||
public ResponseEntity<TableDataInfo> sendMater(@RequestBody SendMaterVo materInfo) {
|
||||
JSONObject toJSON = (JSONObject) JSON.toJSON(materInfo);
|
||||
//TODO:待确定
|
||||
if ("1".equals(materInfo.getPoint_code())) {
|
||||
List<SendVehicleVo> mater = materInfo.getMater();
|
||||
if (CollUtil.isEmpty(mater)) throw new BadRequestException("物料信息为空,请确认!");
|
||||
JSONObject json = new JSONObject();
|
||||
JSONArray jsonArray = new JSONArray();
|
||||
HashMap<String, Object> map = new HashMap<>();
|
||||
mater.stream().forEach(material -> {
|
||||
map.put("order_code", material.getOrder_code());
|
||||
map.put("qty", material.getMaterial_qty());
|
||||
jsonArray.add(map);
|
||||
});
|
||||
SchBasePoint schBasePoint = iSchBasePointService.selectByPointCode(materInfo.getDevice_code());
|
||||
json.put("vehicle_code", schBasePoint.getVehicle_code());
|
||||
json.put("region_code", schBasePoint.getRegion_code());
|
||||
json.put("materials", jsonArray);
|
||||
JSONObject jsonObject = wmsToConnectorService.applyRegionAndDueDate(json);
|
||||
if (ObjectUtil.isNotEmpty(jsonObject) && jsonObject.getInteger("status") == 200) {
|
||||
JSONArray data = jsonObject.getJSONArray("data");
|
||||
data.stream().forEach(material -> {
|
||||
JSONObject jsonObject1 = JSONObject.parseObject(StrUtil.toString(material));
|
||||
mater.stream().forEach(material1 -> {
|
||||
if (material1.getOrder_code().equals(jsonObject1.getString("order_code"))) {
|
||||
material1.setDue_date(jsonObject1.getString("due_date"));
|
||||
material1.setRegion_code(jsonObject1.getString("next_region_code"));
|
||||
material1.setPriority(jsonObject1.getString("priority"));
|
||||
}
|
||||
});
|
||||
});
|
||||
} else if (ObjectUtil.isNotEmpty(jsonObject) && jsonObject.getInteger("status") == 400) {
|
||||
throw new BadRequestException(jsonObject.getString("msg"));
|
||||
if (REGION_CODE.get("货架").equals(materInfo.getPoint_code())) {
|
||||
List<SendVehicleVo> materials = materInfo.getMater();
|
||||
if (CollUtil.isEmpty(materials)) {
|
||||
throw new BadRequestException("物料信息为空,请确认!");
|
||||
}
|
||||
SchBasePoint schBasePoint = iSchBasePointService.selectByPointCode(materInfo.getDevice_code());
|
||||
JSONObject jsonObject = wmsToConnectorService.applyRegionAndDueDate(buildRequestJson(materials, schBasePoint));
|
||||
handleWmsResponse(jsonObject, materials);
|
||||
List<String> materiales = new ArrayList<>();
|
||||
mater.stream().forEach(material -> {
|
||||
materials.forEach(material -> {
|
||||
materiales.add(JSONObject.toJSONString(material));
|
||||
});
|
||||
toJSON.put("material_info", materiales);
|
||||
toJSON.put("vehicle_code", schBasePoint.getVehicle_code());
|
||||
toJSON.put("region_code", StrUtil.isNotEmpty(mater.get(0).getRegion_code()) ? mater.get(0).getRegion_code() : schBasePoint.getRegion_code());
|
||||
toJSON.put("region_code", StrUtil.isNotEmpty(materials.get(0).getRegion_code()) ? materials.get(0).getRegion_code() : schBasePoint.getRegion_code());
|
||||
} else {
|
||||
if ("2".equals(materInfo.getPoint_code())) {
|
||||
if (REGION_CODE.get("内部加工").equals(materInfo.getPoint_code())) {
|
||||
List<SendVehicleVo> mater = materInfo.getMater();
|
||||
if (CollUtil.isEmpty(mater)) throw new BadRequestException("物料信息为空,请确认!");
|
||||
toJSON.put("material_info", mater);
|
||||
toJSON.put("region_code", RegionEnum.NBJG.getRegion_code());
|
||||
} else if ("3".equals(materInfo.getPoint_code())) {
|
||||
} else if (REGION_CODE.get("外协加工").equals(materInfo.getPoint_code())) {
|
||||
toJSON.put("region_code", RegionEnum.WXJG.getRegion_code());
|
||||
} else if ("4".equals(materInfo.getPoint_code())) {
|
||||
} else if (REGION_CODE.get("内部过道").equals(materInfo.getPoint_code())) {
|
||||
toJSON.put("region_code", RegionEnum.NBGD.getRegion_code());
|
||||
} else if (REGION_CODE.get("其他加工").equals(materInfo.getPoint_code())) {
|
||||
toJSON.put("region_code", RegionEnum.QTJG.getRegion_code());
|
||||
}
|
||||
}
|
||||
fabService.createAgvTask(toJSON, "smt");
|
||||
return new ResponseEntity(TableDataInfo.build(), HttpStatus.OK);
|
||||
}
|
||||
|
||||
private void handleWmsResponse(JSONObject response, List<SendVehicleVo> materials) {
|
||||
if (ObjectUtil.isEmpty(response)) {
|
||||
throw new BadRequestException("WMS服务无响应");
|
||||
}
|
||||
int status = response.getIntValue("status");
|
||||
if (status == HttpStatus.OK.value()) {
|
||||
response.getJSONArray("data").forEach(item -> {
|
||||
JSONObject dataItem = (JSONObject) item;
|
||||
materials.forEach(material -> {
|
||||
if (dataItem.getString("order_code").equals(material.getOrder_code())) {
|
||||
material.setDue_date(dataItem.getString("due_date"));
|
||||
material.setRegion_code(dataItem.getString("next_region_code"));
|
||||
material.setPriority(dataItem.getString("priority"));
|
||||
}
|
||||
});
|
||||
});
|
||||
} else {
|
||||
throw new BadRequestException(response.getString("msg"));
|
||||
}
|
||||
}
|
||||
|
||||
private JSONObject buildRequestJson(List<SendVehicleVo> materials, SchBasePoint schBasePoint) {
|
||||
JSONArray jsonArray = materials.stream().map(
|
||||
material -> {
|
||||
HashMap<String, Object> map = new HashMap<>();
|
||||
map.put("order_code", material.getOrder_code());
|
||||
map.put("qty", material.getMaterial_qty());
|
||||
return map;
|
||||
}
|
||||
).collect(Collectors.toCollection(JSONArray::new));
|
||||
JSONObject json = new JSONObject();
|
||||
json.put("vehicle_code", schBasePoint.getVehicle_code());
|
||||
json.put("region_code", schBasePoint.getRegion_code());
|
||||
json.put("materials", jsonArray);
|
||||
return json;
|
||||
}
|
||||
|
||||
//TODO: 根据物料查主盘信息; 当前工序查所有物料 ->
|
||||
|
||||
/**
|
||||
|
||||
@@ -128,9 +128,8 @@ public class FabServiceImpl {
|
||||
param.put("device_code", sendMaterVo.getDevice_code());
|
||||
param.put("ext_data", sendMaterVo);
|
||||
param.put("region_code", sendMaterVo.getRegion_code());
|
||||
if (sendMaterVo.getRegion_code().equals(RegionEnum.NBJG.getRegion_code()) || sendMaterVo.getRegion_code().equals(RegionEnum.WXJG.getRegion_code())) {
|
||||
param.put("config_code", "ProcessingSMTTask");
|
||||
} else if (sendMaterVo.getRegion_code().equals(RegionEnum.NBGD.getRegion_code())) {
|
||||
if (sendMaterVo.getRegion_code().equals(RegionEnum.NBJG.getRegion_code()) || sendMaterVo.getRegion_code().equals(RegionEnum.WXJG.getRegion_code())
|
||||
|| sendMaterVo.getRegion_code().equals(RegionEnum.NBGD.getRegion_code()) || sendMaterVo.getRegion_code().equals(RegionEnum.QTJG.getRegion_code())) {
|
||||
param.put("config_code", "ProcessingSMTTask");
|
||||
} else {
|
||||
param.put("config_code", "PcOperationSMTTask");
|
||||
|
||||
@@ -29,7 +29,7 @@ public class HandheldController {
|
||||
private HandheldService handheldService;
|
||||
|
||||
@PostMapping("/cageFrame")
|
||||
@Log("外协区空笼框送回")
|
||||
@Log("笼框补仓")
|
||||
public ResponseEntity<Object> createEmptyCageStorageTask(@RequestBody JSONObject param) {
|
||||
handheldService.emptyCageStorageTask(param);
|
||||
return new ResponseEntity<>(HttpStatus.OK);
|
||||
|
||||
@@ -73,7 +73,7 @@ public class HandheldServiceImpl implements HandheldService {
|
||||
private RedisUtils redisUtils;
|
||||
@Autowired
|
||||
private WmsToAcsService wmsToAcsService;
|
||||
static final Map<String,String> STATUS = MapOf.of("释放","0","锁定","1");
|
||||
static final Map<String, String> STATUS = MapOf.of("释放", "0", "锁定", "1");
|
||||
|
||||
|
||||
@Override
|
||||
@@ -168,38 +168,12 @@ public class HandheldServiceImpl implements HandheldService {
|
||||
String[] vehicle_list = null;
|
||||
if (vehicle.contains(",")) {
|
||||
vehicle_list = vehicle.split(",");
|
||||
}
|
||||
if (CollUtil.isEmpty(Arrays.asList(vehicle_list))) {
|
||||
MdBaseVehicle mdBaseVehicle = iMdBaseVehicleService.selectByVehicleCode(vehicle);
|
||||
if (ObjectUtil.isEmpty(mdBaseVehicle)) throw new BadRequestException("载具不存在!");
|
||||
if (!mdBaseVehicle.getVehicle_type().equals(VehicleTypeEnum.FRAME_R01.getVehicleCode())
|
||||
&& !mdBaseVehicle.getVehicle_type().equals(VehicleTypeEnum.FRAME_R02.getVehicleCode())) {
|
||||
throw new BadRequestException("托盘类型不匹配,,生成搬运任务失败!");
|
||||
}
|
||||
} else {
|
||||
String[] finalVehicle_list = vehicle_list;
|
||||
MdBaseVehicle mdBaseVehicle = iMdBaseVehicleService.selectByVehicleCode(vehicle_list[0]);
|
||||
if (ObjectUtil.isEmpty(mdBaseVehicle)) throw new BadRequestException("载具不存在!");
|
||||
if (mdBaseVehicle.getVehicle_type().equals(VehicleTypeEnum.FRAME_R01.getVehicleCode())) {
|
||||
if (finalVehicle_list.length != 2) {
|
||||
throw new BadRequestException("笼框数量不匹配,请确认笼框数量后重新扫码!");
|
||||
}
|
||||
}
|
||||
if (mdBaseVehicle.getVehicle_type().equals(VehicleTypeEnum.FRAME_R02.getVehicleCode())) {
|
||||
if (finalVehicle_list.length != 4) {
|
||||
throw new BadRequestException("笼框数量不匹配,请确认笼框数量后重新扫码!");
|
||||
}
|
||||
}
|
||||
Arrays.stream(vehicle_list).forEach(vehicleCode -> {
|
||||
String vehicleCode1 = vehicleCode;
|
||||
MdBaseVehicle mdBaseVehicle1 = iMdBaseVehicleService.selectByVehicleCode(vehicleCode1);
|
||||
if (ObjectUtil.isEmpty(mdBaseVehicle1)) throw new BadRequestException("载具不存在!");
|
||||
if (!mdBaseVehicle1.getVehicle_type().equals(VehicleTypeEnum.FRAME_R01.getVehicleCode())
|
||||
&& !mdBaseVehicle1.getVehicle_type().equals(VehicleTypeEnum.FRAME_R02.getVehicleCode())) {
|
||||
throw new BadRequestException("托盘类型不匹配,,生成搬运任务失败!");
|
||||
}
|
||||
});
|
||||
vehicle_list = new String[]{vehicle};
|
||||
}
|
||||
MdBaseVehicle mdBaseVehicle = iMdBaseVehicleService.selectByVehicleCode(vehicle_list[0]);
|
||||
if(ObjectUtil.isEmpty(mdBaseVehicle)) throw new BadRequestException("托盘不存在!");
|
||||
verifyNumber(vehicle_list, mdBaseVehicle.getVehicle_type());
|
||||
SchBasePoint schBasePoint = iSchBasePointService.selectByPointCode(device_code);
|
||||
if (ObjectUtil.isEmpty(schBasePoint)) throw new BadRequestException("设备点位不存在!");
|
||||
AbstractTask connectorTask = taskFactory.getTask("EMPTYCAGETask");
|
||||
@@ -214,6 +188,55 @@ public class HandheldServiceImpl implements HandheldService {
|
||||
connectorTask.apply(jo);
|
||||
}
|
||||
|
||||
/**
|
||||
* 验证托盘数量和类型
|
||||
*
|
||||
* @param vehicles 回库托盘号
|
||||
* @param number 托盘数
|
||||
* @param vehicleType 托盘类型
|
||||
*/
|
||||
private void verifyNumber(String[] vehicles, String vehicleType) {
|
||||
switch(vehicleType){
|
||||
case "R01":
|
||||
if (vehicles.length != 2) {
|
||||
throw new BadRequestException("托盘数量不匹配");
|
||||
}
|
||||
verifyVehicleType(vehicles, "R01");
|
||||
break;
|
||||
case "R02":
|
||||
if (vehicles.length != 4) {
|
||||
throw new BadRequestException("托盘数量不匹配");
|
||||
}
|
||||
verifyVehicleType(vehicles, "R02");
|
||||
break;
|
||||
case "S04":
|
||||
if (vehicles.length != 1) {
|
||||
throw new BadRequestException("托盘数量不匹配");
|
||||
}
|
||||
verifyVehicleType(vehicles, "S04");
|
||||
break;
|
||||
case "S06":
|
||||
if (vehicles.length != 1) {
|
||||
throw new BadRequestException("托盘数量不匹配");
|
||||
}
|
||||
verifyVehicleType(vehicles, "S06");
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
private void verifyVehicleType(String[] vehicles, String vehicleType) {
|
||||
Arrays.stream(vehicles).forEach(vehicleCode -> {
|
||||
MdBaseVehicle mdBaseVehicle = iMdBaseVehicleService.selectByVehicleCode(vehicleCode);
|
||||
if (ObjectUtil.isEmpty(mdBaseVehicle)) throw new BadRequestException("托盘号不存在");
|
||||
if (!mdBaseVehicle.getVehicle_type().equals(vehicleType)) {
|
||||
throw new BadRequestException("托盘类型不匹配");
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object applyEmptyVehicle(JSONObject param) {
|
||||
return null;
|
||||
@@ -248,6 +271,9 @@ public class HandheldServiceImpl implements HandheldService {
|
||||
case "4":
|
||||
connectorBlanking(param, RegionEnum.LAG_ROBOT_BEANDING_CELL.getRegion_code(), device_code, vehicle_code, connectorTask);
|
||||
break;
|
||||
case "5":
|
||||
connectorBlanking(param, RegionEnum.QTJG.getRegion_code(), device_code, vehicle_code, connectorTask);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
@@ -338,10 +364,10 @@ public class HandheldServiceImpl implements HandheldService {
|
||||
param.put("region_code", region_code);
|
||||
param.put("materials", materials);
|
||||
jo.put("ext_data", param);
|
||||
connectorTask.apply(jo);
|
||||
iSchBasePointService.update(Wrappers.lambdaUpdate(SchBasePoint.class)
|
||||
.eq(SchBasePoint::getPoint_code, device_code)
|
||||
.set(SchBasePoint::getIs_lock, true));
|
||||
connectorTask.apply(jo);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -629,11 +655,11 @@ public class HandheldServiceImpl implements HandheldService {
|
||||
List<Map> maps = iSchBaseVehiclematerialgroupService.selectOrdersByVehicleCode(list);
|
||||
HashSet<Map> keys = new HashSet<>();
|
||||
maps.stream().forEach(item -> {
|
||||
keys.add(MapOf.of("material_id", item.get("material_id"),"material_path", item.get("material_path")));
|
||||
keys.add(MapOf.of("material_id", item.get("material_id"), "material_path", item.get("material_path")));
|
||||
});
|
||||
JSONObject json = new JSONObject();
|
||||
json.put("vehiclePath",maps.get(0).get("vehicle_path"));
|
||||
json.put("materialList",keys);
|
||||
json.put("vehiclePath", maps.get(0).get("vehicle_path"));
|
||||
json.put("materialList", keys);
|
||||
return json;
|
||||
}
|
||||
return null;
|
||||
|
||||
@@ -220,4 +220,15 @@ public interface ISchBasePointService extends IService<SchBasePoint> {
|
||||
* @return
|
||||
*/
|
||||
SchBasePoint selectPointByEmpAndRegion(String region_code, String vehicle_code, String s);
|
||||
|
||||
/**
|
||||
* 查询堆叠点位
|
||||
* @param region_code 工序
|
||||
* @param pointType 点位类型
|
||||
* @param vehicleCode 托盘号
|
||||
* @param i 排序
|
||||
* @param i1 排序
|
||||
* @return 点位对象
|
||||
*/
|
||||
SchBasePoint selectStackPoint(String region_code, String pointType, String vehicleCode, int is_vehicle, int i1);
|
||||
}
|
||||
|
||||
@@ -77,6 +77,7 @@
|
||||
select point_code, point_name, point_status
|
||||
from sch_base_point
|
||||
where region_code = #{regionCode}
|
||||
AND is_used = true
|
||||
</select>
|
||||
|
||||
</mapper>
|
||||
|
||||
@@ -96,7 +96,7 @@ public class SchBasePointServiceImpl extends ServiceImpl<SchBasePointMapper, Sch
|
||||
.or(ObjectUtil.isNotEmpty(blurry), lam1 -> lam1.like(SchBasePoint::getPoint_name, blurry))
|
||||
.eq(ObjectUtil.isNotEmpty(workshop_code), SchBasePoint::getWorkshop_code, workshop_code)
|
||||
.eq(ObjectUtil.isNotEmpty(region_code), SchBasePoint::getRegion_code, region_code)
|
||||
.eq(ObjectUtil.isNotEmpty(point_type), SchBasePoint::getPoint_type, point_type)
|
||||
.eq(ObjectUtil.isNotEmpty(point_type), SchBasePoint::getCan_vehicle_type, point_type)
|
||||
.eq(ObjectUtil.isNotEmpty(point_status), SchBasePoint::getPoint_status, point_status)
|
||||
.eq(ObjectUtil.isNotEmpty(is_used), SchBasePoint::getIs_used, is_used)
|
||||
.eq(ObjectUtil.isNotEmpty(lock_type), SchBasePoint::getIs_lock, lock_type)
|
||||
@@ -254,46 +254,43 @@ public class SchBasePointServiceImpl extends ServiceImpl<SchBasePointMapper, Sch
|
||||
public SchBasePoint selectByRegionCode(String region_code, String vehicleCode, String piont_type) {
|
||||
synchronized (lock2) {
|
||||
//查询载具的类型
|
||||
MdBaseVehicle mdBaseVehicle = iMdBaseVehicleService.getById(vehicleCode);
|
||||
MdBaseVehicle mdBaseVehicle = iMdBaseVehicleService.selectByVehicleCode(vehicleCode);
|
||||
if (ObjectUtil.isEmpty(mdBaseVehicle)) throw new BadRequestException("载具类型不存在!");
|
||||
//查询满足条件的站点
|
||||
List<SchBasePoint> schBasePoints = pointMapper.selectList(Wrappers.lambdaQuery(SchBasePoint.class)
|
||||
.eq(SchBasePoint::getIs_lock, false)
|
||||
.isNull(SchBasePoint::getVehicle_code)
|
||||
.eq(SchBasePoint::getPoint_type, piont_type)
|
||||
.eq(SchBasePoint::getRegion_code, region_code)
|
||||
.eq(SchBasePoint::getPoint_status, GoodsEnum.OUT_OF_STOCK.getValue())
|
||||
.eq(SchBasePoint::getCan_vehicle_type, mdBaseVehicle.getVehicle_type())
|
||||
.eq(SchBasePoint::getIs_used, true));
|
||||
if (CollUtil.isNotEmpty(schBasePoints) && schBasePoints.size() > 0) {
|
||||
SchBasePoint schBasePoint = schBasePoints.get(0);
|
||||
schBasePoint.setIs_lock(true);
|
||||
PointUtils.setUpdateByAcs(schBasePoint);
|
||||
pointMapper.updateById(schBasePoint);
|
||||
return schBasePoint;
|
||||
}
|
||||
/*SchBasePoint schBasePoint1 = pointMapper.selectList(Wrappers.lambdaQuery(SchBasePoint.class).eq(SchBasePoint::getRegion_code, region_code)).get(0);
|
||||
if (ObjectUtil.isEmpty(schBasePoint1)) throw new BadRequestException("不存在该区域!");*/
|
||||
//分配载具类型相同的站点
|
||||
List<SchBasePoint> schBasePoints1 = pointMapper.selectList(Wrappers.lambdaQuery(SchBasePoint.class)
|
||||
.eq(SchBasePoint::getIs_lock, false)
|
||||
.isNull(SchBasePoint::getVehicle_code)
|
||||
.eq(SchBasePoint::getPoint_type, piont_type)
|
||||
.eq(SchBasePoint::getCan_vehicle_type, mdBaseVehicle.getVehicle_type())
|
||||
.eq(SchBasePoint::getIs_used, true)
|
||||
.eq(SchBasePoint::getPoint_status, GoodsEnum.OUT_OF_STOCK.getValue()));
|
||||
if (CollUtil.isNotEmpty(schBasePoints1) && schBasePoints1.size() > 0) {
|
||||
/*schBasePoints1.stream().sorted(Comparator.comparingInt(schBasePoint -> Math.abs(schBasePoint1.getRegion_seq() - schBasePoint.getRegion_seq())));*/
|
||||
SchBasePoint schBasePoint = schBasePoints1.get(0);
|
||||
schBasePoint.setIs_lock(true);
|
||||
PointUtils.setUpdateByAcs(schBasePoint);
|
||||
pointMapper.updateById(schBasePoint);
|
||||
return schBasePoint;
|
||||
SchBasePoint schBasePoint = getSchBasePoint(region_code, piont_type, mdBaseVehicle);
|
||||
if(ObjectUtil.isEmpty(schBasePoint)){
|
||||
schBasePoint = getSchBasePoint(null, piont_type, mdBaseVehicle);
|
||||
}
|
||||
if (ObjectUtil.isNotEmpty(schBasePoint)) return schBasePoint;
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取空点位
|
||||
* @param regionCode
|
||||
* @param pointType
|
||||
* @param mdBaseVehicle
|
||||
* @return
|
||||
*/
|
||||
private SchBasePoint getSchBasePoint(String regionCode, String pointType, MdBaseVehicle mdBaseVehicle) {
|
||||
List<SchBasePoint> schBasePoints = pointMapper.selectList(Wrappers.lambdaQuery(SchBasePoint.class)
|
||||
.eq(SchBasePoint::getIs_lock, false)
|
||||
.isNull(SchBasePoint::getVehicle_code)
|
||||
.eq(SchBasePoint::getPoint_type, pointType)
|
||||
.eq(StrUtil.isNotEmpty(regionCode),SchBasePoint::getRegion_code, regionCode)
|
||||
.eq(SchBasePoint::getPoint_status, GoodsEnum.OUT_OF_STOCK.getValue())
|
||||
.eq(SchBasePoint::getCan_vehicle_type, mdBaseVehicle.getVehicle_type())
|
||||
.eq(SchBasePoint::getIs_used, true));
|
||||
if (CollUtil.isNotEmpty(schBasePoints) && schBasePoints.size() > 0) {
|
||||
SchBasePoint schBasePoint = schBasePoints.get(0);
|
||||
schBasePoint.setIs_lock(true);
|
||||
PointUtils.setUpdateByAcs(schBasePoint);
|
||||
pointMapper.updateById(schBasePoint);
|
||||
return schBasePoint;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public SchBasePoint selectByPointCode(String start_device_code) {
|
||||
return pointMapper.selectOne(Wrappers.lambdaQuery(SchBasePoint.class)
|
||||
@@ -450,9 +447,6 @@ public class SchBasePointServiceImpl extends ServiceImpl<SchBasePointMapper, Sch
|
||||
.orderByDesc(SchBasePoint::getIn_order_seq));
|
||||
if (CollUtil.isNotEmpty(schBasePoints) && schBasePoints.size() > 0) {
|
||||
SchBasePoint schBasePoint = schBasePoints.get(0);
|
||||
/*Gson gson = new Gson();
|
||||
Type setType = new TypeToken<List<String>>() {
|
||||
}.getType();*/
|
||||
List<String> msg = new ArrayList<>();
|
||||
String vehicles = schBasePoint.getVehicles();
|
||||
boolean contains = vehicles.contains(",");
|
||||
@@ -611,6 +605,27 @@ public class SchBasePointServiceImpl extends ServiceImpl<SchBasePointMapper, Sch
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public SchBasePoint selectStackPoint(String regionCode, String pointStatus, String vehicleType, int seq, int point_type) {
|
||||
List<SchBasePoint> schBasePoints = pointMapper.selectList(Wrappers.lambdaQuery(SchBasePoint.class)
|
||||
.eq(SchBasePoint::getIs_lock, false)
|
||||
.eq(SchBasePoint::getIs_used, true)
|
||||
.eq(SchBasePoint::getPoint_status, pointStatus)
|
||||
.eq(SchBasePoint::getCan_vehicle_type, vehicleType)
|
||||
.eq(SchBasePoint::getPoint_type, point_type)
|
||||
.eq(SchBasePoint::getRegion_code, regionCode)
|
||||
.isNull(seq == 2, SchBasePoint::getVehicles)
|
||||
.isNull(seq == 1, SchBasePoint::getVehicle_code)
|
||||
.orderByAsc( SchBasePoint::getIn_order_seq));
|
||||
SchBasePoint schBasePoint = (CollUtil.isNotEmpty(schBasePoints) && schBasePoints.size() > 0) ? schBasePoints.get(0) : null;
|
||||
if (ObjectUtil.isNotEmpty(schBasePoint)) {
|
||||
schBasePoint.setIs_lock(true);
|
||||
PointUtils.setUpdateByAcs(schBasePoint);
|
||||
updateById(schBasePoint);
|
||||
}
|
||||
return schBasePoint;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<OrderMater> getStructList(String pointCode, String vehicle_type) {
|
||||
//1.查询的结果一个托盘有多个800,PC需要怎么展示?
|
||||
|
||||
@@ -213,5 +213,8 @@ public class GeneralDefinition {
|
||||
|
||||
public static final Map<String,List<String>> CYZZD01 = MapOf.of("CYZZD01", ListUtil.of("CYXLDJW01", "CYXLDJW02"));
|
||||
public static final Map<String,List<String>> CYZZD02 = MapOf.of("CYZZD02", ListUtil.of("CYXLDJW03", "CYXLDJW04"));
|
||||
|
||||
/**
|
||||
* 是否打印
|
||||
*/
|
||||
public static final String IS_PRINT = "is_print";
|
||||
}
|
||||
|
||||
@@ -1,176 +0,0 @@
|
||||
/*
|
||||
package org.nl.wms.sch.task_manage.task.tasks.handheld;
|
||||
|
||||
import cn.hutool.core.util.ObjectUtil;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
||||
import org.nl.common.enums.GoodsEnum;
|
||||
import org.nl.common.exception.BadRequestException;
|
||||
import org.nl.system.service.notice.ISysNoticeService;
|
||||
import org.nl.wms.database.vehicle.service.IMdBaseVehicleService;
|
||||
import org.nl.wms.database.vehicle.service.dao.MdBaseVehicle;
|
||||
import org.nl.wms.ext.acs.service.dto.to.BaseResponse;
|
||||
import org.nl.wms.sch.group.service.ISchBaseVehiclematerialgroupService;
|
||||
import org.nl.wms.sch.point.service.ISchBasePointService;
|
||||
import org.nl.wms.sch.point.service.dao.SchBasePoint;
|
||||
import org.nl.wms.sch.task.service.ISchBaseTaskService;
|
||||
import org.nl.wms.sch.task.service.ISchBaseTaskconfigService;
|
||||
import org.nl.wms.sch.task.service.dao.SchBaseTask;
|
||||
import org.nl.wms.sch.task_manage.AbstractTask;
|
||||
import org.nl.wms.sch.task_manage.GeneralDefinition;
|
||||
import org.nl.wms.sch.task_manage.enums.NoticeTypeEnum;
|
||||
import org.nl.wms.sch.task_manage.enums.TaskFinishedTypeEnum;
|
||||
import org.nl.wms.sch.task_manage.task.core.TaskStatus;
|
||||
import org.nl.wms.util.PointUtils;
|
||||
import org.nl.wms.util.TaskUtils;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
*/
|
||||
/**
|
||||
* @author LENOVO
|
||||
* 手持呼叫空料笼
|
||||
*//*
|
||||
|
||||
@Component("CALLEMPTYTask")
|
||||
public class CallEmptyTask extends AbstractTask {
|
||||
|
||||
private static final String TASK_CONFIG_CODE = "CALLEMPTYTask";
|
||||
@Autowired
|
||||
private ISchBasePointService pointService;
|
||||
@Autowired
|
||||
private ISchBaseTaskService taskService;
|
||||
@Autowired
|
||||
private ISchBaseTaskconfigService taskConfigService;
|
||||
@Autowired
|
||||
private ISysNoticeService noticeService;
|
||||
@Autowired
|
||||
private ISchBasePointService schBasePointService;
|
||||
@Autowired
|
||||
private IMdBaseVehicleService iMdBaseVehicleService;
|
||||
|
||||
@Override
|
||||
protected void create() throws BadRequestException {
|
||||
// 获取任务
|
||||
List<SchBaseTask> tasks = taskService.findTasksByTaskStatus(TASK_CONFIG_CODE, TaskStatus.APPLY);
|
||||
// 配置信息
|
||||
for (SchBaseTask task : tasks) {
|
||||
MdBaseVehicle mdBaseVehicle = iMdBaseVehicleService.selectByVehicleCode(task.getVehicle_code());
|
||||
if (ObjectUtil.isEmpty(mdBaseVehicle)) {
|
||||
task.setRemark("载具号不存在!");
|
||||
taskService.updateById(task);
|
||||
// 消息通知
|
||||
noticeService.createNotice("载具号不存在!", TASK_CONFIG_CODE + task.getTask_code(),
|
||||
NoticeTypeEnum.WARN.getCode());
|
||||
continue;
|
||||
}
|
||||
SchBasePoint schBasePoint = schBasePointService.selectByGroundPoint(task.getRegion_code(), GoodsEnum.OUT_OF_STOCK.getValue()
|
||||
, mdBaseVehicle.getVehicle_type(), 1,1);
|
||||
if (ObjectUtil.isEmpty(schBasePoint)) {
|
||||
task.setRemark("未找到所需点位!");
|
||||
taskService.updateById(task);
|
||||
// 消息通知
|
||||
noticeService.createNotice("未找到所需点位!", TASK_CONFIG_CODE + task.getTask_code(),
|
||||
NoticeTypeEnum.WARN.getCode());
|
||||
continue;
|
||||
}
|
||||
// 设置终点并修改创建成功状态
|
||||
task.setPoint_code1(schBasePoint.getPoint_code());
|
||||
task.setVehicle_type(schBasePoint.getCan_vehicle_type());
|
||||
task.setRemark("");
|
||||
task.setTask_status(TaskStatus.CREATED.getCode());
|
||||
TaskUtils.setUpdateByAcs(task);
|
||||
taskService.updateById(task);
|
||||
|
||||
schBasePoint.setIs_lock(true);
|
||||
PointUtils.setUpdateByAcs(schBasePoint);
|
||||
pointService.updateById(schBasePoint);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void updateStatus(String task_code, TaskStatus status) {
|
||||
//TODO:完成任务的时候将int_task_code的清除
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void forceFinish(String task_code) {
|
||||
SchBaseTask taskObj = taskService.getByCode(task_code);
|
||||
if (ObjectUtil.isEmpty(taskObj)) {
|
||||
throw new BadRequestException("该任务不存在");
|
||||
}
|
||||
this.finishTask(taskObj, TaskFinishedTypeEnum.MANUAL_CONNECTOR);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void cancel(String task_code) {
|
||||
//TODO:取消任务的时候将int_task_code的清除
|
||||
SchBaseTask taskObj = taskService.getByCode(task_code);
|
||||
if (ObjectUtil.isEmpty(taskObj)) {
|
||||
throw new BadRequestException("该任务不存在");
|
||||
}
|
||||
this.cancelTask(taskObj, TaskFinishedTypeEnum.MANUAL_CONNECTOR);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void feedbackTaskState(JSONObject param, SchBaseTask schBaseTask, BaseResponse result) {
|
||||
|
||||
}
|
||||
|
||||
public void finishTask(SchBaseTask taskObj, TaskFinishedTypeEnum taskFinishedType) {
|
||||
// 获取参数
|
||||
String startPoint = taskObj.getPoint_code1();
|
||||
SchBasePoint schBasePoint = pointService.selectByPointCode(startPoint);
|
||||
// 起点清空
|
||||
if (ObjectUtil.isNotEmpty(schBasePoint)) {
|
||||
PointUtils.updateByIngTaskCode(schBasePoint);
|
||||
pointService.update(Wrappers.lambdaUpdate(SchBasePoint.class)
|
||||
.eq(SchBasePoint::getPoint_code, startPoint)
|
||||
.set(SchBasePoint::getVehicle_code, null)
|
||||
.set(SchBasePoint::getPoint_status, GoodsEnum.OUT_OF_STOCK.getValue())
|
||||
.set(SchBasePoint::getIs_lock, false));
|
||||
}
|
||||
String point_code2 = taskObj.getPoint_code2();
|
||||
SchBasePoint schBasePoint2 = pointService.selectByPointCode(point_code2);
|
||||
if (ObjectUtil.isNotEmpty(schBasePoint2)) {
|
||||
PointUtils.updateByIngTaskCode(schBasePoint2);
|
||||
pointService.update(Wrappers.lambdaUpdate(SchBasePoint.class)
|
||||
.eq(SchBasePoint::getPoint_code, point_code2)
|
||||
.set(SchBasePoint::getVehicle_code, taskObj.getVehicle_code())
|
||||
.set(SchBasePoint::getPoint_status, GoodsEnum.EMPTY_PALLETS.getValue())
|
||||
.set(SchBasePoint::getIs_lock, false));
|
||||
}
|
||||
// 任务完成
|
||||
taskObj.setTask_status(TaskStatus.FINISHED.getCode());
|
||||
taskObj.setRemark(GeneralDefinition.TASK_FINISH);
|
||||
taskObj.setFinished_type(taskFinishedType.getCode());
|
||||
TaskUtils.setUpdateByType(taskObj, taskFinishedType);
|
||||
taskService.updateById(taskObj);
|
||||
}
|
||||
|
||||
public void cancelTask(SchBaseTask taskObj, TaskFinishedTypeEnum taskFinishedType) {
|
||||
// 获取参数
|
||||
SchBasePoint schBasePoint1 = schBasePointService.selectByPointCode(taskObj.getPoint_code1());
|
||||
if (ObjectUtil.isNotEmpty(schBasePoint1)) {
|
||||
schBasePoint1.setIs_lock(false);
|
||||
PointUtils.setUpdateByAcs(schBasePoint1);
|
||||
schBasePointService.updateById(schBasePoint1);
|
||||
}
|
||||
SchBasePoint schBasePoint = schBasePointService.selectByPointCode(taskObj.getPoint_code2());
|
||||
if (ObjectUtil.isNotEmpty(schBasePoint)) {
|
||||
schBasePoint.setIs_lock(false);
|
||||
PointUtils.setUpdateByAcs(schBasePoint);
|
||||
schBasePointService.updateById(schBasePoint);
|
||||
}
|
||||
taskObj.setTask_status(TaskStatus.CANCELED.getCode());
|
||||
taskObj.setRemark(GeneralDefinition.TASK_CANCEL);
|
||||
taskObj.setTask_status(TaskStatus.CANCELED.getCode());
|
||||
taskObj.setFinished_type(taskFinishedType.getCode());
|
||||
TaskUtils.setUpdateByType(taskObj, taskFinishedType);
|
||||
taskService.updateById(taskObj);
|
||||
}
|
||||
}
|
||||
*/
|
||||
@@ -10,6 +10,7 @@ import org.nl.common.enums.GoodsEnum;
|
||||
import org.nl.common.enums.VehicleTypeEnum;
|
||||
import org.nl.common.enums.region.RegionEnum;
|
||||
import org.nl.common.exception.BadRequestException;
|
||||
import org.nl.config.MapOf;
|
||||
import org.nl.system.service.notice.ISysNoticeService;
|
||||
import org.nl.wms.database.vehicle.service.IMdBaseVehicleService;
|
||||
import org.nl.wms.database.vehicle.service.dao.MdBaseVehicle;
|
||||
@@ -30,7 +31,9 @@ import org.nl.wms.util.TaskUtils;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* 手持创建空料笼入库
|
||||
@@ -53,6 +56,8 @@ public class EmptyCageTask extends AbstractTask {
|
||||
private ISchBaseVehiclematerialgroupService schBaseVehiclematerialgroupService;
|
||||
@Autowired
|
||||
private IMdBaseVehicleService iMdBaseVehicleService;
|
||||
private static final HashMap<String,Integer> IS_VEHICLE = MapOf.of("vehicles",2,"vehicle_code",1);
|
||||
private static final HashMap<String,Integer> POINT_TYPE = MapOf.of("空托盘",0,"满托盘",1);
|
||||
|
||||
@Override
|
||||
protected void create() throws BadRequestException {
|
||||
@@ -60,36 +65,24 @@ public class EmptyCageTask extends AbstractTask {
|
||||
List<SchBaseTask> tasks = taskService.findTasksByTaskStatus(TASK_CONFIG_CODE, TaskStatus.APPLY);
|
||||
// 配置信息
|
||||
for (SchBaseTask task : tasks) {
|
||||
TaskUtils.setUpdateByAcs(task);
|
||||
// 查询是空料笼还是,空料架
|
||||
String vehicle_type = task.getVehicle_type();
|
||||
String vehicle_code = task.getVehicle_code();
|
||||
if (StrUtil.isNotEmpty(vehicle_code) && vehicle_code.contains(",")) {
|
||||
String[] split = vehicle_code.split(",");
|
||||
MdBaseVehicle mdBaseVehicle = iMdBaseVehicleService.selectByVehicleCode(split[0]);
|
||||
vehicle_type = mdBaseVehicle.getVehicle_type();
|
||||
}
|
||||
String vehicle_type = getVehicleType(task);
|
||||
SchBasePoint schBasePoint = null;
|
||||
switch (vehicle_type) {
|
||||
case "R01":
|
||||
//RO1空料容
|
||||
schBasePoint = schBasePointService.selectByGroundPoint(RegionEnum.DDLK.getRegion_code(),
|
||||
GoodsEnum.OUT_OF_STOCK.getValue(), VehicleTypeEnum.FRAME_R01.getVehicleCode(), 2,1);
|
||||
schBasePoint = schBasePointService.selectStackPoint(RegionEnum.DDLK.getRegion_code(),
|
||||
GoodsEnum.OUT_OF_STOCK.getValue(), VehicleTypeEnum.FRAME_R01.getVehicleCode(), IS_VEHICLE.get("vehicles"), POINT_TYPE.get("空托盘"));
|
||||
break;
|
||||
case "R02":
|
||||
//RO2空料容
|
||||
schBasePoint = schBasePointService.selectByGroundPoint(RegionEnum.DDLK.getRegion_code(),
|
||||
GoodsEnum.OUT_OF_STOCK.getValue(), VehicleTypeEnum.FRAME_R02.getVehicleCode(), 2,1);
|
||||
schBasePoint = schBasePointService.selectStackPoint(RegionEnum.DDLK.getRegion_code(),
|
||||
GoodsEnum.OUT_OF_STOCK.getValue(), VehicleTypeEnum.FRAME_R02.getVehicleCode(), IS_VEHICLE.get("vehicles"), POINT_TYPE.get("空托盘"));
|
||||
break;
|
||||
case "S04":
|
||||
//RO2空料容
|
||||
schBasePoint = schBasePointService.selectByGroundPoint(RegionEnum.DDLK.getRegion_code(),
|
||||
GoodsEnum.OUT_OF_STOCK.getValue(), VehicleTypeEnum.RACKS_S04.getVehicleCode(), 2,1);
|
||||
schBasePoint = schBasePointService.selectStackPoint(RegionEnum.DDLK.getRegion_code(),
|
||||
GoodsEnum.OUT_OF_STOCK.getValue(), VehicleTypeEnum.RACKS_S04.getVehicleCode(), IS_VEHICLE.get("vehicle_code"), POINT_TYPE.get("空托盘"));
|
||||
break;
|
||||
case "S06":
|
||||
//RO2空料容
|
||||
schBasePoint = schBasePointService.selectByGroundPoint(RegionEnum.DDLK.getRegion_code(),
|
||||
GoodsEnum.OUT_OF_STOCK.getValue(), VehicleTypeEnum.RACKS_S06.getVehicleCode(), 2,1);
|
||||
schBasePoint = schBasePointService.selectStackPoint(RegionEnum.DDLK.getRegion_code(),
|
||||
GoodsEnum.OUT_OF_STOCK.getValue(), VehicleTypeEnum.RACKS_S06.getVehicleCode(), IS_VEHICLE.get("vehicle_code"), POINT_TYPE.get("空托盘"));
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
@@ -103,25 +96,35 @@ public class EmptyCageTask extends AbstractTask {
|
||||
continue;
|
||||
}
|
||||
// 设置终点并修改创建成功状态
|
||||
TaskUtils.setUpdateByAcs(task);
|
||||
task.setPoint_code2(schBasePoint.getPoint_code());
|
||||
task.setVehicle_type(schBasePoint.getCan_vehicle_type());
|
||||
task.setVehicle_type(vehicle_type);
|
||||
task.setRemark("");
|
||||
task.setTask_status(TaskStatus.CREATED.getCode());
|
||||
taskService.updateById(task);
|
||||
|
||||
if (vehicle_type.equals(VehicleTypeEnum.FRAME_R01.getVehicleCode()) || vehicle_type.equals(VehicleTypeEnum.FRAME_R02.getVehicleCode())) {
|
||||
schBasePoint.setVehicles(task.getVehicle_code());
|
||||
} else {
|
||||
schBasePoint.setVehicle_code(task.getVehicle_code());
|
||||
}
|
||||
schBasePoint.setVehicle_qty(task.getVehicle_qty());
|
||||
schBasePoint.setPoint_status(GoodsEnum.EMPTY_PALLETS.getValue());
|
||||
schBasePoint.setIs_lock(true);
|
||||
PointUtils.setUpdateByAcs(schBasePoint);
|
||||
pointService.updateById(schBasePoint);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取托盘类型
|
||||
* @param task 任务对象
|
||||
* @return 托盘类型
|
||||
*/
|
||||
private String getVehicleType(SchBaseTask task) {
|
||||
String vehicle_type = task.getVehicle_type();
|
||||
String vehicle_code = task.getVehicle_code();
|
||||
if (StrUtil.isNotEmpty(vehicle_code)) {
|
||||
String vehicleCode = vehicle_code;
|
||||
if(vehicle_code.contains(",")){
|
||||
String[] split = vehicle_code.split(",");
|
||||
vehicleCode = split[0];
|
||||
}
|
||||
MdBaseVehicle mdBaseVehicle = iMdBaseVehicleService.selectByVehicleCode(vehicleCode);
|
||||
vehicle_type = mdBaseVehicle.getVehicle_type();
|
||||
}
|
||||
return vehicle_type;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void updateStatus(String task_code, TaskStatus status) {
|
||||
//TODO:完成任务的时候将int_task_code的清除
|
||||
@@ -141,50 +144,42 @@ public class EmptyCageTask extends AbstractTask {
|
||||
public void cancel(String task_code) {
|
||||
//TODO:取消任务的时候将int_task_code的清除
|
||||
SchBaseTask taskObj = taskService.getByCode(task_code);
|
||||
SchBasePoint schBasePoint1 = schBasePointService.selectByPointCode(taskObj.getPoint_code2());
|
||||
if (ObjectUtil.isNotEmpty(schBasePoint1)) {
|
||||
schBasePoint1.setVehicle_code(null);
|
||||
schBasePoint1.setPoint_status(GoodsEnum.OUT_OF_STOCK.getValue());
|
||||
schBasePoint1.setIs_lock(false);
|
||||
PointUtils.setUpdateByAcs(schBasePoint1);
|
||||
schBasePointService.updateById(schBasePoint1);
|
||||
}
|
||||
SchBasePoint schBasePoint = schBasePointService.selectByPointCode(taskObj.getPoint_code1());
|
||||
if (ObjectUtil.isNotEmpty(schBasePoint)) {
|
||||
schBasePoint.setVehicle_code(taskObj.getVehicle_code());
|
||||
schBasePoint.setPoint_status(GoodsEnum.EMPTY_PALLETS.getValue());
|
||||
schBasePoint.setIs_lock(false);
|
||||
PointUtils.setUpdateByAcs(schBasePoint);
|
||||
schBasePointService.updateById(schBasePoint);
|
||||
}
|
||||
cancelPoint(taskObj.getPoint_code1());
|
||||
cancelPoint(taskObj.getPoint_code2());
|
||||
if (ObjectUtil.isEmpty(taskObj)) {
|
||||
throw new BadRequestException("该任务不存在");
|
||||
}
|
||||
this.cancelTask(taskObj, TaskFinishedTypeEnum.MANUAL_CONNECTOR);
|
||||
}
|
||||
|
||||
/**
|
||||
* 取消任务还原点位状态
|
||||
*
|
||||
* @param pointCode 点位名称
|
||||
*/
|
||||
private void cancelPoint(String pointCode) {
|
||||
SchBasePoint schBasePoint = schBasePointService.selectByPointCode(pointCode);
|
||||
if (ObjectUtil.isNotEmpty(schBasePoint)) {
|
||||
schBasePoint.setIs_lock(false);
|
||||
PointUtils.setUpdateByAcs(schBasePoint);
|
||||
schBasePointService.updateById(schBasePoint);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void feedbackTaskState(JSONObject param, SchBaseTask schBaseTask, BaseResponse result) {
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* 更新任务状态
|
||||
*
|
||||
* @param taskObj
|
||||
* @param taskFinishedType
|
||||
*/
|
||||
public void finishTask(SchBaseTask taskObj, TaskFinishedTypeEnum taskFinishedType) {
|
||||
// 获取参数
|
||||
String startPoint = taskObj.getPoint_code1();
|
||||
SchBasePoint schBasePoint = pointService.selectByPointCode(startPoint);
|
||||
// 起点清空
|
||||
if (ObjectUtil.isNotEmpty(schBasePoint)) {
|
||||
PointUtils.updateByIngTaskCode(schBasePoint);
|
||||
pointService.update(Wrappers.lambdaUpdate(SchBasePoint.class).eq(SchBasePoint::getPoint_code, startPoint)
|
||||
.set(SchBasePoint::getIs_lock, false));
|
||||
}
|
||||
String point_code2 = taskObj.getPoint_code2();
|
||||
SchBasePoint schBasePoint2 = pointService.selectByPointCode(point_code2);
|
||||
if (ObjectUtil.isNotEmpty(schBasePoint2)) {
|
||||
PointUtils.updateByIngTaskCode(schBasePoint2);
|
||||
pointService.update(Wrappers.lambdaUpdate(SchBasePoint.class).eq(SchBasePoint::getPoint_code, point_code2)
|
||||
.set(SchBasePoint::getIs_lock, false));
|
||||
}
|
||||
updateStartPointStatus(taskObj);
|
||||
updateEndPointStatus(taskObj);
|
||||
// 任务完成
|
||||
taskObj.setTask_status(TaskStatus.FINISHED.getCode());
|
||||
taskObj.setRemark(GeneralDefinition.TASK_FINISH);
|
||||
@@ -193,24 +188,46 @@ public class EmptyCageTask extends AbstractTask {
|
||||
taskService.updateById(taskObj);
|
||||
}
|
||||
|
||||
public void cancelTask(SchBaseTask taskObj, TaskFinishedTypeEnum taskFinishedType) {
|
||||
// 获取参数
|
||||
/**
|
||||
* 更新起点点位状态
|
||||
*
|
||||
* @param taskObj 任务对象
|
||||
*/
|
||||
private void updateStartPointStatus(SchBaseTask taskObj) {
|
||||
String startPoint = taskObj.getPoint_code1();
|
||||
SchBasePoint schBasePoint = pointService.selectByPointCode(startPoint);
|
||||
// 起点清空
|
||||
if (ObjectUtil.isNotEmpty(schBasePoint)) {
|
||||
PointUtils.updateByIngTaskCode(schBasePoint);
|
||||
pointService.update(Wrappers.lambdaUpdate(SchBasePoint.class).eq(SchBasePoint::getPoint_code, startPoint)
|
||||
pointService.update(Wrappers.lambdaUpdate(SchBasePoint.class)
|
||||
.eq(SchBasePoint::getPoint_code, startPoint)
|
||||
.set(SchBasePoint::getIs_lock, false));
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 更新终点点位状态
|
||||
*
|
||||
* @param taskObj 任务对象
|
||||
*/
|
||||
private void updateEndPointStatus(SchBaseTask taskObj) {
|
||||
String point_code2 = taskObj.getPoint_code2();
|
||||
SchBasePoint schBasePoint2 = pointService.selectByPointCode(point_code2);
|
||||
if (ObjectUtil.isNotEmpty(schBasePoint2)) {
|
||||
PointUtils.updateByIngTaskCode(schBasePoint2);
|
||||
pointService.update(Wrappers.lambdaUpdate(SchBasePoint.class).eq(SchBasePoint::getPoint_code, point_code2)
|
||||
.set(SchBasePoint::getIs_lock, false));
|
||||
String vehicle_type = taskObj.getVehicle_type();
|
||||
if (vehicle_type.equals(VehicleTypeEnum.FRAME_R01.getVehicleCode()) || vehicle_type.equals(VehicleTypeEnum.FRAME_R02.getVehicleCode())) {
|
||||
schBasePoint2.setVehicles(taskObj.getVehicle_code());
|
||||
schBasePoint2.setVehicle_qty(taskObj.getVehicle_qty());
|
||||
} else {
|
||||
schBasePoint2.setVehicle_code(taskObj.getVehicle_code());
|
||||
}
|
||||
schBasePoint2.setPoint_status(GoodsEnum.EMPTY_PALLETS.getValue());
|
||||
schBasePoint2.setIs_lock(false);
|
||||
PointUtils.setUpdateByAcs(schBasePoint2);
|
||||
pointService.updateById(schBasePoint2);
|
||||
}
|
||||
}
|
||||
|
||||
public void cancelTask(SchBaseTask taskObj, TaskFinishedTypeEnum taskFinishedType) {
|
||||
taskObj.setRemark(GeneralDefinition.TASK_CANCEL);
|
||||
taskObj.setTask_status(TaskStatus.CANCELED.getCode());
|
||||
taskObj.setFinished_type(taskFinishedType.getCode());
|
||||
|
||||
@@ -135,7 +135,7 @@ public class PcOperationSMTTask extends AbstractTask {
|
||||
updatePointStatus(schBasePoint, null, GoodsEnum.OUT_OF_STOCK.getValue());
|
||||
String endPoint = taskObj.getPoint_code2();
|
||||
SchBasePoint schBasePoint2 = pointService.selectByPointCode(endPoint);
|
||||
updatePointStatus(schBasePoint, taskObj.getVehicle_code(), GoodsEnum.IN_STOCK.getValue());
|
||||
updatePointStatus(schBasePoint2, taskObj.getVehicle_code(), GoodsEnum.IN_STOCK.getValue());
|
||||
SendMaterVo sendMaterVo = JSONObject.parseObject(taskObj.getRequest_param(),SendMaterVo.class);
|
||||
List<SendMaterVo> sendMaterVos = new ArrayList<>();
|
||||
sendMaterVo.getMaterial_info().forEach(materVo -> {
|
||||
|
||||
@@ -90,7 +90,6 @@ public class ProcessingSMTTask extends AbstractTask {
|
||||
List<SchBaseTask> tasks = taskService.findTasksByTaskStatus(TASK_CONFIG_CODE, TaskStatus.APPLY);
|
||||
|
||||
for (SchBaseTask task : tasks) {
|
||||
|
||||
SendMaterVo sendMaterVo = JSONObject.parseObject(task.getRequest_param(), SendMaterVo.class);
|
||||
//判断是否指定到外协区
|
||||
String targetRegionCode = sendMaterVo.getRegion_code();
|
||||
@@ -158,8 +157,11 @@ public class ProcessingSMTTask extends AbstractTask {
|
||||
|
||||
/**
|
||||
* 完成任务
|
||||
*
|
||||
* @param taskObj
|
||||
* @param taskFinishedType
|
||||
*/
|
||||
@Transactional
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public void finishTask(SchBaseTask taskObj, TaskFinishedTypeEnum taskFinishedType) {
|
||||
log.info("开始完成任务:{},", taskObj.getTask_code());
|
||||
updateStartPointStatus(taskObj);
|
||||
@@ -170,27 +172,57 @@ public class ProcessingSMTTask extends AbstractTask {
|
||||
if (CollUtil.isEmpty(materials)) {
|
||||
materials = jsonObject2.getJSONArray("mater");
|
||||
}
|
||||
List<SendVehicleVo> sendVehicleVos = BeanUtil.copyToList(materials, SendVehicleVo.class);
|
||||
sendVehicleVos.forEach(sendVehicleVo -> {
|
||||
String dueDate = schBaseVehiclematerialgroupService.selectDueDateByVehicleCode(sendVehicleVo);
|
||||
sendVehicleVo.setDue_date(dueDate);
|
||||
});
|
||||
if (region_code.equals(RegionEnum.NBJG.getRegion_code())) {
|
||||
JSONObject jsonObject3 = new JSONObject();
|
||||
jsonObject3.put("vehicle_code", taskObj.getVehicle_code());
|
||||
jsonObject3.put("id", taskObj.getTask_code());
|
||||
JSONArray jsonArray = new JSONArray();
|
||||
if (CollUtil.isNotEmpty(materials)) {
|
||||
List<SendVehicleVo> sendVehicleVos = BeanUtil.copyToList(materials, SendVehicleVo.class);
|
||||
sendVehicleVos.forEach(sendVehicleVo -> {
|
||||
JSONObject jsonObject4 = new JSONObject();
|
||||
jsonObject4.put("product_id", sendVehicleVo.getMaterial_code());
|
||||
jsonObject4.put("current_qty", sendVehicleVo.getMaterial_qty());
|
||||
jsonObject4.put("production_order", sendVehicleVo.getOrder_code());
|
||||
jsonObject4.put("due_date", sendVehicleVo.getDue_date());
|
||||
jsonArray.add(jsonObject4);
|
||||
String dueDate = schBaseVehiclematerialgroupService.selectDueDateByVehicleCode(sendVehicleVo);
|
||||
sendVehicleVo.setDue_date(dueDate);
|
||||
});
|
||||
jsonObject3.put("materials", jsonArray);
|
||||
lmsToWmsService.feedbackMaterialStatus(jsonObject3);
|
||||
} else if (region_code.equals(RegionEnum.WXJG.getRegion_code())) {
|
||||
if (region_code.equals(RegionEnum.NBJG.getRegion_code())) {
|
||||
interiorTemplate(taskObj, sendVehicleVos);
|
||||
} else if (region_code.equals(RegionEnum.WXJG.getRegion_code())) {
|
||||
outsourcingTemplate(taskObj, sendVehicleVos);
|
||||
}
|
||||
updateVehicleData(taskObj, sendVehicleVos);
|
||||
}
|
||||
// 任务完成
|
||||
taskObj.setTask_status(TaskStatus.FINISHED.getCode());
|
||||
taskObj.setRemark(GeneralDefinition.TASK_FINISH);
|
||||
taskObj.setFinished_type(taskFinishedType.getCode());
|
||||
TaskUtils.setUpdateByType(taskObj, taskFinishedType);
|
||||
taskService.updateById(taskObj);
|
||||
}
|
||||
|
||||
/**
|
||||
* 更新托盘数据
|
||||
*
|
||||
* @param taskObj
|
||||
* @param sendVehicleVos
|
||||
*/
|
||||
private void updateVehicleData(SchBaseTask taskObj, List<SendVehicleVo> sendVehicleVos) {
|
||||
schBaseVehiclematerialgroupService.remove(new QueryWrapper<SchBaseVehiclematerialgroup>().eq("vehicle_code", taskObj.getVehicle_code()));
|
||||
sendVehicleVos.forEach(sendVehicleVo -> {
|
||||
SchBaseVehiclematerialgroup schBaseVehiclematerialgroup = new SchBaseVehiclematerialgroup();
|
||||
schBaseVehiclematerialgroup.setVehicle_code(taskObj.getVehicle_code());
|
||||
schBaseVehiclematerialgroup.setMaterial_qty(sendVehicleVo.getMaterial_qty());
|
||||
schBaseVehiclematerialgroup.setMaterial_id(sendVehicleVo.getMaterial_code());
|
||||
schBaseVehiclematerialgroup.setOrder_code(sendVehicleVo.getOrder_code());
|
||||
schBaseVehiclematerialgroup.setDue_date(sendVehicleVo.getDue_date());
|
||||
schBaseVehiclematerialgroup.setCreate_name(SecurityUtils.getCurrentNickName());
|
||||
schBaseVehiclematerialgroupService.create(schBaseVehiclematerialgroup);
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* 外协数据打印
|
||||
*
|
||||
* @param taskObj
|
||||
* @param sendVehicleVos
|
||||
*/
|
||||
private void outsourcingTemplate(SchBaseTask taskObj, List<SendVehicleVo> sendVehicleVos) {
|
||||
Param isPrint = sysParamService.findByCode(GeneralDefinition.IS_PRINT);
|
||||
if (ObjectUtil.isNotEmpty(isPrint) && "1".equals(isPrint.getValue())) {
|
||||
} else {
|
||||
Param byCode = sysParamService.findByCode(GeneralDefinition.TEMPLATE_URL);
|
||||
Param filePath = sysParamService.findByCode(GeneralDefinition.FILE_URL);
|
||||
Param printerName = sysParamService.findByCode(GeneralDefinition.PRINTER_NAME);
|
||||
@@ -212,23 +244,29 @@ public class ProcessingSMTTask extends AbstractTask {
|
||||
json.put("data", jsonArray);
|
||||
PrintUtil.printWord(byCode.getValue(), json, filePath.getValue(), printerName.getValue());
|
||||
}
|
||||
schBaseVehiclematerialgroupService.remove(new QueryWrapper<SchBaseVehiclematerialgroup>().eq("vehicle_code", taskObj.getVehicle_code()));
|
||||
}
|
||||
|
||||
/**
|
||||
* 内部数据反馈
|
||||
*
|
||||
* @param taskObj
|
||||
* @param sendVehicleVos
|
||||
*/
|
||||
private void interiorTemplate(SchBaseTask taskObj, List<SendVehicleVo> sendVehicleVos) {
|
||||
JSONObject jsonObject3 = new JSONObject();
|
||||
jsonObject3.put("vehicle_code", taskObj.getVehicle_code());
|
||||
jsonObject3.put("id", taskObj.getTask_code());
|
||||
JSONArray jsonArray = new JSONArray();
|
||||
sendVehicleVos.forEach(sendVehicleVo -> {
|
||||
SchBaseVehiclematerialgroup schBaseVehiclematerialgroup = new SchBaseVehiclematerialgroup();
|
||||
schBaseVehiclematerialgroup.setVehicle_code(taskObj.getVehicle_code());
|
||||
schBaseVehiclematerialgroup.setMaterial_qty(sendVehicleVo.getMaterial_qty());
|
||||
schBaseVehiclematerialgroup.setMaterial_id(sendVehicleVo.getMaterial_code());
|
||||
schBaseVehiclematerialgroup.setOrder_code(sendVehicleVo.getOrder_code());
|
||||
schBaseVehiclematerialgroup.setDue_date(sendVehicleVo.getDue_date());
|
||||
schBaseVehiclematerialgroup.setCreate_name(SecurityUtils.getCurrentNickName());
|
||||
schBaseVehiclematerialgroupService.create(schBaseVehiclematerialgroup);
|
||||
JSONObject jsonObject4 = new JSONObject();
|
||||
jsonObject4.put("product_id", sendVehicleVo.getMaterial_code());
|
||||
jsonObject4.put("current_qty", sendVehicleVo.getMaterial_qty());
|
||||
jsonObject4.put("production_order", sendVehicleVo.getOrder_code());
|
||||
jsonObject4.put("due_date", sendVehicleVo.getDue_date());
|
||||
jsonArray.add(jsonObject4);
|
||||
});
|
||||
// 任务完成
|
||||
taskObj.setTask_status(TaskStatus.FINISHED.getCode());
|
||||
taskObj.setRemark(GeneralDefinition.TASK_FINISH);
|
||||
taskObj.setFinished_type(taskFinishedType.getCode());
|
||||
TaskUtils.setUpdateByType(taskObj, taskFinishedType);
|
||||
taskService.updateById(taskObj);
|
||||
jsonObject3.put("materials", jsonArray);
|
||||
lmsToWmsService.feedbackMaterialStatus(jsonObject3);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -254,9 +292,9 @@ public class ProcessingSMTTask extends AbstractTask {
|
||||
.set(SchBasePoint::getPoint_status, pointStatus)
|
||||
.set(SchBasePoint::getIs_lock, false));
|
||||
}
|
||||
}catch (Exception e){
|
||||
log.error("修改终点点位状态失败",e);
|
||||
throw new BadRequestException("修改" + taskObj.getPoint_code2()+ "终点点位状态失败:" + e.getMessage() + "任务号:" + taskObj.getTask_code());
|
||||
} catch (Exception e) {
|
||||
log.error("修改终点点位状态失败", e);
|
||||
throw new BadRequestException("修改" + taskObj.getPoint_code2() + "终点点位状态失败:" + e.getMessage() + "任务号:" + taskObj.getTask_code());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -274,9 +312,9 @@ public class ProcessingSMTTask extends AbstractTask {
|
||||
.set(SchBasePoint::getPoint_status, GoodsEnum.OUT_OF_STOCK.getValue())
|
||||
.set(SchBasePoint::getIs_lock, false));
|
||||
}
|
||||
}catch (Exception e){
|
||||
log.error("修改起点点位状态失败",e);
|
||||
throw new BadRequestException("修改" + taskObj.getPoint_code1()+ "起点点位状态失败:" + e.getMessage() + "任务号:" + taskObj.getTask_code());
|
||||
} catch (Exception e) {
|
||||
log.error("修改起点点位状态失败", e);
|
||||
throw new BadRequestException("修改" + taskObj.getPoint_code1() + "起点点位状态失败:" + e.getMessage() + "任务号:" + taskObj.getTask_code());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -31,6 +31,7 @@ import org.springframework.web.multipart.MultipartFile;
|
||||
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import java.io.InputStream;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
@@ -184,16 +185,16 @@ public class BmVehicleInfoServiceImpl extends ServiceImpl<BmVehicleInfoMapper, B
|
||||
// 从第二行开始获取数据 excelReader.read的结果是一个2纬的list,外层是行,内层是行对应的所有列
|
||||
List<List<Object>> read = excelReader.read(1, excelReader.getRowCount());
|
||||
// 循环获取的数据
|
||||
List<BmVehicleInfo> bmVehicleInfos = new ArrayList<>();
|
||||
for (int i = 0; i < read.size(); i++) {
|
||||
List list = read.get(i);
|
||||
JSONObject param = new JSONObject();
|
||||
String vehicleCode = list.get(0).toString();
|
||||
String vehicleType = list.get(1).toString();
|
||||
if (StrUtil.isEmpty(vehicleCode) || StrUtil.isEmpty(vehicleType)) {
|
||||
throw new BadRequestException("载具号或载具类型为空!");
|
||||
}
|
||||
BmVehicleInfo one = getOne(Wrappers.lambdaQuery(BmVehicleInfo.class).eq(BmVehicleInfo::getVehicle_code, vehicleCode));
|
||||
if(ObjectUtil.isNotEmpty(one)){
|
||||
if (ObjectUtil.isNotEmpty(one)) {
|
||||
continue;
|
||||
}
|
||||
Dict dict = dictService.getOne(new QueryWrapper<Dict>().eq("code", "can_vehicle_type").eq("value", vehicleType));
|
||||
@@ -206,8 +207,9 @@ public class BmVehicleInfoServiceImpl extends ServiceImpl<BmVehicleInfoMapper, B
|
||||
entity.setUpdate_name(SecurityUtils.getCurrentNickName());
|
||||
entity.setUpdate_time(DateUtil.now());
|
||||
entity.setVehicle_type(dict.getValue());
|
||||
this.save(entity);
|
||||
bmVehicleInfos.add(entity);
|
||||
}
|
||||
this.saveBatch(bmVehicleInfos);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
Reference in New Issue
Block a user