Browse Source

添加成果信息导入

master
yangzj 3 years ago
parent
commit
8495134be0
  1. 2
      Rk-progect/ruoyi-common/src/main/java/com/ruoyi/common/utils/file/MimeTypeUtils.java
  2. 3
      Rk-progect/ruoyi-project/src/main/java/com/ruoyi/project/mapper/PaProjectInfoMapper.java
  3. 111
      Rk-progect/ruoyi-project/src/main/java/com/ruoyi/project/service/impl/export/AchievementsExport.java
  4. 10
      Rk-progect/ruoyi-project/src/main/java/com/ruoyi/project/service/impl/export/ComplementReportExport.java
  5. 10
      Rk-progect/ruoyi-project/src/main/resources/mapper/project/PaAchievementsMapper.xml
  6. 15
      Rk-progect/ruoyi-project/src/main/resources/mapper/project/PaProjectInfoMapper.xml
  7. 15
      Rk-progect/ruoyi-project/target/classes/mapper/project/PaProjectInfoMapper.xml

2
Rk-progect/ruoyi-common/src/main/java/com/ruoyi/common/utils/file/MimeTypeUtils.java

@ -35,7 +35,7 @@ public class MimeTypeUtils @@ -35,7 +35,7 @@ public class MimeTypeUtils
"pdf" ,
//activiti
"bpmn", "bar",
"webloc","mp4",
"caj","mht","tif"
};

3
Rk-progect/ruoyi-project/src/main/java/com/ruoyi/project/mapper/PaProjectInfoMapper.java

@ -24,6 +24,9 @@ public interface PaProjectInfoMapper @@ -24,6 +24,9 @@ public interface PaProjectInfoMapper
PaProjectInfo selectPaProjectInfoByProjectName(String projectName);
List<PaProjectInfo> selectPaProjectInfoByProjectCode(String code);
/**
* 查询请填写功能名称列表
*

111
Rk-progect/ruoyi-project/src/main/java/com/ruoyi/project/service/impl/export/AchievementsExport.java

@ -38,69 +38,80 @@ public class AchievementsExport extends BaseExport { @@ -38,69 +38,80 @@ public class AchievementsExport extends BaseExport {
private PaAchievementsMapper paAchievementsMapper;
@Override
public AjaxResult addData(MultipartFile file, boolean updateSupport) {
// StringBuilder exportMsg =new StringBuilder();
try {
ExcelUtilPL<PaAchievements> achievementsExcel = new ExcelUtilPL<PaAchievements>(file.getInputStream());
List<PaAchievements> achievementSheet = achievementsExcel.importExcel("成果信息", PaAchievements.class);
String uploadPath = RuoYiConfig.getUploadPath()+ExportConfig.getAchievements();
logger.info("===================================");
logger.info("uploadPath:{}",uploadPath);
Map<String, String> fileNames = DirAll(new File(uploadPath)).stream().collect(Collectors.toMap( BaseExport::getFileName, s -> s));
fileNames.forEach((k,v)->{
logger.info("K:{}",k);
logger.info("V:{}",v);
});
achievementSheet.forEach(achievements->{
List<PaAchievements> list = paAchievementsMapper.selectPaAchievementsList(achievements);
if (list==null||list.size()== 0){
PaProjectInfo projectInfo = new PaProjectInfo();
projectInfo.setCode(achievements.getProjectCode());
List<PaProjectInfo> projectInfos = paProjectInfoMapper.selectPaProjectInfoList(projectInfo);
if (projectInfos!=null && projectInfos.size()>0){
String attachment = fileNames.get(achievements.getAttachment());
if (!attachment.isEmpty()){
try {
File uploadReusts = new File(attachment);
String path = FileUploadUtils.upload(uploadReusts);
PaAttachment pattachment = new PaAttachment();
pattachment.setTitle(uploadReusts.getName());
pattachment.setFilename(uploadReusts.getName());
pattachment.setFileSize(uploadReusts.length());
pattachment.setExt(getExt(uploadReusts.getName()));
pattachment.setPath(path);
pattachment.setType("5");
pattachment.setProjectId(projectInfos.get(0).getId());
paAttachmentMapper.insertPaAttachment(pattachment);
achievements.setAttachment(pattachment.getPath());
} catch (IOException e) {
e.printStackTrace();
}
}
String materialScience = fileNames.get(achievements.getMaterialScience());
// TODO: 2022/7/3 上传支撑材料附件并保存
if (!materialScience.isEmpty()){
try {
File uploadReusts = new File(materialScience);
String path = FileUploadUtils.upload(uploadReusts);
PaAttachment pattachment = new PaAttachment();
pattachment.setTitle(uploadReusts.getName());
pattachment.setFilename(uploadReusts.getName());
pattachment.setFileSize(uploadReusts.length());
pattachment.setExt(getExt(uploadReusts.getName()));
pattachment.setPath(path);
pattachment.setType("5");
pattachment.setProjectId(projectInfos.get(0).getId());
paAttachmentMapper.insertPaAttachment(pattachment);
achievements.setMaterialScience(pattachment.getPath());
} catch (IOException e) {
e.printStackTrace();
if (!achievements.getProjectCode().isEmpty()){
List<PaAchievements> list = paAchievementsMapper.selectPaAchievementsList(achievements);
if (list==null||list.size()== 0){
PaProjectInfo projectInfo = new PaProjectInfo();
projectInfo.setCode(achievements.getProjectCode());
List<PaProjectInfo> projectInfos = paProjectInfoMapper.selectPaProjectInfoList(projectInfo);
List<PaProjectInfo> paProjectInfo = paProjectInfoMapper.selectPaProjectInfoByProjectCode(achievements.getProjectCode());
if (paProjectInfo!=null&&paProjectInfo.size()>0){
String attachment = fileNames.get(achievements.getAttachment());
if (attachment!=null&&!attachment.isEmpty()){
try {
File uploadReusts = new File(attachment);
String path = FileUploadUtils.upload(uploadReusts);
PaAttachment pattachment = new PaAttachment();
pattachment.setTitle(uploadReusts.getName());
pattachment.setFilename(uploadReusts.getName());
pattachment.setFileSize(uploadReusts.length());
pattachment.setExt(getExt(uploadReusts.getName()));
pattachment.setPath(path);
pattachment.setType("5");
pattachment.setProjectId(projectInfos.get(0).getId());
paAttachmentMapper.insertPaAttachment(pattachment);
logger.info("附件为:{}上传成功",attachment);
achievements.setAttachment(pattachment.getPath());
} catch (IOException e) {
e.printStackTrace();
}
}
String materialScience = fileNames.get(achievements.getMaterialScience());
// TODO: 2022/7/3 上传支撑材料附件并保存
if (materialScience!=null&&!materialScience.isEmpty()){
try {
File uploadReusts = new File(materialScience);
String path = FileUploadUtils.upload(uploadReusts);
PaAttachment pattachment = new PaAttachment();
pattachment.setTitle(uploadReusts.getName());
pattachment.setFilename(uploadReusts.getName());
pattachment.setFileSize(uploadReusts.length());
pattachment.setExt(getExt(uploadReusts.getName()));
pattachment.setPath(path);
pattachment.setType("5");
pattachment.setProjectId(projectInfos.get(0).getId());
paAttachmentMapper.insertPaAttachment(pattachment);
logger.info("支撑材料为:{}上传成功",materialScience);
achievements.setMaterialScience(pattachment.getPath());
} catch (IOException e) {
e.printStackTrace();
}
}
paAchievementsMapper.insertPaAchievements(achievements);
}
paAchievementsMapper.insertPaAchievements(achievements);
}
}
});
@ -108,11 +119,13 @@ public class AchievementsExport extends BaseExport { @@ -108,11 +119,13 @@ public class AchievementsExport extends BaseExport {
} catch (IOException e) {
e.printStackTrace();
return AjaxResult.error();
} catch (Exception e){
e.printStackTrace();
return AjaxResult.error();
}
return null;
return AjaxResult.success();
}
@Override

10
Rk-progect/ruoyi-project/src/main/java/com/ruoyi/project/service/impl/export/ComplementReportExport.java

@ -57,6 +57,10 @@ public class ComplementReportExport extends BaseExport { @@ -57,6 +57,10 @@ public class ComplementReportExport extends BaseExport {
Map<String, String> fileNames = DirAll(new File(uploadPath)).stream().collect(Collectors.toMap( BaseExport::getFileName, s -> s));
//上传项目并保存
fileNames.forEach((k,v)->{
logger.info("K:{}",k);
logger.info("V:{}",v);
});
Future<String> projectFuture = executorService.submit(() -> {
StringBuilder taskMsg = new StringBuilder();
StringBuilder taskErrorMsg = new StringBuilder();
@ -74,7 +78,7 @@ public class ComplementReportExport extends BaseExport { @@ -74,7 +78,7 @@ public class ComplementReportExport extends BaseExport {
paProjectInfo.setCode(attachment.getCode());
List<PaProjectInfo> paProjectInfos = paProjectInfoMapper.selectPaProjectInfoList(paProjectInfo);
if (!paProjectInfos.isEmpty() && paProjectInfos.size() > 0) {
if (!fileNames.get(attachment.getFilename()).isEmpty()) {
if (fileNames.containsKey(attachment.getFilename())) {
File uploadReusts = new File(fileNames.get(attachment.getFilename()));
try {
String path = FileUploadUtils.upload(uploadReusts);
@ -125,7 +129,7 @@ public class ComplementReportExport extends BaseExport { @@ -125,7 +129,7 @@ public class ComplementReportExport extends BaseExport {
topic.setCode(attachment.getCode());
List<PaTopic> topics = paTopicMapper.selectPaTopicList(topic);
if (!topics.isEmpty()&&topics.size()>0){
if (!fileNames.get(attachment.getFilename()).isEmpty()){
if (fileNames.containsKey(attachment.getFilename())){
File uploadReusts=new File(fileNames.get(attachment.getFilename()));
try {
String path = FileUploadUtils.upload(uploadReusts);
@ -182,7 +186,7 @@ public class ComplementReportExport extends BaseExport { @@ -182,7 +186,7 @@ public class ComplementReportExport extends BaseExport {
topic.setCode(attachment.getCode());
PaTopic paTopic = paTopicMapper.selectPaTopicById(paSpecialSubjects.get(0).getTopicId());
if (paTopic!=null){
if (!fileNames.get(attachment.getFilename()).isEmpty()){
if (fileNames.containsKey(attachment.getFilename())){
File uploadReusts=new File(fileNames.get(attachment.getFilename()));
try {
String path = FileUploadUtils.upload(uploadReusts);

10
Rk-progect/ruoyi-project/src/main/resources/mapper/project/PaAchievementsMapper.xml

@ -20,7 +20,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" @@ -20,7 +20,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<sql id="selectPaAchievementsVo">
SELECT "id", "category", "entry", "referred_to", "format_requirements", "attachment", "situation", "material_science", "remake", "explain", "project_code"
FROM "public"."pa_achievements"
FROM "PUBLIC"."PA_ACHIEVEMENTS"
</sql>
<select id="selectPaAchievementsList" parameterType="PaAchievements" resultMap="PaAchievementsResult">
@ -47,7 +47,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" @@ -47,7 +47,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
</select>
<insert id="insertPaAchievements" parameterType="PaAchievements" useGeneratedKeys="true" keyProperty="id">
INSERT INTO "public"."pa_achievements"
INSERT INTO "PUBLIC"."PA_ACHIEVEMENTS"
<trim prefix="(" suffix=")" suffixOverrides=",">
<if test="id != null">id,</if>
<if test="category != null">category,</if>
@ -77,7 +77,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" @@ -77,7 +77,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
</insert>
<update id="updatePaAchievements" parameterType="PaAchievements">
UPDATE "public"."pa_achievements"
UPDATE "PUBLIC"."PA_ACHIEVEMENTS"
<trim prefix="SET" suffixOverrides=",">
<if test="id != null">id = #{id},</if>
<if test="category != null">category = #{category},</if>
@ -96,12 +96,12 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" @@ -96,12 +96,12 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
</update>
<delete id="deletePaAchievementsById" parameterType="Long">
DELETE FROM "public"."pa_achievements" where id = #{id}
DELETE FROM "PUBLIC"."PA_ACHIEVEMENTS" where id = #{id}
</delete>
<delete id="deletePaAchievementsByIds" parameterType="String">
DELETE FROM "public"."pa_achievements"
DELETE FROM "PUBLIC"."PA_ACHIEVEMENTS"
<foreach item="id" collection="array" open="(" separator="," close=")">
#{id}
</foreach>

15
Rk-progect/ruoyi-project/src/main/resources/mapper/project/PaProjectInfoMapper.xml

@ -199,6 +199,12 @@ @@ -199,6 +199,12 @@
where name like concat('%', #{name}, '%')
</select>
<select id="selectPaProjectInfoByProjectCode" parameterType="String" resultMap="PaProjectInfoResult">
<include refid="selectPaProjectInfoVo"/>
where code like concat('%', #{code}, '%')
</select>
<select id="countAllNum" parameterType="PaProjectInfo" resultType="Integer">
select count(1) from "PUBLIC"."pa_project_info"
<where>
@ -593,8 +599,8 @@ @@ -593,8 +599,8 @@
from (
select * from "PUBLIC"."pa_project_info"
where department_id in('25','26','27','28','29','30','31','32','33','149')
or department_name in ('医药卫生学部','机械与运载工程学部','信息与电子工程学部','化工、治金与材料工程学部','能源与矿业工程学部', '土木、水利与建筑工程学部','环境与轻纺工程学部','农业学部','工程管理学部','中国工程院战略咨询中心')
where department_id in('25','26','27','28','29','30','31','32','33','149','40')
or department_name in ('医药卫生学部','机械与运载工程学部','信息与电子工程学部','化工、治金与材料工程学部','能源与矿业工程学部', '土木、水利与建筑工程学部','环境与轻纺工程学部','农业学部','工程管理学部','中国工程院战略咨询中心','地方研究院')
) as p
<where>
@ -619,13 +625,16 @@ @@ -619,13 +625,16 @@
when p.type = '6' then '高端智库'
when p.type = '16' then '行业院重点'
when p.type = '18' then '行业院重大'
when p.type = '25' then '地方研究院重大'
when p.type = '26' then '地方研究院重点'
when p.type = '27' then '地方研究院'
when p.type = '3' then '其他'
when p.type = '20' then '其他'
when p.type = '21' then '其他'
end) as "TYPENAME",count(1) as "TYPENUM"
from "PUBLIC"."pa_project_info" p
<where>
p.type in('1','2','17','19','6','16','18','3','20','21')
p.type in('1','2','17','19','6','16','18','3','20','21','25','26','27')
<if test="yearRadio2 != null and yearRadio2 != '' and yearRadio2 != '2015'.toString() and yearRadio2 != '999'.toString()"> and to_char(p.approval_date,'YYYY') = #{yearRadio2}</if>
<if test="yearRadio2 == '2015'.toString()"> and to_char(p.approval_date,'YYYY') &lt; 2016</if>
<if test="yearRadio2 == '999'.toString()">and to_char(p.approval_date,'YYYY') &gt;= 2016</if>

15
Rk-progect/ruoyi-project/target/classes/mapper/project/PaProjectInfoMapper.xml

@ -199,6 +199,12 @@ @@ -199,6 +199,12 @@
where name like concat('%', #{name}, '%')
</select>
<select id="selectPaProjectInfoByProjectCode" parameterType="String" resultMap="PaProjectInfoResult">
<include refid="selectPaProjectInfoVo"/>
where code like concat('%', #{code}, '%')
</select>
<select id="countAllNum" parameterType="PaProjectInfo" resultType="Integer">
select count(1) from "PUBLIC"."pa_project_info"
<where>
@ -593,8 +599,8 @@ @@ -593,8 +599,8 @@
from (
select * from "PUBLIC"."pa_project_info"
where department_id in('25','26','27','28','29','30','31','32','33','149')
or department_name in ('医药卫生学部','机械与运载工程学部','信息与电子工程学部','化工、治金与材料工程学部','能源与矿业工程学部', '土木、水利与建筑工程学部','环境与轻纺工程学部','农业学部','工程管理学部','中国工程院战略咨询中心')
where department_id in('25','26','27','28','29','30','31','32','33','149','40')
or department_name in ('医药卫生学部','机械与运载工程学部','信息与电子工程学部','化工、治金与材料工程学部','能源与矿业工程学部', '土木、水利与建筑工程学部','环境与轻纺工程学部','农业学部','工程管理学部','中国工程院战略咨询中心','地方研究院')
) as p
<where>
@ -619,13 +625,16 @@ @@ -619,13 +625,16 @@
when p.type = '6' then '高端智库'
when p.type = '16' then '行业院重点'
when p.type = '18' then '行业院重大'
when p.type = '25' then '地方研究院重大'
when p.type = '26' then '地方研究院重点'
when p.type = '27' then '地方研究院'
when p.type = '3' then '其他'
when p.type = '20' then '其他'
when p.type = '21' then '其他'
end) as "TYPENAME",count(1) as "TYPENUM"
from "PUBLIC"."pa_project_info" p
<where>
p.type in('1','2','17','19','6','16','18','3','20','21')
p.type in('1','2','17','19','6','16','18','3','20','21','25','26','27')
<if test="yearRadio2 != null and yearRadio2 != '' and yearRadio2 != '2015'.toString() and yearRadio2 != '999'.toString()"> and to_char(p.approval_date,'YYYY') = #{yearRadio2}</if>
<if test="yearRadio2 == '2015'.toString()"> and to_char(p.approval_date,'YYYY') &lt; 2016</if>
<if test="yearRadio2 == '999'.toString()">and to_char(p.approval_date,'YYYY') &gt;= 2016</if>

Loading…
Cancel
Save