Commit c41d2718 authored by wangqiang's avatar wangqiang

ExtPlanController:业务代码迁入(2.x版本->4.1版本)--暂时还未编译通过

parent 91afe366
package com.yonde.dcs.plan.common.utils;
import cn.hutool.poi.excel.ExcelReader;
import cn.hutool.poi.excel.ExcelUtil;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.multipart.MultipartFile;
/**
* @author xfchai
* @ClassName ExcelUtils.java
* @Description 操作excel工具类
* @createTime 2021/09/06 09:38:00
*/
@Slf4j
public class ExcelUtils {
/**
* 通过名称读取Excel
*
* @param uploadFile
* @param sheetName
* @return
*/
public static ExcelReader excelUtil(MultipartFile uploadFile, String sheetName) {
try {
ExcelReader reader = ExcelUtil.getReader(uploadFile.getInputStream(), sheetName);
return reader;
} catch (Exception e) {
log.error(e.getMessage());
return null;
}
}
/**
* 通过sheetIndex读取Excel
*
* @param uploadFile
* @param sheetIndex
* @return
*/
public static ExcelReader excelReader(MultipartFile uploadFile, int sheetIndex) {
try {
ExcelReader reader = ExcelUtil.getReader(uploadFile.getInputStream(), sheetIndex);
return reader;
} catch (Exception e) {
log.error(e.getMessage());
return null;
}
}
}
package com.yonde.dcs.plan.common.utils;
import lombok.extern.slf4j.Slf4j;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.util.Properties;
/**
* @program: service
* @description: 外部资源配置类
* @author: dang wei
* @create: 2021-01-04 11:29
*/
@Slf4j
public class ResourceHelper {
/**
* 获取外部资源配置
* @return
*/
public static Properties getResource(){
Properties prop = new Properties();
try{
prop.load(new FileInputStream("resource/esignConfig.properties"));
}catch (FileNotFoundException e){
log.error("找不到配置资源文件:" + e.getMessage());
}catch (IOException e){
log.error("读取外部配置资源文件报错:" + e.getMessage());
}
return prop;
}
}
package com.yonde.dcs.plan.common.vo;
import lombok.Data;
import java.io.Serializable;
import java.util.Date;
/**
* @author xfchai
* @ClassName ExtPlanEntity.java
* @Description 计划导入实体
* @createTime 2021/09/09 10:59:00
*/
@Data
public class PlanExcelVO implements Serializable {
/**
* 操作
*/
private String operate;
/**
* 计划名称
*/
private String name;
/**
* 计划编号
*/
private String number;
/**
* 父级计划编号
*/
private String superPlanCode;
/**
* 业务计划类型
*/
private String businessPlanType;
/**
* 反馈类型
*/
private String feedbackType;
/**
* 是否产生计划任务
*/
private String hasPlanTasks;
/**
* 合同编号
*/
private String contractNo;
/**
* 计划执行人
*/
private String planExecutor;
/**
* 工期
*/
private String constructPeriod;
/**
* 开始时间
*/
private Date startTime;
/**
* 完成时间
*/
private Date completeTime;
/**
* 文件分类
*/
private String fileType;
/**
* 文件名称
*/
private String fileName;
/**
* 文件编号
*/
private String fileNumber;
/**
* 文件代号
*/
private String fileCode;
/**
* 项目代号
*/
private String projectCode;
/**
* 管理信息系统编码
*/
private String systemCode;
/**
* 审核者
*/
private String review;
/**
* 批准者
*/
private String approver;
/**
* 审定者
*/
private String verifier;
/**
* 状态
*/
// private String state;
/**
* 阶段状态
*/
private String phaseState;
/**
* 计划级别
*/
private String planLevel;
/**
* 密级
*/
private String secretCode;
}
......@@ -3,6 +3,8 @@ package com.yonde.dcs.plan.core.controller;
import org.springframework.stereotype.Controller;
import io.swagger.annotations.ApiOperation;
import org.springframework.validation.annotation.Validated;
import java.io.IOException;
import java.util.List;
import com.yonde.dcs.plan.common.vo.ExtPlanVO;
import org.springframework.beans.factory.annotation.Qualifier;
......@@ -13,7 +15,10 @@ import com.yonde.dcs.plan.core.service.ExtPlanService;
import com.yonde.dex.basedata.entity.api.ApiResult;
import com.yonde.dcs.plan.core.controller.shadow.ExtPlanControllerShadow;
import javax.annotation.Resource;
import javax.servlet.http.HttpServletResponse;
import org.springframework.stereotype.Controller;
import org.springframework.web.multipart.MultipartFile;
/**
* @description: ExtPlan-Controller
......@@ -27,6 +32,30 @@ import org.springframework.stereotype.Controller;
@Controller(ExtPlanController.BEAN_NAME)
public class ExtPlanController<V extends ExtPlanVO, S extends ExtPlanService<V>> extends ExtPlanControllerShadow<V, S> {
@Autowired
private ExtPlanService extPlanService;
@ApiOperation("下载计划模板")
@GetMapping(value = "/downloadTemplate")
public void downloadTemplate(HttpServletResponse response, @RequestParam(value = "name", required = false) String name) throws IOException {
extPlanService.downloadTemplate(response, name);
}
/**
* 新增计划
*
* @param uploadFile
* @return
* @throws IOException
*/
@ApiOperation("新增计划")
@PostMapping(value = "/insertPlan/{projectId}")
public ApiResult insertPlan(@RequestParam("file") MultipartFile uploadFile,
@PathVariable("projectId") Long projectId) throws IOException {
ApiResult apiResult = extPlanService.insertPlan(uploadFile, projectId);
return apiResult;
}
}
......
......@@ -2,8 +2,12 @@ package com.yonde.dcs.plan.core.service;
import com.yonde.dcs.plan.common.vo.ExtPlanVO;
import com.yonde.dcs.plan.core.service.shadow.ExtPlanServiceShadow;
import com.yonde.dex.basedata.entity.api.ApiResult;
import com.yonde.dex.user.common.vo.DxOrganizationVO;
import org.springframework.web.multipart.MultipartFile;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.util.List;
/**
......@@ -22,4 +26,21 @@ public interface ExtPlanService<V extends ExtPlanVO> extends ExtPlanServiceShado
*/
List<DxOrganizationVO> searchOrgNameByUserId(Long userId, String code);
/**
* 导出计划
*
* @param response
* @param name
*/
void downloadTemplate(HttpServletResponse response, String name) throws IOException;
/**
* 新增计划
*
* @param uploadFile
*/
ApiResult insertPlan(MultipartFile uploadFile, Long projectId);
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment