@ -60,12 +60,12 @@ public class SendMaterialTask extends AbstractAcsTask {
jsonTask . put ( "update_time" , DateUtil . now ( ) ) ;
jsonTask . put ( "car_no" , taskObj . getString ( "car_no" ) ) ;
taskTab . update ( jsonTask ) ;
HashMap map = new HashMap ( ) ;
map . put ( "update_optid" , SecurityUtils . getCurrentUserId ( ) ) ;
map . put ( "update_optname" , SecurityUtils . getNickName ( ) ) ;
map . put ( "update_time" , DateUtil . now ( ) ) ;
map . put ( "bill_status" , "40" ) ;
WQLObject . getWQLObject ( "ST_IVT_regionIO" ) . update ( map , "task_id='" + jsonTask . getString ( "task_id" ) + "'" ) ;
// HashMap map = new HashMap();
// map.put("update_optid", SecurityUtils.getCurrentUserId());
// map.put("update_optname", SecurityUtils.getNickName());
// map.put("update_time", DateUtil.now());
// map.put("bill_status", "40");
// WQLObject.getWQLObject("ST_IVT_regionIO").update(map, "task_id='" + jsonTask.getString("task_id") + "'");
}
if ( TaskStatusEnum . FINISHED . getCode ( ) . equals ( status ) ) {
@ -75,15 +75,15 @@ public class SendMaterialTask extends AbstractAcsTask {
jsonTask . put ( "update_time" , DateUtil . now ( ) ) ;
jsonTask . put ( "remark" , "任务执行完成" ) ;
///审核单据 增加库存 改变出入库表的状态
WQLObject mstTab = WQLObject . getWQLObject ( "ST_IVT_regionIO" ) ;
JSONObject mstObj = mstTab . query ( "task_id='" + task_id + "' and is_delete='0'" ) . uniqueResult ( 0 ) ;
// WQLObject mstTab = WQLObject.getWQLObject("ST_IVT_regionIO");
// JSONObject mstObj = mstTab.query("task_id='" + task_id + "' and is_delete='0'").uniqueResult(0);
//审核 加库存可和用数量
// StoreIvtServiceImpl ivtService = new StoreIvtServiceImpl();
mstObj . put ( "bill_status" , "50" ) ;
mstObj . put ( "confirm_optid" , SecurityUtils . getCurrentUserId ( ) ) ;
mstObj . put ( "confirm_optname" , SecurityUtils . getNickName ( ) ) ;
mstObj . put ( "confirm_time" , DateUtil . now ( ) ) ;
mstTab . update ( mstObj ) ;
// mstObj.put("bill_status", "50");
// mstObj.put("confirm_optid", SecurityUtils.getCurrentUserId());
// mstObj.put("confirm_optname", SecurityUtils.getNickName());
// mstObj.put("confirm_time", DateUtil.now());
// mstTab.update(mstObj);
// String iostorinv_id = mstObj.getString("iostorinv_id");
// String bill_code = mstObj.getString("bill_code");
@ -115,8 +115,13 @@ public class SendMaterialTask extends AbstractAcsTask {
throw new BadRequestException ( "未找到可用点位:" + start_point_code ) ;
}
// 如果终点区域为待检区,则需要添加库存
if ( nextPointDto . getRegion_id ( ) . equals ( 1572481855792484352L ) ) {
// 如果起点是仓位(待检区),则需要删除库存
if ( StrUtil . equals ( startPointDto . getPoint_type ( ) , "01" ) ) {
WQLObject . getWQLObject ( "st_ivt_structivt" ) . delete ( "struct_id = " + startPointDto . getPoint_id ( ) ) ;
}
// 如果终点为仓位(待检区),则需要添加库存
if ( StrUtil . equals ( nextPointDto . getPoint_type ( ) , "01" ) ) {
JSONObject struct = new JSONObject ( ) ;
struct . put ( "stockrecord_id" , IdUtil . getSnowflake ( 1 , 1 ) . nextId ( ) ) ;
struct . put ( "struct_id" , nextPointDto . getPoint_id ( ) ) ;
@ -130,15 +135,13 @@ public class SendMaterialTask extends AbstractAcsTask {
// param.put("struct_id", nextPointDto.getPoint_id());
// ivtService.addIvtFlow(param, IvtChangeTypeEnum.ADD_IVT_AND_CAN_USE);
// 解锁点位 将起点的点位状态写给终点
// 将起点的点位状态写给终点
WQLObject pointTab = WQLObject . getWQLObject ( "sch_base_point" ) ;
JSONObject startPointObj = pointTab . query ( "point_code='" + start_point_code + "'" ) . uniqueResult ( 0 ) ;
JSONObject endPointObj = pointTab . query ( "point_code='" + next_point_code + "'" ) . uniqueResult ( 0 ) ;
// 起点写给终点
endPointObj . put ( "lock_type" , "00" ) ;
String pointStatus = startPointObj . getString ( "point_status" ) ;
endPointObj . put ( "point_status" , pointStatus ) ;
endPointObj . put ( "point_status" , startPointObj . getString ( "point_status" ) ) ;
pointTab . update ( endPointObj ) ;
// 起点置空
@ -147,6 +150,9 @@ public class SendMaterialTask extends AbstractAcsTask {
pointTab . update ( startPointObj ) ;
// 更新任务
jsonTask . put ( "update_optid" , SecurityUtils . getCurrentUserId ( ) ) ;
jsonTask . put ( "update_optname" , SecurityUtils . getNickName ( ) ) ;
jsonTask . put ( "update_time" , DateUtil . now ( ) ) ;
taskTab . update ( jsonTask ) ;
}
@ -202,54 +208,76 @@ public class SendMaterialTask extends AbstractAcsTask {
@Override
@Transactional ( rollbackFor = Exception . class )
public String createTask ( JSONObject form ) {
//请求参数 载具、起点、终点
// 参数校验
String start_point_code = form . getString ( "start_point_code" ) ;
String next_point_code = form . getString ( "next_point_code" ) ; ;
WQLObject taskTable = WQLObject . getWQLObject ( "SCH_BASE_Task" ) ;
if ( StrUtil . isEmpty ( start_point_code ) ) {
throw new BadRequestException ( "起点不能为空!" ) ;
}
String next_point_code = form . getString ( "next_point_code" ) ;
if ( StrUtil . isEmpty ( next_point_code ) ) {
throw new BadRequestException ( "终点不能为空!" ) ;
}
WQLObject taskTable = WQLObject . getWQLObject ( "SCH_BASE_Task" ) ;
PointService pointService = SpringContextHolder . getBean ( PointService . class ) ;
// 起点是空位不能搬
PointDto startPoint = pointService . findByCode ( start_point_code ) ;
if ( StrUtil . equals ( startPoint . getPoint_status ( ) , "00" ) ) {
throw new BadRequestException ( "起点是空位!" ) ;
}
// 终点不是不合格品区且不是 空位不能搬
// 终点不是空位不能搬
PointDto nextPoint = pointService . findByCode ( next_point_code ) ;
if ( ! nextPoint . getRegion_id ( ) . equals ( 1572481902244401152L ) & & ! StrUtil . equals ( nextPoint . getPoint_status ( ) , "00" ) ) {
if ( ! StrUtil . equals ( nextPoint . getPoint_status ( ) , "00" ) ) {
throw new BadRequestException ( "终点不是空位!" ) ;
}
//判断起点有没有未完成的指令
JSONObject beforTaskObj = taskTable .
query ( "is_delete='0' and start_point_code= '" + start_point_code + "' and task_status <> '" + TaskStatusEnum . FINISHED . getCode ( ) + "'" )
// 判断起点有没有未完成的指令
JSONObject startPointTask = taskTable
. query ( "(start_point_code = '" + start_point_code + "' OR next_point_code = '" + start_point_code + "') AND is_delete = '0' AND task_status <> '" + TaskStatusEnum . FINISHED . getCode ( ) + "'" )
. uniqueResult ( 0 ) ;
if ( ObjectUtil . isNotEmpty ( beforTaskObj ) ) {
throw new BadRequestException ( "起点存在指令号为'" + beforTaskObj . getString ( "task_code" ) + "' 未完成!" ) ;
if ( ObjectUtil . isNotEmpty ( startPointTask ) ) {
throw new BadRequestException ( "起点存在指令号为'" + startPointTask . getString ( "task_code" ) + "'未完成!" ) ;
}
WQLObject pointTable = WQLObject . getWQLObject ( "sch_base_point" ) ;
// 判断起点有没有未完成的指令
JSONObject nextPointTask = taskTable
. query ( "(start_point_code = '" + next_point_code + "' OR next_point_code = '" + next_point_code + "') AND is_delete = '0' AND task_status <> '" + TaskStatusEnum . FINISHED . getCode ( ) + "'" )
. uniqueResult ( 0 ) ;
if ( ObjectUtil . isNotEmpty ( nextPointTask ) ) {
throw new BadRequestException ( "终点存在指令号为'" + nextPointTask . getString ( "task_code" ) + "'未完成!" ) ;
}
//终点点加锁
JSONObject endPointObj = pointTable . query ( "point_code='" + next_point_code + "'" ) . uniqueResult ( 0 ) ;
endPointObj . put ( "lock_type" , "01" ) ;
pointTable . update ( endPointObj ) ;
if ( StrUtil . equals ( startPoint . getPoint_status ( ) , "03" ) & & StrUtil . equals ( startPoint . getPoint_type ( ) , "01" ) ) {
// 如果起点有料桶且是仓位(待检区),需要判断质量
String qualityScode = WQLObject
. getWQLObject ( "st_ivt_structivt" )
. query ( "struct_id = " + startPoint . getPoint_id ( ) )
. uniqueResult ( 0 )
. getString ( "quality_scode" ) ;
if ( StrUtil . equals ( qualityScode , "00" ) ) {
// 未检品不能送
throw new BadRequestException ( "待检品不能搬运" ) ;
}
if ( StrUtil . equals ( qualityScode , "01" ) & & nextPoint . getPoint_code ( ) . startsWith ( "BHG" ) ) {
// 合格品不能送到不合格品间
throw new BadRequestException ( "合格品不能送到不合格品间" ) ;
}
if ( StrUtil . equals ( qualityScode , "02" ) & & nextPoint . getPoint_code ( ) . startsWith ( "TL" ) ) {
// 不合格品不能送到投料站
throw new BadRequestException ( "不合格品不能送到投料站" ) ;
}
}
// 创建任务
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 ) ;
String taskI d = IdUtil . getSnowflake ( 1 , 1 ) . nextId ( ) + "" ;
taskObj . put ( "task_id" , taskI d ) ;
taskObj . put ( "taskdtl_id" , taskI d ) ;
taskObj . put ( "task_code" , CodeUtil . getNewCode ( "TASK_CODE" ) ) ;
taskObj . put ( "task_type" , "01" ) ;
taskObj . put ( "taskdtl_type" , "01" ) ;
@ -267,7 +295,19 @@ public class SendMaterialTask extends AbstractAcsTask {
taskObj . put ( "create_time" , DateUtil . now ( ) ) ;
taskObj . put ( "is_delete" , "0" ) ;
taskTable . insert ( taskObj ) ;
return task_id ;
// 下发任务
JSONObject ACSResult = renotifyAcs ( taskId ) ;
if ( ! StrUtil . equals ( ACSResult . getString ( "status" ) , "200" ) ) {
// 报错后删除任务
taskTable . delete ( "task_id = " + taskId ) ;
String resultMessage = ACSResult . getString ( "message" ) ;
throw new BadRequestException ( resultMessage ) ;
}
return taskId ;
}