1.转EBOM
This commit is contained in:
parent
9eb0dcd64f
commit
eb19755b41
|
|
@ -47,7 +47,7 @@ import java.util.concurrent.ExecutionException;
|
|||
@Api(tags = "原始BOM")
|
||||
@RestController
|
||||
@RequestMapping("bom/new/bomOriginal")
|
||||
public class OriginalBomApi extends BaseApi {
|
||||
public class OriginalBomApi extends BaseApi {
|
||||
|
||||
@Resource
|
||||
BomNewOriginalParentService originalParentService;
|
||||
|
|
@ -78,15 +78,16 @@ public class OriginalBomApi extends BaseApi {
|
|||
public ResultVO<List<TreeNode<BomOriginalListVO>>> getChildTree(@RequestParam("rowId") Long rowId) throws ExecutionException, InterruptedException {
|
||||
return ResultVO.success(originalParentService.getChildTree(rowId));
|
||||
}
|
||||
|
||||
@PostMapping("saveBom")
|
||||
@ApiOperation("编辑时-暂存")
|
||||
public ResultVO<Boolean> saveBom(@Valid @RequestBody OriginalSaveBomDTO bom) {
|
||||
return ResultVO.success(originalParentService.saveBom(bom,false));
|
||||
return ResultVO.success(originalParentService.saveBom(bom, false));
|
||||
}
|
||||
|
||||
@PostMapping("saveSubmit")
|
||||
@ApiOperation("编辑时-提交")
|
||||
public ResultVO<Boolean> saveSubmit(@Valid @RequestBody OriginalSaveBomDTO bom) {
|
||||
public ResultVO<Boolean> saveSubmit(@Valid @RequestBody OriginalSaveBomDTO bom) {
|
||||
return ResultVO.success(originalParentService.saveSubmit(bom));
|
||||
}
|
||||
|
||||
|
|
@ -120,6 +121,7 @@ public class OriginalBomApi extends BaseApi {
|
|||
|
||||
/**
|
||||
* 原始BOM转EBom
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
@PostMapping("convertToEBom")
|
||||
|
|
@ -128,7 +130,7 @@ public class OriginalBomApi extends BaseApi {
|
|||
public ResultVO<Boolean> convertToEBom(@RequestBody List<Long> bomRowIds) throws ExecutionException, InterruptedException {
|
||||
|
||||
VUtils.isTure(CollUtil.isEmpty(bomRowIds)).throwMessage("请选择要转换的BOM");
|
||||
VUtils.isTure(bomRowIds.size()>20).throwMessage("你选择的BOM数据大于20");
|
||||
VUtils.isTure(bomRowIds.size() > 20).throwMessage("你选择的BOM数据大于20");
|
||||
originalParentService.convertToEBom(bomRowIds);
|
||||
//更新物料使用
|
||||
bomNewEbomChildMapper.updateEBomMaterialUse();
|
||||
|
|
@ -152,7 +154,7 @@ public class OriginalBomApi extends BaseApi {
|
|||
@ApiOperation("导入")
|
||||
@PostMapping("importBom")
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public ResultVO<Boolean> importBom(@RequestParam(value = "file")MultipartFile file) throws IOException {
|
||||
public ResultVO<Boolean> importBom(@RequestParam(value = "file") MultipartFile file) throws IOException {
|
||||
if (file != null && !file.getOriginalFilename().endsWith("xls") && !file.getOriginalFilename().endsWith("xlsx")) {
|
||||
return ResultVO.error("请上传Excel文件");
|
||||
}
|
||||
|
|
@ -160,12 +162,7 @@ public class OriginalBomApi extends BaseApi {
|
|||
|
||||
//计算层级
|
||||
originalParentService.computeLevelNumAndRootState();
|
||||
// TransactionSynchronizationManager.registerSynchronization(new TransactionSynchronizationAdapter() {
|
||||
// @Override
|
||||
// public void afterCommit() {
|
||||
// originalParentService.computeLevelNumAndRootState();
|
||||
// }
|
||||
// });
|
||||
|
||||
|
||||
return ResultVO.success(true);
|
||||
}
|
||||
|
|
@ -174,18 +171,18 @@ public class OriginalBomApi extends BaseApi {
|
|||
@ApiOperation("新增物料")
|
||||
@GetMapping("testaddMaterial")
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public ResultVO<String> testaddMaterial(@RequestParam(value = "drawingNo" ,required = false)String drawingNo,
|
||||
@RequestParam(value = "materialName" ,required = false)String materialName,
|
||||
@RequestParam("materialCategoryCode")String materialCategoryCode) throws IOException {
|
||||
public ResultVO<String> testaddMaterial(@RequestParam(value = "drawingNo", required = false) String drawingNo,
|
||||
@RequestParam(value = "materialName", required = false) String materialName,
|
||||
@RequestParam("materialCategoryCode") String materialCategoryCode) throws IOException {
|
||||
|
||||
materialService.addMaterial(drawingNo, materialName,materialCategoryCode);
|
||||
materialService.addMaterial(drawingNo, materialName, materialCategoryCode);
|
||||
return ResultVO.success("true");
|
||||
}
|
||||
|
||||
|
||||
@ApiOperation("获取sessionKey")
|
||||
@GetMapping("getSessionKey")
|
||||
public ResultVO<String> getSessionKey() {
|
||||
public ResultVO<String> getSessionKey() {
|
||||
|
||||
|
||||
return ResultVO.success(SessionUtil.getSessionKey());
|
||||
|
|
@ -196,19 +193,16 @@ public class OriginalBomApi extends BaseApi {
|
|||
@PostMapping("testImportBom")
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public ResultVO<Boolean> testImportBom() throws IOException {
|
||||
InputStream inputStream=new FileInputStream("C:\\Users\\01956\\Desktop\\西卡印尼烘干线总站BOM.xlsx");
|
||||
InputStream inputStream = new FileInputStream("C:\\Users\\01956\\Desktop\\西卡印尼烘干线总站BOM.xlsx");
|
||||
originalParentService.importBomTest(inputStream);
|
||||
TransactionSynchronizationManager.registerSynchronization(new TransactionSynchronizationAdapter() {
|
||||
@Override
|
||||
public void afterCommit() {
|
||||
originalParentService.computeLevelNumAndRootState();
|
||||
}
|
||||
});
|
||||
|
||||
// originalParentService.computeLevelNumAndRootState();
|
||||
|
||||
originalParentService.computeLevelNumAndRootState();
|
||||
|
||||
|
||||
return ResultVO.success(true);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -33,5 +33,8 @@ public interface BomNewOriginalParentMapper extends BaseMapper<BomNewOriginalPar
|
|||
/**
|
||||
* 更新是否根节点状态
|
||||
*/
|
||||
void updateRootState();
|
||||
void updateRootState_1();
|
||||
|
||||
void updateRootState_2();
|
||||
void updateRootState_3();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -8,6 +8,7 @@ import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
|||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import com.nflg.product.base.core.config.SpringContextUtils;
|
||||
import com.nflg.product.base.core.conmon.util.SessionUtil;
|
||||
import com.nflg.product.base.core.exception.NflgBusinessException;
|
||||
import com.nflg.product.bomnew.constant.OriginalConstant;
|
||||
import com.nflg.product.bomnew.constant.OriginalEditStatusEnum;
|
||||
import com.nflg.product.bomnew.constant.OriginalSourceEnum;
|
||||
|
|
@ -99,22 +100,22 @@ public class BomNewOriginalParentService extends ServiceImpl<BomNewOriginalParen
|
|||
* @param bom
|
||||
* @return
|
||||
*/
|
||||
public Boolean saveBom(OriginalSaveBomDTO bom ,Boolean submitIs) {
|
||||
public Boolean saveBom(OriginalSaveBomDTO bom, Boolean submitIs) {
|
||||
|
||||
List<BomOriginalListVO> saveEnts = bom.getBomList().stream().filter(u -> u.getDelIs().equals(0)).collect(Collectors.toList());
|
||||
List<BomNewOriginalChildEntity> childEntities = Convert.toList(BomNewOriginalChildEntity.class, saveEnts);
|
||||
// originalChildService.getBaseMapper().deleteByMap(ImmutableMap.of("parent_row_id",bom.getParentRowId()));
|
||||
childEntities.forEach(u -> {
|
||||
u.setParentRowId(bom.getParentRowId());
|
||||
if(submitIs){
|
||||
if (submitIs) {
|
||||
u.setEditStatus(OriginalEditStatusEnum.HANDLER_FINISHED.getValue());
|
||||
}
|
||||
});
|
||||
|
||||
if (CollUtil.isNotEmpty(childEntities)) {
|
||||
//删除行
|
||||
List<Long> delRowIds = bom.getBomList().stream().filter(u->u.getRowId()>0).map(u-> u.getRowId()).collect(Collectors.toList());
|
||||
originalChildService.getBaseMapper().delOriginalChildNotInRowIds(delRowIds,bom.getParentRowId());
|
||||
List<Long> delRowIds = bom.getBomList().stream().filter(u -> u.getRowId() > 0).map(u -> u.getRowId()).collect(Collectors.toList());
|
||||
originalChildService.getBaseMapper().delOriginalChildNotInRowIds(delRowIds, bom.getParentRowId());
|
||||
originalChildService.saveOrUpdateBatch(childEntities);
|
||||
}
|
||||
return true;
|
||||
|
|
@ -128,7 +129,7 @@ public class BomNewOriginalParentService extends ServiceImpl<BomNewOriginalParen
|
|||
* @return
|
||||
*/
|
||||
public Boolean saveSubmit(OriginalSaveBomDTO bom) {
|
||||
saveBom(bom,true);
|
||||
saveBom(bom, true);
|
||||
//将状态变为已处理
|
||||
BomNewOriginalParentEntity parentEntity = new BomNewOriginalParentEntity();
|
||||
parentEntity.setRowId(bom.getParentRowId());
|
||||
|
|
@ -161,13 +162,13 @@ public class BomNewOriginalParentService extends ServiceImpl<BomNewOriginalParen
|
|||
child.setStatus(parentEntity.getStatus());
|
||||
child.setDeviseName(parentEntity.getDeviseName());
|
||||
child.setDeviseUserCode(parentEntity.getDeviseUserCode());
|
||||
// child.setCreatedBy(parentEntity.getCreatedBy());
|
||||
// child.setCreatedTime(parentEntity.getCreatedTime());
|
||||
// child.setCreatedBy(parentEntity.getCreatedBy());
|
||||
// child.setCreatedTime(parentEntity.getCreatedTime());
|
||||
child.setBomRowId(parentEntity.getRowId());
|
||||
child.setLevelNum(parentEntity.getLevelNum());
|
||||
child.setDeptName(parentEntity.getDeptName());
|
||||
child.setSource(parentEntity.getSource());
|
||||
if(parentEntity.getStatus().equals(OriginalStatusEnum.OVER_CONVERT)){
|
||||
if (parentEntity.getStatus().equals(OriginalStatusEnum.OVER_CONVERT)) {
|
||||
child.setStatus(OriginalStatusEnum.BORROWED_PARTS.getValue());
|
||||
}
|
||||
//非本人则为借用件
|
||||
|
|
@ -233,7 +234,7 @@ public class BomNewOriginalParentService extends ServiceImpl<BomNewOriginalParen
|
|||
|
||||
if (CollUtil.isNotEmpty(list)) {
|
||||
for (BomNewOriginalParentEntity bom : list) {
|
||||
bom.setRootIs(1);
|
||||
// bom.setRootIs(1);
|
||||
List<BomOriginalListVO> bomDetail = this.getBaseMapper().getParentChild(bom.getRowId());
|
||||
OriginalBomDetailTask detailTask = new OriginalBomDetailTask(bomDetail);
|
||||
detailTask.setLevelNum(1);
|
||||
|
|
@ -284,16 +285,18 @@ public class BomNewOriginalParentService extends ServiceImpl<BomNewOriginalParen
|
|||
* 计算层级数和根节点状态
|
||||
*/
|
||||
public void computeLevelNumAndRootState() {
|
||||
//计算树的层级数
|
||||
// CompletableFuture.runAsync(() -> {
|
||||
try {
|
||||
this.getBaseMapper().updateRootState();
|
||||
this.compucteLevelNum();
|
||||
|
||||
} catch (Exception e) {
|
||||
log.info("计算层级出错:"+e.getMessage());
|
||||
}
|
||||
// });
|
||||
try {
|
||||
this.getBaseMapper().updateRootState_1();
|
||||
this.getBaseMapper().updateRootState_2();
|
||||
this.getBaseMapper().updateRootState_3();
|
||||
this.compucteLevelNum();
|
||||
|
||||
|
||||
} catch (Exception e) {
|
||||
|
||||
log.info("计算层级出错:" + e.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
|
@ -310,8 +313,8 @@ public class BomNewOriginalParentService extends ServiceImpl<BomNewOriginalParen
|
|||
List<BomOriginalListVO> bomTree = getBomTree(bomRowId);
|
||||
//需删除的BOM
|
||||
List<BomOriginalListVO> delBom = bomTree.stream().filter(u -> u.getBomRowId() > 0 && OriginalStatusEnum.UN_CONVERT.equalsValue(u.getStatus())).collect(Collectors.toList());
|
||||
List<Long> delParentRowId=new ArrayList<>();
|
||||
for ( BomOriginalListVO bom: delBom) {
|
||||
List<Long> delParentRowId = new ArrayList<>();
|
||||
for (BomOriginalListVO bom : delBom) {
|
||||
delParentRowId.add(bom.getBomRowId());
|
||||
}
|
||||
delParentRowId.add(bomRowId);
|
||||
|
|
@ -333,7 +336,7 @@ public class BomNewOriginalParentService extends ServiceImpl<BomNewOriginalParen
|
|||
List<BomNewOriginalParentEntity> bomNewOriginalParentEntities = this.getBaseMapper().selectBatchIds(bomRowIds);
|
||||
|
||||
List<BomNewOriginalParentEntity> convertedBom = bomNewOriginalParentEntities.stream().filter(u -> OriginalStatusEnum.OVER_CONVERT.equalsValue(u.getStatus())).collect(Collectors.toList());
|
||||
// VUtils.isTure(CollUtil.isNotEmpty(convertedBom)).throwMessage("所选BOM中存在已转换的BOM");
|
||||
// VUtils.isTure(CollUtil.isNotEmpty(convertedBom)).throwMessage("所选BOM中存在已转换的BOM");
|
||||
|
||||
//开始转换
|
||||
for (BomNewOriginalParentEntity parent : bomNewOriginalParentEntities) {
|
||||
|
|
@ -385,17 +388,16 @@ public class BomNewOriginalParentService extends ServiceImpl<BomNewOriginalParen
|
|||
/**
|
||||
* 原始BOM导入
|
||||
*/
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public void importBom(MultipartFile file) throws IOException {
|
||||
rowNum.set(1);
|
||||
excelContextTL.set(new ArrayList<>());
|
||||
String uuid = IdUtil.simpleUUID();
|
||||
EecExcelUtil.handlerExcel(file.getInputStream(), BomNewOriginalExcelDTO.class, BomNewOriginalParentService::handlerExcelRow);
|
||||
List<BomNewOriginalExcelDTO> excelContext = excelContextTL.get();
|
||||
List<Integer> noLevelNo = excelContext.stream().filter(u -> Objects.isNull(u.getLevelNo())).map(u->u.getRowNum()).collect(Collectors.toList());
|
||||
VUtils.isTure(CollUtil.isNotEmpty(noLevelNo)).throwMessage(StrUtil.join(",",noLevelNo )+"层次为空");
|
||||
List<Integer> noDrawingNo = excelContext.stream().filter(u -> StrUtil.isBlank(u.getChartNo())).map(u->u.getRowNum()).collect(Collectors.toList());
|
||||
VUtils.isTure(CollUtil.isNotEmpty(noDrawingNo)).throwMessage(StrUtil.join(",",noDrawingNo )+"图号为空");
|
||||
List<Integer> noLevelNo = excelContext.stream().filter(u -> Objects.isNull(u.getLevelNo())).map(u -> u.getRowNum()).collect(Collectors.toList());
|
||||
VUtils.isTure(CollUtil.isNotEmpty(noLevelNo)).throwMessage(StrUtil.join(",", noLevelNo) + "层次为空");
|
||||
List<Integer> noDrawingNo = excelContext.stream().filter(u -> StrUtil.isBlank(u.getChartNo())).map(u -> u.getRowNum()).collect(Collectors.toList());
|
||||
VUtils.isTure(CollUtil.isNotEmpty(noDrawingNo)).throwMessage(StrUtil.join(",", noDrawingNo) + "图号为空");
|
||||
// List<Integer> noNum = excelContext.stream().filter(u -> Objects.isNull(u.getQty())).map(u->u.getRowNum()).collect(Collectors.toList());
|
||||
// VUtils.isTure(CollUtil.isNotEmpty(noNum)).throwMessage( StrUtil.join(",",noNum )+"数量为空");
|
||||
|
||||
|
|
@ -410,7 +412,7 @@ public class BomNewOriginalParentService extends ServiceImpl<BomNewOriginalParen
|
|||
PlmBomToOriginalConvert convert = new PlmBomToOriginalConvert();
|
||||
List<BomNewOriginalExcelDTO> chileds = excelContext.stream().filter(u -> u.getParentKey().equals(data.getLevelNo() + "-" + data.getRowNum())).collect(Collectors.toList());
|
||||
if (CollUtil.isNotEmpty(chileds)) {
|
||||
int i=1;
|
||||
int i = 1;
|
||||
for (BomNewOriginalExcelDTO ch : chileds) {
|
||||
ch.setOrderNo(i);
|
||||
i++;
|
||||
|
|
@ -430,8 +432,8 @@ public class BomNewOriginalParentService extends ServiceImpl<BomNewOriginalParen
|
|||
|
||||
public static void handlerExcelRow(BomNewOriginalExcelDTO data) {
|
||||
data.setRowNum(rowNum.get());
|
||||
// data.setOrderNo(data.getLevelNo());
|
||||
data.setChartNo(StrUtil.trim(data.getChartNo()).replace("(","(").replace(")",")").replace(" ",""));
|
||||
// data.setOrderNo(data.getLevelNo());
|
||||
data.setChartNo(StrUtil.trim(data.getChartNo()).replace("(", "(").replace(")", ")").replace(" ", ""));
|
||||
rowNum.set(rowNum.get() + 1);
|
||||
|
||||
excelContextTL.get().add(data);
|
||||
|
|
@ -446,12 +448,12 @@ public class BomNewOriginalParentService extends ServiceImpl<BomNewOriginalParen
|
|||
String uuid = IdUtil.simpleUUID();
|
||||
EecExcelUtil.handlerExcel(file, BomNewOriginalExcelDTO.class, BomNewOriginalParentService::handlerExcelRow);
|
||||
List<BomNewOriginalExcelDTO> excelContext = excelContextTL.get();
|
||||
List<Integer> noLevelNo = excelContext.stream().filter(u -> Objects.isNull(u.getLevelNo())).map(u->u.getRowNum()).collect(Collectors.toList());
|
||||
VUtils.isTure(CollUtil.isNotEmpty(noLevelNo)).throwMessage(StrUtil.join(",",noLevelNo )+"层次为空");
|
||||
List<Integer> noDrawingNo = excelContext.stream().filter(u -> StrUtil.isBlank(u.getChartNo())).map(u->u.getRowNum()).collect(Collectors.toList());
|
||||
VUtils.isTure(CollUtil.isNotEmpty(noDrawingNo)).throwMessage(StrUtil.join(",",noDrawingNo )+"图号为空");
|
||||
List<Integer> noNum = excelContext.stream().filter(u -> Objects.isNull(u.getQty())).map(u->u.getRowNum()).collect(Collectors.toList());
|
||||
VUtils.isTure(CollUtil.isNotEmpty(noNum)).throwMessage( StrUtil.join(",",noNum )+"数量为空");
|
||||
List<Integer> noLevelNo = excelContext.stream().filter(u -> Objects.isNull(u.getLevelNo())).map(u -> u.getRowNum()).collect(Collectors.toList());
|
||||
VUtils.isTure(CollUtil.isNotEmpty(noLevelNo)).throwMessage(StrUtil.join(",", noLevelNo) + "层次为空");
|
||||
List<Integer> noDrawingNo = excelContext.stream().filter(u -> StrUtil.isBlank(u.getChartNo())).map(u -> u.getRowNum()).collect(Collectors.toList());
|
||||
VUtils.isTure(CollUtil.isNotEmpty(noDrawingNo)).throwMessage(StrUtil.join(",", noDrawingNo) + "图号为空");
|
||||
List<Integer> noNum = excelContext.stream().filter(u -> Objects.isNull(u.getQty())).map(u -> u.getRowNum()).collect(Collectors.toList());
|
||||
VUtils.isTure(CollUtil.isNotEmpty(noNum)).throwMessage(StrUtil.join(",", noNum) + "数量为空");
|
||||
|
||||
for (BomNewOriginalExcelDTO data : excelContext) {
|
||||
List<BomNewOriginalExcelDTO> parentData = excelContext.stream().filter(u -> u.getLevelNo().equals(data.getLevelNo() - 1) && u.getRowNum() < data.getRowNum())
|
||||
|
|
@ -464,7 +466,7 @@ public class BomNewOriginalParentService extends ServiceImpl<BomNewOriginalParen
|
|||
PlmBomToOriginalConvert convert = new PlmBomToOriginalConvert();
|
||||
List<BomNewOriginalExcelDTO> chileds = excelContext.stream().filter(u -> u.getParentKey().equals(data.getLevelNo() + "-" + data.getRowNum())).collect(Collectors.toList());
|
||||
if (CollUtil.isNotEmpty(chileds)) {
|
||||
int i=1;
|
||||
int i = 1;
|
||||
for (BomNewOriginalExcelDTO ch : chileds) {
|
||||
ch.setOrderNo(i);
|
||||
i++;
|
||||
|
|
|
|||
|
|
@ -124,23 +124,27 @@
|
|||
</foreach>;
|
||||
</update>
|
||||
|
||||
<update id="updateRootState">
|
||||
<update id="updateRootState_1">
|
||||
|
||||
update t_bom_new_original_parent set root_is=0,user_root_is=0 where last_version_is=1;
|
||||
update t_bom_new_original_parent set root_is=0,user_root_is=0 where last_version_is=1
|
||||
|
||||
</update>
|
||||
<update id="updateRootState_2">
|
||||
update t_bom_new_original_parent a join (
|
||||
select a.row_id from t_bom_new_original_parent a
|
||||
left join t_bom_new_original_child b
|
||||
on a.drawing_no=b.drawing_no
|
||||
where a.last_version_is=1 and b.row_id is null ) t on a.row_id=t.row_id set a.root_is=1;
|
||||
|
||||
where a.last_version_is=1 and b.row_id is null ) t on a.row_id=t.row_id set a.root_is=1
|
||||
</update>
|
||||
|
||||
<update id="updateRootState_3">
|
||||
update t_bom_new_original_parent a join (
|
||||
select a.row_id from t_bom_new_original_parent a
|
||||
left join t_bom_new_original_child b
|
||||
on a.drawing_no=b.drawing_no and a.created_by=b.created_by
|
||||
where a.last_version_is=1 and b.row_id is null ) t on a.row_id=t.row_id set a.user_root_is=1;
|
||||
|
||||
where a.last_version_is=1 and b.row_id is null ) t on a.row_id=t.row_id set a.user_root_is=1
|
||||
</update>
|
||||
|
||||
|
||||
|
||||
</mapper>
|
||||
|
|
|
|||
Loading…
Reference in New Issue