代码更新

This commit is contained in:
2022-08-16 19:55:37 +08:00
parent ace8399af0
commit de937332ad
35 changed files with 1322 additions and 1578 deletions

View File

@@ -0,0 +1,39 @@
package org.nl.wms.ext.acs.rest;
import com.alibaba.fastjson.JSONObject;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.nl.annotation.Log;
import org.nl.wms.ext.acs.service.AcsToLmsService;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
@RestController
@RequiredArgsConstructor
@Api(tags = "acs接收wms")
@RequestMapping("/api/acsToLms/task")
@Slf4j
public class AcsToLmsController {
private final AcsToLmsService acsToLmsService;
@PostMapping("/taskResult")
@Log("任务反馈")
@ApiOperation("任务反馈")
public ResponseEntity<Object> taskResult(@RequestBody JSONObject whereJson) {
return new ResponseEntity<>(acsToLmsService.taskResult(whereJson), HttpStatus.OK);
}
@PostMapping("/apply")
@Log("申请任务")
@ApiOperation("申请任务")
public ResponseEntity<Object> apply(@RequestBody JSONObject whereJson) {
return new ResponseEntity<>(acsToLmsService.apply(whereJson), HttpStatus.OK);
}
}

View File

@@ -0,0 +1,26 @@
package org.nl.wms.ext.acs.service;
import com.alibaba.fastjson.JSONObject;
import java.util.Map;
public interface AcsToLmsService {
/**
* ACS客户端--->LMS服务端
* 任务反馈
*
* @param whereJson 条件
* @return JSONObject
*/
JSONObject taskResult(JSONObject whereJson);
/**
* ACS客户端--->LMS服务端
* 任务申请
*
* @param whereJson 条件
* @return JSONObject
*/
JSONObject apply(JSONObject whereJson);
}

View File

@@ -0,0 +1,341 @@
package org.nl.wms.ext.acs.service.impl;
import cn.hutool.core.date.DateUtil;
import cn.hutool.core.util.IdUtil;
import cn.hutool.core.util.ObjectUtil;
import cn.hutool.core.util.StrUtil;
import com.alibaba.fastjson.JSONObject;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.apache.catalina.security.SecurityUtil;
import org.nl.exception.BadRequestException;
import org.nl.modules.system.util.CodeUtil;
import org.nl.utils.SecurityUtils;
import org.nl.utils.SpringContextHolder;
import org.nl.wms.ext.acs.service.AcsToLmsService;
import org.nl.wms.pdm.service.DeviceService;
import org.nl.wms.pdm.service.dto.DeviceDto;
import org.nl.wms.sch.service.PointService;
import org.nl.wms.sch.tasks.CallEmpVehicleTask;
import org.nl.wms.sch.tasks.CallMaterialTask;
import org.nl.wms.sch.tasks.SendEmpVehicleTask;
import org.nl.wms.sch.tasks.SendMaterialTask;
import org.nl.wql.WQL;
import org.nl.wql.core.bean.WQLObject;
import org.nl.wql.core.engine.object.WO;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
@Service
@RequiredArgsConstructor
@Slf4j
public class AcsToLmsServiceImpl implements AcsToLmsService {
@Override
public JSONObject taskResult(JSONObject whereJson) {
return null;
}
@Override
@Transactional
public JSONObject apply(JSONObject whereJson) {
String type = whereJson.getString("type");
String point_code = whereJson.getString("point_code");
String vehicle_num = whereJson.getString("vehicle_num");
String vehicle_type = whereJson.getString("vehicle_type");
String vehicle_code = whereJson.getString("vehicle_code");
String qty = whereJson.getString("qty");
if (ObjectUtil.isEmpty(type)) throw new BadRequestException("类型不能为空");
if (ObjectUtil.isEmpty(point_code)) throw new BadRequestException("点位不能为空");
WQLObject empTab = WQLObject.getWQLObject("st_ivt_EmptyVehicleRecord");// 空载具作业记录表
WQLObject taskTab = WQLObject.getWQLObject("sch_base_task");// 空载具作业记录表
WQLObject regionTab = WQLObject.getWQLObject("ST_IVT_regionIO"); // 区域出入库表
/*
* 根据type判断是什么业务类型
* 1.共挤线申请空盘
* 2.共挤线满托入库
* 3.油漆线申请空盘
* 4.油漆线申请物料
* 5.油漆线空盘入库
* 6.一楼空盘入库 (有载具号)
*/
JSONObject resuft = new JSONObject();
try {
if (StrUtil.equals(type, "1")) {
// 1.共挤线申请空盘: 调用空托盘出库处理类创建任务
if (ObjectUtil.isEmpty(vehicle_num)) throw new BadRequestException("数量不能为空");
JSONObject param = new JSONObject();
param.put("next_point_code", point_code);
param.put("qty", vehicle_num);
// 创建任务
String task_id = SpringContextHolder.getBean(CallEmpVehicleTask.class).createTask(param);
// 插入空载具作业记录表
JSONObject jsonEmpParam = new JSONObject();
jsonEmpParam.put("vehicle_qty",vehicle_num);
jsonEmpParam.put("task_id",task_id);
jsonEmpParam.put("io_type","1");
this.createEmp(jsonEmpParam);
//TODO 下发
// 成功返回
resuft.put("status", "200");
resuft.put("message", "");
} else if (StrUtil.equals(type, "2")) {
// 2.共挤线满托入库: 调用物料入库处理类创建任务
if (ObjectUtil.isEmpty(qty)) throw new BadRequestException("物料数量不能为空");
JSONObject param = new JSONObject();
param.put("start_point_code", point_code);
String task_id = SpringContextHolder.getBean(SendMaterialTask.class).createTask(param);
JSONObject jsonTask = taskTab.query("task_id = '" + task_id + "'").uniqueResult(0);
// 插入区域出入库表
param.put("next_point_code", jsonTask.getString("next_point_code"));
param.put("qty", qty);
param.put("task_id", task_id);
param.put("io_type", "0");
JSONObject json = this.inCreateRegion(param);
// 回显任务载具类型
jsonTask.put("vehicle_type", json.getString("vehicle_type"));
taskTab.update(jsonTask);
//TODO 下发
// 返回成功
resuft.put("status", "200");
resuft.put("message", "");
} else if (StrUtil.equals(type, "3")) {
// 3.油漆线申请空盘: 调用空托盘出库处理类创建任务
if (ObjectUtil.isEmpty(vehicle_num)) throw new BadRequestException("数量不能为空");
JSONObject param = new JSONObject();
param.put("next_point_code", point_code);
param.put("qty", vehicle_num);
// 创建任务
String task_id = SpringContextHolder.getBean(CallEmpVehicleTask.class).createTask(param);
// 插入空载具作业记录表
JSONObject jsonEmpParam = new JSONObject();
jsonEmpParam.put("vehicle_qty",vehicle_num);
jsonEmpParam.put("task_id",task_id);
jsonEmpParam.put("io_type","1");
this.createEmp(jsonEmpParam);
//TODO 下发
// 成功返回
resuft.put("status", "200");
resuft.put("message", "");
} else if (StrUtil.equals(type, "4")) {
// 4.油漆线申请物料: 调用物料出库库处理类创建任务
JSONObject param = new JSONObject();
param.put("next_point_code",point_code);
param.put("io_type","1");
// 插入区域出库单
JSONObject json = this.outCreateRegion(param);
param.put("vehicle_type", json.getString("vehicle_type"));
param.put("material_id", json.getString("material_id"));
param.put("create_mode", json.getString("create_mode"));
param.put("iostorinv_id", json.getString("iostorinv_id"));
// 创建任务
String task_id = SpringContextHolder.getBean(CallMaterialTask.class).createTask(param);
JSONObject jsonTask = taskTab.query("task_id = '" + task_id + "'").uniqueResult(0);
// 回显出库单起始点位、起始区域、任务id
JSONObject jsonRegion = regionTab.query("iostorinv_id = '" + json.getString("iostorinv_id") + "'").uniqueResult(0);
jsonRegion.put("start_point_code", jsonTask.getString("start_point_code"));
Long start_region_id = SpringContextHolder.getBean(PointService.class).findByCode(jsonTask.getString("start_point_code")).getRegion_id();
jsonRegion.put("start_region_id", String.valueOf(start_region_id));
jsonRegion.put("task_id", Long.valueOf(task_id));
regionTab.update(jsonRegion);
//TODO 下发
// 成功返回
resuft.put("status", "200");
resuft.put("message", "");
} else if (StrUtil.equals(type, "5")) {
// 5.油漆线空盘入库: 调用空托盘入库处理类创建任务
if (ObjectUtil.isEmpty(vehicle_num)) throw new BadRequestException("数量不能为空");
JSONObject param = new JSONObject();
param.put("start_point_code", point_code);
param.put("qty", vehicle_num);
// 创建任务
String task_id = SpringContextHolder.getBean(SendEmpVehicleTask.class).createTask(param);
// 插入空载具作业记录表
JSONObject jsonEmpParam = new JSONObject();
jsonEmpParam.put("vehicle_qty",vehicle_num);
jsonEmpParam.put("task_id",task_id);
jsonEmpParam.put("io_type","0");
this.createEmp(jsonEmpParam);
//TODO 下发
// 成功返回
resuft.put("status", "200");
resuft.put("message", "");
} else if (StrUtil.equals(type, "6")) {
// 6.一楼空盘入库 (有载具号): 调用空托盘入库处理类创建任务
if (ObjectUtil.isEmpty(vehicle_num)) throw new BadRequestException("数量不能为空");
if (ObjectUtil.isEmpty(vehicle_code)) throw new BadRequestException("载具号不能为空");
JSONObject param = new JSONObject();
param.put("start_point_code", point_code);
param.put("qty", vehicle_num);
param.put("vehicle_code", vehicle_code);
// 创建任务
String task_id = SpringContextHolder.getBean(SendEmpVehicleTask.class).createTask(param);
// 插入空载具作业记录表
JSONObject jsonEmpParam = new JSONObject();
jsonEmpParam.put("vehicle_qty",vehicle_num);
jsonEmpParam.put("task_id",task_id);
jsonEmpParam.put("io_type","0");
this.createEmp(jsonEmpParam);
//TODO 下发
// 成功返回
resuft.put("status", "200");
resuft.put("message", "");
}
} catch (Exception e) {
resuft.put("status",((BadRequestException) e).getStatus());
resuft.put("message",e.getMessage());
}
return resuft;
}
@Transactional
public void createEmp(JSONObject json) {
String vehicle_qty = json.getString("vehicle_qty");
String task_id = json.getString("task_id");
String io_type = json.getString("io_type");
WQLObject empTab = WQLObject.getWQLObject("st_ivt_EmptyVehicleRecord");// 空载具作业记录表
WQLObject taskTab = WQLObject.getWQLObject("sch_base_task");// 空载具作业记录表
JSONObject jsonTask = taskTab.query("task_id = '" + task_id + "'").uniqueResult(0);
JSONObject jsonEmp = new JSONObject();
jsonEmp.put("record_uuid", IdUtil.getSnowflake(1,1).nextId());
jsonEmp.put("bill_code", CodeUtil.getNewCode("KZJ_BILL_CODE"));
jsonEmp.put("io_type", io_type);
jsonEmp.put("bill_status", "20");
jsonEmp.put("vehicle_qty", vehicle_qty);
jsonEmp.put("start_point_code", jsonTask.getString("start_point_code"));
Long start_region_id = SpringContextHolder.getBean(PointService.class).findByCode(jsonTask.getString("start_point_code")).getRegion_id();
jsonEmp.put("start_region_id", start_region_id);
jsonEmp.put("next_point_code", jsonTask.getString("next_point_code"));
Long next_region_id = SpringContextHolder.getBean(PointService.class).findByCode(jsonTask.getString("next_point_code")).getRegion_id();
jsonEmp.put("end_region_id", next_region_id);
jsonEmp.put("task_uuid", task_id);
jsonEmp.put("create_id", SecurityUtils.getCurrentUserId());
jsonEmp.put("create_name", SecurityUtils.getNickName());
jsonEmp.put("create_time", DateUtil.now());
empTab.insert(jsonEmp);
}
@Transactional
public JSONObject inCreateRegion(JSONObject json) {
String start_point_code = json.getString("start_point_code");
String next_point_code = json.getString("next_point_code");
String qty = json.getString("qty");
Long task_id = json.getLongValue("task_id");
String io_type = json.getString("io_type");
WQLObject regionTab = WQLObject.getWQLObject("ST_IVT_regionIO");
WQLObject orderTab = WQLObject.getWQLObject("mps_bd_produceshiftorder");
WQLObject materTab = WQLObject.getWQLObject("md_me_materialbase");
JSONObject jsonRegion = new JSONObject();
jsonRegion.put("iostorinv_id",IdUtil.getSnowflake(1,1).nextId());
jsonRegion.put("bill_code",CodeUtil.getNewCode("IN_STORE_CODE"));
jsonRegion.put("io_type",io_type);
jsonRegion.put("bill_status","20");
// 根据起点点位找到起点设备,根据设备找到对应工单, 根据工单找到对应物料及托盘类型
String device_code = start_point_code.substring(0, start_point_code.indexOf("-"));
DeviceService deviceBean = SpringContextHolder.getBean(DeviceService.class);
DeviceDto deviceDto = deviceBean.findByCode(device_code);
if (ObjectUtil.isEmpty(deviceDto)) throw new BadRequestException("此设备不存在");
JSONObject jsonOrder = orderTab.query("device_id = '" + deviceDto.getDevice_id() + "' and order_status = '02' and is_delete = '0'").uniqueResult(0);
if (ObjectUtil.isEmpty(jsonOrder)) throw new BadRequestException("此设备未在生产中或不存在");
jsonRegion.put("material_id",jsonOrder.getString("material_id"));
jsonRegion.put("qty",qty);
JSONObject jsonMater = materTab.query("material_id ='" + jsonOrder.getString("material_id") + "'").uniqueResult(0);
jsonRegion.put("qty_unit_id",jsonMater.getString("base_unit_id"));
jsonRegion.put("start_point_code",start_point_code);
Long start_region_id = SpringContextHolder.getBean(PointService.class).findByCode(start_point_code).getRegion_id();
jsonRegion.put("start_region_id",String.valueOf(start_region_id));
jsonRegion.put("end_point_code",next_point_code);
Long end_region_id = SpringContextHolder.getBean(PointService.class).findByCode(next_point_code).getRegion_id();
jsonRegion.put("end_region_id",String.valueOf(end_region_id));
jsonRegion.put("create_mode","02");
jsonRegion.put("task_id",task_id);
jsonRegion.put("create_id",SecurityUtils.getCurrentUserId());
jsonRegion.put("create_name",SecurityUtils.getNickName());
jsonRegion.put("create_time",DateUtil.now());
regionTab.insert(jsonRegion);
JSONObject resuft = new JSONObject();
resuft.put("vehicle_type", jsonOrder.getString("vehicle_type"));
resuft.put("material_id", jsonRegion.getString("material_id"));
resuft.put("create_mode", jsonRegion.getString("create_mode"));
return resuft;
}
@Transactional
public JSONObject outCreateRegion(JSONObject json) {
String next_point_code = json.getString("next_point_code");
String io_type = json.getString("io_type");
WQLObject regionTab = WQLObject.getWQLObject("ST_IVT_regionIO");
WQLObject orderTab = WQLObject.getWQLObject("mps_bd_produceshiftorder");
WQLObject materTab = WQLObject.getWQLObject("md_me_materialbase");
JSONObject jsonRegion = new JSONObject();
jsonRegion.put("iostorinv_id",IdUtil.getSnowflake(1,1).nextId());
jsonRegion.put("bill_code",CodeUtil.getNewCode("OUT_STORE_CODE"));
jsonRegion.put("io_type",io_type);
jsonRegion.put("bill_status","20");
// 根据起点点位找到起点设备,根据设备找到对应工单, 根据工单找到对应物料及托盘类型
String device_code = next_point_code.substring(0, next_point_code.indexOf("-"));
DeviceService deviceBean = SpringContextHolder.getBean(DeviceService.class);
DeviceDto deviceDto = deviceBean.findByCode(device_code);
if (ObjectUtil.isEmpty(deviceDto)) throw new BadRequestException("此设备不存在");
JSONObject jsonOrder = orderTab.query("device_id = '" + deviceDto.getDevice_id() + "' and order_status = '02' and is_delete = '0'").uniqueResult(0);
if (ObjectUtil.isEmpty(jsonOrder)) throw new BadRequestException("此设备未在生产中或不存在");
jsonRegion.put("material_id",jsonOrder.getString("material_id"));
jsonRegion.put("qty","100"); // 暂时先按照100
JSONObject jsonMater = materTab.query("material_id ='" + jsonOrder.getString("material_id") + "'").uniqueResult(0);
jsonRegion.put("qty_unit_id",jsonMater.getString("base_unit_id"));
jsonRegion.put("end_point_code",next_point_code);
Long end_region_id = SpringContextHolder.getBean(PointService.class).findByCode(next_point_code).getRegion_id();
jsonRegion.put("end_region_id",String.valueOf(end_region_id));
jsonRegion.put("create_mode","02");
jsonRegion.put("create_id",SecurityUtils.getCurrentUserId());
jsonRegion.put("create_name",SecurityUtils.getNickName());
jsonRegion.put("create_time",DateUtil.now());
regionTab.insert(jsonRegion);
// 需回显起始点位、起始区域、任务id
JSONObject resuft = new JSONObject();
resuft.put("iostorinv_id",jsonRegion.getString("iostorinv_id"));
resuft.put("vehicle_type",jsonOrder.getString("vehicle_type"));
resuft.put("create_mode",jsonRegion.getString("create_mode"));
resuft.put("material_id",jsonOrder.getString("material_id"));
return resuft;
}
}

View File

@@ -8,98 +8,152 @@ import java.io.Serializable;
import java.math.BigDecimal;
/**
* @description /
* @author qinx
* @date 2022-05-24
**/
* @author qinx
* @description /
* @date 2022-05-24
**/
@Data
public class ProduceshiftorderDto implements Serializable {
/** 生产班次工单标识 */
/** 防止精度丢失 */
@JsonSerialize(using= ToStringSerializer.class)
private Long produceorder_id;
/** 生产班次工单标识 */
/**
* 防止精度丢失
*/
@JsonSerialize(using = ToStringSerializer.class)
private Long produceorder_id;
/** 生产班次工单编号 */
private String produceorder_code;
/**
* 生产班次工单编号
*/
private String produceorder_code;
/** 机台工单号 */
private String producedeviceorder_code;
/**
* 机台工单号
*/
private String producedeviceorder_code;
/** 班次类型 */
private String shift_type_scode;
/**
* 班次类型
*/
private String shift_type_scode;
/** 工序标识 */
private Long workprocedure_id;
/**
* 生产日期
*/
private String produce_date;
/** 生产日期 */
private String produce_date;
/**
* 计划数量
*/
private BigDecimal plan_qty;
/** 计划数量 */
private BigDecimal plan_qty;
/**
* 实际数量
*/
private BigDecimal real_qty;
/** 实际数量 */
private BigDecimal real_qty;
/**
* 报工数量
*/
private BigDecimal report_qty;
/** 报工数量 */
private BigDecimal report_qty;
/**
* 物料标识
*/
private Long material_id;
/** 物料标识 */
private Long material_id;
/**
* 物料单重
*/
private BigDecimal material_weight;
/** 物料单重 */
private BigDecimal material_weight;
/**
* 托盘类型
*/
private String vehicle_type;
/** 计划生产开始时间 */
private String planproducestart_date;
/**
* 计划生产开始时间
*/
private String planproducestart_date;
/** 计划生产结束时间 */
private String planproduceend_date;
/**
* 计划生产结束时间
*/
private String planproduceend_date;
/** 实际生产开始时间 */
private String realproducestart_date;
/**
* 实际生产开始时间
*/
private String realproducestart_date;
/** 实际生产结束时间 */
private String realproduceend_date;
/**
* 实际生产结束时间
*/
private String realproduceend_date;
/** 工单状态 */
private String order_status;
/**
* 工单状态
*/
private String order_status;
/** 是否搬运 */
private String is_needmove;
/**
* 是否搬运
*/
private String is_needmove;
/** 工单类型 */
private String order_type_scode;
/**
* 工单类型
*/
private String order_type_scode;
/** 创建人 */
private Long create_id;
/**
* 创建人
*/
private Long create_id;
/** 创建人姓名 */
private String create_name;
/**
* 创建人姓名
*/
private String create_name;
/** 创建时间 */
private String create_time;
/**
* 创建时间
*/
private String create_time;
/** 修改人 */
private Long update_optid;
/**
* 修改人
*/
private Long update_optid;
/** 修改人姓名 */
private String update_optname;
/**
* 修改人姓名
*/
private String update_optname;
/** 修改时间 */
private String update_time;
/**
* 修改时间
*/
private String update_time;
/** 部门ID */
private Long sysdeptid;
/**
* 部门ID
*/
private Long sysdeptid;
/** 公司ID */
private Long syscompanyid;
/**
* 公司ID
*/
private Long syscompanyid;
/** 是否删除 */
private String is_delete;
/**
* 是否删除
*/
private String is_delete;
private String is_canupdate_update;
private String is_canupdate_update;
private Long device_id;
private Long sale_id;
private Long device_id;
private Long sale_id;
}

View File

@@ -51,9 +51,7 @@ public class ProduceshiftorderServiceImpl implements ProduceshiftorderService {
String order_type_scode = MapUtil.getStr(whereJson, "order_type_scode");
String order_status = MapUtil.getStr(whereJson, "order_status");
String shift_type_scode = MapUtil.getStr(whereJson, "shift_type_scode");
String parent_id = MapUtil.getStr(whereJson, "product_series");
String sale_id = MapUtil.getStr(whereJson, "sale_id");
String product_series = "";
JSONObject map = new JSONObject();
map.put("flag", "1");
map.put("order_type_scode", order_type_scode);
@@ -70,10 +68,6 @@ public class ProduceshiftorderServiceImpl implements ProduceshiftorderService {
map.put("unFinish", "-1");
map.put("order_status", order_status.replace("-1", ""));
}
if (StrUtil.isNotEmpty(parent_id)) {
product_series = classstandardService.getChildIdStr(parent_id);
map.put("product_series", product_series);
}
if (StrUtil.isNotEmpty(produceorder_code)) {
map.put("produceorder_code", "%" + produceorder_code + "%");
}
@@ -185,12 +179,19 @@ public class ProduceshiftorderServiceImpl implements ProduceshiftorderService {
Long currentUserId = SecurityUtils.getCurrentUserId();
String nickName = SecurityUtils.getNickName();
String now = DateUtil.now();
WQLObject wo = WQLObject.getWQLObject("mps_bd_produceshiftorder");
param.put("order_status", "01");
param.put("update_optid", currentUserId);
param.put("update_optname", nickName);
param.put("update_time", now);
wo.update(param);
JSONObject json = wo.query("produceorder_id = '" + param.getString("produceorder_id") + "'").uniqueResult(0);
if (ObjectUtil.isEmpty(json.getString("device_id"))) throw new BadRequestException("请先绑定设备");
JSONArray orderArr = wo.query("device_id = '" + param.getString("device_id") + "' and order_status = '02'").getResultJSONArray(0);
if (ObjectUtil.isNotEmpty(orderArr)) throw new BadRequestException("当前设备正在生产中");
json.put("order_status", "02");
json.put("update_optid", currentUserId);
json.put("update_optname", nickName);
json.put("update_time", now);
wo.update(json);
}
@Override

View File

@@ -60,14 +60,13 @@
material.material_name,
material.material_spec,
material.product_series,
WorkProcedure.workprocedure_code,
WorkProcedure.workprocedure_name,
classstandard.class_id,
classstandard.class_name
classstandard.class_name,
device.device_name
FROM
MPS_BD_ProduceShiftOrder ShiftOrder
LEFT JOIN md_me_materialbase material ON material.material_id = ShiftOrder.material_id
LEFT JOIN PDM_BI_WorkProcedure WorkProcedure ON WorkProcedure.workprocedure_id = ShiftOrder.workprocedure_id
LEFT JOIN pdm_bi_device device ON ShiftOrder.device_id = device.device_id
LEFT JOIN md_pb_classstandard classstandard ON classstandard.class_id = material.product_series
WHERE
ShiftOrder.is_delete = '0'
@@ -82,9 +81,6 @@
ENDOPTION
OPTION 输入.shift_type_scode <> ""
ShiftOrder.shift_type_scode = 输入.shift_type_scode
ENDOPTION
OPTION 输入.product_series <> ""
material.product_series in 输入.product_series
ENDOPTION
OPTION 输入.begin_time <> ""
ShiftOrder.produce_date >= 输入.begin_time

View File

@@ -66,46 +66,12 @@ public class DeviceController {
return new ResponseEntity<>(HttpStatus.OK);
}
@GetMapping("/getWorkprocedure")
@Log("工序下拉")
@ApiOperation("工序下拉")
//@PreAuthorize("@el.check('device:list')")
public ResponseEntity<Object> getWorkprocedure(){
return new ResponseEntity<>(deviceService.getWorkprocedure(),HttpStatus.OK);
}
@PostMapping("/getItemByDevice")
@Log("获取设备下的项点")
@ApiOperation("获取设备下的项点")
//@PreAuthorize("@el.check('device:list')")
public ResponseEntity<Object> getItemByDevice(@RequestBody JSONObject param){
return new ResponseEntity<>(deviceService.getItemByDevice(param),HttpStatus.OK);
}
@PostMapping("/savaDeviceItem")
@Log("保存设备项点")
@ApiOperation("保存设备项点")
//@PreAuthorize("@el.check('device:list')")
public ResponseEntity<Object> savaDeviceItem(@RequestBody JSONObject param){
deviceService.savaDeviceItem(param);
return new ResponseEntity<>(HttpStatus.OK);
}
@PostMapping("/getItemByDeviceId")
@Log("动态获取表格列")
@ApiOperation("动态获取表格列")
//@PreAuthorize("@el.check('dcBaseDevice:list')")
public ResponseEntity<Object> getItemByDeviceId(@RequestBody JSONObject param){
return new ResponseEntity<>(deviceService.getItemByDeviceId(param),HttpStatus.OK);
}
@PostMapping("/copyAdd")
@Log("复制新增")
@ApiOperation("复制新增")
//@PreAuthorize("@el.check('dcBaseDevice:list')")
public ResponseEntity<Object> copyAdd(@RequestBody JSONObject param){
deviceService.copyAdd(param);
return new ResponseEntity<>(HttpStatus.OK);
@PutMapping("/changeActive")
@Log("修改点位启用状态")
@ApiOperation("修改点位启用状态")
public ResponseEntity<Object> changeActive(@RequestBody JSONObject json) {
deviceService.changeActive(json);
return new ResponseEntity<>(HttpStatus.NO_CONTENT);
}
}

View File

@@ -64,18 +64,6 @@ public interface DeviceService {
*/
void deleteAll(Long[] ids);
JSONArray getWorkprocedure();
JSONArray getItemByDevice(JSONObject param);
void savaDeviceItem(JSONObject param);
/**
* 查询设备类型
* @param param
* @return
*/
Map<String,Object> getItemByDeviceId(JSONObject param);
void copyAdd(JSONObject param);
void changeActive(JSONObject json);
}

View File

@@ -8,64 +8,72 @@ import java.io.Serializable;
import java.math.BigDecimal;
/**
* @description /
* @author geng by
* @date 2022-05-25
**/
* @author geng by
* @description /
* @date 2022-05-25
**/
@Data
public class DeviceDto implements Serializable {
/** 设备标识 */
/** 防止精度丢失 */
@JsonSerialize(using= ToStringSerializer.class)
private Long device_id;
/** 设备标识 */
/**
* 防止精度丢失
*/
@JsonSerialize(using = ToStringSerializer.class)
private Long device_id;
/** 设备编码 */
private String device_code;
/**
* 设备编码
*/
private String device_code;
/** 设备名称 */
private String device_name;
/**
* 设备名称
*/
private String device_name;
/** 设备型号 */
private String device_model;
/**
* 设备型号
*/
private String device_model;
/** 工序标识 */
private Long workprocedure_id;
/**
* 外部编码
*/
private String extend_code;
/** 外部编码 */
private String extend_code;
/**
* 备注
*/
private String remark;
/** 设备档案标识 */
private Long devicebill_id;
/**
* 是否启用
*/
private String is_active;
/** 备注 */
private String remark;
/**
* 创建人
*/
private Long create_id;
/** 是否启用 */
private String is_active;
/**
* 创建人姓名
*/
private String create_name;
/** 创建人 */
private Long create_id;
/**
* 创建时间
*/
private String create_time;
/** 创建人姓名 */
private String create_name;
/**
* 是否删除
*/
private String is_delete;
/** 创建时间 */
private String create_time;
/** 是否删除 */
private String is_delete;
/** 物料标识 */
private Long material_id;
/** 生产班次工单标识 */
private Long produceorder_id;
/** 生产班次工单编号 */
private String produceorder_code;
/** 设备产能 */
/**
* 设备产能
*/
private BigDecimal productivity;
}

View File

@@ -38,54 +38,13 @@ public class DeviceServiceImpl implements DeviceService {
@Override
public Map<String, Object> queryAll(Map whereJson, Pageable page) {
String workprocedure_id = MapUtil.getStr(whereJson, "workprocedure_id");
String search = MapUtil.getStr(whereJson, "search");
JSONObject map2 = new JSONObject();
map2.put("flag", "3");
map2.put("workprocedure_id", workprocedure_id);
JSONObject map = new JSONObject();
map.put("flag", "1");
if (!StrUtil.isEmpty(search)) {
map2.put("search", "%" + search + "%");
map.put("search", "%" + search + "%");
}
//根据工序获取设备信息
JSONObject json = WQL.getWO("PDM_BI_DEVICE01").addParamMap(map2).pageQuery(WqlUtil.getHttpContext(page), "device.create_time desc");
JSONArray jsonArray = json.getJSONArray("content");
JSONArray newContent = new JSONArray();
for (int i = 0; i < jsonArray.size(); i++) {
JSONObject jsonObject = jsonArray.getJSONObject(i);
JSONObject map = new JSONObject();
String device_id = jsonObject.getString("device_id");
map.put("flag", "4");
map.put("device_id", device_id);
//获取设备所拥有的项点信息
JSONArray itemArray = WQL.getWO("PDM_BI_DEVICE01").addParamMap(map).process().getResultJSONArray(0);
JSONObject newMap = new JSONObject();
newMap.put("device_id", jsonObject.getString("device_id"));
newMap.put("device_code", jsonObject.getString("device_code"));
newMap.put("device_name", jsonObject.getString("device_name"));
newMap.put("device_model", jsonObject.getString("device_model"));
newMap.put("productivity", jsonObject.getString("productivity"));
newMap.put("workprocedure_id", jsonObject.getString("workprocedure_id"));
newMap.put("extend_code", jsonObject.getString("extend_code"));
newMap.put("devicebill_id", jsonObject.getString("devicebill_id"));
newMap.put("remark", jsonObject.getString("remark"));
newMap.put("is_active", jsonObject.getString("is_active"));
newMap.put("is_delete", jsonObject.getString("is_delete"));
//循环每个设备的项点信息将项点所对应的键设为项点编码对应动态表格的prop
for (int j = 0; j < itemArray.size(); j++) {
JSONObject itemObject = itemArray.getJSONObject(j);
if (itemObject.getString("data_type").equals("01")){
if (itemObject.getString("item_value").equals("0")){
newMap.put(itemObject.getString("item_code"), "");
}else {
newMap.put(itemObject.getString("item_code"), "");
}
}else {
newMap.put(itemObject.getString("item_code"), itemObject.getString("item_value"));
}
}
newContent.add(newMap);
}
json.put("content", newContent);
JSONObject json = WQL.getWO("PDM_BI_DEVICE01").addParamMap(map).pageQuery(WqlUtil.getHttpContext(page), "device.create_time DESC");
return json;
}
@@ -168,109 +127,14 @@ public class DeviceServiceImpl implements DeviceService {
}
}
@Override
public JSONArray getWorkprocedure() {
WQLObject wo = WQLObject.getWQLObject("pdm_bi_workprocedure");
final JSONArray resultJSONArray = wo.query("is_delete = '0'").getResultJSONArray(0);
return resultJSONArray;
}
@Override
public JSONArray getItemByDevice(JSONObject param) {
JSONObject map = new JSONObject();
map.put("flag", "1");
map.put("device_id", param.getString("device_id"));
final JSONArray resultJSONArray = WQL.getWO("PDM_BI_DEVICE01").addParamMap(map).addParamMap(map).process().getResultJSONArray(0);
return resultJSONArray;
}
@Transactional(rollbackFor = Exception.class)
@Override
public void savaDeviceItem(JSONObject param) {
WQLObject wo = WQLObject.getWQLObject("PDM_BI_DeviceItemValue");
final JSONObject row = param.getJSONObject("row");
final JSONArray rows = param.getJSONArray("rows");
final String device_id = row.getString("device_id");
wo.delete("device_id = '" + device_id + "'");
for (int i = 0; i < rows.size(); i++) {
final JSONObject jsonObject = rows.getJSONObject(i);
final String item_id = jsonObject.getString("item_id");
JSONObject map = new JSONObject();
map.put("deviceitem_id", IdUtil.getSnowflake(1, 1).nextId());
map.put("device_id", device_id);
map.put("item_id", item_id);
map.put("item_value", jsonObject.getString("item_value"));
map.put("order_seq", i + 1);
wo.insert(map);
}
}
@Override
public Map<String, Object> getItemByDeviceId(JSONObject param) {
//动态获取设备类型下对应的项点信息
String workprocedure_id = param.getString("workprocedure_id");
String search = param.getString("search");
JSONObject map = new JSONObject();
map.put("flag", "2");
map.put("workprocedure_id", workprocedure_id);
if (StrUtil.isNotEmpty(search)) {
map.put("search", "%" + search + "%");
}
final JSONArray jsonArray = WQL.getWO("PDM_BI_DEVICE01").addParamMap(map).process().getResultJSONArray(0);
JSONArray newArray = new JSONArray();
for (int i = 0; i < jsonArray.size(); i++) {
JSONObject jsonObject = jsonArray.getJSONObject(i);
String item_name = jsonObject.getString("item_name");
JSONObject json = new JSONObject();
json.put("label", item_name);
//将表格prop设置为项点编码
json.put("prop", jsonObject.getString("item_code"));
json.put("show", true);
if (item_name.length() >= 6) {
json.put("width", "150");
}
newArray.add(json);
}
JSONObject resultMap = new JSONObject();
resultMap.put("newArray", newArray);
return resultMap;
}
@Override
@Transactional(rollbackFor = Exception.class)
public void copyAdd(JSONObject param) {
WQLObject wo = WQLObject.getWQLObject("PDM_BI_Device");
WQLObject wo_value = WQLObject.getWQLObject("PDM_BI_DeviceItemValue");
Long currentUserId = SecurityUtils.getCurrentUserId();
String nickName = SecurityUtils.getNickName();
String now = DateUtil.now();
String device_id = IdUtil.getSnowflake(1, 1).nextId() + "";
JSONObject row = param.getJSONObject("row");
//编码唯一性校验
String device_code = row.getString("device_code");
DeviceDto byCode = this.findByCode(device_code);
if (ObjectUtil.isNotEmpty(byCode)) throw new BadRequestException("编码已存在!");
row.put("device_id", device_id);
row.put("create_id", currentUserId);
row.put("create_name", nickName);
row.put("create_time", now);
wo.insert(row);
JSONArray rows = param.getJSONArray("rows");
if (rows.size() > 0) {
for (int i = 0; i < rows.size(); i++) {
JSONObject jsonObject = rows.getJSONObject(i);
JSONObject map = new JSONObject();
map.put("deviceitem_id", IdUtil.getSnowflake(1, 1).nextId());
map.put("device_id", device_id);
map.put("item_id", jsonObject.getString("item_id"));
map.put("item_value", jsonObject.getString("default_value"));
map.put("order_seq", i + 1);
wo_value.insert(map);
}
public void changeActive(JSONObject json) {
String is_used = "1";
if (StrUtil.equals("1", json.getString("is_used"))) {
is_used = "0";
}
json.put("is_used", is_used);
WQLObject.getWQLObject("PDM_BI_Device").update(json);
}
}

View File

@@ -15,8 +15,6 @@
#################################################
输入.flag TYPEAS s_string
输入.search TYPEAS s_string
输入.device_id TYPEAS s_string
输入.workprocedure_id TYPEAS s_string
[临时表]
@@ -42,79 +40,19 @@
##########################################
IF 输入.flag = "1"
QUERY
PAGEQUERY
SELECT
deviceitem.*,
deviceitemvalue.item_value,
'1' as is_show
device.*
FROM
PDM_BI_DeviceItemValue deviceitemvalue
left join PDM_BI_DeviceItem deviceitem on deviceitemvalue.item_id = deviceitem.item_id
PDM_BI_Device device
WHERE
deviceitemvalue.device_id = 输入.device_id
order by
deviceitemvalue.order_seq
ENDSELECT
ENDQUERY
ENDIF
device.is_delete = '0'
IF 输入.flag = "2"
QUERY
SELECT
deviceitem.*
FROM
`pdm_bi_deviceitemvalue` deviceitemvalue
LEFT JOIN pdm_bi_device device ON deviceitemvalue.device_id = device.device_id
LEFT JOIN pdm_bi_deviceitem deviceitem ON deviceitemvalue.item_id = deviceitem.item_id
where
1 = 1
OPTION 输入.workprocedure_id <> ""
device.workprocedure_id = 输入.workprocedure_id
ENDOPTION
OPTION 输入.search <> ""
(device.device_code like 输入.search or device.device_name like 输入.search)
(device.device_code like 输入.search or
device.device_name like 输入.search)
ENDOPTION
GROUP BY
deviceitem.item_code
ENDSELECT
ENDQUERY
ENDIF
IF 输入.flag = "3"
PAGEQUERY
SELECT
device.*
FROM
PDM_BI_Device device
WHERE
1 = 1
OPTION 输入.workprocedure_id <> ""
device.workprocedure_id = 输入.workprocedure_id
ENDOPTION
OPTION 输入.search <> ""
(device.device_code like 输入.search or
device.device_name like 输入.search)
ENDOPTION
ENDSELECT
ENDPAGEQUERY
ENDIF
IF 输入.flag = "4"
QUERY
SELECT
deviceItemValue.device_id,
deviceItemValue.item_id,
deviceItemValue.item_value,
item.item_code,
item.data_type
FROM
PDM_BI_DeviceItemValue deviceItemValue
LEFT JOIN PDM_BI_Device device ON deviceItemValue.device_id = device.device_id
LEFT JOIN PDM_BI_DeviceItem item ON deviceItemValue.item_id = item.item_id
where
deviceItemValue.device_id = 输入.device_id
ENDSELECT
ENDQUERY
ENDIF
ENDPAGEQUERY
ENDIF

View File

@@ -61,6 +61,16 @@ public class PointDto implements Serializable {
*/
private Integer vehicle_qty;
/**
* 载具类型
*/
private String vehicle_type;
/**
* 是否专机
*/
private String is_host;
/**
* 来源标识
*/

View File

@@ -74,7 +74,9 @@
point.create_name,
point.create_time,
point.update_optname,
point.update_time
point.update_time,
point.vehicle_type,
point.is_host
FROM
sch_base_point point
LEFT JOIN SCH_BASE_Region region ON point.region_id = region.region_id

View File

@@ -13,6 +13,8 @@ import org.nl.exception.BadRequestException;
import org.nl.modules.system.util.CodeUtil;
import org.nl.utils.SecurityUtils;
import org.nl.utils.SpringContextHolder;
import org.nl.wms.pdm.service.DeviceService;
import org.nl.wms.pdm.service.dto.DeviceDto;
import org.nl.wms.sch.manage.AbstractAcsTask;
import org.nl.wms.sch.manage.TaskStatusEnum;
import org.nl.wms.sch.service.PointService;
@@ -60,7 +62,10 @@ public class CallEmpVehicleTask extends AbstractAcsTask {
BigDecimal vehicle_qty_point = NumberUtil.sub(String.valueOf(vehicle_qty), String.valueOf(jsonEmp.getIntValue("vehicle_qty")));
start_point_code.setVehicle_qty(Integer.valueOf(vehicle_qty_point.toString()));
if (StrUtil.equals(vehicle_qty_point.toString(), "0")) start_point_code.setPoint_status("00");
if (StrUtil.equals(vehicle_qty_point.toString(), "0")) {
start_point_code.setPoint_status("00");
start_point_code.setVehicle_type("");
}
start_point_code.setLock_type("00");
pointTab.update(JSONObject.parseObject(JSON.toJSONString(start_point_code)));
@@ -93,6 +98,7 @@ public class CallEmpVehicleTask extends AbstractAcsTask {
String next_point_code = form.getString("next_point_code");
String qty = form.getString("qty");
String record_uuid = form.getString("record_uuid");
String vehicle_type = form.getString("vehicle_type");
// 出库终点不能为空
if (ObjectUtil.isEmpty(next_point_code)) {
@@ -114,7 +120,9 @@ public class CallEmpVehicleTask extends AbstractAcsTask {
JSONObject param = new JSONObject();
param.put("next_point_code",next_point_code);
param.put("vehicle_qty",qty);
start_point_code = this.findBeginPoint(param);
JSONObject json = this.findBeginPoint(param);
start_point_code = json.getString("start_point_code");
vehicle_type = json.getString("vehicle_type");
} else {
// 判断终点是否是空位
JSONObject jsonPoint = pointTab.query("point_code = '" + start_point_code + "' and lock_type = '00' and point_status <> '02' and is_delete = '0' and is_used = '1'").uniqueResult(0);
@@ -133,6 +141,7 @@ public class CallEmpVehicleTask extends AbstractAcsTask {
jsonTask.put("start_point_code", start_point_code);
jsonTask.put("next_point_code", next_point_code);
jsonTask.put("handle_class", THIS_CLASS);
jsonTask.put("vehicle_type", vehicle_type);
jsonTask.put("create_name", SecurityUtils.getCurrentUsername());
jsonTask.put("create_id", SecurityUtils.getCurrentUserId());
jsonTask.put("create_time", DateUtil.now());
@@ -169,7 +178,7 @@ public class CallEmpVehicleTask extends AbstractAcsTask {
}
public String findBeginPoint(JSONObject json) {
public JSONObject findBeginPoint(JSONObject json) {
String next_point_code = json.getString("next_point_code");
String vehicle_qty = json.getString("vehicle_qty");
if (ObjectUtil.isEmpty(next_point_code)) throw new BadRequestException("终点不能为空");
@@ -177,48 +186,89 @@ public class CallEmpVehicleTask extends AbstractAcsTask {
WQLObject pointTab = WQLObject.getWQLObject("sch_base_point");
WQLObject regionTab = WQLObject.getWQLObject("SCH_BASE_Region");
WQLObject orderTab = WQLObject.getWQLObject("mps_bd_produceshiftorder");
// 根据终点区域判断优先的起点区域
JSONObject jsonPointEnd = pointTab.query("point_code = '" + next_point_code + "'").uniqueResult(0);
if (ObjectUtil.isEmpty(jsonPointEnd)) throw new BadRequestException("终点点位不存在");
JSONObject jsonRegionEnd = regionTab.query("region_id ='" + jsonPointEnd.getString("region_id") + "'").uniqueResult(0);
// 根据起点找到对应设备,根据设备查询工单表中 - 正在运行的工单中的载具类型
String device_code = next_point_code.substring(0, next_point_code.indexOf("-"));
DeviceService deviceBean = SpringContextHolder.getBean(DeviceService.class);
DeviceDto deviceDto = deviceBean.findByCode(device_code);
if (ObjectUtil.isEmpty(deviceDto)) throw new BadRequestException("此设备不存在");
JSONObject jsonOrder = orderTab.query("device_id = '" + deviceDto.getDevice_id() + "' and order_status = '02' and is_delete = '0'").uniqueResult(0);
if (ObjectUtil.isEmpty(jsonOrder)) throw new BadRequestException("此设备未在生产中或不存在");
/*
* 空托盘出库任务:
* 1.叠盘架B区、养生A区 --> 共挤线 优先级1叠盘架B区 2养生A区
* 2.叠盘架A区、养生A区 --> 油漆线 优先级1叠盘架A区 2养生A区
*/
String start_point_code = "";
HashMap<String, String> map = new HashMap<>();
JSONObject map = new JSONObject();
if (StrUtil.equals(jsonRegionEnd.getString("region_code"),RegionTypeEnum.GJQY.getCode())) {
// 共挤线呼叫空托盘业务查找叠盘架B区是否有满足条件的点位
map.put("flag", "1");
map.put("vehicle_qty", vehicle_qty);
map.put("vehicle_type", jsonOrder.getString("vehicle_type"));
map.put("region_code", RegionTypeEnum.DPJQB.getCode());
JSONObject jsonStartPointDPB = WQL.getWO("ST_VEHICLE_OUT_02").addParamMap(map).process().uniqueResult(0);
if (ObjectUtil.isNotEmpty(jsonStartPointDPB)) {
start_point_code = jsonStartPointDPB.getString("point_code");
} else {
// 为空说明叠盘架B区没有则去养生A区找
// 为空说明叠盘架B区没有则去养生A区找 : 只能找数量为1的空托盘
map.put("flag", "3");
map.put("region_code", RegionTypeEnum.YSQA.getCode());
JSONObject jsonStartPointYSA = WQL.getWO("ST_VEHICLE_OUT_02").addParamMap(map).process().uniqueResult(0);
if (ObjectUtil.isEmpty(jsonStartPointYSA)) throw new BadRequestException("没有满足需求数量的点位");
start_point_code = jsonStartPointYSA.getString("point_code");
if (ObjectUtil.isNotEmpty(jsonStartPointYSA)) {
start_point_code = jsonStartPointYSA.getString("point_code");
} else {
throw new BadRequestException("没有满足需求数量的点位");
/* // 如果没有则需要从养生区A区里找到 > 1的货位 出库到叠盘架B中
map.put("flag", "1");
map.put("region_code", RegionTypeEnum.YSQA.getCode());
// 起点
JSONObject jsonStart = WQL.getWO("ST_VEHICLE_OUT_02").addParamMap(map).process().uniqueResult(0);
if (ObjectUtil.isEmpty(jsonStart)) throw new BadRequestException("没有满足需求数量的点位");
// 终点
JSONObject jsonEnd = pointTab.query("region_id = '" + RegionTypeEnum.DPJQB.getId() + "' and point_status = '00' and lock_type = '00' and is_used = '1' and is_delete = '0'").uniqueResult(0);
if (ObjectUtil.isEmpty(jsonEnd)) throw new BadRequestException("叠盘架B货位不足");
JSONObject parem = new JSONObject();
parem.put("start_point_code",jsonStart.getString("point_code"));
parem.put("next_point_code",jsonEnd.getString("point_code"));
parem.put("qty",jsonStart.getString("vehicle_qty"));
parem.put("vehicle_type",jsonStart.getString("vehicle_qty"));
String task_id = this.createTask(parem);
// 生成 叠盘架 -> 共挤线的任务 返回叠盘架B的点位code
start_point_code = jsonEnd.getString("point_code");*/
}
}
} else if (StrUtil.equals(jsonRegionEnd.getString("region_code"),RegionTypeEnum.YQQY.getCode())) {
// 油漆线呼叫空托盘业务查找叠盘架A区是否有满足条件的点位
map.put("flag", "1");
map.put("vehicle_qty", vehicle_qty);
map.put("vehicle_type", jsonOrder.getString("vehicle_type"));
map.put("region_code", RegionTypeEnum.DPJQA.getCode());
JSONObject jsonStartPointDPA = WQL.getWO("ST_VEHICLE_OUT_02").addParamMap(map).process().uniqueResult(0);
if (ObjectUtil.isNotEmpty(jsonStartPointDPA)) {
start_point_code = jsonStartPointDPA.getString("point_code");
} else {
// 为空说明叠盘架A区没有则去养生A区找
map.put("flag", "3");
map.put("region_code", RegionTypeEnum.YSQA.getCode());
JSONObject jsonStartPointYSA = WQL.getWO("ST_VEHICLE_OUT_02").addParamMap(map).process().uniqueResult(0);
if (ObjectUtil.isEmpty(jsonStartPointYSA)) throw new BadRequestException("没有满足需求数量的点位");
start_point_code = jsonStartPointYSA.getString("point_code");
}
}
return start_point_code;
JSONObject resuft = new JSONObject();
resuft.put("start_point_code",start_point_code);
resuft.put("vehicle_type",jsonOrder.getString("vehicle_type"));
return resuft;
}
}

View File

@@ -15,6 +15,7 @@ import org.nl.wms.basedata.st.StoreIvtServiceImpl;
import org.nl.wms.common.StructFindUtil;
import org.nl.wms.sch.manage.AbstractAcsTask;
import org.nl.wms.sch.manage.TaskStatusEnum;
import org.nl.wms.sch.service.PointService;
import org.nl.wms.sch.service.dto.PointDto;
import org.nl.wms.sch.service.impl.PointServiceImpl;
import org.nl.wql.WQL;
@@ -99,6 +100,7 @@ public class CallMaterialTask extends AbstractAcsTask {
startPointObj.put("lock_type", "00");
startPointObj.put("point_status", "00");
startPointObj.put("vehicle_code", "");
startPointObj.put("vehicle_type", "");
pointTab.update(startPointObj);
taskTab.update(jsonTask);
}
@@ -153,17 +155,20 @@ public class CallMaterialTask extends AbstractAcsTask {
@Override
@Transactional
public String createTask(JSONObject form) {
//请求参数 终点不能为空 物料,数量,客户,批次,创建方式,托盘,是否满托不能为空! 起点点位不为空时,单据编号不能为空!
//请求参数 载具、起点、终点
String vehicle_code = form.getString("vehicle_code");
String start_point_code = form.getString("start_point_code");
String next_point_code = form.getString("next_point_code");
String vehicle_code = form.getString("vehicle_code");
String vehicle_type = form.getString("vehicle_type");
String task_status = TaskStatusEnum.START_AND_POINT.getCode();
String material_id = form.getString("material_id");
String create_mode = form.getString("create_mode");
String pcsn = form.getString("pcsn");
WQLObject taskTable = WQLObject.getWQLObject("SCH_BASE_Task");
String iostorinv_id = form.getString("iostorinv_id");
WQLObject taskTable = WQLObject.getWQLObject("SCH_BASE_Task");
WQLObject regionTable = WQLObject.getWQLObject("ST_IVT_regionIO");
if (StrUtil.isEmpty(next_point_code)) {
throw new BadRequestException("终点不能为空!");
}
@@ -183,30 +188,27 @@ public class CallMaterialTask extends AbstractAcsTask {
PointServiceImpl pointService = SpringContextHolder.getBean(PointServiceImpl.class);
String task_id = IdUtil.getSnowflake(1, 1).nextId() + "";
String start_area = "";
String startArea_type = "";
String bill_type = "";
String qty = "";
String qty_unit_id = "";
String ivt_workprocedure_id = "";
WQLObject iosTable = WQLObject.getWQLObject("ST_IVT_regionIO");
if (StrUtil.isNotEmpty(start_point_code)) {
if (StrUtil.isEmpty(iostorinv_id)) {
throw new BadRequestException("入库单据号不能为空!");
}
JSONObject IosObj = iosTable.query("iostorinv_id='" + iostorinv_id + "'").uniqueResult(0);
IosObj.put("bill_status", "20");
iosTable.update(IosObj);
PointDto StartPoint = pointService.findByCode(start_point_code);
JSONObject ivtObj = WQLObject.getWQLObject("ST_IVT_StructIvt").query("struct_id='" + StartPoint.getPoint_id() + "'").uniqueResult(0);
if (ObjectUtil.isEmpty(ivtObj)) {
throw new BadRequestException("仓位为'" + StartPoint.getPoint_code() + "'的库存信息不存在!");
}
if (StrUtil.isEmpty(start_point_code)) {
// 起点为空找到对应的起点
JSONObject param = new JSONObject();
param.put("next_point_code",next_point_code);
param.put("vehicle_type",vehicle_type);
param.put("material_id",material_id);
JSONObject ivtObj = this.findBeginPoint(param);
qty = ivtObj.getString("canuse_qty");
qty_unit_id = ivtObj.getString("qty_unit_id");
start_point_code = ivtObj.getString("struct_code");
} else {
// 不能空则为点对点,查找对应出入库单据
if (ObjectUtil.isEmpty(iostorinv_id)) throw new BadRequestException("出库单id不能为空");
JSONObject jsonRegion = regionTable.query("iostorinv_id = '" + iostorinv_id + "'").uniqueResult(0);
qty = jsonRegion.getString("qty");
qty_unit_id = jsonRegion.getString("qty_unit_id");
}
PointDto nextPoint = pointService.findByCode(next_point_code);
task_status = TaskStatusEnum.START_AND_POINT.getCode();
PointDto startPoint = pointService.findByCode(start_point_code);
//起点点加锁
@@ -263,4 +265,36 @@ public class CallMaterialTask extends AbstractAcsTask {
public void cancel(String task_id) {
}
@Transactional
public JSONObject findBeginPoint(JSONObject json) {
String next_point_code = json.getString("next_point_code");
String vehicle_type = json.getString("vehicle_type");
String material_id = json.getString("material_id");
WQLObject regionTab = WQLObject.getWQLObject("SCH_BASE_Region");
// 根据起点判断是什么区域 然后要入到什么区
PointDto endDto = SpringContextHolder.getBean(PointService.class).findByCode(next_point_code);
if (ObjectUtil.isEmpty(endDto)) throw new BadRequestException("终点点位不存在");
JSONObject jsonEndRegion = regionTab.query("region_id = '" + endDto.getRegion_id() + "'").uniqueResult(0);
/*
* 物料出库业务目前只有1个业务如果区域不正确则报错
* 1.养生A区 --> 油漆线
*/
JSONObject resuft = new JSONObject();
if (StrUtil.equals(jsonEndRegion.getString("region_code"),RegionTypeEnum.YQQY.getCode())) {
JSONObject map = new JSONObject();
map.put("flag", "3");
map.put("vehicle_type", vehicle_type);
map.put("material_id", material_id);
map.put("region_code", RegionTypeEnum.YSQA.getCode());
resuft = WQL.getWO("ST_REGION_OUT_01").addParamMap(map).process().uniqueResult(0);
if (ObjectUtil.isEmpty(resuft)) throw new BadRequestException("库存不足");
} else {
throw new BadRequestException("业务类型错误");
}
return resuft;
}
}

View File

@@ -4,19 +4,20 @@ package org.nl.wms.sch.tasks;
* 任务状态枚举
*/
public enum RegionTypeEnum {
CPQY(1, "CPQY01", "成品区域"),
YSQA(2, "YSQA01", "养生A区"),
YSQB(3, "YSQB01", "养生B区"),
GJQY(4, "GJQY01", "共挤区"),
YQQY(5, "YQQY01", "油漆区"),
DPJQA(6, "DPJQA01", "叠盘架A区"),
DPJQB(7, "DPJQB01", "叠盘架B区"),
KTPHCQA(8, "KTPHCQA01", "空托盘缓存A区"),
KTPHCQB(8, "KTPHCQB01", "空托盘缓存B区");
CPQY(1, "CPQY01", "成品区域","1557538851726168064"),
YSQA(2, "YSQA01", "养生A区","1557539288307077120"),
YSQB(3, "YSQB01", "养生B区","1557539423292362752"),
GJQY(4, "GJQY01", "共挤区","1557539744848678912"),
YQQY(5, "YQQY01", "油漆区","1557913112412295168"),
DPJQA(6, "DPJQA01", "叠盘架A区","1558015562792177664"),
DPJQB(7, "DPJQB01", "叠盘架B区","1558015634472833024"),
KTPHCQA(8, "KTPHCQA01", "空托盘缓存A区","1558015810096730112"),
KTPHCQB(8, "KTPHCQB01", "空托盘缓存B区","1558015870570205184");
private int index;
private String code;
private String name;
private String id;
public String getCode() {
return code;
@@ -26,8 +27,13 @@ public enum RegionTypeEnum {
return name;
}
RegionTypeEnum(int index, String code, String name) {
public String getId() {
return id;
}
RegionTypeEnum(int index, String code, String name, String id) {
this.index = index;
this.id = id;
this.code = code;
this.name = name;
}

View File

@@ -13,6 +13,10 @@ import org.nl.exception.BadRequestException;
import org.nl.modules.system.util.CodeUtil;
import org.nl.utils.SecurityUtils;
import org.nl.utils.SpringContextHolder;
import org.nl.wms.basedata.master.service.StoragevehicleinfoService;
import org.nl.wms.basedata.master.service.dto.StoragevehicleinfoDto;
import org.nl.wms.pdm.service.DeviceService;
import org.nl.wms.pdm.service.dto.DeviceDto;
import org.nl.wms.sch.manage.AbstractAcsTask;
import org.nl.wms.sch.manage.TaskStatusEnum;
import org.nl.wms.sch.service.PointService;
@@ -46,23 +50,27 @@ public class SendEmpVehicleTask extends AbstractAcsTask {
jsonTask.put("update_time", DateUtil.now());
taskTab.update(jsonTask);
String start_point_code = jsonTask.getString("start_point_code");
PointService point = SpringContextHolder.getBean(PointService.class);
// 校验起点是否存在
PointDto start_point_code = point.findByCode(jsonTask.getString("start_point_code"));
if (ObjectUtil.isEmpty(start_point_code)) throw new BadRequestException("未找到可用点位:" + start_point_code);
PointDto startDto = point.findByCode(start_point_code);
if (ObjectUtil.isEmpty(startDto)) throw new BadRequestException("未找到可用点位:" + startDto);
// 校验终点是否存在
PointDto next_point_code = point.findByCode(jsonTask.getString("next_point_code"));
if (ObjectUtil.isEmpty(start_point_code)) throw new BadRequestException("未找到可用点位:" + next_point_code);
PointDto nextDto = point.findByCode(jsonTask.getString("next_point_code"));
if (ObjectUtil.isEmpty(nextDto)) throw new BadRequestException("未找到可用点位:" + nextDto);
// 1.更新点位数量 2.解锁点位
JSONObject jsonEmp = empTab.query("task_uuid = '" + taskObj.getString("task_id") + "'").uniqueResult(0);
int vehicle_qty = JSONObject.parseObject(JSON.toJSONString(next_point_code)).getIntValue("vehicle_qty");
int vehicle_qty = JSONObject.parseObject(JSON.toJSONString(nextDto)).getIntValue("vehicle_qty");
BigDecimal vehicle_qty_point = NumberUtil.add(String.valueOf(vehicle_qty), String.valueOf(jsonEmp.getIntValue("vehicle_qty")));
next_point_code.setVehicle_qty(Integer.valueOf(vehicle_qty_point.toString()));
next_point_code.setPoint_status("01");
next_point_code.setLock_type("00");
pointTab.update(JSONObject.parseObject(JSON.toJSONString(next_point_code)));
nextDto.setVehicle_qty(Integer.valueOf(vehicle_qty_point.toString()));
nextDto.setPoint_status("01");
nextDto.setLock_type("00");
nextDto.setVehicle_type(jsonTask.getString("vehicle_type"));
nextDto.setVehicle_code(jsonTask.getString("vehicle_code"));
pointTab.update(JSONObject.parseObject(JSON.toJSONString(nextDto)));
// 完成单据状态
jsonEmp.put("bill_status", "50");
@@ -91,9 +99,11 @@ public class SendEmpVehicleTask extends AbstractAcsTask {
String start_point_code = form.getString("start_point_code");
String next_point_code = form.getString("next_point_code");
String vehicle_code = form.getString("vehicle_code");
String qty = form.getString("qty");
String record_uuid = form.getString("record_uuid");
String vehicle_type = "";
// 入库起点不能为空
if (ObjectUtil.isEmpty(start_point_code)) {
throw new BadRequestException("起点不能为空");
@@ -114,7 +124,10 @@ public class SendEmpVehicleTask extends AbstractAcsTask {
JSONObject param = new JSONObject();
param.put("start_point_code",start_point_code);
param.put("vehicle_qty",qty);
next_point_code = this.findEndPoint(param);
param.put("vehicle_code",vehicle_code);
JSONObject json = this.findEndPoint(param);
next_point_code = json.getString("EndPoint_code");
vehicle_type = json.getString("vehicle_type");
} else {
// 判断终点是否是空位
JSONObject jsonPoint = pointTab.query("point_code = '" + next_point_code + "' and lock_type = '00' and point_status <> '02' and is_delete = '0' and is_used = '1'").uniqueResult(0);
@@ -132,6 +145,8 @@ public class SendEmpVehicleTask extends AbstractAcsTask {
jsonTask.put("task_status", "01");
jsonTask.put("start_point_code", start_point_code);
jsonTask.put("next_point_code", next_point_code);
jsonTask.put("vehicle_type", vehicle_type);
jsonTask.put("vehicle_code", vehicle_code);
jsonTask.put("handle_class", THIS_CLASS);
jsonTask.put("create_name", SecurityUtils.getCurrentUsername());
jsonTask.put("create_id", SecurityUtils.getCurrentUserId());
@@ -169,17 +184,47 @@ public class SendEmpVehicleTask extends AbstractAcsTask {
}
public String findEndPoint(JSONObject json) {
public JSONObject findEndPoint(JSONObject json) {
String start_point_code = json.getString("start_point_code");
String vehicle_qty = json.getString("vehicle_qty");
String vehicle_code = json.getString("vehicle_code");
if (ObjectUtil.isEmpty(start_point_code)) throw new BadRequestException("起点不能为空");
if (ObjectUtil.isEmpty(vehicle_qty)) throw new BadRequestException("载具数量不能为空");
WQLObject pointTab = WQLObject.getWQLObject("sch_base_point");
WQLObject regionTab = WQLObject.getWQLObject("SCH_BASE_Region");
WQLObject pointTab = WQLObject.getWQLObject("sch_base_point"); // 点位表
WQLObject regionTab = WQLObject.getWQLObject("SCH_BASE_Region"); // 区域表
WQLObject orderTab = WQLObject.getWQLObject("mps_bd_produceshiftorder"); //空载具记录表
WQLObject velicleTab = WQLObject.getWQLObject("md_pb_storagevehicleinfo"); // 载具表
// 根据起点区域判断优先的终点区域
JSONObject jsonPointStart = pointTab.query("point_code = '" + start_point_code + "'").uniqueResult(0);
if (ObjectUtil.isEmpty(jsonPointStart)) throw new BadRequestException("起点点位不存在");
JSONObject jsonRegionStart = regionTab.query("region_id ='" + jsonPointStart.getString("region_id") + "'").uniqueResult(0);
// 根据起点找到对应设备,根据设备查询工单表中 - 正在运行的工单中的载具类型
String device_code = "";
if (ObjectUtil.isEmpty(vehicle_code)) {
device_code = start_point_code.substring(0, start_point_code.indexOf("-"));
}
String vehicle_type = "";
DeviceService deviceBean = SpringContextHolder.getBean(DeviceService.class);
DeviceDto deviceDto = deviceBean.findByCode(device_code);
if (ObjectUtil.isEmpty(deviceDto)) {
// 如果说明是货梯业务:则判断载具号是否为空
if (ObjectUtil.isEmpty(vehicle_code)) throw new BadRequestException("起点点位错误");
// 根据载具号找对应的载具类型
StoragevehicleinfoDto vehicleDto = SpringContextHolder.getBean(StoragevehicleinfoService.class).findByCode(vehicle_code);
if (ObjectUtil.isEmpty(vehicleDto)) throw new BadRequestException("载具不存在");
vehicle_type = vehicleDto.getStoragevehicle_type();
} else {
// 不为空说明不是货梯业务:则根据工单找到对应类型
JSONObject jsonOrder = orderTab.query("device_id = '" + deviceDto.getDevice_id() + "' and order_status = '02' and is_delete = '0'").uniqueResult(0);
if (ObjectUtil.isEmpty(jsonOrder)) throw new BadRequestException("此设备未在生产中或不存在");
vehicle_type = jsonOrder.getString("vehicle_type");
}
/*
* 空托盘入库业务:
* 1.油漆线 --> 叠盘架A区、养生区A区 优先级1叠盘架A区 2.养生A区
@@ -191,35 +236,56 @@ public class SendEmpVehicleTask extends AbstractAcsTask {
// 油漆线入库查找叠盘架A区是否有满足的空位
map.put("flag", "1");
map.put("vehicle_qty",vehicle_qty);
map.put("vehicle_type",vehicle_type);
map.put("region_code",RegionTypeEnum.DPJQA.getCode());
JSONObject jsonEndPointDPA = WQL.getWO("ST_VEHICLE_IN_02").addParamMap(map).process().uniqueResult(0);
if (ObjectUtil.isNotEmpty(jsonEndPointDPA)) {
EndPoint_code = jsonEndPointDPA.getString("point_code");
} else {
// 为空说明叠盘架A区上货位不足则需要入库到养生A区
// 为空说明没有相同的载具类型
map.put("flag", "2");
map.put("region_code",RegionTypeEnum.YSQA.getCode() );
JSONObject jsonEndPointYSA = WQL.getWO("ST_VEHICLE_IN_02").addParamMap(map).process().uniqueResult(0);
if (ObjectUtil.isEmpty(jsonEndPointYSA)) throw new BadRequestException("没有满足需求的空位");
EndPoint_code = jsonEndPointYSA.getString("point_code");
map.put("vehicle_type","");
JSONObject jsonEndPointDPA2 = WQL.getWO("ST_VEHICLE_IN_02").addParamMap(map).process().uniqueResult(0);
if (ObjectUtil.isNotEmpty(jsonEndPointDPA2)) {
EndPoint_code = jsonEndPointDPA2.getString("point_code");
} else {
// 为空说明叠盘架A区上货位不足则需要入库到养生A区
map.put("flag", "3");
map.put("region_code",RegionTypeEnum.YSQA.getCode() );
JSONObject jsonEndPointYSA = WQL.getWO("ST_VEHICLE_IN_02").addParamMap(map).process().uniqueResult(0);
if (ObjectUtil.isEmpty(jsonEndPointYSA)) throw new BadRequestException("没有满足需求的空位");
EndPoint_code = jsonEndPointYSA.getString("point_code");
}
}
} else {
// 货梯入库查找叠盘架B区是否有满足的空位
map.put("flag", "1");
map.put("vehicle_qty",vehicle_qty);
map.put("vehicle_type",vehicle_type);
map.put("region_code",RegionTypeEnum.DPJQB.getCode());
JSONObject jsonEndPointDPB = WQL.getWO("ST_VEHICLE_IN_02").addParamMap(map).process().uniqueResult(0);
if (ObjectUtil.isNotEmpty(jsonEndPointDPB)) {
EndPoint_code = jsonEndPointDPB.getString("point_code");
} else {
// 为空说明叠盘架B区上货位不足则需要入库到养生A区
// 为空说明没有相同的载具类型
map.put("flag", "2");
map.put("region_code", RegionTypeEnum.YSQA.getCode());
JSONObject jsonEndPointYSA = WQL.getWO("ST_VEHICLE_IN_02").addParamMap(map).process().uniqueResult(0);
if (ObjectUtil.isEmpty(jsonEndPointYSA)) throw new BadRequestException("没有满足需求的空位");
EndPoint_code = jsonEndPointYSA.getString("point_code");
map.put("vehicle_type","");
JSONObject jsonEndPointDPB2 = WQL.getWO("ST_VEHICLE_IN_02").addParamMap(map).process().uniqueResult(0);
if (ObjectUtil.isNotEmpty(jsonEndPointDPB2)) {
EndPoint_code = jsonEndPointDPB2.getString("point_code");
} else {
// 为空说明叠盘架B区上货位不足则需要入库到养生A区
map.put("flag", "3");
map.put("region_code", RegionTypeEnum.YSQA.getCode());
JSONObject jsonEndPointYSA = WQL.getWO("ST_VEHICLE_IN_02").addParamMap(map).process().uniqueResult(0);
if (ObjectUtil.isEmpty(jsonEndPointYSA)) throw new BadRequestException("没有满足需求的空位");
EndPoint_code = jsonEndPointYSA.getString("point_code");
}
}
}
return EndPoint_code;
JSONObject resuft = new JSONObject();
resuft.put("EndPoint_code",EndPoint_code);
resuft.put("vehicle_type",vehicle_type);
return resuft;
}
}

View File

@@ -130,14 +130,16 @@ public class SendMaterialTask extends AbstractAcsTask {
endpointObj.put("lock_type", "00");
endpointObj.put("point_status", "02");
endpointObj.put("vehicle_code", vehicle_code);
endpointObj.put("vehicle_type", jsonTask.getString("vehicle_type"));
pointTab.update(endpointObj);
taskTab.update(jsonTask);
JSONObject startPointObj = pointTab.query("point_code='" + jsonTask.getString("start_point_code") + "'").uniqueResult(0);
/* JSONObject startPointObj = pointTab.query("point_code='" + jsonTask.getString("start_point_code") + "'").uniqueResult(0);
startPointObj.put("lock_type", "00");
startPointObj.put("point_status", "00");
startPointObj.put("vehicle_code", "");
pointTab.update(startPointObj);
taskTab.update(jsonTask);
taskTab.update(jsonTask);*/
}
}
@@ -194,17 +196,14 @@ public class SendMaterialTask extends AbstractAcsTask {
public String createTask(JSONObject form) {
//请求参数 载具、起点、终点
String vehicle_code = form.getString("vehicle_code");
String vehicle_type = form.getString("vehicle_type");
String start_point_code = form.getString("start_point_code");
String next_point_code = form.getString("next_point_code");
String material_id = form.getString("material_id");
String stewing_time = form.getString("stewing_time");
String producetask_id = form.getString("producetask_id");
String is_full = form.getString("is_full");
String qty = form.getString("qty");
String cust_id = form.getString("cust_id");
String create_mode = form.getString("create_mode");
String pcsn = form.getString("pcsn");
WQLObject taskTable = WQLObject.getWQLObject("SCH_BASE_Task");
WQLObject iosTable = WQLObject.getWQLObject("ST_IVT_regionIO");
if (StrUtil.isEmpty(start_point_code)) {
throw new BadRequestException("起点不能为空!");
}
@@ -215,44 +214,42 @@ public class SendMaterialTask extends AbstractAcsTask {
if (ObjectUtil.isNotEmpty(beforTaskObj)) {
throw new BadRequestException("存在指令号为'" + beforTaskObj.getString("task_code") + "' 未完成!");
}
PointService pointService = SpringContextHolder.getBean(PointService.class);
PointDto startPoint = pointService.findByCode(start_point_code);
String task_id = IdUtil.getSnowflake(1, 1).nextId() + "";
String qty_unit_id = "";
String endArea_type = "";
String bill_type = "";
WQLObject iosTable = WQLObject.getWQLObject("ST_IVT_regionIO");
//如果给了终点更新入库单据给pc、手持调用
if (StrUtil.isNotEmpty(next_point_code)) {
String iostorinv_id = form.getString("iostorinv_id");
if (StrUtil.isEmpty(iostorinv_id)) {
throw new BadRequestException("入库单据号不能为空!");
}
JSONObject IosObj = iosTable.query("iostorinv_id='" + iostorinv_id + "'").uniqueResult(0);
IosObj.put("bill_status", "20");
iosTable.update(IosObj);
if (StrUtil.isEmpty(next_point_code)) {
// 终点为空需要找终点
JSONObject param = new JSONObject();
param.put("start_point_code",start_point_code);
JSONObject endPoint = this.findEndPoint(param);
next_point_code = endPoint.getString("next_point_code");
}
String task_status = TaskStatusEnum.START_AND_POINT.getCode();
PointDto nextPoint = pointService.findByCode(next_point_code);
//终点点加锁
WQLObject pointTable = WQLObject.getWQLObject("sch_base_point");
JSONObject endPointObj = pointTable.query("point_code='" + next_point_code + "'").uniqueResult(0);
endPointObj.put("lock_type", "01");
pointTable.update(endPointObj);
CodeUtil.getNewCode("TASK_CODE");
// 创建任务
PointService pointService = SpringContextHolder.getBean(PointService.class);
JSONObject taskObj = new JSONObject();
CodeUtil.getNewCode("TASK_CODE");
String task_id = IdUtil.getSnowflake(1, 1).nextId() + "";
taskObj.put("task_id", task_id);
taskObj.put("taskdtl_id", task_id);
taskObj.put("task_code", CodeUtil.getNewCode("TASK_CODE"));
taskObj.put("task_type", "01");
taskObj.put("vehicle_type", vehicle_type);
taskObj.put("taskdtl_type", "01");
taskObj.put("acs_task_type", "1");
taskObj.put("task_status", task_status);
taskObj.put("task_status", TaskStatusEnum.START_AND_POINT.getCode());
taskObj.put("start_point_code", start_point_code);
PointDto startPoint = pointService.findByCode(start_point_code);
taskObj.put("start_area", startPoint.getRegion_id());
taskObj.put("request_param", form.toJSONString());
taskObj.put("next_point_code", next_point_code);
PointDto nextPoint = pointService.findByCode(next_point_code);
taskObj.put("next_area", nextPoint.getRegion_id());
taskObj.put("vehicle_code", vehicle_code);
taskObj.put("handle_class", THIS_CLASS);
@@ -282,4 +279,38 @@ public class SendMaterialTask extends AbstractAcsTask {
}
@Transactional
public JSONObject findEndPoint(JSONObject json) {
String start_point_code = json.getString("start_point_code");
WQLObject regionTab = WQLObject.getWQLObject("SCH_BASE_Region");
// 根据起点判断是什么区域 然后要入到什么区
PointDto startDto = SpringContextHolder.getBean(PointService.class).findByCode(start_point_code);
if (ObjectUtil.isEmpty(startDto)) throw new BadRequestException("起点点位不存在");
JSONObject jsonStartRegion = regionTab.query("region_id = '" + startDto.getRegion_id() + "'").uniqueResult(0);
/*
* 物料入库业务目前只有1个业务如果区域不正确则报错
* 1.共挤线 --> 养生区A
*/
String next_point_code = "";
if (StrUtil.equals(jsonStartRegion.getString("region_code"),RegionTypeEnum.GJQY.getCode())) {
JSONObject map = new JSONObject();
map.put("flag", "2");
map.put("region_code", RegionTypeEnum.YSQA.getCode());
JSONObject jsonEndPoint = WQL.getWO("ST_REGION_IN_01").addParamMap(map).process().uniqueResult(0);
if (ObjectUtil.isEmpty(jsonEndPoint)) throw new BadRequestException("仓位不足");
next_point_code = jsonEndPoint.getString("point_code");
} else {
throw new BadRequestException("业务类型错误");
}
JSONObject resuft = new JSONObject();
resuft.put("next_point_code",next_point_code);
return resuft;
}
}

View File

@@ -7,6 +7,9 @@ import com.alibaba.fastjson.JSON;
import lombok.RequiredArgsConstructor;
import org.nl.exception.BadRequestException;
import org.nl.modules.system.util.CodeUtil;
import org.nl.utils.SpringContextHolder;
import org.nl.wms.pdm.service.DeviceService;
import org.nl.wms.pdm.service.dto.DeviceDto;
import org.nl.wms.sch.tasks.SendMaterialTask;
import org.nl.wms.st.inbill.service.RegionioInService;
import org.nl.wms.st.inbill.service.dto.RegionioDto;
@@ -187,13 +190,17 @@ public class RegionioInServiceImpl implements RegionioInService {
@Transactional(rollbackFor = Exception.class)
public void createTask(JSONObject jsonObject) {
String iostorinv_id = jsonObject.getString("iostorinv_id");
WQLObject wo = WQLObject.getWQLObject("ST_IVT_regionIO");
WQLObject orderTab = WQLObject.getWQLObject("mps_bd_produceshiftorder");
JSONObject jsonIn = wo.query("iostorinv_id = '" + iostorinv_id + "'").uniqueResult(0);
String start_point_code = jsonIn.getString("start_point_code");
// 准备参数 并调用入库处理类中的创建任务方法
JSONObject form = new JSONObject();
form.put("vehicle_code", jsonIn.getString("vehicle_code"));
form.put("start_point_code", jsonIn.getString("start_point_code"));
form.put("start_point_code", start_point_code);
form.put("next_point_code", jsonIn.getString("end_point_code"));
form.put("material_id", jsonIn.getString("material_id"));
form.put("qty", jsonIn.getString("qty"));
@@ -201,6 +208,17 @@ public class RegionioInServiceImpl implements RegionioInService {
form.put("create_mode", jsonIn.getString("create_mode"));
form.put("pcsn", jsonIn.getString("pcsn"));
form.put("iostorinv_id", iostorinv_id);
// 根据起点点位 找到对应设备,根据设备找到对应工单,根据工单获取载具类型
String device_code = start_point_code.substring(0, start_point_code.indexOf("-"));
DeviceService deviceBean = SpringContextHolder.getBean(DeviceService.class);
DeviceDto deviceDto = deviceBean.findByCode(device_code);
if (ObjectUtil.isEmpty(deviceDto)) throw new BadRequestException("此设备不存在");
JSONObject jsonOrder = orderTab.query("device_id = '" + deviceDto.getDevice_id() + "' and order_status = '02' and is_delete = '0'").uniqueResult(0);
if (ObjectUtil.isEmpty(jsonOrder)) throw new BadRequestException("此设备未在生产中或不存在");
form.put("vehicle_type", jsonOrder.getString("vehicle_type"));
SendMaterialTask sendMaterialTask = new SendMaterialTask();
String task_id = sendMaterialTask.createTask(form);

View File

@@ -23,6 +23,7 @@
输入.end_point_code TYPEAS s_string
输入.start_region_code TYPEAS s_string
输入.end_region_code TYPEAS s_string
输入.region_code TYPEAS s_string
[临时表]
--这边列出来的临时表就会在运行期动态创建
@@ -113,3 +114,26 @@
ENDSELECT
ENDPAGEQUERY
ENDIF
IF 输入.flag = "2"
QUERY
SELECT
point.*
FROM
sch_base_point point
LEFT JOIN SCH_BASE_Region region ON point.region_id = region.region_id
WHERE
point.point_status = '00'
AND point.lock_type = '00'
AND point.is_used = '1'
AND point.is_delete = '0'
OPTION 输入.region_code <> ""
region.region_code = 输入.region_code
ENDOPTION
order by point.point_code DESC
ENDSELECT
ENDQUERY
ENDIF

View File

@@ -18,12 +18,15 @@
输入.bill_status TYPEAS s_string
输入.vehicle_code TYPEAS s_string
输入.material_code TYPEAS s_string
输入.material_id TYPEAS s_string
输入.pcsn TYPEAS s_string
输入.start_point_code TYPEAS s_string
输入.end_point_code TYPEAS s_string
输入.start_region_code TYPEAS s_string
输入.end_region_code TYPEAS s_string
输入.region_id TYPEAS s_string
输入.vehicle_type TYPEAS s_string
输入.region_code TYPEAS s_string
[临时表]
--这边列出来的临时表就会在运行期动态创建
@@ -145,3 +148,33 @@
ENDSELECT
ENDPAGEQUERY
ENDIF
IF 输入.flag = "3"
PAGEQUERY
SELECT
ivt.*
FROM
ST_IVT_StructIvt ivt
LEFT JOIN sch_base_point point ON point.point_id = ivt.struct_id
LEFT JOIN SCH_BASE_Region region ON region.region_id = point.region_id
WHERE
point.lock_type = '00'
AND point.point_status = '02'
OPTION 输入.vehicle_type <> ""
point.vehicle_type = 输入.vehicle_type
ENDOPTION
OPTION 输入.region_code <> ""
region.region_code = 输入.region_code
ENDOPTION
OPTION 输入.material_id <> ""
ivt.material_id = 输入.material_id
ENDOPTION
order by point.point_code DESC
ENDSELECT
ENDPAGEQUERY
ENDIF

View File

@@ -16,6 +16,7 @@
输入.flag TYPEAS s_string
输入.vehicle_qty TYPEAS s_string
输入.region_code TYPEAS s_string
输入.vehicle_type TYPEAS s_string
[临时表]
--这边列出来的临时表就会在运行期动态创建
@@ -54,6 +55,10 @@
region.region_code = 输入.region_code
ENDOPTION
OPTION 输入.vehicle_type <> ""
point.vehicle_type = 输入.vehicle_type
ENDOPTION
order by point.vehicle_qty DESC
ENDSELECT
@@ -61,6 +66,27 @@
ENDIF
IF 输入.flag = "2"
QUERY
SELECT
point.*
FROM
sch_base_point point
LEFT JOIN SCH_BASE_Region region ON point.region_id = region.region_id
WHERE
point.lock_type = '00'
AND IFNULL(point.vehicle_qty,0) = '0'
OPTION 输入.region_code <> ""
region.region_code = 输入.region_code
ENDOPTION
order by point.vehicle_qty DESC
ENDSELECT
ENDQUERY
ENDIF
IF 输入.flag = "3"
QUERY
SELECT
point.*

View File

@@ -15,6 +15,7 @@
#################################################
输入.flag TYPEAS s_string
输入.vehicle_qty TYPEAS s_string
输入.vehicle_type TYPEAS s_string
输入.region_code TYPEAS s_string
[临时表]
@@ -55,12 +56,42 @@
region.region_code = 输入.region_code
ENDOPTION
OPTION 输入.vehicle_type <> ""
point.vehicle_type = 输入.vehicle_type
ENDOPTION
order by point.vehicle_qty ASC
ENDSELECT
ENDQUERY
ENDIF
IF 输入.flag = "3"
QUERY
SELECT
point.*
FROM
sch_base_point point
LEFT JOIN SCH_BASE_Region region ON point.region_id = region.region_id
WHERE
point.lock_type = '00'
AND point.point_status = '01'
AND IFNULL(point.vehicle_qty,0) == 输入.vehicle_qty
OPTION 输入.region_code <> ""
region.region_code = 输入.region_code
ENDOPTION
OPTION 输入.vehicle_type <> ""
point.vehicle_type = 输入.vehicle_type
ENDOPTION
order by point.point_code DESC
ENDSELECT
ENDQUERY
ENDIF
IF 输入.flag = "2"
QUERY
SELECT