@@ -2,10 +2,14 @@ package org.nl.wms.warehouse_management.service.impl;
import cn.hutool.core.date.DateUtil ;
import cn.hutool.core.map.MapUtil ;
import cn.hutool.core.util.NumberUtil ;
import cn.hutool.core.util.ObjectUtil ;
import cn.hutool.core.util.StrUtil ;
import com.alibaba.excel.EasyExcel ;
import com.alibaba.excel.ExcelWriter ;
import com.alibaba.excel.write.metadata.WriteSheet ;
import com.alibaba.excel.write.metadata.fill.FillWrapper ;
import com.alibaba.fastjson.JSON ;
import com.alibaba.fastjson.JSONArray ;
import com.alibaba.fastjson.JSONObject ;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper ;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper ;
@@ -16,28 +20,26 @@ import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.nl.common.domain.query.PageQuery ;
import org.nl.common.exception.BadRequestException ;
import org.nl.common.utils.CodeUtil ;
import org.nl.common.utils.FileUtil ;
import org.nl.common.utils.IdUtil ;
import org.nl.common.utils.SecurityUtils ;
import org.nl.config.SpringContextHolder ;
import org.nl.system.enums.SysParamConstant ;
import org.nl.system.service.param.dao.Param ;
import org.nl.system.service.param.impl.SysParamServiceImpl ;
import org.nl.wms.basedata_manage.enums.BaseDataEnum ;
import org.nl.wms.basedata_manage.service.IBsrealStorattrService ;
import org.nl.wms.basedata_manage.service.IMdPbStoragevehicleextService ;
import org.nl.wms.basedata_manage.service.IStructattrService ;
import org.nl.wms.basedata_manage.service.dao.BsrealStorattr ;
import org.nl.wms.basedata_manage.service.dao.MdPbStoragevehicleinfo ;
import org.nl.wms.basedata_manage.service.dao.Structattr ;
import org.nl.wms.basedata_manage.service.* ;
import org.nl.wms.basedata_manage.service.dao.* ;
import org.nl.wms.basedata_manage.service.dao.mapper.MdPbStoragevehicleinfoMapper ;
import org.nl.wms.sch_manage.service.dao.SchBasePoint ;
import org.nl.wms.sch_manage.service.dao.SchBaseTask ;
import org.nl.wms.sch_manage.service.dao.mapper.SchBasePointMapper ;
import org.nl.wms.sch_manage.service.util.AbstractTask ;
import org.nl.wms.sch_manage.service.util.tasks.StInTask ;
import org.nl.wms.warehouse_management.enums.IOSConstant ;
import org.nl.wms.warehouse_management.enums.IOSEnum ;
import org.nl.wms.warehouse_management.service.IRawAssistIStorService ;
import org.nl.wms.warehouse_management.service.dao.* ;
import org.nl.wms.warehouse_management.service.dao.GroupPlate ;
import org.nl.wms.warehouse_management.service.dao.IOStorInv ;
import org.nl.wms.warehouse_management.service.dao.IOStorInvDis ;
import org.nl.wms.warehouse_management.service.dao.IOStorInvDtl ;
import org.nl.wms.warehouse_management.service.dao.mapper.GroupPlateMapper ;
import org.nl.wms.warehouse_management.service.dao.mapper.IOStorInvDisMapper ;
import org.nl.wms.warehouse_management.service.dao.mapper.IOStorInvDtlMapper ;
@@ -45,11 +47,11 @@ import org.nl.wms.warehouse_management.service.dao.mapper.IOStorInvMapper;
import org.nl.wms.warehouse_management.service.dto.GroupPlateDto ;
import org.nl.wms.warehouse_management.service.dto.IOStorInvDisDto ;
import org.nl.wms.warehouse_management.service.dto.IOStorInvDtlDto ;
import org.springframework.data.domain.Pageable ;
import org.springframework.stereotype.Service ;
import org.springframework.transaction.annotation.Transactional ;
import javax.annotation.Resource ;
import javax.servlet.ServletOutputStream ;
import javax.servlet.http.HttpServletResponse ;
import java.io.IOException ;
import java.math.BigDecimal ;
@@ -90,6 +92,12 @@ public class RawAssistIStorServiceImpl extends ServiceImpl<IOStorInvMapper, IOSt
@Resource
private GroupPlateMapper groupPlateMapper ;
@Resource
private IMdMeMaterialbaseService iMdMeMaterialbaseService ;
@Resource
private IMdCsCustomerbaseService iMdCsCustomerbaseService ;
@Override
public IPage < IOStorInv > pageQuery ( Map whereJson , PageQuery page ) {
HashMap < String , String > map = new HashMap < > ( ) ;
@@ -115,7 +123,7 @@ public class RawAssistIStorServiceImpl extends ServiceImpl<IOStorInvMapper, IOSt
String [ ] s = pcsn . split ( " " ) ;
String pcsn_in = String . join ( " ',' " , Arrays . asList ( s ) ) ;
map . put ( " pcsn_in " , " (' " + pcsn_in + " ') " ) ;
map . put ( " pcsn_in " , " (' " + pcsn_in + " ') " ) ;
} else {
map . put ( " pcsn " , " % " + pcsn + " % " ) ;
}
@@ -130,12 +138,12 @@ public class RawAssistIStorServiceImpl extends ServiceImpl<IOStorInvMapper, IOSt
if ( ! StrUtil . isEmpty ( end_time ) ) {
map . put ( " end_time " , end_time ) ;
}
return ioStorInvMapper . queryAllByPage ( new Page < > ( page . getPage ( ) + 1 , page . getSize ( ) ) , map ) ;
return ioStorInvMapper . queryAllByPage ( new Page < > ( page . getPage ( ) + 1 , page . getSize ( ) ) , map ) ;
}
@Override
public IPage < GroupPlateDto > getBillDtl ( Map whereJson , PageQuery page ) {
return ioStorInvMapper . getGroupPlate ( new Page < > ( page . getPage ( ) + 1 , page . getSize ( ) ) , whereJson ) ;
return ioStorInvMapper . getGroupPlate ( new Page < > ( page . getPage ( ) + 1 , page . getSize ( ) ) , whereJson ) ;
}
@Override
@@ -182,23 +190,23 @@ public class RawAssistIStorServiceImpl extends ServiceImpl<IOStorInvMapper, IOSt
HashMap < String , Object > row = rows . get ( i ) ;
JSONObject ioStorInvDtl = new JSONObject ( ) ;
ioStorInvDtl . putAll ( row ) ;
ioStorInvDtl . put ( " iostorinvdtl_id " , IdUtil . getStringId ( ) ) ;
ioStorInvDtl . put ( " iostorinv_id " , iostorinv_id ) ;
ioStorInvDtl . put ( " seq_no " , ( i + 1 ) + " " ) ;
ioStorInvDtl . put ( " material_id " , row . get ( " material_id " ) ) ;
ioStorInvDtl . put ( " Pcsn " , row . get ( " pcsn " ) ) ;
ioStorInvDtl . put ( " bill_status " , IOSEnum . BILL_STATUS . code ( " 生成 " ) ) ;
ioStorInvDtl . put ( " qty_unit_id " , row . get ( " qty_unit_id " ) ) ;
ioStorInvDtl . put ( " qty_unit_name " , row . get ( " qty_unit_name " ) ) ;
ioStorInvDtl . put ( " source_bill_type " , row . get ( " ext_type " ) ) ;
ioStorInvDtl . put ( " source_bill_code " , row . get ( " ext_code " ) ) ;
ioStorInvDtl . put ( " assign_qty " , " 0 " ) ;
ioStorInvDtl . put ( " unassign_qty " , row . get ( " plan_qty " ) ) ;
ioStorInvDtl . put ( " plan_qty " , row . get ( " plan_qty " ) ) ;
ioStorInvDtl . put ( " iostorinvdtl_id " , IdUtil . getStringId ( ) ) ;
ioStorInvDtl . put ( " iostorinv_id " , iostorinv_id ) ;
ioStorInvDtl . put ( " seq_no " , ( i + 1 ) + " " ) ;
ioStorInvDtl . put ( " material_id " , row . get ( " material_id " ) ) ;
ioStorInvDtl . put ( " Pcsn " , row . get ( " pcsn " ) ) ;
ioStorInvDtl . put ( " bill_status " , IOSEnum . BILL_STATUS . code ( " 生成 " ) ) ;
ioStorInvDtl . put ( " qty_unit_id " , row . get ( " qty_unit_id " ) ) ;
ioStorInvDtl . put ( " qty_unit_name " , row . get ( " qty_unit_name " ) ) ;
ioStorInvDtl . put ( " source_bill_type " , row . get ( " ext_type " ) ) ;
ioStorInvDtl . put ( " source_bill_code " , row . get ( " ext_code " ) ) ;
ioStorInvDtl . put ( " assign_qty " , " 0 " ) ;
ioStorInvDtl . put ( " unassign_qty " , row . get ( " plan_qty " ) ) ;
ioStorInvDtl . put ( " plan_qty " , row . get ( " plan_qty " ) ) ;
total_qty + = Double . parseDouble ( row . get ( " qty " ) . toString ( ) ) ;
//判断该载具编号是否已经存在库内
Structattr structattr = iStructattrService . getOne ( new LambdaQueryWrapper < > ( Structattr . class ) . eq ( Structattr : : getStoragevehicle_code , row . get ( " storagevehicle_code " ) ) ) ;
Structattr structattr = iStructattrService . getOne ( new LambdaQueryWrapper < > ( Structattr . class ) . eq ( Structattr : : getStoragevehicle_code , row . get ( " storagevehicle_code " ) ) ) ;
if ( ObjectUtil . isNotEmpty ( structattr ) ) {
throw new BadRequestException ( " 载具编码: " + row . get ( " storagevehicle_code " ) + " 已存在库内,请对数据进行核实! " ) ;
}
@@ -218,6 +226,8 @@ public class RawAssistIStorServiceImpl extends ServiceImpl<IOStorInvMapper, IOSt
dis . put ( " qty_unit_id " , row . get ( " qty_unit_id " ) ) ;
dis . put ( " qty_unit_name " , row . get ( " qty_unit_name " ) ) ;
dis . put ( " plan_qty " , row . get ( " plan_qty " ) ) ;
dis . put ( " cust_code " , row . get ( " cust_code " ) ) ;
dis . put ( " contract_code " , row . get ( " contract_code " ) ) ;
ioStorInvDisMapper . insert ( dis . toJavaObject ( IOStorInvDis . class ) ) ;
}
@@ -261,45 +271,45 @@ public class RawAssistIStorServiceImpl extends ServiceImpl<IOStorInvMapper, IOSt
String now = DateUtil . now ( ) ;
JSONObject iostorinv_json = new JSONObject ( ) ;
iostorinv_json . put ( " iostorinv_id " , iostorinv_id ) ;
iostorinv_json . put ( " stor_id " , whereJson . get ( " stor_id " ) ) ;
iostorinv_json . put ( " stor_code " , whereJson . get ( " stor_code " ) ) ;
iostorinv_json . put ( " stor_name " , whereJson . get ( " stor_name " ) ) ;
iostorinv_json . put ( " total_qty " , whereJson . get ( " total_qty " ) ) ;
iostorinv_json . put ( " detail_count " , whereJson . get ( " detail_count " ) ) ;
iostorinv_json . put ( " biz_date " , whereJson . get ( " biz_date " ) ) ;
iostorinv_json . put ( " bill_type " , whereJson . get ( " bill_type " ) ) ;
iostorinv_json . put ( " remark " , whereJson . get ( " remark " ) ) ;
iostorinv_json . put ( " update_optid " , currentUserId ) ;
iostorinv_json . put ( " update_optname " , nickName ) ;
iostorinv_json . put ( " update_time " , now ) ;
iostorinv_json . put ( " iostorinv_id " , iostorinv_id ) ;
iostorinv_json . put ( " stor_id " , whereJson . get ( " stor_id " ) ) ;
iostorinv_json . put ( " stor_code " , whereJson . get ( " stor_code " ) ) ;
iostorinv_json . put ( " stor_name " , whereJson . get ( " stor_name " ) ) ;
iostorinv_json . put ( " total_qty " , whereJson . get ( " total_qty " ) ) ;
iostorinv_json . put ( " detail_count " , whereJson . get ( " detail_count " ) ) ;
iostorinv_json . put ( " biz_date " , whereJson . get ( " biz_date " ) ) ;
iostorinv_json . put ( " bill_type " , whereJson . get ( " bill_type " ) ) ;
iostorinv_json . put ( " remark " , whereJson . get ( " remark " ) ) ;
iostorinv_json . put ( " update_optid " , currentUserId ) ;
iostorinv_json . put ( " update_optname " , nickName ) ;
iostorinv_json . put ( " update_time " , now ) ;
ioStorInvMapper . updateById ( iostorinv_json . toJavaObject ( IOStorInv . class ) ) ;
//先删除该单据下的所有明细
ioStorInvDtlMapper . delete ( new LambdaQueryWrapper < > ( IOStorInvDtl . class ) . eq ( IOStorInvDtl : : getIostorinv_id , iostorinv_id ) ) ;
ioStorInvDtlMapper . delete ( new LambdaQueryWrapper < > ( IOStorInvDtl . class ) . eq ( IOStorInvDtl : : getIostorinv_id , iostorinv_id ) ) ;
ioStorInvDisMapper . delete ( new LambdaQueryWrapper < > ( IOStorInvDis . class ) . eq ( IOStorInvDis : : getIostorinv_id , iostorinv_id ) ) ;
ioStorInvDisMapper . delete ( new LambdaQueryWrapper < > ( IOStorInvDis . class ) . eq ( IOStorInvDis : : getIostorinv_id , iostorinv_id ) ) ;
ArrayList < HashMap > rows = ( ArrayList < HashMap > ) whereJson . get ( " tableData " ) ;
for ( int i = 0 ; i < rows . size ( ) ; i + + ) {
HashMap < String , Object > row = rows . get ( i ) ;
JSONObject ioStorInvDtl = new JSONObject ( ) ;
ioStorInvDtl . putAll ( row ) ;
ioStorInvDtl . put ( " iostorinvdtl_id " , IdUtil . getStringId ( ) ) ;
ioStorInvDtl . put ( " iostorinv_id " , iostorinv_id ) ;
ioStorInvDtl . put ( " seq_no " , ( i + 1 ) + " " ) ;
ioStorInvDtl . put ( " material_id " , row . get ( " material_id " ) ) ;
ioStorInvDtl . put ( " Pcsn " , row . get ( " pcsn " ) ) ;
ioStorInvDtl . put ( " bill_status " , IOSEnum . BILL_STATUS . code ( " 生成 " ) ) ;
ioStorInvDtl . put ( " qty_unit_id " , row . get ( " qty_unit_id " ) ) ;
ioStorInvDtl . put ( " qty_unit_name " , row . get ( " qty_unit_name " ) ) ;
ioStorInvDtl . put ( " assign_qty " , 0 ) ;
ioStorInvDtl . put ( " plan_qty " , row . get ( " plan_qty " ) ) ;
ioStorInvDtl . put ( " unassign_qty " , row . get ( " qty " ) ) ;
ioStorInvDtl . put ( " iostorinvdtl_id " , IdUtil . getStringId ( ) ) ;
ioStorInvDtl . put ( " iostorinv_id " , iostorinv_id ) ;
ioStorInvDtl . put ( " seq_no " , ( i + 1 ) + " " ) ;
ioStorInvDtl . put ( " material_id " , row . get ( " material_id " ) ) ;
ioStorInvDtl . put ( " Pcsn " , row . get ( " pcsn " ) ) ;
ioStorInvDtl . put ( " bill_status " , IOSEnum . BILL_STATUS . code ( " 生成 " ) ) ;
ioStorInvDtl . put ( " qty_unit_id " , row . get ( " qty_unit_id " ) ) ;
ioStorInvDtl . put ( " qty_unit_name " , row . get ( " qty_unit_name " ) ) ;
ioStorInvDtl . put ( " assign_qty " , 0 ) ;
ioStorInvDtl . put ( " plan_qty " , row . get ( " plan_qty " ) ) ;
ioStorInvDtl . put ( " unassign_qty " , row . get ( " qty " ) ) ;
//判断该载具编号是否已经存在库内
Structattr structattr = iStructattrService . getOne ( new LambdaQueryWrapper < > ( Structattr . class ) . eq ( Structattr : : getStoragevehicle_code , row . get ( " storagevehicle_code " ) ) ) ;
Structattr structattr = iStructattrService . getOne ( new LambdaQueryWrapper < > ( Structattr . class ) . eq ( Structattr : : getStoragevehicle_code , row . get ( " storagevehicle_code " ) ) ) ;
if ( ObjectUtil . isNotEmpty ( structattr ) ) {
throw new BadRequestException ( " 载具编码: " + row . get ( " storagevehicle_code " ) + " 已存在库内,请对数据进行核实! " ) ;
}
@@ -349,9 +359,9 @@ public class RawAssistIStorServiceImpl extends ServiceImpl<IOStorInvMapper, IOSt
//判断该分配明细是否已经分配货位
IOStorInvDis ioStorInvDis = ioStorInvDisMapper . selectOne ( new LambdaQueryWrapper < > ( IOStorInvDis . class )
. eq ( IOStorInvDis : : getIostorinvdis_id , map . get ( " iostorinvdis_id " ) )
. and ( wrapper - > wrapper . isNull ( IOStorInvDis : : getStruct_code ) . or ( ) . eq ( IOStorInvDis : : getStruct_code , " " ) ) ) ;
if ( ObjectUtil . isEmpty ( ioStorInvDis ) ) {
. eq ( IOStorInvDis : : getIostorinvdis_id , map . get ( " iostorinvdis_id " ) )
. and ( wrapper - > wrapper . isNull ( IOStorInvDis : : getStruct_code ) . or ( ) . eq ( IOStorInvDis : : getStruct_code , " " ) ) ) ;
if ( ObjectUtil . isEmpty ( ioStorInvDis ) ) {
throw new BadRequestException ( " 该明细已经分配过货位,无法继续分配! " ) ;
}
@@ -382,12 +392,12 @@ public class RawAssistIStorServiceImpl extends ServiceImpl<IOStorInvMapper, IOSt
Structattr structattr = iStructattrService . getByCode ( map . get ( " struct_code " ) ) ;
MdPbStoragevehicleinfo mdPbStoragevehicleinfo = mdPbStoragevehicleinfoMapper . selectOne ( new LambdaQueryWrapper < > ( MdPbStoragevehicleinfo . class )
. eq ( MdPbStoragevehicleinfo : : getStoragevehicle_code , map . get ( " storagevehicle_code " ) )
. eq ( MdPbStoragevehicleinfo : : getStoragevehicle_code , map . get ( " storagevehicle_code " ) )
) ;
//判断仓位的长高宽是否能放下载具
if ( structattr . getWidth ( ) . compareTo ( mdPbStoragevehicleinfo . getVehicle_width ( ) ) < 0 & &
structattr . getHeight ( ) . compareTo ( mdPbStoragevehicleinfo . getVehicle_height ( ) ) < 0 & &
structattr . getZdepth ( ) . compareTo ( mdPbStoragevehicleinfo . getVehicle_long ( ) ) < 0 ) {
if ( structattr . getWidth ( ) . compareTo ( mdPbStoragevehicleinfo . getVehicle_width ( ) ) < 0 & &
structattr . getHeight ( ) . compareTo ( mdPbStoragevehicleinfo . getVehicle_height ( ) ) < 0 & &
structattr . getZdepth ( ) . compareTo ( mdPbStoragevehicleinfo . getVehicle_long ( ) ) < 0 ) {
throw new BadRequestException ( " 当前载具与仓位不匹配,请检查! " ) ;
}
sect_id = map . get ( " sect_id " ) ;
@@ -413,31 +423,31 @@ public class RawAssistIStorServiceImpl extends ServiceImpl<IOStorInvMapper, IOSt
lock_map . put ( " inv_code " , ioStorInv . getBill_code ( ) ) ;
lock_map . put ( " inv_type " , ioStorInv . getBill_type ( ) ) ;
lock_map . put ( " lock_type " , IOSEnum . LOCK_TYPE . code ( " 入库锁 " ) ) ;
iStructattrService . updateStatusByCode ( " 0 " , lock_map ) ;
iStructattrService . updateStatusByCode ( " 0 " , lock_map ) ;
// 更新分配明细表
ioStorInvDisMapper . update ( dis_map . toJavaObject ( IOStorInvDis . class ) , new LambdaUpdateWrapper < > ( IOStorInvDis . class )
. set ( IOStorInvDis : : getSect_id , dis_map . getString ( " sect_id " ) )
. set ( IOStorInvDis : : getSect_code , dis_map . getString ( " sect_code " ) )
. set ( IOStorInvDis : : getSect_name , dis_map . getString ( " sect_name " ) )
. set ( IOStorInvDis : : getStruct_id , dis_map . getString ( " struct_id " ) )
. set ( IOStorInvDis : : getStruct_code , dis_map . getString ( " struct_code " ) )
. set ( IOStorInvDis : : getStruct_name , dis_map . getString ( " struct_name " ) )
. eq ( IOStorInvDis : : getIostorinvdis_id , map . get ( " iostorinvdis_id " ) )
ioStorInvDisMapper . update ( dis_map . toJavaObject ( IOStorInvDis . class ) , new LambdaUpdateWrapper < > ( IOStorInvDis . class )
. set ( IOStorInvDis : : getSect_id , dis_map . getString ( " sect_id " ) )
. set ( IOStorInvDis : : getSect_code , dis_map . getString ( " sect_code " ) )
. set ( IOStorInvDis : : getSect_name , dis_map . getString ( " sect_name " ) )
. set ( IOStorInvDis : : getStruct_id , dis_map . getString ( " struct_id " ) )
. set ( IOStorInvDis : : getStruct_code , dis_map . getString ( " struct_code " ) )
. set ( IOStorInvDis : : getStruct_name , dis_map . getString ( " struct_name " ) )
. eq ( IOStorInvDis : : getIostorinvdis_id , map . get ( " iostorinvdis_id " ) )
) ;
//维护单据明细表里 分配数量
JSONObject jsonObject = new JSONObject ( ) ;
jsonObject . put ( " iostorinvdtl_id " , map . get ( " iostorinvdtl_id " ) ) ;
jsonObject . put ( " bill_status " , IOSEnum . BILL_STATUS . code ( " 分配完 " ) ) ;
jsonObject . put ( " assign_qty " , map . get ( " plan_qty " ) ) ;
jsonObject . put ( " unassign_qty " , " 0 " ) ;
jsonObject . put ( " iostorinvdtl_id " , map . get ( " iostorinvdtl_id " ) ) ;
jsonObject . put ( " bill_status " , IOSEnum . BILL_STATUS . code ( " 分配完 " ) ) ;
jsonObject . put ( " assign_qty " , map . get ( " plan_qty " ) ) ;
jsonObject . put ( " unassign_qty " , " 0 " ) ;
ioStorInvDtlMapper . updateById ( jsonObject . toJavaObject ( IOStorInvDtl . class ) ) ;
//根据单据标识判断分配明细是否都已经分配完成
int disCount = ioStorInvDisMapper . selectCount ( new LambdaQueryWrapper < > ( IOStorInvDis . class )
. eq ( IOStorInvDis : : getIostorinv_id , map . get ( " iostorinv_id " ) )
. and ( wrapper - > wrapper . isNull ( IOStorInvDis : : getStruct_code ) . or ( ) . eq ( IOStorInvDis : : getStruct_code , " " ) ) ) ;
. eq ( IOStorInvDis : : getIostorinv_id , map . get ( " iostorinv_id " ) )
. and ( wrapper - > wrapper . isNull ( IOStorInvDis : : getStruct_code ) . or ( ) . eq ( IOStorInvDis : : getStruct_code , " " ) ) ) ;
// 根据分配货位情况 更新主表单据状态
IOStorInv ios = new IOStorInv ( ) ;
@@ -445,7 +455,7 @@ public class RawAssistIStorServiceImpl extends ServiceImpl<IOStorInvMapper, IOSt
ios . setUpdate_optid ( currentUserId ) ;
ios . setUpdate_optname ( nickName ) ;
ios . setUpdate_time ( now ) ;
ios . setBill_status ( disCount > 0 ? IOSEnum . BILL_STATUS . code ( " 分配中 " ) : IOSEnum . BILL_STATUS . code ( " 分配完 " ) ) ;
ios . setBill_status ( disCount > 0 ? IOSEnum . BILL_STATUS . code ( " 分配中 " ) : IOSEnum . BILL_STATUS . code ( " 分配完 " ) ) ;
ioStorInvMapper . updateById ( ios ) ;
}
@@ -466,31 +476,31 @@ public class RawAssistIStorServiceImpl extends ServiceImpl<IOStorInvMapper, IOSt
unlock_map . put ( " inv_type " , null ) ;
unlock_map . put ( " inv_id " , null ) ;
unlock_map . put ( " inv_code " , null ) ;
iStructattrService . updateStatusByCode ( " 2 " , unlock_map ) ;
iStructattrService . updateStatusByCode ( " 2 " , unlock_map ) ;
// 修改分配明细表
ioStorInvDisMapper . update ( new IOStorInvDis ( ) , new LambdaUpdateWrapper < > ( IOStorInvDis . class )
. set ( IOStorInvDis : : getSect_id , null )
. set ( IOStorInvDis : : getSect_code , null )
. set ( IOStorInvDis : : getSect_name , null )
. set ( IOStorInvDis : : getStruct_id , null )
. set ( IOStorInvDis : : getStruct_code , null )
. set ( IOStorInvDis : : getStruct_name , null )
. eq ( IOStorInvDis : : getIostorinvdis_id , jo . get ( " iostorinvdis_id " ) )
ioStorInvDisMapper . update ( new IOStorInvDis ( ) , new LambdaUpdateWrapper < > ( IOStorInvDis . class )
. set ( IOStorInvDis : : getSect_id , null )
. set ( IOStorInvDis : : getSect_code , null )
. set ( IOStorInvDis : : getSect_name , null )
. set ( IOStorInvDis : : getStruct_id , null )
. set ( IOStorInvDis : : getStruct_code , null )
. set ( IOStorInvDis : : getStruct_name , null )
. eq ( IOStorInvDis : : getIostorinvdis_id , jo . get ( " iostorinvdis_id " ) )
) ;
//维护单据明细表里 分配数量
JSONObject jsonObject = new JSONObject ( ) ;
jsonObject . put ( " iostorinvdtl_id " , jo . get ( " iostorinvdtl_id " ) ) ;
jsonObject . put ( " bill_status " , IOSEnum . BILL_STATUS . code ( " 生成 " ) ) ;
jsonObject . put ( " assign_qty " , " 0 " ) ;
jsonObject . put ( " unassign_qty " , jo . get ( " plan_qty " ) ) ;
jsonObject . put ( " iostorinvdtl_id " , jo . get ( " iostorinvdtl_id " ) ) ;
jsonObject . put ( " bill_status " , IOSEnum . BILL_STATUS . code ( " 生成 " ) ) ;
jsonObject . put ( " assign_qty " , " 0 " ) ;
jsonObject . put ( " unassign_qty " , jo . get ( " plan_qty " ) ) ;
ioStorInvDtlMapper . updateById ( jsonObject . toJavaObject ( IOStorInvDtl . class ) ) ;
//根据单据标识判断分配明细是否都已经分配完成
int disCount = ioStorInvDisMapper . selectCount ( new LambdaQueryWrapper < > ( IOStorInvDis . class )
. eq ( IOStorInvDis : : getIostorinv_id , jo . get ( " iostorinv_id " ) )
. and ( wrapper - > wrapper . isNotNull ( IOStorInvDis : : getStruct_code ) . or ( ) . ne ( IOStorInvDis : : getStruct_code , " " ) ) ) ;
. eq ( IOStorInvDis : : getIostorinv_id , jo . get ( " iostorinv_id " ) )
. and ( wrapper - > wrapper . isNotNull ( IOStorInvDis : : getStruct_code ) . or ( ) . ne ( IOStorInvDis : : getStruct_code , " " ) ) ) ;
// 根据分配货位情况 更新主表单据状态
IOStorInv ios = new IOStorInv ( ) ;
@@ -498,7 +508,7 @@ public class RawAssistIStorServiceImpl extends ServiceImpl<IOStorInvMapper, IOSt
ios . setUpdate_optid ( currentUserId ) ;
ios . setUpdate_optname ( nickName ) ;
ios . setUpdate_time ( now ) ;
ios . setBill_status ( disCount > 0 ? IOSEnum . BILL_STATUS . code ( " 分配中 " ) : IOSEnum . BILL_STATUS . code ( " 生成 " ) ) ;
ios . setBill_status ( disCount > 0 ? IOSEnum . BILL_STATUS . code ( " 分配中 " ) : IOSEnum . BILL_STATUS . code ( " 生成 " ) ) ;
ioStorInvMapper . updateById ( ios ) ;
}
@@ -511,16 +521,16 @@ public class RawAssistIStorServiceImpl extends ServiceImpl<IOStorInvMapper, IOSt
//判断是否已经分配好货位
IOStorInvDis ioStorInvDis = ioStorInvDisMapper . selectOne ( new LambdaQueryWrapper < > ( IOStorInvDis . class )
. eq ( IOStorInvDis : : getIostorinvdis_id , map . get ( " iostorinvdis_id " ) )
. and ( wrapper - > wrapper . isNotNull ( IOStorInvDis : : getStruct_code ) . or ( ) . ne ( IOStorInvDis : : getStruct_code , " " ) ) ) ;
if ( ObjectUtil . isEmpty ( ioStorInvDis ) ) {
. eq ( IOStorInvDis : : getIostorinvdis_id , map . get ( " iostorinvdis_id " ) )
. and ( wrapper - > wrapper . isNotNull ( IOStorInvDis : : getStruct_code ) . or ( ) . ne ( IOStorInvDis : : getStruct_code , " " ) ) ) ;
if ( ObjectUtil . isEmpty ( ioStorInvDis ) ) {
throw new BadRequestException ( " 该明细还没分配货位,请先分配货位 " ) ;
}
//创建任务
JSONObject task_form = new JSONObject ( ) ;
task_form . put ( " task_type " , " STInTask " ) ;
task_form . put ( " TaskCode " , CodeUtil . getNewCode ( " TASK_CODE " ) ) ;
task_form . put ( " TaskCode " , CodeUtil . getNewCode ( " TASK_CODE " ) ) ;
task_form . put ( " PickingLocation " , point_code ) ;
task_form . put ( " PlacedLocation " , ioStorInvDis . getStruct_code ( ) ) ;
task_form . put ( " vehicle_code " , map . get ( " storagevehicle_code " ) ) ;
@@ -552,27 +562,27 @@ public class RawAssistIStorServiceImpl extends ServiceImpl<IOStorInvMapper, IOSt
String now = DateUtil . now ( ) ;
IOStorInv ioStorInv = ioStorInvMapper . selectOne ( new LambdaQueryWrapper < > ( IOStorInv . class )
. eq ( IOStorInv : : getIostorinv_id , whereJson . get ( " iostorinv_id " ) )
. eq ( IOStorInv : : getIostorinv_id , whereJson . get ( " iostorinv_id " ) )
) ;
if ( ObjectUtil . isNotEmpty ( ioStorInv ) & & ! IOSEnum . BILL_STATUS . code ( " 分配完 " ) . equals ( ioStorInv . getBill_status ( ) ) ) {
if ( ObjectUtil . isNotEmpty ( ioStorInv ) & & ! IOSEnum . BILL_STATUS . code ( " 分配完 " ) . equals ( ioStorInv . getBill_status ( ) ) ) {
throw new BadRequestException ( " 主表状态必须为分配完! " ) ;
}
//解锁原货位点位
List < IOStorInvDis > storInvDisList = ioStorInvDisMapper . selectList ( new LambdaQueryWrapper < > ( IOStorInvDis . class )
. eq ( IOStorInvDis : : getIostorinv_id , whereJson . get ( " iostorinv_id " ) )
. eq ( IOStorInvDis : : getIostorinv_id , whereJson . get ( " iostorinv_id " ) )
) ;
for ( IOStorInvDis ioStorInvDis : storInvDisList ) {
if ( StrUtil . isNotBlank ( ioStorInvDis . getStruct_code ( ) ) ) {
for ( IOStorInvDis ioStorInvDis : storInvDisList ) {
if ( StrUtil . isNotBlank ( ioStorInvDis . getStruct_code ( ) ) ) {
JSONObject finish_map = new JSONObject ( ) ;
finish_map . put ( " struct_code " , ioStorInvDis . getStruct_code ( ) ) ;
finish_map . put ( " storagevehicle_code " , ioStorInvDis . getStoragevehicle_code ( ) ) ;
finish_map . put ( " struct_code " , ioStorInvDis . getStruct_code ( ) ) ;
finish_map . put ( " storagevehicle_code " , ioStorInvDis . getStoragevehicle_code ( ) ) ;
finish_map . put ( " inv_type " , null ) ;
finish_map . put ( " inv_id " , null ) ;
finish_map . put ( " inv_code " , null ) ;
iStructattrService . updateStatusByCode ( " 1 " , finish_map ) ;
iStructattrService . updateStatusByCode ( " 1 " , finish_map ) ;
//修改库存
List < JSONObject > updateIvtList = new ArrayList < > ( ) ;
@@ -589,36 +599,36 @@ public class RawAssistIStorServiceImpl extends ServiceImpl<IOStorInvMapper, IOSt
}
//更新详情数据
ioStorInvDisMapper . update ( ioStorInvDis , new LambdaUpdateWrapper < > ( IOStorInvDis . class )
. set ( IOStorInvDis : : getWork_status , IOSEnum . INBILL_DIS_STATUS . code ( " 完成 " ) )
. set ( IOStorInvDis : : getReal_qty , ioStorInvDis . getPlan_qty ( ) )
. eq ( IOStorInvDis : : getIostorinvdis_id , ioStorInvDis . getIostorinvdis_id ( ) )
. ne ( IOStorInvDis : : getWork_status , IOSEnum . INBILL_DIS_STATUS . code ( " 完成 " ) )
ioStorInvDisMapper . update ( ioStorInvDis , new LambdaUpdateWrapper < > ( IOStorInvDis . class )
. set ( IOStorInvDis : : getWork_status , IOSEnum . INBILL_DIS_STATUS . code ( " 完成 " ) )
. set ( IOStorInvDis : : getReal_qty , ioStorInvDis . getPlan_qty ( ) )
. eq ( IOStorInvDis : : getIostorinvdis_id , ioStorInvDis . getIostorinvdis_id ( ) )
. ne ( IOStorInvDis : : getWork_status , IOSEnum . INBILL_DIS_STATUS . code ( " 完成 " ) )
) ;
ioStorInvDtlMapper . update ( new IOStorInvDtl ( ) , new LambdaUpdateWrapper < > ( IOStorInvDtl . class )
. set ( IOStorInvDtl : : getBill_status , IOSEnum . BILL_STATUS . code ( " 完成 " ) )
. set ( IOStorInvDtl : : getReal_qty , ioStorInvDis . getPlan_qty ( ) )
. eq ( IOStorInvDtl : : getIostorinvdtl_id , ioStorInvDis . getIostorinvdtl_id ( ) )
. ne ( IOStorInvDtl : : getBill_status , IOSEnum . BILL_STATUS . code ( " 完成 " ) )
ioStorInvDtlMapper . update ( new IOStorInvDtl ( ) , new LambdaUpdateWrapper < > ( IOStorInvDtl . class )
. set ( IOStorInvDtl : : getBill_status , IOSEnum . BILL_STATUS . code ( " 完成 " ) )
. set ( IOStorInvDtl : : getReal_qty , ioStorInvDis . getPlan_qty ( ) )
. eq ( IOStorInvDtl : : getIostorinvdtl_id , ioStorInvDis . getIostorinvdtl_id ( ) )
. ne ( IOStorInvDtl : : getBill_status , IOSEnum . BILL_STATUS . code ( " 完成 " ) )
) ;
//更新组盘记录表
groupPlateMapper . update ( new GroupPlate ( ) , new LambdaUpdateWrapper < > ( GroupPlate . class )
. set ( GroupPlate : : getStatus , IOSEnum . GROUP_PLATE_STATUS . code ( " 入库 " ) )
. eq ( GroupPlate : : getPcsn , ioStorInvDis . getPcsn ( ) )
. eq ( GroupPlate : : getMaterial_id , ioStorInvDis . getMaterial_id ( ) )
. eq ( GroupPlate : : getStoragevehicle_code , ioStorInvDis . getStoragevehicle_code ( ) )
groupPlateMapper . update ( new GroupPlate ( ) , new LambdaUpdateWrapper < > ( GroupPlate . class )
. set ( GroupPlate : : getStatus , IOSEnum . GROUP_PLATE_STATUS . code ( " 入库 " ) )
. eq ( GroupPlate : : getPcsn , ioStorInvDis . getPcsn ( ) )
. eq ( GroupPlate : : getMaterial_id , ioStorInvDis . getMaterial_id ( ) )
. eq ( GroupPlate : : getStoragevehicle_code , ioStorInvDis . getStoragevehicle_code ( ) )
) ;
}
//更新主表状态
ioStorInvMapper . update ( ioStorInv , new LambdaUpdateWrapper < > ( IOStorInv . class )
. set ( IOStorInv : : getBill_status , IOSEnum . BILL_STATUS . code ( " 完成 " ) )
. set ( IOStorInv : : getConfirm_optid , currentUserId )
. set ( IOStorInv : : getConfirm_optname , nickName )
. set ( IOStorInv : : getConfirm_time , now )
. eq ( IOStorInv : : getIostorinv_id , whereJson . get ( " iostorinv_id " ) )
ioStorInvMapper . update ( ioStorInv , new LambdaUpdateWrapper < > ( IOStorInv . class )
. set ( IOStorInv : : getBill_status , IOSEnum . BILL_STATUS . code ( " 完成 " ) )
. set ( IOStorInv : : getConfirm_optid , currentUserId )
. set ( IOStorInv : : getConfirm_optname , nickName )
. set ( IOStorInv : : getConfirm_time , now )
. eq ( IOStorInv : : getIostorinv_id , whereJson . get ( " iostorinv_id " ) )
) ;
}
@@ -632,27 +642,27 @@ public class RawAssistIStorServiceImpl extends ServiceImpl<IOStorInvMapper, IOSt
String now = DateUtil . now ( ) ;
IOStorInvDis ioStorInvDis = ioStorInvDisMapper . selectOne ( new LambdaQueryWrapper < > ( IOStorInvDis . class )
. eq ( IOStorInvDis : : getTask_id , task . getTask_id ( ) )
. eq ( IOStorInvDis : : getTask_id , task . getTask_id ( ) )
) ;
if ( ObjectUtil . isEmpty ( ioStorInvDis ) ) {
if ( ObjectUtil . isEmpty ( ioStorInvDis ) ) {
throw new BadRequestException ( " 未找到任务对应的分配明细 " ) ;
}
// 完成当前分配明细
ioStorInvDisMapper . update ( ioStorInvDis , new LambdaUpdateWrapper < > ( IOStorInvDis . class )
. set ( IOStorInvDis : : getWork_status , IOSEnum . INBILL_DIS_STATUS . code ( " 完成 " ) )
. set ( IOStorInvDis : : getReal_qty , ioStorInvDis . getPlan_qty ( ) )
. eq ( IOStorInvDis : : getIostorinvdis_id , ioStorInvDis . getIostorinvdis_id ( ) )
ioStorInvDisMapper . update ( ioStorInvDis , new LambdaUpdateWrapper < > ( IOStorInvDis . class )
. set ( IOStorInvDis : : getWork_status , IOSEnum . INBILL_DIS_STATUS . code ( " 完成 " ) )
. set ( IOStorInvDis : : getReal_qty , ioStorInvDis . getPlan_qty ( ) )
. eq ( IOStorInvDis : : getIostorinvdis_id , ioStorInvDis . getIostorinvdis_id ( ) )
) ;
//解锁库位
JSONObject finish_map = new JSONObject ( ) ;
finish_map . put ( " struct_code " , ioStorInvDis . getStruct_code ( ) ) ;
finish_map . put ( " storagevehicle_code " , ioStorInvDis . getStoragevehicle_code ( ) ) ;
finish_map . put ( " struct_code " , ioStorInvDis . getStruct_code ( ) ) ;
finish_map . put ( " storagevehicle_code " , ioStorInvDis . getStoragevehicle_code ( ) ) ;
finish_map . put ( " inv_type " , null ) ;
finish_map . put ( " inv_id " , null ) ;
finish_map . put ( " inv_code " , null ) ;
iStructattrService . updateStatusByCode ( " 1 " , finish_map ) ;
iStructattrService . updateStatusByCode ( " 1 " , finish_map ) ;
//修改库存
List < JSONObject > updateIvtList = new ArrayList < > ( ) ;
@@ -668,26 +678,26 @@ public class RawAssistIStorServiceImpl extends ServiceImpl<IOStorInvMapper, IOSt
iMdPbStoragevehicleextService . updateIvt ( updateIvtList ) ;
//更新组盘记录表
groupPlateMapper . update ( new GroupPlate ( ) , new LambdaUpdateWrapper < > ( GroupPlate . class )
. set ( GroupPlate : : getStatus , IOSEnum . GROUP_PLATE_STATUS . code ( " 入库 " ) )
. eq ( GroupPlate : : getPcsn , ioStorInvDis . getPcsn ( ) )
. eq ( GroupPlate : : getMaterial_id , ioStorInvDis . getMaterial_id ( ) )
. eq ( GroupPlate : : getStoragevehicle_code , ioStorInvDis . getStoragevehicle_code ( ) )
groupPlateMapper . update ( new GroupPlate ( ) , new LambdaUpdateWrapper < > ( GroupPlate . class )
. set ( GroupPlate : : getStatus , IOSEnum . GROUP_PLATE_STATUS . code ( " 入库 " ) )
. eq ( GroupPlate : : getPcsn , ioStorInvDis . getPcsn ( ) )
. eq ( GroupPlate : : getMaterial_id , ioStorInvDis . getMaterial_id ( ) )
. eq ( GroupPlate : : getStoragevehicle_code , ioStorInvDis . getStoragevehicle_code ( ) )
) ;
// 查询该明细下是否还有未完成的分配明细
int countDis = ioStorInvDisMapper . selectCount ( new LambdaQueryWrapper < > ( IOStorInvDis . class )
. eq ( IOStorInvDis : : getIostorinvdtl_id , ioStorInvDis . getIostorinvdtl_id ( ) )
. ne ( IOStorInvDis : : getWork_status , IOSEnum . INBILL_DIS_STATUS . code ( " 完成 " ) )
. eq ( IOStorInvDis : : getIostorinvdtl_id , ioStorInvDis . getIostorinvdtl_id ( ) )
. ne ( IOStorInvDis : : getWork_status , IOSEnum . INBILL_DIS_STATUS . code ( " 完成 " ) )
) ;
// 明细
IOStorInvDtl ioStorInvDtl = ioStorInvDtlMapper . selectById ( ioStorInvDis . getIostorinvdtl_id ( ) ) ;
if ( ObjectUtil . isEmpty ( ioStorInvDtl ) ) {
if ( ObjectUtil . isEmpty ( ioStorInvDtl ) ) {
throw new BadRequestException ( " 未找到明细 " ) ;
}
// 如果分配明细全部完成则更新明细表状态
if ( countDis = = 0 ) {
if ( countDis = = 0 ) {
// 更新明细表状态
ioStorInvDtl . setReal_qty ( ioStorInvDis . getPlan_qty ( ) ) ;
ioStorInvDtl . setBill_status ( IOSEnum . BILL_STATUS . code ( " 完成 " ) ) ;
@@ -695,19 +705,19 @@ public class RawAssistIStorServiceImpl extends ServiceImpl<IOStorInvMapper, IOSt
// 查看明细是否全部完成
int countDtl = ioStorInvDtlMapper . selectCount ( new LambdaQueryWrapper < > ( IOStorInvDtl . class )
. eq ( IOStorInvDtl : : getIostorinv_id , ioStorInvDtl . getIostorinv_id ( ) )
. ne ( IOStorInvDtl : : getBill_status , IOSEnum . BILL_STATUS . code ( " 完成 " ) )
. eq ( IOStorInvDtl : : getIostorinv_id , ioStorInvDtl . getIostorinv_id ( ) )
. ne ( IOStorInvDtl : : getBill_status , IOSEnum . BILL_STATUS . code ( " 完成 " ) )
) ;
// 如果明细全部完成则更新主表状态
if ( countDtl = = 0 ) {
if ( countDtl = = 0 ) {
//更新主表状态
ioStorInvMapper . update ( new IOStorInv ( ) , new LambdaUpdateWrapper < > ( IOStorInv . class )
. set ( IOStorInv : : getBill_status , IOSEnum . BILL_STATUS . code ( " 完成 " ) )
. set ( IOStorInv : : getConfirm_optid , currentUserId )
. set ( IOStorInv : : getConfirm_optname , nickName )
. set ( IOStorInv : : getConfirm_time , now )
. eq ( IOStorInv : : getIostorinv_id , ioStorInvDtl . getIostorinv_id ( ) )
ioStorInvMapper . update ( new IOStorInv ( ) , new LambdaUpdateWrapper < > ( IOStorInv . class )
. set ( IOStorInv : : getBill_status , IOSEnum . BILL_STATUS . code ( " 完成 " ) )
. set ( IOStorInv : : getConfirm_optid , currentUserId )
. set ( IOStorInv : : getConfirm_optname , nickName )
. set ( IOStorInv : : getConfirm_time , now )
. eq ( IOStorInv : : getIostorinv_id , ioStorInvDtl . getIostorinv_id ( ) )
) ;
}
}
@@ -725,21 +735,21 @@ public class RawAssistIStorServiceImpl extends ServiceImpl<IOStorInvMapper, IOSt
String sect_id = whereJson . getString ( " sect_id " ) ;
String storagevehicle_code = whereJson . getString ( " storagevehicle_code " ) ;
MdPbStoragevehicleinfo mdPbStoragevehicleinfo = mdPbStoragevehicleinfoMapper . selectOne ( new LambdaQueryWrapper < > ( MdPbStoragevehicleinfo . class )
. eq ( MdPbStoragevehicleinfo : : getStoragevehicle_code , storagevehicle_code )
. eq ( MdPbStoragevehicleinfo : : getStoragevehicle_code , storagevehicle_code )
) ;
if ( ObjectUtil . isEmpty ( mdPbStoragevehicleinfo ) ) {
if ( ObjectUtil . isEmpty ( mdPbStoragevehicleinfo ) ) {
throw new BadRequestException ( " 没有该载具号信息 " ) ;
}
// 查询没有任务的仓位号 并且根据载具类型分配货位
// 金属托盘 - 3 ,小料架 - 4, 大料架(短)-1 ,大料架(长) - 2
List < Structattr > structattrList = iStructattrService . list ( new LambdaQueryWrapper < > ( Structattr . class )
. eq ( Structattr : : getSect_id , sect_id )
. eq ( Structattr : : getLock_type , IOSEnum . LOCK_TYPE . code ( " 未锁定 " ) )
. eq ( Structattr : : getIs_used , IOSConstant . IS_DELETE_YES )
. eq ( Structattr : : getIs_delete , IOSConstant . IS_DELETE_NO )
. and ( wrapper - > wrapper . isNull ( Structattr : : getStoragevehicle_code ) . or ( ) . eq ( Structattr : : getStoragevehicle_code , " " ) )
. eq ( Structattr : : getSect_id , sect_id )
. eq ( Structattr : : getLock_type , IOSEnum . LOCK_TYPE . code ( " 未锁定 " ) )
. eq ( Structattr : : getIs_used , IOSConstant . IS_DELETE_YES )
. eq ( Structattr : : getIs_delete , IOSConstant . IS_DELETE_NO )
. and ( wrapper - > wrapper . isNull ( Structattr : : getStoragevehicle_code ) . or ( ) . eq ( Structattr : : getStoragevehicle_code , " " ) )
. eq ( mdPbStoragevehicleinfo . getStoragevehicle_type ( ) . equals ( IOSEnum . VEHICLE_TYPE . code ( " 金属托盘 " ) ) ,
Structattr : : getStoragevehicle_type , IOSEnum . VEHICLE_TYPE_PUT . code ( " 金属托盘 " ) )
. eq ( mdPbStoragevehicleinfo . getStoragevehicle_type ( ) . equals ( IOSEnum . VEHICLE_TYPE . code ( " 小料架 " ) ) ,
@@ -751,18 +761,18 @@ public class RawAssistIStorServiceImpl extends ServiceImpl<IOStorInvMapper, IOSt
. eq ( mdPbStoragevehicleinfo . getStoragevehicle_type ( ) . equals ( IOSEnum . VEHICLE_TYPE . code ( " 大料架(增高) " ) ) ,
Structattr : : getStoragevehicle_type , IOSEnum . VEHICLE_TYPE_PUT . code ( " 大料架(增高) " ) )
) ;
if ( ObjectUtil . isEmpty ( structattrList ) ) {
if ( ObjectUtil . isEmpty ( structattrList ) ) {
throw new BadRequestException ( " 该库区没有仓位 " ) ;
}
// 过滤掉不满足载具长宽高的仓位
Structattr structattr = structattrList . stream ( ) . filter ( st - >
st . getWidth ( ) . compareTo ( mdPbStoragevehicleinfo . getVehicle_width ( ) ) > = 0 & &
st . getHeight ( ) . compareTo ( mdPbStoragevehicleinfo . getVehicle_height ( ) ) > = 0 & &
st . getZdepth ( ) . compareTo ( mdPbStoragevehicleinfo . getVehicle_long ( ) ) > = 0
st . getWidth ( ) . compareTo ( mdPbStoragevehicleinfo . getVehicle_width ( ) ) > = 0 & &
st . getHeight ( ) . compareTo ( mdPbStoragevehicleinfo . getVehicle_height ( ) ) > = 0 & &
st . getZdepth ( ) . compareTo ( mdPbStoragevehicleinfo . getVehicle_long ( ) ) > = 0
) . findAny ( ) . get ( ) ;
if ( ObjectUtil . isEmpty ( structattr ) ) {
if ( ObjectUtil . isEmpty ( structattr ) ) {
throw new BadRequestException ( " 未找到满足的仓位 " ) ;
}
@@ -778,65 +788,105 @@ public class RawAssistIStorServiceImpl extends ServiceImpl<IOStorInvMapper, IOSt
@Override
@Transactional
public void download ( Map whereJson , HttpServletResponse response ) throws IOException {
HashMap < String , String > map = new HashMap < > ( ) ;
map . put ( " buss_type " , ( String ) whereJson . get ( " buss_type " ) ) ;
map . put ( " stor_id " , ( String ) whereJson . get ( " stor_id " ) ) ;
map . put ( " bill_type " , ( String ) whereJson . get ( " bill_type " ) ) ;
map . put ( " create_mode " , ( String ) whereJson . get ( " create_mode " ) ) ;
map . put ( " bill_status " , ( String ) whereJson . get ( " bill_status " ) ) ;
String bill_code = MapUtil . getStr ( whereJson , " bill_code " ) ;
String pcsn = MapUtil . getStr ( whereJson , " pcsn " ) ;
if ( ! ObjectUtil . isEmpty ( bill_code ) ) {
map . put ( " bill_code " , " % " + bill_code + " % " ) ;
// --------------组织数据--------------
IOStorInv mstDao = this . ioStorInvMapper . selectById ( whereJson . get ( " iostorinv_id " ) . toString ( ) ) ;
if ( ! mstDao . getBill_status ( ) . equals ( IOSEnum . BILL_STATUS . code ( " 完成 " ) ) ) {
throw new BadRequestException ( " 单据未完成! " ) ;
}
// 空格 查询
if ( StrUtil . isNotEmpty ( pcsn ) ) {
// 判断是否有空格
boolean matches = pcsn . matches ( " .* \\ s.* " ) ;
// 查询明细
List < IOStorInvDtl > dtlList = ioStorInvDtlMapper . selectList (
new QueryWrapper < IOStorInvDtl > ( ) . lambda ( )
. eq ( IOStorInvDtl : : getIostorinv_id , mstDao . getIostorinv_id ( ) )
) ;
// 查询分配明细
List < IOStorInvDis > disDaoList = ioStorInvDisMapper . selectList (
new QueryWrapper < IOStorInvDis > ( ) . lambda ( )
. eq ( IOStorInvDis : : getIostorinv_id , mstDao . getIostorinv_id ( ) )
) ;
// 查询物料
List < MdMeMaterialbase > materList = iMdMeMaterialbaseService . list (
new QueryWrapper < MdMeMaterialbase > ( ) . lambda ( )
. in ( MdMeMaterialbase : : getMaterial_id , disDaoList . stream ( )
. map ( IOStorInvDis : : getMaterial_id )
. distinct ( )
. collect ( Collectors . toList ( ) ) )
) ;
if ( ObjectUtil . isEmpty ( materList ) ) {
throw new BadRequestException ( " 未查询到相关物料信息! " ) ;
}
if ( matches ) {
String [ ] s = pcsn . sp lit( " " ) ;
String pcsn_in = String . join ( " ',' " , Arrays . asList ( s ) ) ;
// 查询客户
List < MdCsCustomerbase > custList = iMdCsCustomerbaseService . lis t (
new QueryWrapper < MdCsCustomerbase > ( ) . lambda ( )
. in ( MdCsCustomerbase : : getCust_code , disDaoList . stream ( )
. map ( IOStorInvDis : : getCust_code )
. distinct ( )
. collect ( Collectors . toList ( ) ) ) ) ;
if ( ObjectUtil . isEmpty ( custList ) ) {
throw new BadRequestException ( " 未查询到相关客户信息! " ) ;
}
map . put ( " pcsn_in " , " (' " + pcsn_in + " ') " ) ;
} else {
map . put ( " pcsn " , " % " + pcsn + " % " ) ;
// excel多组填充
ArrayList < HashMap < String , Object > > flData = new ArrayList < > ( ) ;
double sum_qty = 0 . 00 ;
for ( IOStorInvDtl dtlDao : dtlList ) {
HashMap < String , Object > map = new HashMap < > ( ) ;
// 查询一条分配明细
IOStorInvDis disDao = disDaoList . stream ( )
. filter ( row - > row . getIostorinvdtl_id ( ) . equals ( dtlDao . getIostorinvdtl_id ( ) ) )
. findFirst ( ) . orElse ( null ) ;
// 客户
MdCsCustomerbase custDao = custList . stream ( )
. filter ( row - > row . getCust_code ( ) . equals ( disDao . getCust_code ( ) ) )
. findFirst ( ) . orElse ( null ) ;
if ( ObjectUtil . isEmpty ( custDao ) ) {
throw new BadRequestException ( " 没有此编码【 " + disDao . getCust_code ( ) + " 】客户 " ) ;
}
map . put ( " cust_name " , custDao . getCust_name ( ) ) ;
// 物料信息
MdMeMaterialbase materDao = materList . stream ( )
. filter ( row - > row . getMaterial_id ( ) . equals ( dtlDao . getMaterial_id ( ) ) )
. findFirst ( ) . orElse ( null ) ;
if ( ObjectUtil . isEmpty ( materDao ) ) {
throw new BadRequestException ( " 没有此ID【 " + dtlDao . getMaterial_id ( ) + " 】物料 " ) ;
}
map . put ( " material_name " , materDao . getMaterial_name ( ) ) ;
map . put ( " material_model " , materDao . getMaterial_model ( ) ) ;
// 数量
map . put ( " qty " , dtlDao . getPlan_qty ( ) ) ;
// 单价
map . put ( " price " , NumberUtil . round ( materDao . getMaterial_price ( ) , 2 ) ) ;
// 金额 = 单价 * 数量
BigDecimal amount = NumberUtil . mul ( materDao . getMaterial_price ( ) , dtlDao . getPlan_qty ( ) ) ;
map . put ( " amount " , NumberUtil . round ( amount , 2 ) ) ;
// 合同编号
map . put ( " contract " , disDao . getContract_code ( ) ) ;
sum_qty = NumberUtil . add ( sum_qty , amount ) . doubleValue ( ) ;
flData . add ( map ) ;
}
String begin_time = ( String ) whereJson . get ( " begin_time " ) ;
if ( ! StrUtil . isEmpty ( begin_time ) ) {
map . put ( " begin_time " , begin_time ) ;
// 获取输出流
ServletOutputStream outputStream = response . getOutputStream ( ) ;
// 获取模板地址
SysParamServiceImpl sysParamService = SpringContextHolder . getBean ( SysParamServiceImpl . class ) ;
Param excelParam = sysParamService . findByCode ( SysParamConstant . EXCEL_TEMPLATE ) ;
ExcelWriter workBook = EasyExcel . write ( outputStream , null ) . withTemplate ( excelParam . getValue ( ) ) . build ( ) ;
// 根据出入库类型获取sheet
int sheetInt = 0 ;
if ( mstDao . getIo_type ( ) . equals ( IOSEnum . IO_TYPE . code ( " 出库 " ) ) ) {
sheetInt = 1 ;
}
String end_time = ( String ) w hereJson . get ( " end_time " ) ;
if ( ! StrUtil . isEmpty ( end_time ) ) {
map . put ( " end_time " , end_time ) ;
}
List < JSONObject > disList = ioStorInvMapper . queryAlldownload ( map ) ;
WriteSheet sheet = EasyExcel . writerSheet ( s heetInt ) . build ( ) ;
// 单组填充
HashMap < String , Object > oneMap = new HashMap < > ( ) ;
oneMap . put ( " sum_qty " , sum_qty ) ;
workBook . fill ( oneMap , sheet ) ;
List < Map < String , Object > > list = new ArrayList < > ( ) ;
for ( JSONObject json : disL ist ) {
Map < String , Object > mp = new LinkedHashMap < > ( ) ;
mp . put ( " 入库单编码 " , json . getString ( " bill_code " ) ) ;
mp . put ( " 物料编码 " , json . getString ( " material_code " ) ) ;
mp . put ( " 物料名称 " , json . getString ( " material_name " ) ) ;
mp . put ( " 入库批次 " , json . getString ( " pcsn " ) ) ;
mp . put ( " 入库载具 " , json . getString ( " storagevehicle_code " ) ) ;
mp . put ( " 入库仓位 " , json . getString ( " struct_code " ) ) ;
mp . put ( " 入库数量 " , json . getString ( " plan_qty " ) ) ;
mp . put ( " 单位 " , json . getString ( " qty_unit_name " ) ) ;
mp . put ( " 单据状态 " , json . getString ( " bill_status " ) ) ;
mp . put ( " 创建人 " , json . getString ( " input_optname " ) ) ;
mp . put ( " 创建时间 " , json . getString ( " input_time " ) ) ;
mp . put ( " 完成人 " , json . getString ( " confirm_optname " ) ) ;
mp . put ( " 完成时间 " , json . getString ( " confirm_time " ) ) ;
list . add ( mp ) ;
}
FileUtil . downloadExcel ( list , response ) ;
// 多组填充
workBook . fill ( new FillWrapper ( " data " , flData ) , sheet ) ;
workBook . fin ish ( ) ;
outputStream . close ( ) ;
}
}