| | |
| | | package com.whyc.service; |
| | | |
| | | |
| | | import com.github.pagehelper.PageHelper; |
| | | import com.github.pagehelper.PageInfo; |
| | | import com.whyc.dto.Response; |
| | | import com.whyc.mapper.ProjectArchiveManageMapper; |
| | | import com.whyc.mapper.ProjectManageMapper; |
| | | import com.whyc.pojo.DeviceManage; |
| | | import com.whyc.pojo.ProjectArchiveManage; |
| | | import com.whyc.pojo.ProjectManage; |
| | | import io.swagger.models.auth.In; |
| | |
| | | import org.springframework.transaction.TransactionStatus; |
| | | |
| | | import javax.annotation.Resource; |
| | | import java.text.SimpleDateFormat; |
| | | import java.util.ArrayList; |
| | | import java.util.Date; |
| | | import java.util.HashMap; |
| | |
| | | return response; |
| | | } |
| | | |
| | | public Response<List<ProjectManage>> searchByCondition(ProjectManage projectManage) { |
| | | Response<List<ProjectManage>> response = new Response<>(); |
| | | /** |
| | | * 根据筛选条件 |
| | | * @param pageNum |
| | | * @param pageSize |
| | | * @param projectManage |
| | | * @return |
| | | */ |
| | | public Response<PageInfo<ProjectManage>> searchByCondition(int pageNum, int pageSize, ProjectManage projectManage) { |
| | | PageHelper.startPage(pageNum, pageSize); |
| | | List<ProjectManage> projectManages = projectManageMapper.searchByCondition(projectManage); |
| | | response.setCode(1); |
| | | response.setData(projectManages); |
| | | return response; |
| | | |
| | | PageInfo<ProjectManage> projectManagePageInfo = new PageInfo<>(projectManages); |
| | | return new Response<PageInfo<ProjectManage>>().set(1, projectManagePageInfo); |
| | | } |
| | | |
| | | |
| | | /** |
| | | * 新建项目 |
| | | * |
| | | * @param pm |
| | | * @return |
| | | */ |
| | | public Response add(ProjectManage pm) { |
| | | Response response = new Response<>(); |
| | | pm.setProNameCode(new SimpleDateFormat("yyyyMMddHHmmss").format(new Date())); |
| | | pm.setProState(1);//项目状态 进行中 |
| | | pm.setProProgress(1);//项目进度 立项 |
| | | Integer num = projectManageMapper.checkUniqueId(pm); |
| | | if(num>0){ |
| | | return response.setMsg(0, "添加失败,pro_name_code重复"); |
| | | if (num > 0) { |
| | | return response.setMsg(0, "添加失败,pro_name_code重复"); |
| | | } |
| | | boolean bl; |
| | | TransactionStatus transactionStatus = dataSourceTransactionManager.getTransaction(transactionDefinition); |
| | | try { |
| | | bl = projectManageMapper.insert(pm) > 0; |
| | | if (bl) { |
| | | String[] paths = pm.getNote().split(";"); |
| | | for (int i = 0; i < paths.length; i++) { |
| | | ProjectArchiveManage pam = new ProjectArchiveManage(); |
| | | pam.setProNum(pm.getProNum()); |
| | | pam.setProName(pm.getProName()); |
| | | pam.setProNameCode(pm.getProNameCode());//唯一,可对应多个文件 |
| | | pam.setProSort(pm.getProSort()); |
| | | String path = paths[i]; |
| | | pam.setProFilePath(path); |
| | | String[] split = path.split("_"); |
| | | int rexIdex = split[1].lastIndexOf("."); |
| | | pam.setProDocumentName(split[1].substring(0, rexIdex)); |
| | | pam.setProDocumentFormat(split[1].substring(rexIdex + 1)); |
| | | pam.setProUploadDate(new Date()); |
| | | projectArchiveManageMapper.insert(pam); |
| | | ArrayList<String> list = pm.getFileList(); |
| | | if (null != list) { |
| | | Date proUploadDate = new Date(); |
| | | for (int i = 0; i < list.size(); i++) { |
| | | ProjectArchiveManage pam = new ProjectArchiveManage(); |
| | | pam.setProNum(pm.getProNum()); |
| | | pam.setProName(pm.getProName()); |
| | | pam.setProNameCode(pm.getProNameCode());//唯一,可对应多个文件 |
| | | pam.setProSort(pm.getProSort()); |
| | | String path = list.get(i); |
| | | pam.setProFilePath(path); |
| | | String[] split = path.split("_"); |
| | | int rexIdex = split[1].lastIndexOf("."); |
| | | pam.setProDocumentName(split[1].substring(0, rexIdex)); |
| | | pam.setProDocumentFormat(split[1].substring(rexIdex + 1)); |
| | | pam.setProUploadDate(proUploadDate); |
| | | projectArchiveManageMapper.insert(pam); |
| | | } |
| | | } |
| | | } |
| | | } catch (Exception e) { |
| | |
| | | ProjectManage pm = projectManageMapper.searchManageStateByCondition(projectManage); |
| | | List<ProjectArchiveManage> pams = projectArchiveManageMapper.searchByConditionDocumentPath(projectManage); |
| | | HashMap<Object, Object> map = new HashMap<>(); |
| | | map.put("项目管理", pm); |
| | | map.put("pm", pm); |
| | | ArrayList<Object> list = new ArrayList<>(); |
| | | if (null != pams) { |
| | | for (int i = 0; i < pams.size(); i++) { |
| | | ProjectArchiveManage pam = pams.get(i); |
| | | HashMap<Object, Object> mapDoc = new HashMap<>(); |
| | | mapDoc.put("文件名", pam.getProDocumentName()); |
| | | mapDoc.put("文件路径", pam.getProFilePath()); |
| | | mapDoc.put("name", pam.getProDocumentName()); |
| | | mapDoc.put("url", pam.getProFilePath()); |
| | | list.add(mapDoc); |
| | | } |
| | | } |
| | | map.put("文档材料", list); |
| | | map.put("mapDoc", list); |
| | | response.setCode(1); |
| | | response.setMsg(1, "查询成功"); |
| | | response.setData(map); |
| | |
| | | TransactionStatus transactionStatus = dataSourceTransactionManager.getTransaction(transactionDefinition); |
| | | try { |
| | | bl = projectManageMapper.updateManageState(pm) > 0; |
| | | String path = pm.getNote().trim(); |
| | | if (path.length() > 10) { |
| | | ProjectArchiveManage pam = new ProjectArchiveManage(); |
| | | pam.setProNum(pm.getProNum()); |
| | | pam.setProName(pm.getProName()); |
| | | pam.setProNameCode(pm.getProNameCode());//唯一 |
| | | pam.setProSort(pm.getProSort()); |
| | | pam.setProFilePath(path); |
| | | String[] split = path.split("-"); |
| | | int rexIdex = split[1].lastIndexOf("."); |
| | | pam.setProDocumentName(split[1].substring(0, rexIdex)); |
| | | pam.setProDocumentFormat(split[1].substring(rexIdex + 1)); |
| | | projectArchiveManageMapper.insert(pam); |
| | | ArrayList<String> fileList = pm.getFileList(); |
| | | if (bl&&null != fileList) { |
| | | for (int i = 0; i < fileList.size(); i++) { |
| | | String filePath = fileList.get(i); |
| | | Boolean fileExist = projectArchiveManageMapper.checkFileExist(filePath)>0; |
| | | if (!fileExist) { |
| | | ProjectArchiveManage pam = new ProjectArchiveManage(); |
| | | pam.setProNum(pm.getProNum()); |
| | | pam.setProName(pm.getProName()); |
| | | pam.setProNameCode(pm.getProNameCode());//唯一 |
| | | pam.setProSort(pm.getProSort()); |
| | | pam.setProFilePath(filePath); |
| | | String[] split = filePath.split("_"); |
| | | int rexIdex = split[1].lastIndexOf("."); |
| | | pam.setProDocumentName(split[1].substring(0, rexIdex)); |
| | | pam.setProDocumentFormat(split[1].substring(rexIdex + 1)); |
| | | projectArchiveManageMapper.insert(pam); |
| | | } |
| | | } |
| | | } |
| | | response.setMsg(1, "更新成功"); |
| | | } catch (Exception e) { |
| | | e.printStackTrace(); |
| | | dataSourceTransactionManager.rollback(transactionStatus); |
| | | return response.setMsg(0, "更新失败"); |
| | | } |
| | | if (bl) { |
| | | response.setMsg(1, "更新成功"); |
| | | dataSourceTransactionManager.commit(transactionStatus); |
| | | } else { |
| | | |
| | | response.setMsg(0, "更新失败"); |
| | | dataSourceTransactionManager.rollback(transactionStatus); |
| | | } |
| | | return response; |
| | | } |
| | | |
| | | |
| | | /** |
| | | * 项目进度管理 |
| | | * 项目进度(1-6 立项、审批、研究、结题、验收、归档) |
| | | * @param progress |
| | | * @return |
| | | */ |
| | | public Response updateProjectProgress(ProjectManage progress) { |
| | | Response<Object> response = new Response<>(); |
| | | TransactionStatus transactionStatus = dataSourceTransactionManager.getTransaction(transactionDefinition); |
| | | progress.setProArchiveDate(new Date()); |
| | | boolean bl = projectManageMapper.updateProjectProgress(progress) > 0; |
| | | if (bl) { |
| | | bl = projectArchiveManageMapper.updateProjectProgress(progress) > 0; |
| | | } |
| | | if (bl) { |
| | | dataSourceTransactionManager.commit(transactionStatus); |
| | | response.setMsg(1, "更新成功"); |
| | | } else { |
| | | dataSourceTransactionManager.rollback(transactionStatus); |
| | | response.setMsg(0, "更新失败"); |
| | | } |
| | | return response; |
| | | } |
| | | } |