|
@@ -2,6 +2,7 @@ package com.jeeplus.sys.controller;
|
|
|
|
|
|
import cn.hutool.core.util.ObjectUtil;
|
|
import cn.hutool.core.util.ObjectUtil;
|
|
import cn.hutool.core.util.StrUtil;
|
|
import cn.hutool.core.util.StrUtil;
|
|
|
|
+import com.aliyun.oss.ServiceException;
|
|
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
|
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
|
import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
|
|
import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
|
|
import com.baomidou.mybatisplus.core.metadata.IPage;
|
|
import com.baomidou.mybatisplus.core.metadata.IPage;
|
|
@@ -14,6 +15,9 @@ import com.jeeplus.core.excel.utils.EasyPoiUtil;
|
|
import com.jeeplus.core.query.QueryWrapperGenerator;
|
|
import com.jeeplus.core.query.QueryWrapperGenerator;
|
|
import com.jeeplus.security.util.SecurityUtils;
|
|
import com.jeeplus.security.util.SecurityUtils;
|
|
import com.jeeplus.sys.constant.enums.ProjectStatusEnum;
|
|
import com.jeeplus.sys.constant.enums.ProjectStatusEnum;
|
|
|
|
+import com.jeeplus.sys.constant.enums.ProjectTypeEnum;
|
|
|
|
+import com.jeeplus.sys.constant.enums.YesOrNoEnum;
|
|
|
|
+import com.jeeplus.sys.domain.User;
|
|
import com.jeeplus.sys.domain.UserProject;
|
|
import com.jeeplus.sys.domain.UserProject;
|
|
import com.jeeplus.sys.service.UserProjectService;
|
|
import com.jeeplus.sys.service.UserProjectService;
|
|
import com.jeeplus.sys.service.UserService;
|
|
import com.jeeplus.sys.service.UserService;
|
|
@@ -21,6 +25,7 @@ import com.jeeplus.sys.service.dto.UserDTO;
|
|
import com.jeeplus.sys.service.dto.UserProjectDTO;
|
|
import com.jeeplus.sys.service.dto.UserProjectDTO;
|
|
import com.jeeplus.sys.service.mapstruct.UserProjectWrapper;
|
|
import com.jeeplus.sys.service.mapstruct.UserProjectWrapper;
|
|
import com.jeeplus.sys.service.mapstruct.UserWrapper;
|
|
import com.jeeplus.sys.service.mapstruct.UserWrapper;
|
|
|
|
+import com.jeeplus.sys.utils.UserUtils;
|
|
import io.swagger.annotations.Api;
|
|
import io.swagger.annotations.Api;
|
|
import io.swagger.annotations.ApiOperation;
|
|
import io.swagger.annotations.ApiOperation;
|
|
import org.apache.commons.lang3.time.DateUtils;
|
|
import org.apache.commons.lang3.time.DateUtils;
|
|
@@ -31,11 +36,14 @@ import org.springframework.security.access.prepost.PreAuthorize;
|
|
import org.springframework.web.bind.annotation.*;
|
|
import org.springframework.web.bind.annotation.*;
|
|
import org.springframework.web.multipart.MultipartFile;
|
|
import org.springframework.web.multipart.MultipartFile;
|
|
|
|
|
|
|
|
+import javax.servlet.http.HttpServletResponse;
|
|
import javax.validation.ConstraintViolationException;
|
|
import javax.validation.ConstraintViolationException;
|
|
import javax.validation.Valid;
|
|
import javax.validation.Valid;
|
|
import java.text.ParseException;
|
|
import java.text.ParseException;
|
|
import java.text.SimpleDateFormat;
|
|
import java.text.SimpleDateFormat;
|
|
|
|
+import java.util.ArrayList;
|
|
import java.util.Date;
|
|
import java.util.Date;
|
|
|
|
+import java.util.HashMap;
|
|
import java.util.List;
|
|
import java.util.List;
|
|
|
|
|
|
|
|
|
|
@@ -56,12 +64,16 @@ public class UserProjectController {
|
|
@Autowired
|
|
@Autowired
|
|
private UserService userService;
|
|
private UserService userService;
|
|
|
|
|
|
|
|
+ private int successNum;
|
|
|
|
+
|
|
@ApiLog("查询项目列表")
|
|
@ApiLog("查询项目列表")
|
|
@PreAuthorize("hasAuthority('sys:project:list')")
|
|
@PreAuthorize("hasAuthority('sys:project:list')")
|
|
@GetMapping("list")
|
|
@GetMapping("list")
|
|
public ResponseEntity<IPage<UserProject>> data(UserProject userProject, Page<UserProject> page) throws Exception {
|
|
public ResponseEntity<IPage<UserProject>> data(UserProject userProject, Page<UserProject> page) throws Exception {
|
|
QueryWrapper<UserProject> queryWrapper = QueryWrapperGenerator.buildQueryCondition (userProject, UserProject.class);
|
|
QueryWrapper<UserProject> queryWrapper = QueryWrapperGenerator.buildQueryCondition (userProject, UserProject.class);
|
|
- IPage<UserProject> result = userProjectService.page (page, queryWrapper);
|
|
|
|
|
|
+ queryWrapper.lambda().eq(StrUtil.isNotEmpty(userProject.getItemType()),UserProject::getItemType,userProject.getItemType());
|
|
|
|
+ IPage<UserProject> result = userProjectService.selectPage (userProject);
|
|
|
|
+
|
|
return ResponseEntity.ok (result);
|
|
return ResponseEntity.ok (result);
|
|
}
|
|
}
|
|
|
|
|
|
@@ -90,9 +102,58 @@ public class UserProjectController {
|
|
//新增或编辑表单保存
|
|
//新增或编辑表单保存
|
|
UserProject project = UserProjectWrapper.INSTANCE.toEntity (projectDTO);
|
|
UserProject project = UserProjectWrapper.INSTANCE.toEntity (projectDTO);
|
|
UserProject pro = userProjectService.projectDtoToDate(project,projectDTO);
|
|
UserProject pro = userProjectService.projectDtoToDate(project,projectDTO);
|
|
|
|
+ pro.setItemType(projectDTO.getItemType());
|
|
|
|
+
|
|
|
|
+ if(StrUtil.isNotEmpty(projectDTO.getProjectHead())){
|
|
|
|
+ String userId = userService.getUserIdByLogin(projectDTO.getProjectHead());
|
|
|
|
+ if(StrUtil.isNotEmpty(userId)){
|
|
|
|
+ pro.setProjectHead(userId);
|
|
|
|
+ }else{
|
|
|
|
+ pro.setProjectHead("");
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ if(StrUtil.isNotEmpty(projectDTO.getEvaluationPersonOne())){
|
|
|
|
+ String userId = userService.getUserIdByLogin(projectDTO.getEvaluationPersonOne());
|
|
|
|
+ if(StrUtil.isNotEmpty(userId)){
|
|
|
|
+ pro.setEvaluationPersonOne(userId);
|
|
|
|
+ }else{
|
|
|
|
+ pro.setEvaluationPersonOne("");
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ if(StrUtil.isNotEmpty(projectDTO.getEvaluationPersonTwo())){
|
|
|
|
+ String userId = userService.getUserIdByLogin(projectDTO.getEvaluationPersonTwo());
|
|
|
|
+ if(StrUtil.isNotEmpty(userId)){
|
|
|
|
+ pro.setEvaluationPersonTwo(userId);
|
|
|
|
+ }else{
|
|
|
|
+ pro.setEvaluationPersonTwo("");
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
if(StrUtil.isEmpty(projectDTO.getId())){
|
|
if(StrUtil.isEmpty(projectDTO.getId())){
|
|
|
|
+
|
|
|
|
+ //判断一下文号是否存在
|
|
|
|
+ if(StrUtil.isNotEmpty(projectDTO.getDocumentNum())){
|
|
|
|
+ if(ObjectUtil.isNotEmpty(userProjectService.selectByDocumentNum(projectDTO.getDocumentNum()))){
|
|
|
|
+ return ResponseEntity.badRequest().body("不可使用已存在的文号");
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
userProjectService.save(pro);//新增
|
|
userProjectService.save(pro);//新增
|
|
}else{
|
|
}else{
|
|
|
|
+
|
|
|
|
+ //判断一下文号是否存在
|
|
|
|
+ if(StrUtil.isNotEmpty(projectDTO.getDocumentNum())){
|
|
|
|
+ UserProject userProjects = userProjectService.selectByDocumentNum(projectDTO.getDocumentNum());
|
|
|
|
+ if(ObjectUtil.isNotEmpty(userProjects)){
|
|
|
|
+ if(!projectDTO.getId().equals(userProjects.getId())){
|
|
|
|
+ return ResponseEntity.badRequest().body("不可使用已存在的文号");
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
LambdaUpdateWrapper<UserProject> wrapper = userProjectService.getLambdaUpdateWrapper(projectDTO);
|
|
LambdaUpdateWrapper<UserProject> wrapper = userProjectService.getLambdaUpdateWrapper(projectDTO);
|
|
userProjectService.update (pro,wrapper);//修改
|
|
userProjectService.update (pro,wrapper);//修改
|
|
}
|
|
}
|
|
@@ -123,16 +184,47 @@ public class UserProjectController {
|
|
@PreAuthorize("hasAnyAuthority('sys:project:import')")
|
|
@PreAuthorize("hasAnyAuthority('sys:project:import')")
|
|
@PostMapping("import")
|
|
@PostMapping("import")
|
|
@ApiOperation(value = "导入项目数据excel")
|
|
@ApiOperation(value = "导入项目数据excel")
|
|
- public ResponseEntity importFile(MultipartFile file) throws ParseException {
|
|
|
|
- int successNum = 0;
|
|
|
|
- List<UserProjectDTO> list = EasyPoiUtil.importSheetExcel(file, 1, 1, 1, UserProjectDTO.class);
|
|
|
|
|
|
+ public ResponseEntity importFile(MultipartFile file) {
|
|
|
|
+
|
|
|
|
+ this.successNum = 0;
|
|
|
|
+
|
|
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
|
|
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
|
|
|
|
+ ArrayList<UserProject> arrayList = new ArrayList<>();
|
|
|
|
+ HashMap<String,String> hashMap = new HashMap<>();
|
|
|
|
+
|
|
|
|
+ //评估项目sheet1
|
|
|
|
+ List<UserProjectDTO> listA = EasyPoiUtil.importSheetExcel(file, 1, 1, 0,1, UserProjectDTO.class);
|
|
|
|
+
|
|
|
|
+ String resultA = importDecide(listA, sdf, arrayList, hashMap, successNum, ProjectTypeEnum.ASSESS.getValue());
|
|
|
|
+ if(StrUtil.isNotEmpty(resultA)){
|
|
|
|
+ return ResponseEntity.badRequest().body (resultA);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ //咨询项目sheet2
|
|
|
|
+ List<UserProjectDTO> listB = EasyPoiUtil.importSheetExcel(file, 1, 1, 1,1, UserProjectDTO.class);
|
|
|
|
+
|
|
|
|
+ String resultB = importDecide(listB, sdf, arrayList, hashMap, successNum, ProjectTypeEnum.CONSULTATION.getValue());
|
|
|
|
+ if(StrUtil.isNotEmpty(resultB)){
|
|
|
|
+ return ResponseEntity.badRequest().body (resultB);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ if(hashMap.size() != listA.size() + listB.size()){
|
|
|
|
+ return ResponseEntity.badRequest().body ("文件中存在重复的文号或者多个空文号");
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ userProjectService.saveBatch(arrayList);
|
|
|
|
+
|
|
|
|
+ return ResponseEntity.ok("已成功导入 " + successNum + " 条数据");
|
|
|
|
+ }
|
|
|
|
+ public String importDecide(List<UserProjectDTO> list,SimpleDateFormat sdf,ArrayList<UserProject> arrayList,HashMap<String,String> hashMap,int successNum,String itemType){
|
|
|
|
+
|
|
for (UserProjectDTO project : list) {
|
|
for (UserProjectDTO project : list) {
|
|
|
|
|
|
try {
|
|
try {
|
|
if(StrUtil.isNotEmpty(project.getEvaluationReportDateUi())){
|
|
if(StrUtil.isNotEmpty(project.getEvaluationReportDateUi())){
|
|
String format = sdf.format(DateUtils.parseDate(project.getEvaluationReportDateUi(), new String[]{"yyyy/MM/dd"}));
|
|
String format = sdf.format(DateUtils.parseDate(project.getEvaluationReportDateUi(), new String[]{"yyyy/MM/dd"}));
|
|
project.setEvaluationReportDate(sdf.parse(format));
|
|
project.setEvaluationReportDate(sdf.parse(format));
|
|
|
|
+ project.setStatus(ProjectStatusEnum.FINISH.getValue());
|
|
}
|
|
}
|
|
}catch (Exception e){
|
|
}catch (Exception e){
|
|
if(StrUtil.isNotEmpty(project.getEvaluationReportDateUi())){
|
|
if(StrUtil.isNotEmpty(project.getEvaluationReportDateUi())){
|
|
@@ -168,29 +260,135 @@ public class UserProjectController {
|
|
project.setInvoiceMessage(project.getInvoiceDateUi());
|
|
project.setInvoiceMessage(project.getInvoiceDateUi());
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+ try {
|
|
|
|
+ if(StrUtil.isNotEmpty(project.getReimbursementDateUi())){
|
|
|
|
+ String format = sdf.format(DateUtils.parseDate(project.getReimbursementDateUi(), new String[]{"yyyy/MM/dd"}));
|
|
|
|
+ project.setReimbursementDate(sdf.parse(format));
|
|
|
|
+ }
|
|
|
|
+ }catch (Exception e){
|
|
|
|
+ e.printStackTrace();
|
|
|
|
+ }
|
|
|
|
+
|
|
//项目负责人、签字评估师1、签字评估师2 关联user表的id
|
|
//项目负责人、签字评估师1、签字评估师2 关联user表的id
|
|
- if(StrUtil.isNotBlank(project.getProjectHead())){
|
|
|
|
- project.setProjectHead(userService.getUserByLoginName(project.getProjectHead()).getId());
|
|
|
|
- }else{
|
|
|
|
- project.setProjectHead("");
|
|
|
|
|
|
+ if(StrUtil.isNotEmpty(project.getProjectHead())){
|
|
|
|
+ String id = userService.getUserIdByLogin(project.getProjectHead());
|
|
|
|
+ if(StrUtil.isNotEmpty(id)){
|
|
|
|
+ project.setProjectHead(id);
|
|
|
|
+ }else{
|
|
|
|
+ project.setProjectHead("");
|
|
|
|
+ }
|
|
}
|
|
}
|
|
|
|
|
|
- if(StrUtil.isNotBlank(project.getEvaluationPersonOne())){
|
|
|
|
- project.setEvaluationPersonOne(userService.getUserByLoginName(project.getEvaluationPersonOne()).getId());
|
|
|
|
- }else{
|
|
|
|
- project.setEvaluationPersonOne("");
|
|
|
|
|
|
+ if(StrUtil.isNotEmpty(project.getEvaluationPersonOne())){
|
|
|
|
+ String id = userService.getUserIdByLogin(project.getEvaluationPersonOne());
|
|
|
|
+ if(ObjectUtil.isNotEmpty(id)){
|
|
|
|
+ project.setEvaluationPersonOne(id);
|
|
|
|
+ }else{
|
|
|
|
+ project.setEvaluationPersonOne("");
|
|
|
|
+ }
|
|
}
|
|
}
|
|
|
|
|
|
- if(StrUtil.isNotBlank(project.getEvaluationPersonTwo())){
|
|
|
|
- project.setEvaluationPersonTwo(userService.getUserByLoginName(project.getEvaluationPersonTwo()).getId());
|
|
|
|
- }else{
|
|
|
|
- project.setEvaluationPersonTwo("");
|
|
|
|
|
|
+ if(StrUtil.isNotEmpty(project.getEvaluationPersonTwo())){
|
|
|
|
+ String id = userService.getUserIdByLogin(project.getEvaluationPersonTwo());
|
|
|
|
+ if(ObjectUtil.isNotEmpty(id)){
|
|
|
|
+ project.setEvaluationPersonTwo(id);
|
|
|
|
+ }else{
|
|
|
|
+ project.setEvaluationPersonTwo("");
|
|
|
|
+ }
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+ //文号的问题
|
|
|
|
+ if(StrUtil.isNotEmpty(project.getDocumentNum())) {
|
|
|
|
+ UserProject userProject = userProjectService.selectByDocumentNum(project.getDocumentNum());
|
|
|
|
+ if(ObjectUtil.isNotEmpty(userProject)){
|
|
|
|
+ return "文件中存在已在档的文号";
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ //是否开票
|
|
|
|
+ if(YesOrNoEnum.YES.getLabel().equals(project.getIsInvoice())){
|
|
|
|
+ project.setIsInvoice(YesOrNoEnum.YES.getValue());
|
|
|
|
+ }else if(YesOrNoEnum.NO.getLabel().equals(project.getIsInvoice())){
|
|
|
|
+ project.setIsInvoice(YesOrNoEnum.NO.getValue());
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ //合同是否存档
|
|
|
|
+ if(YesOrNoEnum.YES.getLabel().equals(project.getIsContractArchive())){
|
|
|
|
+ project.setIsContractArchive(YesOrNoEnum.YES.getValue());
|
|
|
|
+ }else if(YesOrNoEnum.NO.getLabel().equals(project.getIsContractArchive())){
|
|
|
|
+ project.setIsContractArchive(YesOrNoEnum.NO.getValue());
|
|
|
|
+ }
|
|
|
|
|
|
- userProjectService.save(UserProjectWrapper.INSTANCE.toEntity(project));
|
|
|
|
- successNum++;
|
|
|
|
|
|
+ //底稿是否完好
|
|
|
|
+ if(YesOrNoEnum.YES.getLabel().equals(project.getIsPapersIntact())){
|
|
|
|
+ project.setIsPapersIntact(YesOrNoEnum.YES.getValue());
|
|
|
|
+ }else if(YesOrNoEnum.NO.getLabel().equals(project.getIsPapersIntact())){
|
|
|
|
+ project.setIsPapersIntact(YesOrNoEnum.NO.getValue());
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ //底稿是否归档
|
|
|
|
+ if(YesOrNoEnum.YES.getLabel().equals(project.getIsPapersArchive())){
|
|
|
|
+ project.setIsPapersArchive(YesOrNoEnum.YES.getValue());
|
|
|
|
+ }else if(YesOrNoEnum.NO.getLabel().equals(project.getIsPapersArchive())){
|
|
|
|
+ project.setIsPapersArchive(YesOrNoEnum.NO.getValue());
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ //外勤是否已经报销
|
|
|
|
+ if(YesOrNoEnum.YES.getLabel().equals(project.getIsOpsReimbursement())){
|
|
|
|
+ project.setIsOpsReimbursement(YesOrNoEnum.YES.getValue());
|
|
|
|
+ }else if(YesOrNoEnum.NO.getLabel().equals(project.getIsOpsReimbursement())){
|
|
|
|
+ project.setIsOpsReimbursement(YesOrNoEnum.NO.getValue());
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ //是否已经报销提成
|
|
|
|
+ if(YesOrNoEnum.YES.getLabel().equals(project.getIsCommissionReimbursement())){
|
|
|
|
+ project.setIsCommissionReimbursement(YesOrNoEnum.YES.getValue());
|
|
|
|
+ }else if(YesOrNoEnum.NO.getLabel().equals(project.getIsCommissionReimbursement())){
|
|
|
|
+ project.setIsCommissionReimbursement(YesOrNoEnum.NO.getValue());
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ hashMap.put(project.getDocumentNum(),null);
|
|
|
|
+
|
|
|
|
+ UserProject userProject = UserProjectWrapper.INSTANCE.toEntity(project);
|
|
|
|
+ //项目类型 1.评估项目 2.咨询项目
|
|
|
|
+ userProject.setItemType(itemType);
|
|
|
|
+ arrayList.add(userProject);
|
|
|
|
+ this.successNum++;
|
|
}
|
|
}
|
|
- return ResponseEntity.ok("已成功导入 " + successNum + " 条数据");
|
|
|
|
|
|
+
|
|
|
|
+ return null;
|
|
}
|
|
}
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+ /**
|
|
|
|
+ * 下载导入项目数据模板
|
|
|
|
+ *
|
|
|
|
+ * @param response
|
|
|
|
+ * @return
|
|
|
|
+ */
|
|
|
|
+ @PreAuthorize ("hasAnyAuthority('sys:project:import')")
|
|
|
|
+ @GetMapping("import/template/assess")
|
|
|
|
+ @ApiOperation(value = "下载模板")
|
|
|
|
+ public void importFileTemplateAssess(HttpServletResponse response) {
|
|
|
|
+ String fileName = "项目数据导入模板.xlsx";
|
|
|
|
+ List<UserProjectDTO> list = Lists.newArrayList();
|
|
|
|
+ EasyPoiUtil.exportExcel ( list, "2021年资产评估项目备查登记表", "项目明细表", UserProjectDTO.class, fileName, response );
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+ /**
|
|
|
|
+ * 下载导入项目数据模板
|
|
|
|
+ *
|
|
|
|
+ * @param response
|
|
|
|
+ * @return
|
|
|
|
+ */
|
|
|
|
+ @PreAuthorize ("hasAnyAuthority('sys:project:import')")
|
|
|
|
+ @GetMapping("import/template/consultation")
|
|
|
|
+ @ApiOperation(value = "下载模板")
|
|
|
|
+ public void importFileTemplateConsultation(HttpServletResponse response) {
|
|
|
|
+ String fileName = "项目数据导入模板.xlsx";
|
|
|
|
+ List<UserProjectDTO> list = Lists.newArrayList();
|
|
|
|
+ EasyPoiUtil.exportExcel ( list, "2021年资产评估项目备查登记表", "咨询报告", UserProjectDTO.class, fileName, response );
|
|
|
|
+ }
|
|
|
|
+
|
|
}
|
|
}
|