@ -28,76 +28,96 @@ public class EmptyAndQtyServiceImpl implements EmptyAndQtyService {
public JSONObject confirm ( JSONObject whereJSON ) {
// 返回值
JSONObject resultJSON = new JSONObject ( ) ;
// 参数校验
String pointId = whereJSON . getString ( "point_id" ) ;
if ( StrUtil . isEmpty ( pointId ) ) {
resultJSON . put ( "code" , "0" ) ;
resultJSON . put ( "desc" , "点位不能为空" ) ;
return resultJSON ;
}
String pointStatus = whereJSON . getString ( "point_status" ) ;
if ( StrUtil . isEmpty ( pointStatus ) ) {
resultJSON . put ( "code" , "0" ) ;
resultJSON . put ( "desc" , "点位状态不能为空" ) ;
return resultJSON ;
}
String qualityScode = whereJSON . getString ( "quality_scode" ) ;
if ( StrUtil . equals ( pointStatus , "03" ) & & StrUtil . isEmpty ( qualityScode ) ) {
resultJSON . put ( "code" , "0" ) ;
resultJSON . put ( "desc" , "质量不能为空" ) ;
return resultJSON ;
}
// 查询点位
WQLObject pointTable = WQLObject . getWQLObject ( "sch_base_point" ) ;
JSONObject point = pointTable
. query ( "point_id = " + pointId )
. uniqueResult ( 0 ) ;
// 判断点位是否有为完成的指令
String pointCode = point . getString ( "point_code" ) ;
JSONObject task = WQLObject
. getWQLObject ( "sch_base_task" )
. query ( "(start_point_code = '" + pointCode + "' OR next_point_code = '" + pointCode + "') AND is_delete = '0' AND task_status <> '" + TaskStatusEnum . FINISHED . getCode ( ) + "'" )
. uniqueResult ( 0 ) ;
if ( ObjectUtil . isNotEmpty ( task ) ) {
resultJSON . put ( "code" , "0" ) ;
resultJSON . put ( "desc" , "当前点位存在未完成的指令" ) ;
return resultJSON ;
}
// 修改点位
point . put ( "point_status" , pointStatus ) ;
pointTable . update ( point ) ;
if ( StrUtil . equals ( pointStatus , "03" ) & & StrUtil . equals ( point . getString ( "point_type" ) , "01" ) ) {
// 如果是有料桶且是仓位(待检区),则需要修改库存表
WQLObject structTable = WQLObject . getWQLObject ( "st_ivt_structivt" ) ;
JSONObject struct = structTable
. query ( "struct_id = " + pointId )
. uniqueResult ( 0 ) ;
if ( ObjectUtil . isEmpty ( struct ) ) {
// 当前库存为空,则添加库存
struct = new JSONObject ( ) ;
struct . put ( "stockrecord_id" , IdUtil . getSnowflake ( 1L , 1L ) . nextId ( ) ) ;
struct . put ( "struct_id" , pointId ) ;
struct . put ( "struct_code" , point . get ( "point_code" ) ) ;
struct . put ( "struct_name" , point . get ( "point_name" ) ) ;
struct . put ( "region_id" , point . get ( "region_id" ) ) ;
struct . put ( "quality_scode" , qualityScode ) ;
structTable . insert ( struct ) ;
} else {
// 当前存在库存,则更新库存
struct . put ( "quality_scode" , qualityScode ) ;
structTable . update ( struct ) ;
String point_id = whereJSON . getString ( "point_id" ) ;
int type = whereJSON . getIntValue ( "type" ) ;
String quality_scode = whereJSON . getString ( "quality_scode" ) ;
WQLObject ivtTab = WQLObject . getWQLObject ( "st_ivt_structivt" ) ;
JSONObject ivt_json = ivtTab . query ( "struct_id ='" + point_id + "'" ) . uniqueResult ( 0 ) ;
if ( ObjectUtil . isNotEmpty ( ivt_json ) ) {
if ( type = = 1 ) {
ivt_json . put ( "quality_scode" , quality_scode ) ;
} else if ( type = = 2 ) {
ivt_json . put ( "quality_scode" , null ) ;
}
ivtTab . update ( ivt_json ) ;
}
// 返回
resultJSON . put ( "code" , "1" ) ;
resultJSON . put ( "desc" , "绑定 成功" ) ;
resultJSON . put ( "desc" , "更新成功" ) ;
return resultJSON ;
// // 返回值
// JSONObject resultJSON = new JSONObject();
//
// // 参数校验
// String pointId = whereJSON.getString("point_id");
// if (StrUtil.isEmpty(pointId)) {
// resultJSON.put("code", "0");
// resultJSON.put("desc", "点位不能为空");
// return resultJSON;
// }
// String pointStatus = whereJSON.getString("point_status");
// if (StrUtil.isEmpty(pointStatus)) {
// resultJSON.put("code", "0");
// resultJSON.put("desc", "点位状态不能为空");
// return resultJSON;
// }
// String qualityScode = whereJSON.getString("quality_scode");
// if (StrUtil.equals(pointStatus, "03") && StrUtil.isEmpty(qualityScode)) {
// resultJSON.put("code", "0");
// resultJSON.put("desc", "质量不能为空");
// return resultJSON;
// }
//
// // 查询点位
// WQLObject pointTable = WQLObject.getWQLObject("sch_base_point");
// JSONObject point = pointTable
// .query("point_id = " + pointId)
// .uniqueResult(0);
//
// // 判断点位是否有为完成的指令
// String pointCode = point.getString("point_code");
// JSONObject task = WQLObject
// .getWQLObject("sch_base_task")
// .query("(start_point_code = '" + pointCode + "' OR next_point_code = '" + pointCode + "') AND is_delete = '0' AND task_status <> '" + TaskStatusEnum.FINISHED.getCode() + "'")
// .uniqueResult(0);
// if (ObjectUtil.isNotEmpty(task)) {
// resultJSON.put("code", "0");
// resultJSON.put("desc", "当前点位存在未完成的指令");
// return resultJSON;
// }
//
// // 修改点位
// point.put("point_status", pointStatus);
// pointTable.update(point);
//
// if (StrUtil.equals(pointStatus, "03") && StrUtil.equals(point.getString("point_type"), "01")) {
// // 如果是有料桶且是仓位(待检区),则需要修改库存表
// WQLObject structTable = WQLObject.getWQLObject("st_ivt_structivt");
// JSONObject struct = structTable
// .query("struct_id = " + pointId)
// .uniqueResult(0);
//
// if (ObjectUtil.isEmpty(struct)) {
// // 当前库存为空,则添加库存
// struct = new JSONObject();
// struct.put("stockrecord_id", IdUtil.getSnowflake(1L, 1L).nextId());
// struct.put("struct_id", pointId);
// struct.put("struct_code", point.get("point_code"));
// struct.put("struct_name", point.get("point_name"));
// struct.put("region_id", point.get("region_id"));
// struct.put("quality_scode", qualityScode);
// structTable.insert(struct);
// } else {
// // 当前存在库存,则更新库存
// struct.put("quality_scode", qualityScode);
// structTable.update(struct);
// }
// }
//
// // 返回
// resultJSON.put("code", "1");
// resultJSON.put("desc", "绑定成功");
// return resultJSON;
}
}