yangys
2025-08-17 9970b367767e5c73f8e0a296615f29770ff4425f
增加dnc入库历史记录
已修改4个文件
49 ■■■■■ 文件已修改
blade-service/blade-mdm/src/main/java/org/springblade/mdm/program/entity/DncBackFile.java 11 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
blade-service/blade-mdm/src/main/java/org/springblade/mdm/program/mapper/DncBackFileMapper.xml 12 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
blade-service/blade-mdm/src/main/java/org/springblade/mdm/program/service/DNCSendBackService.java 24 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
blade-service/blade-mdm/src/main/java/org/springblade/mdm/program/vo/DncBackFileVO.java 2 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
blade-service/blade-mdm/src/main/java/org/springblade/mdm/program/entity/DncBackFile.java
@@ -20,18 +20,9 @@
    /**
     * 程序包名 节点 的id
     */
    private Long approvedId;
    /**
     * 确认时间
     */
    private Date confirmTime;
    private Long ncNodeId;
    /**
     * 对象存储文件名
     */
    private String ossName;
    /**
     * 对象存储文件地址
     */
    private String url;
}
blade-service/blade-mdm/src/main/java/org/springblade/mdm/program/mapper/DncBackFileMapper.xml
@@ -13,11 +13,9 @@
    <!--DNC回传程序处理分页-->
    <select id="pageQuery" resultType="org.springblade.mdm.program.vo.DncBackFileVO">
        select f.id,n.name name,f.create_time,m.code machine_code, m.name machine_name,f.create_time
        select f.id,n.name name,m.code machine_code, m.name machine_name,f.create_time
        from mdm_dnc_back_file f
        left join mdm_nc_program_approved a on f.approved_id=a.id
        join mdm_nc_node n on a.nc_node_id=n.id
        join mdm_nc_node n on f.nc_node_id=n.id
        left join mdm_machine m on n.machine_code=m.code
       <where>
@@ -27,14 +25,14 @@
        </if>
        <if test="query.keyword!=null and query.keyword!=''">
            and (m.code like CONCAT('%', #{query.keyword,jdbcType=VARCHAR},'%') or m.name like CONCAT('%', #{query.keyword,jdbcType=VARCHAR},'%')
            or p.name like CONCAT('%', #{query.keyword,jdbcType=VARCHAR},'%')
            or n.name like CONCAT('%', #{query.keyword,jdbcType=VARCHAR},'%')
                )
        </if>
       <if test="query.createTimeBegin!=null">
           and a.create_time &gt;= #{query.createTimeBegin}
           and f.create_time &gt;= #{query.createTimeBegin}
       </if>
       <if test="query.createTimeEnd!=null">
           and a.create_time &lt;= #{query.createTimeEnd}
           and f.create_time &lt;= #{query.createTimeEnd}
       </if>
      </where>
    </select>
blade-service/blade-mdm/src/main/java/org/springblade/mdm/program/service/DNCSendBackService.java
@@ -20,6 +20,7 @@
import org.springblade.mdm.flow.service.CureFlowService;
import org.springblade.mdm.flow.service.FlowCommonService;
import org.springblade.mdm.flow.service.FlowProgramFileService;
import org.springblade.mdm.program.entity.DncBackFile;
import org.springblade.mdm.program.entity.NcNode;
import org.springblade.mdm.program.entity.NcProgramExchange;
import org.springblade.mdm.program.mapper.NcProgramExchangeMapper;
@@ -56,7 +57,7 @@
    private final OssTemplate ossTemplate;
    private final BladeRedis bladeRedis;
    private final FlowCommonService flowCommonService;
    private final DncBackFileService dncBackFileService;
    private String getFileKey(){
        return "dncimpfile-"+ AuthUtil.getUserId();
    }
@@ -210,6 +211,13 @@
    }
    /**
     * 处理回传文件
     * @param ossFileName
     * @param acceptIdList
     * @return
     * @throws IOException
     */
    private Map<Long, List<FlowProgramFile>> dealWithBackFile(String ossFileName, List<Long> acceptIdList) throws IOException{
        Map<Long, List<FlowProgramFile>> pkgIdFileMap = new HashMap<>();
@@ -248,6 +256,12 @@
                if(active){
                    throw new ServiceException(programPackageName+"正在审批中,请勿重复入库。");
                }
                //验证都过了,保存dncbackFile
                DncBackFile backFile = new DncBackFile();
                backFile.setNcNodeId(packageNode.getId());
                backFile.setOssName(ossFileName);
                dncBackFileService.save(backFile);
                List<FlowProgramFile> flowFiles = new ArrayList<>();
                //查找包下的文件数据,
@@ -291,6 +305,7 @@
     * @param programPackageSubMap 新的 程序包节点id -> =文件列表 map,用于回传数据
     * @throws IOException 访问文件异常
     */
    /*
    List<NcNode> updateNodeDataByDNCBackData(String pkgFileName, List<Long> programPackageIdList,Map<Long,List<NcNode>> programPackageSubMap) throws IOException {
        InputStream inputStream = this.ossTemplate.statFileStream(pkgFileName);
        Path tempZipFile = createTempFile(inputStream);
@@ -391,7 +406,7 @@
        return newProgramPackageNodeList;
    }
    */
    /**
     * 创建一个临时zip文件
     * @param inputStream 文件的输入流
@@ -428,7 +443,10 @@
                    }
                    try (InputStream fileIns = zipFile.getInputStream(zipFile.getEntry(entryName))) {
                        ByteArrayInputStream bos = new ByteArrayInputStream(fileIns.readAllBytes());
                        boolean isText = FileContentUtil.isTextFile(bos);
                        boolean isText = StringUtils.endsWithIgnoreCase(entryName,".txt") || StringUtils.endsWithIgnoreCase(entryName,".nc")|| StringUtils.endsWithIgnoreCase(entryName,".xml");
                        if(!isText) {
                            isText = FileContentUtil.isTextFile(bos);
                        }
                        if (isText) {
                            bos.reset();
                            result = FileContentUtil.getContentFromStream(bos);
blade-service/blade-mdm/src/main/java/org/springblade/mdm/program/vo/DncBackFileVO.java
@@ -20,6 +20,4 @@
    private String machineCode;
    @Schema(description = "程序编号")
    private String code;
    @Schema(description = "文件到达时间")
    private Date arrivedTime;
}