|
@@ -1,21 +1,25 @@
|
|
|
package com.jeeplus.modules.projectFilingBatch.web;
|
|
|
|
|
|
+import com.google.common.collect.Lists;
|
|
|
import com.google.gson.internal.$Gson$Preconditions;
|
|
|
import com.jeeplus.common.config.Global;
|
|
|
import com.jeeplus.common.persistence.Page;
|
|
|
-import com.jeeplus.common.utils.IdGen;
|
|
|
-import com.jeeplus.common.utils.MyBeanUtils;
|
|
|
-import com.jeeplus.common.utils.StringUtils;
|
|
|
+import com.jeeplus.common.utils.*;
|
|
|
+import com.jeeplus.common.utils.excel.ExportExcel;
|
|
|
+import com.jeeplus.common.utils.excel.ImportExcel;
|
|
|
import com.jeeplus.common.web.BaseController;
|
|
|
import com.jeeplus.modules.act.entity.Act;
|
|
|
import com.jeeplus.modules.act.service.ActTaskService;
|
|
|
+import com.jeeplus.modules.pojectMaterialsWarehouse.entity.ProjectMaterialCollectInfo;
|
|
|
import com.jeeplus.modules.projectAccessory.entity.ProjectTemplateInfo;
|
|
|
import com.jeeplus.modules.projectFilingBatch.dao.ProjectFilingBatchProInfoDao;
|
|
|
import com.jeeplus.modules.projectFilingBatch.entity.ProjectFilingBatch;
|
|
|
+import com.jeeplus.modules.projectFilingBatch.entity.ProjectFilingBatchImportInfo;
|
|
|
import com.jeeplus.modules.projectFilingBatch.entity.ProjectFilingBatchProInfo;
|
|
|
import com.jeeplus.modules.projectFilingBatch.entity.ProjectFilingbatchRelation;
|
|
|
import com.jeeplus.modules.projectFilingBatch.service.ProjectFilingBatchService;
|
|
|
import com.jeeplus.modules.projectrecord.entity.ProjectRecords;
|
|
|
+import com.jeeplus.modules.ruralprojectrecords.entity.ImportBRuralProjectRecords;
|
|
|
import com.jeeplus.modules.ruralprojectrecords.entity.RuralProjectRecords;
|
|
|
import com.jeeplus.modules.ruralprojectrecords.enums.ProjectStatusEnum;
|
|
|
import com.jeeplus.modules.ruralprojectrecords.service.RuralProjectRecordsService;
|
|
@@ -26,6 +30,7 @@ import com.jeeplus.modules.sys.service.UserService;
|
|
|
import com.jeeplus.modules.sys.utils.UserUtils;
|
|
|
import com.jeeplus.modules.workclientinfo.entity.WorkClientAttachment;
|
|
|
import com.jeeplus.modules.workengineeringproject.entity.WorkEngineeringProject;
|
|
|
+import net.sf.json.JSONObject;
|
|
|
import org.activiti.engine.runtime.ProcessInstance;
|
|
|
import org.activiti.engine.task.Task;
|
|
|
import org.apache.shiro.authz.annotation.Logical;
|
|
@@ -36,6 +41,7 @@ import org.springframework.ui.Model;
|
|
|
import org.springframework.web.bind.annotation.*;
|
|
|
import org.springframework.web.multipart.MultipartFile;
|
|
|
import org.springframework.web.servlet.mvc.support.RedirectAttributes;
|
|
|
+import redis.clients.jedis.Jedis;
|
|
|
|
|
|
import javax.servlet.http.HttpServletRequest;
|
|
|
import javax.servlet.http.HttpServletResponse;
|
|
@@ -558,7 +564,9 @@ public class ProjectFilingBatchController extends BaseController {
|
|
|
for(int i=0;i<types.length;i++){
|
|
|
Map<String,String> map=new HashMap<>();
|
|
|
map.put("type",types[i]);
|
|
|
- map.put("name",names[i]);
|
|
|
+ if(null != names && names.length>0){
|
|
|
+ map.put("name",names[i]);
|
|
|
+ }
|
|
|
proInfo.add(map);
|
|
|
}
|
|
|
model.addAttribute("proInfo", proInfo);
|
|
@@ -581,4 +589,155 @@ public class ProjectFilingBatchController extends BaseController {
|
|
|
return "success";
|
|
|
}
|
|
|
|
|
|
-}
|
|
|
+ /**
|
|
|
+ * 批量项目信息文档下载
|
|
|
+ */
|
|
|
+ //@RequiresPermissions("projectFilingBatch:projectFilingBatchInfo:import")
|
|
|
+ @RequestMapping(value = "import/template")
|
|
|
+ public String importFileTemplate(HttpServletResponse response, HttpServletRequest request, RedirectAttributes redirectAttributes) {
|
|
|
+ try {
|
|
|
+ ThisLocalityDownloadUtil download = new ThisLocalityDownloadUtil();
|
|
|
+ download.download("批量归档导入模板.xlsx",request,response);
|
|
|
+ } catch (Exception e) {
|
|
|
+ addMessage(redirectAttributes, "模板下载失败!失败信息:"+e.getMessage());
|
|
|
+ }
|
|
|
+ //return "redirect:" + Global.getAdminPath() + "/projectFilingBatch/projectFilingBatchInfo/?repage";
|
|
|
+ return null;
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 批量项目信息导入
|
|
|
+ */
|
|
|
+ //@RequiresPermissions("projectFilingBatch:projectFilingBatchInfo:import")
|
|
|
+ @RequestMapping(value = "import", method=RequestMethod.POST)
|
|
|
+ @ResponseBody
|
|
|
+ public Map<String,Object> importFile(MultipartFile file) {
|
|
|
+ Map<String,Object> map = new HashMap<>();
|
|
|
+
|
|
|
+ //创建一个UUID
|
|
|
+ String uuid = UUID.randomUUID().toString().trim().replaceAll("-", "");
|
|
|
+ //创建缓存
|
|
|
+ JedisUtils jedis = new JedisUtils();
|
|
|
+ try {
|
|
|
+ ImportExcel ei = new ImportExcel(file, 1, 0);
|
|
|
+ List<ProjectFilingBatchImportInfo> list = ei.getDataList(ProjectFilingBatchImportInfo.class);
|
|
|
+ Set<String> reportNumberSet = new HashSet();
|
|
|
+ //对数据进行处理
|
|
|
+ //将报告号进行筛选去重
|
|
|
+ for (ProjectFilingBatchImportInfo info : list) {
|
|
|
+ if(StringUtils.isBlank(info.getReportNumber())){
|
|
|
+ map.put("success",false);
|
|
|
+ map.put("msg","存在未填写报告号的信息");
|
|
|
+ return map;
|
|
|
+ }
|
|
|
+ if(StringUtils.isBlank(info.getTypes())){
|
|
|
+ map.put("success",false);
|
|
|
+ map.put("msg","存在未填写项目类型的信息");
|
|
|
+ return map;
|
|
|
+ }
|
|
|
+ reportNumberSet.add(info.getReportNumber());
|
|
|
+ }
|
|
|
+ //数据进行分组
|
|
|
+ Map<String, List<ProjectFilingBatchImportInfo>> listMap = ruralProjectRecordsService.dataMessageDispose(list);
|
|
|
+ List<String> projectIdList = Lists.newArrayList();
|
|
|
+ for (String reportNumber: reportNumberSet) {
|
|
|
+ //判断报告号对应的项目是否存在
|
|
|
+ RuralProjectRecords records = ruralProjectRecordsService.getByReportNumber(reportNumber);
|
|
|
+ if(null == records){
|
|
|
+ map.put("success",false);
|
|
|
+ map.put("msg","未查询到报告号:"+ reportNumber + " 的项目信息");
|
|
|
+ return map;
|
|
|
+ }
|
|
|
+ //判断项目登记人是否为当前登陆人
|
|
|
+ if(!UserUtils.getUser().getId().equals(records.getCreateBy().getId())){
|
|
|
+ map.put("success",false);
|
|
|
+ map.put("msg","报告号:"+ reportNumber + " 的项目登记人不是您。无法进行归档");
|
|
|
+ return map;
|
|
|
+ }
|
|
|
+
|
|
|
+ //判断该项目信息是否已经提交归档或者是否归档已完成
|
|
|
+ Integer result = ruralProjectRecordsService.getEfficientProjectFlingbatchRelationByProjectId(records.getId());
|
|
|
+ if(result != 0){
|
|
|
+ map.put("success",false);
|
|
|
+ map.put("msg","报告号:"+ reportNumber + " 的项目信息已经归档或正在归档,无法进行二次归档");
|
|
|
+ return map;
|
|
|
+ }
|
|
|
+
|
|
|
+ List<ProjectFilingBatchImportInfo> projectFilingBatchImportInfos = listMap.get(reportNumber);
|
|
|
+ StringBuilder jedisJsonBuilder = new StringBuilder();
|
|
|
+ for (ProjectFilingBatchImportInfo info: projectFilingBatchImportInfos) {
|
|
|
+ info.setProId(records.getId());
|
|
|
+ //1、使用JSONObject
|
|
|
+ JSONObject json = JSONObject.fromObject(info);
|
|
|
+ String strJson=json.toString();
|
|
|
+ jedisJsonBuilder.append(strJson).append(";");
|
|
|
+ }
|
|
|
+ String jedisJson = jedisJsonBuilder.toString();
|
|
|
+ jedisJson.lastIndexOf(";");
|
|
|
+ jedis.set(uuid + "_" + records.getId(),jedisJson,120);
|
|
|
+ projectIdList.add(records.getId());
|
|
|
+ }
|
|
|
+
|
|
|
+ map.put("success",true);
|
|
|
+ map.put("projectIdList",projectIdList);
|
|
|
+ map.put("uuid",uuid);
|
|
|
+ map.put("msg","导入成功");
|
|
|
+ } catch (Exception e) {
|
|
|
+ map.put("success",false);
|
|
|
+ map.put("msg","导入失败。原因:" + e.getMessage());
|
|
|
+ }
|
|
|
+ return map;
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 根据项目id查询项目信息
|
|
|
+ * @param projectId
|
|
|
+ * @return
|
|
|
+ */
|
|
|
+ @ResponseBody
|
|
|
+ @RequestMapping(value = "getProjectByProjectId")
|
|
|
+ public RuralProjectRecords getProjectByProjectId(@RequestParam("projectId") String projectId) {
|
|
|
+ RuralProjectRecords projectRecords = ruralProjectRecordsService.getProjectByProjectId(projectId);
|
|
|
+ return projectRecords;
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 根据key键查询导入批量归档中的子节点信息
|
|
|
+ * @return
|
|
|
+ */
|
|
|
+ @ResponseBody
|
|
|
+ @RequestMapping(value = "getImportDescendantsInfo")
|
|
|
+ public Map<String,Object> getImportDescendantsInfo(@RequestParam("key") String key){
|
|
|
+ Map map = new HashMap();
|
|
|
+ //创建缓存
|
|
|
+ JedisUtils jedis = new JedisUtils();
|
|
|
+ try {
|
|
|
+ String jedisValue = jedis.get(key);
|
|
|
+ String[] split = jedisValue.split(";");
|
|
|
+ List<String> splitList = Arrays.asList(split);
|
|
|
+ List<ProjectFilingBatchImportInfo> infoList = Lists.newArrayList();
|
|
|
+ List<String> infoStrList = Lists.newArrayList();
|
|
|
+ for (String infoStr: splitList) {
|
|
|
+ //1、使用JSONObject
|
|
|
+ JSONObject jsonObject=JSONObject.fromObject(infoStr);
|
|
|
+ ProjectFilingBatchImportInfo info=(ProjectFilingBatchImportInfo)JSONObject.toBean(jsonObject, ProjectFilingBatchImportInfo.class);
|
|
|
+ infoList.add(info);
|
|
|
+ infoStrList.add(infoStr);
|
|
|
+ }
|
|
|
+
|
|
|
+ map.put("success",true);
|
|
|
+ map.put("infoList",infoList);
|
|
|
+ map.put("infoStrList",infoStrList);
|
|
|
+ //删除缓存数据
|
|
|
+ jedis.del(key);
|
|
|
+
|
|
|
+ } catch (Exception e) {
|
|
|
+ map.put("success",false);
|
|
|
+ map.put("msg","导入失败。原因:" + e.getMessage());
|
|
|
+ }
|
|
|
+ return map;
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+}
|