|
@@ -7,6 +7,7 @@ import com.ims.eval.entity.*;
|
|
|
import com.ims.eval.entity.dto.result.R;
|
|
|
import com.ims.eval.service.*;
|
|
|
import com.ims.eval.util.ExcelUtil;
|
|
|
+import com.ims.eval.util.WordUtil;
|
|
|
import lombok.extern.slf4j.Slf4j;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.web.bind.annotation.*;
|
|
@@ -14,9 +15,7 @@ import org.springframework.web.multipart.MultipartFile;
|
|
|
|
|
|
import javax.servlet.http.HttpServletRequest;
|
|
|
import java.io.InputStream;
|
|
|
-import java.util.ArrayList;
|
|
|
-import java.util.Arrays;
|
|
|
-import java.util.List;
|
|
|
+import java.util.*;
|
|
|
|
|
|
/**
|
|
|
* 本部部门业绩指标计划
|
|
@@ -251,4 +250,44 @@ public class DepartmentalPerformanceIndicatorPlanController {
|
|
|
return R.customError(e.getMessage()).data("失败!");
|
|
|
}
|
|
|
}
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 生成报表
|
|
|
+ *
|
|
|
+ * @return 结果
|
|
|
+ */
|
|
|
+ @GetMapping(value = "/generateReport/{id}")
|
|
|
+ public R generateReport(@PathVariable("id") String id) throws Exception {
|
|
|
+ Map<String, Object> dataMap = new HashMap<>();
|
|
|
+ EvaluationDeptBusinessPlan evaluationDeptBusinessPlan = evaluationDeptBusinessPlanService.getById(id);
|
|
|
+ String[] deptIds = evaluationDeptBusinessPlan.getDeptId().split(",");
|
|
|
+ String[] deptNames = evaluationDeptBusinessPlan.getDeptName().split(",");
|
|
|
+ List<EvaluationDept> evaluationDeptList = new ArrayList<>();
|
|
|
+ for (int i = 0; i < deptIds.length; i++) {
|
|
|
+ EvaluationDept evaluationDept = new EvaluationDept();
|
|
|
+ evaluationDept.setDeptId(deptIds[i]);
|
|
|
+ evaluationDept.setDeptName(deptNames[i]);
|
|
|
+ List<EvaluationDeptBusinessContent> evaluationDeptBusinessContentList = evaluationDeptBusinessContentService.selectEvaluationDeptBusinessContentListByBusinessPlanId(id, deptIds[i]);
|
|
|
+ if (evaluationDeptBusinessContentList.size() > 0) {
|
|
|
+ evaluationDept.setEvaluationDeptBusinessContent(evaluationDeptBusinessContentList.get(0));
|
|
|
+ if (evaluationDeptBusinessContentList.size() > 1) {
|
|
|
+ evaluationDeptBusinessContentList.remove(0);
|
|
|
+ evaluationDept.setList(evaluationDeptBusinessContentList);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ evaluationDeptList.add(evaluationDept);
|
|
|
+ }
|
|
|
+ dataMap.put("appraisalYear", evaluationDeptBusinessPlan.getAppraisalYear());
|
|
|
+ dataMap.put("list", evaluationDeptList);
|
|
|
+ String os = System.getProperty("os.name");
|
|
|
+ String path;
|
|
|
+ if (os.toLowerCase().startsWith("win")) { //如果是Windows系统
|
|
|
+ path = "D:/home/statement/";
|
|
|
+ } else { //linux和mac
|
|
|
+ path = "/home/dbkp/statement/";
|
|
|
+ }
|
|
|
+ String fileName = evaluationDeptBusinessPlan.getAppraisalYear() + "年度经营业绩指标计划.doc";
|
|
|
+ WordUtil.generateWord(dataMap, "template_dbkp_zbjh.ftl", path, fileName);
|
|
|
+ return R.ok().data(fileName);
|
|
|
+ }
|
|
|
}
|