@ -17,14 +17,10 @@ import org.nl.modules.wql.WQL;
import org.nl.modules.wql.core.bean.WQLObject ;
import org.nl.modules.wql.core.bean.WQLObject ;
import org.nl.modules.wql.util.WqlUtil ;
import org.nl.modules.wql.util.WqlUtil ;
import org.nl.wms.basedata.st.service.impl.UserStorServiceImpl ;
import org.nl.wms.basedata.st.service.impl.UserStorServiceImpl ;
import org.nl.wms.st.inbill.service.StorPublicService ;
import org.nl.wms.st.instor.service.CheckService ;
import org.nl.wms.st.instor.service.CheckService ;
import org.nl.wms.st.instor.task.HandMoveStorAcsTask ;
import org.springframework.beans.factory.annotation.Autowired ;
import org.springframework.data.domain.Pageable ;
import org.springframework.data.domain.Pageable ;
import org.springframework.stereotype.Service ;
import org.springframework.stereotype.Service ;
import org.springframework.transaction.annotation.Transactional ;
import org.springframework.transaction.annotation.Transactional ;
import javax.servlet.http.HttpServletResponse ;
import javax.servlet.http.HttpServletResponse ;
import java.io.IOException ;
import java.io.IOException ;
import java.util.* ;
import java.util.* ;
@ -37,14 +33,10 @@ import java.util.stream.Collectors;
@RequiredArgsConstructor
@RequiredArgsConstructor
@Slf4j
@Slf4j
public class CheckServiceImpl implements CheckService {
public class CheckServiceImpl implements CheckService {
@Autowired
private StorPublicService storPublicService ;
@Override
@Override
public Map < String , Object > pageQuery ( Map whereJson , Pageable page ) {
public Map < String , Object > pageQuery ( Map whereJson , Pageable page ) {
WQLObject dtlTab = WQLObject . getWQLObject ( "st_ivt_checkdtl" ) ;
HashMap < String , String > map = new HashMap < > ( whereJson ) ;
HashMap < String , String > map = new HashMap < > ( whereJson ) ;
map . put ( "flag" , "1" ) ;
map . put ( "flag" , "1" ) ;
if ( StrUtil . isNotEmpty ( map . get ( "check_code" ) ) ) {
if ( StrUtil . isNotEmpty ( map . get ( "check_code" ) ) ) {
@ -223,30 +215,6 @@ public class CheckServiceImpl implements CheckService {
}
}
}
}
/ * *
* 根据传进来的载具物料明细 , 查询载具所有库存记录 , 并生成移库明细
*
* @param rows
* /
@Transactional ( rollbackFor = Exception . class )
void insertDtlByRows ( JSONObject jo_mst , ArrayList < HashMap > rows ) {
//明细表
WQLObject wo_dtl = WQLObject . getWQLObject ( "ST_IVT_CheckDtl" ) ;
//定义需要需要插入的库存集合
HashSet < String > set = new HashSet < > ( ) ;
for ( int i = 0 ; i < rows . size ( ) ; i + + ) {
HashMap < String , String > row = rows . get ( i ) ;
set . add ( row . get ( "struct_id" ) ) ;
String checkdtl_id = IdUtil . getSnowflake ( 1 , 1 ) . nextId ( ) + "" ;
row . put ( "checkdtl_id" , checkdtl_id ) ;
row . put ( "check_code" , jo_mst . getString ( "check_code" ) ) ;
row . put ( "check_id" , jo_mst . getString ( "check_id" ) ) ;
row . put ( "seq_no" , ( i + 1 ) + "" ) ;
row . put ( "is_down" , "0" ) ;
wo_dtl . insert ( row ) ;
}
}
@Override
@Override
public JSONArray getOutBillDtl ( Map whereJson ) {
public JSONArray getOutBillDtl ( Map whereJson ) {
@ -283,15 +251,6 @@ public class CheckServiceImpl implements CheckService {
return jo ;
return jo ;
}
}
@Override
public JSONArray getOutBillDis ( Map whereJson ) {
whereJson . put ( "flag" , "4" ) ;
JSONArray jo = WQL . getWO ( "QST_IVT_CHECK" )
. addParamMap ( ( HashMap ) whereJson )
. process ( )
. getResultJSONArray ( 0 ) ;
return jo ;
}
@Override
@Override
@Transactional ( rollbackFor = Exception . class )
@Transactional ( rollbackFor = Exception . class )
@ -422,61 +381,6 @@ public class CheckServiceImpl implements CheckService {
wo_mst . update ( jsonMst ) ;
wo_mst . update ( jsonMst ) ;
}
}
@Override
@Transactional ( rollbackFor = Exception . class )
public void handdown ( JSONObject whereJson ) {
//移库单主表
WQLObject wo_mst = WQLObject . getWQLObject ( "ST_IVT_MoveInv" ) ;
//移库单明细表
WQLObject wo_dtl = WQLObject . getWQLObject ( "ST_IVT_MoveInvDtl" ) ;
//任务表
WQLObject wo_Task = WQLObject . getWQLObject ( "SCH_BASE_Task" ) ;
HandMoveStorAcsTask handMoveStorAcsTask = new HandMoveStorAcsTask ( ) ;
String currentUserId = SecurityUtils . getCurrentUserId ( ) ;
String nickName = SecurityUtils . getCurrentNickName ( ) ;
String now = DateUtil . now ( ) ;
String moveinv_id = whereJson . getString ( "moveinv_id" ) ;
//查询当前移库单所有载具的任务
JSONArray ja = WQL . getWO ( "QST_IVT_HANDMOVESTOR" )
. addParam ( "flag" , "4" )
. addParam ( "moveinv_id" , moveinv_id )
. process ( ) . getResultJSONArray ( 0 ) ;
if ( ja . size ( ) = = 0 ) {
throw new BadRequestException ( "当前移库单无可下发任务!" ) ;
}
for ( int i = 0 ; i < ja . size ( ) ; i + + ) {
JSONObject jo = ja . getJSONObject ( i ) ;
String task_id = jo . getString ( "task_id" ) ;
String taskdtl_id = whereJson . getString ( "taskdtl_id" ) ;
JSONObject result = handMoveStorAcsTask . notifyAcs ( taskdtl_id ) ;
if ( ObjectUtil . isNotEmpty ( result ) ) {
String status = result . getString ( "status" ) ;
if ( "200" . equals ( status ) ) {
HashMap < String , String > map = new HashMap < > ( ) ;
//更新分配表
map . put ( "is_issued" , "1" ) ;
wo_dtl . update ( map , "is_issued='0' and task_id='" + task_id + "'" ) ;
//更新任务为已下发
map . put ( "task_status" , "02" ) ;
map . put ( "update_optid" , currentUserId + "" ) ;
map . put ( "update_optname" , nickName ) ;
map . put ( "update_time" , now ) ;
wo_Task . update ( map , "task_status='01' and taskdtl_id='" + taskdtl_id + "'" ) ;
} else {
throw new BadRequestException ( "任务下发失败,请稍后重试!" ) ;
}
} else {
throw new BadRequestException ( "任务下发失败,请稍后重试!" ) ;
}
}
HashMap < String , String > map = new HashMap < > ( ) ;
map . put ( "bill_status" , "20" ) ;
wo_mst . update ( map , "moveinv_id='" + moveinv_id + "'" ) ;
}
@Override
@Override
public void saveCheck ( JSONObject whereJson ) {
public void saveCheck ( JSONObject whereJson ) {
//主表
//主表
@ -534,177 +438,6 @@ public class CheckServiceImpl implements CheckService {
wo_mst . update ( jo_mst ) ;
wo_mst . update ( jo_mst ) ;
}
}
@Override
@Transactional ( rollbackFor = Exception . class )
public void process0 ( JSONObject whereJson ) {
//主表
WQLObject wo_mst = WQLObject . getWQLObject ( "ST_IVT_CheckMst" ) ;
//明细表
WQLObject wo_dtl = WQLObject . getWQLObject ( "ST_IVT_CheckDtl" ) ;
JSONObject form = whereJson . getJSONObject ( "form" ) ;
JSONObject row = whereJson . getJSONObject ( "row" ) ;
String currentUserId = SecurityUtils . getCurrentUserId ( ) ;
String nickName = SecurityUtils . getCurrentNickName ( ) ;
String now = DateUtil . now ( ) ;
JSONObject jo_mst = wo_mst . query ( "status <>'99' and check_id='" + form . getString ( "check_id" ) + "'" ) . uniqueResult ( 0 ) ;
if ( jo_mst = = null ) {
throw new BadRequestException ( "盘点单状态异常!" ) ;
}
row . put ( "status" , "07" ) ;
row . put ( "process_optid" , currentUserId ) ;
row . put ( "process_type" , "0" ) ;
row . put ( "is_process" , "1" ) ;
row . put ( "process_time" , now ) ;
wo_dtl . update ( row ) ;
JSONArray ja = wo_dtl . query ( "status in ('99','07') and check_id='" + form . getString ( "check_id" ) + "'" ) . getResultJSONArray ( 0 ) ;
//说明全部确认
if ( ja . size ( ) = = jo_mst . getInteger ( "dtl_num" ) ) {
HashMap < String , String > mapdtl = new HashMap < > ( ) ;
mapdtl . put ( "status" , "99" ) ;
wo_dtl . update ( mapdtl , "check_id='" + form . getString ( "check_id" ) + "'" ) ;
jo_mst . put ( "status" , "99" ) ;
jo_mst . put ( "confirm_optid" , currentUserId ) ;
jo_mst . put ( "confirm_optname" , nickName ) ;
jo_mst . put ( "confirm_time" , now ) ;
for ( int i = 0 ; i < ja . size ( ) ; i + + ) {
JSONObject jo = ja . getJSONObject ( i ) ;
//锁定起点点位、仓位
JSONObject from_start = new JSONObject ( ) ;
from_start . put ( "lock_type" , "00" ) ;
from_start . put ( "struct_id" , jo . getString ( "struct_id" ) ) ;
storPublicService . updateStructAndPoint ( from_start ) ;
}
}
wo_mst . update ( jo_mst ) ;
}
@Override
@Transactional ( rollbackFor = Exception . class )
public void process1 ( JSONObject whereJson ) {
//主表
WQLObject wo_mst = WQLObject . getWQLObject ( "ST_IVT_CheckMst" ) ;
//明细表
WQLObject wo_dtl = WQLObject . getWQLObject ( "ST_IVT_CheckDtl" ) ;
//明细表
WQLObject wo_dis = WQLObject . getWQLObject ( "ST_IVT_CheckDtlDis" ) ;
JSONObject form = whereJson . getJSONObject ( "row" ) ;
JSONArray rows = whereJson . getJSONArray ( "rows" ) ;
String currentUserId = SecurityUtils . getCurrentUserId ( ) ;
String nickName = SecurityUtils . getCurrentNickName ( ) ;
String now = DateUtil . now ( ) ;
JSONObject jo_mst = wo_mst . query ( "status <>'99' and check_id='" + form . getString ( "check_id" ) + "'" ) . uniqueResult ( 0 ) ;
if ( jo_mst = = null ) {
throw new BadRequestException ( "盘点单状态异常!" ) ;
}
HashMap < String , String > map = new HashMap < > ( ) ;
map . put ( "status" , "07" ) ;
map . put ( "process_optid" , currentUserId + "" ) ;
map . put ( "process_type" , "1" ) ;
map . put ( "is_process" , "1" ) ;
map . put ( "process_time" , now ) ;
wo_dtl . update ( map , "status not in('07','99') and storagevehicle_code='" + form . getString ( "storagevehicle_code" ) + "' and check_id='" + form . getString ( "check_id" ) + "'" ) ;
for ( int i = 0 ; i < rows . size ( ) ; i + + ) {
JSONObject jo = rows . getJSONObject ( i ) ;
String checkdtldis_id = IdUtil . getSnowflake ( 1 , 1 ) . nextId ( ) + "" ;
jo . put ( "checkdtldis_id" , checkdtldis_id ) ;
jo . put ( "check_id" , jo_mst . getString ( "check_id" ) ) ;
jo . put ( "check_code" , jo_mst . getString ( "check_code" ) ) ;
jo . put ( "sect_id" , form . getString ( "sect_id" ) ) ;
jo . put ( "struct_id" , form . getString ( "struct_id" ) ) ;
jo . put ( "struct_name" , form . getString ( "struct_name" ) ) ;
jo . put ( "sect_name" , form . getString ( "sect_name" ) ) ;
wo_dis . insert ( jo ) ;
}
//判断是否要生成损单
JSONArray ja_sun = WQL . getWO ( "QST_IVT_CHECK" )
. addParam ( "storagevehicle_code" , form . getString ( "storagevehicle_code" ) )
. addParam ( "check_id" , form . getString ( "check_id" ) )
. addParam ( "flag" , "6" )
. process ( )
. getResultJSONArray ( 0 ) ;
if ( ja_sun . size ( ) > 0 ) {
JSONObject mapMst = new JSONObject ( ) ;
mapMst . put ( "mol_inv_type" , "42" ) ;
mapMst . put ( "create_mode" , "02" ) ;
mapMst . put ( "mol_type" , "0" ) ;
mapMst . put ( "stor_id" , ja_sun . getJSONObject ( 0 ) . getString ( "stor_id" ) ) ;
mapMst . put ( "sect_id" , ja_sun . getJSONObject ( 0 ) . getString ( "sect_id" ) ) ;
mapMst . put ( "sect_name" , ja_sun . getJSONObject ( 0 ) . getString ( "sect_name" ) ) ;
mapMst . put ( "struct_id" , ja_sun . getJSONObject ( 0 ) . getString ( "struct_id" ) ) ;
mapMst . put ( "struct_name" , ja_sun . getJSONObject ( 0 ) . getString ( "struct_name" ) ) ;
mapMst . put ( "tableData" , ja_sun ) ;
}
//判断是否要生成溢单
JSONArray ja_yi = WQL . getWO ( "QST_IVT_CHECK" )
. addParam ( "storagevehicle_code" , form . getString ( "storagevehicle_code" ) )
. addParam ( "check_id" , form . getString ( "check_id" ) )
. addParam ( "flag" , "5" )
. process ( )
. getResultJSONArray ( 0 ) ;
if ( ja_yi . size ( ) > 0 ) {
JSONObject mapMst = new JSONObject ( ) ;
mapMst . put ( "mol_inv_type" , "42" ) ;
mapMst . put ( "create_mode" , "02" ) ;
mapMst . put ( "mol_type" , "1" ) ;
mapMst . put ( "stor_id" , ja_yi . getJSONObject ( 0 ) . getString ( "stor_id" ) ) ;
mapMst . put ( "sect_id" , ja_yi . getJSONObject ( 0 ) . getString ( "sect_id" ) ) ;
mapMst . put ( "sect_name" , ja_yi . getJSONObject ( 0 ) . getString ( "sect_name" ) ) ;
mapMst . put ( "struct_id" , ja_yi . getJSONObject ( 0 ) . getString ( "struct_id" ) ) ;
mapMst . put ( "struct_name" , ja_yi . getJSONObject ( 0 ) . getString ( "struct_name" ) ) ;
mapMst . put ( "tableData" , ja_yi ) ;
}
JSONArray ja = wo_dtl . query ( "status in ('99','07') and check_id='" + form . getString ( "check_id" ) + "'" ) . getResultJSONArray ( 0 ) ;
//说明全部确认
if ( ja . size ( ) = = jo_mst . getInteger ( "dtl_num" ) ) {
HashMap < String , String > mapdtl = new HashMap < > ( ) ;
mapdtl . put ( "status" , "99" ) ;
wo_dtl . update ( mapdtl , "check_id='" + form . getString ( "check_id" ) + "'" ) ;
jo_mst . put ( "status" , "99" ) ;
jo_mst . put ( "confirm_optid" , currentUserId ) ;
jo_mst . put ( "confirm_optname" , nickName ) ;
jo_mst . put ( "confirm_time" , now ) ;
for ( int i = 0 ; i < ja . size ( ) ; i + + ) {
JSONObject jo = ja . getJSONObject ( i ) ;
//锁定起点点位、仓位
JSONObject from_start = new JSONObject ( ) ;
from_start . put ( "lock_type" , "00" ) ;
from_start . put ( "struct_id" , jo . getString ( "struct_id" ) ) ;
storPublicService . updateStructAndPoint ( from_start ) ;
}
//确认损益单
JSONArray ja_sunyi = WQL . getWO ( "QST_IVT_CHECK" )
. addParam ( "check_code" , form . getString ( "check_code" ) )
. addParam ( "flag" , "7" )
. process ( )
. getResultJSONArray ( 0 ) ;
for ( int i = 0 ; i < ja_sunyi . size ( ) ; i + + ) {
JSONObject jo = ja_sunyi . getJSONObject ( i ) ;
}
}
wo_mst . update ( jo_mst ) ;
}
@Override
public JSONArray getInvTypes ( ) {
//查询单据字段类型
JSONArray ja = WQL . getWO ( "ST_PUB_QUERY_01" )
. addParam ( "flag" , "4" )
. process ( )
. getResultJSONArray ( 0 ) ;
return ja ;
}
@Override
@Override
public void download ( JSONArray rows , HttpServletResponse response ) throws IOException {
public void download ( JSONArray rows , HttpServletResponse response ) throws IOException {
WQLObject subTab = WQLObject . getWQLObject ( "pdm_bi_subpackagerelation" ) ;
WQLObject subTab = WQLObject . getWQLObject ( "pdm_bi_subpackagerelation" ) ;