@ -10,20 +10,25 @@ import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j ;
import org.nl.modules.common.exception.BadRequestException ;
import org.nl.modules.common.utils.SecurityUtils ;
import org.nl.modules.system.util.CodeUtil ;
import org.nl.modules.wql.WQL ;
import org.nl.modules.wql.core.bean.WQLObject ;
import org.nl.modules.wql.util.SpringContextHolder ;
import org.nl.wms.basedata.eum.StandStatus ;
import org.nl.wms.basedata.eum.TrueOrFalse ;
import org.nl.wms.basedata.eum.VehicleType ;
import org.nl.wms.common.PickType ;
import org.nl.wms.das.service.GroupUpdateRecordService ;
import org.nl.wms.das.service.dto.GroupUpdateRecordDto ;
import org.nl.wms.ext.acs.service.WmsToAcsService ;
import org.nl.wms.pda.service.PdaService ;
import org.nl.wms.sch.manage.CreateMode ;
import org.nl.wms.sch.manage.PointStatus ;
import org.nl.wms.sch.manage.Region ;
import org.nl.wms.sch.manage.* ;
import org.nl.wms.sch.task.call.empty.FJCallEmptyTask ;
import org.nl.wms.sch.task.call.empty.HLCallEmptyTask ;
import org.nl.wms.sch.task.call.empty.YZCallEmptyTask ;
import org.nl.wms.sch.task.call.material.FJCallMaterialTask ;
import org.nl.wms.sch.task.call.material.YZCallMaterialTask ;
import org.nl.wms.sch.task.p2p.PDATask ;
import org.nl.wms.sch.task.send.empty.FJSendEmptyTask ;
import org.nl.wms.sch.task.send.empty.YZSendEmptyTask ;
import org.nl.wms.sch.task.send.material.FJSendMaterialTask ;
@ -33,6 +38,8 @@ import org.nl.wms.sch.task.util.TaskUtils;
import org.springframework.stereotype.Service ;
import org.springframework.transaction.annotation.Transactional ;
import java.math.BigDecimal ;
/ * *
* @author 张江玮
* @date 2022 / 12 / 02 10 : 04
@ -64,6 +71,8 @@ public class PdaServiceImpl implements PdaService {
private final WmsToAcsService wmsToAcsService ;
private final GroupUpdateRecordService groupUpdateRecordService ;
@Override
public JSONArray region ( String func ) {
switch ( func ) {
@ -615,4 +624,702 @@ public class PdaServiceImpl implements PdaService {
method_param . put ( "create_name" , SecurityUtils . getCurrentNickName ( ) ) ;
yzCallMaterialTask . createTask ( method_param ) ;
}
@Override
@Transactional ( rollbackFor = Exception . class )
public void manualExceptionHandlingTask ( JSONObject param ) {
WQLObject taskTab = WQLObject . getWQLObject ( "sch_base_task" ) ;
String taskId = param . getString ( "task_id" ) ;
// param中包含两个信息:task_id, target_point(可为空)
JSONObject taskObject = taskTab . query ( "task_id = '" + taskId + "'" ) . uniqueResult ( 0 ) ;
if ( ObjectUtil . isEmpty ( taskObject ) ) {
throw new BadRequestException ( "任务「" + taskId + "」不存在!" ) ;
}
if ( ObjectUtil . isNotEmpty ( param . getString ( "end_point" ) ) ) {
taskObject . put ( "point_code2" , param . getString ( "end_point" ) ) ;
}
taskObject . put ( "task_status" , TaskStatus . FINISHED . value ( ) ) ;
TaskUtils . addCurrentUpdateColum ( taskObject ) ;
taskTab . update ( taskObject ) ;
log . info ( "任务「{}」已经更新目的地「{}」并完成" , taskId , param . getString ( "end_point" ) ) ;
}
@Override
public JSONArray manualExceptionHandlingTaskShow ( JSONObject param ) {
return WQL
. getWO ( "PDA" )
. addParam ( "flag" , "4" )
. addParam ( "region_code" , param . getString ( "region_code" ) )
. process ( )
. getResultJSONArray ( 0 ) ;
}
@Override
@Transactional ( rollbackFor = Exception . class )
public void manualMixingMoveTask ( JSONObject param ) {
WQLObject vd_table = WQLObject . getWQLObject ( "st_ivt_vehicle_detail" ) ;
WQLObject pointTab = WQLObject . getWQLObject ( "sch_base_point" ) ;
WQLObject taskTab = WQLObject . getWQLObject ( "sch_base_task" ) ;
// param: point_code, vehicle_code, weight
String target_point = "KLXNK" ;
String pointCode = param . getString ( "point_code" ) ;
String vehicleCode = param . getString ( "vehicle_code" ) ;
String weight = param . getString ( "weight" ) ;
if ( ObjectUtil . isEmpty ( vehicleCode ) ) {
throw new BadRequestException ( "载具编码不能为空!" ) ;
}
if ( ObjectUtil . isEmpty ( weight ) ) {
throw new BadRequestException ( "重量不能为空!" ) ;
}
// 检测同个点位是否存在任务
JSONObject tasking = taskTab . query ( "point_code1 = '" + pointCode + "' AND task_status < '7' AND is_delete = '0'" ) . uniqueResult ( 0 ) ;
if ( ObjectUtil . isNotEmpty ( tasking ) ) {
throw new BadRequestException ( "点位「" + pointCode + "」存在任务『" + tasking . getString ( "task_code" ) + "』" ) ;
}
// 组盘
// 相同组盘信息,先标记删除
JSONObject vd_update = new JSONObject ( ) ;
vd_update . put ( "is_delete" , "1" ) ;
vd_update . put ( "update_optid" , ACSSystem . id ) ;
vd_update . put ( "update_optname" , ACSSystem . nick_name ) ;
String now = DateUtil . now ( ) ;
vd_update . put ( "update_time" , now ) ;
vd_table . update ( vd_update , "vehicle_type = '1' AND vehicle_code = '" + vehicleCode + "' AND is_delete = '0'" ) ;
// 获取点位
JSONObject point = pointTab . query ( "point_code = '" + pointCode + "'" ) . uniqueResult ( 0 ) ;
// 获取工单
JSONObject workorder = TaskUtils . hasWorkOrder ( point ) ;
// 创建任务,状态为完成
JSONObject vd = new JSONObject ( ) ;
vd . put ( "vd_id" , IdUtil . getSnowflake ( 1L , 1L ) . nextId ( ) ) ;
vd . put ( "vehicle_type" , VehicleType . CUP . value ( ) ) ;
vd . put ( "vehicle_code" , vehicleCode ) ;
vd . put ( "material_id" , workorder . getString ( "material_id" ) ) ;
vd . put ( "weight" , weight ) ;
vd . put ( "workorder_id" , workorder . getString ( "workorder_id" ) ) ;
vd . put ( "point_code" , pointCode ) ;
vd . put ( "create_id" , SecurityUtils . getCurrentUserId ( ) ) ;
vd . put ( "create_name" , SecurityUtils . getCurrentNickName ( ) ) ;
vd . put ( "create_time" , now ) ;
vd . put ( "is_in_kiln" , "0" ) ;
vd . put ( "stand_status" , StandStatus . STANDING . value ( ) ) ;
vd . put ( "mix_num" , "0" ) ; // todo
vd_table . insert ( vd ) ;
param . put ( "vd" , vd ) ;
// 创建任务
JSONObject task = new JSONObject ( ) ;
task . put ( "task_id" , IdUtil . getSnowflake ( ) . nextId ( ) ) ;
task . put ( "task_code" , CodeUtil . getNewCode ( "TASK_CODE" ) ) ;
task . put ( "task_name" , "混料区人工送料" ) ;
task . put ( "task_type" , TaskType . PDA_HN . value ( ) ) ;
task . put ( "task_status" , TaskStatus . FINISHED . value ( ) ) ;
task . put ( "point_code1" , pointCode ) ;
task . put ( "point_code2" , target_point ) ;
task . put ( "group_id" , vd . getString ( "vd_id" ) ) ;
task . put ( "material_id" , workorder . getString ( "material_id" ) ) ;
task . put ( "vehicle_type" , VehicleType . CUP . value ( ) ) ;
task . put ( "vehicle_code" , vehicleCode ) ;
task . put ( "priority" , "1" ) ;
task . put ( "is_auto_issue" , "0" ) ;
task . put ( "handle_class" , this . getClass ( ) . getName ( ) ) ;
task . put ( "create_mode" , CreateMode . SCCJ . value ( ) ) ;
task . put ( "request_param" , param ) ;
task . put ( "create_id" , SecurityUtils . getCurrentUserId ( ) ) ;
task . put ( "create_name" , SecurityUtils . getCurrentNickName ( ) ) ;
task . put ( "create_time" , DateUtil . now ( ) ) ;
taskTab . insert ( task ) ;
// 混碾工单需要加上重量真实值
JSONObject workorder_update = new JSONObject ( ) ;
workorder_update . put ( "real_qty" , workorder . getIntValue ( "real_qty" ) + param . getIntValue ( "weight" ) ) ;
TaskUtils . addACSUpdateColum ( workorder_update ) ;
WQLObject . getWQLObject ( "pdm_bd_workorder" ) . update ( workorder_update , "workorder_id = " + workorder . getString ( "workorder_id" ) ) ;
}
@Override
public JSONArray getMixingPointList ( ) {
return WQL
. getWO ( "PDA" )
. addParam ( "flag" , "5" )
. addParam ( "region_code" , "HL" )
. process ( )
. getResultJSONArray ( 0 ) ;
}
@Override
public JSONArray getMixingTaskList ( ) {
return getTaskList ( TaskType . PDA_HN . value ( ) ) ;
}
public JSONArray getTaskList ( String task_type ) {
return WQL
. getWO ( "PDA" )
. addParam ( "flag" , "6" )
. addParam ( "task_type" , task_type )
. addParam ( "handle_class" , "org.nl.wms.pda.service.impl.PdaServiceImpl" )
. process ( )
. getResultJSONArray ( 0 ) ;
}
@Override
public JSONArray getPositionList ( ) {
return WQL
. getWO ( "PDA" )
. addParam ( "flag" , "9" )
. addParam ( "types" , "('2','3')" )
. process ( )
. getResultJSONArray ( 0 ) ;
}
@Override
@Transactional ( rollbackFor = Exception . class )
public void transferCreateTask ( JSONObject param ) {
log . info ( "请求参数:{}" , param ) ;
WQLObject vd_table = WQLObject . getWQLObject ( "st_ivt_vehicle_detail" ) ;
WQLObject pointTab = WQLObject . getWQLObject ( "sch_base_point" ) ;
WQLObject taskTab = WQLObject . getWQLObject ( "sch_base_task" ) ;
// param: start_point, end_point, vehicle_code, is_agv
String startPoint = param . getString ( "start_point" ) ;
String endPoint = param . getString ( "end_point" ) ;
if ( startPoint . equals ( endPoint ) ) {
throw new BadRequestException ( "起点和终点不能一样" ) ;
}
String vehicleCode = param . getString ( "vehicle_code" ) ;
String isAgv = param . getString ( "is_agv" ) ;
JSONObject point1 = pointTab . query ( "point_code = '" + startPoint + "'" ) . uniqueResult ( 0 ) ;
JSONObject point2 = pointTab . query ( "point_code = '" + endPoint + "'" ) . uniqueResult ( 0 ) ;
point2 . put ( "vehicle_type" , point1 . getString ( "vehicle_type" ) ) ;
point2 . put ( "vehicle_code" , point1 . getString ( "vehicle_code" ) ) ;
point2 . put ( "point_status" , "1" ) ;
pointTab . update ( point2 ) ;
// 校验任务
JSONObject tasking = taskTab . query ( "(point_code1 = '" + startPoint + "' or point_code2 = '" + endPoint + "') " +
"AND task_status < '7' AND is_delete = '0'" ) . uniqueResult ( 0 ) ;
if ( ObjectUtil . isNotEmpty ( tasking ) ) {
throw new BadRequestException ( "已存在任务" ) ;
}
// 获取组盘
JSONObject groupInfo = vd_table . query ( "vehicle_type = '1' AND vehicle_code = '" + vehicleCode + "' AND is_delete = '0'" ) . uniqueResult ( 0 ) ;
if ( ObjectUtil . isEmpty ( groupInfo ) ) {
throw new BadRequestException ( "料盅「" + vehicleCode + "」的组盘信息不存在" ) ;
}
JSONObject taskParam = new JSONObject ( ) ;
taskParam . put ( "point1" , startPoint ) ;
taskParam . put ( "point2" , endPoint ) ;
taskParam . put ( "vehicle_type" , VehicleType . CUP . value ( ) ) ;
taskParam . put ( "vehicle_code" , vehicleCode ) ;
taskParam . put ( "create_mode" , CreateMode . SCCJ . value ( ) ) ;
taskParam . put ( "group_id" , groupInfo . getString ( "vd_id" ) ) ;
if ( "1" . equals ( isAgv ) ) {
PDATask pdaTask = SpringContextHolder . getBean ( PDATask . class ) ;
pdaTask . createTask ( taskParam ) ;
} else {
// 不是AGV就是人工搬运。
taskParam . put ( "task_id" , IdUtil . getSnowflake ( ) . nextId ( ) ) ;
taskParam . put ( "task_code" , CodeUtil . getNewCode ( "TASK_CODE" ) ) ;
taskParam . put ( "task_name" , "人工泥料转移" ) ;
taskParam . put ( "task_type" , TaskType . PDA_MATERIAL_TRANSFER . value ( ) ) ;
taskParam . put ( "task_status" , TaskStatus . FINISHED . value ( ) ) ;
taskParam . put ( "material_id" , groupInfo . getString ( "material_id" ) ) ;
taskParam . put ( "priority" , "1" ) ;
taskParam . put ( "is_auto_issue" , "0" ) ;
taskParam . put ( "handle_class" , this . getClass ( ) . getName ( ) ) ;
taskParam . put ( "request_param" , param ) ;
taskParam . put ( "create_id" , SecurityUtils . getCurrentUserId ( ) ) ;
taskParam . put ( "create_name" , SecurityUtils . getCurrentNickName ( ) ) ;
taskParam . put ( "create_time" , DateUtil . now ( ) ) ;
taskTab . insert ( taskParam ) ;
}
log . info ( "手持任务创建成功" ) ;
}
@Override
public JSONArray transferTaskShow ( ) {
return WQL
. getWO ( "PDA" )
. addParam ( "flag" , "7" )
. process ( )
. getResultJSONArray ( 0 ) ;
}
@Override
public JSONArray suppressStartPointList ( ) {
return WQL
. getWO ( "PDA" )
. addParam ( "flag" , "8" )
. process ( )
. getResultJSONArray ( 0 ) ;
}
@Override
public void suppressCreateTask ( JSONObject param ) {
log . info ( "请求参数:{}" , param ) ;
WQLObject vd_table = WQLObject . getWQLObject ( "st_ivt_vehicle_detail" ) ;
WQLObject pointTab = WQLObject . getWQLObject ( "sch_base_point" ) ;
WQLObject taskTab = WQLObject . getWQLObject ( "sch_base_task" ) ;
// param: start_point, end_point, vehicle_code
String startPoint = param . getString ( "start_point" ) ;
String endPoint = param . getString ( "end_point" ) ;
String vehicleCode = param . getString ( "vehicle_code" ) ;
// 校验是否创建过任务
JSONObject tasking = taskTab . query ( "(point_code1 = '" + startPoint + "' or point_code2 = '" + endPoint + "') " +
"AND task_status < '7' AND is_delete = '0'" ) . uniqueResult ( 0 ) ;
if ( ObjectUtil . isNotEmpty ( tasking ) ) {
throw new BadRequestException ( "已存在任务" ) ;
}
// 创建人工搬运任务,任务状态是完成,点位上记录的数据需要变动
JSONObject point1 = pointTab . query ( "point_code = '" + startPoint + "'" ) . uniqueResult ( 0 ) ;
JSONObject point2 = pointTab . query ( "point_code = '" + endPoint + "'" ) . uniqueResult ( 0 ) ;
// 获取组盘信息
JSONObject vd = vd_table . query ( "vehicle_type = '1' AND vehicle_code = '" + vehicleCode + "' AND is_delete = '0'" ) . uniqueResult ( 0 ) ;
if ( ObjectUtil . isEmpty ( vd ) ) {
throw new BadRequestException ( "料盅「" + vehicleCode + "」的组盘信息不存在" ) ;
}
// 获取工单
JSONObject workorder = TaskUtils . hasWorkOrder ( point2 ) ;
// 创建任务
JSONObject task = new JSONObject ( ) ;
task . put ( "task_id" , IdUtil . getSnowflake ( ) . nextId ( ) ) ;
task . put ( "task_code" , CodeUtil . getNewCode ( "TASK_CODE" ) ) ;
task . put ( "task_name" , "人工布料机上料" ) ;
task . put ( "task_type" , TaskType . PDA_PRESS_UP . value ( ) ) ;
task . put ( "task_status" , TaskStatus . FINISHED . value ( ) ) ;
task . put ( "point_code1" , startPoint ) ;
task . put ( "point_code2" , endPoint ) ;
task . put ( "group_id" , vd . getString ( "vd_id" ) ) ;
task . put ( "material_id" , workorder . getString ( "material_id" ) ) ;
task . put ( "vehicle_type" , VehicleType . CUP . value ( ) ) ;
task . put ( "vehicle_code" , vehicleCode ) ;
task . put ( "priority" , "1" ) ;
task . put ( "is_auto_issue" , "0" ) ;
task . put ( "handle_class" , this . getClass ( ) . getName ( ) ) ;
task . put ( "create_mode" , CreateMode . SCCJ . value ( ) ) ;
task . put ( "request_param" , param ) ;
task . put ( "create_id" , SecurityUtils . getCurrentUserId ( ) ) ;
task . put ( "create_name" , SecurityUtils . getCurrentNickName ( ) ) ;
task . put ( "create_time" , DateUtil . now ( ) ) ;
taskTab . insert ( task ) ;
// 点位数据更新
point1 . put ( "task_code" , "" ) ;
point1 . put ( "vehicle_type" , "" ) ;
point1 . put ( "vehicle_code" , "" ) ;
point1 . put ( "point_status" , PointStatus . EMPTY . value ( ) ) ;
TaskUtils . addCurrentUpdateColum ( point1 ) ;
pointTab . update ( point1 ) ;
point2 . put ( "task_code" , "" ) ;
point2 . put ( "vehicle_type" , task . getString ( "vehicle_type" ) ) ;
point2 . put ( "vehicle_code" , task . getString ( "vehicle_code" ) ) ;
point2 . put ( "point_status" , PointStatus . NOT_EMPTY . value ( ) ) ;
TaskUtils . addCurrentUpdateColum ( point2 ) ;
pointTab . update ( point2 ) ;
log . info ( "布料机叫料手持任务创建成功" ) ;
}
@Override
public JSONArray suppressDownPointList ( ) {
return WQL
. getWO ( "PDA" )
. addParam ( "flag" , "9" )
. addParam ( "types" , "('1')" )
. process ( )
. getResultJSONArray ( 0 ) ;
}
@Override
public void suppressDownCreateTask ( JSONObject param ) {
log . info ( "请求参数:{}" , param ) ;
WQLObject vd_table = WQLObject . getWQLObject ( "st_ivt_vehicle_detail" ) ;
WQLObject pointTab = WQLObject . getWQLObject ( "sch_base_point" ) ;
WQLObject taskTab = WQLObject . getWQLObject ( "sch_base_task" ) ;
// param: start_point, vehicle_code, qty, is_full
String startPoint = param . getString ( "start_point" ) ;
String endPoint = "YQXNK" ;
String vehicleCode = param . getString ( "vehicle_code" ) ;
String qty = param . getString ( "qty" ) ;
String isFull = param . getString ( "is_full" ) ;
String weight = "0" ;
// 判断是否有任务
JSONObject tasking = taskTab . query ( "(point_code1 = '" + startPoint + "' or point_code2 = '" + endPoint + "') " +
"AND task_status < '7' AND is_delete = '0'" ) . uniqueResult ( 0 ) ;
if ( ObjectUtil . isNotEmpty ( tasking ) ) {
throw new BadRequestException ( "已存在任务" ) ;
}
// 组盘
// 相同组盘信息,先标记删除
JSONObject vd_update = new JSONObject ( ) ;
vd_update . put ( "is_delete" , "1" ) ;
vd_update . put ( "update_optid" , ACSSystem . id ) ;
vd_update . put ( "update_optname" , ACSSystem . nick_name ) ;
String now = DateUtil . now ( ) ;
vd_update . put ( "update_time" , now ) ;
vd_table . update ( vd_update , "vehicle_type = '2' AND vehicle_code = '" + vehicleCode + "' AND is_delete = '0'" ) ;
// 获取点位
JSONObject point1 = pointTab . query ( "point_code = '" + startPoint + "'" ) . uniqueResult ( 0 ) ;
JSONObject point2 = pointTab . query ( "point_code = '" + endPoint + "'" ) . uniqueResult ( 0 ) ;
// 获取工单
JSONObject workorder = TaskUtils . hasWorkOrder ( point1 ) ;
JSONObject vd = new JSONObject ( ) ;
vd . put ( "vd_id" , IdUtil . getSnowflake ( 1 , 1 ) . nextId ( ) ) ;
vd . put ( "vehicle_type" , "2" ) ;
vd . put ( "vehicle_code" , vehicleCode ) ;
vd . put ( "material_id" , workorder . getString ( "material_id" ) ) ;
vd . put ( "qty" , qty ) ;
vd . put ( "weight" , weight ) ;
vd . put ( "is_full" , isFull ) ;
vd . put ( "workorder_id" , workorder . getString ( "workorder_id" ) ) ;
vd . put ( "point_code" , endPoint ) ; // 这里换成虚拟库位置
vd . put ( "create_id" , ACSSystem . id ) ;
vd . put ( "create_name" , ACSSystem . nick_name ) ;
vd . put ( "create_time" , DateUtil . now ( ) ) ;
vd . put ( "is_delete" , TrueOrFalse . FALSE . value ( ) ) ;
vd_table . insert ( vd ) ;
JSONObject pn = TaskUtils . buildPN ( PickType . YZ , vd . getLongValue ( "qty" ) , vd . getLongValue ( "workorder_id" ) ) ;
WQLObject . getWQLObject ( "das_produce_number" ) . insert ( pn ) ;
// 创建任务
JSONObject task = new JSONObject ( ) ;
task . put ( "task_id" , IdUtil . getSnowflake ( ) . nextId ( ) ) ;
task . put ( "task_code" , CodeUtil . getNewCode ( "TASK_CODE" ) ) ;
task . put ( "task_name" , "人工压机下料" ) ;
task . put ( "task_type" , TaskType . PDA_PRESS_DOWN . value ( ) ) ;
task . put ( "task_status" , TaskStatus . FINISHED . value ( ) ) ;
task . put ( "point_code1" , startPoint ) ;
task . put ( "point_code2" , endPoint ) ;
task . put ( "group_id" , vd . getString ( "vd_id" ) ) ;
task . put ( "material_id" , workorder . getString ( "material_id" ) ) ;
task . put ( "vehicle_type" , VehicleType . STEEL_TRAY . value ( ) ) ;
task . put ( "vehicle_code" , vehicleCode ) ;
task . put ( "priority" , "1" ) ;
task . put ( "is_auto_issue" , "0" ) ;
task . put ( "handle_class" , this . getClass ( ) . getName ( ) ) ;
task . put ( "create_mode" , CreateMode . SCCJ . value ( ) ) ;
task . put ( "request_param" , param ) ;
task . put ( "create_id" , SecurityUtils . getCurrentUserId ( ) ) ;
task . put ( "create_name" , SecurityUtils . getCurrentNickName ( ) ) ;
task . put ( "create_time" , DateUtil . now ( ) ) ;
taskTab . insert ( task ) ;
// 起点清空,终点赋值。
point1 . put ( "task_code" , "" ) ;
point1 . put ( "vehicle_type" , "" ) ;
point1 . put ( "vehicle_code" , "" ) ;
point1 . put ( "point_status" , PointStatus . EMPTY . value ( ) ) ;
TaskUtils . addCurrentUpdateColum ( point1 ) ;
pointTab . update ( point1 ) ;
point2 . put ( "task_code" , "" ) ;
point2 . put ( "vehicle_type" , task . getString ( "vehicle_type" ) ) ;
point2 . put ( "vehicle_code" , task . getString ( "vehicle_code" ) ) ;
point2 . put ( "point_status" , PointStatus . NOT_EMPTY . value ( ) ) ;
TaskUtils . addCurrentUpdateColum ( point2 ) ;
pointTab . update ( point2 ) ;
log . info ( "压机下料手持任务创建成功" ) ;
}
@Override
public JSONArray suppressDownShow ( ) {
return getTaskList ( TaskType . PDA_PRESS_DOWN . value ( ) ) ;
}
@Override
public void kilnOutCreateTask ( JSONObject param ) {
log . info ( "请求参数:{}" , param ) ;
WQLObject vd_table = WQLObject . getWQLObject ( "st_ivt_vehicle_detail" ) ;
WQLObject pointTab = WQLObject . getWQLObject ( "sch_base_point" ) ;
WQLObject taskTab = WQLObject . getWQLObject ( "sch_base_task" ) ;
// JYHJ01DJ04
// param: vehicle_code
String startPoint = "JYHJ01DJ04" ;
String endPoint = "CYXNK" ;
String vehicleCode = param . getString ( "vehicle_code" ) ;
// 校验任务
JSONObject tasking = taskTab . query ( "(point_code1 = '" + startPoint + "' or point_code2 = '" + endPoint + "') " +
"AND task_status < '7' AND is_delete = '0'" ) . uniqueResult ( 0 ) ;
if ( ObjectUtil . isNotEmpty ( tasking ) ) {
throw new BadRequestException ( "已存在任务" ) ;
}
// 获取组盘 (此时是刚托盘)
JSONObject vd = vd_table . query ( "vehicle_type = '2' AND vehicle_code = '" + vehicleCode + "' AND is_delete = '0'" ) . uniqueResult ( 0 ) ;
if ( ObjectUtil . isEmpty ( vd ) ) {
throw new BadRequestException ( "钢托盘「" + vehicleCode + "」的组盘信息不存在" ) ;
}
vd . put ( "is_fire" , "1" ) ;
vd . put ( "is_in_kiln" , "0" ) ;
vd . put ( "point_code" , endPoint ) ;
vd_table . update ( vd ) ;
// 创建任务
JSONObject task = new JSONObject ( ) ;
task . put ( "task_id" , IdUtil . getSnowflake ( ) . nextId ( ) ) ;
task . put ( "task_code" , CodeUtil . getNewCode ( "TASK_CODE" ) ) ;
task . put ( "task_name" , "人工出窑任务" ) ;
task . put ( "task_type" , TaskType . PDA_OUT_KILN . value ( ) ) ;
task . put ( "task_status" , TaskStatus . FINISHED . value ( ) ) ;
task . put ( "point_code1" , startPoint ) ;
task . put ( "point_code2" , endPoint ) ;
task . put ( "group_id" , vd . getString ( "vd_id" ) ) ;
task . put ( "material_id" , vd . getString ( "material_id" ) ) ;
task . put ( "vehicle_type" , VehicleType . STEEL_TRAY . value ( ) ) ;
task . put ( "vehicle_code" , vehicleCode ) ;
task . put ( "priority" , "1" ) ;
task . put ( "is_auto_issue" , "0" ) ;
task . put ( "handle_class" , this . getClass ( ) . getName ( ) ) ;
task . put ( "create_mode" , CreateMode . SCCJ . value ( ) ) ;
task . put ( "request_param" , param ) ;
task . put ( "create_id" , SecurityUtils . getCurrentUserId ( ) ) ;
task . put ( "create_name" , SecurityUtils . getCurrentNickName ( ) ) ;
task . put ( "create_time" , DateUtil . now ( ) ) ;
taskTab . insert ( task ) ;
}
@Override
public void kilnMoveCreateTask ( JSONObject param ) {
log . info ( "请求参数:{}" , param ) ;
WQLObject vd_table = WQLObject . getWQLObject ( "st_ivt_vehicle_detail" ) ;
WQLObject pointTab = WQLObject . getWQLObject ( "sch_base_point" ) ;
WQLObject taskTab = WQLObject . getWQLObject ( "sch_base_task" ) ;
// param: start_point, vehicle_code
String startPoint = param . getString ( "start_point" ) ;
String vehicleCode = param . getString ( "vehicle_code" ) ;
String endPoint = "CYXNK" ;
JSONObject point1 = pointTab . query ( "point_code = '" + startPoint + "'" ) . uniqueResult ( 0 ) ;
// 判断是否有任务
JSONObject tasking = taskTab . query ( "(point_code1 = '" + startPoint + "' or point_code2 = '" + endPoint + "') " +
"AND task_status < '7' AND is_delete = '0'" ) . uniqueResult ( 0 ) ;
if ( ObjectUtil . isNotEmpty ( tasking ) ) {
throw new BadRequestException ( "已存在任务" ) ;
}
// 获取组盘 (此时是刚托盘)
JSONObject vd = vd_table . query ( "vehicle_type = '2' AND vehicle_code = '" + vehicleCode + "' AND is_delete = '0'" ) . uniqueResult ( 0 ) ;
if ( ObjectUtil . isEmpty ( vd ) ) {
throw new BadRequestException ( "钢托盘「" + vehicleCode + "」的组盘信息不存在" ) ;
}
vd . put ( "point_code" , endPoint ) ; // 更新到虚拟库
vd_table . update ( vd ) ;
// 生成完成的任务
JSONObject task = new JSONObject ( ) ;
task . put ( "task_id" , IdUtil . getSnowflake ( ) . nextId ( ) ) ;
task . put ( "task_code" , CodeUtil . getNewCode ( "TASK_CODE" ) ) ;
task . put ( "task_name" , "人工移库任务" ) ;
task . put ( "task_type" , TaskType . PDA_VEHICLE_TRANSFER . value ( ) ) ;
task . put ( "task_status" , TaskStatus . FINISHED . value ( ) ) ;
task . put ( "point_code1" , startPoint ) ;
task . put ( "point_code2" , endPoint ) ;
task . put ( "group_id" , vd . getString ( "vd_id" ) ) ;
task . put ( "material_id" , vd . getString ( "material_id" ) ) ;
task . put ( "vehicle_type" , VehicleType . STEEL_TRAY . value ( ) ) ;
task . put ( "vehicle_code" , vehicleCode ) ;
task . put ( "priority" , "1" ) ;
task . put ( "is_auto_issue" , "0" ) ;
task . put ( "handle_class" , this . getClass ( ) . getName ( ) ) ;
task . put ( "create_mode" , CreateMode . SCCJ . value ( ) ) ;
task . put ( "request_param" , param ) ;
task . put ( "create_id" , SecurityUtils . getCurrentUserId ( ) ) ;
task . put ( "create_name" , SecurityUtils . getCurrentNickName ( ) ) ;
task . put ( "create_time" , DateUtil . now ( ) ) ;
taskTab . insert ( task ) ;
// 起点清空
point1 . put ( "task_code" , "" ) ;
point1 . put ( "vehicle_type" , "" ) ;
point1 . put ( "vehicle_code" , "" ) ;
point1 . put ( "point_status" , PointStatus . EMPTY . value ( ) ) ;
TaskUtils . addCurrentUpdateColum ( point1 ) ;
}
@Override
public JSONArray kilnMovePointList ( ) {
return WQL
. getWO ( "PDA" )
. addParam ( "flag" , "5" )
. addParam ( "region_code" , "BCPHJ" )
. process ( )
. getResultJSONArray ( 0 ) ;
}
@Override
public JSONArray manualExceptionHandlingTaskList ( ) {
return WQL
. getWO ( "PDA" )
. addParam ( "flag" , "5" )
. addParam ( "region_code" , "XN" )
. process ( )
. getResultJSONArray ( 0 ) ;
}
@Override
public JSONArray suppressTaskShow ( ) {
return getTaskList ( TaskType . PDA_PRESS_UP . value ( ) ) ;
}
@Override
@Transactional ( rollbackFor = Exception . class )
public void MaterialReturn ( JSONObject param ) {
log . info ( "请求参数:{}" , param ) ;
WQLObject vd_table = WQLObject . getWQLObject ( "st_ivt_vehicle_detail" ) ;
WQLObject orderTab = WQLObject . getWQLObject ( "pdm_bd_workorder" ) ;
// param: vehicle_code
String vehicleCode = param . getString ( "vehicle_code" ) ;
JSONObject groupObj = vd_table . query ( "vehicle_code = '" + vehicleCode + "' AND vehicle_type = '1'" , "create_time desc" ) . uniqueResult ( 0 ) ;
if ( ObjectUtil . isEmpty ( groupObj ) ) {
throw new BadRequestException ( "料盅[" + vehicleCode + "]组盘信息不存在!" ) ;
}
// 查找工单
JSONObject orderObj = orderTab . query ( "workorder_id = '" + groupObj . getString ( "workorder_id" ) + "'" ) . uniqueResult ( 0 ) ;
orderObj . put ( "unqualified_qty" , orderObj . getBigDecimal ( "unqualified_qty" ) . add ( groupObj . getBigDecimal ( "weight" ) ) ) ;
TaskUtils . addCurrentUpdateColum ( orderObj ) ;
orderTab . update ( orderObj ) ;
// 组盘修改
groupObj . put ( "is_back" , "1" ) ;
TaskUtils . addCurrentUpdateColum ( groupObj ) ;
vd_table . update ( groupObj ) ;
}
@Override
public void samplingCountNum ( JSONObject param ) {
log . info ( "请求参数:{}" , param ) ;
WQLObject vd_table = WQLObject . getWQLObject ( "st_ivt_vehicle_detail" ) ;
// param: vehicle_code, number
String vehicleCode = param . getString ( "vehicle_code" ) ;
BigDecimal number = param . getBigDecimal ( "number" ) ;
JSONObject groupObj = vd_table . query ( "vehicle_code = '" + vehicleCode + "' AND vehicle_type = '2'" , "create_time desc" ) . uniqueResult ( 0 ) ;
if ( ObjectUtil . isEmpty ( groupObj ) ) {
throw new BadRequestException ( "托盘[" + vehicleCode + "]组盘信息不存在!" ) ;
}
BigDecimal bigDecimal = ObjectUtil . isNotEmpty ( groupObj . getBigDecimal ( "count_num" ) ) ? groupObj . getBigDecimal ( "count_num" ) : new BigDecimal ( "0" ) ;
groupObj . put ( "count_num" , bigDecimal . add ( number ) ) ;
TaskUtils . addCurrentUpdateColum ( groupObj ) ;
vd_table . update ( groupObj ) ;
}
@Override
public JSONArray manualExceptionHandlingTaskRegionList ( ) {
return region ( "send_material" ) ;
}
@Override
public JSONArray kilnOutCreateTaskShow ( ) {
return getTaskList ( TaskType . PDA_OUT_KILN . value ( ) ) ;
}
@Override
public JSONArray kilnMoveCreateTaskShow ( ) {
return this . getTaskList ( TaskType . PDA_VEHICLE_TRANSFER . value ( ) ) ;
}
@Override
public JSONArray getLoamComparePointList ( ) {
return getPositionList ( ) ;
}
@Override
public String getLoamCompareDoCheck ( JSONObject param ) {
// param: point_code、vehicle_code
WQLObject taskTab = WQLObject . getWQLObject ( "sch_base_task" ) ;
JSONObject taskObj = taskTab . query ( "point_code2 = '" + param . getString ( "point_code" ) + "' AND point_type = '" +
TaskType . PDA_PRESS_UP . value ( ) + "'" , "update_time desc" ) . uniqueResult ( 0 ) ;
if ( taskObj . getString ( "vehicle_code" ) . equals ( param . getString ( "vehicle_code" ) ) ) {
return "检测符合!" ;
}
return "检测不符合!" ;
}
@Override
public JSONObject getGroupInfoByVehicleCode ( JSONObject param ) {
// param: vehicle_code, vehicle_type
JSONObject info = WQL . getWO ( "PDA" )
. addParam ( "flag" , "10" )
. addParam ( "vehicle_code" , param . getString ( "vehicle_code" ) )
. addParam ( "vehicle_type" , param . getString ( "vehicle_type" ) )
. process ( )
. uniqueResult ( 0 ) ;
if ( ObjectUtil . isEmpty ( info ) ) {
throw new BadRequestException ( "托盘:[" + param . getString ( "vehicle_code" ) + "]的组盘信息不存在!" ) ;
}
return info ;
}
@Override
@Transactional ( rollbackFor = Exception . class )
public void doUpdateWeight ( JSONObject param ) {
// param: vehicle_code, vehicle_type, current_weight
// 更新、记录信息
WQLObject vdTab = WQLObject . getWQLObject ( "st_ivt_vehicle_detail" ) ;
JSONObject info = vdTab . query ( "vehicle_code = '" + param . getString ( "vehicle_code" ) + "' AND vehicle_type = '" +
param . getString ( "vehicle_type" ) + "' AND is_delete = '0'" ) . uniqueResult ( 0 ) ;
if ( ObjectUtil . isEmpty ( info ) ) {
throw new BadRequestException ( "托盘:[" + param . getString ( "vehicle_code" ) + "]的组盘信息不存在!" ) ;
}
// 插入记录
GroupUpdateRecordDto dto = new GroupUpdateRecordDto ( ) ;
dto . setGroup_id ( info . getString ( "vd_id" ) ) ;
dto . setOrign_weight ( info . getString ( "weight" ) ) ;
dto . setCurrent_weight ( param . getString ( "current_weight" ) ) ;
dto . setVehicle_code ( param . getString ( "vehicle_code" ) ) ;
dto . setVehicle_type ( param . getString ( "vehicle_type" ) ) ;
dto . setUpdate_type ( "1" ) ;
groupUpdateRecordService . create ( dto ) ;
info . put ( "weight" , param . getString ( "current_weight" ) ) ;
TaskUtils . addCurrentUpdateColum ( info ) ;
vdTab . update ( info ) ;
}
@Override
@Transactional ( rollbackFor = Exception . class )
public void doUpdateQty ( JSONObject param ) {
// param: vehicle_code, vehicle_type, current_weight,current_qty
// 更新、记录信息
WQLObject vdTab = WQLObject . getWQLObject ( "st_ivt_vehicle_detail" ) ;
JSONObject info = vdTab . query ( "vehicle_code = '" + param . getString ( "vehicle_code" ) + "' AND vehicle_type = '" +
param . getString ( "vehicle_type" ) + "' AND is_delete = '0'" ) . uniqueResult ( 0 ) ;
if ( ObjectUtil . isEmpty ( info ) ) {
throw new BadRequestException ( "托盘:[" + param . getString ( "vehicle_code" ) + "]的组盘信息不存在!" ) ;
}
// 获取重量
BigDecimal currentWeight = param . getBigDecimal ( "current_weight" ) ;
// 获取数量
BigDecimal currentQty = param . getBigDecimal ( "current_qty" ) ;
if ( ObjectUtil . isEmpty ( currentQty ) ) {
currentQty = info . getBigDecimal ( "weight" ) ;
}
// 插入记录
GroupUpdateRecordDto dto = new GroupUpdateRecordDto ( ) ;
dto . setGroup_id ( info . getString ( "vd_id" ) ) ;
dto . setOrign_weight ( info . getString ( "weight" ) ) ;
dto . setCurrent_weight ( String . valueOf ( currentWeight . multiply ( currentQty ) ) ) ;
dto . setOrign_qty ( info . getString ( "qty" ) ) ;
dto . setCurrent_qty ( param . getString ( "current_qty" ) ) ;
dto . setVehicle_code ( param . getString ( "vehicle_code" ) ) ;
dto . setVehicle_type ( param . getString ( "vehicle_type" ) ) ;
dto . setUpdate_type (
( ObjectUtil . isEmpty ( param . getString ( "current_weight" ) ) & & ObjectUtil . isNotEmpty ( param . getString ( "current_qty" ) ) )
? "2" :
( ObjectUtil . isNotEmpty ( param . getString ( "current_weight" ) ) & & ObjectUtil . isNotEmpty ( param . getString ( "current_qty" ) ) )
? "3" : "1" ) ;
groupUpdateRecordService . create ( dto ) ;
info . put ( "weight" , param . getString ( "current_weight" ) ) ;
TaskUtils . addCurrentUpdateColum ( info ) ;
vdTab . update ( info ) ;
}
@Override
public JSONObject checkHaveMaterial ( JSONObject param ) {
JSONObject res = new JSONObject ( ) ;
// param: vehicle_code, vehicle_type
WQLObject vdTab = WQLObject . getWQLObject ( "st_ivt_vehicle_detail" ) ;
JSONObject info = vdTab . query ( "vehicle_code = '" + param . getString ( "vehicle_code" ) + "' AND vehicle_type = '" +
param . getString ( "vehicle_type" ) + "' AND is_delete = '0'" ) . uniqueResult ( 0 ) ;
if ( ObjectUtil . isEmpty ( info ) ) {
res . put ( "message" , "该托盘系统中无组盘信息!" ) ;
return res ;
}
res . put ( "message" , "该托盘系统中存在组盘信息,如需解绑,请点击确认!" ) ;
return res ;
}
@Override
public void doUnbindVehicle ( JSONObject param ) {
WQLObject vdTab = WQLObject . getWQLObject ( "st_ivt_vehicle_detail" ) ;
JSONObject info = vdTab . query ( "vehicle_code = '" + param . getString ( "vehicle_code" ) + "' AND vehicle_type = '" +
param . getString ( "vehicle_type" ) + "' AND is_delete = '0'" ) . uniqueResult ( 0 ) ;
if ( ObjectUtil . isEmpty ( info ) ) {
throw new BadRequestException ( "托盘:[" + param . getString ( "vehicle_code" ) + "]的组盘信息不存在!" ) ;
}
info . put ( "is_delete" , "1" ) ;
TaskUtils . addCurrentUpdateColum ( info ) ;
vdTab . update ( info ) ;
}
}