diff --git a/nflg_project_dev/nflg-bom-new/src/main/java/com/nflg/product/bomnew/api/user/OriginalBomApi.java b/nflg_project_dev/nflg-bom-new/src/main/java/com/nflg/product/bomnew/api/user/OriginalBomApi.java index 458a3ab2..35887dcf 100644 --- a/nflg_project_dev/nflg-bom-new/src/main/java/com/nflg/product/bomnew/api/user/OriginalBomApi.java +++ b/nflg_project_dev/nflg-bom-new/src/main/java/com/nflg/product/bomnew/api/user/OriginalBomApi.java @@ -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()); }); diff --git a/nflg_project_dev/nflg-bom-new/src/main/java/com/nflg/product/bomnew/api/user/PBomApi.java b/nflg_project_dev/nflg-bom-new/src/main/java/com/nflg/product/bomnew/api/user/PBomApi.java index 2f097f7f..d8771396 100644 --- a/nflg_project_dev/nflg-bom-new/src/main/java/com/nflg/product/bomnew/api/user/PBomApi.java +++ b/nflg_project_dev/nflg-bom-new/src/main/java/com/nflg/product/bomnew/api/user/PBomApi.java @@ -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 data = bomNewPbomParentService.workDetailsListByPage(query); + List 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 data = bomNewPbomParentService.releaseListByPage(query); + List 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 bomRowIds, HttpServletResponse response) throws IOException { -// List 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 bomRowIds, HttpServletResponse response) throws IOException { -// List 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 bomRowIds, HttpServletResponse response) throws IOException { + VUtils.isTure(CollUtil.isEmpty(bomRowIds)).throwMessage("请选择要导出的行"); + + List 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 bomRowIds, HttpServletResponse response) throws IOException { + VUtils.isTure(CollUtil.isEmpty(bomRowIds)).throwMessage("请选择要导出的行"); + + List data = bomNewPbomParentService.exportExcel(bomRowIds); + EecExcelUtil.export(response, data, BomNewPbomWorkExcelVO.class, "pbom已发布明细列表"); + } @GetMapping("getChild") @ApiOperation("获取子级") diff --git a/nflg_project_dev/nflg-bom-new/src/main/java/com/nflg/product/bomnew/config/TaskPoolConfig.java b/nflg_project_dev/nflg-bom-new/src/main/java/com/nflg/product/bomnew/config/TaskPoolConfig.java index 710bf2b7..bfb9579b 100644 --- a/nflg_project_dev/nflg-bom-new/src/main/java/com/nflg/product/bomnew/config/TaskPoolConfig.java +++ b/nflg_project_dev/nflg-bom-new/src/main/java/com/nflg/product/bomnew/config/TaskPoolConfig.java @@ -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; + } } diff --git a/nflg_project_dev/nflg-bom-new/src/main/java/com/nflg/product/bomnew/constant/EBomStatusEnum.java b/nflg_project_dev/nflg-bom-new/src/main/java/com/nflg/product/bomnew/constant/EBomStatusEnum.java index da0e0c6e..f7c8951b 100644 --- a/nflg_project_dev/nflg-bom-new/src/main/java/com/nflg/product/bomnew/constant/EBomStatusEnum.java +++ b/nflg_project_dev/nflg-bom-new/src/main/java/com/nflg/product/bomnew/constant/EBomStatusEnum.java @@ -20,4 +20,13 @@ public enum EBomStatusEnum implements ValueEnum { 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("无效的值"); + } } diff --git a/nflg_project_dev/nflg-bom-new/src/main/java/com/nflg/product/bomnew/mapper/master/BomNewOriginalParentMapper.java b/nflg_project_dev/nflg-bom-new/src/main/java/com/nflg/product/bomnew/mapper/master/BomNewOriginalParentMapper.java index 4bcdc20c..c9bd1591 100644 --- a/nflg_project_dev/nflg-bom-new/src/main/java/com/nflg/product/bomnew/mapper/master/BomNewOriginalParentMapper.java +++ b/nflg_project_dev/nflg-bom-new/src/main/java/com/nflg/product/bomnew/mapper/master/BomNewOriginalParentMapper.java @@ -38,7 +38,7 @@ public interface BomNewOriginalParentMapper extends BaseMapper result = new Page<>(); //物料编码搜索或图号搜索 if (CollUtil.isNotEmpty(query.getMaterialNos()) || CollUtil.isNotEmpty(query.getDrawingNos())) { - List queryDrawingNos = new ArrayList<>(); - queryDrawingNos.addAll(query.getDrawingNos()); - List drawingParentNos=new ArrayList<>(); + List queryDrawingNos = new ArrayList<>(query.getDrawingNos()); if (CollUtil.isNotEmpty(query.getMaterialNos())) { - drawingParentNos = this.getBaseMapper().getDrawingNoByMaterialNos(query.getMaterialNos()); + List drawingParentNos = this.getBaseMapper().getDrawingNoByMaterialNos(query.getMaterialNos()); if (CollUtil.isNotEmpty(drawingParentNos)) { queryDrawingNos.addAll(drawingParentNos); } @@ -160,7 +158,7 @@ public class BomNewOriginalParentService extends ServiceImpl parentDrawingNos = getParentDrawingNoByMaterialNo(queryDrawingNos).stream().collect(Collectors.toList()); + List parentDrawingNos = new ArrayList<>(getParentDrawingNoByMaterialNo(queryDrawingNos)); parentDrawingNos.addAll(queryDrawingNos); if (CollUtil.isNotEmpty(parentDrawingNos)) { List parents = this.getBaseMapper().getParentForDrawingNoSeach(parentDrawingNos, query.getStatus()); @@ -173,8 +171,11 @@ public class BomNewOriginalParentService extends ServiceImpl(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 delRowIds = bom.getBomList().stream().filter(u -> u.getRowId() > 0).map(u -> u.getRowId()).collect(Collectors.toList()); + List 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 parentMaterialByMaterialNo = getParentMaterialByMaterialNo(materialNo).stream().collect(Collectors.toList()); + List parentMaterialByMaterialNo = new ArrayList<>(getParentMaterialByMaterialNo(materialNo)); parentMaterialByMaterialNo.add(materialNo); if (CollUtil.isNotEmpty(parentMaterialByMaterialNo)) { List parents = this.getBaseMapper().getParentForMaterialNoSeach(StrUtil.isBlank(userRoleService.getUserFactory()) ? userRoleService.getUserFactory() : query.getFacCode(), parentMaterialByMaterialNo); @@ -131,7 +131,7 @@ public class BomNewPbomParentService extends ServiceImpl(); + return new Page<>(); } else { Page 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 handSeachToTree(List parents, List childs) { Page resutlData = new Page<>(); - Set parentSet = parents.stream().map(u -> u.getMaterialNo()).collect(Collectors.toSet()); - Set childSet = childs.stream().map(u -> u.getMaterialNo()).collect(Collectors.toSet()); + Set parentSet = parents.stream().map(BaseMaterialVO::getMaterialNo).collect(Collectors.toSet()); + Set childSet = childs.stream().map(BaseMaterialVO::getMaterialNo).collect(Collectors.toSet()); Set difference = Sets.difference(parentSet, childSet); List resultParents = parents.stream().filter(u -> difference.contains(u.getMaterialNo())).collect(Collectors.toList()); resutlData.setTotal(difference.size()); diff --git a/nflg_project_dev/nflg-bom-new/src/main/java/com/nflg/product/bomnew/service/MaterialService.java b/nflg_project_dev/nflg-bom-new/src/main/java/com/nflg/product/bomnew/service/MaterialService.java index 42726c78..79590791 100644 --- a/nflg_project_dev/nflg-bom-new/src/main/java/com/nflg/product/bomnew/service/MaterialService.java +++ b/nflg_project_dev/nflg-bom-new/src/main/java/com/nflg/product/bomnew/service/MaterialService.java @@ -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; } diff --git a/nflg_project_dev/nflg-bom-new/src/main/java/com/nflg/product/bomnew/service/domain/EBom/VirtualPackageBase.java b/nflg_project_dev/nflg-bom-new/src/main/java/com/nflg/product/bomnew/service/domain/EBom/VirtualPackageBase.java index 5b1e7c05..2e56294e 100644 --- a/nflg_project_dev/nflg-bom-new/src/main/java/com/nflg/product/bomnew/service/domain/EBom/VirtualPackageBase.java +++ b/nflg_project_dev/nflg-bom-new/src/main/java/com/nflg/product/bomnew/service/domain/EBom/VirtualPackageBase.java @@ -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); diff --git a/nflg_project_dev/nflg-bom-new/src/main/java/com/nflg/product/bomnew/util/HttpUtils.java b/nflg_project_dev/nflg-bom-new/src/main/java/com/nflg/product/bomnew/util/HttpUtils.java index 57f486fa..ab9a4bd6 100644 --- a/nflg_project_dev/nflg-bom-new/src/main/java/com/nflg/product/bomnew/util/HttpUtils.java +++ b/nflg_project_dev/nflg-bom-new/src/main/java/com/nflg/product/bomnew/util/HttpUtils.java @@ -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; } /** diff --git a/nflg_project_dev/nflg-bom-new/src/main/resources/mapper/master/BomNewEbomParentMapper.xml b/nflg_project_dev/nflg-bom-new/src/main/resources/mapper/master/BomNewEbomParentMapper.xml index b8a9480f..294ec9fe 100644 --- a/nflg_project_dev/nflg-bom-new/src/main/resources/mapper/master/BomNewEbomParentMapper.xml +++ b/nflg_project_dev/nflg-bom-new/src/main/resources/mapper/master/BomNewEbomParentMapper.xml @@ -195,7 +195,7 @@ 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` < 4; update t_bom_new_ebom_parent a left join ( diff --git a/nflg_project_dev/nflg-bom-new/src/main/resources/mapper/master/BomNewOriginalParentMapper.xml b/nflg_project_dev/nflg-bom-new/src/main/resources/mapper/master/BomNewOriginalParentMapper.xml index 66ca1288..4f560eb6 100644 --- a/nflg_project_dev/nflg-bom-new/src/main/resources/mapper/master/BomNewOriginalParentMapper.xml +++ b/nflg_project_dev/nflg-bom-new/src/main/resources/mapper/master/BomNewOriginalParentMapper.xml @@ -70,6 +70,9 @@ and created_time between #{query.startDate} and DATE_ADD(#{query.endDate}, INTERVAL 1 DAY) + + and created_by=#{userCode} + @@ -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}