This commit is contained in:
jing's 2024-01-19 17:56:03 +08:00
parent 05cc8db7db
commit ce9596a61f
8 changed files with 141 additions and 76 deletions

View File

@ -193,12 +193,17 @@ public class MBomApi extends BaseApi {
public ResultVO<Boolean> confirmBack(@RequestBody List<Long> rowIds){
VUtils.isTure(CollectionUtil.isEmpty(rowIds)).throwMessage("选择行数据操作");
bomNewMbomBackMaterialService.confirmBack(rowIds);
return ResultVO.success(true);
try {
bomNewMbomBackMaterialService.confirmBack(rowIds);
return ResultVO.success(true);
}catch (Exception e){
throw new NflgBusinessException(STATE.Error,"联系管理员,"+e.getMessage());
}
}
}

View File

@ -9,7 +9,7 @@ import lombok.Getter;
public enum VirtualPackageTypeEnum implements ValueEnum<Integer>{
//1-发货包 2-制作包 4-直发包 8-发货前装配包
UN_VIRTUAL_PACKAGE(1,"非虚拟包","" ,"", ""),
UN_VIRTUAL_PACKAGE(0,"非虚拟包","" ,"", ""),
DELIVERY_PACKAGE(1,"发货包","发货" ,"201101", ""),
MAKING_PACKAGE(2,"制作包","制作","201101",""),
DIRECT_DELIVERY_PACKAGE(4,"直发包","直发","201101","F"),

View File

@ -30,6 +30,15 @@ public class BomNewEbomMaterialQuery implements Serializable {
*/
@ApiModelProperty(value = "物料编码")
private String materialNo;
@ApiModelProperty(value = "上级rowId")
private Long bomRowId;
@ApiModelProperty(value = "当前行rowId")
private Long rowId;

View File

@ -1212,18 +1212,36 @@ public class BomNewEbomParentService extends ServiceImpl<BomNewEbomParentMapper,
}
BomNewEbomParentEntity bomParent=null;
if(query.getBomRowId()!=null){
bomParent= getById(query.getBomRowId());
}
if (CollUtil.isNotEmpty(materialMainList)) {
MaterialMainEntity materialMainEntity = materialMainList.get(0);
BomNewEbomParentVO baseMaterialVO = new BomNewEbomParentVO();
BeanUtil.copyProperties(materialMainEntity, baseMaterialVO);
// baseMaterialVO.setCreatedBy(SessionUtil.getUserCode());
baseMaterialVO.setRowId(null);
baseMaterialVO.setExceptionStatus(materialMainEntity.getMaterialState());
baseMaterialVO.setRowId(query.getRowId());
materialMainEntity.setProjectType(null);
baseMaterialVO.setDeviseUserCode(SessionUtil.getUserCode());
baseMaterialVO.setDeviseName(SessionUtil.getRealName());
baseMaterialVO.setCreatedBy(SessionUtil.getUserCode());
baseMaterialVO.setCreatedTime(LocalDateTime.now());
baseMaterialVO.setModifyTime(LocalDateTime.now());
baseMaterialVO.setUnitWeight(new BigDecimal(materialMainEntity.getMaterialWeight()));
if(bomParent!=null){
baseMaterialVO.setEditStatus(bomParent.getEditStatus());
baseMaterialVO.setStatus(bomParent.getStatus());
}
baseMaterialVO.setTotalWeight(NumberUtil.mul(baseMaterialVO.getUnitWeight(), baseMaterialVO.getNum()));
return baseMaterialVO;
}
throw new NflgBusinessException(STATE.Error, "未查询到相关物料信息");
}
/**

View File

@ -12,10 +12,12 @@ import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.nflg.product.base.core.conmon.util.SessionUtil;
import com.nflg.product.base.core.exception.NflgBusinessException;
import com.nflg.product.bomnew.constant.FactoryCodeEnum;
import com.nflg.product.bomnew.constant.MBomConstantEnum;
import com.nflg.product.bomnew.constant.ProjectTypeInputTypeEnum;
import com.nflg.product.bomnew.constant.VirtualPackageTypeEnum;
import com.nflg.product.bomnew.mapper.master.BomNewMbomBackMaterialMapper;
import com.nflg.product.bomnew.pojo.dto.BomNewMBomChildDTO;
import com.nflg.product.bomnew.pojo.dto.BomNewMbomApplyBackMaterialDTO;
import com.nflg.product.bomnew.pojo.dto.BomNewMbomBackMaterialDTO;
import com.nflg.product.bomnew.pojo.entity.BomNewMbomBackMaterialEntity;
@ -36,8 +38,11 @@ import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import java.util.Objects;
import java.util.concurrent.ExecutionException;
import java.util.stream.Collectors;
import static com.nflg.product.bomnew.constant.EBomConstant.MAIN_FACTORY_CODE_1010;
/**
* t_bom_new_mbom_back_material 表服务实现类
@ -115,6 +120,7 @@ private void checkBackStatus( List<BomNewMbomBackMaterialEntity> backList){
/**
* 驳回
* 1010工厂处理
* @param rowIds
*/
@Transactional(rollbackFor = Exception.class)
@ -129,6 +135,11 @@ private void checkBackStatus( List<BomNewMbomBackMaterialEntity> backList){
checkBackStatus(backList);
List<String> facList=SpringUtil.getBean(UserRoleService.class).getUserOfFactory();
if(!facList.contains(MAIN_FACTORY_CODE_1010)){
throw new NflgBusinessException(STATE.BusinessError,StrUtil.format("你不是{}工厂用户不能操作",MAIN_FACTORY_CODE_1010));
}
//修改物料退回
for ( BomNewMbomBackMaterialEntity entity:
@ -160,7 +171,7 @@ private void checkBackStatus( List<BomNewMbomBackMaterialEntity> backList){
/**
* 申请退回
*
*只能退回1020工厂的
*/
@Transactional(rollbackFor = Exception.class)
public void applyBack(BomNewMbomApplyBackMaterialDTO dto ){
@ -177,9 +188,16 @@ private void checkBackStatus( List<BomNewMbomBackMaterialEntity> backList){
List<Long> backRowId=rowIds.stream().map(BomNewMbomBackMaterialDTO::getRowId).collect(Collectors.toList());
QueryWrapper<BomNewMbomBackMaterialEntity> queryWrapper=new QueryWrapper<>();
queryWrapper.lambda().in(BomNewMbomBackMaterialEntity::getDetailRowId,backRowId);
queryWrapper.lambda().eq(BomNewMbomBackMaterialEntity::getBackStatus,MBomConstantEnum.MBomBackStatusEnum.REJECT_2.getValue());
List<BomNewMbomBackMaterialEntity> backList=getBaseMapper().selectList(queryWrapper);
checkBackStatus(backList);
if(CollectionUtil.isNotEmpty(backList)){
throw new NflgBusinessException(STATE.BusinessError,"选择数据申请退回中或已处理退回");
}
@ -192,6 +210,12 @@ private void checkBackStatus( List<BomNewMbomBackMaterialEntity> backList){
throw new NflgBusinessException(STATE.BusinessError,"虚拟包数据不能进行退回");
}
if(detailEntityList.get(0).getFacCode().equals(FactoryCodeEnum.FACTORY_1010.getValue())){
throw new NflgBusinessException(STATE.BusinessError,StrUtil.format("{}({}) 工厂数据不能退回",FactoryCodeEnum.FACTORY_1010.getDescription(),FactoryCodeEnum.FACTORY_1010.getValue()));
}
//订单号
String orderNo;
if(CollectionUtil.isNotEmpty(detailEntityList)){
@ -217,8 +241,6 @@ private void checkBackStatus( List<BomNewMbomBackMaterialEntity> backList){
for (BomNewMbomBackMaterialEntity item:
backMaterialEntityList) {
item.setBackUserName(SessionUtil.getRealName());
item.setBackUserCode(SessionUtil.getUserCode());
item.setCreatedTime(LocalDateTime.now());
@ -226,16 +248,17 @@ private void checkBackStatus( List<BomNewMbomBackMaterialEntity> backList){
item.setReasonMsg(dto.getReasonMsg());
item.setOrderNo(orderNo);
item.setBackStatus(MBomConstantEnum.MBomBackStatusEnum.APPLY_0.getValue());
if(item.getProjectType().equals(ProjectTypeInputTypeEnum.ProjectTypeEnum.TYPE_Q.getValue())){
item.setGroupRowId(SpringUtil.getBean(BomNewMbomDetailService.class).getGroupRowId(item.getDetailRowId()));
}else{
if (item.getProjectType().equals(ProjectTypeInputTypeEnum.ProjectTypeEnum.TYPE_Q.getValue())) {
item.setGroupRowId(SpringUtil.getBean(BomNewMbomDetailService.class).getGroupRowId(item.getDetailRowId()));
} else {
item.setGroupRowId(SpringUtil.getBean(BomNewMbomDetailService.class).getGroupRowId(findRootRowId(item.getDetailRowId())));
}
saveBackList.add(beanBack);
});
this.save(item);
SpringUtil.getBean(BomNewMbomDetailService.class).getBaseMapper().updateBackStatus(item.getGroupRowId(),
MBomConstantEnum.MaterialBackStatusEnum.DEAL_1.getValue());
this.saveBatch(saveBackList);
}
}
@ -250,15 +273,16 @@ private void checkBackStatus( List<BomNewMbomBackMaterialEntity> backList){
*/
private Long findRootRowId(Long rowId){
//向上到根
List<BomNewMbomMiddleVO> childList = SpringUtil.getBean(BomNewMbomParentService.class).getBaseMapper()
.searchList(rowId);
BomNewMbomMiddleVO root=listToTree(childList);
for (;root!=null;) {
//查找根非虚拟包
if(root.getVirtualPartType()!=null&&
root.getVirtualPartType().intValue()== VirtualPackageTypeEnum.UN_VIRTUAL_PACKAGE.getValue()){
root.getVirtualPartType().intValue()== VirtualPackageTypeEnum.UN_VIRTUAL_PACKAGE.getValue().intValue()){
return root.getRowId();
}
if(CollectionUtil.isNotEmpty(root.getChildNodes())){
@ -301,58 +325,52 @@ private void checkBackStatus( List<BomNewMbomBackMaterialEntity> backList){
* @param rowIds
*/
@Transactional(rollbackFor = Exception.class)
public void confirmBack(List<Long> rowIds ){
public void confirmBack(List<Long> rowIds ) throws ExecutionException, InterruptedException {
QueryWrapper<BomNewMbomBackMaterialEntity> queryWrapper=new QueryWrapper<>();
queryWrapper.lambda().in(BomNewMbomBackMaterialEntity::getRowId,rowIds);
List<BomNewMbomBackMaterialEntity> backList=getBaseMapper().selectList(queryWrapper);
Map<Integer,List<BomNewMbomBackMaterialEntity>> groupBackMap=backList.stream().collect(Collectors.groupingBy(BomNewMbomBackMaterialEntity::getBackStatus));
if(CollectionUtil.isNotEmpty(groupBackMap.get(MBomConstantEnum.MBomBackStatusEnum.DEAL_1.getValue()))){
throw new NflgBusinessException(STATE.BusinessError,"选择数据存在已确认退回");
checkBackStatus(backList);
List<String> facList=SpringUtil.getBean(UserRoleService.class).getUserOfFactory();
if(!facList.contains(MAIN_FACTORY_CODE_1010)){
throw new NflgBusinessException(STATE.BusinessError,StrUtil.format("你不是{}工厂用户不能操作",MAIN_FACTORY_CODE_1010));
}
if(CollectionUtil.isNotEmpty(groupBackMap.get(MBomConstantEnum.MBomBackStatusEnum.REJECT_2.getValue()))){
throw new NflgBusinessException(STATE.BusinessError,"选择数据存在已驳回");
// Map<Integer,List<BomNewMbomBackMaterialEntity>> groupBackMap=backList.stream().collect(Collectors.groupingBy(BomNewMbomBackMaterialEntity::getBackStatus));
for (BomNewMbomBackMaterialEntity item:
backList) {
BomNewMbomParentEntity parentEntity= SpringUtil.getBean(BomNewMbomParentService.class).getById(item.getBomRowId());
QueryWrapper<BomNewMbomDetailEntity > queryWrapper1=new QueryWrapper<>();
queryWrapper1.lambda().in(BomNewMbomDetailEntity::getRowId,item.getGroupRowId());
List<BomNewMbomDetailEntity> detailEntityList= SpringUtil.getBean(BomNewMbomDetailService.class).list(queryWrapper1);
SpringUtil.getBean(BomNewMbomDetailService.class).getBaseMapper().updateBackStatus(item.getGroupRowId(),
MBomConstantEnum.MaterialBackStatusEnum.REJECT_2.getValue());
List<Long> sourceIds= detailEntityList.stream().map(BomNewMbomDetailEntity::getSourceRowId).collect(Collectors.toList());
//重新发布
SpringUtil.getBean(BomNewPbomParentService.class).reConvertToMBom(parentEntity.getSourceRowId(),sourceIds);
BomNewMbomBackMaterialEntity bean=new BomNewMbomBackMaterialEntity();
bean.setRowId(item.getRowId());
bean.setBackStatus(MBomConstantEnum.MBomBackStatusEnum.DEAL_1.getValue());
bean.setConfirmTime(LocalDateTime.now());
bean.setModifyTime(LocalDateTime.now());
bean.setConfirmUserName(SessionUtil.getUserName());
bean.setConfirmUserName(SessionUtil.getUserName());
updateById(bean);
}
//退回逻辑
//同一个bom下退回的物料
Map<Long,List<BomNewMbomBackMaterialEntity>> groupBackMap2=backList.stream().collect(Collectors.groupingBy(BomNewMbomBackMaterialEntity::getBomRowId));
groupBackMap2.forEach((bomRowId,val)->{
BomNewMbomParentEntity parentEntity=SpringUtil.getBean(BomNewMbomParentService.class).getById(bomRowId);
if(parentEntity==null){
throw new NflgBusinessException(STATE.BusinessError , StrUtil.format("{} 数据不存在 退回生成异常",bomRowId));
}
List<Long> updateSourceIdList=val.stream().map(BomNewMbomBackMaterialEntity::getSourceRowId).collect(Collectors.toList());
//重新发布
//SpringUtil.getBean(BomNewPbomParentService.class).reConvertToMBom(parentEntity.getSourceRowId(),updateSourceIdList);
//更新状态
List<Long> updateIdList=val.stream().map(BomNewMbomBackMaterialEntity::getRowId).collect(Collectors.toList());
UpdateWrapper<BomNewMbomBackMaterialEntity> updateWrapper=new UpdateWrapper();
updateWrapper.lambda().in(BomNewMbomBackMaterialEntity::getRowId,updateIdList);
updateWrapper.lambda().set(BomNewMbomBackMaterialEntity::getBackStatus, MBomConstantEnum.MBomBackStatusEnum.DEAL_1.getValue());
updateWrapper.lambda(). set(BomNewMbomBackMaterialEntity::getConfirmTime,LocalDateTime.now());
updateWrapper.lambda(). set(BomNewMbomBackMaterialEntity::getConfirmUserName,SessionUtil.getUserName());
updateWrapper.lambda(). set(BomNewMbomBackMaterialEntity::getConfirmUserCode,SessionUtil.getUserCode());
update(updateWrapper);
});

View File

@ -5,6 +5,7 @@ import cn.hutool.core.collection.CollUtil;
import cn.hutool.core.convert.Convert;
import cn.hutool.core.util.NumberUtil;
import cn.hutool.core.util.StrUtil;
import cn.hutool.extra.spring.SpringUtil;
import com.alibaba.excel.enums.BooleanEnum;
import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
@ -679,14 +680,20 @@ public class BomNewPbomParentService extends ServiceImpl<BomNewPbomParentMapper,
}
public void reConvertToMBom(Long bomRowId, List<Long> backRowId) {
/**
* 修改生产工厂
* 重新发布
*
*/
public void reConvertToMBom(Long bomRowId, List<Long> sourceRowId) throws ExecutionException, InterruptedException {
UpdateWrapper<BomNewPbomChildEntity> updateWrapper = new UpdateWrapper<>();
updateWrapper.lambda().set(BomNewPbomChildEntity::getProductionFactoryCode, backRowId);
updateWrapper.lambda().in(BomNewPbomChildEntity::getRowId, backRowId);
updateWrapper.lambda().set(BomNewPbomChildEntity::getProductionFactoryCode, FactoryCodeEnum.FACTORY_1010.getValue());
updateWrapper.lambda().in(BomNewPbomChildEntity::getRowId, sourceRowId);
SpringUtil.getBean(BomNewPbomChildService.class).update(updateWrapper);
convertToMBomFor1020(bomRowId);
}

View File

@ -56,7 +56,13 @@
<select id="getSourceRowId" resultType="java.lang.String">
SELECT GROUP_CONCAT( source_row_id) ids
from t_bom_new_mbom_detail
WHERE
row_id in (${rowIds})
</select>
<!--向下递归查找-->
<select id="getGroupRowId" resultType="java.lang.String">
@ -74,7 +80,7 @@
, t_bom_new_mbom_detail d
WHERE
FIND_IN_SET( d.row_id
, dd._ids );
, dd._ids )
</select>
<update id="updateBackStatus" >

View File

@ -106,12 +106,12 @@
<!-- </select>-->
<select id="getParentChild" resultType="com.nflg.product.bomnew.pojo.vo.BomNewMbomMiddleVO">
select t1.*,IFNULL(t2.back_status,0) as back_status,
(SELECT count(1) from t_bom_new_mbom_detail where parent_row_id=t1.row_id) as bom_exist
select t1.*,t2.status,
(SELECT count(1) from t_bom_new_mbom_detail where parent_row_id=t1.row_id) as bom_exist
from t_bom_new_mbom_detail as t1
left join t_bom_new_mbom_back_material as t2
on t1.row_id=t2.detail_row_id
left join t_bom_new_mbom_parent as t2
on
t1.bom_row_id=t2.row_id
where t1.parent_row_id = #{rowId}
<if test="bomRowId!=null and bomRowId!=0">
and t1.bom_row_id=#{bomRowId}
@ -161,7 +161,7 @@
<!--向上递归查找-->
<select id="searchList" resultType="com.nflg.product.bomnew.pojo.vo.BomNewMbomMiddleVO">
<![CDATA[
select T1.*
select T1.*,T2.status
from (SELECT t2.*, (SELECT count(1) from t_bom_new_mbom_detail where parent_row_id = t2.row_id) as bom_exist
FROM (SELECT @r AS _row_id,
(SELECT @r := parent_row_id
@ -174,6 +174,8 @@
JOIN t_bom_new_mbom_detail t2
ON t1._row_id = t2.row_id
)as T1
left join t_bom_new_mbom_parent as T2
on T1.bom_row_id=T2.row_id
]]>
</select>