@ -306,11 +306,15 @@ public class BaseKnifeController extends BaseController
@PostMapping ( " /open/productionArrangements " )
@ResponseBody
public AjaxResult productionArrangements ( @RequestBody String json ) {
/ / 验证请求数据
List < BaseTechnologyBom > technologyBomList = JSON . parseArray ( json , BaseTechnologyBom . class ) ;
if ( technologyBomList . isEmpty ( ) | | technologyBomList . size ( ) = = 1 & & technologyBomList . get ( 0 ) . getKnifeCode ( ) = = null )
return AjaxResult . error ( " 未检测到工艺bom项 " ) ;
technologyBomList . forEach ( baseTechnologyBom - > baseTechnologyBomService . insertBaseTechnologyBom ( baseTechnologyBom ) ) ;
/ / 记录数据修改
List < BaseKnife > baseKnifeOriginList = new ArrayList < > ( ) ;
/ / 构建日志
SysOperLog operLog = new SysOperLog ( ) ;
operLog . setTitle ( " 生产准备 " ) ;
@ -340,6 +344,7 @@ public class BaseKnifeController extends BaseController
/ / 台账表中查询工具 : 并记录数量
mdItemTemp = mdItemService . selectMdItemByCode ( techBom . getKnifeCode ( ) ) ;
if ( mdItemTemp = = null ) {
baseKnifeOriginList . forEach ( baseKnife - > baseKnifeService . updateBaseKnife ( baseKnife ) ) ;
operLog . setJsonResult ( " 物料台账查询错误: " + techBom . getKnifeCode ( ) ) ;
operLogService . insertOperlog ( operLog ) ;
return AjaxResult . error ( " 物料台账查询错误 " , techBom . getKnifeCode ( ) ) ;
@ -358,12 +363,12 @@ public class BaseKnifeController extends BaseController
bomRouteTemp . setMdItemId ( mdItemTemp . getItemId ( ) ) ;
List < BomRoute > bomRouteList = bomRouteService . selectBomRouteList ( bomRouteTemp ) ;
if ( bomRouteList . isEmpty ( ) ) {
baseKnifeOriginList . forEach ( baseKnife - > baseKnifeService . updateBaseKnife ( baseKnife ) ) ;
operLog . setJsonResult ( " Bom头查询错误: " + techBom . getKnifeCode ( ) ) ;
operLogService . insertOperlog ( operLog ) ;
return AjaxResult . error ( " Bom头查询错误 " , techBom . getKnifeCode ( ) ) ;
}
BomRoute bomRoute = bomRouteService . selectBomRouteByBomRouteId ( bomRouteList . get ( 0 ) . getBomRouteId ( ) ) ;
if ( ! bomRoute . getMbbProduBomList ( ) . isEmpty ( ) ) {
@ -376,6 +381,7 @@ public class BaseKnifeController extends BaseController
sitmTempList . removeIf ( baseKnife - > baseKnife . getKnifeLife ( ) + baseKnife . getResetCount ( ) * 100 < techBom . getExpendLife ( ) ) ;
if ( sitmTempList . isEmpty ( ) ) {
baseKnifeOriginList . forEach ( baseKnife - > baseKnifeService . updateBaseKnife ( baseKnife ) ) ;
operLog . setJsonResult ( " 基础物料不足进行组装工具: " + bom . getMdItemCode ( ) ) ;
operLogService . insertOperlog ( operLog ) ;
return AjaxResult . error ( " 基础物料不足进行组装工具 " , bom . getMdItemCode ( ) ) ;
@ -383,6 +389,7 @@ public class BaseKnifeController extends BaseController
if ( sitmTempList . size ( ) > = bom . getStandardDosage ( ) * knifeCount . get ( ) ) {
countMap . put ( sitmTempList . get ( 0 ) . getKnifeCode ( ) , bom . getStandardDosage ( ) * knifeCount . get ( ) ) ;
} else {
baseKnifeOriginList . forEach ( baseKnife - > baseKnifeService . updateBaseKnife ( baseKnife ) ) ;
operLog . setJsonResult ( " 基础物料不足进行组装工具: " + bom . getMdItemCode ( ) ) ;
operLogService . insertOperlog ( operLog ) ;
return AjaxResult . error ( " 基础物料不足进行组装工具 " , bom . getMdItemCode ( ) ) ;
@ -393,17 +400,20 @@ public class BaseKnifeController extends BaseController
/ / 判断基础物料是否充足
if ( sitmTempList . size ( ) < countMap . get ( sitmTempList . get ( 0 ) . getKnifeCode ( ) ) & & countMap . get ( sitmTempList . get ( 0 ) . getKnifeCode ( ) ) > bom . getStandardDosage ( ) * knifeCount . get ( ) ) {
baseKnifeOriginList . forEach ( baseKnife - > baseKnifeService . updateBaseKnife ( baseKnife ) ) ;
operLog . setJsonResult ( " 基础物料不足进行组装工具: " + techBom . getKnifeCode ( ) ) ;
operLogService . insertOperlog ( operLog ) ;
return AjaxResult . error ( " 基础物料不足进行组装工具 " , bom . getMdItemCode ( ) ) ;
}
}
} else {
baseKnifeOriginList . forEach ( baseKnife - > baseKnifeService . updateBaseKnife ( baseKnife ) ) ;
operLog . setJsonResult ( " 暂无记录整刀bom项: " + techBom . getKnifeCode ( ) ) ;
operLogService . insertOperlog ( operLog ) ;
return AjaxResult . error ( " 暂无记录整刀bom项 " , techBom . getKnifeCode ( ) ) ;
}
} else {
baseKnifeOriginList . forEach ( baseKnife - > baseKnifeService . updateBaseKnife ( baseKnife ) ) ;
operLog . setJsonResult ( " 基础物料不足: " + techBom . getKnifeCode ( ) ) ;
operLogService . insertOperlog ( operLog ) ;
return AjaxResult . error ( " 基础物料不足 " , techBom . getKnifeCode ( ) ) ;
@ -412,8 +422,16 @@ public class BaseKnifeController extends BaseController
/ / 将物料填入集合
tempList . forEach ( item - > {
if ( knifeCount . get ( ) > 0 & & tempList . size ( ) > countMap . get ( item . getKnifeCode ( ) ) ) {
/ / 更新数量
knifeCount . getAndDecrement ( ) ;
countMap . put ( item . getKnifeCode ( ) , countMap . get ( item . getKnifeCode ( ) ) + 1 ) ;
/ / 记录源数据然后锁定
baseKnifeOriginList . add ( item ) ;
item . setPlanSheet ( techBom . getTechnologyBomId ( ) ) ;
item . setIsLocked ( 1 ) ;
item . setLockedStartTime ( techBom . getLockedStartTime ( ) ) ;
item . setLockedEndTime ( techBom . getLockedEndTime ( ) ) ;
baseKnifeService . updateBaseKnife ( item ) ;
}
} ) ;
if ( knifeCount . get ( ) > 0 ) {
@ -423,6 +441,7 @@ public class BaseKnifeController extends BaseController
List < BomRoute > bomRouteList = bomRouteService . selectBomRouteList ( bomRouteTemp ) ;
if ( bomRouteList . isEmpty ( ) ) {
baseKnifeOriginList . forEach ( baseKnife - > baseKnifeService . updateBaseKnife ( baseKnife ) ) ;
operLog . setJsonResult ( " Bom头查询错误: " + techBom . getKnifeCode ( ) ) ;
operLogService . insertOperlog ( operLog ) ;
return AjaxResult . error ( " Bom头查询错误 " , techBom . getKnifeCode ( ) ) ;
@ -440,6 +459,7 @@ public class BaseKnifeController extends BaseController
sitmTempList . removeIf ( baseKnife - > baseKnife . getKnifeLife ( ) + baseKnife . getResetCount ( ) * 100 < techBom . getExpendLife ( ) ) ;
if ( sitmTempList . isEmpty ( ) ) {
baseKnifeOriginList . forEach ( baseKnife - > baseKnifeService . updateBaseKnife ( baseKnife ) ) ;
operLog . setJsonResult ( " 基础物料不足进行组装工具: " + bom . getMdItemCode ( ) ) ;
operLogService . insertOperlog ( operLog ) ;
return AjaxResult . error ( " 基础物料不足进行组装工具 " , bom . getMdItemCode ( ) ) ;
@ -447,6 +467,7 @@ public class BaseKnifeController extends BaseController
if ( sitmTempList . size ( ) > = bom . getStandardDosage ( ) * knifeCount . get ( ) ) {
countMap . put ( sitmTempList . get ( 0 ) . getKnifeCode ( ) , bom . getStandardDosage ( ) * knifeCount . get ( ) ) ;
} else {
baseKnifeOriginList . forEach ( baseKnife - > baseKnifeService . updateBaseKnife ( baseKnife ) ) ;
operLog . setJsonResult ( " 基础物料不足进行组装工具: " + bom . getMdItemCode ( ) ) ;
operLogService . insertOperlog ( operLog ) ;
return AjaxResult . error ( " 基础物料不足进行组装工具 " , bom . getMdItemCode ( ) ) ;
@ -457,17 +478,20 @@ public class BaseKnifeController extends BaseController
/ / 判断基础物料是否充足
if ( sitmTempList . size ( ) < countMap . get ( sitmTempList . get ( 0 ) . getKnifeCode ( ) ) & & countMap . get ( sitmTempList . get ( 0 ) . getKnifeCode ( ) ) > bom . getStandardDosage ( ) * knifeCount . get ( ) ) {
baseKnifeOriginList . forEach ( baseKnife - > baseKnifeService . updateBaseKnife ( baseKnife ) ) ;
operLog . setJsonResult ( " 基础物料不足进行组装工具: " + techBom . getKnifeCode ( ) ) ;
operLogService . insertOperlog ( operLog ) ;
return AjaxResult . error ( " 基础物料不足进行组装工具 " , bom . getMdItemCode ( ) ) ;
}
}
} else {
baseKnifeOriginList . forEach ( baseKnife - > baseKnifeService . updateBaseKnife ( baseKnife ) ) ;
operLog . setJsonResult ( " 暂无记录整刀bom项: " + techBom . getKnifeCode ( ) ) ;
operLogService . insertOperlog ( operLog ) ;
return AjaxResult . error ( " 暂无记录整刀bom项 " , techBom . getKnifeCode ( ) ) ;
}
} else {
baseKnifeOriginList . forEach ( baseKnife - > baseKnifeService . updateBaseKnife ( baseKnife ) ) ;
operLog . setJsonResult ( " 基础物料不足: " + techBom . getKnifeCode ( ) ) ;
operLogService . insertOperlog ( operLog ) ;
return AjaxResult . error ( " 基础物料不足 " , techBom . getKnifeCode ( ) ) ;
@ -504,6 +528,7 @@ public class BaseKnifeController extends BaseController
List < BomRoute > bomRouteList = bomRouteService . selectBomRouteList ( bomRouteTemp ) ;
if ( bomRouteList . isEmpty ( ) ) {
baseKnifeOriginList . forEach ( baseKnife - > baseKnifeService . updateBaseKnife ( baseKnife ) ) ;
operLog . setJsonResult ( " Bom头查询错误: " + techBom . getKnifeCode ( ) ) ;
operLogService . insertOperlog ( operLog ) ;
return AjaxResult . error ( " Bom头查询错误 " , techBom . getKnifeCode ( ) ) ;
@ -511,14 +536,16 @@ public class BaseKnifeController extends BaseController
WmsZdTask wmsZdTask = new WmsZdTask ( ) ;
wmsZdTask . setmProductId ( mdItem . getItemId ( ) ) ;
wmsZdTask . setCode ( techBom . getProcessCode ( ) + mdItem . getItemCode ( ) ) ;
wmsZdTask . setName ( techBom . getProcessName ( ) + " [ " + mdItem . getItemName ( ) + " ] " ) ;
wmsZdTask . setAttr4 ( techBom . getTechnologyBomId ( ) ) ;
wmsZdTask . setCode ( techBom . getProcessCode ( ) ) ;
wmsZdTask . setName ( techBom . getProcessName ( ) ) ;
wmsZdTask . setProductIdQty ( count ) ;
wmsZdTask . setAttr1 ( bomRouteList . get ( 0 ) . getBomRouteId ( ) ) ;
wmsZdTask . setCreateTime ( DateUtils . getNowDate ( ) ) ;
zdTaskService . insertWmsZdTask ( wmsZdTask ) ;
msg = " 生产准备验证成功! 已生成组装任务!" ;
msg = " 生产准备验证成功! 缺少物料 已生成组装任务!" ;
} else {
baseKnifeOriginList . forEach ( baseKnife - > baseKnifeService . updateBaseKnife ( baseKnife ) ) ;
operLog . setJsonResult ( " 缺少BOM项: " + techBom . getKnifeCode ( ) ) ;
operLogService . insertOperlog ( operLog ) ;
return AjaxResult . error ( " 缺少BOM项 " , techBom . getKnifeCode ( ) ) ;
@ -541,10 +568,8 @@ public class BaseKnifeController extends BaseController
@PutMapping ( " /zdTask " )
public AjaxResult zdTask ( @RequestBody WmsZdTask zdTask )
{
String planSheet = " JHD001 " ;
String batchNum = " ZZPC001 " ;
/ / 判断物料是否充足
BomRoute bomRoute = bomRouteService . selectBomRouteByBomRouteId ( zdTask . getAttr1 ( ) ) ;
BaseKnife baseKnifeWrapper = new BaseKnife ( ) ;
@ -561,8 +586,19 @@ public class BaseKnifeController extends BaseController
List < WmsOutPlanDetail > wmsOutPlanDetailList = new ArrayList < > ( ) ;
List < BaseKnife > baseKnifeListOutPlan = new ArrayList < > ( ) ;
/ / 查询工艺bom
BaseTechnologyBom technologyBom = new BaseTechnologyBom ( ) ;
if ( zdTask . getAttr4 ( ) ! = null ) {
technologyBom = baseTechnologyBomService . selectBaseTechnologyBomByTechnologyBomId ( zdTask . getAttr4 ( ) ) ;
} else {
technologyBom . setFigureCode ( zdTask . getCode ( ) ) ;
technologyBom . setLockedStartTime ( DateUtils . getNowDate ( ) ) ;
technologyBom . setLockedEndTime ( DateUtils . getNowDate ( ) ) ;
}
/ / 出库基础物料
WmsOutPlan outPlan = new WmsOutPlan ( ) ;
outPlan . setPlanCode ( zdTask . getCode ( ) ) ;
outPlan . setPlanCode ( technologyBom. getFigure Code( ) ) ;
outPlan . setWmsBusinessTypeId ( 12L ) ;
outPlan . setPlanState ( " 1 " ) ;
outPlan . setPlanType ( " ZDCK " ) ;
@ -573,6 +609,7 @@ public class BaseKnifeController extends BaseController
/ / 锁定物料
Boolean outPlanFlag = true ;
for ( int i = 0 ; i < zdTask . getProductIdQty ( ) ; i + + ) {
/ / 构建整刀
BaseKnife baseKnife = new BaseKnife ( ) ;
MdItem mdItem = mdItemService . selectMdItemById ( zdTask . getmProductId ( ) ) ;
baseKnife . setMbbBdMrlId ( zdTask . getmProductId ( ) ) ;
@ -581,17 +618,20 @@ public class BaseKnifeController extends BaseController
baseKnife . setKnifeUnit ( mdItem . getUnitName ( ) ) ;
baseKnife . setKnifeType ( mdItem . getItemTypeName ( ) ) ;
baseKnife . setAreaCode ( zdTask . getAttr3 ( ) ) ;
baseKnife . setSafeStock ( mdItem . getMinStock ( ) .toString ( ) . split ( " \\ . " ) [ 0 ] );
baseKnife . setSafeStock ( mdItem . getMinStock ( ) );
baseKnife . setStandardQuantity ( " 1 " ) ;
baseKnife . setKnifeLife ( 100 ) ;
baseKnife . setKnifeFineState ( 0 ) ;
baseKnife . setIsLocked ( 0 ) ;
baseKnife . setPlanSheet ( planSheet ) ;
baseKnife . setIsLocked ( 1 ) ;
baseKnife . setLockedStartTime ( technologyBom . getLockedStartTime ( ) ) ;
baseKnife . setLockedEndTime ( technologyBom . getLockedEndTime ( ) ) ;
baseKnife . setPlanSheet ( zdTask . getAttr4 ( ) ) ;
baseKnife . setItemOrProduct ( " PRODUCT " ) ;
baseKnife . setCreateBy ( getUsername ( ) ) ;
baseKnife . setCreateTime ( DateUtils . getNowDate ( ) ) ;
baseKnifeService . insertBaseKnife ( baseKnife ) ;
/ / 锁定物料
int resetCount = 0 ;
for ( MbbProduBom mbbProduBom : bomRoute . getMbbProduBomList ( ) ) {
baseKnifeWrapper . setMbbBdMrlId ( mbbProduBom . getMdItemId ( ) ) ;
@ -599,6 +639,7 @@ public class BaseKnifeController extends BaseController
baseKnifeList = baseKnifeService . selectBaseKnifeList ( baseKnifeWrapper ) ;
if ( outPlanFlag ) {
/ / 出库任务
MdItem mdItemOutPlan = mdItemService . selectMdItemById ( mbbProduBom . getMdItemId ( ) ) ;
WmsOutPlanDetail outPlanDetail = new WmsOutPlanDetail ( ) ;
outPlanDetail . setWmsOutPlanId ( outPlan . getWmsOutPlanId ( ) ) ;
@ -617,13 +658,14 @@ public class BaseKnifeController extends BaseController
wmsOutPlanDetailList . add ( outPlanDetail ) ;
}
/ / 锁定物料
int bomCount = mbbProduBom . getStandardDosage ( ) ;
for ( BaseKnife wmsBaseKnife : baseKnifeList ) {
if ( bomCount > 0 ) {
wmsBaseKnife . setIsLocked ( 1 ) ;
wmsBaseKnife . setKnifeFineState ( 2 ) ;
wmsBaseKnife . setLockedStartTime ( new Dat e( ) ) ;
wmsBaseKnife . setLockedEndTime ( new Dat e( ) ) ;
wmsBaseKnife . setLockedStartTime ( technologyBom . getLockedStartTim e( ) ) ;
wmsBaseKnife . setLockedEndTime ( technologyBom . getLockedEndTim e( ) ) ;
wmsBaseKnife . setAttr1 ( baseKnife . getBaseKnifeId ( ) ) ;
baseKnifeListOutPlan . add ( wmsBaseKnife ) ;
baseKnifeService . updateBaseKnife ( wmsBaseKnife ) ;
@ -633,15 +675,18 @@ public class BaseKnifeController extends BaseController
}
}
/ / 更新重置次数
outPlanFlag = false ;
baseKnife . setResetCount ( resetCount ) ;
baseKnifeService . updateBaseKnife ( baseKnife ) ;
}
/ / 出库
int i = 0 ;
for ( WmsOutPlanDetail outPlanDetail : wmsOutPlanDetailList ) {
wmsOutPlanMapper . insertWmsOutPlanDetail ( outPlanDetail ) ;
/ / 出库计划明细
for ( int j = 0 ; j < outPlanDetail . getPlannedQuantity ( ) ; j + + ) {
WmsOutPlanDetailEntity wmsOutPlanDetailEntity = new WmsOutPlanDetailEntity ( ) ;
wmsOutPlanDetailEntity . setBaseKnifeId ( baseKnifeListOutPlan . get ( i + + ) . getBaseKnifeId ( ) ) ;
@ -651,6 +696,7 @@ public class BaseKnifeController extends BaseController
wmsOutPlanDetailEntityMapper . insertWmsOutPlanDetailEntity ( wmsOutPlanDetailEntity ) ;
}
/ / 出库任务
WmsOutTask wmsOutTask = new WmsOutTask ( ) ;
wmsOutTask . setWmsOutPlanId ( outPlan . getWmsOutPlanId ( ) ) ;
wmsOutTask . setWmsOutPlanCode ( outPlan . getPlanCode ( ) ) ;
@ -672,17 +718,19 @@ public class BaseKnifeController extends BaseController
wmsOutTaskMapper . insertWmsOutTask ( wmsOutTask ) ;
}
/ / 整刀入库计划
Random random = new Random ( ) ;
WmsInPlan wmsInPlan = new WmsInPlan ( ) ;
wmsInPlan . setState ( " 1 " ) ;
wmsInPlan . setSourceType ( " SGLR " ) ;
wmsInPlan . setCellCode ( zdTask . getAttr3 ( ) ) ;
wmsInPlan . setPlanCode ( zdTask. getCode ( ) + random . nextInt ( 100 ) ) ;
wmsInPlan . setPlanCode ( technologyBom. getFigureCode ( ) ) ;
wmsInPlan . setRelBillCode ( " 组装单据 " ) ;
wmsInPlan . setPlanTypeId ( " 13 " ) ;
wmsInPlan . setCreateBy ( getUsername ( ) ) ;
wmsInPlan . setCreateTime ( DateUtils . getNowDate ( ) ) ;
/ / 入库任务明细
List < WmsInPlanDetails > wmsInPlanDetailsList = new ArrayList < > ( ) ;
WmsInPlanDetails wmsInPlanDetails = new WmsInPlanDetails ( ) ;
wmsInPlanDetails . setMaterialId ( zdTask . getmProductId ( ) . toString ( ) ) ;
@ -695,6 +743,7 @@ public class BaseKnifeController extends BaseController
wmsInPlan . setWmsInPlanDetailsList ( wmsInPlanDetailsList ) ;
wmsInPlanService . insertWmsInPlan ( wmsInPlan ) ;
/ / 入库任务
MdItem mdItem = mdItemService . selectMdItemById ( zdTask . getmProductId ( ) ) ;
WmsInTask wmsInTask = new WmsInTask ( ) ;
wmsInTask . setPlanInId ( wmsInPlan . getPlanId ( ) ) ;
@ -710,9 +759,11 @@ public class BaseKnifeController extends BaseController
wmsInTask . setPlanInStatus ( " 1 " ) ;
wmsInTaskService . insertWmsInTask ( wmsInTask ) ;
/ / 更新数量
mdItem . setStandardNumber ( mdItem . getStandardNumber ( ) + zdTask . getProductIdQty ( ) ) ;
mdItemService . updateMdItem ( mdItem ) ;
/ / 更新组装任务
zdTask . setStatus ( " 1 " ) ;
zdTask . setQtyOk ( zdTask . getProductIdQty ( ) ) ;
zdTaskService . updateWmsZdTask ( zdTask ) ;