|
|
@ -9,6 +9,7 @@ import com.alibaba.fastjson.JSON; |
|
|
|
import com.alibaba.fastjson.JSONArray; |
|
|
|
import com.alibaba.fastjson.JSONObject; |
|
|
|
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; |
|
|
|
import com.baomidou.mybatisplus.core.toolkit.Wrappers; |
|
|
|
import io.swagger.annotations.Api; |
|
|
|
import lombok.extern.slf4j.Slf4j; |
|
|
|
import org.nl.common.base.TableDataInfo; |
|
|
@ -20,6 +21,7 @@ import org.nl.wms.ext.connector.service.WmsToConnectorService; |
|
|
|
import org.nl.wms.ext.fab.service.dto.*; |
|
|
|
import org.nl.wms.ext.fab.service.impl.FabServiceImpl; |
|
|
|
import org.nl.wms.sch.group.service.ISchBaseVehiclematerialgroupService; |
|
|
|
import org.nl.wms.sch.group.service.dao.SchBaseVehiclematerialgroup; |
|
|
|
import org.nl.wms.sch.point.service.ISchBasePointService; |
|
|
|
import org.nl.wms.sch.point.service.dao.SchBasePoint; |
|
|
|
import org.nl.wms.sch.region.service.ISchBaseRegionService; |
|
|
@ -93,8 +95,8 @@ public class FabController { |
|
|
|
*/ |
|
|
|
@Log("根据工序查询工单") |
|
|
|
@GetMapping("/regionOrder") |
|
|
|
public ResponseEntity<TableDataInfo<OrderMater>> regionOrder(String regionCode) { |
|
|
|
List<OrderMater> structList = iSchBasePointService.getStructList(regionCode, null); |
|
|
|
public ResponseEntity<TableDataInfo<OrderMater>> regionOrder(String deviceCode) { |
|
|
|
List<OrderMater> structList = iSchBasePointService.getStructList(deviceCode, null); |
|
|
|
return new ResponseEntity(TableDataInfo.build(structList), HttpStatus.OK); |
|
|
|
} |
|
|
|
|
|
|
@ -148,7 +150,7 @@ public class FabController { |
|
|
|
@PostMapping("/sendVehicle") |
|
|
|
public ResponseEntity<TableDataInfo> sendVehicle(@RequestBody SendVehiclesVo sendVehiclesVo) { |
|
|
|
JSONObject toJSON = (JSONObject) JSON.toJSON(sendVehiclesVo); |
|
|
|
List<SendVehicleVo> sendVehicleVoList = sendVehiclesVo.getSendVehicleVoList(); |
|
|
|
List<SendVehicleVo> sendVehicleVoList = sendVehiclesVo.getMater(); |
|
|
|
if (CollUtil.isEmpty(sendVehicleVoList)) throw new BadRequestException("物料信息为空,请确认!"); |
|
|
|
AtomicReference<Boolean> flag = new AtomicReference<>(false); |
|
|
|
sendVehicleVoList.stream().forEach(sendVehicleVo1 -> { |
|
|
@ -156,6 +158,7 @@ public class FabController { |
|
|
|
flag.set(true); |
|
|
|
} |
|
|
|
}); |
|
|
|
sendVehicleVoList.removeIf(sendVehicleVo1 -> (ObjectUtil.isEmpty(sendVehicleVo1) || sendVehicleVo1.getMaterial_qty() == 0)); |
|
|
|
if (!flag.get()) { |
|
|
|
fabService.createAgvTask(toJSON, "snt"); |
|
|
|
} else { |
|
|
@ -163,8 +166,12 @@ public class FabController { |
|
|
|
toJSON.put("vehicle_code", schBasePoint.getVehicle_code()); |
|
|
|
List<String> materiales = new ArrayList<>(); |
|
|
|
sendVehicleVoList.stream().forEach(send -> { |
|
|
|
SchBaseVehiclematerialgroup one = iSchBaseVehiclematerialgroupService.getOne(Wrappers.lambdaQuery(SchBaseVehiclematerialgroup.class) |
|
|
|
.eq(SchBaseVehiclematerialgroup::getOrder_code, send.getOrder_code())); |
|
|
|
send.setDue_date(one.getDue_date()); |
|
|
|
materiales.add(JSONObject.toJSONString(send)); |
|
|
|
}); |
|
|
|
toJSON.put("region_code", schBasePoint.getRegion_code()); |
|
|
|
toJSON.put("material_info", materiales); |
|
|
|
//TODO:修改物料信息
|
|
|
|
fabService.createAgvTask(toJSON, "smt"); |
|
|
@ -196,41 +203,52 @@ public class FabController { |
|
|
|
@Log("工序下料") |
|
|
|
@PostMapping("/sendMater") |
|
|
|
public ResponseEntity<TableDataInfo> sendMater(@RequestBody SendMaterVo materInfo) { |
|
|
|
JSONObject toJSON = (JSONObject) JSON.toJSON(materInfo); |
|
|
|
//TODO:待确定
|
|
|
|
List<String> material_info = materInfo.getMaterial_info(); |
|
|
|
if (CollUtil.isEmpty(material_info)) throw new BadRequestException("物料信息为空,请确认!"); |
|
|
|
JSONObject json = new JSONObject(); |
|
|
|
JSONArray jsonArray = new JSONArray(); |
|
|
|
HashMap<String, Object> map = new HashMap<>(); |
|
|
|
material_info.stream().forEach(material -> { |
|
|
|
JSONObject jsonObject = JSONObject.parseObject(material); |
|
|
|
map.put("order_code", jsonObject.getString("order_code")); |
|
|
|
map.put("qty", jsonObject.getString("material_qty")); |
|
|
|
jsonArray.add(map); |
|
|
|
}); |
|
|
|
json.put("vehicle_code", materInfo.getVehicle_code()); |
|
|
|
json.put("region_code", materInfo.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)); |
|
|
|
material_info.stream().forEach(material1 -> { |
|
|
|
JSONObject jsonObject2 = JSONObject.parseObject(StrUtil.toString(material1)); |
|
|
|
if (jsonObject2.getString("order_code").equals(jsonObject1.getString("order_code"))) { |
|
|
|
jsonObject2.put("due_date", jsonObject1.getString("due_date")); |
|
|
|
jsonObject2.put("region_code", jsonObject1.getString("next_region_code")); |
|
|
|
} |
|
|
|
if (StrUtil.isNotEmpty(materInfo.getRegion_code())) { |
|
|
|
JSONObject toJSON = (JSONObject) JSON.toJSON(materInfo); |
|
|
|
fabService.createAgvTask(toJSON, "smt"); |
|
|
|
return new ResponseEntity(TableDataInfo.build(), HttpStatus.OK); |
|
|
|
} else { |
|
|
|
JSONObject toJSON = (JSONObject) JSON.toJSON(materInfo); |
|
|
|
//TODO:待确定
|
|
|
|
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")); |
|
|
|
} |
|
|
|
}); |
|
|
|
}); |
|
|
|
} else if (ObjectUtil.isNotEmpty(jsonObject) && jsonObject.getInteger("status") == 400) { |
|
|
|
throw new BadRequestException(jsonObject.getString("msg")); |
|
|
|
} |
|
|
|
List<String> materiales = new ArrayList<>(); |
|
|
|
mater.stream().forEach(material -> { |
|
|
|
materiales.add(JSONObject.toJSONString(material)); |
|
|
|
}); |
|
|
|
} else if (ObjectUtil.isNotEmpty(jsonObject) && jsonObject.getInteger("status") == 400) { |
|
|
|
throw new BadRequestException(jsonObject.getString("msg")); |
|
|
|
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()); |
|
|
|
fabService.createAgvTask(toJSON, "smt"); |
|
|
|
return new ResponseEntity(TableDataInfo.build(), HttpStatus.OK); |
|
|
|
} |
|
|
|
toJSON.put("region_code", JSONObject.parseObject(material_info.get(0)).getString("region_code")); |
|
|
|
fabService.createAgvTask(toJSON, "smt"); |
|
|
|
return new ResponseEntity(TableDataInfo.build(), HttpStatus.OK); |
|
|
|
} |
|
|
|
|
|
|
|
//TODO: 根据物料查主盘信息; 当前工序查所有物料 ->
|
|
|
@ -263,7 +281,13 @@ public class FabController { |
|
|
|
list.stream().forEach(item -> { |
|
|
|
keys.add(item); |
|
|
|
}); |
|
|
|
return new ResponseEntity(keys, HttpStatus.OK); |
|
|
|
List<JSONObject> jsonObjectList = new ArrayList<>(); |
|
|
|
list.stream().forEach(item -> { |
|
|
|
JSONObject jsonObject = new JSONObject(); |
|
|
|
jsonObject.put("order_code", item); |
|
|
|
jsonObjectList.add(jsonObject); |
|
|
|
}); |
|
|
|
return new ResponseEntity(jsonObjectList, HttpStatus.OK); |
|
|
|
} |
|
|
|
|
|
|
|
/** |
|
|
|