소스 검색

4/6 xiexiang

xiexiang 2 년 전
부모
커밋
395c2b1e9a
2개의 변경된 파일22개의 추가작업 그리고 168개의 파일을 삭제
  1. 22 12
      RMS/src/main/java/cn/cslg/report/service/impl/FollowUpServiceImpl.java
  2. 0 156
      RMS/src/main/resources/mapper/FollowUpMapper.xml

+ 22 - 12
RMS/src/main/java/cn/cslg/report/service/impl/FollowUpServiceImpl.java

@@ -170,19 +170,16 @@ public class FollowUpServiceImpl implements IFollowUpService {
             log.info("登记结果失败,{}", message);
         }
         log.info("登记结果完成");
-        //上传附件 进行关联绑定
-        if (files != null && files.size() != 0) {
-            //将文档上传并返回文件入库的Id
-            List<Integer> fileIds = reportFileService.uploadFiles(files);
-            this.addAsso(register.getFollowUpId(), fileIds);
-        }
+
+        //删除
+
         //简化定义后续事项id
         int followUpId = register.getFollowUpId();
         //根据后续事项id查询关联表找出所有fileId
         List<Integer> fileIdS = followUpMapper.queryFileIdByFollowUpId(followUpId);
         //判断第二次登记结果时候文件数量
-        if(register.getFilesVOs() != null){//传入不为空
-            List<FilesVO> filesVOs= register.getFilesVOs();
+        List<FilesVO> filesVOs= register.getFilesVOs();
+        if(filesVOs != null){//传入不为空
             //遍历前端传入数据,取得fileId的集合ids
             List<Integer> ids = new ArrayList<>();
             for(FilesVO filesVO:filesVOs){
@@ -197,13 +194,25 @@ public class FollowUpServiceImpl implements IFollowUpService {
                     deleteIds.add(fileId);
                 }
             }
-            followUpMapper.deleteAssoId(followUpId,deleteIds);
-            log.info("多余关联附件删除完成");
-        }else{//传入为空数组 等于附件需要全部删除
+            if(deleteIds.size()>0) {
+                followUpMapper.deleteAssoId(followUpId, deleteIds);
+                log.info("多余关联附件删除完成");
+            }
+        }else if(filesVOs != null && filesVOs.size() == 0){//传入为空数组 等于附件需要全部删除
             followUpMapper.deleteAssoId(followUpId,fileIdS);
         }
+        //新增文件
+
+        //上传附件 进行关联绑定
+        if (files != null && files.size() != 0) {
+            //将文档上传并返回文件入库的Id
+            List<Integer> fileIds = reportFileService.uploadFiles(files);
+            this.addAsso(register.getFollowUpId(), fileIds);
+        }
         //批量新增后续事项
-        this.add(register.getFollowUps());
+        if(register.getFollowUps() != null && register.getFollowUps().size()>0) {
+            this.add(register.getFollowUps());
+        }
     }
 
     /**
@@ -220,6 +229,7 @@ public class FollowUpServiceImpl implements IFollowUpService {
             assoFollowUpFile.setFileId(fileId);
             assoFollowUpFile.setFileType(0);
             int rows = followUpMapper.addAssoIds(assoFollowUpFile);
+            System.out.println(rows);
             if(rows != 1){
                 String message = "第" + i + "条失败";
                 log.info("新增后续事项和附件id关联表数据失败,{}", message);

+ 0 - 156
RMS/src/main/resources/mapper/FollowUpMapper.xml

@@ -1,156 +0,0 @@
-<?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="cn.cslg.report.mapper.FollowUpMapper">
-    <!--插入数据-->
-    <!--int add(FollowUp followUp);-->
-    <insert id="add" useGeneratedKeys="true" keyProperty="id">
-        insert into follow_up(report_id, parent_id, follow_up_name, remark, time_limit,
-                              agent, assist_person, finish_time, status, conclusion, create_person_id,
-                              create_person_name)
-        values
-               (#{reportId}, #{parentId}, #{followUpName}, #{remark},
-                #{timeLimit}, #{agent}, #{assistPerson}, #{finishTime}, #{status},
-                #{conclusion}, #{createPersonId}, #{createPersonName})
-    </insert>
-    <!--根据id修改数据-->
-    <!--int update(FollowUp followUp);-->
-    <update id="update">
-        update follow_up
-        <set>
-            <if test="followUpName != null">
-                follow_up_name = #{followUpName},
-            </if>
-            <if test="remark != null">
-                remark = #{remark},
-            </if>
-            <if test="timeLimit != null">
-                time_limit = #{timeLimit},
-            </if>
-            <if test="agent != null">
-                agent = #{agent},
-            </if>
-            <if test="assistPerson != null">
-                assist_person = #{assistPerson},
-            </if>
-            <if test="finishTime != null">
-                finish_time = #{finishTime},
-            </if>
-            <if test="status != null">
-                status = #{status},
-            </if>
-            <if test="conclusion != null">
-                conclusion = #{conclusion},
-            </if>
-        </set>
-        where id = #{id}
-    </update>
-
-    <!--根据报告id查询后续事项-->
-    <!--List<FollowUpVO> query(Integer reportId);-->
-    <resultMap id="queryMap" type="cn.cslg.report.common.model.vo.FollowUpVO">
-        <id column="id" property="id"/>
-        <result column="report_id" property="reportId"/>
-        <result column="parent_id" property="parentId"/>
-        <result column="follow_up_name" property="followUpName"/>
-        <result column="remark" property="remark"/>
-        <result column="time_limit" property="timeLimit"/>
-        <result column="agent" property="agent"/>
-        <result column="assist_person" property="assistPerson"/>
-        <result column="finish_time" property="finishTime"/>
-        <result column="status" property="status"/>
-        <result column="conclusion" property="conclusion"/>
-        <result column="create_person_id" property="createPersonId"/>
-        <result column="create_person_name" property="createPersonName"/>
-        <result column="create_time" property="createTime"/>
-        <collection property="filesVOs" resultMap="FilesVOsResultMap"/>
-    </resultMap>
-    <resultMap id="FilesVOsResultMap" type="cn.cslg.report.common.model.vo.FilesVO">
-        <result column="file_id" property="fileId"/>
-        <result column="name" property="name"/>
-        <result column="address" property="url"/>
-        <result column="ZID" property="zId"/>
-        <result column="FILEREMARK" property="remark"/>
-        <result column="update_time" property="updateTime"/>
-        <result column="UID" property="uId"/>
-        <result column="type" property="type"/>
-        <result column="suffix" property="suffix"/>
-        <result column="file_name" property="fileName"/>
-    </resultMap>
-
-<!--    <select id="query" resultMap="queryMap">-->
-<!--        select id,-->
-<!--               report_id,-->
-<!--               parent_id,-->
-<!--               follow_up_name,-->
-<!--               remark,-->
-<!--               time_limit,-->
-<!--               agent,-->
-<!--               assist_person,-->
-<!--               finish_time,-->
-<!--               status,-->
-<!--               conclusion,-->
-<!--               create_person_id,-->
-<!--               create_person_name,-->
-<!--               create_time-->
-<!--        from follow_up-->
-<!--        where report_id = #{reportId}-->
-<!--    </select>-->
-
-    <select id="query" resultMap="queryMap">
-        select a.id, a.report_id, a.parent_id, a.follow_up_name,a.remark,a.time_limit,a.agent,a.assist_person,a.finish_time,a.status, a.conclusion,
-               a.create_person_id, a.create_person_name, a.create_time, d.FILE_ID, d.NAME, d.ADDRESS, d.ZID,d.FILEREMARK, d.UPDATE_TIME, d.UID,d.TYPE, d.SIZE, d.SUFFIX, d.FILE_NAME
-        from follow_up a left JOIN (SELECT b.follow_up_id, b.FILE_ID, c.ID, c.NAME, c.ADDRESS, c.ZID, c.REMARK AS FILEREMARK, c.UPDATE_TIME, c.UID, c.TYPE, c.SIZE, c.SUFFIX, c.FILE_NAME
-                                    FROM asso_follow_up_file b LEFT JOIN report_file c ON b.FILE_ID = c.ID) d
-                                   ON a.ID = d.FOLLOW_UP_ID
-        WHERE a.report_id = #{reportId} ORDER BY create_time DESC
-    </select>
-
-    <!--根据报告id统计后续事项数量-->
-    <!--int countByReportId();-->
-    <select id="countByReportId" resultType="int">
-        select count(*)
-        from follow_up
-        where report_id = #{reportId}
-    </select>
-
-    <!--根据ids删除数据-->
-    <!--int delete(List<Integer> ids);-->
-    <delete id="delete" parameterType="java.util.List">
-        delete
-        from follow_up
-        where id in
-        <foreach collection="ids" item="id" index="index" open="(" close=")" separator=",">
-            #{id}
-        </foreach>
-    </delete>
-
-    <!--根据后续事项id和文件id删除数据-->
-    <!--int deleteAssoId(Integer followUpId, Integer fileId);-->
-    <delete id="deleteAssoId">
-        delete
-        from asso_follow_up_file
-        where follow_up_id = #{followUpId}
-        and FILE_ID in
-            <foreach collection="fileIds" item="fileId" index="index" open="(" close=")" separator=",">
-                #{fileId}
-            </foreach>
-    </delete>
-
-
-    <!--根据报告id统计后续事项数量-->
-    <!--List<Integer> queryFileIdByFollowUpId(Integer followUpId);-->
-    <select id="queryFileIdByFollowUpId" resultType="Integer">
-        SELECT FILE_ID FROM asso_follow_up_file WHERE FOLLOW_UP_ID = #{followUpId};
-    </select>
-
-
-    <!--插入数据-->
-    <!--int addAssoIds(List<AssoFollowUpFile> assoFollowUpFiles);-->
-    <insert id="addAssoIds" useGeneratedKeys="true" keyProperty="id">
-        insert into asso_follow_up_file(follow_up_id, file_id, file_type)
-        values
-            (#{followUpId}, #{fileId}, #{fileType})
-    </insert>
-
-</mapper>