From e756af0f5bfd1addbd5d5c145441fb34aad91a28 Mon Sep 17 00:00:00 2001 From: lyh <925863403@qq.com> Date: 星期三, 25 六月 2025 13:55:58 +0800 Subject: [PATCH] 同步工控网 --- lxzn-module-mdc/src/main/java/org/jeecg/modules/mdc/job/ExportToXmlJob.java | 63 + lxzn-module-system/lxzn-system-start/src/main/resources/application-dev.yml | 15 lxzn-module-dnc/src/main/java/org/jeecg/modules/dncFlow/mapper/AssignEquipmentFileStreamMapper.java | 17 lxzn-module-dnc/src/main/java/org/jeecg/modules/dnc/service/impl/DataImportService.java | 204 +++ lxzn-module-dnc/src/main/java/org/jeecg/modules/dnc/entity/ProductMix.java | 11 lxzn-module-dnc/src/main/java/org/jeecg/modules/dncFlow/adapter/AssignEquipmentFileStreamAdapter.java | 53 + lxzn-module-system/lxzn-system-biz/src/main/java/org/jeecg/modules/system/util/FileUtils.java | 194 ++++ lxzn-module-mdc/src/main/java/org/jeecg/modules/mdc/service/IMdcPassLogService.java | 19 lxzn-module-system/lxzn-system-biz/src/main/java/org/jeecg/modules/system/mapper/xml/MdcPassLogMapper.xml | 8 lxzn-module-mdc/src/main/java/org/jeecg/modules/mdc/service/ILogTableService.java | 4 lxzn-module-dnc/src/main/java/org/jeecg/modules/dnc/service/IProductMixService.java | 9 lxzn-module-dnc/src/main/java/org/jeecg/modules/dncFlow/service/impl/AssignEquipmentFileStreamServiceImpl.java | 316 +++++++ lxzn-module-system/lxzn-system-biz/src/main/java/org/jeecg/modules/system/mapper/MdcPassLogMapper.java | 20 lxzn-module-dnc/src/main/java/org/jeecg/modules/dnc/controller/GuideCardBatchController.java | 23 lxzn-module-dnc/src/main/java/org/jeecg/modules/dnc/service/impl/GuideCardBatchServiceImpl.java | 224 ++++ lxzn-module-dnc/src/main/java/org/jeecg/modules/dncFlow/constant/DispatchFileEnum.java | 36 lxzn-module-dnc/src/main/java/org/jeecg/modules/dncFlow/constant/GuideCardBatchEnum.java | 41 lxzn-module-dnc/src/main/java/org/jeecg/modules/dnc/service/impl/FullHierarchyTraceService.java | 27 lxzn-module-dnc/src/main/java/org/jeecg/modules/dncFlow/controller/DispatchFileController.java | 22 lxzn-module-dnc/src/main/java/org/jeecg/modules/dncFlow/service/IAssignEquipmentFileStreamService.java | 30 lxzn-module-dnc/src/main/java/org/jeecg/modules/dnc/dto/TransferPackage.java | 3 lxzn-module-system/lxzn-system-biz/src/main/java/org/jeecg/modules/system/service/IMdcPassLogService.java | 19 lxzn-module-dnc/src/main/java/org/jeecg/modules/dncFlow/service/impl/PermissionService.java | 6 lxzn-module-mdc/src/main/java/org/jeecg/modules/mdc/service/impl/LogTableServiceImpl.java | 96 + lxzn-module-dnc/src/main/java/org/jeecg/modules/dncFlow/vo/AssignEquipmentFileStreamVo.java | 28 lxzn-module-dnc/src/main/java/org/jeecg/modules/dnc/service/impl/ProductMixServiceImpl.java | 91 ++ lxzn-module-dnc/src/main/java/org/jeecg/modules/dncFlow/mapper/xml/AssignEquipmentFileStreamMapper.xml | 5 lxzn-boot-base-core/src/main/java/org/jeecg/common/constant/CommonConstant.java | 2 lxzn-module-dnc/src/main/java/org/jeecg/modules/dnc/service/IGuideCardBatchService.java | 16 lxzn-module-dnc/src/main/java/org/jeecg/modules/dnc/mapper/xml/PermissionStreamNewMapper.xml | 6 lxzn-module-dnc/src/main/java/org/jeecg/modules/dnc/mapper/ProductMixMapper.java | 17 lxzn-module-system/lxzn-system-start/src/main/java/org/jeecg/codegenerate/CreateTrigger.java | 199 ++++ lxzn-module-dnc/src/main/java/org/jeecg/modules/dncFlow/service/IDispatchFileService.java | 6 lxzn-module-dnc/src/main/java/org/jeecg/modules/dncFlow/vo/GuideCardBatchFlowTaskVo.java | 38 lxzn-module-dnc/src/main/java/org/jeecg/modules/dnc/entity/GuideCardBatch.java | 6 lxzn-module-dnc/src/main/java/org/jeecg/modules/dncFlow/service/impl/DispatchFileServiceImpl.java | 153 +++ lxzn-module-dnc/src/main/java/org/jeecg/modules/dncFlow/controller/AssignEquipmentFileStreamController.java | 252 +++++ lxzn-module-dnc/src/main/java/org/jeecg/modules/dncFlow/entity/AssignEquipmentFileStream.java | 133 +++ lxzn-module-system/lxzn-system-biz/src/main/java/org/jeecg/modules/system/entity/MdcPassLog.java | 58 + lxzn-module-dnc/src/main/java/org/jeecg/modules/dnc/controller/ProductMixController.java | 12 lxzn-module-dnc/src/main/java/org/jeecg/modules/dnc/listener/FileListener.java | 16 lxzn-module-dnc/src/main/java/org/jeecg/modules/dnc/service/impl/FileFerryService.java | 68 + lxzn-module-system/lxzn-system-biz/src/main/java/org/jeecg/modules/system/service/impl/MdcPassLogServiceImpl.java | 26 43 files changed, 2,438 insertions(+), 154 deletions(-) diff --git a/lxzn-boot-base-core/src/main/java/org/jeecg/common/constant/CommonConstant.java b/lxzn-boot-base-core/src/main/java/org/jeecg/common/constant/CommonConstant.java index a258837..ef6acb1 100644 --- a/lxzn-boot-base-core/src/main/java/org/jeecg/common/constant/CommonConstant.java +++ b/lxzn-boot-base-core/src/main/java/org/jeecg/common/constant/CommonConstant.java @@ -171,7 +171,7 @@ */ String SUPPLIERTYPE_1 = "1"; String SUPPLIERTYPE_2 = "2"; - /** + /** * 鍚屾宸ヤ綔娴佸紩鎿�1鍚屾0涓嶅悓姝� */ Integer ACT_SYNC_1 = 1; diff --git a/lxzn-module-dnc/src/main/java/org/jeecg/modules/dnc/controller/GuideCardBatchController.java b/lxzn-module-dnc/src/main/java/org/jeecg/modules/dnc/controller/GuideCardBatchController.java index 8f1b9c3..f17ae05 100644 --- a/lxzn-module-dnc/src/main/java/org/jeecg/modules/dnc/controller/GuideCardBatchController.java +++ b/lxzn-module-dnc/src/main/java/org/jeecg/modules/dnc/controller/GuideCardBatchController.java @@ -12,6 +12,7 @@ import org.jeecg.common.system.base.controller.JeecgController; import org.jeecg.modules.dnc.entity.GuideCardBatch; import org.jeecg.modules.dnc.service.IGuideCardBatchService; +import org.jeecg.modules.dncFlow.vo.GuideCardBatchFlowTaskVo; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.web.bind.annotation.*; import org.springframework.web.servlet.ModelAndView; @@ -138,6 +139,28 @@ return Result.OK(guideCardBatch); } + /** + * 鍙戣捣纭娴佺▼ + * @param id + * @return + */ + @ApiOperation(value="nc鏂囦欢瀵瑰簲鏁版帶绋嬪簭鍔犲伐纭琛�-鍙戣捣纭娴佺▼", notes="nc鏂囦欢瀵瑰簲鏁版帶绋嬪簭鍔犲伐纭琛�-鍙戣捣纭娴佺▼") + @GetMapping(value = "/startGuideCardBatch") + public Result<?> startGuideCardBatch(String id){ + return guideCardBatchService.startGuideCardBatch(id); + } + + /** + * 娴佺▼鑺傜偣瀹℃牳 + * @param guideCardBatchFlowTaskVo + * @return + */ + @ApiOperation(value="nc鏂囦欢瀵瑰簲鏁版帶绋嬪簭鍔犲伐纭琛�-娴佺▼鑺傜偣瀹℃牳", notes="nc鏂囦欢瀵瑰簲鏁版帶绋嬪簭鍔犲伐纭琛�-娴佺▼鑺傜偣瀹℃牳") + @PostMapping(value = "/auditGuideCardBatch") + public Result<?> auditGuideCardBatch(@RequestBody GuideCardBatchFlowTaskVo guideCardBatchFlowTaskVo){ + return guideCardBatchService.auditGuideCardBatch(guideCardBatchFlowTaskVo); + } + /** * 瀵煎嚭excel * diff --git a/lxzn-module-dnc/src/main/java/org/jeecg/modules/dnc/controller/ProductMixController.java b/lxzn-module-dnc/src/main/java/org/jeecg/modules/dnc/controller/ProductMixController.java index c91e823..8c424bd 100644 --- a/lxzn-module-dnc/src/main/java/org/jeecg/modules/dnc/controller/ProductMixController.java +++ b/lxzn-module-dnc/src/main/java/org/jeecg/modules/dnc/controller/ProductMixController.java @@ -38,6 +38,18 @@ } /** + * 鑾峰彇鍏ㄩ儴浜у搧鏍戯紙鍖呮嫭璁惧绫讳笌nc鏂囦欢锛� + * @return + */ + @AutoLog(value = "鑾峰彇鍏ㄩ儴浜у搧鏍�") + @ApiOperation(value = "鑾峰彇鍏ㄩ儴浜у搧鏍�", notes = "鑾峰彇鍏ㄩ儴浜у搧鏍�") + @GetMapping(value = "/getAllTree") + public Result<?> getAllTree() { + List<ProductMix> productMixList = iProductMixService.getProductMixTree(); + return Result.OK(productMixList); + } + + /** * 鑾峰彇鍏蜂綋灞傜骇瀹炰綋 * @param id,type * @return diff --git a/lxzn-module-dnc/src/main/java/org/jeecg/modules/dnc/dto/TransferPackage.java b/lxzn-module-dnc/src/main/java/org/jeecg/modules/dnc/dto/TransferPackage.java index 15bd6b1..9b28811 100644 --- a/lxzn-module-dnc/src/main/java/org/jeecg/modules/dnc/dto/TransferPackage.java +++ b/lxzn-module-dnc/src/main/java/org/jeecg/modules/dnc/dto/TransferPackage.java @@ -1,12 +1,11 @@ package org.jeecg.modules.dnc.dto; - import com.fasterxml.jackson.annotation.JsonCreator; import com.fasterxml.jackson.annotation.JsonIgnoreProperties; import com.fasterxml.jackson.annotation.JsonInclude; import com.fasterxml.jackson.annotation.JsonProperty; import lombok.Builder; import lombok.Data; -import org.jeecg.modules.dnc.entity.DocRelative; +import org.jeecg.modules.dnc.entity.*; @Data @Builder diff --git a/lxzn-module-dnc/src/main/java/org/jeecg/modules/dnc/entity/GuideCardBatch.java b/lxzn-module-dnc/src/main/java/org/jeecg/modules/dnc/entity/GuideCardBatch.java index 3af6f98..0018d05 100644 --- a/lxzn-module-dnc/src/main/java/org/jeecg/modules/dnc/entity/GuideCardBatch.java +++ b/lxzn-module-dnc/src/main/java/org/jeecg/modules/dnc/entity/GuideCardBatch.java @@ -9,6 +9,7 @@ import lombok.Data; import lombok.EqualsAndHashCode; import lombok.experimental.Accessors; +import org.jeecg.common.aspect.annotation.Dict; import org.jeecgframework.poi.excel.annotation.Excel; import org.springframework.format.annotation.DateTimeFormat; @@ -104,6 +105,7 @@ /**缂栧啓浜�*/ @Excel(name = "缂栧啓浜�", width = 15) @ApiModelProperty(value = "缂栧啓浜�") + @Dict(dictTable = "sys_user", dicCode = "username", dicText = "realname") private String compiler; /**缂栧啓鏃ユ湡*/ @Excel(name = "缂栧啓鏃ユ湡", width = 15, format = "yyyy-MM-dd") @@ -114,6 +116,7 @@ /**鏍″浜�*/ @Excel(name = "鏍″浜�", width = 15) @ApiModelProperty(value = "鏍″浜�") + @Dict(dictTable = "sys_user", dicCode = "username", dicText = "realname") private String proofreader; /**鏍″鏃ユ湡*/ @Excel(name = "鏍″鏃ユ湡", width = 15, format = "yyyy-MM-dd") @@ -124,6 +127,7 @@ /**鎿嶄綔鑰�*/ @Excel(name = "鎿嶄綔鑰�", width = 15) @ApiModelProperty(value = "鎿嶄綔鑰�") + @Dict(dictTable = "sys_user", dicCode = "username", dicText = "realname") private String operator; /**棣栨鏃ユ湡*/ @Excel(name = "棣栨鏃ユ湡", width = 15, format = "yyyy-MM-dd") @@ -138,6 +142,7 @@ /**瀹℃壒浜�*/ @Excel(name = "瀹℃壒浜�", width = 15) @ApiModelProperty(value = "瀹℃壒浜�") + @Dict(dictTable = "sys_user", dicCode = "username", dicText = "realname") private String approver; /**瀹℃壒鏃ユ湡*/ @Excel(name = "瀹℃壒鏃ユ湡", width = 15, format = "yyyy-MM-dd") @@ -147,6 +152,7 @@ private Date approverTime; /**鍒涘缓浜�*/ @ApiModelProperty(value = "鍒涘缓浜�") + @Dict(dictTable = "sys_user", dicCode = "username", dicText = "realname") private String createBy; /**鍒涘缓鏃ユ湡*/ @JsonFormat(timezone = "GMT+8",pattern = "yyyy-MM-dd HH:mm:ss") diff --git a/lxzn-module-dnc/src/main/java/org/jeecg/modules/dnc/entity/ProductMix.java b/lxzn-module-dnc/src/main/java/org/jeecg/modules/dnc/entity/ProductMix.java index 879114e..f390a20 100644 --- a/lxzn-module-dnc/src/main/java/org/jeecg/modules/dnc/entity/ProductMix.java +++ b/lxzn-module-dnc/src/main/java/org/jeecg/modules/dnc/entity/ProductMix.java @@ -6,6 +6,7 @@ import com.fasterxml.jackson.databind.annotation.JsonSerialize; import com.fasterxml.jackson.databind.ser.std.ToStringSerializer; import lombok.Data; +import lombok.Getter; import lombok.NoArgsConstructor; import java.io.Serializable; @@ -13,6 +14,7 @@ import java.util.Date; import java.util.List; +@Getter @Data @NoArgsConstructor @TableName(value = "nc_product_mix") @@ -41,20 +43,19 @@ //灞曠ず鍚嶇О private transient String label; - //绫诲瀷鏂逛究鍓嶇灞曠ず + //绫诲瀷 鏂逛究鍓嶇灞曠ず private transient Integer type; - private transient List<ProductMix> children = new ArrayList<>(); - public ProductMix(Long id, Long parentId, String treeName, String treeCode, Integer type, Date createTime) { + public ProductMix(Long id, Long parentId, String treeName, String trrCode, Integer type, Date createTime) { this.id = id; this.parentId = parentId; this.treeName = treeName; - this.treeCode = treeCode; + this.treeCode = trrCode; this.type = type; this.children = new ArrayList<>(); - this.label="["+treeCode+"]"+treeName; + this.label="["+ trrCode +"]"+ treeName; this.createTime = createTime; } diff --git a/lxzn-module-dnc/src/main/java/org/jeecg/modules/dnc/listener/FileListener.java b/lxzn-module-dnc/src/main/java/org/jeecg/modules/dnc/listener/FileListener.java index bfd8427..5b8b097 100644 --- a/lxzn-module-dnc/src/main/java/org/jeecg/modules/dnc/listener/FileListener.java +++ b/lxzn-module-dnc/src/main/java/org/jeecg/modules/dnc/listener/FileListener.java @@ -1,5 +1,4 @@ package org.jeecg.modules.dnc.listener; - import org.apache.commons.io.monitor.FileAlterationListener; import org.apache.commons.io.monitor.FileAlterationObserver; import org.jeecg.modules.dnc.dto.TransferPackage; @@ -8,9 +7,11 @@ import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.beans.factory.annotation.Value; import org.springframework.stereotype.Component; import java.io.File; +import java.util.Objects; @Component public class FileListener implements FileAlterationListener { @@ -21,6 +22,7 @@ @Autowired private DataImportService dataImportService; + @Override public void onStart(FileAlterationObserver observer) { @@ -46,11 +48,13 @@ public void onFileCreate(File file) { String filePath = file.getAbsolutePath(); log.info("[鏂板缓]: {}", filePath); - if (filePath.endsWith(".ferry")){ - TransferPackage data = fileFerryService.importData(filePath); - dataImportService.importTransferPackage(data); - log.info("鏂囦欢瀵煎叆瀹屾垚"); - } +// if (filePath.startsWith(fileMonitorConfig.getPaths().get(0))){ + if (filePath.endsWith(".ferry")){ + TransferPackage data = fileFerryService.importData(filePath); + dataImportService.importTransferPackage(data); + log.info("鏂囦欢瀵煎叆瀹屾垚"); + } +// } } @Override public void onFileChange(File file) { diff --git a/lxzn-module-dnc/src/main/java/org/jeecg/modules/dnc/mapper/ProductMixMapper.java b/lxzn-module-dnc/src/main/java/org/jeecg/modules/dnc/mapper/ProductMixMapper.java index aaa74b5..4d861f3 100644 --- a/lxzn-module-dnc/src/main/java/org/jeecg/modules/dnc/mapper/ProductMixMapper.java +++ b/lxzn-module-dnc/src/main/java/org/jeecg/modules/dnc/mapper/ProductMixMapper.java @@ -6,6 +6,23 @@ import org.jeecg.modules.dnc.entity.ProductMix; public interface ProductMixMapper extends BaseMapper<ProductMix> { + @Select("SELECT * FROM nc_product_mix WHERE id = #{productId} AND tree_type = 1") + ProductMix findByProductId(@Param("productId") String productId); + + @Select("SELECT * FROM nc_product_mix WHERE id = #{componentId} AND tree_type = 2") + ProductMix findByComponentId(@Param("componentId") String componentId); + + @Select("SELECT * FROM nc_product_mix WHERE id = #{partsId} AND tree_type = 3") + ProductMix findByPartsId(@Param("partsId") String partsId); + + @Select("SELECT * FROM nc_product_mix WHERE id = #{operationId} AND tree_type = 4") + ProductMix findByOperationId(@Param("operationId") String operationId); + + @Select("SELECT * FROM nc_product_mix WHERE id = #{processId} AND tree_type = 5") + ProductMix findByProcessId(@Param("operationId") String processId); + + @Select("SELECT * FROM nc_product_mix WHERE id = #{worksiteId} AND tree_type = 6") + ProductMix findByWorksiteId(@Param("operationId") String worksiteId); @Select("SELECT * FROM nc_product_mix WHERE id = #{productId} AND tree_type = 1") ProductMix findByProductId(@Param("productId") String productId); diff --git a/lxzn-module-dnc/src/main/java/org/jeecg/modules/dnc/mapper/xml/PermissionStreamNewMapper.xml b/lxzn-module-dnc/src/main/java/org/jeecg/modules/dnc/mapper/xml/PermissionStreamNewMapper.xml index 6ebebfa..a0ccbec 100644 --- a/lxzn-module-dnc/src/main/java/org/jeecg/modules/dnc/mapper/xml/PermissionStreamNewMapper.xml +++ b/lxzn-module-dnc/src/main/java/org/jeecg/modules/dnc/mapper/xml/PermissionStreamNewMapper.xml @@ -5,7 +5,7 @@ SELECT DISTINCT mix.id, mix.tree_code, - mix.tree_name, + mix.tree_name, mix.parent_id, mix.tree_type AS 'type', mix.extend, @@ -31,8 +31,8 @@ </select> <select id="loadProductMixAll" resultType="org.jeecg.modules.dnc.entity.ProductMix"> SELECT DISTINCT mix.id, - mix.tree_code, - mix.tree_name , + mix.tree_code , + mix.tree_name , mix.parent_id, mix.tree_type AS 'type', mix.extend, diff --git a/lxzn-module-dnc/src/main/java/org/jeecg/modules/dnc/service/IGuideCardBatchService.java b/lxzn-module-dnc/src/main/java/org/jeecg/modules/dnc/service/IGuideCardBatchService.java index 7666932..dde62b2 100644 --- a/lxzn-module-dnc/src/main/java/org/jeecg/modules/dnc/service/IGuideCardBatchService.java +++ b/lxzn-module-dnc/src/main/java/org/jeecg/modules/dnc/service/IGuideCardBatchService.java @@ -1,7 +1,9 @@ package org.jeecg.modules.dnc.service; import com.baomidou.mybatisplus.extension.service.IService; +import org.jeecg.common.api.vo.Result; import org.jeecg.modules.dnc.entity.GuideCardBatch; +import org.jeecg.modules.dncFlow.vo.GuideCardBatchFlowTaskVo; /** * @Description: nc鏂囦欢瀵瑰簲鏁版帶绋嬪簭鍔犲伐纭琛� @@ -24,4 +26,18 @@ * @return */ boolean importGuideCardBatch(String docId,String attributionId,Integer attributionType); + + /** + * 鍙戣捣纭娴佺▼ + * @param id + * @return + */ + Result<?> startGuideCardBatch(String id); + + /** + * 娴佺▼鑺傜偣瀹℃牳 + * @param guideCardBatchFlowTaskVo + * @return + */ + Result<?> auditGuideCardBatch(GuideCardBatchFlowTaskVo guideCardBatchFlowTaskVo); } diff --git a/lxzn-module-dnc/src/main/java/org/jeecg/modules/dnc/service/IProductMixService.java b/lxzn-module-dnc/src/main/java/org/jeecg/modules/dnc/service/IProductMixService.java index dafd539..e78a076 100644 --- a/lxzn-module-dnc/src/main/java/org/jeecg/modules/dnc/service/IProductMixService.java +++ b/lxzn-module-dnc/src/main/java/org/jeecg/modules/dnc/service/IProductMixService.java @@ -1,6 +1,8 @@ package org.jeecg.modules.dnc.service; +import cn.hutool.core.lang.tree.Tree; import com.baomidou.mybatisplus.extension.service.IService; +import org.jeecg.common.api.vo.Result; import org.jeecg.modules.dnc.entity.ProductMix; import java.util.List; @@ -8,7 +10,7 @@ public interface IProductMixService extends IService<ProductMix> { //鑾峰彇灏佽浜у搧缁撴瀯鏍� - List<ProductMix> getTree(); + public List<ProductMix> getTree(); /** * 鏌ヨ瀵瑰簲id鐨勬墍鏈夌埗绾�(鏉冮檺鍒嗛厤浣跨敤) @@ -24,4 +26,9 @@ */ List<ProductMix> getChildrenList(String id); + /** + * 鏌ヨ浜у搧缁撴瀯鏍戯紙鍖呮嫭璁惧绫讳笌nc鏂囦欢锛� + * @return + */ + List<ProductMix> getProductMixTree(); } diff --git a/lxzn-module-dnc/src/main/java/org/jeecg/modules/dnc/service/impl/DataImportService.java b/lxzn-module-dnc/src/main/java/org/jeecg/modules/dnc/service/impl/DataImportService.java index c91c587..3ddf601 100644 --- a/lxzn-module-dnc/src/main/java/org/jeecg/modules/dnc/service/impl/DataImportService.java +++ b/lxzn-module-dnc/src/main/java/org/jeecg/modules/dnc/service/impl/DataImportService.java @@ -1,10 +1,16 @@ package org.jeecg.modules.dnc.service.impl; +import cn.hutool.core.util.StrUtil; import com.jeecg.weibo.exception.BusinessException; +import liquibase.pro.packaged.S; import org.jeecg.modules.dnc.dto.ComponentHierarchy; import org.jeecg.modules.dnc.dto.TransferPackage; import org.jeecg.modules.dnc.entity.*; import org.jeecg.modules.dnc.mapper.*; +import org.jeecg.modules.dnc.service.*; +import org.jeecg.modules.system.entity.MdcProduction; +import org.jeecg.modules.system.service.IMdcProductionService; +import org.jeecg.modules.system.service.ISysUserService; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.beans.factory.annotation.Autowired; @@ -64,6 +70,48 @@ @Autowired private GuideCardBatchMapper guideCardBatchMapper; + @Autowired + private ISysUserService sysUserService; + + @Autowired + private IMdcProductionService mdcProductionService; + + @Autowired + private IProductPermissionService productPermissionService; + + @Autowired + private IProductDepartmentService productDepartmentService; + + @Autowired + private IComponentPermissionService componentPermissionService; + + @Autowired + private IComponentDepartmentService componentDepartmentService; + + @Autowired + private IPartsPermissionService partsPermissionService; + + @Autowired + private IPartsDepartmentService partsDepartmentService; + + @Autowired + private IProcessSpecVersionPermissionService processSpecVersionPermissionService; + + @Autowired + private IProcessSpecVersionDepartmentService processSpecVersionDepartmentService; + + @Autowired + private IProcessStreamPermissionService processStreamPermissionService; + + @Autowired + private IProcessionDepartmentService processionDepartmentService; + + @Autowired + private IWorkStepPermissionService workStepPermissionService; + + @Autowired + private IWorkStepDepartmentService workStepDepartmentService; + @Transactional(rollbackFor = Exception.class) public void importTransferPackage(TransferPackage transferPackage) { try { @@ -109,6 +157,12 @@ if (transferPackage.getTraceChain() != null&& transferPackage.getTraceChain().getTreePath() != null) { saveTreePath(transferPackage.getTraceChain().getTreePath()); + } + + //淇濆瓨鏉冮檺 + if (transferPackage.getTraceChain() != null&& + transferPackage.getTraceChain().getPermissionStreamNewList() != null) { + savePermissionStreamNewList(transferPackage.getTraceChain().getPermissionStreamNewList()); } // 淇濆瓨璁惧绫� @@ -170,8 +224,7 @@ productMapper.insert(product); logger.debug("浜у搧宸蹭繚瀛�: {}", product.getProductId()); } else { - productMapper.updateById(product); - logger.debug("浜у搧宸叉洿鏂�: {}", product.getProductId()); + logger.debug("浜у搧宸插瓨鍦�: {}", product.getProductId()); } } @@ -181,8 +234,7 @@ componentMapper.insert(component); logger.debug("閮ㄤ欢宸蹭繚瀛�: {}", component.getComponentId()); } else { - componentMapper.updateById(component); - logger.debug("閮ㄤ欢宸叉洿鏂�: {}", component.getComponentId()); + logger.debug("閮ㄤ欢宸插瓨鍦�: {}", component.getComponentId()); } } } @@ -192,8 +244,7 @@ partsMapper.insert(parts); logger.debug("闆朵欢宸蹭繚瀛�: {}", parts.getPartsId()); } else { - partsMapper.updateById(parts); - logger.debug("闆朵欢宸叉洿鏂�: {}", parts.getPartsId()); + logger.debug("闆朵欢宸插瓨鍦�: {}", parts.getPartsId()); } } @@ -202,8 +253,7 @@ psvMapper.insert(processSpec); logger.debug("宸ヨ壓瑙勭▼宸蹭繚瀛�: {}", processSpec.getId()); } else { - psvMapper.updateById(processSpec); - logger.debug("宸ヨ壓瑙勭▼宸叉洿鏂�: {}", processSpec.getId()); + logger.debug("宸ヨ壓瑙勭▼宸插瓨鍦�: {}", processSpec.getId()); } } @@ -212,8 +262,7 @@ processMapper.insert(process); logger.debug("宸ュ簭宸蹭繚瀛�: {}", process.getProcessId()); } else { - processMapper.updateById(process); - logger.debug("宸ュ簭宸叉洿鏂�: {}", process.getProcessId()); + logger.debug("宸ュ簭宸插瓨鍦�: {}", process.getProcessId()); } } @@ -222,8 +271,7 @@ workStepMapper.insert(workStep); logger.debug("宸ユ宸蹭繚瀛�: {}", workStep.getId()); } else { - workStepMapper.updateById(workStep); - logger.debug("宸ユ宸叉洿鏂�: {}", workStep.getId()); + logger.debug("宸ユ宸插瓨鍦�: {}", workStep.getId()); } } @@ -233,10 +281,115 @@ productMixMapper.insert(productMix); logger.debug("浜у搧缁勫悎宸蹭繚瀛�: {}", productMix.getId()); } else { - productMixMapper.updateById(productMix); - logger.debug("浜у搧缁勫悎宸叉洿鏂�: {}", productMix.getId()); + logger.debug("浜у搧缁勫悎宸插瓨鍦�: {}", productMix.getId()); } } + } + + private void savePermissionStreamNewList(List<PermissionStreamNew> permissionStreamNewList) { + for (PermissionStreamNew permissionStreamNew : permissionStreamNewList) { + if (permissionStreamNewMapper.selectById(permissionStreamNew.getId()) == null) { + if (permissionStreamNew.getUserId() != null) { + String id=sysUserService.getUserByName(permissionStreamNew.getUserId()).getId(); + if (id!=null){ + permissionStreamNew.setUserId(id); + } + } + if (permissionStreamNew.getDepartId() != null) { + MdcProduction mdcProduction=mdcProductionService.findByOrgCode(permissionStreamNew.getDepartId()); + if (mdcProduction!=null){ + permissionStreamNew.setDepartId(mdcProduction.getId()); + } + } + permissionStreamNewMapper.insert(permissionStreamNew); + logger.debug("鏉冮檺宸蹭繚瀛�: {}", permissionStreamNew.getId()); + } + } + //鍒嗘壒娣诲姞浜у搧銆侀儴浠躲�侀浂浠躲�佸伐鑹鸿绋嬨�佸伐搴忋�佸伐姝ユ潈闄� + permissionStreamNewList.forEach(item -> { + switch (item.getBusinessType()){ + case "1": + if (StrUtil.isNotEmpty(item.getUserId())){ + ProductPermission productPermission = new ProductPermission(); + productPermission.setProductId(item.getBusinessId()); + productPermission.setUserId(item.getUserId()); + productPermissionService.save(productPermission); + }else { + ProductDepartment productDepartment = new ProductDepartment(); + productDepartment.setProductId(item.getBusinessId()); + productDepartment.setDepartId(item.getDepartId()); + productDepartmentService.save(productDepartment); + } + break; + case "2": + + if (StrUtil.isNotEmpty(item.getUserId())){ + ComponentPermission componentPermission = new ComponentPermission(); + componentPermission.setComponentId(item.getBusinessId()); + componentPermission.setUserId(item.getUserId()); + componentPermissionService.save(componentPermission); + }else { + ComponentDepartment componentDepartment = new ComponentDepartment(); + componentDepartment.setComponentId(item.getBusinessId()); + componentDepartment.setDepartId(item.getDepartId()); + componentDepartmentService.save(componentDepartment); + } + break; + case "3": + if (StrUtil.isNotEmpty(item.getUserId())){ + PartsPermission partsPermission = new PartsPermission(); + partsPermission.setPartsId(item.getBusinessId()); + partsPermission.setUserId(item.getUserId()); + partsPermissionService.save(partsPermission); + }else { + PartsDepartment partsDepartment = new PartsDepartment(); + partsDepartment.setPartsId(item.getBusinessId()); + partsDepartment.setDepartId(item.getDepartId()); + partsDepartmentService.save(partsDepartment); + } + break; + case "4": + if (StrUtil.isNotEmpty(item.getUserId())){ + ProcessSpecVersionPermission processSpecVersionPermission = new ProcessSpecVersionPermission(); + processSpecVersionPermission.setPsvId(item.getBusinessId()); + processSpecVersionPermission.setUserId(item.getUserId()); + processSpecVersionPermissionService.save(processSpecVersionPermission); + }else { + ProcessSpecVersionDepartment processSpecVersionDepartment = new ProcessSpecVersionDepartment(); + processSpecVersionDepartment.setPsvId(item.getBusinessId()); + processSpecVersionDepartment.setDepartId(item.getDepartId()); + processSpecVersionDepartmentService.save(processSpecVersionDepartment); + } + break; + case "5": + if (StrUtil.isNotEmpty(item.getUserId())){ + ProcessionPermission processionPermission = new ProcessionPermission(); + processionPermission.setProcessId(item.getBusinessId()); + processionPermission.setUserId(item.getUserId()); + processStreamPermissionService.save(processionPermission); + }else { + ProcessionDepartment processionDepartment = new ProcessionDepartment(); + processionDepartment.setProcessId(item.getBusinessId()); + processionDepartment.setDepartId(item.getDepartId()); + processionDepartmentService.save(processionDepartment); + } + break; + case "6": + if (StrUtil.isNotEmpty(item.getUserId())){ + WorkStepPermission workStepPermission = new WorkStepPermission(); + workStepPermission.setStepId(item.getBusinessId()); + workStepPermission.setUserId(item.getUserId()); + workStepPermissionService.save(workStepPermission); + }else { + WorkStepDepartment workStepDepartment = new WorkStepDepartment(); + workStepDepartment.setStepId(item.getBusinessId()); + workStepDepartment.setDepartId(item.getDepartId()); + workStepDepartmentService.save(workStepDepartment); + } + break; + default: + } + }); } private void saveDeviceManagement(DeviceManagement deviceManagement) { @@ -244,8 +397,7 @@ deviceManagementMapper.insert(deviceManagement); logger.debug("璁惧绫讳俊鎭凡淇濆瓨: {}", deviceManagement.getId()); } else { - deviceManagementMapper.updateById(deviceManagement); - logger.debug("璁惧绫讳俊鎭凡鏇存柊: {}", deviceManagement.getId()); + logger.debug("璁惧绫讳俊鎭凡瀛樺湪: {}", deviceManagement.getId()); } } @@ -254,8 +406,7 @@ deviceTypeMapper.insert(deviceType); logger.debug("璁惧绫诲凡淇濆瓨: {}", deviceType.getId()); } else { - deviceTypeMapper.updateById(deviceType); - logger.debug("璁惧绫诲凡鏇存柊: {}", deviceType.getId()); + logger.debug("璁惧绫诲凡瀛樺湪: {}", deviceType.getId()); } } @@ -264,9 +415,7 @@ docInfoMapper.insert(docInfo); logger.debug("鏂囨。宸蹭繚瀛�: {}", docInfo.getDocId()); } else { - docInfo.setDocDispatchStatus(5); - docInfoMapper.updateById(docInfo); - logger.debug("鏂囨。宸叉洿鏂�: {}", docInfo.getDocId()); + logger.debug("鏂囨。宸插瓨鍦�: {}", docInfo.getDocId()); } } @@ -275,8 +424,7 @@ docFileMapper.insert(docFile); logger.debug("鏂囨。鏂囦欢宸蹭繚瀛�: {}", docFile.getFileId()); } else { - docFileMapper.updateById(docFile); - logger.debug("鏂囨。鏂囦欢宸叉洿鏂�: {}", docFile.getFileId()); + logger.debug("鏂囨。鏂囦欢宸插瓨鍦�: {}", docFile.getFileId()); } } @@ -285,8 +433,7 @@ docRelativeMapper.insert(docRelative); logger.debug("鏂囨。瀵瑰簲鍏崇郴宸蹭繚瀛�: {}", docRelative.getId()); } else { - docRelativeMapper.updateById(docRelative); - logger.debug("鏂囨。瀵瑰簲鍏崇郴宸叉洿鏂�: {}", docRelative.getId()); + logger.debug("鏂囨。瀵瑰簲鍏崇郴宸插瓨鍦�: {}", docRelative.getId()); } } @@ -297,18 +444,17 @@ logger.debug("鍒�鍏峰凡淇濆瓨: {}", cutter.getId()); } else { cutterMapper.updateById(cutter); - logger.debug("鍒�鍏峰凡鏇存柊: {}", cutter.getId()); } } } private void saveGuideCardBatch(GuideCardBatch guideCardBatch) { if (guideCardBatchMapper.selectById(guideCardBatch.getId()) == null) { + guideCardBatch.setFlowStatus("1"); guideCardBatchMapper.insert(guideCardBatch); - logger.debug("绋嬪簭鍔犲伐纭琛ㄥ凡淇濆瓨: {}", guideCardBatch.getId()); + logger.debug("鍒�鐗囨壒娆″凡淇濆瓨: {}", guideCardBatch.getId()); } else { - guideCardBatchMapper.updateById(guideCardBatch); - logger.debug("绋嬪簭鍔犲伐纭琛ㄥ凡鏇存柊: {}", guideCardBatch.getId()); + logger.debug("鍒�鐗囨壒娆″凡瀛樺湪: {}", guideCardBatch.getId()); } } } diff --git a/lxzn-module-dnc/src/main/java/org/jeecg/modules/dnc/service/impl/FileFerryService.java b/lxzn-module-dnc/src/main/java/org/jeecg/modules/dnc/service/impl/FileFerryService.java index 4661dcd..586e458 100644 --- a/lxzn-module-dnc/src/main/java/org/jeecg/modules/dnc/service/impl/FileFerryService.java +++ b/lxzn-module-dnc/src/main/java/org/jeecg/modules/dnc/service/impl/FileFerryService.java @@ -1,13 +1,24 @@ package org.jeecg.modules.dnc.service.impl; +import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; +import liquibase.pro.packaged.S; +import org.apache.commons.lang3.StringUtils; import org.jeecg.modules.dnc.dto.ComponentHierarchy; import org.jeecg.modules.dnc.dto.TransferPackage; -import org.jeecg.modules.dnc.entity.ComponentInfo; -import org.jeecg.modules.dnc.entity.DocFile; +import org.jeecg.modules.dnc.entity.*; +import org.jeecg.modules.dnc.exception.ExceptionCast; +import org.jeecg.modules.dnc.mapper.DocRelativeMapper; +import org.jeecg.modules.dnc.response.ActivitiCode; +import org.jeecg.modules.dnc.response.DocumentCode; import org.jeecg.modules.dnc.service.IDocClassificationService; +import org.jeecg.modules.dnc.service.IDocFileService; import org.jeecg.modules.dnc.service.IDocInfoService; import org.jeecg.modules.dnc.service.IDocRelativeService; +import org.jeecg.modules.dnc.utils.CompressionUtils; import org.jeecg.modules.dnc.utils.JsonUtils; +import org.jeecg.modules.dnc.utils.file.FileUtilS; +import org.jeecg.modules.dncFlow.service.IAssignFileStreamService; +import org.jeecg.modules.mdc.entity.MdcEquipment; import org.jeecg.modules.mdc.mapper.MdcEquipmentMapper; import org.jeecg.modules.system.service.IMdcProductionService; import org.slf4j.Logger; @@ -29,9 +40,6 @@ @Service public class FileFerryService { - private final DataPackageService dataPackageService; - private final SecurityService securityService; - private static final Logger logger = LoggerFactory.getLogger(FileFerryService.class); @Value("${deploy.secretFolder}") @@ -47,19 +55,15 @@ private IMdcProductionService mdcProductionService; @Autowired + private IDocInfoService docInfoService; + + @Autowired private IDocClassificationService classificationService; @Autowired private IDocRelativeService docRelativeService; - @Autowired - private IDocInfoService docInfoService; - - @Autowired - public FileFerryService(DataPackageService dataPackageService, SecurityService securityService) { - this.dataPackageService = dataPackageService; - this.securityService = securityService; - } + private DataPackageService dataPackageService; public String exportData(TransferPackage.DataType type, String id,String fileName) { // 1. 鑾峰彇灏佽鏁版嵁 @@ -87,6 +91,8 @@ throw new RuntimeException("鏂囦欢鍐欏叆澶辫触", e); } } + + public TransferPackage importData(String filePath) { try { @@ -140,6 +146,7 @@ // 6. 鑾峰彇鏂囦欢澶嶅埗鐩爣璺緞 DocFile docFile = pkg.getTraceChain().getDocFile(); + DocInfo docInfo = pkg.getTraceChain().getDocInfo(); if (docFile == null) { throw new IllegalStateException("浼犺緭鍖呬腑缂哄皯鏂囨。鏂囦欢淇℃伅"); } @@ -159,6 +166,41 @@ Path source = Paths.get(ncFilePath); Files.copy(source, Paths.get(targetPath), StandardCopyOption.REPLACE_EXISTING); + // 8. 鏌ヨ璁惧id + MdcEquipment mdcEquipment=mdcEquipmentMapper.selectOne(new QueryWrapper<MdcEquipment>().eq("equipment_id",equipmentId)); + if (mdcEquipment == null) { + throw new IllegalArgumentException("鏃犳晥鐨勮澶嘔D: " + equipmentId); + } + + // 9.浼犺緭鏂囦欢鍒拌澶囦笅 + List<String> strings = mdcProductionService.findListParentTreeAll(mdcEquipment.getId()); + if (strings != null && !strings.isEmpty()) { + DocInfo deviceDoc = docInfoService.getByDocAttrAndDocId(docInfo.getDocId(), 7, mdcEquipment.getId()); + if (deviceDoc == null) { + DocClassification classification = classificationService.getByCode("send"); + if(classification == null) + ExceptionCast.cast(DocumentCode.DOC_CLASS_ERROR); + DocRelative docRelative = new DocRelative(); + docRelative.setDocId(docInfo.getDocId()); + docRelative.setClassificationId(classification.getClassificationId()); + docRelative.setAttributionType(7); + docRelative.setAttributionId(mdcEquipment.getId()); + docRelativeService.save(docRelative); + } + String sendPath = StringUtils.join(strings.toArray(), "/"); + boolean copyFileNc = FileUtilS.copyFileNc(docFile.getFilePath(), sendPath + "/" + mdcEquipment.getEquipmentId(), + docFile.getFileEncodeName(), + docFile.getFileName(), docFile.getFileSuffix()); + if (!copyFileNc) { + ExceptionCast.cast(ActivitiCode.ACT_FILE_ERROR); + } else { + FileUtilS.deleteZipFromToSend(sendPath + "/" + mdcEquipment.getEquipmentId(), + docFile.getFileName(), docFile.getFileSuffix()); + } + } else { + throw new RuntimeException("鏂囦欢浼犺緭璺緞鑾峰彇澶辫触"); + } + // 10.鍒犻櫎涓存椂NC鏂囦欢涓巎son鏂囦欢 logger.info("鍒犻櫎涓存椂鏂囦欢: {}", ncFilePath); Files.delete(source); diff --git a/lxzn-module-dnc/src/main/java/org/jeecg/modules/dnc/service/impl/FullHierarchyTraceService.java b/lxzn-module-dnc/src/main/java/org/jeecg/modules/dnc/service/impl/FullHierarchyTraceService.java index 43d8920..1180bdf 100644 --- a/lxzn-module-dnc/src/main/java/org/jeecg/modules/dnc/service/impl/FullHierarchyTraceService.java +++ b/lxzn-module-dnc/src/main/java/org/jeecg/modules/dnc/service/impl/FullHierarchyTraceService.java @@ -6,7 +6,6 @@ import org.jeecg.modules.dnc.entity.*; import org.jeecg.modules.dnc.mapper.*; import org.jeecg.modules.dnc.service.IPermissionStreamNewService; -import org.jeecg.modules.system.entity.MdcProduction; import org.jeecg.modules.system.service.IMdcProductionService; import org.jeecg.modules.system.service.ISysUserService; import org.springframework.beans.factory.annotation.Autowired; @@ -47,12 +46,6 @@ private CutterMapper cutterMapper; @Autowired private GuideCardBatchMapper guideCardBatchMapper; - @Autowired - private IPermissionStreamNewService permissionStreamNewService; - @Autowired - private ISysUserService sysUserService; - @Autowired - private IMdcProductionService mdcProductionService; public ProcessTraceChain traceFromProcess(DocRelative docRelative) { ProcessTraceChain chain = initChainWithDocInfo(docRelative); @@ -67,7 +60,6 @@ completeChainWithProductInfo(chain); List<ProductMix> productMixList=buildFullTreePath(chain); chain.setTreePath(productMixList); - chain.setPermissionStreamNewList(buildFullTreePathPermission(productMixList)); return chain; } @@ -84,7 +76,6 @@ completeChainWithProductInfo(chain); List<ProductMix> productMixList=buildFullTreePath(chain); chain.setTreePath(productMixList); - chain.setPermissionStreamNewList(buildFullTreePathPermission(productMixList)); return chain; } @@ -219,22 +210,4 @@ return path; } - private List<PermissionStreamNew> buildFullTreePathPermission(List<ProductMix> productMixList) { - List<Long> ids=productMixList.stream().map(ProductMix::getId).collect(Collectors.toList()); - List<PermissionStreamNew> path = permissionStreamNewService - .list(new QueryWrapper<PermissionStreamNew>().in("business_id",ids) - .eq("delete_flag",0)); - path.forEach(item->{ - if (item.getDepartId()!=null){ - MdcProduction mdcProduction=mdcProductionService.getById(item.getDepartId()); - if(mdcProduction!=null){ - item.setDepartId(item.getDepartId()); - } - } - if (item.getUserId()!=null){ - item.setUserId(sysUserService.getById(item.getUserId()).getUsername()); - } - }); - return path; - } } diff --git a/lxzn-module-dnc/src/main/java/org/jeecg/modules/dnc/service/impl/GuideCardBatchServiceImpl.java b/lxzn-module-dnc/src/main/java/org/jeecg/modules/dnc/service/impl/GuideCardBatchServiceImpl.java index 9ccebff..f61a051 100644 --- a/lxzn-module-dnc/src/main/java/org/jeecg/modules/dnc/service/impl/GuideCardBatchServiceImpl.java +++ b/lxzn-module-dnc/src/main/java/org/jeecg/modules/dnc/service/impl/GuideCardBatchServiceImpl.java @@ -1,21 +1,39 @@ package org.jeecg.modules.dnc.service.impl; +import com.alibaba.fastjson.JSON; import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; import org.apache.shiro.SecurityUtils; +import org.flowable.engine.TaskService; +import org.flowable.task.api.Task; +import org.jeecg.common.api.vo.Result; import org.jeecg.common.system.vo.LoginUser; import org.jeecg.common.util.DateUtils; import org.jeecg.modules.dnc.constant.DocAttributionTypeEnum; import org.jeecg.modules.dnc.entity.*; import org.jeecg.modules.dnc.mapper.GuideCardBatchMapper; +import org.jeecg.modules.dnc.response.ActivitiCode; +import org.jeecg.modules.dnc.response.CommonCode; +import org.jeecg.modules.dnc.response.UcenterCode; import org.jeecg.modules.dnc.service.*; +import org.jeecg.modules.dnc.utils.ValidateUtil; +import org.jeecg.modules.dncFlow.constant.GuideCardBatchEnum; +import org.jeecg.modules.dncFlow.entity.DispatchFile; +import org.jeecg.modules.dncFlow.vo.GuideCardBatchFlowTaskVo; +import org.jeecg.modules.flowable.apithird.business.entity.FlowMyBusiness; +import org.jeecg.modules.flowable.apithird.business.service.IFlowMyBusinessService; +import org.jeecg.modules.flowable.apithird.service.FlowCallBackServiceI; +import org.jeecg.modules.flowable.apithird.service.FlowCommonService; +import org.jeecg.modules.flowable.service.IFlowDefinitionService; +import org.jeecg.modules.flowable.service.IFlowTaskService; import org.jeecg.modules.system.service.ISysDictService; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; +import org.springframework.transaction.interceptor.TransactionAspectSupport; -import java.util.Date; -import java.util.List; +import javax.annotation.Resource; +import java.util.*; /** * @Description: nc鏂囦欢瀵瑰簲鏁版帶绋嬪簭鍔犲伐纭琛� @@ -23,8 +41,8 @@ * @Date: 2025-05-27 * @Version: V1.0 */ -@Service -public class GuideCardBatchServiceImpl extends ServiceImpl<GuideCardBatchMapper, GuideCardBatch> implements IGuideCardBatchService { +@Service("IGuideCardBatchService") +public class GuideCardBatchServiceImpl extends ServiceImpl<GuideCardBatchMapper, GuideCardBatch> implements IGuideCardBatchService , FlowCallBackServiceI { @Autowired private ISysDictService sysDictService; @@ -43,6 +61,17 @@ @Autowired private IDeviceTypeService deviceTypeService; + + @Resource + private FlowCommonService flowCommonService; + @Resource + private IFlowDefinitionService flowDefinitionService; + @Autowired + private IFlowTaskService flowTaskService; + @Autowired + private TaskService taskService; + @Autowired + private IFlowMyBusinessService flowMyBusinessService; /** * 鐢熸垚娴佹按鍙� @@ -126,18 +155,193 @@ guideCardBatch.setProcessWorkCode(workStep.getStepCode()); partsInfo=partsInfoService.getById(workStep.getPartsId()); } + if (partsInfo==null){ + return false; + } guideCardBatch.setDocId(docId); guideCardBatch.setSerialNumber(getSerialNumber("C140")); guideCardBatch.setUnit(sysDictService.queryDictTextByKey("unit_code", "C140")); guideCardBatch.setDocName(docInfo.getDocName()); - if (partsInfo!=null){ - guideCardBatch.setPartsCode(partsInfo.getPartsCode()); - guideCardBatch.setPartsName(partsInfo.getPartsName()); - guideCardBatch.setMaterielDesp(partsInfo.getStructureType()); - } - guideCardBatch.setFlowStatus("0"); + guideCardBatch.setPartsCode(partsInfo.getPartsCode()); + guideCardBatch.setPartsName(partsInfo.getPartsName()); + guideCardBatch.setMaterielDesp(partsInfo.getMaterielDesp()); guideCardBatch.setCompiler(user.getUsername()); guideCardBatch.setCreateTime(new Date()); return this.save(guideCardBatch); } + + /** + * 鍙戣捣纭娴佺▼ + * @param id + * @return + */ + @Override + @Transactional(rollbackFor = Exception.class) + public Result<?> startGuideCardBatch(String id){ + LoginUser user = (LoginUser) SecurityUtils.getSubject().getPrincipal(); + //鑾峰彇绋嬪簭鍔犲伐纭琛� + GuideCardBatch guideCardBatch=this.getById(id); + if (guideCardBatch==null) { + return Result.ok("鏈壘鍒板搴旂殑绋嬪簭鍔犲伐纭琛�"); + } + //濉厖鏁版嵁 + guideCardBatch.setCompiler(user.getUsername()); + guideCardBatch.setCompilerTime(new Date()); + guideCardBatch.setFlowStatus(GuideCardBatchEnum.VERIFY.getCode()); + this.updateById(guideCardBatch); + System.out.println("绋嬪簭鍔犲伐纭琛� 纭娴佺▼锛�" + guideCardBatch.getId()); + flowCommonService.initActBusiness("娴佹按鍙凤細"+guideCardBatch.getSerialNumber()+" 绋嬪簭鍔犲伐纭琛ㄨ繘琛岀‘璁ゆ祦绋�", + guideCardBatch.getId(), "IGuideCardBatchService", "nc_guide_card_batch", null); + Map<String, Object> variables = new HashMap<>(); + variables.put("dataId", guideCardBatch.getId()); + variables.put("organization", "鐢ㄦ埛"+user.getRealname()+"鍙戣捣娴佺▼"); + variables.put("comment", "鐢ㄦ埛"+user.getRealname()+"鍙戣捣娴佺▼"); + variables.put("proofreading",true); + Result result= flowDefinitionService.startProcessInstanceByKey("nc_guide_card_batch", variables); + if (!result.isSuccess()) { + guideCardBatch.setCompiler(null); + guideCardBatch.setCompilerTime(null); + this.updateById(guideCardBatch); + } + return result; + } + + /** + * 娴佺▼鑺傜偣瀹℃牳 + * @param guideCardBatchFlowTaskVo + * @return + */ + @Override + @Transactional(rollbackFor = Exception.class) + public Result<?> auditGuideCardBatch(GuideCardBatchFlowTaskVo guideCardBatchFlowTaskVo){ + LoginUser user = (LoginUser) SecurityUtils.getSubject().getPrincipal(); + try { + // 鍙傛暟鏍¢獙 + if (!ValidateUtil.validateString(guideCardBatchFlowTaskVo.getTaskId()) || !ValidateUtil.validateString(guideCardBatchFlowTaskVo.getDataId())) { + return Result.error(CommonCode.INVALID_PARAM.toString()); + } + String userId = user.getId(); + guideCardBatchFlowTaskVo.setAssignee(user.getUsername()); + if (!ValidateUtil.validateString(userId)) { + return Result.error(UcenterCode.UCENTER_ACCOUNT_NOT_EXIST.toString()); + } + + // 鏁版嵁鏌ヨ + GuideCardBatch guideCardBatch = this.getById(guideCardBatchFlowTaskVo.getDataId()); + if (guideCardBatch == null) { + return Result.error(CommonCode.INVALID_PARAM.toString()); + } + DocInfo docInfo = docInfoService.getById(guideCardBatch.getDocId()); + if (docInfo == null) { + return Result.error(ActivitiCode.ACT_DOC_ERROR.toString()); + } + + // 2. 鏌ヨ娴佺▼涓氬姟璁板綍锛堝鐞嗙┖缁撴灉锛� + List<FlowMyBusiness> businessList = flowMyBusinessService.list( + new QueryWrapper<FlowMyBusiness>() + .eq("process_instance_id", guideCardBatchFlowTaskVo.getInstanceId()) + ); + if (businessList.isEmpty()) { + return Result.error("娴佺▼璁板綍涓嶅瓨鍦�"); + } + FlowMyBusiness flowMyBusiness = businessList.get(0); + + // 3. 鏍¢獙鐢ㄦ埛鏄惁涓哄�欓�夊鐞嗕汉 + List<String> todoUsers = JSON.parseArray(flowMyBusiness.getTodoUsers(), String.class); + if (todoUsers == null || !todoUsers.contains(user.getUsername())) { + return Result.error("鐢ㄦ埛鏃犳潈鎿嶄綔姝や换鍔�"); + } + + // 4. 璁ら浠诲姟锛堝鐞嗗凡琚棰嗙殑鎯呭喌锛� + String taskId = flowMyBusiness.getTaskId(); + Task task = taskService.createTaskQuery().taskId(taskId).singleResult(); + if (task == null) { + return Result.error("浠诲姟涓嶅瓨鍦ㄦ垨宸插畬鎴�"); + } + if (task.getAssignee() != null && !task.getAssignee().equals(user.getUsername())) { + return Result.error("浠诲姟宸茶浠栦汉璁ら"); + } + taskService.claim(taskId, user.getUsername()); + + // 璁剧疆娴佺▼鍙橀噺 + Map<String, Object> values = new HashMap<>(); + values.put("dataId", guideCardBatch.getId()); + values.put("assignee", userId); + values.put("comment", guideCardBatchFlowTaskVo.getComment()); + values.put("organization", guideCardBatchFlowTaskVo.getComment()); + if (guideCardBatchFlowTaskVo.getCheckType() != null) { + values.put("checkType", guideCardBatchFlowTaskVo.getCheckType()); + } + if (guideCardBatchFlowTaskVo.getConfirmType() != null) { + values.put("confirmType", guideCardBatchFlowTaskVo.getConfirmType()); + } + if (guideCardBatchFlowTaskVo.getApproveType() != null) { + values.put("approveType", guideCardBatchFlowTaskVo.getApproveType()); + } + guideCardBatchFlowTaskVo.setValues(values); + // 瀹屾垚娴佺▼浠诲姟 + Result result = flowTaskService.complete(guideCardBatchFlowTaskVo); + if (result.isSuccess()) { + if (guideCardBatchFlowTaskVo.getCheckType() != null) { + if (guideCardBatchFlowTaskVo.getCheckType()){ + guideCardBatch.setFlowStatus(GuideCardBatchEnum.CONFIRM.getCode()); + guideCardBatch.setProofreader(user.getUsername()); + guideCardBatch.setProofreaderTime(new Date()); + }else { + guideCardBatch.setFlowStatus(GuideCardBatchEnum.PREPARE.getCode()); + } + } + if (guideCardBatchFlowTaskVo.getConfirmType() != null) { + if (guideCardBatchFlowTaskVo.getConfirmType()){ + guideCardBatch.setFlowStatus(GuideCardBatchEnum.APPROVE.getCode()); + guideCardBatch.setOperator(user.getUsername()); + guideCardBatch.setInspectionTime(new Date()); + guideCardBatch.setInspectionOpinion(guideCardBatchFlowTaskVo.getInspectionOpinion()); + }else { + guideCardBatch.setFlowStatus(GuideCardBatchEnum.PREPARE.getCode()); + } + } + if (guideCardBatchFlowTaskVo.getApproveType() != null) { + if (guideCardBatchFlowTaskVo.getApproveType()){ + guideCardBatch.setFlowStatus(GuideCardBatchEnum.COMPLETE.getCode()); + guideCardBatch.setApprover(user.getUsername()); + guideCardBatch.setApproverTime(new Date()); + }else { + guideCardBatch.setFlowStatus(GuideCardBatchEnum.PREPARE.getCode()); + } + } + this.updateById(guideCardBatch); + } else { + return result; + } + return Result.OK("鎿嶄綔鎴愬姛"); + } catch (Exception e) { + // 璁剧疆浜嬪姟鍥炴粴 + TransactionAspectSupport.currentTransactionStatus().setRollbackOnly(); + return Result.error("鎿嶄綔澶辫触锛�" + e.getMessage()); + } + } + + @Override + public void afterFlowHandle(FlowMyBusiness business) { + business.getTaskNameId();//鎺ヤ笅鏉ュ鎵圭殑鑺傜偣 + business.getValues();//鍓嶇浼犺繘鏉ョ殑鍙傛暟 + business.getActStatus(); + } + + @Override + public Object getBusinessDataById(String dataId) { + return this.getById(dataId); + } + + @Override + public Map<String, Object> flowValuesOfTask(String taskNameId, Map<String, Object> values) { + return null; + } + + @Override + public List<String> flowCandidateUsernamesOfTask(String taskNameId, Map<String, Object> values) { + //涓氬姟鏄惁骞查娴佺▼锛屼笟鍔″共棰勶紝娴佺▼骞查锛屾寚瀹氫汉鍛樿繘琛屽鐞� + return null; + } } diff --git a/lxzn-module-dnc/src/main/java/org/jeecg/modules/dnc/service/impl/ProductMixServiceImpl.java b/lxzn-module-dnc/src/main/java/org/jeecg/modules/dnc/service/impl/ProductMixServiceImpl.java index 699b3a6..ef68867 100644 --- a/lxzn-module-dnc/src/main/java/org/jeecg/modules/dnc/service/impl/ProductMixServiceImpl.java +++ b/lxzn-module-dnc/src/main/java/org/jeecg/modules/dnc/service/impl/ProductMixServiceImpl.java @@ -1,17 +1,19 @@ package org.jeecg.modules.dnc.service.impl; +import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; import org.apache.shiro.SecurityUtils; import org.jeecg.common.system.vo.LoginUser; -import org.jeecg.modules.dnc.entity.ProductMix; +import org.jeecg.modules.dnc.entity.*; import org.jeecg.modules.dnc.mapper.ProductMixMapper; -import org.jeecg.modules.dnc.service.IPermissionStreamNewService; -import org.jeecg.modules.dnc.service.IProductMixService; +import org.jeecg.modules.dnc.service.*; import org.jeecg.modules.dnc.utils.TreeBuilder; import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.context.annotation.Lazy; import org.springframework.stereotype.Service; import java.util.*; +import java.util.stream.Collectors; @Service public class ProductMixServiceImpl extends ServiceImpl<ProductMixMapper, ProductMix> implements IProductMixService { @@ -19,6 +21,21 @@ @Autowired private IPermissionStreamNewService permissionStreamNewService; + @Autowired + @Lazy + private IDeviceTypeService deviceTypeService; + + @Autowired + @Lazy + private IDeviceManagementService deviceManagementService; + + @Autowired + @Lazy + private IDocInfoService docInfoService; + + @Autowired + @Lazy + private IDocRelativeService docRelativeService; /** * 榛樿缁撴瀯鏍戞煡璇� * @return @@ -111,4 +128,72 @@ return childrenList; } + /** + * 鏌ヨ浜у搧缁撴瀯鏍戯紙鍖呮嫭璁惧绫讳笌nc鏂囦欢锛� + * @return + */ + @Override + public List<ProductMix> getProductMixTree() { + LoginUser loginUser = (LoginUser) SecurityUtils.getSubject().getPrincipal(); + List<ProductMix> rawData = new ArrayList<>(); + if (loginUser.getUsername().equals("admin")) { + //涓嶉渶瑕佹潈闄愯繃婊� + rawData = permissionStreamNewService.loadProductMixAll(loginUser.getId()); + } else { + //闇�瑕佹潈闄愯繃婊� + String productIds = loginUser.getProductionIds(); + if (productIds != null && !productIds.isEmpty()) { + List<String> productIdList = Arrays.asList(productIds.split(",")); + rawData = permissionStreamNewService.loadProductMix(loginUser.getId(), productIdList); + } + } + List<Long> ids = rawData.stream() + .filter(p -> p.getType() != null) + .filter(productMix -> productMix.getType() == 5 || productMix.getType() == 6) + .map(ProductMix::getId) + .collect(Collectors.toList()); + if (ids.isEmpty()) { + return rawData; + } + //杩囨护璁惧绫诲叧鑱斾俊鎭� + List<DeviceType> deviceTypeList = deviceTypeService.list(new QueryWrapper<DeviceType>() + .in("attribution_id", ids)); + List<ProductMix> productMixList = new ArrayList<>(); + deviceTypeList.forEach(item->{ + ProductMix productMix = new ProductMix(); + productMix.setId(Long.parseLong(item.getId())); + productMix.setParentId(Long.parseLong(item.getAttributionId())); + DeviceManagement deviceManagement=deviceManagementService.getById(item.getDeviceManagementId()); + productMix.setTreeCode(deviceManagement.getDeviceManagementCode()); + productMix.setTreeName(deviceManagement.getDeviceManagementName()); + productMix.setType(7); + productMixList.add(productMix); + }); + rawData.addAll(productMixList); + //杩囨护鏂囨。鍏宠仈淇℃伅 + List<String> deviceTypeIds = deviceTypeList.stream().map(DeviceType::getId).collect(Collectors.toList()); + List<DocRelative> relativeList = docRelativeService.list(new QueryWrapper<DocRelative>() + .in("attribution_id", deviceTypeIds)); + List<ProductMix> docList = new ArrayList<>(); + relativeList.forEach(item->{ + ProductMix productMix = new ProductMix(); + productMix.setId(Long.parseLong(item.getId())); + productMix.setParentId(Long.parseLong(item.getAttributionId())); + DocInfo docInfo = docInfoService.getById(item.getDocId()); + productMix.setTreeCode(docInfo.getDocSuffix()); + productMix.setTreeName(docInfo.getDocName()); + productMix.setType(99); + docList.add(productMix); + }); + rawData.addAll(docList); + TreeBuilder builder = new TreeBuilder(); + TreeBuilder.CleanResult cleanResult = builder.preprocessData(rawData); + List<ProductMix> sorted = builder.topologicalSort( + cleanResult.getValidNodes(), + cleanResult.getNodeMap() + ); + List<ProductMix> result =builder.assembleTree(sorted, cleanResult.getNodeMap()); + result.sort(Comparator.comparing(ProductMix::getCreateTime, Comparator.nullsLast(Date::compareTo))); + return result; + } } diff --git a/lxzn-module-dnc/src/main/java/org/jeecg/modules/dncFlow/adapter/AssignEquipmentFileStreamAdapter.java b/lxzn-module-dnc/src/main/java/org/jeecg/modules/dncFlow/adapter/AssignEquipmentFileStreamAdapter.java new file mode 100644 index 0000000..d952b71 --- /dev/null +++ b/lxzn-module-dnc/src/main/java/org/jeecg/modules/dncFlow/adapter/AssignEquipmentFileStreamAdapter.java @@ -0,0 +1,53 @@ +package org.jeecg.modules.dncFlow.adapter; + +import org.jeecg.modules.dncFlow.entity.AssignEquipmentFileStream; +import org.jeecg.modules.dncFlow.service.StreamTarget; + +public class AssignEquipmentFileStreamAdapter implements StreamTarget { + private final AssignEquipmentFileStream file; + + public AssignEquipmentFileStreamAdapter(AssignEquipmentFileStream file) { + this.file = file; + } + + @Override + public void setProductId(String productId) { + file.setProductId(productId); + } + + @Override + public void setComponentId(String componentId) { + file.setComponentId(componentId); + } + + @Override + public void setPartsId(String partsId) { + file.setPartsId(partsId); + } + + @Override + public void setProcessId(String processId) { + file.setProcessId(processId); + } + + @Override + public void setPsvId(String psvId) { + file.setPsvId(psvId); + } + + @Override + public void setStepId(String stepId) { + file.setStepId(stepId); + } + + @Override + public void setDeviceTypeId(String deviceTypeId) { + file.setDeviceTypeId(deviceTypeId); + } + + @Override + public String getAttributionId() { + return file.getAttributionId(); + } + +} diff --git a/lxzn-module-dnc/src/main/java/org/jeecg/modules/dncFlow/constant/DispatchFileEnum.java b/lxzn-module-dnc/src/main/java/org/jeecg/modules/dncFlow/constant/DispatchFileEnum.java new file mode 100644 index 0000000..10a6fc9 --- /dev/null +++ b/lxzn-module-dnc/src/main/java/org/jeecg/modules/dncFlow/constant/DispatchFileEnum.java @@ -0,0 +1,36 @@ +package org.jeecg.modules.dncFlow.constant; + +public enum DispatchFileEnum { + COMPLETE("1", "缂栧埗"), + + VERIFY("2", "鏍″"), + + APPROVE("3", "鎵瑰噯"); + + private String code; + private String name; + + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } + + public String getCode() { + return code; + } + + public void setCode(String code) { + this.code = code; + } + + DispatchFileEnum() { + } + + DispatchFileEnum(String code, String name) { + this.code = code; + this.name = name; + } +} diff --git a/lxzn-module-dnc/src/main/java/org/jeecg/modules/dncFlow/constant/GuideCardBatchEnum.java b/lxzn-module-dnc/src/main/java/org/jeecg/modules/dncFlow/constant/GuideCardBatchEnum.java new file mode 100644 index 0000000..503fc13 --- /dev/null +++ b/lxzn-module-dnc/src/main/java/org/jeecg/modules/dncFlow/constant/GuideCardBatchEnum.java @@ -0,0 +1,41 @@ +package org.jeecg.modules.dncFlow.constant; + +public enum GuideCardBatchEnum { + PREPARE("1", "缂栧埗"), + + VERIFY("2", "鏍″"), + + CONFIRM("3", "鎿嶄綔纭"), + + APPROVE("4", "瀹℃壒"), + + COMPLETE("5", "瀹屾垚"); + + + private String code; + private String name; + + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } + + public String getCode() { + return code; + } + + public void setCode(String code) { + this.code = code; + } + + GuideCardBatchEnum() { + } + + GuideCardBatchEnum(String code, String name) { + this.code = code; + this.name = name; + } +} diff --git a/lxzn-module-dnc/src/main/java/org/jeecg/modules/dncFlow/controller/AssignEquipmentFileStreamController.java b/lxzn-module-dnc/src/main/java/org/jeecg/modules/dncFlow/controller/AssignEquipmentFileStreamController.java new file mode 100644 index 0000000..5b57491 --- /dev/null +++ b/lxzn-module-dnc/src/main/java/org/jeecg/modules/dncFlow/controller/AssignEquipmentFileStreamController.java @@ -0,0 +1,252 @@ +package org.jeecg.modules.dncFlow.controller; + +import java.util.Arrays; +import java.util.List; +import java.util.Map; +import java.util.stream.Collectors; +import java.io.IOException; +import java.io.UnsupportedEncodingException; +import java.net.URLDecoder; +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpServletResponse; +import org.jeecg.common.api.vo.Result; +import org.jeecg.common.system.query.QueryGenerator; +import org.jeecg.common.util.oConvertUtils; +import org.jeecg.modules.dnc.entity.DeviceManagement; +import org.jeecg.modules.dnc.entity.DeviceType; +import org.jeecg.modules.dnc.entity.DocInfo; +import org.jeecg.modules.dnc.entity.DocRelative; +import org.jeecg.modules.dnc.service.IDeviceManagementService; +import org.jeecg.modules.dnc.service.IDeviceTypeService; +import org.jeecg.modules.dnc.service.IDocInfoService; +import org.jeecg.modules.dnc.service.IDocRelativeService; +import org.jeecg.modules.dncFlow.entity.AssignEquipmentFileStream; +import org.jeecg.modules.dncFlow.service.IAssignEquipmentFileStreamService; + +import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; +import com.baomidou.mybatisplus.core.metadata.IPage; +import com.baomidou.mybatisplus.extension.plugins.pagination.Page; +import lombok.extern.slf4j.Slf4j; + +import org.jeecg.modules.dncFlow.vo.AssignEquipmentFileStreamVo; +import org.jeecgframework.poi.excel.ExcelImportUtil; +import org.jeecgframework.poi.excel.def.NormalExcelConstants; +import org.jeecgframework.poi.excel.entity.ExportParams; +import org.jeecgframework.poi.excel.entity.ImportParams; +import org.jeecgframework.poi.excel.view.JeecgEntityExcelView; +import org.jeecg.common.system.base.controller.JeecgController; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.web.bind.annotation.*; +import org.springframework.web.multipart.MultipartFile; +import org.springframework.web.multipart.MultipartHttpServletRequest; +import org.springframework.web.servlet.ModelAndView; +import com.alibaba.fastjson.JSON; +import io.swagger.annotations.Api; +import io.swagger.annotations.ApiOperation; +import org.jeecg.common.aspect.annotation.AutoLog; + + /** + * @Description: DNC-璁惧缁撴瀯鏍戞寚娲句骇鍝佺粨鏋勬爲 + * @Author: jeecg-boot + * @Date: 2025-06-17 + * @Version: V1.0 + */ +@Api(tags="DNC-璁惧缁撴瀯鏍戞寚娲句骇鍝佺粨鏋勬爲") +@RestController +@RequestMapping("/dncFlow/assignEquipmentFileStream") +@Slf4j +public class AssignEquipmentFileStreamController extends JeecgController<AssignEquipmentFileStream, IAssignEquipmentFileStreamService> { + @Autowired + private IAssignEquipmentFileStreamService assignEquipmentFileStreamService; + + @Autowired + private IDeviceTypeService deviceTypeService; + + @Autowired + private IDeviceManagementService deviceManagementService; + + @Autowired + private IDocRelativeService docRelativeService; + + @Autowired + private IDocInfoService docInfoService; + /** + * 鍒嗛〉鍒楄〃鏌ヨ + * + * @param assignEquipmentFileStream + * @param pageNo + * @param pageSize + * @param req + * @return + */ + //@AutoLog(value = "DNC-璁惧缁撴瀯鏍戞寚娲句骇鍝佺粨鏋勬爲-鍒嗛〉鍒楄〃鏌ヨ") + @ApiOperation(value="DNC-璁惧缁撴瀯鏍戞寚娲句骇鍝佺粨鏋勬爲-鍒嗛〉鍒楄〃鏌ヨ", notes="DNC-璁惧缁撴瀯鏍戞寚娲句骇鍝佺粨鏋勬爲-鍒嗛〉鍒楄〃鏌ヨ") + @GetMapping(value = "/list") + public Result<IPage<AssignEquipmentFileStream>> queryPageList(AssignEquipmentFileStream assignEquipmentFileStream, + @RequestParam(name="pageNo", defaultValue="1") Integer pageNo, + @RequestParam(name="pageSize", defaultValue="10") Integer pageSize, + HttpServletRequest req) { + QueryWrapper<AssignEquipmentFileStream> queryWrapper = QueryGenerator.initQueryWrapper(assignEquipmentFileStream, req.getParameterMap()); + Page<AssignEquipmentFileStream> page = new Page<AssignEquipmentFileStream>(pageNo, pageSize); + IPage<AssignEquipmentFileStream> pageList = assignEquipmentFileStreamService.page(page, queryWrapper); + return Result.OK(pageList); + } + + + /** + * 娴佺▼鍚姩,淇濆瓨瀵瑰簲鐨勬暟鎹� + * @param assignEquipmentFileStream + * @return + */ + @AutoLog(value = "DNC-璁惧缁撴瀯鏍戞寚娲句骇鍝佺粨鏋勬爲-娴佺▼鍚姩,淇濆瓨瀵瑰簲鐨勬暟鎹�") + @ApiOperation(value="DNC-璁惧缁撴瀯鏍戞寚娲句骇鍝佺粨鏋勬爲-娴佺▼鍚姩,淇濆瓨瀵瑰簲鐨勬暟鎹�", notes="DNC-璁惧缁撴瀯鏍戞寚娲句骇鍝佺粨鏋勬爲-娴佺▼鍚姩,淇濆瓨瀵瑰簲鐨勬暟鎹�") + @PostMapping(value = "savaFlow") + public Result<?> saveAssignEquipmentFileStream(@RequestBody AssignEquipmentFileStream assignEquipmentFileStream){ + return assignEquipmentFileStreamService.saveAssignEquipmentFileStream(assignEquipmentFileStream); + } + + /** + * 娴佺▼鑺傜偣瀹℃牳 + * @param assignEquipmentFileStreamVo + * @return + */ + @AutoLog(value = "DNC-璁惧缁撴瀯鏍戞寚娲句骇鍝佺粨鏋勬爲-娴佺▼鑺傜偣瀹℃牳") + @ApiOperation(value="DNC-璁惧缁撴瀯鏍戞寚娲句骇鍝佺粨鏋勬爲-娴佺▼鑺傜偣瀹℃牳", notes="DNC-璁惧缁撴瀯鏍戞寚娲句骇鍝佺粨鏋勬爲-娴佺▼鑺傜偣瀹℃牳") + @PostMapping(value = "audit") + public Result<?> auditAssignEquipmentFileStream(@RequestBody AssignEquipmentFileStreamVo assignEquipmentFileStreamVo){ + return assignEquipmentFileStreamService.auditAssignEquipmentFileStream(assignEquipmentFileStreamVo); + } + + /** + * 娣诲姞 + * + * @param assignEquipmentFileStream + * @return + */ + @AutoLog(value = "DNC-璁惧缁撴瀯鏍戞寚娲句骇鍝佺粨鏋勬爲-娣诲姞") + @ApiOperation(value="DNC-璁惧缁撴瀯鏍戞寚娲句骇鍝佺粨鏋勬爲-娣诲姞", notes="DNC-璁惧缁撴瀯鏍戞寚娲句骇鍝佺粨鏋勬爲-娣诲姞") + //@RequiresPermissions("org.jeecg.modules:nc_assign_equipment_file_stream:add") + @PostMapping(value = "/add") + public Result<String> add(@RequestBody AssignEquipmentFileStream assignEquipmentFileStream) { + assignEquipmentFileStreamService.save(assignEquipmentFileStream); + return Result.OK("娣诲姞鎴愬姛锛�"); + } + + /** + * 鏌ヨ瀹$鍩烘湰淇℃伅 + * @param id + * @return + */ + @ApiOperation(value = "鏌ヨ瀹$鍩烘湰淇℃伅", notes = "鏌ヨ瀹$鍩烘湰淇℃伅") + @GetMapping(value = "/selectVoById") + public Result<?> selectVoById(@RequestParam(name="id") String id){ + List<AssignEquipmentFileStream> list = assignEquipmentFileStreamService.list(new QueryWrapper<AssignEquipmentFileStream>().eq("id", id)); + if (!list.isEmpty()){ + list.forEach(item->{ + DeviceType deviceType = deviceTypeService.getById(item.getDeviceTypeId()); + if (deviceType!=null){ + DeviceManagement deviceManagement = deviceManagementService.getById(deviceType.getDeviceManagementId()); + if (deviceManagement!=null){ + item.setDeviceTypeName(deviceManagement.getDeviceManagementName()); + } + } + DocRelative docRelative=docRelativeService.getById(item.getDocId()); + if (docRelative!=null){ + DocInfo docInfo = docInfoService.getById(docRelative.getDocId()); + item.setDocName(docInfo.getDocName()); + } + + }); + return Result.OK(list); + } + return Result.error("鏈壘鍒板搴旀暟鎹�"); + } + + /** + * 缂栬緫 + * + * @param assignEquipmentFileStream + * @return + */ + @AutoLog(value = "DNC-璁惧缁撴瀯鏍戞寚娲句骇鍝佺粨鏋勬爲-缂栬緫") + @ApiOperation(value="DNC-璁惧缁撴瀯鏍戞寚娲句骇鍝佺粨鏋勬爲-缂栬緫", notes="DNC-璁惧缁撴瀯鏍戞寚娲句骇鍝佺粨鏋勬爲-缂栬緫") + //@RequiresPermissions("org.jeecg.modules:nc_assign_equipment_file_stream:edit") + @RequestMapping(value = "/edit", method = {RequestMethod.PUT,RequestMethod.POST}) + public Result<String> edit(@RequestBody AssignEquipmentFileStream assignEquipmentFileStream) { + assignEquipmentFileStreamService.updateById(assignEquipmentFileStream); + return Result.OK("缂栬緫鎴愬姛!"); + } + + /** + * 閫氳繃id鍒犻櫎 + * + * @param id + * @return + */ + @AutoLog(value = "DNC-璁惧缁撴瀯鏍戞寚娲句骇鍝佺粨鏋勬爲-閫氳繃id鍒犻櫎") + @ApiOperation(value="DNC-璁惧缁撴瀯鏍戞寚娲句骇鍝佺粨鏋勬爲-閫氳繃id鍒犻櫎", notes="DNC-璁惧缁撴瀯鏍戞寚娲句骇鍝佺粨鏋勬爲-閫氳繃id鍒犻櫎") + //@RequiresPermissions("org.jeecg.modules:nc_assign_equipment_file_stream:delete") + @DeleteMapping(value = "/delete") + public Result<String> delete(@RequestParam(name="id",required=true) String id) { + assignEquipmentFileStreamService.removeById(id); + return Result.OK("鍒犻櫎鎴愬姛!"); + } + + /** + * 鎵归噺鍒犻櫎 + * + * @param ids + * @return + */ + @AutoLog(value = "DNC-璁惧缁撴瀯鏍戞寚娲句骇鍝佺粨鏋勬爲-鎵归噺鍒犻櫎") + @ApiOperation(value="DNC-璁惧缁撴瀯鏍戞寚娲句骇鍝佺粨鏋勬爲-鎵归噺鍒犻櫎", notes="DNC-璁惧缁撴瀯鏍戞寚娲句骇鍝佺粨鏋勬爲-鎵归噺鍒犻櫎") + //@RequiresPermissions("org.jeecg.modules:nc_assign_equipment_file_stream:deleteBatch") + @DeleteMapping(value = "/deleteBatch") + public Result<String> deleteBatch(@RequestParam(name="ids",required=true) String ids) { + this.assignEquipmentFileStreamService.removeByIds(Arrays.asList(ids.split(","))); + return Result.OK("鎵归噺鍒犻櫎鎴愬姛!"); + } + + /** + * 閫氳繃id鏌ヨ + * + * @param id + * @return + */ + //@AutoLog(value = "DNC-璁惧缁撴瀯鏍戞寚娲句骇鍝佺粨鏋勬爲-閫氳繃id鏌ヨ") + @ApiOperation(value="DNC-璁惧缁撴瀯鏍戞寚娲句骇鍝佺粨鏋勬爲-閫氳繃id鏌ヨ", notes="DNC-璁惧缁撴瀯鏍戞寚娲句骇鍝佺粨鏋勬爲-閫氳繃id鏌ヨ") + @GetMapping(value = "/queryById") + public Result<AssignEquipmentFileStream> queryById(@RequestParam(name="id",required=true) String id) { + AssignEquipmentFileStream assignEquipmentFileStream = assignEquipmentFileStreamService.getById(id); + if(assignEquipmentFileStream==null) { + return Result.error("鏈壘鍒板搴旀暟鎹�"); + } + return Result.OK(assignEquipmentFileStream); + } + + /** + * 瀵煎嚭excel + * + * @param request + * @param assignEquipmentFileStream + */ + //@RequiresPermissions("org.jeecg.modules:nc_assign_equipment_file_stream:exportXls") + @RequestMapping(value = "/exportXls") + public ModelAndView exportXls(HttpServletRequest request, AssignEquipmentFileStream assignEquipmentFileStream) { + return super.exportXls(request, assignEquipmentFileStream, AssignEquipmentFileStream.class, "DNC-璁惧缁撴瀯鏍戞寚娲句骇鍝佺粨鏋勬爲"); + } + + /** + * 閫氳繃excel瀵煎叆鏁版嵁 + * + * @param request + * @param response + * @return + */ + //@RequiresPermissions("nc_assign_equipment_file_stream:importExcel") + @RequestMapping(value = "/importExcel", method = RequestMethod.POST) + public Result<?> importExcel(HttpServletRequest request, HttpServletResponse response) { + return super.importExcel(request, response, AssignEquipmentFileStream.class); + } + +} diff --git a/lxzn-module-dnc/src/main/java/org/jeecg/modules/dncFlow/controller/DispatchFileController.java b/lxzn-module-dnc/src/main/java/org/jeecg/modules/dncFlow/controller/DispatchFileController.java index 35234c4..0afad22 100644 --- a/lxzn-module-dnc/src/main/java/org/jeecg/modules/dncFlow/controller/DispatchFileController.java +++ b/lxzn-module-dnc/src/main/java/org/jeecg/modules/dncFlow/controller/DispatchFileController.java @@ -10,6 +10,10 @@ import org.jeecg.common.aspect.annotation.AutoLog; import org.jeecg.common.system.base.controller.JeecgController; import org.jeecg.common.system.query.QueryGenerator; +import org.jeecg.modules.dnc.entity.DocInfo; +import org.jeecg.modules.dnc.response.CommonCode; +import org.jeecg.modules.dnc.response.ResponseResult; +import org.jeecg.modules.dnc.service.IDocInfoService; import org.jeecg.modules.dncFlow.entity.DispatchFile; import org.jeecg.modules.dncFlow.service.IDispatchFileService; import org.jeecg.modules.dncFlow.vo.DispatchFileFlowTaskVo; @@ -40,6 +44,8 @@ @Autowired private IHisWorkTaskService hisWorkTaskService; + @Autowired + private IDocInfoService docInfoService; /** * 鍒嗛〉鍒楄〃鏌ヨ * @@ -231,5 +237,21 @@ public Result<?> importExcel(HttpServletRequest request, HttpServletResponse response) { return super.importExcel(request, response, DispatchFile.class); } + @AutoLog(value = "鏂囨。琛�-瀹氬瀷娴佺▼鍙戣捣") + @ApiOperation(value = "鏂囨。琛�-瀹氬瀷娴佺▼鍙戣捣", notes = "鏂囨。琛�-瀹氬瀷娴佺▼鍙戣捣") + @PostMapping("/submitProccess") + public ResponseResult submitProccess(@RequestBody DispatchFile dispatchFile) { + dispatchFileService.submitProccess(dispatchFile); + return new ResponseResult(CommonCode.SUCCESS); + } + @AutoLog(value = "鏂囨。琛�-淇℃伅鏌ヨ") + @ApiOperation(value = "鏂囨。琛�-淇℃伅鏌ヨ", notes = "鏂囨。琛�-淇℃伅鏌ヨ") + @GetMapping("/queryDocInfoByFlowDataId") + public Result<DocInfo> queryDocInfoByFlowDataId(@RequestParam("dataId") String dataId) { + DispatchFile dispatchFile = dispatchFileService.getById(dataId); + DocInfo docInfo = docInfoService.getById(dispatchFile.getDocId()); + return Result.OK(docInfo); + } + } diff --git a/lxzn-module-dnc/src/main/java/org/jeecg/modules/dncFlow/entity/AssignEquipmentFileStream.java b/lxzn-module-dnc/src/main/java/org/jeecg/modules/dncFlow/entity/AssignEquipmentFileStream.java new file mode 100644 index 0000000..6fb3a6f --- /dev/null +++ b/lxzn-module-dnc/src/main/java/org/jeecg/modules/dncFlow/entity/AssignEquipmentFileStream.java @@ -0,0 +1,133 @@ +package org.jeecg.modules.dncFlow.entity; + +import java.io.Serializable; +import java.io.UnsupportedEncodingException; +import java.util.Date; +import java.math.BigDecimal; + +import com.baomidou.mybatisplus.annotation.*; +import lombok.Data; +import com.fasterxml.jackson.annotation.JsonFormat; +import org.springframework.format.annotation.DateTimeFormat; +import org.jeecgframework.poi.excel.annotation.Excel; +import org.jeecg.common.aspect.annotation.Dict; +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; +import lombok.EqualsAndHashCode; +import lombok.experimental.Accessors; + +/** + * @Description: + * @Author: jeecg-boot + * @Date: 2025-06-17 + * @Version: V1.0 + */ +@Data +@TableName("nc_assign_equipment_file_stream") +@Accessors(chain = true) +@EqualsAndHashCode(callSuper = false) +@ApiModel(value="nc_assign_equipment_file_stream瀵硅薄", description="DNC-璁惧缁撴瀯鏍戞寚娲句骇鍝佺粨鏋勬爲") +public class AssignEquipmentFileStream implements Serializable { + private static final long serialVersionUID = 1L; + + /**涓婚敭*/ + @TableId(type = IdType.ASSIGN_ID) + @ApiModelProperty(value = "涓婚敭") + private String id; + /**璁惧ID*/ + @Excel(name = "璁惧ID", width = 15) + @ApiModelProperty(value = "璁惧ID") + @Dict(dictTable = "mdc_equipment", dicCode = "id", dicText = "equipment_id") + private String equipmentId; + /**璁惧鏂囨。ID*/ + @Excel(name = "璁惧鏂囨。ID", width = 15) + @ApiModelProperty(value = "璁惧鏂囨。ID") + @Dict(dictTable = "nc_doc_info", dicCode = "doc_id", dicText = "doc_name") + private String equipmentDocId; + /**璁惧鏂囦欢ID*/ + @Excel(name = "璁惧鏂囦欢ID", width = 15) + @ApiModelProperty(value = "璁惧鏂囦欢ID") + private String equipmentFileId; + /**浜у搧ID*/ + @Excel(name = "浜у搧ID", width = 15) + @ApiModelProperty(value = "浜у搧ID") + @Dict(dictTable = "nc_product_info", dicCode = "product_id", dicText = "product_name") + private String productId; + /**閮ㄤ欢ID*/ + @Excel(name = "閮ㄤ欢ID", width = 15) + @ApiModelProperty(value = "閮ㄤ欢ID") + @Dict(dictTable = "nc_component_info", dicCode = "component_id", dicText = "component_name") + private String componentId; + /**闆朵欢ID*/ + @Excel(name = "闆朵欢ID", width = 15) + @ApiModelProperty(value = "闆朵欢ID") + @Dict(dictTable = "nc_parts_info", dicCode = "parts_id", dicText = "parts_name") + private String partsId; + /**宸ヨ壓瑙勭▼鐗堟湰ID*/ + @Excel(name = "宸ヨ壓瑙勭▼鐗堟湰ID", width = 15) + @ApiModelProperty(value = "宸ヨ壓瑙勭▼鐗堟湰ID") + @Dict(dictTable = "nc_process_spec_version", dicCode = "id", dicText = "process_spec_version_name") + private String psvId; + /**宸ュ簭ID*/ + @Excel(name = "宸ュ簭ID", width = 15) + @ApiModelProperty(value = "宸ュ簭ID") + @Dict(dictTable = "nc_process_stream", dicCode = "process_id", dicText = "process_name") + private String processId; + /**宸ユID*/ + @Excel(name = "宸ユID", width = 15) + @ApiModelProperty(value = "宸ユID") + @Dict(dictTable = "nc_work_step", dicCode = "id", dicText = "step_name") + private String stepId; + /**璁惧绫籌D*/ + @Excel(name = "璁惧绫籌D", width = 15) + @ApiModelProperty(value = "璁惧绫籌D") + private String deviceTypeId; + /**浜у搧鏂囨。id*/ + @Excel(name = "浜у搧鏂囨。id", width = 15) + @ApiModelProperty(value = "浜у搧鏂囨。id") + @Dict(dictTable = "nc_doc_info", dicCode = "doc_id", dicText = "doc_name") + private String docId; + /**鎸囨淳鍘熷洜*/ + @Excel(name = "鎸囨淳鍘熷洜", width = 15) + @ApiModelProperty(value = "鎸囨淳鍘熷洜") + private String applyReason; + /**瀹℃牳绫诲瀷*/ + @Excel(name = "瀹℃牳绫诲瀷", width = 15) + @ApiModelProperty(value = "瀹℃牳绫诲瀷") + private String auditType; + /**瀹℃牳鎰忚*/ + @Excel(name = "瀹℃牳鎰忚", width = 15) + @ApiModelProperty(value = "瀹℃牳鎰忚") + private String auditReason; + /**鍒涘缓浜�*/ + @ApiModelProperty(value = "鍒涘缓浜�") + private String createBy; + /**鍒涘缓鏃ユ湡*/ + @JsonFormat(timezone = "GMT+8",pattern = "yyyy-MM-dd HH:mm:ss") + @DateTimeFormat(pattern="yyyy-MM-dd HH:mm:ss") + @ApiModelProperty(value = "鍒涘缓鏃ユ湡") + private Date createTime; + /**鏇存柊浜�*/ + @ApiModelProperty(value = "鏇存柊浜�") + private String updateBy; + /**鏇存柊鏃ユ湡*/ + @JsonFormat(timezone = "GMT+8",pattern = "yyyy-MM-dd HH:mm:ss") + @DateTimeFormat(pattern="yyyy-MM-dd HH:mm:ss") + @ApiModelProperty(value = "鏇存柊鏃ユ湡") + private Date updateTime; + /**鎵�灞為儴闂�*/ + @ApiModelProperty(value = "鎵�灞為儴闂�") + private String sysOrgCode; + + /**璁惧绫诲悕绉�*/ + private transient String deviceTypeName; + + /**浜у搧鏂囦欢鍚嶇О*/ + private transient String docName; + + /**鎵�灞瀒d*/ + private transient String attributionId; + + /**鎵�灞瀟ype*/ + private transient String attributionType; +} diff --git a/lxzn-module-dnc/src/main/java/org/jeecg/modules/dncFlow/mapper/AssignEquipmentFileStreamMapper.java b/lxzn-module-dnc/src/main/java/org/jeecg/modules/dncFlow/mapper/AssignEquipmentFileStreamMapper.java new file mode 100644 index 0000000..09093de --- /dev/null +++ b/lxzn-module-dnc/src/main/java/org/jeecg/modules/dncFlow/mapper/AssignEquipmentFileStreamMapper.java @@ -0,0 +1,17 @@ +package org.jeecg.modules.dncFlow.mapper; + +import java.util.List; + +import org.apache.ibatis.annotations.Param; +import org.jeecg.modules.dncFlow.entity.AssignEquipmentFileStream; +import com.baomidou.mybatisplus.core.mapper.BaseMapper; + +/** + * @Description: DNC-璁惧缁撴瀯鏍戞寚娲句骇鍝佺粨鏋勬爲 + * @Author: jeecg-boot + * @Date: 2025-06-17 + * @Version: V1.0 + */ +public interface AssignEquipmentFileStreamMapper extends BaseMapper<AssignEquipmentFileStream> { + +} diff --git a/lxzn-module-dnc/src/main/java/org/jeecg/modules/dncFlow/mapper/xml/AssignEquipmentFileStreamMapper.xml b/lxzn-module-dnc/src/main/java/org/jeecg/modules/dncFlow/mapper/xml/AssignEquipmentFileStreamMapper.xml new file mode 100644 index 0000000..429b990 --- /dev/null +++ b/lxzn-module-dnc/src/main/java/org/jeecg/modules/dncFlow/mapper/xml/AssignEquipmentFileStreamMapper.xml @@ -0,0 +1,5 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd"> +<mapper namespace="org.jeecg.modules.dncFlow.mapper.AssignEquipmentFileStreamMapper"> + +</mapper> diff --git a/lxzn-module-dnc/src/main/java/org/jeecg/modules/dncFlow/service/IAssignEquipmentFileStreamService.java b/lxzn-module-dnc/src/main/java/org/jeecg/modules/dncFlow/service/IAssignEquipmentFileStreamService.java new file mode 100644 index 0000000..99be2f7 --- /dev/null +++ b/lxzn-module-dnc/src/main/java/org/jeecg/modules/dncFlow/service/IAssignEquipmentFileStreamService.java @@ -0,0 +1,30 @@ +package org.jeecg.modules.dncFlow.service; + +import org.jeecg.common.api.vo.Result; +import org.jeecg.modules.dncFlow.entity.AssignEquipmentFileStream; +import com.baomidou.mybatisplus.extension.service.IService; +import org.jeecg.modules.dncFlow.vo.AssignEquipmentFileStreamVo; + +/** + * @Description: DNC-璁惧缁撴瀯鏍戞寚娲句骇鍝佺粨鏋勬爲 + * @Author: jeecg-boot + * @Date: 2025-06-17 + * @Version: V1.0 + */ +public interface IAssignEquipmentFileStreamService extends IService<AssignEquipmentFileStream> { + + /** + * 娴佺▼鍚姩,淇濆瓨瀵瑰簲鐨勬暟鎹� + * @param assignEquipmentFileStream + * @return + */ + Result<?> saveAssignEquipmentFileStream(AssignEquipmentFileStream assignEquipmentFileStream); + + /** + * 娴佺▼鑺傜偣瀹℃牳 + * @param assignEquipmentFileStreamVo + * @return + */ + Result<?> auditAssignEquipmentFileStream(AssignEquipmentFileStreamVo assignEquipmentFileStreamVo); + +} diff --git a/lxzn-module-dnc/src/main/java/org/jeecg/modules/dncFlow/service/IDispatchFileService.java b/lxzn-module-dnc/src/main/java/org/jeecg/modules/dncFlow/service/IDispatchFileService.java index 7246401..d183c52 100644 --- a/lxzn-module-dnc/src/main/java/org/jeecg/modules/dncFlow/service/IDispatchFileService.java +++ b/lxzn-module-dnc/src/main/java/org/jeecg/modules/dncFlow/service/IDispatchFileService.java @@ -2,6 +2,7 @@ import com.baomidou.mybatisplus.extension.service.IService; import org.jeecg.common.api.vo.Result; +import org.jeecg.modules.dnc.entity.DocInfo; import org.jeecg.modules.dncFlow.entity.DispatchFile; import org.jeecg.modules.dncFlow.vo.DispatchFileFlowTaskVo; @@ -53,5 +54,8 @@ * @param id */ Result<?> queryDispatchFile(String id); - + /** + * 瀹氬瀷娴佺▼ + */ + Result<?> submitProccess(DispatchFile dispatchFile); } diff --git a/lxzn-module-dnc/src/main/java/org/jeecg/modules/dncFlow/service/impl/AssignEquipmentFileStreamServiceImpl.java b/lxzn-module-dnc/src/main/java/org/jeecg/modules/dncFlow/service/impl/AssignEquipmentFileStreamServiceImpl.java new file mode 100644 index 0000000..68972da --- /dev/null +++ b/lxzn-module-dnc/src/main/java/org/jeecg/modules/dncFlow/service/impl/AssignEquipmentFileStreamServiceImpl.java @@ -0,0 +1,316 @@ +package org.jeecg.modules.dncFlow.service.impl; + +import com.alibaba.fastjson.JSON; +import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; +import com.baomidou.mybatisplus.core.toolkit.CollectionUtils; +import org.apache.commons.lang3.StringUtils; +import org.apache.shiro.SecurityUtils; +import org.flowable.engine.TaskService; +import org.flowable.task.api.Task; +import org.jeecg.common.api.vo.Result; +import org.jeecg.common.system.vo.LoginUser; +import org.jeecg.modules.dnc.constant.DncPassLogPassType; +import org.jeecg.modules.dnc.constant.DocAttributionTypeEnum; +import org.jeecg.modules.dnc.dto.TransferPackage; +import org.jeecg.modules.dnc.entity.*; +import org.jeecg.modules.dnc.exception.ExceptionCast; +import org.jeecg.modules.dnc.response.ActivitiCode; +import org.jeecg.modules.dnc.response.CommonCode; +import org.jeecg.modules.dnc.response.DocumentCode; +import org.jeecg.modules.dnc.response.UcenterCode; +import org.jeecg.modules.dnc.service.*; +import org.jeecg.modules.dnc.service.impl.FileFerryService; +import org.jeecg.modules.dnc.utils.ValidateUtil; +import org.jeecg.modules.dnc.utils.date.DateUtil; +import org.jeecg.modules.dnc.utils.file.FileUtilS; +import org.jeecg.modules.dncFlow.constant.GuideCardBatchEnum; +import org.jeecg.modules.dncFlow.entity.AssignEquipmentFileStream; +import org.jeecg.modules.dncFlow.entity.DispatchFile; +import org.jeecg.modules.dncFlow.mapper.AssignEquipmentFileStreamMapper; +import org.jeecg.modules.dncFlow.service.IAssignEquipmentFileStreamService; +import org.jeecg.modules.dncFlow.vo.AssignEquipmentFileStreamVo; +import org.jeecg.modules.flowable.apithird.business.entity.FlowMyBusiness; +import org.jeecg.modules.flowable.apithird.business.service.IFlowMyBusinessService; +import org.jeecg.modules.flowable.apithird.service.FlowCallBackServiceI; +import org.jeecg.modules.flowable.apithird.service.FlowCommonService; +import org.jeecg.modules.flowable.service.IFlowDefinitionService; +import org.jeecg.modules.flowable.service.IFlowTaskService; +import org.jeecg.modules.mdc.entity.MdcEquipment; +import org.jeecg.modules.mdc.service.IMdcEquipmentService; +import org.jeecg.modules.system.service.IMdcProductionService; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.beans.factory.annotation.Value; +import org.springframework.context.annotation.Lazy; +import org.springframework.stereotype.Service; + +import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; +import org.springframework.transaction.NoTransactionException; +import org.springframework.transaction.TransactionStatus; +import org.springframework.transaction.annotation.Transactional; +import org.springframework.transaction.interceptor.TransactionAspectSupport; + +import javax.annotation.Resource; +import java.io.File; +import java.util.*; + +/** + * @Description: DNC-璁惧缁撴瀯鏍戞寚娲句骇鍝佺粨鏋勬爲 + * @Author: jeecg-boot + * @Date: 2025-06-17 + * @Version: V1.0 + */ +@Service("IAssignEquipmentFileStreamService") +public class AssignEquipmentFileStreamServiceImpl extends ServiceImpl<AssignEquipmentFileStreamMapper, AssignEquipmentFileStream> implements IAssignEquipmentFileStreamService , FlowCallBackServiceI { + + @Autowired + private IDocInfoService docInfoService; + @Autowired + private IDocFileService docFileService; + @Autowired + private IMdcEquipmentService mdcEquipmentService; + @Autowired + private IGuideCardBatchService iGuideCardBatchService; + @Resource + private FlowCommonService flowCommonService; + @Resource + private IFlowDefinitionService flowDefinitionService; + @Autowired + private IFlowTaskService flowTaskService; + @Autowired + private TaskService taskService; + @Autowired + private IFlowMyBusinessService flowMyBusinessService; + @Autowired + private IDocRelativeService docRelativeService; + @Autowired + private IDeviceTypeService deviceTypeService; + @Autowired + private PermissionService permissionService; + /** + * 娴佺▼鍚姩,淇濆瓨瀵瑰簲鐨勬暟鎹� + * @param assignEquipmentFileStream + * @return + */ + @Override + public Result<?> saveAssignEquipmentFileStream(AssignEquipmentFileStream assignEquipmentFileStream){ + //鍙傛暟鏍¢獙 + checkParam(assignEquipmentFileStream); + //鑾峰彇璁惧 + MdcEquipment equipment = mdcEquipmentService.getById(assignEquipmentFileStream.getEquipmentId()); + if(equipment==null){ + return Result.error("鏈彂鐜拌璁惧"); + } + //鑾峰彇璁惧鏂囨。淇℃伅 + DocInfo docInfo =docInfoService.getById(assignEquipmentFileStream.getEquipmentDocId()); + if(docInfo==null){ + return Result.error("鏈彂鐜拌璁惧瀵瑰簲鏂囨。"); + } + //鑾峰彇璁惧鏂囦欢淇℃伅 + DocFile docFile =docFileService.getById(assignEquipmentFileStream.getEquipmentFileId()); + if(docFile==null){ + return Result.error("鏈彂鐜拌璁惧瀵瑰簲鏂囦欢"); + } + //鑾峰彇浜у搧鏂囨。淇℃伅 + DocRelative docRelative=docRelativeService.getById(assignEquipmentFileStream.getDocId()); + //鑾峰彇瀵瑰簲璁惧绫� + DeviceType deviceType = deviceTypeService.getById(docRelative.getAttributionId()); + if(deviceType!=null){ + assignEquipmentFileStream.setDeviceTypeId(deviceType.getId()); + assignEquipmentFileStream.setAttributionId(deviceType.getAttributionId()); + assignEquipmentFileStream.setAttributionType(deviceType.getAttributionType().toString()); + PermissionStreamNew permissionStreamNew=permissionService.getPermissionStreams(assignEquipmentFileStream); + if(permissionStreamNew==null){ + return Result.error("鐢ㄦ埛鏃犳潈鎿嶄綔姝や换鍔�"); + } + } + DocInfo productDocInfo =docInfoService.getById(docRelative.getDocId()); + if(productDocInfo==null){ + return Result.error("鏈彂鐜拌浜у搧缁撴瀯鏍戝搴旀枃妗�"); + } + //鑾峰彇浜у搧鏂囨。淇℃伅瀵瑰簲鏈�鏂扮▼搴忓姞宸ョ‘璁よ〃 + List<GuideCardBatch> batches = iGuideCardBatchService.list( + new QueryWrapper<GuideCardBatch>() + .eq("doc_id", productDocInfo.getDocId()) + .eq("flow_status", GuideCardBatchEnum.COMPLETE.getCode()) + .orderByDesc("SUBSTRING(serial_number, LEN(serial_number)-3, 4)")); + if(CollectionUtils.isEmpty(batches)){ + return Result.error("璇ユ枃妗e搴旂殑绋嬪簭鍔犲伐纭琛ㄥ鎵规湭閫氳繃锛屼笉鑳借繘琛屽崌鐗�"); + } + this.save(assignEquipmentFileStream); + System.out.println("璁惧缁撴瀯鏍戞寚娲句骇鍝佺粨鏋勬爲锛�" + assignEquipmentFileStream.getId()); + flowCommonService.initActBusiness("璁惧缁撴瀯鏍戞寚娲句骇鍝佺粨鏋勬爲:"+docInfo.getDocName()+"->"+productDocInfo.getDocName(), + assignEquipmentFileStream.getId(), "IAssignEquipmentFileStreamService", "nc_assign_equipment_file_stream", null); + Map<String, Object> variables = new HashMap<>(); + variables.put("dataId", assignEquipmentFileStream.getId()); + variables.put("organization", assignEquipmentFileStream.getApplyReason()); + variables.put("comment", assignEquipmentFileStream.getApplyReason()); + variables.put("proofreading",true); + Result result= flowDefinitionService.startProcessInstanceByKey("nc_assign_equipment_file_stream", variables); + if (!result.isSuccess()) { + super.removeById(assignEquipmentFileStream.getId()); + } + return result; + } + + /** + * 娴佺▼鑺傜偣瀹℃牳 + * @param assignEquipmentFileStreamVo + * @return + */ + @Transactional(rollbackFor = Exception.class) + @Override + public Result<?> auditAssignEquipmentFileStream(AssignEquipmentFileStreamVo assignEquipmentFileStreamVo){ + LoginUser user = (LoginUser) SecurityUtils.getSubject().getPrincipal(); + try { + // 鍙傛暟鏍¢獙 + if (!ValidateUtil.validateString(assignEquipmentFileStreamVo.getTaskId()) || !ValidateUtil.validateString(assignEquipmentFileStreamVo.getDataId())) { + return Result.error(CommonCode.INVALID_PARAM.toString()); + } + String userId = user.getId(); + assignEquipmentFileStreamVo.setAssignee(user.getUsername()); + if (!ValidateUtil.validateString(userId)) { + return Result.error(UcenterCode.UCENTER_ACCOUNT_NOT_EXIST.toString()); + } + + // 鏁版嵁鏌ヨ + AssignEquipmentFileStream assignEquipmentFileStream = this.getById(assignEquipmentFileStreamVo.getDataId()); + if (assignEquipmentFileStream == null) { + return Result.error(CommonCode.INVALID_PARAM.toString()); + } + //鑾峰彇璁惧 + MdcEquipment equipment = mdcEquipmentService.getById(assignEquipmentFileStream.getEquipmentId()); + if(equipment==null){ + return Result.error("鏈彂鐜拌璁惧"); + } + //鑾峰彇璁惧鏂囨。淇℃伅 + DocInfo docInfo =docInfoService.getById(assignEquipmentFileStream.getEquipmentDocId()); + if(docInfo==null){ + return Result.error("鏈彂鐜拌璁惧瀵瑰簲鏂囨。"); + } + //鑾峰彇璁惧鏂囦欢淇℃伅 + DocFile docFile =docFileService.getById(assignEquipmentFileStream.getEquipmentFileId()); + if(docFile==null){ + return Result.error("鏈彂鐜拌璁惧瀵瑰簲鏂囦欢"); + } + //鑾峰彇浜у搧鏂囨。淇℃伅 + DocRelative docRelative=docRelativeService.getById(assignEquipmentFileStream.getDocId()); + DocInfo productDocInfo =docInfoService.getById(docRelative.getDocId()); + if(productDocInfo==null){ + return Result.error("鏈彂鐜拌浜у搧缁撴瀯鏍戝搴旀枃妗�"); + } + //鑾峰彇璁惧 + MdcEquipment mdcEquipment =mdcEquipmentService.getById(assignEquipmentFileStream.getEquipmentId()); + if (mdcEquipment==null){ + return Result.error("鏈彂鐜拌璁惧"); + } + // 2. 鏌ヨ娴佺▼涓氬姟璁板綍锛堝鐞嗙┖缁撴灉锛� + List<FlowMyBusiness> businessList = flowMyBusinessService.list( + new QueryWrapper<FlowMyBusiness>() + .eq("process_instance_id", assignEquipmentFileStreamVo.getInstanceId()) + ); + if (businessList.isEmpty()) { + return Result.error("娴佺▼璁板綍涓嶅瓨鍦�"); + } + FlowMyBusiness flowMyBusiness = businessList.get(0); + + // 3. 鏍¢獙鐢ㄦ埛鏄惁涓哄�欓�夊鐞嗕汉 + List<String> todoUsers = JSON.parseArray(flowMyBusiness.getTodoUsers(), String.class); + if (todoUsers == null || !todoUsers.contains(user.getUsername())) { + return Result.error("鐢ㄦ埛鏃犳潈鎿嶄綔姝や换鍔�"); + } + + // 4. 璁ら浠诲姟锛堝鐞嗗凡琚棰嗙殑鎯呭喌锛� + String taskId = flowMyBusiness.getTaskId(); + Task task = taskService.createTaskQuery().taskId(taskId).singleResult(); + if (task == null) { + return Result.error("浠诲姟涓嶅瓨鍦ㄦ垨宸插畬鎴�"); + } + if (task.getAssignee() != null && !task.getAssignee().equals(user.getUsername())) { + return Result.error("浠诲姟宸茶浠栦汉璁ら"); + } + taskService.claim(taskId, user.getUsername()); + + // 璁剧疆娴佺▼鍙橀噺 + Map<String, Object> values = new HashMap<>(); + values.put("dataId", assignEquipmentFileStream.getId()); + values.put("assignee", userId); + values.put("comment", assignEquipmentFileStreamVo.getComment()); + values.put("organization", assignEquipmentFileStreamVo.getComment()); + assignEquipmentFileStreamVo.setValues(values); + // 瀹屾垚娴佺▼浠诲姟 + Result result = flowTaskService.complete(assignEquipmentFileStreamVo); + if (result.isSuccess()) { + this.updateById(assignEquipmentFileStream); + if (assignEquipmentFileStreamVo.getAuditType().equals("1")) { + //1.浜у搧缁撴瀯鏍憂c鏂囦欢杩涜鍗囩増 + DocFile productDocFile = new DocFile(); + productDocFile.setDocId(productDocInfo.getDocId()); + productDocFile.setFileName(docFile.getFileName()); + productDocFile.setFileEncodeName(docFile.getFileEncodeName()); + productDocFile.setFilePath(docFile.getFilePath()); + productDocFile.setFileSize(docFile.getFileSize()); + productDocFile.setFileSuffix(docFile.getFileSuffix()); + docFileService.addDocFile(productDocFile); + productDocInfo.setPublishVersion(productDocFile.getDocVersion()); + productDocInfo.setPublishFileId(productDocFile.getFileId()); + docInfoService.updateById(productDocInfo); + } + } else { + return result; + } + return Result.OK("鎿嶄綔鎴愬姛"); + } catch (Exception e) { + try { + TransactionStatus transactionStatus = TransactionAspectSupport.currentTransactionStatus(); + if (!transactionStatus.isCompleted()) { + transactionStatus.setRollbackOnly(); + } + } catch (NoTransactionException ex) { + // 蹇界暐鏃犱簨鍔$殑寮傚父 + } + log.error("瀹℃牳澶辫触", e); + return Result.error("鎿嶄綔澶辫触锛�" + e.getMessage()); + } + } + + + //浼犲弬楠岃瘉 + public boolean checkParam(AssignEquipmentFileStream assignEquipmentFileStream) { + if (assignEquipmentFileStream == null) { + ExceptionCast.cast(CommonCode.INVALID_PARAM); + } + if (!ValidateUtil.validateString(assignEquipmentFileStream.getEquipmentId()) || !ValidateUtil.validateString(assignEquipmentFileStream.getDocId()) + || !ValidateUtil.validateString(assignEquipmentFileStream.getEquipmentFileId()) || !ValidateUtil.validateString(assignEquipmentFileStream.getEquipmentDocId())) { + ExceptionCast.cast(CommonCode.INVALID_PARAM); + } + LoginUser user = (LoginUser) SecurityUtils.getSubject().getPrincipal(); + String userId = user.getId(); + if (!ValidateUtil.validateString(userId)) { + ExceptionCast.cast(UcenterCode.UCENTER_ACCOUNT_NOT_EXIST); + } + return true; + } + + @Override + public void afterFlowHandle(FlowMyBusiness business) { + business.getTaskNameId();//鎺ヤ笅鏉ュ鎵圭殑鑺傜偣 + business.getValues();//鍓嶇浼犺繘鏉ョ殑鍙傛暟 + business.getActStatus(); + } + + @Override + public Object getBusinessDataById(String dataId) { + return this.getById(dataId); + } + + @Override + public Map<String, Object> flowValuesOfTask(String taskNameId, Map<String, Object> values) { + return null; + } + + @Override + public List<String> flowCandidateUsernamesOfTask(String taskNameId, Map<String, Object> values) { + //涓氬姟鏄惁骞查娴佺▼锛屼笟鍔″共棰勶紝娴佺▼骞查锛屾寚瀹氫汉鍛樿繘琛屽鐞� + return null; + } +} diff --git a/lxzn-module-dnc/src/main/java/org/jeecg/modules/dncFlow/service/impl/DispatchFileServiceImpl.java b/lxzn-module-dnc/src/main/java/org/jeecg/modules/dncFlow/service/impl/DispatchFileServiceImpl.java index 0314c77..a771833 100644 --- a/lxzn-module-dnc/src/main/java/org/jeecg/modules/dncFlow/service/impl/DispatchFileServiceImpl.java +++ b/lxzn-module-dnc/src/main/java/org/jeecg/modules/dncFlow/service/impl/DispatchFileServiceImpl.java @@ -13,16 +13,21 @@ import org.flowable.task.api.Task; import org.jeecg.common.api.vo.Result; import org.jeecg.common.system.vo.LoginUser; -import org.jeecg.modules.dnc.entity.DocInfo; -import org.jeecg.modules.dnc.entity.PermissionStreamNew; +import org.jeecg.modules.dnc.constant.DncPassLogPassType; +import org.jeecg.modules.dnc.constant.DocAttributionTypeEnum; +import org.jeecg.modules.dnc.dto.TransferPackage; +import org.jeecg.modules.dnc.entity.*; import org.jeecg.modules.dnc.exception.ExceptionCast; import org.jeecg.modules.dnc.mapper.DocInfoMapper; import org.jeecg.modules.dnc.request.DocInfoQueryRequest; import org.jeecg.modules.dnc.response.ActivitiCode; import org.jeecg.modules.dnc.response.CommonCode; import org.jeecg.modules.dnc.response.UcenterCode; -import org.jeecg.modules.dnc.service.IDocInfoService; +import org.jeecg.modules.dnc.service.*; +import org.jeecg.modules.dnc.service.impl.FileFerryService; import org.jeecg.modules.dnc.utils.ValidateUtil; +import org.jeecg.modules.dnc.utils.date.DateUtil; +import org.jeecg.modules.dnc.utils.file.FileUtilS; import org.jeecg.modules.dncFlow.entity.DispatchFile; import org.jeecg.modules.dncFlow.mapper.DispatchFileMapper; import org.jeecg.modules.dncFlow.service.IDispatchFileService; @@ -35,14 +40,23 @@ import org.jeecg.modules.flowable.service.IFlowDefinitionService; import org.jeecg.modules.flowable.service.IFlowTaskService; import org.jeecg.modules.flowable.service.IHisWorkTaskService; +import org.jeecg.modules.mdc.entity.MdcEquipment; +import org.jeecg.modules.system.service.IMdcProductionService; import org.jeecg.modules.system.service.ISysUserRoleService; import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.beans.factory.annotation.Value; import org.springframework.context.annotation.Lazy; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; import javax.annotation.Resource; +import java.io.File; +import java.io.IOException; import java.lang.reflect.InvocationTargetException; +import java.nio.file.Files; +import java.nio.file.Path; +import java.nio.file.Paths; +import java.nio.file.StandardCopyOption; import java.util.*; /** @@ -68,13 +82,29 @@ @Autowired private IFlowMyBusinessService flowMyBusinessService; @Autowired - private DocInfoMapper docInfoMapper; - @Autowired private ISysUserRoleService sysUserRoleService; @Autowired private PermissionService permissionService; @Autowired private IHisWorkTaskService hisWorkTaskService; + @Autowired + private IDeviceTypeService deviceTypeService; + @Autowired + private IDeviceManagementService deviceManagementService; + @Autowired + private IDncPassLogService dncPassLogService; + @Autowired + private IDocFileService docFileService; + @Autowired + private IDocRelativeService docRelativeService; + @Autowired + @Lazy + private FileFerryService ferryService; + @Value("${deploy.secretFolder}") + private String secretFolder; //宸ユ帶缃戜紶杈搉c鏂囦欢澶� + @Value("${fileHomePath}") + private String fileHomePath; + /** * 娴佺▼鍚姩,淇濆瓨瀵瑰簲鐨勬暟鎹� * @param dispatchFile @@ -374,6 +404,31 @@ List<DocInfo> docInfoList = docInfoService.findList(docInfoQueryRequest); return Result.OK(docInfoList); } + /** + * 鍙戣捣瀹氬瀷娴佺▼ + */ + @Override + public Result<?> submitProccess(DispatchFile dispatchFile) { + checkParam(dispatchFile); + //鑾峰彇鏂囦欢淇℃伅 + DocInfo docInfo = docInfoService.getById(dispatchFile.getDocId()); + PermissionStreamNew permissionStreams = getPermissionStreams(dispatchFile); + if (permissionStreams==null){ + return Result.error("鐢ㄦ埛娌℃湁鏉冮檺"); + } + super.save(dispatchFile); + flowCommonService.initActBusiness(docInfo.getDocName()+"."+docInfo.getDocSuffix()+"鏂囦欢杩涜瀹氬瀷", + dispatchFile.getId(), "IDispatchFileService", "process_rf27duhy", null); + Map<String, Object> variables = new HashMap<>(); + variables.put("dataId", dispatchFile.getId()); + variables.put("organization", "瀵煎叆鏂囨。榛樿鍚姩娴佺▼"); + variables.put("comment", "瀵煎叆鏂囨。榛樿鍚姩娴佺▼"); + variables.put("proofreading",true); + Result result= flowDefinitionService.startProcessInstanceByKey("process_rf27duhy", variables); + if (!result.isSuccess()) + super.removeById(dispatchFile.getId()); + return result; + } private Map<String, Object> setProcessVariables(DispatchFile dispatchFile, String userId, DispatchFileFlowTaskVo dispatchFileFlowTaskVo) { Map<String, Object> values = new HashMap<>(); @@ -396,7 +451,7 @@ return values; } - private void updateStatus(DispatchFile dispatchFile, DocInfo docInfo, DispatchFileFlowTaskVo dispatchFileFlowTaskVo) { + private void updateStatus(DispatchFile dispatchFile, DocInfo docInfo, DispatchFileFlowTaskVo dispatchFileFlowTaskVo) throws IOException { if (StrUtil.isNotBlank(dispatchFileFlowTaskVo.getProofreadStatus())) { switch (dispatchFileFlowTaskVo.getProofreadStatus()) { case "1": @@ -427,9 +482,95 @@ if (dispatchFileFlowTaskVo.getStereotype() != null && dispatchFileFlowTaskVo.getStereotype()) { dispatchFile.setCurrentNode("5"); docInfo.setDocDispatchStatus(5); + //瀹氬瀷閫氳繃 + DeviceType deviceType=deviceTypeService.getById(dispatchFile.getDeviceTypeId()); + DeviceManagement deviceManagement=deviceManagementService.getById(deviceType.getDeviceManagementId()); + DocFile docFile=docFileService.getById(dispatchFile.getFileId()); + DocRelative docRelative=docRelativeService.getOne(new QueryWrapper<DocRelative>().eq("doc_id",docInfo.getDocId()) + .eq("attribution_id",dispatchFile.getAttributionId()).eq("attribution_type",dispatchFile.getAttributionType())); + handleFileProcessing(docFile,deviceManagement,secretFolder); + handleProductTree(docInfo,docRelative,deviceManagement); } } + + //灏佽澶勭悊鏂囦欢 + private void handleFileProcessing(DocFile docFile, DeviceManagement deviceManagement, String secretFolder) throws IOException { + if (!docFile.getFileSuffix().equals("zip") && !docFile.getFileSuffix().equals("rar")) { + DncPassLog passInfoTxt = new DncPassLog(); + Date dateFirst = DateUtil.getNow(); + passInfoTxt.setDayTime(DateUtil.format(dateFirst,DateUtil.STR_YEARMONTHDAY)); + /*鏌ヨ鏈�鍚庝竴鏉¤褰�*/ + //浼戠湢 500姣 + DncPassLog dncPassLog = dncPassLogService.findDayTime(DateUtil.format(dateFirst,DateUtil.STR_YEARMONTHDAY)); + int fileNc =0; + if (dncPassLog !=null) { + fileNc = dncPassLog.getSequenceNumber() + 1; + } else { + fileNc = 1; + } + //澶勭悊鏂囦欢鍚嶇О 鏂囦欢璺緞 + String sequenceNc = String.format("%06d",fileNc); + DncPassLog passInfoNc = new DncPassLog(); + passInfoNc.setSequenceNumber(fileNc); + passInfoNc.setSequenceOrder(sequenceNc); + passInfoNc.setDayTime(DateUtil.format(dateFirst,DateUtil.STR_YEARMONTHDAY)); + passInfoNc.setPassType(DncPassLogPassType.NCFILE.getCode()); + passInfoNc.setPassName(docFile.getFileName()); + try { + Thread.sleep(1000); + Date date = new Date(); + passInfoNc.setCreateTime(date); + System.out.println(DateUtil.format(date,DateUtil.STR_DATE_TIME)); + } catch (InterruptedException e) { + e.printStackTrace(); + } + dncPassLogService.save(passInfoNc); + // 4. 鎵ц鏂囦欢鎿嶄綔,鍚庣紑涓篘C + Path source = Paths.get(fileHomePath+docFile.getFilePath(), docFile.getFileEncodeName()); + String destFileName = "10A" + DateUtil.format(dateFirst,DateUtil.STR_YEARMONTHDAY)+sequenceNc + "_" + deviceManagement.getDeviceManagementCode()+".NC"; + Path destination = Paths.get(secretFolder, destFileName); + Files.copy(source, destination, StandardCopyOption.REPLACE_EXISTING); + } + } + + /** + * 澶勭悊瀵瑰簲浜у搧缁撴瀯鏍戙�乶c鏂囦欢銆佸垁鍏峰垪琛ㄣ�佺▼搴忓姞宸ョ‘璁よ〃灏佽 + * @param docInfo + */ + private void handleProductTree(DocInfo docInfo, DocRelative docRelative, DeviceManagement deviceManagement) { + /*鏌ヨ鏈�鍚庝竴鏉¤褰�*/ + //浼戠湢 500姣 + DncPassLog passInfoTxt = new DncPassLog(); + Date dateFirst = DateUtil.getNow(); + passInfoTxt.setDayTime(DateUtil.format(dateFirst,DateUtil.STR_YEARMONTHDAY)); + DncPassLog dncPassLog = dncPassLogService.findDayTime(DateUtil.format(dateFirst,DateUtil.STR_YEARMONTHDAY)); + int fileTxt = 0, fileNc =0; + if (dncPassLog !=null) { + fileTxt = dncPassLog.getSequenceNumber() + 1; + } else { + fileTxt = 1; + } + String sequence = String.format("%06d",fileTxt); + passInfoTxt.setSequenceNumber(fileTxt); + passInfoTxt.setCreateTime(dateFirst); + passInfoTxt.setSequenceOrder(sequence); + System.out.println(DateUtil.format(dateFirst,DateUtil.STR_DATE_TIME)); + passInfoTxt.setPassType(DncPassLogPassType.PRODUCTSTRUCTURE.getCode()); + dncPassLogService.save(passInfoTxt); + String fileName="10A"+DateUtil.format(dateFirst,DateUtil.STR_YEARMONTHDAY); + if (Objects.equals(docInfo.getAttributionType(), DocAttributionTypeEnum.PROCESS.getCode())){ + //宸ュ簭瀵瑰簲璁惧绫� + String filePath = ferryService.exportData(TransferPackage.DataType.PROCESS, docRelative.getId(),fileName+sequence+"_"+deviceManagement.getDeviceManagementCode()+".ferry"); + System.out.println("宸ュ簭鏁版嵁宸插鍑�: " + filePath); + }else { + //宸ユ瀵瑰簲璁惧绫� + String filePath = ferryService.exportData(TransferPackage.DataType.WORKSTEP, docRelative.getId(),fileName+sequence+"_"+deviceManagement.getDeviceManagementCode()+".ferry"); + System.out.println("宸ユ鏁版嵁宸插鍑�: " + filePath); + } + } + + //浼犲弬楠岃瘉 public boolean checkParam(DispatchFile dispatchFile) { if (dispatchFile == null) { diff --git a/lxzn-module-dnc/src/main/java/org/jeecg/modules/dncFlow/service/impl/PermissionService.java b/lxzn-module-dnc/src/main/java/org/jeecg/modules/dncFlow/service/impl/PermissionService.java index 1f4ef4d..368f645 100644 --- a/lxzn-module-dnc/src/main/java/org/jeecg/modules/dncFlow/service/impl/PermissionService.java +++ b/lxzn-module-dnc/src/main/java/org/jeecg/modules/dncFlow/service/impl/PermissionService.java @@ -7,8 +7,10 @@ import org.jeecg.modules.dnc.exception.ExceptionCast; import org.jeecg.modules.dnc.response.ActivitiCode; import org.jeecg.modules.dnc.service.IDeviceTypeService; +import org.jeecg.modules.dncFlow.adapter.AssignEquipmentFileStreamAdapter; import org.jeecg.modules.dncFlow.adapter.AssignFileStreamAdapter; import org.jeecg.modules.dncFlow.adapter.DispatchFileAdapter; +import org.jeecg.modules.dncFlow.entity.AssignEquipmentFileStream; import org.jeecg.modules.dncFlow.entity.AssignFileStream; import org.jeecg.modules.dncFlow.entity.DispatchFile; import org.jeecg.modules.dncFlow.handler.*; @@ -51,6 +53,10 @@ return processInternal(new AssignFileStreamAdapter(stream), stream.getAttributionType()); } + public PermissionStreamNew getPermissionStreams(AssignEquipmentFileStream stream) { + return processInternal(new AssignEquipmentFileStreamAdapter(stream), stream.getAttributionType()); + } + private PermissionStreamNew processInternal(StreamTarget target, String attributionType) { LoginUser user = getCurrentUser(); String resolvedId = resolveAttributionId(target.getAttributionId()); diff --git a/lxzn-module-dnc/src/main/java/org/jeecg/modules/dncFlow/vo/AssignEquipmentFileStreamVo.java b/lxzn-module-dnc/src/main/java/org/jeecg/modules/dncFlow/vo/AssignEquipmentFileStreamVo.java new file mode 100644 index 0000000..c9a9ef9 --- /dev/null +++ b/lxzn-module-dnc/src/main/java/org/jeecg/modules/dncFlow/vo/AssignEquipmentFileStreamVo.java @@ -0,0 +1,28 @@ +package org.jeecg.modules.dncFlow.vo; + +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; +import org.jeecg.modules.flowable.domain.vo.FlowTaskVo; +import org.jeecgframework.poi.excel.annotation.Excel; + +/** + * @Description: DNC-璁惧缁撴瀯鏍戞寚娲句骇鍝佺粨鏋勬爲 + * @Author: jeecg-boot + * @Date: 2025-06-17 + * @Version: V1.0 + */ +@Data +@ApiModel(value="璁惧缁撴瀯鏍戞寚娲句骇鍝佺粨鏋勬爲--璇锋眰鍙傛暟") +public class AssignEquipmentFileStreamVo extends FlowTaskVo { + /** + * taskIds + */ + private String taskIds; + + /**瀹℃牳绫诲瀷*/ + @Excel(name = "瀹℃牳绫诲瀷", width = 15) + @ApiModelProperty(value = "瀹℃牳绫诲瀷") + private String auditType; + +} diff --git a/lxzn-module-dnc/src/main/java/org/jeecg/modules/dncFlow/vo/GuideCardBatchFlowTaskVo.java b/lxzn-module-dnc/src/main/java/org/jeecg/modules/dncFlow/vo/GuideCardBatchFlowTaskVo.java new file mode 100644 index 0000000..2c5a2b4 --- /dev/null +++ b/lxzn-module-dnc/src/main/java/org/jeecg/modules/dncFlow/vo/GuideCardBatchFlowTaskVo.java @@ -0,0 +1,38 @@ +package org.jeecg.modules.dncFlow.vo; + +import io.swagger.annotations.ApiModel; +import lombok.Data; +import org.jeecg.modules.flowable.domain.vo.FlowTaskVo; + +@Data +@ApiModel("绋嬪簭鍔犲伐纭琛ㄥ伐浣滄祦浠诲姟鐩稿叧--璇锋眰鍙傛暟") +public class GuideCardBatchFlowTaskVo extends FlowTaskVo { + /** + * taskIds + */ + private String taskIds; + + /** + * 鏍″绫诲瀷 + * true:鏍″閫氳繃 + * false:鏍″涓嶉�氳繃 + */ + private Boolean checkType; + + /** + * 纭绫诲瀷 + * true:纭閫氳繃 + * false:纭涓嶉�氳繃 + */ + private Boolean confirmType; + + /** + * 瀹℃壒绫诲瀷 + * true:瀹℃壒閫氳繃 + * false:瀹℃壒涓嶉�氳繃 + */ + private Boolean approveType; + + /**棣栨鎰忚*/ + private String inspectionOpinion; +} diff --git a/lxzn-module-mdc/src/main/java/org/jeecg/modules/mdc/job/ExportToXmlJob.java b/lxzn-module-mdc/src/main/java/org/jeecg/modules/mdc/job/ExportToXmlJob.java new file mode 100644 index 0000000..544d4f1 --- /dev/null +++ b/lxzn-module-mdc/src/main/java/org/jeecg/modules/mdc/job/ExportToXmlJob.java @@ -0,0 +1,63 @@ +package org.jeecg.modules.mdc.job; + +import lombok.extern.slf4j.Slf4j; +import org.jeecg.common.util.DateUtils; +import org.jeecg.modules.mdc.service.ILogTableService; +import org.jeecg.modules.mdc.util.ThrowableUtil; +import org.jeecg.modules.quartz.entity.QuartzJob; +import org.jeecg.modules.quartz.entity.SysQuartzLog; +import org.jeecg.modules.quartz.service.IQuartzJobService; +import org.jeecg.modules.quartz.service.ISysQuartzLogService; +import org.jeecg.modules.system.service.ISysAnnouncementService; +import org.quartz.*; + +import javax.annotation.Resource; +import java.util.Date; +import java.util.List; + +/** + * 瀵煎嚭sql璁板綍鍒皒ml鏂囦欢浠诲姟 + * @author Lius + * @date 2024/12/18 14:53 + */ +@PersistJobDataAfterExecution +@DisallowConcurrentExecution +@Slf4j +public class ExportToXmlJob implements Job { + + @Resource + private ISysQuartzLogService sysQuartzLogService; + + @Resource + private IQuartzJobService quartzJobService; + + @Resource + private ISysAnnouncementService sysAnnouncementService; + + @Resource + private ILogTableService logTableService; + + @Override + public void execute(JobExecutionContext context) throws JobExecutionException { + SysQuartzLog quartzLog = new SysQuartzLog(); + quartzLog.setCreateTime(new Date()); + List<QuartzJob> byJobClassName = this.quartzJobService.findByJobClassName(this.getClass().getName()); + if (byJobClassName != null && !byJobClassName.isEmpty()) { + quartzLog.setJobId(byJobClassName.get(0).getId()); + } + log.info("瀹氭椂瀵煎嚭鍚屾鏁版嵁琛╯ql浠诲姟 ExportToXmlJob start! 鏃堕棿:" + DateUtils.now()); + long startTime = System.currentTimeMillis(); + try { + logTableService.exportDataToXml(); + quartzLog.setIsSuccess(0); + } catch (Exception e) { + quartzLog.setIsSuccess(-1); + quartzLog.setExceptionDetail(ThrowableUtil.getStackTrace(e)); + // 鍙戦�佹秷鎭�氱煡 + sysAnnouncementService.jobSendMessage("瀹氭椂瀵煎嚭鍚屾鏁版嵁琛╯ql浠诲姟", quartzLog.getExceptionDetail()); + } + long endTime = System.currentTimeMillis(); + quartzLog.setExecutionTime(Integer.parseInt(String.valueOf(endTime - startTime))); + sysQuartzLogService.save(quartzLog); + } +} diff --git a/lxzn-module-mdc/src/main/java/org/jeecg/modules/mdc/service/ILogTableService.java b/lxzn-module-mdc/src/main/java/org/jeecg/modules/mdc/service/ILogTableService.java index 9e9f887..51eec72 100644 --- a/lxzn-module-mdc/src/main/java/org/jeecg/modules/mdc/service/ILogTableService.java +++ b/lxzn-module-mdc/src/main/java/org/jeecg/modules/mdc/service/ILogTableService.java @@ -10,8 +10,8 @@ public interface ILogTableService extends IService<LogTable> { /** - * 瀵煎叆鍚屾鏁版嵁sql鎵ц鍒版暟鎹簱 + * 瀵煎嚭鍚屾鏁版嵁琛╯ql鍒皒ml鏂囦欢涓婁紶鍒扮綉闂告湇鍔″櫒 */ - void importXmlToData(); + void exportDataToXml(); } diff --git a/lxzn-module-mdc/src/main/java/org/jeecg/modules/mdc/service/IMdcPassLogService.java b/lxzn-module-mdc/src/main/java/org/jeecg/modules/mdc/service/IMdcPassLogService.java new file mode 100644 index 0000000..508b386 --- /dev/null +++ b/lxzn-module-mdc/src/main/java/org/jeecg/modules/mdc/service/IMdcPassLogService.java @@ -0,0 +1,19 @@ +package org.jeecg.modules.mdc.service; + +import com.baomidou.mybatisplus.extension.service.IService; +import org.jeecg.modules.system.entity.MdcPassLog; + +/** + * @author Lius + * @date 2024/12/23 15:00 + */ +public interface IMdcPassLogService extends IService<MdcPassLog> { + + /** + * 鏌ヨ浠婃棩鏈�鏂颁竴鏉′紶杈撴棩蹇� + * + * @param date + * @return + */ + MdcPassLog selectTodayLast(String date); +} diff --git a/lxzn-module-mdc/src/main/java/org/jeecg/modules/mdc/service/impl/LogTableServiceImpl.java b/lxzn-module-mdc/src/main/java/org/jeecg/modules/mdc/service/impl/LogTableServiceImpl.java index 8f5d25e..b3cd919 100644 --- a/lxzn-module-mdc/src/main/java/org/jeecg/modules/mdc/service/impl/LogTableServiceImpl.java +++ b/lxzn-module-mdc/src/main/java/org/jeecg/modules/mdc/service/impl/LogTableServiceImpl.java @@ -1,22 +1,25 @@ package org.jeecg.modules.mdc.service.impl; import cn.hutool.core.io.FileUtil; -import cn.hutool.core.io.file.FileReader; +import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; import lombok.extern.slf4j.Slf4j; import org.jeecg.common.exception.JeecgBootException; import org.jeecg.modules.mdc.entity.LogTable; import org.jeecg.modules.mdc.mapper.LogTableMapper; import org.jeecg.modules.mdc.service.ILogTableService; -import org.jeecg.modules.mdc.util.SqlExecutor; +import org.jeecg.modules.mdc.util.DateUtils; +import org.jeecg.modules.system.entity.MdcPassLog; +import org.jeecg.modules.system.service.IMdcPassLogService; +import org.jeecg.modules.system.util.FileUtils; import org.springframework.beans.factory.annotation.Value; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; import javax.annotation.Resource; import java.io.File; -import java.util.ArrayList; import java.util.List; +import java.util.stream.Collectors; /** * @author Lius @@ -29,52 +32,65 @@ @Value("${fileService.localFilePath}") private String localFilePath; - @Value("${fileService.newFilePath}") - private String newFilePath; - - @Value("${fileService.failedLocFilePath}") - private String failedLocFilePath; - @Resource - private SqlExecutor sqlExecutor; + private IMdcPassLogService mdcPassLogService; + + private static final String TYPE = "18"; /** - * 瀵煎叆鍚屾鏁版嵁sql鎵ц鍒版暟鎹簱 + * 瀵煎嚭鍚屾鏁版嵁琛╯ql鍒皒ml鏂囦欢 */ @Override @Transactional(rollbackFor = Exception.class) - public void importXmlToData() { - File[] files = FileUtil.ls(localFilePath); - List<String> failedSqlList = new ArrayList<>(); // 鐢ㄤ簬瀛樺偍鎵ц澶辫触鐨� SQL - for (File file : files) { - if (file.isFile()) { - String loFilePath = localFilePath + file.getName(); - FileReader fileReader = new FileReader(loFilePath); - List<String> sqlList = fileReader.readLines(); - log.info("鎴愬姛璇诲彇鍒皗}鏉ql,鎵ц鎿嶄綔", sqlList.size()); - for (String sql : sqlList) { - try { - sqlExecutor.execute(sql); - } catch (Exception e) { - failedSqlList.add(sql); - } - } - if (!failedSqlList.isEmpty()) { - try { - FileUtil.appendLines(failedSqlList, failedLocFilePath, "UTF-8"); - } catch (Exception e) { - throw new JeecgBootException("鏁版嵁鍐欏叆鏂囦欢澶辫触锛�"); - } - } + public void exportDataToXml() { + // step.1 鏌ヨ鏈�鏂版暟鎹� 鏃堕棿姝e簭鎺掑垪 + List<LogTable> logTables = this.baseMapper.selectList(new LambdaQueryWrapper<LogTable>().orderByAsc(LogTable::getCreateTime)); + if (logTables != null && !logTables.isEmpty()) { - if (Integer.parseInt(file.getName().substring(file.getName().length() - 10, file.getName().length() - 4)) == 1) { - // 鍒犻櫎鍘嗗彶鏂囦欢 - FileUtil.clean(newFilePath); - } + // step.2 澶勭悊鏁版嵁 + List<String> sqlList = logTables.stream().map(LogTable::getSqlLog).collect(Collectors.toList()); - // 澶囦唤 - FileUtil.move(new File(loFilePath), new File(newFilePath + file.getName()), true); + // step.3 鍐欏叆鏂囦欢 + // step.3.1 鏂囦欢鍛藉悕 + String today = DateUtils.format(DateUtils.getNow(), DateUtils.STRDATE); + MdcPassLog mdcPassLogLast = mdcPassLogService.selectTodayLast(today); + int sequenceNumber = 1; + if (mdcPassLogLast != null) { + sequenceNumber = mdcPassLogLast.getSequenceNumber() + 1; } + + // 鏂囦欢璺緞 + String locFilePath = localFilePath + TYPE + today + String.format("%06d", sequenceNumber) + ".xml"; + String listSql = String.join("\n", sqlList); + try { + FileUtils.fileWriterSql(locFilePath, listSql); + } catch (Exception e) { + throw new JeecgBootException("鏁版嵁鍐欏叆鏂囦欢澶辫触锛�"); + } + + File[] files = FileUtil.ls(localFilePath); + for (File file : files) { + if (file.isFile()) { + //椤哄簭鍙� + String fileName = file.getName(); + String sequenceOrder = fileName.substring(fileName.length() - 10, fileName.length() - 4); + String dayTime = fileName.substring(fileName.length() - 18, fileName.length() - 10); + int sequenceNum = Integer.parseInt(sequenceOrder); + // 鎻掑叆浼犺緭鏃ュ織 + MdcPassLog mdcPassLog = new MdcPassLog(); + mdcPassLog.setPassLogFileName(file.getAbsolutePath()); + mdcPassLog.setPassName(fileName); + mdcPassLog.setDayTime(dayTime); + mdcPassLog.setSequenceNumber(sequenceNum); + mdcPassLog.setSequenceOrder(sequenceOrder); + mdcPassLogService.save(mdcPassLog); + } + } + // step.5 鍒犻櫎宸茬粡鍐欏叆鏂囦欢骞跺彂閫佽嚦缃戦椄鐨勬暟鎹� + // step.5.1 鍒犻櫎鏁版嵁搴撴暟鎹� + this.baseMapper.delete(new LambdaQueryWrapper<LogTable>().le(LogTable::getCreateTime, logTables.get(logTables.size() - 1).getCreateTime())); + } } + } diff --git a/lxzn-module-system/lxzn-system-biz/src/main/java/org/jeecg/modules/system/entity/MdcPassLog.java b/lxzn-module-system/lxzn-system-biz/src/main/java/org/jeecg/modules/system/entity/MdcPassLog.java new file mode 100644 index 0000000..f97cb96 --- /dev/null +++ b/lxzn-module-system/lxzn-system-biz/src/main/java/org/jeecg/modules/system/entity/MdcPassLog.java @@ -0,0 +1,58 @@ +package org.jeecg.modules.system.entity; + +import com.baomidou.mybatisplus.annotation.IdType; +import com.baomidou.mybatisplus.annotation.TableId; +import com.baomidou.mybatisplus.annotation.TableName; +import io.swagger.annotations.ApiModel; +import lombok.Data; +import lombok.EqualsAndHashCode; +import lombok.experimental.Accessors; + +import java.io.Serializable; +import java.util.Date; + +/** + * @author clown + * * @date 2023/12/12 + */ +@Data +@TableName("mdc_pass_log") +@EqualsAndHashCode(callSuper = false) +@Accessors(chain = true) +@ApiModel(value = "mdc_pass_log瀵硅薄", description = "鍙戦�佹枃浠舵棩蹇楄〃") +public class MdcPassLog implements Serializable { + + private static final long serialVersionUID = -9138730240370211497L; + + @TableId(type = IdType.ASSIGN_ID) + private String id; + /** + * 鍚嶇О + */ + private String passName; + /** + * 搴忓彿 + */ + private String sequenceOrder; + /** + * 鏃堕棿 + */ + private String dayTime; + /** + * 绫诲瀷 + */ + private String passType; + /** + * 鏂囦欢鍚嶇О + */ + private String passLogFileName; + /** + * 椤哄簭鍙� + */ + private Integer sequenceNumber; + /** + * 鍒涘缓鏃堕棿 + */ + private Date createTime; + +} diff --git a/lxzn-module-system/lxzn-system-biz/src/main/java/org/jeecg/modules/system/mapper/MdcPassLogMapper.java b/lxzn-module-system/lxzn-system-biz/src/main/java/org/jeecg/modules/system/mapper/MdcPassLogMapper.java new file mode 100644 index 0000000..579d8c5 --- /dev/null +++ b/lxzn-module-system/lxzn-system-biz/src/main/java/org/jeecg/modules/system/mapper/MdcPassLogMapper.java @@ -0,0 +1,20 @@ +package org.jeecg.modules.system.mapper; + +import com.baomidou.mybatisplus.core.mapper.BaseMapper; +import org.apache.ibatis.annotations.Param; +import org.jeecg.modules.system.entity.MdcPassLog; + +/** + * @author Lius + * @date 2024/12/23 14:59 + */ +public interface MdcPassLogMapper extends BaseMapper<MdcPassLog> { + + /** + * 鏌ヨ浠婃棩鏈�鏂颁竴鏉′紶杈撴棩蹇� + * + * @param date + * @return + */ + MdcPassLog selectTodayLast(@Param("date") String date); +} diff --git a/lxzn-module-system/lxzn-system-biz/src/main/java/org/jeecg/modules/system/mapper/xml/MdcPassLogMapper.xml b/lxzn-module-system/lxzn-system-biz/src/main/java/org/jeecg/modules/system/mapper/xml/MdcPassLogMapper.xml new file mode 100644 index 0000000..7cd9e3a --- /dev/null +++ b/lxzn-module-system/lxzn-system-biz/src/main/java/org/jeecg/modules/system/mapper/xml/MdcPassLogMapper.xml @@ -0,0 +1,8 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd"> +<mapper namespace="org.jeecg.modules.system.mapper.MdcPassLogMapper"> + + <select id="selectTodayLast" resultType="org.jeecg.modules.system.entity.MdcPassLog"> + SELECT TOP 1 * FROM mdc_pass_log WHERE day_time = #{date} ORDER BY create_time DESC + </select> +</mapper> diff --git a/lxzn-module-system/lxzn-system-biz/src/main/java/org/jeecg/modules/system/service/IMdcPassLogService.java b/lxzn-module-system/lxzn-system-biz/src/main/java/org/jeecg/modules/system/service/IMdcPassLogService.java new file mode 100644 index 0000000..e531182 --- /dev/null +++ b/lxzn-module-system/lxzn-system-biz/src/main/java/org/jeecg/modules/system/service/IMdcPassLogService.java @@ -0,0 +1,19 @@ +package org.jeecg.modules.system.service; + +import com.baomidou.mybatisplus.extension.service.IService; +import org.jeecg.modules.system.entity.MdcPassLog; + +/** + * @author Lius + * @date 2024/12/23 15:00 + */ +public interface IMdcPassLogService extends IService<MdcPassLog> { + + /** + * 鏌ヨ浠婃棩鏈�鏂颁竴鏉′紶杈撴棩蹇� + * + * @param date + * @return + */ + MdcPassLog selectTodayLast(String date); +} diff --git a/lxzn-module-system/lxzn-system-biz/src/main/java/org/jeecg/modules/system/service/impl/MdcPassLogServiceImpl.java b/lxzn-module-system/lxzn-system-biz/src/main/java/org/jeecg/modules/system/service/impl/MdcPassLogServiceImpl.java new file mode 100644 index 0000000..eb9fd10 --- /dev/null +++ b/lxzn-module-system/lxzn-system-biz/src/main/java/org/jeecg/modules/system/service/impl/MdcPassLogServiceImpl.java @@ -0,0 +1,26 @@ +package org.jeecg.modules.system.service.impl; + +import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; +import org.jeecg.modules.system.entity.MdcPassLog; +import org.jeecg.modules.system.mapper.MdcPassLogMapper; +import org.jeecg.modules.system.service.IMdcPassLogService; +import org.springframework.stereotype.Service; + +/** + * @author Lius + * @date 2024/12/23 15:00 + */ +@Service +public class MdcPassLogServiceImpl extends ServiceImpl<MdcPassLogMapper, MdcPassLog> implements IMdcPassLogService { + + /** + * 鏌ヨ浠婃棩鏈�鏂颁竴鏉′紶杈撴棩蹇� + * + * @param date + * @return + */ + @Override + public MdcPassLog selectTodayLast(String date) { + return this.baseMapper.selectTodayLast(date); + } +} diff --git a/lxzn-module-system/lxzn-system-biz/src/main/java/org/jeecg/modules/system/util/FileUtils.java b/lxzn-module-system/lxzn-system-biz/src/main/java/org/jeecg/modules/system/util/FileUtils.java new file mode 100644 index 0000000..ba6c022 --- /dev/null +++ b/lxzn-module-system/lxzn-system-biz/src/main/java/org/jeecg/modules/system/util/FileUtils.java @@ -0,0 +1,194 @@ +package org.jeecg.modules.system.util; + +import cn.hutool.core.date.DateUtil; +import org.springframework.web.multipart.MultipartFile; + +import javax.servlet.http.HttpServletRequest; +import java.io.File; +import java.io.FileOutputStream; +import java.io.IOException; +import java.io.OutputStreamWriter; +import java.math.BigDecimal; + +/** + * Created by YangBin on 2017/9/15. + */ +public class FileUtils { + private static final long MAX_FILE_SIZE = 10 * 1024 * 1024; + + /** + * 鑾峰彇鏈嶅姟鍣ㄤ复鏃惰矾寰� + * + * @param request + * @return + */ + public static String serverTempPath(HttpServletRequest request) { + String fsep = System.getProperty("file.separator"); + String path = request.getSession().getServletContext().getRealPath(""); + if (path.lastIndexOf(fsep) == path.length() - 1) { + path += "upload" + fsep + "voucher" + fsep; + } else { + path += fsep + "upload" + fsep + "voucher" + fsep; + } + return path; + } + + public static String serverTempPathIntactReg(HttpServletRequest request) { + String fsep = System.getProperty("file.separator"); + String path = request.getSession().getServletContext().getRealPath(""); + if (path.lastIndexOf(fsep) == path.length() - 1) { + path += "upload" + fsep + "log" + fsep + "error" + fsep; + } else { + path += fsep + "upload" + fsep + "log" + fsep + "error" + fsep; + } + return path; + } + + public static String serverTempPathProcess(HttpServletRequest request) { + String fsep = System.getProperty("file.separator"); + String path = request.getSession().getServletContext().getRealPath(""); + if (path.lastIndexOf(fsep) == path.length() - 1) { + path += "upload" + fsep + "process" + fsep; + } else { + path += fsep + "upload" + fsep + "process" + fsep; + } + return path; + } + + public static String changeFileFormatKb(String flow) { + BigDecimal flows = new BigDecimal(flow); + if (flows.compareTo(new BigDecimal(0)) > 0 && flows.compareTo(new BigDecimal(1024)) < 0) {//灏忎簬1M + return flows.toString() + "B"; + } else if (flows.compareTo(new BigDecimal(1024)) >= 0) { + BigDecimal result = flows.divide(new BigDecimal(1024), 2, BigDecimal.ROUND_HALF_UP); + return result.toString() + "KB"; + } else { + return "0"; + } + } + + + /** + * 寰楀埌椤圭洰鏍圭洰褰曚笅鐨勭粷瀵硅矾寰勶紙纾佺洏鐨勭墿鐞嗚矾寰勶級 + * + * @param request + * @param newPath + * @return + */ + public static String getFilePath(HttpServletRequest request, String newPath) { + String fsep = System.getProperty("file.separator"); + String path = request.getSession().getServletContext().getRealPath("/upload"); + path += fsep + newPath; + return path; + } + + /** + * 寰楀埌椤圭洰鏍圭洰褰曚笅鐨勭浉瀵硅矾寰� 锛堢浉瀵逛簬椤圭洰涓烘牴璺緞锛� + * + * @param newPath + * @return + */ + public static String getRelativePath(String newPath) { + return "/upload/" + newPath; + } + + + /** + * 鏂规硶涓�:浣跨敤 FileWriter 鍐欐枃浠� + * + * @param filepath 鏂囦欢鐩綍 + * @param content 寰呭啓鍏ュ唴瀹� + * @throws IOException + */ + public static void fileWriterSql(String filepath, String content) throws IOException { + OutputStreamWriter outputStreamWriter = null; + try { + File file = new File(filepath); + if (!file.exists()) { + file.createNewFile(); + } + FileOutputStream outputStream = new FileOutputStream(file); + if (outputStream != null) { + outputStreamWriter = new OutputStreamWriter(outputStream, "UTF-8"); + outputStreamWriter.write(content); + outputStreamWriter.flush(); + } + } catch (IOException e) { + e.getMessage(); + } finally { + try { + if (outputStreamWriter != null) { + outputStreamWriter.close(); + } + } catch (IOException e) { + e.printStackTrace(); + } + } + + /* + File file=new File(filepath); + Writer writer = new OutputStreamWriter(new FileOutputStream(file.getAbsoluteFile()), "UTF-8"); + writer.append(content); + */ + } + + /** + * 鏂囦欢澶у皬鏅鸿兘杞崲 + * 浼氬皢鏂囦欢澶у皬杞崲涓烘渶澶ф弧瓒冲崟浣� + * + * @param size锛堟枃浠跺ぇ灏忥紝鍗曚綅涓築锛� + * @return 鏂囦欢澶у皬 + */ + public static String formatFileSize(Long size) { + String sizeName = null; + if (1024 * 1024 > size && size >= 1024) { + sizeName = String.format("%.2f", size.doubleValue() / 1024) + "KB"; + } else if (1024 * 1024 * 1024 > size && size >= 1024 * 1024) { + sizeName = String.format("%.2f", size.doubleValue() / (1024 * 1024)) + "MB"; + } else if (size >= 1024 * 1024 * 1024) { + sizeName = String.format("%.2f", size.doubleValue() / (1024 * 1024 * 1024)) + "GB"; + } else { + sizeName = size.toString() + "B"; + } + return sizeName; + } + + /** + * 涓婁紶鏂囦欢宸ュ叿绫� + * + * @param userPic + * @param path + * @param fileName + * @return + */ + public static boolean uploadFile(MultipartFile userPic, String path, String fileName) { + Long fileSize = userPic.getSize(); + if (fileSize > MAX_FILE_SIZE) { + return false; + } + File targetFile = new File(path, fileName); + if (!targetFile.exists()) { + targetFile.mkdirs(); + } + try { + userPic.transferTo(targetFile); + return true; + } catch (Exception e) { + return false; + } + } + + /** + * 閲嶅懡鍚嶆枃浠跺悕 鍔犲叆鏃堕棿鎴� + * + * @param fileName + * @return + */ + public static String newFileName(String fileName) { + String suffix = fileName.substring(fileName.lastIndexOf('.')); + String dateStr = "_" + DateUtil.now(); + String nameFile = fileName.substring(0, fileName.indexOf(".")); + //鏂版枃浠跺悕 + return nameFile + dateStr + suffix; + } +} diff --git a/lxzn-module-system/lxzn-system-start/src/main/java/org/jeecg/codegenerate/CreateTrigger.java b/lxzn-module-system/lxzn-system-start/src/main/java/org/jeecg/codegenerate/CreateTrigger.java new file mode 100644 index 0000000..a5085dc --- /dev/null +++ b/lxzn-module-system/lxzn-system-start/src/main/java/org/jeecg/codegenerate/CreateTrigger.java @@ -0,0 +1,199 @@ +package org.jeecg.codegenerate; + +import java.io.FileWriter; +import java.io.IOException; +import java.sql.*; +import java.util.ArrayList; +import java.util.List; + +/** + * @Author: Lius + * @CreateTime: 2025-06-23 + * @Description: SQL Server 瑙﹀彂鍣ㄧ敓鎴愬伐鍏� + */ +public class CreateTrigger { + + // 鏁版嵁搴撹繛鎺ヤ俊鎭� + private static final String JDBC_URL = "jdbc:sqlserver://192.168.1.118:1433;databaseName=LXZN_TEST_HANGYU_GK"; + private static final String USERNAME = "sa"; + private static final String PASSWORD = "123"; + + public static void main(String[] args) { + String schemaName = "dbo"; // SQL Server 榛樿鏋舵瀯 + String logTableName = "log_table"; // 鏃ュ織琛ㄥ悕 + + try (Connection connection = DriverManager.getConnection(JDBC_URL, USERNAME, PASSWORD)) { + // 鑾峰彇鎸囧畾鏋舵瀯涓嬬殑鎵�鏈夎〃 + List<String> tables = getTables(connection, schemaName); + + // 鐢熸垚瑙﹀彂鍣� SQL 骞朵繚瀛樺埌鏂囦欢 + generateTriggersForTables(connection, schemaName, logTableName, tables); + + } catch (SQLException | IOException e) { + e.printStackTrace(); + } + } + + /** + * 鑾峰彇鎸囧畾鏋舵瀯涓嬬殑鎵�鏈夎〃 + */ + private static List<String> getTables(Connection connection, String schemaName) throws SQLException { + List<String> tables = new ArrayList<>(); + DatabaseMetaData metaData = connection.getMetaData(); + + try (ResultSet resultSet = metaData.getTables(null, schemaName, null, new String[]{"TABLE"})) { + while (resultSet.next()) { + String tableName = resultSet.getString("TABLE_NAME"); + tables.add(tableName); + } + } + + return tables; + } + + /** + * 鑾峰彇琛ㄧ殑瀛楁鍒楄〃 + */ + private static List<String> getTableColumns(Connection connection, String schemaName, String tableName) throws SQLException { + List<String> columns = new ArrayList<>(); + DatabaseMetaData metaData = connection.getMetaData(); + + try (ResultSet resultSet = metaData.getColumns(null, schemaName, tableName, null)) { + while (resultSet.next()) { + String columnName = resultSet.getString("COLUMN_NAME"); + columns.add(columnName); + } + } + + return columns; + } + + /** + * 鑾峰彇琛ㄧ殑涓婚敭鍒� + */ + private static String getPrimaryKeyColumn(Connection connection, String schemaName, String tableName) throws SQLException { + DatabaseMetaData metaData = connection.getMetaData(); + try (ResultSet resultSet = metaData.getPrimaryKeys(null, schemaName, tableName)) { + if (resultSet.next()) { + return resultSet.getString("COLUMN_NAME"); + } + } + return "id"; // 榛樿浣跨敤id浣滀负涓婚敭锛屽鏋滄病鏈夋壘鍒颁富閿� + } + + /** + * 涓烘墍鏈夎〃鐢熸垚瑙﹀彂鍣� + */ + private static void generateTriggersForTables(Connection connection, String schemaName, String logTableName, List<String> tables) throws SQLException, IOException { + try (FileWriter writer = new FileWriter("triggers.sql")) { + for (String tableName : tables) { + // 鑾峰彇琛ㄧ粨鏋勪俊鎭� + List<String> columns = getTableColumns(connection, schemaName, tableName); + String primaryKey = getPrimaryKeyColumn(connection, schemaName, tableName); + + // 鐢熸垚瑙﹀彂鍣� SQL + String triggerSQL = generateTriggerSQL(schemaName, tableName, logTableName, columns, primaryKey); + + // 灏嗙敓鎴愮殑瑙﹀彂鍣� SQL 鍐欏叆鏂囦欢 + writer.write("-- 瑙﹀彂鍣ㄨ〃: " + tableName + "\n"); + writer.write(triggerSQL); + writer.write("\n\n"); + + // 濡傛灉闇�瑕侊紝鍙互鐩存帴鍦ㄦ暟鎹簱涓垱寤鸿Е鍙戝櫒 + // createTrigger(connection, triggerSQL); + } + System.out.println("鎴愬姛鐢熸垚瑙﹀彂鍣ㄥ苟淇濆瓨鍒癟riggers.sql涓�!"); + } + } + + /** + * 鐢熸垚 SQL Server 瑙﹀彂鍣� SQL + */ + private static String generateTriggerSQL(String schemaName, String tableName, String logTableName, List<String> columns, String primaryKey) { + StringBuilder triggerSQL = new StringBuilder(); + + // 瑙﹀彂鍣ㄥご閮� + triggerSQL.append("CREATE TRIGGER [") + .append(tableName) + .append("_trigger]\n") + .append("ON [") + .append(schemaName) + .append("].[").append(tableName).append("]\n") + .append("AFTER INSERT, UPDATE, DELETE\n") + .append("AS\n") + .append("BEGIN\n") + .append(" SET NOCOUNT ON;\n\n"); + + // 鎻掑叆鎿嶄綔 + triggerSQL.append(" -- 鎻掑叆鎿嶄綔\n") + .append(" IF EXISTS (SELECT * FROM inserted) AND NOT EXISTS (SELECT * FROM deleted)\n") + .append(" BEGIN\n") + .append(" INSERT INTO [").append(logTableName).append("] (action, create_time, sql_log)\n") + .append(" SELECT 'INSERT', GETDATE(), 'INSERT INTO [").append(tableName).append("] ("); + + // 鎷兼帴瀛楁鍚� + for (int i = 0; i < columns.size(); i++) { + triggerSQL.append("[").append(columns.get(i)).append("]"); + if (i < columns.size() - 1) { + triggerSQL.append(", "); + } + } + + triggerSQL.append(") VALUES (''' + "); + + // 鎷兼帴瀛楁鍊� + for (int i = 0; i < columns.size(); i++) { + triggerSQL.append("ISNULL(CAST(i.").append(columns.get(i)).append(" AS NVARCHAR(MAX)), '') + '''"); + if (i < columns.size() - 1) { + triggerSQL.append(", ''' + "); + } + } + + triggerSQL.append(");'\n") + .append(" FROM inserted i;\n") + .append(" END\n\n"); + + // 鏇存柊鎿嶄綔 + triggerSQL.append(" -- 鏇存柊鎿嶄綔\n") + .append(" IF EXISTS (SELECT * FROM inserted) AND EXISTS (SELECT * FROM deleted)\n") + .append(" BEGIN\n") + .append(" INSERT INTO [").append(logTableName).append("] (action, create_time, sql_log)\n") + .append(" SELECT 'UPDATE', GETDATE(), 'UPDATE [").append(tableName).append("] SET "); + + // 鎷兼帴鏇存柊瀛楁 + for (int i = 0; i < columns.size(); i++) { + triggerSQL.append("[").append(columns.get(i)).append("] = ''' + ISNULL(CAST(i.").append(columns.get(i)).append(" AS NVARCHAR(MAX)), '') + '''"); + if (i < columns.size() - 1) { + triggerSQL.append(", "); + } + } + + triggerSQL.append(" WHERE [").append(primaryKey).append("] = ''' + ISNULL(CAST(d.").append(primaryKey).append(" AS NVARCHAR(MAX)), '') + ''';'\n") + .append(" FROM inserted i\n") + .append(" INNER JOIN deleted d ON i.").append(primaryKey).append(" = d.").append(primaryKey).append(";\n") + .append(" END\n\n"); + + // 鍒犻櫎鎿嶄綔 + triggerSQL.append(" -- 鍒犻櫎鎿嶄綔\n") + .append(" IF NOT EXISTS (SELECT * FROM inserted) AND EXISTS (SELECT * FROM deleted)\n") + .append(" BEGIN\n") + .append(" INSERT INTO [").append(logTableName).append("] (action, create_time, sql_log)\n") + .append(" SELECT 'DELETE', GETDATE(), 'DELETE FROM [").append(tableName).append("] WHERE [").append(primaryKey).append("] = ''' + ISNULL(CAST(d.").append(primaryKey).append(" AS NVARCHAR(MAX)), '') + ''';'\n") + .append(" FROM deleted d;\n") + .append(" END\n\n"); + + triggerSQL.append("END;\n"); + + return triggerSQL.toString(); + } + +// /** +// * 鍦ㄦ暟鎹簱涓垱寤鸿Е鍙戝櫒 +// */ +// private static void createTrigger(Connection connection, String triggerSQL) throws SQLException { +// try (Statement statement = connection.createStatement()) { +// statement.execute(triggerSQL); +// System.out.println("Trigger created successfully!"); +// } +// } +} diff --git a/lxzn-module-system/lxzn-system-start/src/main/resources/application-dev.yml b/lxzn-module-system/lxzn-system-start/src/main/resources/application-dev.yml index 127a534..dc52783 100644 --- a/lxzn-module-system/lxzn-system-start/src/main/resources/application-dev.yml +++ b/lxzn-module-system/lxzn-system-start/src/main/resources/application-dev.yml @@ -126,7 +126,7 @@ connectionProperties: druid.stat.mergeSql\=true;druid.stat.slowSqlMillis\=5000 datasource: master: - url: jdbc:sqlserver://192.168.1.118:1433;databasename=LXZN_TEST_HANGYU;nullCatalogMeansCurrent=true + url: jdbc:sqlserver://192.168.1.118:1433;databasename=LXZN_TEST_HANGYU_GK;nullCatalogMeansCurrent=true username: sa password: 123 driverClassName: com.microsoft.sqlserver.jdbc.SQLServerDriver @@ -309,7 +309,9 @@ #staticAccessPath: /api/ffile/** # 褰撳墠椤圭洰鐨勯潤鎬佽祫婧愯闂厤缃湪nginx涓� #宸ユ帶缃�/娑夊瘑缃戦儴缃茬浉鍏抽厤缃�------------閫氳繃鍏夌洏鎽嗘浮 deploy: - #娑夊瘑缃戜紶杈撳伐鎺х綉nc鏂囦欢澶�(鎸囨淳璁惧nc鏂囦欢) + #宸ユ帶缃�/娑夊瘑缃戦儴缃� 0涓烘秹瀵嗙綉 1涓哄伐鎺х綉 + deployType: 0 + #娑夊瘑缃戜紶杈撳伐鎺х綉nc鏂囦欢澶�(鎸囨淳璁惧nc鏂囦欢) 宸ユ帶缃戜紶杈撴秹瀵嗙綉nc鏂囦欢澶�(瑙f瀽鍥炰紶鍚庣殑nc鏂囦欢) secretFolder: D:\\test\\a file: monitor: @@ -319,10 +321,13 @@ - D:\\hy_test\\b - D:\\hy_test\\c interval: 10000 # 鐩戞帶闂撮殧(ms) +ferry: + file: + path: /data/ferry + max-file-size: 10MB + security: - encryption-key: 1234567890abcdef # 鍔犺В瀵嗙閽� + encryption-key: 1234567890abcdef #mdc鏂囦欢璺緞閰嶇疆 fileService: localFilePath: D:/data/sql/ #鏈湴鏂囦欢璺緞 - newFilePath: D:/data/bak/ #澶囦唤鏂囦欢璺緞 - failedLocFilePath: D:/data/failed/failed.sql #澶辫触鏂囦欢璺緞 -- Gitblit v1.9.3