@@ -2,12 +2,16 @@ package org.nl.b_lms.bst.ivt.stockingivt.service.impl;
import cn.hutool.core.date.DateUtil ;
import cn.hutool.core.util.IdUtil ;
import cn.hutool.core.util.ObjectUtil ;
import com.alibaba.fastjson.JSONObject ;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper ;
import com.baomidou.mybatisplus.core.metadata.IPage ;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page ;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl ;
import lombok.RequiredArgsConstructor ;
import lombok.extern.slf4j.Slf4j ;
import org.nl.b_lms.bst.ivt.papervehicle.service.IMdPbPapervehicleService ;
import org.nl.b_lms.bst.ivt.papervehicle.service.dao.MdPbPapervehicle ;
import org.nl.b_lms.sch.tasks.slitter.constant.SlitterConstant ;
import org.nl.modules.common.exception.BadRequestException ;
import org.nl.common.domain.query.PageQuery ;
@@ -16,6 +20,7 @@ import org.nl.b_lms.bst.ivt.stockingivt.service.IBstIvtStockingivtService;
import org.nl.b_lms.bst.ivt.stockingivt.service.dao.mapper.BstIvtStockingivtMapper ;
import org.nl.b_lms.bst.ivt.stockingivt.service.dao.BstIvtStockingivt ;
import org.springframework.beans.factory.annotation.Autowired ;
import org.springframework.http.HttpStatus ;
import org.springframework.stereotype.Service ;
import java.util.List ;
@@ -23,8 +28,8 @@ import java.util.Map;
import java.util.Set ;
/**
* @description 服务实现
* @author lyd
* @description 服务实现
* @date 2024-02-26
**/
@Slf4j
@@ -33,6 +38,8 @@ public class BstIvtStockingivtServiceImpl extends ServiceImpl<BstIvtStockingivtM
@Autowired
private BstIvtStockingivtMapper bstIvtStockingivtMapper ;
@Autowired
private IMdPbPapervehicleService PapervehicleService ;
@Override
public IPage < BstIvtStockingivt > queryAll ( Map whereJson , PageQuery page ) {
@@ -102,4 +109,54 @@ public class BstIvtStockingivtServiceImpl extends ServiceImpl<BstIvtStockingivtM
return bstIvtStockingivtMapper . getCanMovePointOne ( location , pointType ) ;
}
@Override
public JSONObject operateIvt ( JSONObject jsonObject ) {
String vehicle_code = jsonObject . getString ( " vehicle_code " ) ;
String row_num = jsonObject . getString ( " row_num " ) ;
String material_code = jsonObject . getString ( " material_code " ) ;
String material_name = jsonObject . getString ( " material_name " ) ;
String currentUserId = SecurityUtils . getCurrentUserId ( ) ;
String nickName = SecurityUtils . getCurrentNickName ( ) ;
String now = DateUtil . now ( ) ;
//1-绑定; 2-清除
String type = jsonObject . getString ( " type " ) ;
if ( type . equals ( " 1 " ) ) {
//查询当前载具和排是否存在库存
MdPbPapervehicle papervehicle = PapervehicleService . getOne ( new LambdaQueryWrapper < MdPbPapervehicle > ( ) . eq ( MdPbPapervehicle : : getVehicle_code , vehicle_code )
. eq ( MdPbPapervehicle : : getRow_num , row_num ) ) ;
if ( ObjectUtil . isNotEmpty ( papervehicle ) & & ! papervehicle . getMaterial_code ( ) . equals ( material_code ) ) {
throw new BadRequestException ( " 当前排物料为【 " + papervehicle . getMaterial_code ( ) + " 】,与绑定的物料不同,如需要请先清除库存,再进行绑定! " ) ;
}
if ( ObjectUtil . isNotEmpty ( papervehicle ) ) {
papervehicle . setQty ( jsonObject . getBigDecimal ( " qty " ) ) ;
papervehicle . setUpdate_optid ( currentUserId ) ;
papervehicle . setUpdate_optname ( nickName ) ;
papervehicle . setUpdate_time ( now ) ;
PapervehicleService . updateById ( papervehicle ) ;
} else {
papervehicle = new MdPbPapervehicle ( ) ;
papervehicle . setIvt_id ( IdUtil . getSnowflake ( 1 , 1 ) . nextIdStr ( ) ) ;
papervehicle . setVehicle_code ( vehicle_code ) ;
papervehicle . setRow_num ( row_num ) ;
papervehicle . setMaterial_code ( material_code ) ;
papervehicle . setMaterial_name ( material_name ) ;
papervehicle . setQty ( jsonObject . getBigDecimal ( " qty " ) ) ;
papervehicle . setUpdate_optid ( currentUserId ) ;
papervehicle . setUpdate_optname ( nickName ) ;
papervehicle . setUpdate_time ( now ) ;
PapervehicleService . save ( papervehicle ) ;
}
}
if ( type . equals ( " 2 " ) ) {
PapervehicleService . remove ( new LambdaQueryWrapper < MdPbPapervehicle > ( ) . eq ( MdPbPapervehicle : : getVehicle_code , vehicle_code )
. eq ( MdPbPapervehicle : : getRow_num , row_num ) ) ;
}
JSONObject result = new JSONObject ( ) ;
result . put ( " status " , HttpStatus . OK . value ( ) ) ;
result . put ( " message " , " 操作成功! " ) ;
return result ;
}
}