Parcourir la source

甲供材sql修改,项目信息删除逻辑修改,新增定时任务类,项目信息页面js样式修改

[user3] il y a 3 ans
Parent
commit
2ee175ef0f

+ 4 - 2
src/main/java/com/jeeplus/modules/supply/materialsProvidedByAForReview/mapper/xml/MaterialsProvidedByAForReviewMapper.xml

@@ -106,7 +106,8 @@
         create_date,
         update_by,
         update_date,
-        submittals_id
+        submittals_id,
+        project_name
         )
         values
         <foreach collection="list" item="item" index="index" separator="," >
@@ -120,7 +121,8 @@
             #{item.createDate},
             #{item.updateBy.id},
             #{item.updateDate},
-            #{item.submittalsId}
+            #{item.submittalsId},
+            #{item.projectName}
             )
         </foreach>
     </insert>

+ 15 - 1
src/main/java/com/jeeplus/modules/supply/projectInformation/mapper/ProjectInformationMapper.java

@@ -41,5 +41,19 @@ public interface ProjectInformationMapper extends BaseMapper<ProjectInformation>
      * @param codeList
      * @return
      */
-    Integer deleteAll(@Param("codeList") List<String> codeList);
+    Integer deleteAllByCodList(@Param("codeList") List<String> codeList);
+
+    /**
+     * 查询审定单表中项目定义号的count
+     * @param projectInformation
+     * @return
+     */
+    int getProjectDefinitionNumberCountBySubmissionId(ProjectInformation projectInformation);
+
+    /**
+     * 通过审定单表id关联删除项目信息表+审定单信息表
+     * @param projectInformation
+     * @return
+     */
+    int deleteAllById(ProjectInformation projectInformation);
 }

+ 12 - 2
src/main/java/com/jeeplus/modules/supply/projectInformation/mapper/xml/ProjectInformationMapper.xml

@@ -276,7 +276,7 @@
         </where>
     </select>
 
-    <delete id="deleteAll">
+    <delete id="deleteAllByCodList">
         delete sf,pi from submission_form sf left join project_information pi on pi.project_definition_number = sf.project_definition_number
         <where>
             sf.submission_form_id in
@@ -296,8 +296,18 @@
     </select>
 
     <delete id="delete">
+        delete from submission_form
+        where id = #{id}
+    </delete>
+
+    <select id="getProjectDefinitionNumberCountBySubmissionId" resultType="int">
+        select count(*) from submission_form
+        where project_definition_number = #{projectDefinitionNumber}
+    </select>
+
+    <update id="deleteAllById">
         delete sf,pi from submission_form sf left join project_information pi on pi.project_definition_number = sf.project_definition_number
         where sf.id = #{id}
-    </delete>
+    </update>
 
 </mapper>

+ 15 - 39
src/main/java/com/jeeplus/modules/supply/projectInformation/service/ProjectInformationService.java

@@ -1,7 +1,6 @@
 package com.jeeplus.modules.supply.projectInformation.service;
 
 import com.jeeplus.common.config.Global;
-import com.jeeplus.common.utils.IdGen;
 import com.jeeplus.common.utils.StringUtils;
 import com.jeeplus.core.persistence.Page;
 import com.jeeplus.core.service.CrudService;
@@ -250,15 +249,15 @@ public class ProjectInformationService extends CrudService<ProjectInformationMap
                 for (int i = 0; i < part; i++) {
                     //100条
                     List<String> listPage = projectBasicsList.subList(0, pointsDataLimit);
-                    projectInformationMapper.deleteAll(listPage);
+                    projectInformationMapper.deleteAllByCodList(listPage);
                     //剔除
                     projectBasicsList.subList(0, pointsDataLimit).clear();
                 }
                 if(!projectBasicsList.isEmpty()){
-                    projectInformationMapper.deleteAll(projectBasicsList);
+                    projectInformationMapper.deleteAllByCodList(projectBasicsList);
                 }
             }else{
-                projectInformationMapper.deleteAll(projectBasicsList);
+                projectInformationMapper.deleteAllByCodList(projectBasicsList);
             }
         }
         return null;
@@ -379,42 +378,19 @@ public class ProjectInformationService extends CrudService<ProjectInformationMap
     }
 
     /**
-     * 定时任务删除两天前的数据   待验证
+     * 查询审定单信息表中项目定义号的count
+     * @param projectInformation
+     * @return
      */
-    @Scheduled(cron = "0 0/2 * * * ?")
-    public void deleteFileByCron(){
-        try{
-            System.out.println("开始了!");
-            if(StringUtils.isNotBlank(host) && ("127.0.0.1".equals(host) || "localhost".equals(host))){
-                String path = null;
-                if(System.getProperty("os.name").toLowerCase().contains("win")){
-                    path = Global.getConfig("remoteServer.winDirectory");
-                }else{
-                    path = Global.getConfig("remoteServer.directory");
-                }
-                //删除  路径名
-                File file = new File(path);
-                File[] files = file.listFiles();
-                //获取要删除的时间
-                Calendar date = Calendar.getInstance();
-                date.add(Calendar.DAY_OF_MONTH,-1);
-                String oldOneTime = new SimpleDateFormat("yyyy_MM_dd").format(date.getTime());
-                date.add(Calendar.DAY_OF_MONTH,-1);
-                String oldTwoTime = new SimpleDateFormat("yyyy_MM_dd").format(date.getTime());
-                //遍历获取全部文件名
-                for(File fi:files){
-                    if(fi.isFile()){  //如果是文件  取到名称集合
-                        String fileName = fi.getName();
-                        if(fileName.contains(oldOneTime) || fileName.contains(oldTwoTime)){  //删除前两天的文件
-                            fi.delete();
-                        }
-                    }
-                }
-            }
-            System.out.println("结束了!");
-        }catch (Exception e){
-            e.printStackTrace();
-        }
+    @Transactional(readOnly = false)
+    public int getProjectDefinitionNumberCountBySubmissionId(ProjectInformation projectInformation){
+        int count = projectInformationMapper.getProjectDefinitionNumberCountBySubmissionId(projectInformation);
+        return count;
     }
 
+    //关联删除项目信息表和审定单信息表
+    @Transactional(readOnly = false)
+    public void deleteAllById(ProjectInformation projectInformation){
+        projectInformationMapper.deleteAllById(projectInformation);
+    }
 }

+ 9 - 2
src/main/java/com/jeeplus/modules/supply/projectInformation/web/ProjectInformationController.java

@@ -95,7 +95,15 @@ public class ProjectInformationController extends BaseController {
         AjaxJson j = new AjaxJson();
         String[] idArray = ids.split(",");
         for (String id : idArray) {
-            projectInformationService.delete(projectInformationService.get(id));
+            //根据审定单表的id查找审定单信息表的项目定义号count
+            ProjectInformation projectInformation = projectInformationService.get(id);
+            int count = projectInformationService.getProjectDefinitionNumberCountBySubmissionId(projectInformation);
+            if(count > 1){      //count>1,说明还有其它的审定单id关联着项目表,所以只要删除审定单信息表的信息即可
+                projectInformationService.delete(projectInformation);
+            }else {             //否则则关联删除
+                projectInformationService.deleteAllById(projectInformation);
+            }
+
         }
         j.setMsg("删除成功");
         return j;
@@ -110,7 +118,6 @@ public class ProjectInformationController extends BaseController {
     public AjaxJson importFile(@RequestParam("file") MultipartFile file) {
         AjaxJson j = new AjaxJson();
         try {
-//            projectInformationService.deleteFileByCron();  测试定时任务
             String repeat = "0";  //repeat:0:第一次交互,1:覆盖,2:不覆盖,3:询问
             ImportExcel ei = new ImportExcel(file, 1, 0);
             List<ProjectInformation> list = ei.getDataList(ProjectInformation.class);

+ 74 - 0
src/main/java/com/jeeplus/modules/supply/utils/TaskTime.java

@@ -0,0 +1,74 @@
+package com.jeeplus.modules.supply.utils;
+
+import com.jeeplus.common.config.Global;
+import com.jeeplus.common.utils.StringUtils;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.springframework.context.annotation.Lazy;
+import org.springframework.scheduling.annotation.Scheduled;
+import org.springframework.stereotype.Service;
+
+import java.io.File;
+import java.text.SimpleDateFormat;
+import java.util.*;
+
+/**
+ * 定时任务
+ */
+@Service
+@Lazy(false)
+public class TaskTime {
+
+
+    /** 主机 */
+    private final static String host = Global.getConfig("remoteServer.host");
+
+    public static final Logger logger = LoggerFactory.getLogger(TaskTime.class);
+
+    private static SimpleDateFormat formatter = new SimpleDateFormat("yyyy-MM-dd");
+
+
+    /**
+     * 定时任务删除两天前的数据(物料库/项目信息)   每天凌晨三点执行任务
+     */
+    @Scheduled(cron = "0 0 3 * * ?")
+    public void deleteFileByCron(){
+        try{
+            logger.info("定时删除物料库/项目信息文件任务开始......");
+            long begin = System.currentTimeMillis();
+            String dates = formatter.format(new Date());
+            logger.info("now="+dates);
+
+            if(StringUtils.isNotBlank(host) && ("127.0.0.1".equals(host) || "localhost".equals(host))){
+                String path = null;
+                if(System.getProperty("os.name").toLowerCase().contains("win")){
+                    path = Global.getConfig("remoteServer.winDirectory");
+                }else{
+                    path = Global.getConfig("remoteServer.directory");
+                }
+                //删除  路径名
+                File file = new File(path);
+                File[] files = file.listFiles();
+                //获取要删除的时间
+                Calendar date = Calendar.getInstance();
+                date.add(Calendar.DAY_OF_MONTH,-2);
+                String oldOneTime = new SimpleDateFormat("yyyy_MM_dd").format(date.getTime());
+                date.add(Calendar.DAY_OF_MONTH,-1);
+                String oldTwoTime = new SimpleDateFormat("yyyy_MM_dd").format(date.getTime());
+                //遍历获取全部文件名
+                for(File fi:files){
+                    if(fi.isFile()){  //如果是文件  取到名称集合
+                        String fileName = fi.getName();
+                        if(fileName.contains(oldOneTime) || fileName.contains(oldTwoTime)){  //删除前两天的文件 例子:3.4 删除3.1/3.2
+                            fi.delete();
+                        }
+                    }
+                }
+            }
+            long end = System.currentTimeMillis();
+            logger.info("定时删除物料库/项目信息文件任务结束,共耗时:[" + (end-begin) / 1000 + "]秒");
+        } catch (Exception e) {
+            logger.error("-------------定时删除两天前物料库/项目信息文件发生异常-------------");
+        }
+    }
+}

+ 6 - 6
src/main/webapp/webpage/modules/supply/projectInformation/supplyProjectInformationList.js

@@ -107,6 +107,12 @@
                     sortName: 'submissionFormId'
                 }
                 ,{
+                    field: 'submissionStatus',
+                    title: '送审状态',
+                    width:150,
+                    sortName: 'submissionStatus'
+                }
+                ,{
                     field: 'voltageLeve',
                     title: '电压等级',
                     width:150,
@@ -292,12 +298,6 @@
                     width:150,
                     sortName: 'primaryUnit'
                 }
-                ,{
-                    field: 'submissionStatus',
-                    title: '送审状态',
-                    width:150,
-                    sortName: 'submissionStatus'
-                }