zishan-an 1 year ago
parent
commit
108733c5d3

+ 1 - 1
src/main/java/com/kexun/controller/CooperatorController.java

@@ -64,7 +64,7 @@ public class CooperatorController {
 //        cooperatorInfo.setCooperatorNum(Long.toString(time1));
         cooperatorInfo.setTemplateNo(req.getString("field_template_no"));
         Calendar calendar= Calendar.getInstance();
-        SimpleDateFormat dateFormat= new SimpleDateFormat("yyyy-MM-dd :hh:mm:ss");
+        SimpleDateFormat dateFormat= new SimpleDateFormat("yyyy-MM-dd :HH:mm:ss");
         cooperatorInfo.setCreateTime(dateFormat.format(calendar.getTime()));
         // System.out.println(dateFormat.format(calendar.getTime()));
         CooperatorService.save(cooperatorInfo);

+ 1 - 1
src/main/java/com/kexun/controller/FieldTemplateController.java

@@ -80,7 +80,7 @@ public class FieldTemplateController {
     @PostMapping("save")
     public Result save(@RequestBody FiledTemplateUpdateRO filedTemplateUpdateRO) {
         Result result = new Result();
-        fieldTemplateService.saveOrUpdate(filedTemplateUpdateRO);
+        fieldTemplateService.save(filedTemplateUpdateRO);
         return result;
     }
 

+ 61 - 9
src/main/java/com/kexun/controller/ReportController.java

@@ -3,19 +3,26 @@ package com.kexun.controller;
 //import ch.qos.logback.core.rolling.helper.FileStoreUtil;
 //import ch.qos.logback.core.util.FileUtil;
 
+import com.alibaba.fastjson.JSON;
 import com.alibaba.fastjson.JSONObject;
+import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
 import com.kexun.common.utils.Result;
-import com.kexun.entity.BusinessInfo;
-import com.kexun.entity.CustomInfo;
-import com.kexun.entity.ReportFile;
+import com.kexun.entity.*;
+import com.kexun.service.CooperatorService;
 import com.kexun.service.CustomInfoService;
+import com.kexun.service.ReportService;
 import lombok.extern.java.Log;
 import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.web.bind.annotation.GetMapping;
-import org.springframework.web.bind.annotation.PathVariable;
-import org.springframework.web.bind.annotation.RequestMapping;
-import org.springframework.web.bind.annotation.RestController;
+import org.springframework.util.ResourceUtils;
+import org.springframework.web.bind.annotation.*;
 
+import javax.servlet.ServletOutputStream;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+import java.io.*;
+import java.net.URLEncoder;
+import java.text.SimpleDateFormat;
+import java.util.Calendar;
 import java.util.List;
 
 @RestController
@@ -24,17 +31,62 @@ import java.util.List;
 public class ReportController {
 
     @Autowired
-    private com.kexun.service.ReportService ReportService;
+    private com.kexun.service.ReportService reportService;
 
 
     @GetMapping("reportFileList")
     public Result businessToDoList() {
         JSONObject resJson=new JSONObject();
-        List<ReportFile> list= ReportService.list();
+        List<ReportFile> list= reportService.list();
+        for(int i=0; i<list.size(); i++)
+        {
+            String time = list.get(i).getCreateTime().replace(".0","");
+            list.get(i).setCreateTime(time);
+        }
         resJson.put("report_file_list",list);
         System.out.println(list);
 
         return Result.success("ok",resJson);
     }
+    @GetMapping("del")
+    public Result del(@RequestParam Long id) {
+        System.out.println("role");
+        System.out.println(id);
 
+        reportService.removeById(id);
+        return Result.success();
+    }
+
+
+
+
+    @PostMapping("download")
+    public void  download(@RequestBody String json)  {
+        // 获得待下载文件所在文件夹的绝对路径
+        JSONObject req = JSON.parseObject(json);
+        String fileName = req.getString("file_name");
+        System.out.println(fileName);
+        reportService.download(fileName);
+
+    }
+
+    @PostMapping("fileReportAdd")
+    public Result fileReportAdd(@RequestBody String json)
+    {
+        JSONObject req = JSON.parseObject(json);
+        ReportFile reportFile = new ReportFile();
+        reportFile.setFileName(req.getString("file_name"));
+        reportFile.setFileNameXml(req.getString("fileNameXml"));
+        reportFile.setFileNameTxt(req.getString("fileNameTxt"));
+        reportFile.setFileNameModel(req.getString("fileModel"));
+
+
+        Calendar calendar= Calendar.getInstance();
+        SimpleDateFormat dateFormat= new SimpleDateFormat("yyyy-MM-dd :HH:mm:ss");
+        reportFile.setCreateTime(dateFormat.format(calendar.getTime()));
+        // System.out.println(dateFormat.format(calendar.getTime()));
+        reportService.save(reportFile);
+
+        return Result.success();
+    }
 }

+ 1 - 0
src/main/java/com/kexun/controller/UploadController.java

@@ -64,6 +64,7 @@ public class UploadController {
 
     }
 
+
     @Autowired
     private CustomizedModelService customizedModelService;
 

+ 3 - 0
src/main/java/com/kexun/entity/ReportFile.java

@@ -18,6 +18,9 @@ public class ReportFile implements Serializable {
     @TableField(value = "rpt_no")
     private String rptNo;
 
+    @TableField(value = "file_name")
+    private String fileName;
+
     @TableField(value = "file_name_xml")
     private String fileNameXml;
 

+ 5 - 2
src/main/java/com/kexun/model/ro/FiledTemplateCreateRO.java

@@ -21,7 +21,10 @@ public class FiledTemplateCreateRO implements Serializable {
     @ApiModelProperty(value = "字段模板名称")
     private String templateName;
 
-    @ApiModelProperty(value = "字段列表")
-    private List<FiledUpdateRO> filedList;
+    @ApiModelProperty(value = "基础字段列表")
+    private List fieldSelected;
+
+    @ApiModelProperty(value = "衍生字段列表")
+    private List fieldSelected2;
 
 }

+ 2 - 0
src/main/java/com/kexun/service/FieldDefineService.java

@@ -2,6 +2,7 @@ package com.kexun.service;
 
 import com.baomidou.mybatisplus.core.metadata.IPage;
 import com.baomidou.mybatisplus.extension.service.IService;
+import com.kexun.entity.CooperatorInfo;
 import com.kexun.entity.FieldDefineEntity;
 import com.kexun.model.ro.FiledRO;
 import com.kexun.model.ro.FiledUpdateRO;
@@ -47,6 +48,7 @@ public interface FieldDefineService extends IService<FieldDefineEntity> {
      */
     List<FieldDefineEntity> listFieldInfoByLevel(String oneLevel);
 
+    FieldDefineEntity findByID(long id);
 
 
 }

+ 6 - 0
src/main/java/com/kexun/service/ReportService.java

@@ -4,6 +4,9 @@ import com.baomidou.mybatisplus.extension.service.IService;
 import com.kexun.entity.BusinessInfo;
 import com.kexun.entity.ReportFile;
 
+import javax.servlet.http.HttpServletResponse;
+import java.io.IOException;
+import java.io.OutputStream;
 import java.util.List;
 
 /**
@@ -11,5 +14,8 @@ import java.util.List;
  */
 public interface ReportService extends IService<ReportFile> {
 
+    public void download(String fileName) ;
 
 }
+
+

+ 8 - 2
src/main/java/com/kexun/service/impl/FieldDefineServiceImpl.java

@@ -4,6 +4,7 @@ import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
 import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper;
 import com.baomidou.mybatisplus.core.metadata.IPage;
 import com.kexun.entity.BusInfoModifyHis;
+import com.kexun.entity.CooperatorInfo;
 import com.kexun.entity.FieldDefineEntity;
 import com.kexun.hander.PageBean;
 import com.kexun.mapper.BusInfoModifyHisMapper;
@@ -32,7 +33,8 @@ import java.util.List;
 @Service
 public class FieldDefineServiceImpl extends ServiceImpl<FieldDefineMapper, FieldDefineEntity> implements FieldDefineService {
 
-
+    @Autowired
+    FieldDefineService fieldDefineService;
     @Autowired
     private FieldDefineMapper fieldDefineMapper;
 
@@ -107,6 +109,10 @@ public class FieldDefineServiceImpl extends ServiceImpl<FieldDefineMapper, Field
         fieldDefineMapper.updateStatus(id,status);
     }
 
-
+    @Override
+    public FieldDefineEntity findByID(long id) {
+        QueryWrapper<FieldDefineEntity> wrapper=new QueryWrapper<FieldDefineEntity>().eq("id",id);
+        return getOne(wrapper);
+    }
 
 }

+ 37 - 7
src/main/java/com/kexun/service/impl/FieldTemplateServiceImpl.java

@@ -13,6 +13,7 @@ import com.kexun.model.ro.*;
 import com.kexun.model.vo.FieldVO;
 import com.kexun.model.vo.FiledTemplateVO;
 import com.kexun.service.CooperatorService;
+import com.kexun.service.FieldDefineService;
 import com.kexun.service.FieldTemplateRefService;
 import com.kexun.service.FieldTemplateService;
 import com.kexun.utils.PageUtils;
@@ -33,7 +34,8 @@ import java.util.stream.Collectors;
  */
 @Service
 public class FieldTemplateServiceImpl extends ServiceImpl<FieldTemplateMapper, FieldTemplateEntity> implements FieldTemplateService {
-
+    @Autowired
+    FieldDefineService fieldDefineService;
     @Autowired
     FieldTemplateMapper fieldTemplateMapper;
     @Autowired
@@ -80,11 +82,38 @@ public class FieldTemplateServiceImpl extends ServiceImpl<FieldTemplateMapper, F
 
 
             //模板字段关系表
-            List<FiledUpdateRO> filedList = filedTemplateCreateRO.getFiledList();
-
+            List <String> fieldSelected = filedTemplateCreateRO.getFieldSelected();
+            List <String> fieldSelected2 = filedTemplateCreateRO.getFieldSelected2();
             List<FieldTemplateRefEntity> fieldTemplateRefList = new ArrayList<>();
 
-            //因字段表模型新增缺少选择字段的步骤,所以此部分暂时注掉,保证新增字段表模板部分功能实现
+            for (int i=0;i<fieldSelected.size();i++){
+                Long fid = Long.parseLong(fieldSelected.get(i));
+                FieldDefineEntity fieldDefine = fieldDefineService.findByID(fid);
+                FieldTemplateRefEntity fieldTemplateRefEntity = new FieldTemplateRefEntity();
+                fieldTemplateRefEntity.setIsDeleted(false);
+                fieldTemplateRefEntity.setFieldDefineId(fieldDefine.getId());
+                fieldTemplateRefEntity.setFieldNo(fieldDefine.getFieldNo());
+                fieldTemplateRefEntity.setName(fieldDefine.getName());
+                fieldTemplateRefEntity.setFieldTemplateId(id);
+                fieldTemplateRefEntity.setTemplateNo(fieldTemplateEntity.getTemplateNo());
+                fieldTemplateRefList.add(fieldTemplateRefEntity);
+            }
+            for (int i=0;i<fieldSelected2.size();i++){
+                Long fid = Long.parseLong(fieldSelected.get(i));
+                FieldDefineEntity fieldDefine = fieldDefineService.findByID(fid);
+                FieldTemplateRefEntity fieldTemplateRefEntity = new FieldTemplateRefEntity();
+                fieldTemplateRefEntity.setIsDeleted(false);
+                fieldTemplateRefEntity.setFieldDefineId(fieldDefine.getId());
+                fieldTemplateRefEntity.setFieldNo(fieldDefine.getFieldNo());
+                fieldTemplateRefEntity.setName(fieldDefine.getName());
+                fieldTemplateRefEntity.setFieldTemplateId(id);
+                fieldTemplateRefEntity.setTemplateNo(fieldTemplateEntity.getTemplateNo());
+                fieldTemplateRefList.add(fieldTemplateRefEntity);
+            }
+            fieldTemplateRefService.saveBatch(fieldTemplateRefList);
+
+//            List<FieldTemplateRefEntity> fieldTemplateRefList = new ArrayList<>();
+
 //            for (FiledUpdateRO filedUpdateRO : filedList) {
 //                FieldTemplateRefEntity fieldTemplateRefEntity = new FieldTemplateRefEntity();
 //                fieldTemplateRefEntity.setFieldTemplateId(id);
@@ -95,7 +124,7 @@ public class FieldTemplateServiceImpl extends ServiceImpl<FieldTemplateMapper, F
 //                fieldTemplateRefEntity.setType(filedUpdateRO.getType());
 //                fieldTemplateRefList.add(fieldTemplateRefEntity);
 //            }
-            fieldTemplateRefService.saveBatch(fieldTemplateRefList);
+//            fieldTemplateRefService.saveBatch(fieldTemplateRefList);
         }
     }
 
@@ -108,7 +137,8 @@ public class FieldTemplateServiceImpl extends ServiceImpl<FieldTemplateMapper, F
         Long id = filedTemplateUpdateRO.getId();
         FieldTemplateEntity templateEntity = getById(id);
         FieldTemplateEntity FieldTemplateEntity = new FieldTemplateEntity();
-
+        List<FiledUpdateRO> filedList = filedTemplateUpdateRO.getFieldSelected();
+        System.out.println(filedList);
         if (null != templateEntity) {
             BeanUtils.copyProperties(filedTemplateUpdateRO,FieldTemplateEntity);
 
@@ -131,7 +161,7 @@ public class FieldTemplateServiceImpl extends ServiceImpl<FieldTemplateMapper, F
         Long id = filedTemplateUpdateRO.getId();
         FieldTemplateEntity fieldTemplateSelect = fieldTemplateMapper.selectById(id);
         if (null != fieldTemplateSelect) {
-            List<FiledUpdateRO> filedList = filedTemplateUpdateRO.getFiledList();
+            List<FiledUpdateRO> filedList = filedTemplateUpdateRO.getFieldSelected();
             //先删除,后insert
             List<FieldTemplateRefEntity> filedTemplateList = new ArrayList<>();
             for (FiledUpdateRO filedUpdateRO : filedList) {

+ 26 - 0
src/main/java/com/kexun/service/impl/ReportServiceImpl.java

@@ -7,9 +7,13 @@ import com.kexun.mapper.BusinessMapper;
 import com.kexun.mapper.ReportMapper;
 import com.kexun.service.BusinessService;
 import com.kexun.service.ReportService;
+import org.apache.commons.io.IOUtils;
 import org.springframework.stereotype.Service;
 
 import javax.annotation.Resource;
+import javax.servlet.http.HttpServletResponse;
+import java.io.*;
+import java.net.URLEncoder;
 import java.util.List;
 
 /**
@@ -18,6 +22,28 @@ import java.util.List;
 @Service
 public class ReportServiceImpl extends ServiceImpl<ReportMapper, ReportFile>
     implements ReportService {
+    @Override
+    public void download( String fileName)  {
+        try {
+            String filePath = new String("D:/jin_rong/todo/test_data" +'/'+ fileName);
+
+            FileInputStream inputFile = new FileInputStream(filePath);
+
+            String outPath = new String("C:\\Users\\zishanan\\Desktop\\3" +'/'+ fileName);
+            FileOutputStream outputFile = new FileOutputStream(outPath);
+
+            int byteData;
+            while ((byteData = inputFile.read()) != -1) {
+                outputFile.write(byteData);
+            }
+
+            inputFile.close();
+            outputFile.close();
+            System.out.println("文件下载成功!");
+        } catch (IOException e) {
+            e.printStackTrace();
+        }
+    }
 
 
 }