Merge branch 'feature/DM/nflg-bom' of http://112.74.186.154:3000/nflj/nflg_project into feature/DM/nflg-bom

This commit is contained in:
jing's 2024-03-28 15:58:43 +08:00
commit 7c5c9abc40
14 changed files with 120 additions and 55 deletions

View File

@ -167,6 +167,7 @@ public class OriginalBomApi extends BaseApi {
//更新-原始BOM跟节点
CompletableFuture.runAsync(() -> {
originalParentService.getBaseMapper().updateRootState_1(OriginalStatusEnum.OVER_CONVERT.getValue());
originalParentService.getBaseMapper().updateRootState_2(OriginalStatusEnum.OVER_CONVERT.getValue());
originalParentService.getBaseMapper().updateRootState_3(OriginalStatusEnum.OVER_CONVERT.getValue());
});

View File

@ -1,6 +1,7 @@
package com.nflg.product.bomnew.api.user;
import cn.hutool.core.collection.CollUtil;
import cn.hutool.core.convert.Convert;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.mzt.logapi.context.LogRecordContext;
import com.mzt.logapi.starter.annotation.LogRecord;
@ -16,7 +17,9 @@ import com.nflg.product.bomnew.pojo.query.BomNewPbomParentQuery;
import com.nflg.product.bomnew.pojo.vo.BaseMaterialVO;
import com.nflg.product.bomnew.pojo.vo.BomCopyCheckResultVO;
import com.nflg.product.bomnew.pojo.vo.BomNewPbomParentVO;
import com.nflg.product.bomnew.pojo.vo.BomNewPbomWorkExcelVO;
import com.nflg.product.bomnew.service.*;
import com.nflg.product.bomnew.util.EecExcelUtil;
import com.nflg.product.bomnew.util.VUtils;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
@ -27,6 +30,7 @@ import javax.annotation.Resource;
import javax.servlet.http.HttpServletResponse;
import javax.validation.Valid;
import java.io.IOException;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import java.util.concurrent.ExecutionException;
@ -75,35 +79,51 @@ public class PBomApi extends BaseApi {
}
@PostMapping("exportWorkDetailsListByPage")
@ApiOperation("导出工作列表--导出")
@ApiOperation("导出工作列表--按查询条件")
@LogRecord(success = "PBom-导出工作列表,操作结果:{{#_ret}}", bizNo = "",type = "PBom-导出工作列表")
public void exportWorkDownLoad(@RequestBody BomNewPbomParentQuery query ,HttpServletResponse response) throws IOException {
bomNewPbomParentService.workDetailsExcel(query,response);
public void exportWorkDownLoad(@RequestBody BomNewPbomParentQuery query, HttpServletResponse response) throws IOException {
//bomNewPbomParentService.workDetailsExcel(query,response);
IPage<BomNewPbomParentVO> data = bomNewPbomParentService.workDetailsListByPage(query);
List<BomNewPbomWorkExcelVO> out = new ArrayList<>();
if (!data.getRecords().isEmpty()) {
out = Convert.toList(BomNewPbomWorkExcelVO.class, data.getRecords());
}
EecExcelUtil.export(response, out, BomNewPbomWorkExcelVO.class, "pbom明细列表");
}
@PostMapping("releaseListDownLoad")
@ApiOperation("PBom已发布工作列表--导出")
@ApiOperation("导出正式列表--按查询条件")
@LogRecord(success = "PBom-导出已发布工作列表,操作结果:{{#_ret}}", bizNo = "",type = "PBom-已发布工作列表")
public void releaseListDownLoad(@RequestBody BomNewPbomParentQuery query ,HttpServletResponse response) throws IOException {
bomNewPbomParentService.releaseListExcel(query,response);
//bomNewPbomParentService.releaseListExcel(query,response);
IPage<BomNewPbomParentVO> data = bomNewPbomParentService.releaseListByPage(query);
List<BomNewPbomWorkExcelVO> out = new ArrayList<>();
if (!data.getRecords().isEmpty()) {
out = Convert.toList(BomNewPbomWorkExcelVO.class, data.getRecords());
}
EecExcelUtil.export(response, out, BomNewPbomWorkExcelVO.class, "pbom已发布工作列表");
}
// @PostMapping("exportWorkDetailsListByPage")
// @ApiOperation("导出工作列表--导出")
// @LogRecord(success = "PBom-导出工作列表,操作结果:{{#_ret}}", bizNo = "",type = "PBom-导出工作列表")
// public void exportWorkDownLoad(@RequestBody List<Long> bomRowIds, HttpServletResponse response) throws IOException {
// List<BomNewPbomWorkExcelVO> data = bomNewPbomParentService.exportExcel(bomRowIds);
// //new Workbook().addSheet(new ListSheet<>(data)).writeTo(response.getOutputStream());
// EecExcelUtil.export(response, data, BomNewPbomWorkExcelVO.class, "pbom明细列表");
// }
//
// @PostMapping("releaseListDownLoad")
// @ApiOperation("PBom已发布工作列表--导出")
// @LogRecord(success = "PBom-导出已发布工作列表,操作结果:{{#_ret}}", bizNo = "",type = "PBom-已发布工作列表")
// public void releaseListDownLoad(@RequestBody List<Long> bomRowIds, HttpServletResponse response) throws IOException {
// List<BomNewPbomWorkExcelVO> data = bomNewPbomParentService.exportExcel(bomRowIds);
// EecExcelUtil.export(response, data, BomNewPbomWorkExcelVO.class, "pbom已发布明细列表");
// }
@PostMapping("exportWorkDetailsListByIds")
@ApiOperation("导出工作列表--按rowid")
@LogRecord(success = "PBom-导出工作列表,操作结果:{{#_ret}}", bizNo = "",type = "PBom-导出工作列表")
public void exportWorkDownLoad(@RequestBody List<Long> bomRowIds, HttpServletResponse response) throws IOException {
VUtils.isTure(CollUtil.isEmpty(bomRowIds)).throwMessage("请选择要导出的行");
List<BomNewPbomWorkExcelVO> data = bomNewPbomParentService.exportExcel(bomRowIds);
//new Workbook().addSheet(new ListSheet<>(data)).writeTo(response.getOutputStream());
EecExcelUtil.export(response, data, BomNewPbomWorkExcelVO.class, "pbom明细列表");
}
@PostMapping("releaseListDownLoadByIds")
@ApiOperation("导出正式列表--按rowid")
@LogRecord(success = "PBom-导出已发布工作列表,操作结果:{{#_ret}}", bizNo = "",type = "PBom-已发布工作列表")
public void releaseListDownLoad(@RequestBody List<Long> bomRowIds, HttpServletResponse response) throws IOException {
VUtils.isTure(CollUtil.isEmpty(bomRowIds)).throwMessage("请选择要导出的行");
List<BomNewPbomWorkExcelVO> data = bomNewPbomParentService.exportExcel(bomRowIds);
EecExcelUtil.export(response, data, BomNewPbomWorkExcelVO.class, "pbom已发布明细列表");
}
@GetMapping("getChild")
@ApiOperation("获取子级")

View File

@ -28,4 +28,17 @@ public class TaskPoolConfig {
taskExecutor.setThreadFactory(new ThreadFactoryBuilder().setNamePrefix("plm-searcher-thread-").build());
return taskExecutor;
}
@Bean("syncOAThreadPool")
public ThreadPoolTaskExecutor syncOAThreadPool() {
ThreadPoolTaskExecutor taskExecutor = new ThreadPoolTaskExecutor();
taskExecutor.setCorePoolSize(10);
taskExecutor.setMaxPoolSize(30);
taskExecutor.setQueueCapacity(2000);
taskExecutor.setKeepAliveSeconds(100);
taskExecutor.setRejectedExecutionHandler(new ThreadPoolExecutor.CallerRunsPolicy());
//设置线程池的线程名称方便日志追踪
taskExecutor.setThreadFactory(new ThreadFactoryBuilder().setNamePrefix("sync-oa-").build());
return taskExecutor;
}
}

View File

@ -20,4 +20,13 @@ public enum EBomStatusEnum implements ValueEnum<Integer> {
private final Integer value;
private final String description;
public static EBomStatusEnum findByValue(Integer value) {
for (EBomStatusEnum statusEnum : EBomStatusEnum.values()) {
if (statusEnum.getValue().equals(value)) {
return statusEnum;
}
}
throw new IllegalArgumentException("无效的值");
}
}

View File

@ -38,7 +38,7 @@ public interface BomNewOriginalParentMapper extends BaseMapper<BomNewOriginalPar
/**
* 更新是否根节点状态
*/
void updateRootState_1();
void updateRootState_1(@Param("status") Integer status);
void updateRootState_2(@Param("status") Integer status);
void updateRootState_3(@Param("status") Integer status);

View File

@ -1,6 +1,5 @@
package com.nflg.product.bomnew.pojo.query;
import cn.hutool.core.convert.Convert;
import cn.hutool.core.util.StrUtil;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
@ -8,7 +7,6 @@ import lombok.Data;
import lombok.experimental.Accessors;
import java.util.Arrays;
import java.util.Date;
import java.util.List;
/**
@ -20,8 +18,6 @@ import java.util.List;
@ApiModel(value = "com-nflg-product-bom-obom-pojo-query-BomOriginalParentEntityQuery")
public class OriginalBomQuery extends BasePageQuery {
@ApiModelProperty(value = "图号集合,英文逗号隔开")
private String drawingNoList;
@ -45,12 +41,10 @@ public class OriginalBomQuery extends BasePageQuery {
@ApiModelProperty(value = "状态1=待转换、2=已转换")
private Integer status;
private String startDate;
private String endDate;
@ApiModelProperty(value = "是否仅显示自己的数据0=所有人的数据1=仅自己的数据默认为0")
private Integer showMySelfOnly = 0;
}

View File

@ -6,7 +6,6 @@ import cn.hutool.core.collection.CollectionUtil;
import cn.hutool.core.convert.Convert;
import cn.hutool.core.lang.TypeReference;
import cn.hutool.core.thread.ThreadUtil;
import cn.hutool.core.util.EnumUtil;
import cn.hutool.core.util.IdUtil;
import cn.hutool.core.util.NumberUtil;
import cn.hutool.core.util.ObjectUtil;
@ -1489,7 +1488,7 @@ public class BomNewEbomParentService extends ServiceImpl<BomNewEbomParentMapper,
//待复核和已退回才能删除
VUtils.isTure(parentEntity.getStatus().equals(EBomStatusEnum.WAIT_CHECK.getValue())
|| parentEntity.getStatus().equals(EBomStatusEnum.RETURNED.getValue()))
.throwMessage(EnumUtil.fromString(EBomStatusEnum.class, parentEntity.getStatus().toString()).getDescription() + "状态不能删除");
.throwMessage(EBomStatusEnum.findByValue(parentEntity.getStatus()).getDescription() + "状态不能删除");
EBomDel eBomDel = new EBomDel(bomRowId);
eBomDel.classifyBom();

View File

@ -145,11 +145,9 @@ public class BomNewOriginalParentService extends ServiceImpl<BomNewOriginalParen
Page<BomOriginalListVO> result = new Page<>();
//物料编码搜索或图号搜索
if (CollUtil.isNotEmpty(query.getMaterialNos()) || CollUtil.isNotEmpty(query.getDrawingNos())) {
List<String> queryDrawingNos = new ArrayList<>();
queryDrawingNos.addAll(query.getDrawingNos());
List<String> drawingParentNos=new ArrayList<>();
List<String> queryDrawingNos = new ArrayList<>(query.getDrawingNos());
if (CollUtil.isNotEmpty(query.getMaterialNos())) {
drawingParentNos = this.getBaseMapper().getDrawingNoByMaterialNos(query.getMaterialNos());
List<String> drawingParentNos = this.getBaseMapper().getDrawingNoByMaterialNos(query.getMaterialNos());
if (CollUtil.isNotEmpty(drawingParentNos)) {
queryDrawingNos.addAll(drawingParentNos);
}
@ -160,7 +158,7 @@ public class BomNewOriginalParentService extends ServiceImpl<BomNewOriginalParen
if(query.getStatus().equals(1) && CollUtil.isEmpty(materialBoms)){
return result;
}
List<String> parentDrawingNos = getParentDrawingNoByMaterialNo(queryDrawingNos).stream().collect(Collectors.toList());
List<String> parentDrawingNos = new ArrayList<>(getParentDrawingNoByMaterialNo(queryDrawingNos));
parentDrawingNos.addAll(queryDrawingNos);
if (CollUtil.isNotEmpty(parentDrawingNos)) {
List<BomOriginalListVO> parents = this.getBaseMapper().getParentForDrawingNoSeach(parentDrawingNos, query.getStatus());
@ -173,8 +171,11 @@ public class BomNewOriginalParentService extends ServiceImpl<BomNewOriginalParen
}
}
} else {
result = this.getBaseMapper().getOriginalBomListPage(new Page<>(query.getPage(), query.getPageSize()), query, SessionUtil.getUserCode());
String userCode = null;
if (query.getShowMySelfOnly() == 1) {
userCode = SessionUtil.getUserCode();
}
result = this.getBaseMapper().getOriginalBomListPage(new Page<>(query.getPage(), query.getPageSize()), query, userCode);
materialMainService.intiMaterialInfo(result.getRecords());
}
return result;
@ -201,7 +202,7 @@ public class BomNewOriginalParentService extends ServiceImpl<BomNewOriginalParen
if (CollUtil.isNotEmpty(childEntities)) {
//删除行
List<Long> delRowIds = bom.getBomList().stream().filter(u -> u.getRowId() > 0).map(u -> u.getRowId()).collect(Collectors.toList());
List<Long> delRowIds = bom.getBomList().stream().map(BomOriginalListVO::getRowId).filter(rowId -> rowId > 0).collect(Collectors.toList());
originalChildService.getBaseMapper().delOriginalChildNotInRowIds(delRowIds, bom.getParentRowId());
originalChildService.saveOrUpdateBatch(childEntities);
}
@ -427,7 +428,7 @@ public class BomNewOriginalParentService extends ServiceImpl<BomNewOriginalParen
public void computeLevelNumAndRootState() {
try {
this.getBaseMapper().updateRootState_1();
this.getBaseMapper().updateRootState_1(OriginalStatusEnum.UN_CONVERT.getValue());
this.getBaseMapper().updateRootState_2(OriginalStatusEnum.UN_CONVERT.getValue());
this.getBaseMapper().updateRootState_3(OriginalStatusEnum.UN_CONVERT.getValue());
// this.compucteLevelNum();

View File

@ -112,7 +112,7 @@ public class BomNewPbomParentService extends ServiceImpl<BomNewPbomParentMapper,
}
}
if (StrUtil.isNotBlank(materialNo)) {
List<String> parentMaterialByMaterialNo = getParentMaterialByMaterialNo(materialNo).stream().collect(Collectors.toList());
List<String> parentMaterialByMaterialNo = new ArrayList<>(getParentMaterialByMaterialNo(materialNo));
parentMaterialByMaterialNo.add(materialNo);
if (CollUtil.isNotEmpty(parentMaterialByMaterialNo)) {
List<BomNewPbomParentVO> parents = this.getBaseMapper().getParentForMaterialNoSeach(StrUtil.isBlank(userRoleService.getUserFactory()) ? userRoleService.getUserFactory() : query.getFacCode(), parentMaterialByMaterialNo);
@ -131,7 +131,7 @@ public class BomNewPbomParentService extends ServiceImpl<BomNewPbomParentMapper,
return handSeachToTree(parents, childs);
}
}
return new Page<BomNewPbomParentVO>();
return new Page<>();
} else {
Page<BomNewPbomParentVO> result = this.getBaseMapper().workDetailsListByPage(new Page<>(query.getPage(), query.getPageSize()), query, userRoleService.getUserFactory());
materialMainService.intiMaterialInfo(result.getRecords(), EBomConstant.EBOM_IGNORED_FIELDS_INIT_MATERIAL_DEFAULT);
@ -141,8 +141,8 @@ public class BomNewPbomParentService extends ServiceImpl<BomNewPbomParentMapper,
private Page<BomNewPbomParentVO> handSeachToTree(List<BomNewPbomParentVO> parents, List<BomNewPbomParentVO> childs) {
Page<BomNewPbomParentVO> resutlData = new Page<>();
Set<String> parentSet = parents.stream().map(u -> u.getMaterialNo()).collect(Collectors.toSet());
Set<String> childSet = childs.stream().map(u -> u.getMaterialNo()).collect(Collectors.toSet());
Set<String> parentSet = parents.stream().map(BaseMaterialVO::getMaterialNo).collect(Collectors.toSet());
Set<String> childSet = childs.stream().map(BaseMaterialVO::getMaterialNo).collect(Collectors.toSet());
Set<String> difference = Sets.difference(parentSet, childSet);
List<BomNewPbomParentVO> resultParents = parents.stream().filter(u -> difference.contains(u.getMaterialNo())).collect(Collectors.toList());
resutlData.setTotal(difference.size());

View File

@ -25,6 +25,8 @@ import lombok.extern.slf4j.Slf4j;
import nflg.product.common.constant.STATE;
import nflg.product.common.vo.ResultVO;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
@ -32,6 +34,7 @@ import javax.annotation.Resource;
import java.io.IOException;
import java.time.LocalDateTime;
import java.util.*;
import java.util.concurrent.CompletableFuture;
import java.util.stream.Collectors;
@Service
@ -44,6 +47,10 @@ public class MaterialService {
@Resource
MaterialMainService materialMainService;
@Resource
@Qualifier("syncOAThreadPool")
ThreadPoolTaskExecutor syncOAThreadPool;
/**
* 申请物料
*
@ -202,7 +209,7 @@ public class MaterialService {
materialMainService.saveOrUpdateBatch(resultList);
initCategoryInfo(syncOaEnts);
//同步OA
sysnToOa(syncOaEnts);
CompletableFuture.runAsync(() -> sysnToOa(syncOaEnts),syncOAThreadPool);
return result;
}

View File

@ -126,7 +126,11 @@ public abstract class VirtualPackageBase {
protected BomNewEbomParentEntity buildParentVirtualPackage(Long rowId,VirtualPackageTypeEnum virtualPackageTypeEnum) throws IOException {
AddVirtrualMaterialDTO addM = vMNos.get(StrUtil.join("",rowId,virtualPackageTypeEnum.getConMaterialName()));
BomNewEbomParentEntity oldParent= SpringUtil.getBean(BomNewEbomParentService.class).lambdaQuery().eq(BomNewEbomParentEntity::getMaterialNo, addM.getMaterialNo()).eq(BomNewEbomParentEntity::getLastVersionIs,1).one();
BomNewEbomParentEntity oldParent= SpringUtil.getBean(BomNewEbomParentService.class).lambdaQuery()
.eq(BomNewEbomParentEntity::getMaterialNo, addM.getMaterialNo())
.eq(BomNewEbomParentEntity::getLastVersionIs,1)
.ne(BomNewEbomParentEntity::getStatus,4)
.one();
if(Objects.nonNull(oldParent)){
oldParent.setLastVersionIs(0);

View File

@ -1,10 +1,13 @@
package com.nflg.product.bomnew.util;
import com.baomidou.mybatisplus.core.toolkit.IdWorker;
import com.nflg.product.base.core.exception.NflgBusinessException;
import lombok.extern.slf4j.Slf4j;
import nflg.product.common.constant.STATE;
import okhttp3.*;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.http.HttpStatus;
import java.io.File;
@ -23,6 +26,8 @@ public class HttpUtils {
//请求类
private OkHttpClient okHttpClient;
private static final Logger LOGGER = LoggerFactory.getLogger(HttpUtils.class);
//请求头类型
private final MediaType jsonMediaType = MediaType.parse("application/json;charset=utf-8");
@ -210,13 +215,22 @@ public class HttpUtils {
* @throws IOException e
*/
public String doPost(String url, String json) throws IOException {
System.out.println(url);
System.out.println(json);
Response response = doPostRtnRsp(url, json);
if (response == null || response.body() == null) {
return null;
String ret = null;
String traceId = IdWorker.getIdStr();
LOGGER.info(traceId + "http请求地址" + url + ",参数:" + json);
long start = System.currentTimeMillis();
try (Response response = doPostRtnRsp(url, json)) {
if (response == null || response.body() == null) {
return null;
}
ret = response.body().string();
} catch (Exception ex) {
LOGGER.error(traceId + "http请求出错", ex);
} finally {
long end = System.currentTimeMillis();
LOGGER.info(traceId + "http请求耗时" + (end - start) + "毫秒,返回:" + ret);
}
return response.body().string();
return ret;
}
/**

View File

@ -195,7 +195,7 @@
<update id="updateRootState">
update t_bom_new_ebom_parent
set root_is=0, user_root_is=0
where last_version_is = 1;
where last_version_is = 1 AND `status` &lt; 4;
update t_bom_new_ebom_parent a left join (

View File

@ -70,6 +70,9 @@
<if test="query.startDate!=null and query.startDate!=''">
and created_time between #{query.startDate} and DATE_ADD(#{query.endDate}, INTERVAL 1 DAY)
</if>
<if test="userCode!=null">
and created_by=#{userCode}
</if>
</sql>
<!--获取原始bom列表-->
@ -143,7 +146,7 @@
update t_bom_new_original_parent
set root_is=0,
user_root_is=0
where last_version_is = 1
where last_version_is = 1 and `status`= #{status}
</update>
<!--处理根节点-->
<update id="updateRootState_2">