Compare commits
6 Commits
27f313e939
...
35a16f6f49
Author | SHA1 | Date | |
---|---|---|---|
|
35a16f6f49 | ||
|
81c9ec5ddb | ||
|
f77f9af17a | ||
|
3f72e65969 | ||
|
529ff2d723 | ||
|
61eb8584b9 |
1
.gitignore
vendored
1
.gitignore
vendored
@ -48,3 +48,4 @@ gen
|
||||
# virtual machine crash logs, see http://www.java.com/en/download/help/error_hotspot.xml
|
||||
hs_err_pid*
|
||||
|
||||
/upload/**
|
11
pom.xml
11
pom.xml
@ -82,6 +82,17 @@
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-aop</artifactId>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>io.springfox</groupId>
|
||||
<artifactId>springfox-swagger2</artifactId>
|
||||
<version>2.9.2</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>io.springfox</groupId>
|
||||
<artifactId>springfox-swagger-ui</artifactId>
|
||||
<version>2.10.5</version>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
|
||||
<build>
|
||||
|
@ -3,6 +3,7 @@ package com.example.survey;
|
||||
import org.springframework.boot.SpringApplication;
|
||||
import org.springframework.boot.autoconfigure.SpringBootApplication;
|
||||
|
||||
|
||||
@SpringBootApplication
|
||||
public class SurveyApplication {
|
||||
|
||||
|
@ -8,7 +8,6 @@ import com.example.survey.util.TokenUtil;
|
||||
import com.example.survey.vo.ResultVO;
|
||||
import lombok.extern.log4j.Log4j2;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
|
||||
import javax.servlet.*;
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
|
@ -4,14 +4,10 @@ import lombok.extern.log4j.Log4j2;
|
||||
import org.aspectj.lang.ProceedingJoinPoint;
|
||||
import org.aspectj.lang.annotation.Around;
|
||||
import org.aspectj.lang.annotation.Aspect;
|
||||
import org.aspectj.lang.annotation.Before;
|
||||
import org.aspectj.lang.annotation.Pointcut;
|
||||
import org.springframework.aop.MethodBeforeAdvice;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
|
||||
import java.lang.reflect.Method;
|
||||
import java.util.Arrays;
|
||||
import java.util.Objects;
|
||||
|
||||
/**
|
||||
* @author Pope
|
||||
|
25
src/main/java/com/example/survey/config/SwaggerConfig.java
Normal file
25
src/main/java/com/example/survey/config/SwaggerConfig.java
Normal file
@ -0,0 +1,25 @@
|
||||
package com.example.survey.config;
|
||||
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
import springfox.documentation.builders.PathSelectors;
|
||||
import springfox.documentation.builders.RequestHandlerSelectors;
|
||||
import springfox.documentation.spi.DocumentationType;
|
||||
import springfox.documentation.spring.web.plugins.Docket;
|
||||
import springfox.documentation.swagger2.annotations.EnableSwagger2;
|
||||
|
||||
|
||||
@Configuration
|
||||
@EnableSwagger2
|
||||
public class SwaggerConfig {
|
||||
|
||||
@Bean
|
||||
public Docket api() {
|
||||
return new Docket(DocumentationType.SWAGGER_2)
|
||||
.select()
|
||||
.apis(RequestHandlerSelectors.basePackage("com.example.survey.controller"))
|
||||
.paths(PathSelectors.any())
|
||||
.build();
|
||||
}
|
||||
|
||||
}
|
@ -3,9 +3,12 @@ package com.example.survey.controller;
|
||||
import com.example.survey.dto.metaData.CreateMetaDataDTO;
|
||||
import com.example.survey.dto.metaData.DeleteMetaDataDTO;
|
||||
import com.example.survey.dto.metaData.ModifyMetaDataDTO;
|
||||
import com.example.survey.enumeration.MetaDataTypeEnum;
|
||||
import com.example.survey.enumeration.ResultEnum;
|
||||
import com.example.survey.service.MetaDataService;
|
||||
import com.example.survey.vo.ResultVO;
|
||||
|
||||
import org.apache.commons.lang3.EnumUtils;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
import org.springframework.web.multipart.MultipartFile;
|
||||
@ -30,14 +33,22 @@ public class MetaDataController {
|
||||
}
|
||||
|
||||
@GetMapping("/nameList")
|
||||
public ResultVO listMetaData(@RequestParam(value = "name",required = false) String name,
|
||||
@RequestParam("currentPage")int currentPage,
|
||||
public ResultVO listMetaData(
|
||||
@RequestParam(value = "type",required = false) String type,
|
||||
@RequestParam(value = "name",required = false) String name,
|
||||
@RequestParam(value = "currentPage",defaultValue = "0")int currentPage,
|
||||
@RequestParam(value = "pageSize",defaultValue = "30")int pageSize){
|
||||
|
||||
// if (type != null && (! EnumUtils.isValidEnum(MetaDataTypeEnum.class, type))) {
|
||||
// ResultVO resultVO = new ResultVO(ResultEnum.NOT_EXIST_METADATA);
|
||||
// resultVO.setMsg("元数据类型不存在");
|
||||
// return resultVO;
|
||||
// }
|
||||
Map<String, Object> resultMap = new HashMap<>(16,0.75F);
|
||||
resultMap.put("totalCount", metaDataService.countMetaData(name));
|
||||
resultMap.put("totalCount", metaDataService.countMetaData(name, type));
|
||||
resultMap.put("currentPage", currentPage);
|
||||
resultMap.put("pageSize", pageSize);
|
||||
resultMap.put("data", metaDataService.listMetaDataNameLimit(name,currentPage,pageSize));
|
||||
resultMap.put("data", metaDataService.listMetaDataNameLimit(name, type ,currentPage,pageSize));
|
||||
|
||||
ResultVO resultVO = new ResultVO(ResultEnum.SUCCESS);
|
||||
resultVO.setData(resultMap);
|
||||
@ -63,11 +74,4 @@ public class MetaDataController {
|
||||
return new ResultVO(ResultEnum.SUCCESS);
|
||||
}
|
||||
|
||||
@PostMapping("/wordTemplate")
|
||||
public ResultVO bindWordTemplate(@RequestParam("template")MultipartFile template,
|
||||
@RequestParam("name")String name){
|
||||
metaDataService.bindWordTemplate(template,name);
|
||||
return new ResultVO(ResultEnum.SUCCESS);
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -1,18 +1,19 @@
|
||||
package com.example.survey.controller;
|
||||
|
||||
import com.example.survey.dto.project.AddRecordDTO;
|
||||
import com.example.survey.dto.project.CreateProjectDTO;
|
||||
import com.example.survey.dto.project.DeleteRecordDTO;
|
||||
import com.example.survey.dto.project.ModifyProjectDTO;
|
||||
import com.example.survey.dto.project.ModifyStateDTO;
|
||||
import com.example.survey.enumeration.RespondentStateEnum;
|
||||
|
||||
// import com.example.survey.enumeration.RespondentStateEnum;
|
||||
import com.example.survey.enumeration.ResultEnum;
|
||||
import com.example.survey.service.ProjectService;
|
||||
import com.example.survey.vo.ProjectVO;
|
||||
import com.example.survey.util.TokenUtil;
|
||||
import com.example.survey.vo.ResultVO;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
@ -27,43 +28,29 @@ public class ProjectController {
|
||||
|
||||
|
||||
@PostMapping("/project")
|
||||
public ResultVO createProject(@RequestBody CreateProjectDTO createProjectDTO) {
|
||||
public ResultVO createProject(@RequestBody CreateProjectDTO createProjectDTO,
|
||||
@RequestHeader("Authorization") String token) {
|
||||
createProjectDTO.setPhone((String) TokenUtil.get(token + " : USER_PHONE"));
|
||||
projectService.createProject(createProjectDTO);
|
||||
return new ResultVO(ResultEnum.SUCCESS);
|
||||
}
|
||||
|
||||
@GetMapping("/projectList")
|
||||
public ResultVO getProject(@RequestParam(value = "name",required = false) String name,
|
||||
@RequestParam(value = "state", required = false)String state,
|
||||
@RequestParam(value = "currentPage") int currentPage,
|
||||
@RequestParam(value = "date_gt", required = false, defaultValue = "0") long date_gt,
|
||||
@RequestParam(value = "date_lt", required = false, defaultValue = "0") long date_lt,
|
||||
@RequestParam(value = "currentPage", defaultValue = "0") int currentPage,
|
||||
@RequestParam(value = "pageSize", defaultValue = "30") int pageSize) {
|
||||
Map<String, Object> resultMap = new HashMap<>(16,0.75F);
|
||||
resultMap.put("totalCount", projectService.countProject(name,state));
|
||||
resultMap.put("totalCount", projectService.countProject(name, date_gt, date_lt));
|
||||
resultMap.put("currentPage", currentPage);
|
||||
resultMap.put("pageSize", pageSize);
|
||||
resultMap.put("data", projectService.listProjectLimit(name,state, currentPage, pageSize));
|
||||
resultMap.put("data", projectService.listProjectLimit(name, date_gt, date_lt, currentPage, pageSize));
|
||||
ResultVO resultVO = new ResultVO(ResultEnum.SUCCESS);
|
||||
resultVO.setData(resultMap);
|
||||
return resultVO;
|
||||
}
|
||||
|
||||
@GetMapping("/respondentCount")
|
||||
public ResultVO getRespondentCount(@RequestParam(value = "name") String name) {
|
||||
|
||||
Map<String, Object> resultMap = new HashMap<>(16, 0.75F);
|
||||
resultMap.put("respondentCount", projectService.countRespondent(name));
|
||||
resultMap.put("notInvestigatedRespondentCount", projectService.countRespondent(name, RespondentStateEnum.NOT_INVESTIGATED.getValue()));
|
||||
|
||||
ResultVO resultVO = new ResultVO(ResultEnum.SUCCESS);
|
||||
resultVO.setData(resultMap);
|
||||
return resultVO;
|
||||
}
|
||||
|
||||
@PutMapping("/projectState")
|
||||
public ResultVO modifyProjectState(@RequestBody ModifyStateDTO modifyStateDTO){
|
||||
projectService.modifyProjectState(modifyStateDTO);
|
||||
return new ResultVO(ResultEnum.SUCCESS);
|
||||
}
|
||||
|
||||
@PutMapping("/project")
|
||||
public ResultVO modifyProject(@RequestBody ModifyProjectDTO modifyProjectDTO){
|
||||
@ -71,4 +58,15 @@ public class ProjectController {
|
||||
return new ResultVO(ResultEnum.SUCCESS);
|
||||
}
|
||||
|
||||
@PutMapping("/record")
|
||||
public ResultVO addRecord(@RequestBody AddRecordDTO addRecordDTO){
|
||||
projectService.addRecord(addRecordDTO);
|
||||
return new ResultVO(ResultEnum.SUCCESS);
|
||||
}
|
||||
|
||||
@DeleteMapping("/record")
|
||||
public ResultVO deleteRecord(@RequestBody DeleteRecordDTO deleteRecordDTO){
|
||||
projectService.deleteRecord(deleteRecordDTO);
|
||||
return new ResultVO(ResultEnum.SUCCESS);
|
||||
}
|
||||
}
|
||||
|
@ -3,6 +3,7 @@ package com.example.survey.controller;
|
||||
import com.example.survey.dto.record.*;
|
||||
import com.example.survey.enumeration.ResultEnum;
|
||||
import com.example.survey.service.RecordService;
|
||||
import com.example.survey.util.TokenUtil;
|
||||
import com.example.survey.vo.ResultVO;
|
||||
import lombok.extern.log4j.Log4j2;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
@ -26,19 +27,22 @@ public class RecordController {
|
||||
|
||||
@GetMapping("/recordList")
|
||||
public ResultVO getRecord(@RequestParam(value = "idNumber", required = false) String idNumber,
|
||||
@RequestParam(value = "userPhone", required = false) String userPhone,
|
||||
@RequestParam(value = "projectName", required = false) String projectName,
|
||||
@RequestParam(value = "state", required = false) String state,
|
||||
@RequestParam(value = "version", required = false) String version,
|
||||
@RequestParam(value = "questionnaireNumber", required = false) String questionnaireNumber,
|
||||
@RequestParam(value = "currentPage") Integer currentPage,
|
||||
@RequestParam(value = "pageSize", defaultValue = "30") Integer pageSize
|
||||
) {
|
||||
@RequestParam(value = "templateName", required = false) String templateName,
|
||||
@RequestParam(value = "templateType", required = false) String templateType,
|
||||
@RequestParam(value = "uuid", required = false) String uuid,
|
||||
@RequestParam(value = "submitTimeGt", required = false, defaultValue = "0") long submitTimeGt,
|
||||
@RequestParam(value = "submitTimeLt", required = false, defaultValue = "0") long submitTimeLt,
|
||||
@RequestParam(value = "projectName", required = false) String projectName,
|
||||
@RequestParam(value = "currentPage", defaultValue = "0") Integer currentPage,
|
||||
@RequestParam(value = "pageSize", defaultValue = "30") Integer pageSize) {
|
||||
Map<String, Object> resultMap = new HashMap<>(16, 0.75F);
|
||||
resultMap.put("totalCount", recordService.countRecord(idNumber, userPhone, projectName, state, version, questionnaireNumber));
|
||||
resultMap.put("totalCount", recordService.countRecord(idNumber, state, uuid, templateName, templateType,
|
||||
submitTimeGt, submitTimeLt, projectName));
|
||||
resultMap.put("currentPage", currentPage);
|
||||
resultMap.put("pageSize", pageSize);
|
||||
resultMap.put("data", recordService.listRecordLimit(idNumber, userPhone, projectName, state, version, questionnaireNumber, currentPage, pageSize));
|
||||
resultMap.put("data", recordService.listRecordLimit(idNumber, state, uuid, templateName, templateType,
|
||||
submitTimeGt, submitTimeLt, projectName, currentPage, pageSize));
|
||||
ResultVO resultVo = new ResultVO(ResultEnum.SUCCESS);
|
||||
resultVo.setData(resultMap);
|
||||
|
||||
@ -46,43 +50,41 @@ public class RecordController {
|
||||
}
|
||||
|
||||
@GetMapping("/recordValues")
|
||||
public ResultVO getRecordValue(@RequestParam("projectName") String projectName,
|
||||
@RequestParam("idNumber") String idNumber,
|
||||
@RequestParam(value = "version", required = false) String version) {
|
||||
public ResultVO getRecordValue(@RequestParam("uuid") String uuid) {
|
||||
ResultVO resultVO = new ResultVO(ResultEnum.SUCCESS);
|
||||
resultVO.setData(recordService.getRecordValues(projectName, idNumber, version));
|
||||
resultVO.setData(recordService.getRecordValues(uuid));
|
||||
return resultVO;
|
||||
}
|
||||
|
||||
@GetMapping("/underReviewRecordCount")
|
||||
public ResultVO countUnderReviewRecord(@RequestParam(value = "userPhone") String userPhone,
|
||||
@RequestParam(value = "projectName") String projectName) {
|
||||
ResultVO resultVo = new ResultVO(ResultEnum.SUCCESS);
|
||||
resultVo.setData(recordService.countRecord(userPhone, projectName));
|
||||
return resultVo;
|
||||
}
|
||||
|
||||
@PutMapping("/underReviewRecord")
|
||||
public ResultVO reviewRecord(@RequestBody ReviewRecordDTO reviewRecordDTO) {
|
||||
@PutMapping("/review")
|
||||
public ResultVO reviewRecord(@RequestBody ReviewRecordDTO reviewRecordDTO,
|
||||
@RequestHeader("Authorization") String token) {
|
||||
reviewRecordDTO.setReviewerPhone((String) TokenUtil.get(token + " : USER_PHONE"));
|
||||
recordService.reviewRecord(reviewRecordDTO);
|
||||
return new ResultVO(ResultEnum.SUCCESS);
|
||||
}
|
||||
|
||||
@PutMapping("/record")
|
||||
public ResultVO modifyRecord(@RequestBody ModifyRecordDTO modifyRecordDTO) {
|
||||
public ResultVO modifyRecord(@RequestBody ModifyRecordDTO modifyRecordDTO,
|
||||
@RequestHeader("Authorization") String token) {
|
||||
modifyRecordDTO.setUserPhone((String) TokenUtil.get(token + " : USER_PHONE"));
|
||||
recordService.modifyRecord(modifyRecordDTO);
|
||||
return new ResultVO(ResultEnum.SUCCESS);
|
||||
}
|
||||
|
||||
@PostMapping("/record")
|
||||
public ResultVO submitRecord(@RequestBody SubmitRecordDTO submitRecordDTO) {
|
||||
public ResultVO submitRecord(@RequestBody SubmitRecordDTO submitRecordDTO,
|
||||
@RequestHeader("Authorization") String token) {
|
||||
submitRecordDTO.setUserPhone((String) TokenUtil.get(token + " : USER_PHONE"));
|
||||
recordService.createRecord(submitRecordDTO);
|
||||
|
||||
return new ResultVO(ResultEnum.SUCCESS);
|
||||
}
|
||||
|
||||
@DeleteMapping("/record")
|
||||
public ResultVO deleteRecord(@RequestBody DeleteRecordDTO deleteRecordDTO){
|
||||
public ResultVO deleteRecord(@RequestBody DeleteRecordDTO deleteRecordDTO,
|
||||
@RequestHeader("Authorization") String token) {
|
||||
deleteRecordDTO.setPhone((String) TokenUtil.get(token + " : USER_PHONE"));
|
||||
recordService.deleteRecord(deleteRecordDTO);
|
||||
return new ResultVO(ResultEnum.SUCCESS);
|
||||
}
|
||||
@ -95,24 +97,15 @@ public class RecordController {
|
||||
}
|
||||
|
||||
@GetMapping("/record2word")
|
||||
public void record2word(@RequestParam("idNumber")String idNumber,
|
||||
@RequestParam("projectName")String projectName,
|
||||
HttpServletResponse response){
|
||||
recordService.record2word(idNumber,projectName,response);
|
||||
}
|
||||
|
||||
@PutMapping("/project")
|
||||
public ResultVO modifyProject(@RequestBody ModifyProjectDTO modifyProjectDTO){
|
||||
recordService.modifyProject(modifyProjectDTO);
|
||||
return new ResultVO(ResultEnum.SUCCESS);
|
||||
public void record2word(@RequestParam("uuid") String uuid, HttpServletResponse response) {
|
||||
recordService.record2word(uuid, response);
|
||||
}
|
||||
|
||||
@PutMapping("/metaData")
|
||||
public ResultVO modifyMetaData(@RequestBody ModifyMetaDataDTO modifyMetaDataDTO){
|
||||
public ResultVO modifyMetaData(@RequestBody ModifyMetaDataDTO modifyMetaDataDTO,
|
||||
@RequestHeader("Authorization") String token) {
|
||||
modifyMetaDataDTO.setPhone((String) TokenUtil.get(token + " : USER_PHONE"));
|
||||
recordService.modifyMetaData(modifyMetaDataDTO);
|
||||
return new ResultVO(ResultEnum.SUCCESS);
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
@ -1,72 +0,0 @@
|
||||
package com.example.survey.controller;
|
||||
|
||||
import com.example.survey.dto.respondent.*;
|
||||
import com.example.survey.enumeration.ResultEnum;
|
||||
import com.example.survey.service.RespondentService;
|
||||
import com.example.survey.vo.ResultVO;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* @author Pope
|
||||
*/
|
||||
@RestController
|
||||
@RequestMapping("/respondent")
|
||||
public class RespondentController {
|
||||
|
||||
@Autowired
|
||||
private RespondentService respondentService;
|
||||
|
||||
@PostMapping("/respondent")
|
||||
public ResultVO addRespondent(@RequestBody CreateRespondentDTO createRespondentDTO) {
|
||||
respondentService.createRespondent(createRespondentDTO);
|
||||
return new ResultVO(ResultEnum.SUCCESS);
|
||||
}
|
||||
|
||||
@GetMapping("/respondentList")
|
||||
public ResultVO listRespondent(@RequestParam(value = "userPhone", required = false) String userPhone,
|
||||
@RequestParam(value = "projectName", required = false) String projectName,
|
||||
@RequestParam(value = "state", required = false) String state,
|
||||
@RequestParam(value = "idNumber", required = false) String idNumber,
|
||||
@RequestParam(value = "name", required = false) String name,
|
||||
@RequestParam(value = "phone", required = false) String phone,
|
||||
@RequestParam(value = "province", required = false) String province,
|
||||
@RequestParam(value = "city", required = false) String city,
|
||||
@RequestParam(value = "county", required = false) String county,
|
||||
@RequestParam(value = "currentPage") int currentPage,
|
||||
@RequestParam(value = "pageSize", defaultValue = "30") int pageSize
|
||||
) {
|
||||
Map<String, Object> resultMap = new HashMap<>(16, 0.75F);
|
||||
resultMap.put("totalCount", respondentService.countRespondent(userPhone, state, idNumber, name, phone, province, city, county, projectName));
|
||||
resultMap.put("currentPage", currentPage);
|
||||
resultMap.put("pageSize", pageSize);
|
||||
resultMap.put("data", respondentService.listRespondentLimit(userPhone, state, idNumber, name, phone, province, city, county, projectName, currentPage, pageSize));
|
||||
|
||||
ResultVO resultVo = new ResultVO(ResultEnum.SUCCESS);
|
||||
resultVo.setData(resultMap);
|
||||
|
||||
return resultVo;
|
||||
}
|
||||
|
||||
@PutMapping("/respondent")
|
||||
public ResultVO modifyRespondent(@RequestBody ModifyRespondentDTO modifyRespondentDTO) {
|
||||
respondentService.modifyRespondent(modifyRespondentDTO);
|
||||
return new ResultVO(ResultEnum.SUCCESS);
|
||||
}
|
||||
|
||||
@DeleteMapping("/respondent")
|
||||
public ResultVO deleteRespondent(@RequestBody DeleteRespondentDTO deleteRespondentDTO) {
|
||||
respondentService.deleteRespondent(deleteRespondentDTO);
|
||||
return new ResultVO(ResultEnum.SUCCESS);
|
||||
}
|
||||
|
||||
@PutMapping("/user")
|
||||
public ResultVO modifyUser(@RequestBody ModifyRespondentUserDTO modifyRespondentUserDTO) {
|
||||
respondentService.modifyUser(modifyRespondentUserDTO);
|
||||
return new ResultVO(ResultEnum.SUCCESS);
|
||||
}
|
||||
|
||||
}
|
@ -1,7 +1,6 @@
|
||||
package com.example.survey.dao;
|
||||
|
||||
import com.example.survey.entity.Audit;
|
||||
import com.example.survey.vo.AuditVO;
|
||||
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
|
@ -1,8 +1,7 @@
|
||||
package com.example.survey.dao;
|
||||
|
||||
import com.example.survey.entity.MetaData;
|
||||
import com.example.survey.vo.MetaDataVO;
|
||||
import org.springframework.data.mongodb.core.query.Meta;
|
||||
import com.example.survey.enumeration.MetaDataTypeEnum;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@ -42,7 +41,7 @@ public interface MetaDataDao {
|
||||
* @param pageSize 页大小
|
||||
* @return 元数据
|
||||
*/
|
||||
List<MetaData> listMetaDataLimit(String name, int offset, int pageSize);
|
||||
List<MetaData> listMetaDataLimit(String name, String type, int offset, int pageSize);
|
||||
|
||||
/**
|
||||
* 根据元数据名查询数量
|
||||
@ -50,7 +49,7 @@ public interface MetaDataDao {
|
||||
* @param name 元数据名
|
||||
* @return 数量
|
||||
*/
|
||||
long countMetaData(String name);
|
||||
long countMetaData(String name, String type);
|
||||
|
||||
/**
|
||||
* 获取所有元数据
|
||||
|
@ -1,6 +1,7 @@
|
||||
package com.example.survey.dao;
|
||||
|
||||
import com.example.survey.entity.Project;
|
||||
import com.example.survey.entity.Record;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@ -42,7 +43,7 @@ public interface ProjectDao {
|
||||
* @param pageSize 页大小
|
||||
* @return 项目列表
|
||||
*/
|
||||
List<Project> listProjectLimit(String name,String state, int offset, int pageSize);
|
||||
List<Project> listProjectLimit(String name, long date_gt, long date_lt, int offset, int pageSize);
|
||||
|
||||
/**
|
||||
* 根据项目名查询数量
|
||||
@ -51,5 +52,7 @@ public interface ProjectDao {
|
||||
* @param state 状态
|
||||
* @return 数量
|
||||
*/
|
||||
long countProject(String name,String state);
|
||||
long countProject(String name, long date_gt, long date_lt);
|
||||
|
||||
|
||||
}
|
||||
|
@ -1,9 +1,10 @@
|
||||
package com.example.survey.dao;
|
||||
|
||||
import com.example.survey.entity.Project;
|
||||
import com.example.survey.entity.Record;
|
||||
import com.example.survey.entity.Respondent;
|
||||
// import com.example.survey.entity.Respondent;
|
||||
import com.example.survey.entity.User;
|
||||
import com.example.survey.enumeration.MetaDataTypeEnum;
|
||||
import com.example.survey.enumeration.RecordStateEnum;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@ -19,7 +20,7 @@ public interface RecordDao {
|
||||
* @param state 流调记录状态
|
||||
* @return 是否存在符合条件的流调记录
|
||||
*/
|
||||
boolean existRecord(Respondent respondent, Project project, String state);
|
||||
boolean existRecord(String uuid);
|
||||
|
||||
/**
|
||||
* 根据调查对象身份证号与流调记录状态查询流调记录
|
||||
@ -29,7 +30,7 @@ public interface RecordDao {
|
||||
* @param state 流调记录状态
|
||||
* @return 流调记录
|
||||
*/
|
||||
Record getRecord(Respondent respondent,Project project, String state);
|
||||
Record getRecord(String uuid);
|
||||
|
||||
/**
|
||||
* 保存流调记录,若已有相同id的则更新
|
||||
@ -43,20 +44,20 @@ public interface RecordDao {
|
||||
*
|
||||
* @param respondent 调查对象
|
||||
* @param user 分配的人员
|
||||
* @param project 项目
|
||||
* @param state 流调记录状态
|
||||
* @param version 流调记录版本
|
||||
* @param questionnaireNumber 问卷编号
|
||||
* @return 数量
|
||||
*/
|
||||
long countRecord(Respondent respondent, User user, Project project, String state, String version, String questionnaireNumber);
|
||||
long countRecord(String idNumber, String state, String uuid,
|
||||
String templateName, String templateType,
|
||||
long submitTimeGt, long submitTimeLt, String projectName);
|
||||
|
||||
/**
|
||||
* 根据筛选条件分页查询流调记录
|
||||
*
|
||||
* @param respondent 调查对象
|
||||
* @param user 分配的人员
|
||||
* @param project 项目
|
||||
* @param state 流调记录状态
|
||||
* @param version 流调记录版本
|
||||
* @param questionnaireNumber 问卷编号
|
||||
@ -64,34 +65,9 @@ public interface RecordDao {
|
||||
* @param pageSize 页大小
|
||||
* @return 流调记录
|
||||
*/
|
||||
List<Record> listRecordLimit(Respondent respondent, User user, Project project, String state, String version, String questionnaireNumber, int offset, int pageSize);
|
||||
List<Record> listRecordLimit(String idNumber, String state, String uuid,
|
||||
String templateName, String templateType,
|
||||
long submitTimeGt, long submitTimeLt, String projectName, int offset, int pageSize);
|
||||
|
||||
/**
|
||||
* 根据筛选条件查询流调记录
|
||||
*
|
||||
* @param respondent 调查对象
|
||||
* @param project 项目
|
||||
* @param version 版本号
|
||||
* @return 流调记录
|
||||
*/
|
||||
Record selectRecord(Respondent respondent, Project project, String version);
|
||||
|
||||
/**
|
||||
* 根据筛选条件查询流调记录
|
||||
*
|
||||
* @param respondent 调查对象
|
||||
* @param project 项目
|
||||
* @param states 记录状态
|
||||
* @return 流调记录
|
||||
*/
|
||||
Record selectRecord(Respondent respondent, Project project, List<String> states);
|
||||
|
||||
/**
|
||||
* 查询流调记录列表
|
||||
*
|
||||
* @param project 项目
|
||||
* @param respondent 调查对象
|
||||
* @return 流调记录列表
|
||||
*/
|
||||
List<Record> listRecord(Project project, Respondent respondent);
|
||||
}
|
||||
|
@ -1,101 +0,0 @@
|
||||
package com.example.survey.dao;
|
||||
|
||||
import com.example.survey.entity.Project;
|
||||
import com.example.survey.entity.Respondent;
|
||||
import com.example.survey.entity.User;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @author Pope
|
||||
*/
|
||||
public interface RespondentDao {
|
||||
/**
|
||||
* 插入待调查对象
|
||||
*
|
||||
* @param respondent 待调查对象
|
||||
*/
|
||||
void saveRespondent(Respondent respondent);
|
||||
|
||||
/**
|
||||
* 根据流调人员电话号码分页查询待调查对象列表
|
||||
*
|
||||
* @param user 分配的人员
|
||||
* @param state 状态
|
||||
* @param idNumber 身份证号
|
||||
* @param name 调查对象姓名
|
||||
* @param phone 调查对象电话
|
||||
* @param province 省份
|
||||
* @param city 城市
|
||||
* @param county 区县
|
||||
* @param project 项目
|
||||
* @param offset 偏移量
|
||||
* @param pageSize 大小
|
||||
* @return 待调查对象列表
|
||||
*/
|
||||
List<Respondent> listRespondentLimit(User user, String state, String idNumber, String name, String phone, String province, String city, String county, Project project, int offset, int pageSize);
|
||||
|
||||
/**
|
||||
* 判断是否存在对应id的调查对象
|
||||
*
|
||||
* @param idNumber 身份证号
|
||||
* @param project 项目
|
||||
* @return 是否存在该调查对象
|
||||
*/
|
||||
boolean existRespondent(String idNumber, Project project);
|
||||
|
||||
/**
|
||||
* 判断是否存在符合条件的调查对象
|
||||
*
|
||||
* @param idNumber 身份证号
|
||||
* @param project 项目
|
||||
* @param state 调查对象状态
|
||||
* @return 是否存在该调查对象
|
||||
*/
|
||||
boolean existRespondent(String idNumber, Project project, String state);
|
||||
|
||||
/**
|
||||
* 根绝筛选条件获取调查对象数量
|
||||
*
|
||||
* @param user 分配的人员
|
||||
* @param state 状态
|
||||
* @param idNumber 身份证号
|
||||
* @param name 调查对象姓名
|
||||
* @param phone 调查对象电话
|
||||
* @param province 省份
|
||||
* @param city 城市
|
||||
* @param county 区县
|
||||
* @param project 项目
|
||||
* @return 数量
|
||||
*/
|
||||
long countRespondent(User user, String state, String idNumber, String name, String phone, String province, String city, String county, Project project);
|
||||
|
||||
|
||||
/**
|
||||
* 根据身份证号查询调查对象
|
||||
*
|
||||
* @param idNumber 身份证号
|
||||
* @param project 项目
|
||||
* @return 调查对象
|
||||
*/
|
||||
Respondent selectRespondent(String idNumber, Project project);
|
||||
|
||||
/**
|
||||
* 删除调查对象
|
||||
*
|
||||
* @param idNumber 身份证号
|
||||
*/
|
||||
void deleteRespondent(String idNumber);
|
||||
|
||||
|
||||
/**
|
||||
* 根据项目与调查对象状态查询调查对象数量
|
||||
*
|
||||
* @param project 项目
|
||||
* @param state 调查对象状态
|
||||
* @return 调查对象数量
|
||||
*/
|
||||
long countRespondent(Project project, String state);
|
||||
|
||||
|
||||
}
|
@ -1,10 +1,8 @@
|
||||
package com.example.survey.dao;
|
||||
|
||||
import com.example.survey.entity.Role;
|
||||
import com.example.survey.enumeration.AuthEnum;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
|
||||
/**
|
||||
* @author Pope
|
||||
|
@ -8,8 +8,6 @@ import org.springframework.data.mongodb.core.MongoTemplate;
|
||||
import org.springframework.data.mongodb.core.query.Criteria;
|
||||
import org.springframework.data.mongodb.core.query.Query;
|
||||
import org.springframework.stereotype.Repository;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
/**
|
||||
* @author Pope
|
||||
*/
|
||||
|
@ -2,6 +2,7 @@ package com.example.survey.dao.impl;
|
||||
|
||||
import com.example.survey.dao.MetaDataDao;
|
||||
import com.example.survey.entity.MetaData;
|
||||
import com.example.survey.enumeration.MetaDataTypeEnum;
|
||||
import com.example.survey.enumeration.ResultEnum;
|
||||
import com.example.survey.exception.MetaDataException;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
@ -44,22 +45,28 @@ public class MetaDataDaoImpl implements MetaDataDao {
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<MetaData> listMetaDataLimit(String name, int offset, int pageSize) {
|
||||
public List<MetaData> listMetaDataLimit(String name, String type, int offset, int pageSize) {
|
||||
Criteria criteria = new Criteria();
|
||||
if (name != null) {
|
||||
criteria.and("name").regex(name);
|
||||
}
|
||||
if (type != null) {
|
||||
criteria.and("type").is(type);
|
||||
}
|
||||
Query query = new Query(criteria).skip(offset).limit(pageSize);
|
||||
return mongoTemplate.find(query, MetaData.class);
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public long countMetaData(String name) {
|
||||
public long countMetaData(String name, String type) {
|
||||
Criteria criteria = new Criteria();
|
||||
if (name != null) {
|
||||
criteria.and("name").regex(name);
|
||||
}
|
||||
if (type != null) {
|
||||
criteria.and("type").is(type);
|
||||
}
|
||||
Query query = new Query(criteria);
|
||||
return mongoTemplate.count(query, MetaData.class);
|
||||
}
|
||||
|
@ -2,6 +2,7 @@ package com.example.survey.dao.impl;
|
||||
|
||||
import com.example.survey.dao.ProjectDao;
|
||||
import com.example.survey.entity.Project;
|
||||
import com.example.survey.entity.Record;
|
||||
import com.example.survey.enumeration.ResultEnum;
|
||||
import com.example.survey.exception.ProjectException;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
@ -10,7 +11,9 @@ import org.springframework.data.mongodb.core.query.Criteria;
|
||||
import org.springframework.data.mongodb.core.query.Query;
|
||||
import org.springframework.stereotype.Repository;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
|
||||
|
||||
/**
|
||||
@ -45,13 +48,16 @@ public class ProjectDaoImpl implements ProjectDao {
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<Project> listProjectLimit(String name,String state, int offset, int pageSize) {
|
||||
public List<Project> listProjectLimit(String name, long date_gt, long date_lt, int offset, int pageSize) {
|
||||
Criteria criteria = new Criteria();
|
||||
if (name != null) {
|
||||
criteria.and("name").regex(name);
|
||||
}
|
||||
if(state!=null){
|
||||
criteria.and("state").is(state);
|
||||
if (date_gt != 0) {
|
||||
criteria.and("date").gt(date_gt);
|
||||
}
|
||||
if(date_lt != 0) {
|
||||
criteria.and("date").lt(date_lt);
|
||||
}
|
||||
Query query = new Query(criteria).skip(offset).limit(pageSize);
|
||||
return mongoTemplate.find(query, Project.class);
|
||||
@ -59,15 +65,19 @@ public class ProjectDaoImpl implements ProjectDao {
|
||||
|
||||
|
||||
@Override
|
||||
public long countProject(String name,String state) {
|
||||
public long countProject(String name, long date_gt, long date_lt) {
|
||||
Criteria criteria = new Criteria();
|
||||
if (name != null) {
|
||||
criteria.and("name").regex(name);
|
||||
}
|
||||
if(state!=null){
|
||||
criteria.and("state").is(state);
|
||||
if (date_gt != 0) {
|
||||
criteria.and("date").gt(date_gt);
|
||||
}
|
||||
if(date_lt != 0) {
|
||||
criteria.and("date").lt(date_lt);
|
||||
}
|
||||
Query query = new Query(criteria);
|
||||
return mongoTemplate.count(query, Project.class);
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -1,9 +1,10 @@
|
||||
package com.example.survey.dao.impl;
|
||||
|
||||
import com.example.survey.dao.MetaDataDao;
|
||||
import com.example.survey.dao.RecordDao;
|
||||
import com.example.survey.entity.Project;
|
||||
import com.example.survey.entity.MetaData;
|
||||
import com.example.survey.entity.Record;
|
||||
import com.example.survey.entity.Respondent;
|
||||
// import com.example.survey.entity.Respondent;
|
||||
import com.example.survey.entity.User;
|
||||
import com.example.survey.enumeration.RecordStateEnum;
|
||||
import lombok.extern.log4j.Log4j2;
|
||||
@ -13,6 +14,7 @@ import org.springframework.data.mongodb.core.query.Criteria;
|
||||
import org.springframework.data.mongodb.core.query.Query;
|
||||
import org.springframework.stereotype.Repository;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
@ -25,23 +27,22 @@ public class RecordDaoImpl implements RecordDao {
|
||||
@Autowired
|
||||
MongoTemplate mongoTemplate;
|
||||
|
||||
@Autowired
|
||||
MetaDataDao metaDataDao;
|
||||
|
||||
|
||||
@Override
|
||||
public boolean existRecord(Respondent respondent, Project project, String state) {
|
||||
public boolean existRecord(String uuid) {
|
||||
Criteria criteria = new Criteria()
|
||||
.and("respondent.$id").is(respondent.getId())
|
||||
.and("project.$id").is(project.getId())
|
||||
.and("state").is(state);
|
||||
.and("uuid").is(uuid);
|
||||
Query query = new Query(criteria);
|
||||
return mongoTemplate.exists(query, Record.class);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Record getRecord(Respondent respondent, Project project, String state) {
|
||||
public Record getRecord(String uuid) {
|
||||
Criteria criteria = new Criteria()
|
||||
.and("respondent.$id").is(respondent.getId())
|
||||
.and("project.$id").is(project.getId())
|
||||
.and("state").is(state);
|
||||
.and("uuid").is(uuid);
|
||||
Query query = new Query(criteria);
|
||||
|
||||
return mongoTemplate.findOne(query, Record.class);
|
||||
@ -53,90 +54,98 @@ public class RecordDaoImpl implements RecordDao {
|
||||
}
|
||||
|
||||
@Override
|
||||
public long countRecord(Respondent respondent, User user, Project project, String state, String version, String questionnaireNumber) {
|
||||
public long countRecord(String idNumber, String state, String uuid,
|
||||
String templateName, String templateType,
|
||||
long submitTimeGt, long submitTimeLt, String projectName) {
|
||||
Criteria criteria = new Criteria();
|
||||
if (respondent != null) {
|
||||
criteria.and("respondent.$id").is(respondent.getId());
|
||||
}
|
||||
if (user != null) {
|
||||
criteria.and("user.$id").is(user.getId());
|
||||
}
|
||||
if (project != null) {
|
||||
criteria.and("project.$id").is(project.getId());
|
||||
if (idNumber != null) {
|
||||
criteria.and("idNumber").is(idNumber);
|
||||
}
|
||||
|
||||
if (state != null) {
|
||||
criteria.and("state").is(state);
|
||||
} else {
|
||||
criteria.and("state").in(RecordStateEnum.REVIEWED.getValue(), RecordStateEnum.UNDER_REVIEW.getValue());
|
||||
}
|
||||
if (uuid != null) {
|
||||
criteria.and("uuid").is(uuid);
|
||||
}
|
||||
if (templateName != null) {
|
||||
MetaData metaData = metaDataDao.selectMetaData(templateName);
|
||||
if (metaData != null) {
|
||||
criteria.and("metaData.$id").is(metaData.getId());
|
||||
}
|
||||
else{
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
if (version != null) {
|
||||
criteria.and("version").is(version);
|
||||
if (templateType != null) {
|
||||
criteria.and("metaDataType").is(templateType);
|
||||
}
|
||||
if (questionnaireNumber != null) {
|
||||
criteria.and("value.questionnaireNumber").is(questionnaireNumber);
|
||||
|
||||
if (submitTimeGt != 0) {
|
||||
criteria.and("submitTime").gt(submitTimeGt);
|
||||
}
|
||||
|
||||
if (submitTimeLt != 0) {
|
||||
criteria.and("submitTime").lt(submitTimeLt);
|
||||
}
|
||||
|
||||
|
||||
if (projectName != null) {
|
||||
criteria.and("projectList").elemMatch(new Criteria().in(projectName));
|
||||
}
|
||||
|
||||
Query query = new Query(criteria);
|
||||
return mongoTemplate.count(query, Record.class);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<Record> listRecordLimit(Respondent respondent, User user, Project project, String state, String version, String questionnaireNumber, int offset, int pageSize) {
|
||||
public List<Record> listRecordLimit(String idNumber, String state, String uuid,
|
||||
String templateName, String templateType,
|
||||
long submitTimeGt, long submitTimeLt, String projectName,
|
||||
int offset, int pageSize) {
|
||||
Criteria criteria = new Criteria();
|
||||
if (respondent != null) {
|
||||
criteria.and("respondent.$id").is(respondent.getId());
|
||||
}
|
||||
if (user != null) {
|
||||
criteria.and("user.$id").is(user.getId());
|
||||
}
|
||||
if (project != null) {
|
||||
criteria.and("project.$id").is(project.getId());
|
||||
if (idNumber != null) {
|
||||
criteria.and("idNumber").is(idNumber);
|
||||
}
|
||||
|
||||
if (state != null) {
|
||||
criteria.and("state").is(state);
|
||||
} else {
|
||||
criteria.and("state").in(RecordStateEnum.REVIEWED.getValue(), RecordStateEnum.UNDER_REVIEW.getValue());
|
||||
}
|
||||
else {
|
||||
criteria.and("state").nin(RecordStateEnum.FILED.getValue());
|
||||
}
|
||||
if (uuid != null) {
|
||||
criteria.and("uuid").is(uuid);
|
||||
}
|
||||
if (templateName != null) {
|
||||
MetaData metaData = metaDataDao.selectMetaData(templateName);
|
||||
if (metaData != null) {
|
||||
criteria.and("metaData.$id").is(metaData.getId());
|
||||
}
|
||||
else{
|
||||
return new ArrayList<Record>();
|
||||
}
|
||||
}
|
||||
|
||||
if (version != null) {
|
||||
criteria.and("version").is(version);
|
||||
if (templateType != null) {
|
||||
criteria.and("metaDataType").is(templateType);
|
||||
}
|
||||
if (questionnaireNumber != null) {
|
||||
criteria.and("value.questionnaireNumber").is(questionnaireNumber);
|
||||
|
||||
if (submitTimeGt != 0) {
|
||||
criteria.and("submitTime").gt(submitTimeGt);
|
||||
}
|
||||
|
||||
if (submitTimeLt != 0) {
|
||||
criteria.and("submitTime").lt(submitTimeLt);
|
||||
}
|
||||
|
||||
|
||||
if (projectName != null) {
|
||||
criteria.and("projectList").elemMatch(new Criteria().in(projectName));
|
||||
}
|
||||
|
||||
Query query = new Query(criteria).skip(offset).limit(pageSize);
|
||||
return mongoTemplate.find(query, Record.class);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Record selectRecord(Respondent respondent, Project project, String version) {
|
||||
Criteria criteria = Criteria
|
||||
.where("respondent.$id").is(respondent.getId())
|
||||
.and("project.$id").is(project.getId());
|
||||
if (version != null) {
|
||||
criteria.and("version").is(version);
|
||||
}
|
||||
Query query = new Query(criteria);
|
||||
return mongoTemplate.findOne(query, Record.class);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Record selectRecord(Respondent respondent, Project project, List<String> states) {
|
||||
Criteria criteria = new Criteria()
|
||||
.and("respondent.$id").is(respondent.getId())
|
||||
.and("project.$id").is(project.getId())
|
||||
.and("state").in(states);
|
||||
Query query = new Query(criteria);
|
||||
return mongoTemplate.findOne(query, Record.class);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<Record> listRecord(Project project, Respondent respondent) {
|
||||
|
||||
Query query = new Query(Criteria.where("project.$id").is(project.getId())
|
||||
.and("respondent.$id").is(respondent.getId()));
|
||||
return mongoTemplate.find(query,Record.class);
|
||||
}
|
||||
}
|
||||
|
@ -1,152 +0,0 @@
|
||||
package com.example.survey.dao.impl;
|
||||
|
||||
import com.example.survey.dao.RespondentDao;
|
||||
import com.example.survey.entity.Project;
|
||||
import com.example.survey.entity.Respondent;
|
||||
import com.example.survey.entity.User;
|
||||
import com.example.survey.enumeration.ResultEnum;
|
||||
import com.example.survey.exception.RespondentException;
|
||||
import lombok.extern.log4j.Log4j2;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.data.mongodb.core.MongoTemplate;
|
||||
import org.springframework.data.mongodb.core.query.Criteria;
|
||||
import org.springframework.data.mongodb.core.query.Query;
|
||||
import org.springframework.stereotype.Repository;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @author Pope
|
||||
*/
|
||||
@Log4j2
|
||||
@Repository
|
||||
public class RespondentDaoImpl implements RespondentDao {
|
||||
|
||||
@Autowired
|
||||
private MongoTemplate mongoTemplate;
|
||||
|
||||
@Override
|
||||
public void saveRespondent(Respondent respondent) {
|
||||
try {
|
||||
mongoTemplate.save(respondent);
|
||||
} catch (Exception e) {
|
||||
throw new RespondentException(ResultEnum.ALREADY_EXIST_RESPONDENT);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<Respondent> listRespondentLimit(User user, String state, String idNumber, String name, String phone, String province, String city, String county, Project project, int offset, int pageSize) {
|
||||
Criteria criteria = new Criteria();
|
||||
|
||||
if (idNumber != null) {
|
||||
criteria.and("idNumber").is(idNumber);
|
||||
}
|
||||
if (name != null) {
|
||||
criteria.and("name").regex(name);
|
||||
}
|
||||
if (phone != null) {
|
||||
criteria.and("phone").is(phone);
|
||||
}
|
||||
|
||||
if (province != null) {
|
||||
criteria.and("administrativeArea.province").is(province);
|
||||
}
|
||||
if (city != null) {
|
||||
criteria.and("administrativeArea.city").is(city);
|
||||
}
|
||||
if (county != null) {
|
||||
criteria.and("administrativeArea.county").is(county);
|
||||
}
|
||||
if (project != null) {
|
||||
criteria.and("project.$id").is(project.getId());
|
||||
}
|
||||
if (user != null) {
|
||||
criteria.and("user.$id").is(user.getId());
|
||||
}
|
||||
if (state != null) {
|
||||
criteria.and("state").is(state);
|
||||
}
|
||||
|
||||
Query query = new Query(criteria).skip(offset).limit(pageSize);
|
||||
return mongoTemplate.find(query, Respondent.class);
|
||||
}
|
||||
|
||||
@Override
|
||||
public long countRespondent(User user, String state, String idNumber, String name, String phone, String province, String city, String county, Project project) {
|
||||
Criteria criteria = new Criteria();
|
||||
|
||||
if (idNumber != null) {
|
||||
criteria.and("idNumber").is(idNumber);
|
||||
}
|
||||
if (name != null) {
|
||||
criteria.and("name").regex(name);
|
||||
}
|
||||
if (phone != null) {
|
||||
criteria.and("phone").is(phone);
|
||||
}
|
||||
|
||||
if (province != null) {
|
||||
criteria.and("administrativeArea.province").is(province);
|
||||
}
|
||||
if (city != null) {
|
||||
criteria.and("administrativeArea.city").is(city);
|
||||
}
|
||||
if (county != null) {
|
||||
criteria.and("administrativeArea.county").is(county);
|
||||
}
|
||||
if (project != null) {
|
||||
criteria.and("project.$id").is(project.getId());
|
||||
}
|
||||
if (user != null) {
|
||||
criteria.and("user.$id").is(user.getId());
|
||||
}
|
||||
if (state != null) {
|
||||
criteria.and("state").is(state);
|
||||
}
|
||||
|
||||
Query query = new Query(criteria);
|
||||
return mongoTemplate.count(query, Respondent.class);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean existRespondent(String idNumber, Project project) {
|
||||
Criteria criteria = Criteria.where("idNumber").is(idNumber);
|
||||
if (project != null) {
|
||||
criteria.and("project.$id").is(project.getId());
|
||||
}
|
||||
Query query = new Query(criteria);
|
||||
|
||||
return mongoTemplate.exists(query, Respondent.class);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean existRespondent(String idNumber, Project project, String state) {
|
||||
Query query = new Query(
|
||||
Criteria.where("idNumber").is(idNumber)
|
||||
.and("project.$id").is(project.getId())
|
||||
.and("state").is(state));
|
||||
return mongoTemplate.exists(query, Respondent.class);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public Respondent selectRespondent(String idNumber, Project project) {
|
||||
Query query = new Query(Criteria.where("idNumber").is(idNumber).and("project.$id").is(project.getId()));
|
||||
return mongoTemplate.findOne(query, Respondent.class);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void deleteRespondent(String idNumber) {
|
||||
Query query = new Query(Criteria.where("idNumber").is(idNumber));
|
||||
mongoTemplate.remove(query, Respondent.class);
|
||||
}
|
||||
|
||||
@Override
|
||||
public long countRespondent(Project project, String state) {
|
||||
Criteria criteria = Criteria.where("project.$id").is(project.getId()).and("state").is(state);
|
||||
Query query = new Query(criteria);
|
||||
return mongoTemplate.count(query, Respondent.class);
|
||||
}
|
||||
|
||||
|
||||
}
|
@ -2,7 +2,6 @@ package com.example.survey.dao.impl;
|
||||
|
||||
import com.example.survey.dao.RoleDao;
|
||||
import com.example.survey.entity.Role;
|
||||
import com.example.survey.enumeration.AuthEnum;
|
||||
import com.example.survey.enumeration.ResultEnum;
|
||||
import com.example.survey.exception.RoleException;
|
||||
import lombok.extern.log4j.Log4j2;
|
||||
@ -13,7 +12,6 @@ import org.springframework.data.mongodb.core.query.Query;
|
||||
import org.springframework.stereotype.Repository;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
|
||||
/**
|
||||
* @author Pope
|
||||
|
@ -1,6 +1,8 @@
|
||||
package com.example.survey.dto.metaData;
|
||||
|
||||
import com.example.survey.entity.inner.FieldToName;
|
||||
import com.example.survey.enumeration.MetaDataTypeEnum;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
import java.util.List;
|
||||
@ -13,7 +15,5 @@ import java.util.Map;
|
||||
public class CreateMetaDataDTO {
|
||||
private String name;
|
||||
private Map<String,Object> form;
|
||||
private List<FieldToName> fieldToNameList;
|
||||
private Map<String, Object> config;
|
||||
private String wordTemplate;
|
||||
private String type;
|
||||
}
|
||||
|
@ -1,6 +1,8 @@
|
||||
package com.example.survey.dto.metaData;
|
||||
|
||||
import com.example.survey.entity.inner.FieldToName;
|
||||
import com.example.survey.enumeration.MetaDataTypeEnum;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
import java.util.List;
|
||||
@ -13,6 +15,5 @@ import java.util.Map;
|
||||
public class ModifyMetaDataDTO {
|
||||
private String name;
|
||||
private Map<String,Object> form;
|
||||
private List<FieldToName> fieldToNameList;
|
||||
private Map<String, Object> config;
|
||||
private String type;
|
||||
}
|
||||
|
@ -1,12 +1,13 @@
|
||||
package com.example.survey.dto.project;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
import java.util.Date;
|
||||
|
||||
/**
|
||||
* @author Pope
|
||||
*/
|
||||
@Data
|
||||
public class ModifyStateDTO {
|
||||
public class AddRecordDTO {
|
||||
private String name;
|
||||
private String state;
|
||||
private String uuid;
|
||||
}
|
@ -16,31 +16,10 @@ public class CreateProjectDTO {
|
||||
*/
|
||||
private String name;
|
||||
|
||||
/**
|
||||
* 描述信息
|
||||
*/
|
||||
private String detail;
|
||||
|
||||
/**
|
||||
* 元数据名字
|
||||
*/
|
||||
private String metaDataName;
|
||||
|
||||
/**
|
||||
* 开始时间
|
||||
*/
|
||||
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
|
||||
private Date startTime;
|
||||
|
||||
/**
|
||||
* 结束时间
|
||||
*/
|
||||
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
|
||||
private Date endTime;
|
||||
|
||||
/**
|
||||
* 负责人电话号码
|
||||
*/
|
||||
private String userPhone;
|
||||
private long date;
|
||||
|
||||
private String phone;
|
||||
}
|
||||
|
@ -0,0 +1,13 @@
|
||||
package com.example.survey.dto.project;
|
||||
import lombok.Data;
|
||||
|
||||
import java.util.Date;
|
||||
|
||||
/**
|
||||
* @author Pope
|
||||
*/
|
||||
@Data
|
||||
public class DeleteRecordDTO {
|
||||
private String name;
|
||||
private String uuid;
|
||||
}
|
@ -11,10 +11,5 @@ import java.util.Date;
|
||||
@Data
|
||||
public class ModifyProjectDTO {
|
||||
private String name;
|
||||
private String detail;
|
||||
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
|
||||
private Date startTime;
|
||||
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
|
||||
private Date endTime;
|
||||
private String userPhone;
|
||||
private String phone;
|
||||
}
|
||||
|
@ -7,11 +7,7 @@ import lombok.Data;
|
||||
*/
|
||||
@Data
|
||||
public class DeleteRecordDTO {
|
||||
private String idNumber;
|
||||
|
||||
private String userPhone;
|
||||
|
||||
private String uuid;
|
||||
private String phone;
|
||||
private String msg;
|
||||
|
||||
private String projectName;
|
||||
}
|
||||
|
@ -1,6 +1,5 @@
|
||||
package com.example.survey.dto.record;
|
||||
|
||||
import com.example.survey.entity.inner.AdministrativeArea;
|
||||
import lombok.Data;
|
||||
|
||||
/**
|
||||
@ -8,9 +7,7 @@ import lombok.Data;
|
||||
*/
|
||||
@Data
|
||||
public class ModifyMetaDataDTO {
|
||||
private String idNumber;
|
||||
|
||||
private String projectName;
|
||||
|
||||
private String uuid;
|
||||
private String metaDataName;
|
||||
private String phone;
|
||||
}
|
||||
|
@ -8,12 +8,6 @@ import lombok.Data;
|
||||
*/
|
||||
@Data
|
||||
public class ModifyProjectDTO {
|
||||
private String idNumber;
|
||||
private String phone;
|
||||
private String name;
|
||||
private String msg;
|
||||
private String gender;
|
||||
private AdministrativeArea administrativeArea;
|
||||
private String projectName;
|
||||
private String newProjectName;
|
||||
private String uuid;
|
||||
private String project;
|
||||
}
|
||||
|
@ -3,16 +3,14 @@ package com.example.survey.dto.record;
|
||||
import lombok.*;
|
||||
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
|
||||
/**
|
||||
* @author Pope
|
||||
*/
|
||||
@Data
|
||||
public class ModifyRecordDTO {
|
||||
private String idNumber;
|
||||
private String uuid;
|
||||
private Map<String, Object> values;
|
||||
private String userPhone;
|
||||
private String msg;
|
||||
private String projectName;
|
||||
}
|
||||
|
@ -11,8 +11,7 @@ import lombok.*;
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
public class ReviewRecordDTO {
|
||||
private String idNumber;
|
||||
private String projectName;
|
||||
private String uuid;
|
||||
private Boolean pass;
|
||||
private String msg;
|
||||
private String reviewerPhone;
|
||||
|
@ -13,6 +13,8 @@ import java.util.Map;
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
public class SubmitRecordDTO {
|
||||
private String uuid;
|
||||
|
||||
private String idNumber;
|
||||
|
||||
private Map<String, Object> values;
|
||||
@ -23,6 +25,6 @@ public class SubmitRecordDTO {
|
||||
|
||||
private String metaDataName;
|
||||
|
||||
private String projectName;
|
||||
// private String projectName;
|
||||
|
||||
}
|
||||
|
@ -1,59 +0,0 @@
|
||||
package com.example.survey.dto.respondent;
|
||||
|
||||
import com.example.survey.entity.Project;
|
||||
import com.example.survey.entity.inner.AdministrativeArea;
|
||||
import lombok.*;
|
||||
import org.springframework.data.mongodb.core.index.Indexed;
|
||||
|
||||
import java.util.Set;
|
||||
|
||||
/**
|
||||
* @author Pope
|
||||
*/
|
||||
@Getter
|
||||
@Setter
|
||||
@ToString
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
public class CreateRespondentDTO {
|
||||
/**
|
||||
* 身份证号
|
||||
*/
|
||||
private String idNumber;
|
||||
|
||||
/**
|
||||
* 电话
|
||||
*/
|
||||
private String phone;
|
||||
|
||||
/**
|
||||
* 姓名
|
||||
*/
|
||||
private String name;
|
||||
|
||||
/**
|
||||
* 备注
|
||||
*/
|
||||
private String msg;
|
||||
|
||||
/**
|
||||
* 性别
|
||||
*/
|
||||
private String gender;
|
||||
|
||||
/**
|
||||
* 行政区划
|
||||
*/
|
||||
private AdministrativeArea administrativeArea;
|
||||
|
||||
/**
|
||||
* 分配人员
|
||||
*/
|
||||
private String userPhone;
|
||||
|
||||
/**
|
||||
* 项目名集合
|
||||
*/
|
||||
private String projectName;
|
||||
|
||||
}
|
@ -1,18 +0,0 @@
|
||||
package com.example.survey.dto.respondent;
|
||||
|
||||
import lombok.*;
|
||||
|
||||
/**
|
||||
* @author Pope
|
||||
*/
|
||||
@Getter
|
||||
@Setter
|
||||
@ToString
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
public class DeleteRespondentDTO {
|
||||
|
||||
private String idNumber;
|
||||
private String projectName;
|
||||
|
||||
}
|
@ -1,52 +0,0 @@
|
||||
package com.example.survey.dto.respondent;
|
||||
|
||||
import com.example.survey.entity.inner.AdministrativeArea;
|
||||
import lombok.*;
|
||||
|
||||
/**
|
||||
* @author Pope
|
||||
*/
|
||||
@Getter
|
||||
@Setter
|
||||
@ToString
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
public class ModifyRespondentDTO {
|
||||
|
||||
/**
|
||||
* 身份证号
|
||||
*/
|
||||
private String idNumber;
|
||||
|
||||
/**
|
||||
* 电话
|
||||
*/
|
||||
private String phone;
|
||||
|
||||
/**
|
||||
* 姓名
|
||||
*/
|
||||
private String name;
|
||||
|
||||
/**
|
||||
* 备注
|
||||
*/
|
||||
private String msg;
|
||||
|
||||
/**
|
||||
* 性别
|
||||
*/
|
||||
private String gender;
|
||||
|
||||
/**
|
||||
* 行政区划
|
||||
*/
|
||||
private AdministrativeArea administrativeArea;
|
||||
|
||||
/**
|
||||
* 项目名
|
||||
*/
|
||||
private String projectName;
|
||||
|
||||
|
||||
}
|
@ -1,13 +0,0 @@
|
||||
package com.example.survey.dto.respondent;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
/**
|
||||
* @author Pope
|
||||
*/
|
||||
@Data
|
||||
public class ModifyRespondentUserDTO {
|
||||
private String idNumber;
|
||||
private String projectName;
|
||||
private String userPhone;
|
||||
}
|
@ -2,7 +2,6 @@ package com.example.survey.dto.role;
|
||||
|
||||
import lombok.*;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
|
||||
/**
|
||||
|
@ -1,10 +1,10 @@
|
||||
package com.example.survey.dto.user;
|
||||
|
||||
import com.example.survey.entity.Department;
|
||||
// import com.example.survey.entity.Department;
|
||||
import com.example.survey.entity.inner.AdministrativeArea;
|
||||
import lombok.*;
|
||||
|
||||
import java.util.List;
|
||||
// import java.util.List;
|
||||
|
||||
/**
|
||||
* @author Pope
|
||||
|
@ -2,7 +2,7 @@ package com.example.survey.dto.user;
|
||||
|
||||
import lombok.*;
|
||||
|
||||
import java.util.List;
|
||||
// import java.util.List;
|
||||
import java.util.Set;
|
||||
|
||||
/**
|
||||
|
@ -2,10 +2,11 @@ package com.example.survey.entity;
|
||||
|
||||
import lombok.*;
|
||||
import org.bson.types.ObjectId;
|
||||
import org.springframework.data.mongodb.core.index.Indexed;
|
||||
// import org.springframework.data.mongodb.core.index.Indexed;
|
||||
import org.springframework.data.mongodb.core.mapping.DBRef;
|
||||
import org.springframework.data.mongodb.core.mapping.Document;
|
||||
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
|
@ -1,8 +1,10 @@
|
||||
package com.example.survey.entity;
|
||||
|
||||
import com.example.survey.entity.inner.FieldToName;
|
||||
import com.example.survey.enumeration.MetaDataTypeEnum;
|
||||
|
||||
import lombok.*;
|
||||
import org.bson.types.ObjectId;
|
||||
import org.springframework.data.mongodb.core.index.Indexed;
|
||||
import org.springframework.data.mongodb.core.mapping.Document;
|
||||
|
||||
import java.util.List;
|
||||
@ -15,9 +17,9 @@ import java.util.Map;
|
||||
@Document(collection = "metaData")
|
||||
public class MetaData {
|
||||
private ObjectId id;
|
||||
private String type;
|
||||
|
||||
@Indexed(unique = true)
|
||||
private String name;
|
||||
private Map<String,Object> form;
|
||||
private List<FieldToName> fieldToNameList;
|
||||
private String wordTemplate;
|
||||
private Map<String, Object> config;
|
||||
}
|
||||
|
@ -7,7 +7,9 @@ import org.springframework.data.mongodb.core.index.Indexed;
|
||||
import org.springframework.data.mongodb.core.mapping.DBRef;
|
||||
import org.springframework.data.mongodb.core.mapping.Document;
|
||||
|
||||
|
||||
import java.util.Date;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
|
||||
/**
|
||||
@ -29,39 +31,9 @@ public class Project {
|
||||
@Indexed(unique = true)
|
||||
private String name;
|
||||
|
||||
/**
|
||||
* 描述信息
|
||||
*/
|
||||
private String detail;
|
||||
private long date;
|
||||
|
||||
/**
|
||||
* 调查对象数量
|
||||
*/
|
||||
private long respondentCount;
|
||||
|
||||
/**
|
||||
* 未调查调查对象数量
|
||||
*/
|
||||
private long notInvestigatedRespondentCount;
|
||||
|
||||
/**
|
||||
* 负责人
|
||||
*/
|
||||
@DBRef
|
||||
private User user;
|
||||
|
||||
/**
|
||||
* 开始时间
|
||||
*/
|
||||
private Date startTime;
|
||||
|
||||
/**
|
||||
* 结束时间
|
||||
*/
|
||||
private Date endTime;
|
||||
|
||||
/**
|
||||
* 状态
|
||||
*/
|
||||
private String state;
|
||||
private long count;
|
||||
}
|
||||
|
@ -1,12 +1,17 @@
|
||||
package com.example.survey.entity;
|
||||
|
||||
import com.example.survey.entity.inner.Operation;
|
||||
import com.example.survey.enumeration.MetaDataTypeEnum;
|
||||
import com.example.survey.enumeration.RecordStateEnum;
|
||||
|
||||
import lombok.*;
|
||||
import org.bson.types.ObjectId;
|
||||
import org.springframework.data.annotation.Id;
|
||||
import org.springframework.data.mongodb.core.index.Indexed;
|
||||
import org.springframework.data.mongodb.core.mapping.DBRef;
|
||||
import org.springframework.data.mongodb.core.mapping.Document;
|
||||
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
@ -21,11 +26,10 @@ public class Record {
|
||||
@Id
|
||||
private ObjectId id;
|
||||
|
||||
/**
|
||||
* 调查对象
|
||||
*/
|
||||
@DBRef
|
||||
private Respondent respondent;
|
||||
@Indexed(unique = true)
|
||||
private String uuid;
|
||||
|
||||
private String idNumber;
|
||||
|
||||
/**
|
||||
* 用于存放前端传的字段
|
||||
@ -43,24 +47,19 @@ public class Record {
|
||||
*/
|
||||
private List<Operation> operationList;
|
||||
|
||||
/**
|
||||
* 记录版本
|
||||
*/
|
||||
private String version;
|
||||
|
||||
/**
|
||||
* 记录状态
|
||||
*/
|
||||
private String state;
|
||||
|
||||
/**
|
||||
* 项目集合
|
||||
*/
|
||||
@DBRef
|
||||
private Project project;
|
||||
|
||||
@DBRef
|
||||
private MetaData metaData;
|
||||
|
||||
private String metaDataType;
|
||||
|
||||
private List<String> projectList;
|
||||
|
||||
private long submitTime;
|
||||
|
||||
}
|
||||
|
||||
|
@ -1,79 +0,0 @@
|
||||
package com.example.survey.entity;
|
||||
|
||||
import com.example.survey.entity.inner.AdministrativeArea;
|
||||
import com.example.survey.entity.inner.ProjectPart;
|
||||
import lombok.*;
|
||||
import org.bson.types.ObjectId;
|
||||
import org.springframework.data.annotation.Id;
|
||||
import org.springframework.data.mongodb.core.index.CompoundIndex;
|
||||
import org.springframework.data.mongodb.core.index.CompoundIndexes;
|
||||
import org.springframework.data.mongodb.core.index.Indexed;
|
||||
import org.springframework.data.mongodb.core.mapping.DBRef;
|
||||
import org.springframework.data.mongodb.core.mapping.Document;
|
||||
|
||||
import java.util.Set;
|
||||
|
||||
/**
|
||||
* @author Pope
|
||||
* 调查对象表
|
||||
*/
|
||||
@Data
|
||||
@Document(collection = "respondent")
|
||||
@CompoundIndexes({
|
||||
@CompoundIndex(name = "unique",def = "{idNumber : 1, project : 1}",unique = true)
|
||||
})
|
||||
public class Respondent {
|
||||
|
||||
/**
|
||||
* id
|
||||
*/
|
||||
@Id
|
||||
private ObjectId id;
|
||||
|
||||
/**
|
||||
* 身份证号
|
||||
*/
|
||||
private String idNumber;
|
||||
|
||||
/**
|
||||
* 电话
|
||||
*/
|
||||
private String phone;
|
||||
|
||||
/**
|
||||
* 姓名
|
||||
*/
|
||||
private String name;
|
||||
|
||||
/**
|
||||
* 备注
|
||||
*/
|
||||
private String msg;
|
||||
|
||||
/**
|
||||
* 性别
|
||||
*/
|
||||
private String gender;
|
||||
|
||||
/**
|
||||
* 行政区划
|
||||
*/
|
||||
private AdministrativeArea administrativeArea;
|
||||
|
||||
/**
|
||||
* 分配的人员
|
||||
*/
|
||||
@DBRef
|
||||
private User user;
|
||||
|
||||
/**
|
||||
* 项目
|
||||
*/
|
||||
@DBRef
|
||||
private Project project;
|
||||
|
||||
/**
|
||||
* 调查对象状态
|
||||
*/
|
||||
private String state;
|
||||
}
|
@ -9,6 +9,7 @@ import org.springframework.data.mongodb.core.index.Indexed;
|
||||
import org.springframework.data.mongodb.core.mapping.DBRef;
|
||||
import org.springframework.data.mongodb.core.mapping.Document;
|
||||
|
||||
|
||||
import java.util.*;
|
||||
|
||||
/**
|
||||
|
@ -30,11 +30,6 @@ public class Operation {
|
||||
@DBRef
|
||||
private User user;
|
||||
|
||||
/**
|
||||
* 版本信息
|
||||
*/
|
||||
private String version;
|
||||
|
||||
/**
|
||||
* 备注
|
||||
*/
|
||||
@ -46,45 +41,51 @@ public class Operation {
|
||||
private String result;
|
||||
|
||||
|
||||
public static Operation submitOp(User user, String msg, String version) {
|
||||
public static Operation submitOp(User user, String msg) {
|
||||
Operation submit = new Operation();
|
||||
submit.setType(OpTypeEnum.SUBMIT.getValue());
|
||||
submit.setTime(new Date());
|
||||
submit.setUser(user);
|
||||
submit.setVersion(version);
|
||||
submit.setMsg(msg);
|
||||
submit.setResult("提交成功");
|
||||
return submit;
|
||||
}
|
||||
|
||||
public static Operation modifyOp(User user, String msg, String version) {
|
||||
public static Operation modifyOp(User user, String msg) {
|
||||
Operation modify = new Operation();
|
||||
modify.setType(OpTypeEnum.MODIFY.getValue());
|
||||
modify.setTime(new Date());
|
||||
modify.setUser(user);
|
||||
modify.setVersion(version);
|
||||
modify.setMsg(msg);
|
||||
modify.setResult("提交修改");
|
||||
return modify;
|
||||
}
|
||||
|
||||
public static Operation deleteOp(User user, String msg, String version) {
|
||||
public static Operation modifyMetaOp(User user, String msg) {
|
||||
Operation modify = new Operation();
|
||||
modify.setType(OpTypeEnum.META.getValue());
|
||||
modify.setTime(new Date());
|
||||
modify.setUser(user);
|
||||
modify.setMsg(msg);
|
||||
modify.setResult("提交修改");
|
||||
return modify;
|
||||
}
|
||||
|
||||
public static Operation deleteOp(User user, String msg) {
|
||||
Operation delete = new Operation();
|
||||
delete.setType(OpTypeEnum.DELETE.getValue());
|
||||
delete.setTime(new Date());
|
||||
delete.setUser(user);
|
||||
delete.setVersion(version);
|
||||
delete.setMsg(msg);
|
||||
delete.setResult("删除成功");
|
||||
return delete;
|
||||
}
|
||||
|
||||
public static Operation reviewOp(User user, String msg, String version, boolean result) {
|
||||
public static Operation reviewOp(User user, String msg, boolean result) {
|
||||
Operation review = new Operation();
|
||||
review.setType(OpTypeEnum.REVIEW.getValue());
|
||||
review.setTime(new Date());
|
||||
review.setUser(user);
|
||||
review.setVersion(version);
|
||||
review.setMsg(msg);
|
||||
if (result) {
|
||||
review.setResult("审核通过");
|
||||
@ -99,7 +100,6 @@ public class Operation {
|
||||
cover.setType(OpTypeEnum.COVER.getValue());
|
||||
cover.setTime(new Date());
|
||||
cover.setUser(user);
|
||||
cover.setVersion(version);
|
||||
cover.setMsg("因重复提交覆盖");
|
||||
cover.setResult("被覆盖");
|
||||
return cover;
|
||||
|
@ -0,0 +1,30 @@
|
||||
package com.example.survey.enumeration;
|
||||
|
||||
import java.util.HashSet;
|
||||
import java.util.LinkedList;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
|
||||
/**
|
||||
* @author Pope
|
||||
*/
|
||||
|
||||
public enum MetaDataTypeEnum {
|
||||
|
||||
META_CONFIG("配置"),
|
||||
|
||||
RECORD_TEMP("流调记录"),
|
||||
|
||||
REPORT_TEMP("流调报告")
|
||||
;
|
||||
|
||||
private final String value;
|
||||
|
||||
MetaDataTypeEnum(String value) {
|
||||
this.value = value;
|
||||
}
|
||||
|
||||
public String getValue() {
|
||||
return value;
|
||||
}
|
||||
}
|
@ -28,6 +28,7 @@ public enum OpTypeEnum {
|
||||
* 覆盖
|
||||
*/
|
||||
COVER("覆盖"),
|
||||
META("修改模板"),
|
||||
;
|
||||
|
||||
private final String value;
|
||||
|
@ -9,7 +9,7 @@ public enum RecordStateEnum {
|
||||
/**
|
||||
* 已审核状态
|
||||
*/
|
||||
REVIEWED("已审核"),
|
||||
REVIEWED("已通过"),
|
||||
/**
|
||||
* 待审核状态
|
||||
*/
|
||||
|
@ -1,32 +0,0 @@
|
||||
package com.example.survey.enumeration;
|
||||
|
||||
/**
|
||||
* @author Pope
|
||||
*/
|
||||
public enum RespondentStateEnum {
|
||||
/**
|
||||
* 已调查状态
|
||||
*/
|
||||
INVESTIGATED("已调查"),
|
||||
/**
|
||||
* 未调查状态
|
||||
*/
|
||||
NOT_INVESTIGATED("未调查"),
|
||||
/**
|
||||
* 已归档
|
||||
*/
|
||||
FILED("已归档"),
|
||||
|
||||
;
|
||||
|
||||
|
||||
private final String value;
|
||||
|
||||
RespondentStateEnum(String value) {
|
||||
this.value = value;
|
||||
}
|
||||
|
||||
public String getValue() {
|
||||
return value;
|
||||
}
|
||||
}
|
@ -4,6 +4,7 @@ import com.example.survey.dto.metaData.CreateMetaDataDTO;
|
||||
import com.example.survey.dto.metaData.DeleteMetaDataDTO;
|
||||
import com.example.survey.dto.metaData.ModifyMetaDataDTO;
|
||||
import com.example.survey.entity.MetaData;
|
||||
import com.example.survey.enumeration.MetaDataTypeEnum;
|
||||
import com.example.survey.vo.MetaDataVO;
|
||||
import org.springframework.web.multipart.MultipartFile;
|
||||
|
||||
@ -27,7 +28,7 @@ public interface MetaDataService {
|
||||
* @param pageSize 页大小
|
||||
* @return 元数据名称
|
||||
*/
|
||||
List<String> listMetaDataNameLimit(String name, int currentPage, int pageSize);
|
||||
List<String> listMetaDataNameLimit(String name, String type, int currentPage, int pageSize);
|
||||
|
||||
/**
|
||||
* 根据元数据名查询数量
|
||||
@ -35,7 +36,7 @@ public interface MetaDataService {
|
||||
* @param name 元数据名
|
||||
* @return 数量
|
||||
*/
|
||||
long countMetaData(String name);
|
||||
long countMetaData(String name, String type);
|
||||
|
||||
/**
|
||||
* 获取所有元数据名字的列表
|
||||
@ -62,12 +63,4 @@ public interface MetaDataService {
|
||||
* @param deleteMetaDataDTO 删除信息
|
||||
*/
|
||||
void deleteMetaData(DeleteMetaDataDTO deleteMetaDataDTO);
|
||||
|
||||
/**
|
||||
* 给元数据绑定模板文件
|
||||
*
|
||||
* @param template 模板文件
|
||||
* @param name 元数据名
|
||||
*/
|
||||
void bindWordTemplate(MultipartFile template, String name);
|
||||
}
|
||||
|
@ -1,8 +1,10 @@
|
||||
package com.example.survey.service;
|
||||
|
||||
import com.example.survey.dto.project.AddRecordDTO;
|
||||
import com.example.survey.dto.project.CreateProjectDTO;
|
||||
import com.example.survey.dto.project.DeleteRecordDTO;
|
||||
import com.example.survey.dto.project.ModifyProjectDTO;
|
||||
import com.example.survey.dto.project.ModifyStateDTO;
|
||||
|
||||
import com.example.survey.vo.ProjectVO;
|
||||
|
||||
import java.util.List;
|
||||
@ -12,7 +14,6 @@ import java.util.List;
|
||||
*/
|
||||
public interface ProjectService {
|
||||
|
||||
|
||||
/**
|
||||
* 创建新项目
|
||||
*
|
||||
@ -20,7 +21,6 @@ public interface ProjectService {
|
||||
*/
|
||||
void createProject(CreateProjectDTO createProjectDTO);
|
||||
|
||||
|
||||
/**
|
||||
* 根据筛选条件分页查询项目
|
||||
*
|
||||
@ -30,7 +30,7 @@ public interface ProjectService {
|
||||
* @param pageSize 页大小
|
||||
* @return 项目vo
|
||||
*/
|
||||
List<ProjectVO> listProjectLimit(String name, String state, int currentPage, int pageSize);
|
||||
List<ProjectVO> listProjectLimit(String name, long date_gt, long date_lt, int currentPage, int pageSize);
|
||||
|
||||
/**
|
||||
* 根据项目名查询调查对象数量
|
||||
@ -38,23 +38,7 @@ public interface ProjectService {
|
||||
* @param name 项目名
|
||||
* @return 调查对象数量
|
||||
*/
|
||||
long countRespondent(String name);
|
||||
|
||||
/**
|
||||
* 根据项目名与调查对象状态查询调查对象数量
|
||||
*
|
||||
* @param name 项目名
|
||||
* @param respondentState 调查对象状态
|
||||
* @return 调查对象数量
|
||||
*/
|
||||
long countRespondent(String name, String respondentState);
|
||||
|
||||
/**
|
||||
* 修改项目状态
|
||||
*
|
||||
* @param modifyStateDTO 修改信息
|
||||
*/
|
||||
void modifyProjectState(ModifyStateDTO modifyStateDTO);
|
||||
long countRecord(String name);
|
||||
|
||||
/**
|
||||
* 修改项目数据
|
||||
@ -64,11 +48,16 @@ public interface ProjectService {
|
||||
void modifyProject(ModifyProjectDTO modifyProjectDTO);
|
||||
|
||||
/**
|
||||
* 根据项目吗查询数量
|
||||
* 根据项目名查询数量
|
||||
*
|
||||
* @param name 项目名
|
||||
* @param state 项目状态
|
||||
* @return 数量
|
||||
*/
|
||||
long countProject(String name, String state);
|
||||
long countProject(String name, long date_gt, long date_lt);
|
||||
|
||||
|
||||
void addRecord(AddRecordDTO addRecordDTO);
|
||||
|
||||
void deleteRecord(DeleteRecordDTO deleteRecordDTO);
|
||||
}
|
||||
|
@ -13,15 +13,6 @@ import java.util.Map;
|
||||
*/
|
||||
public interface RecordService {
|
||||
|
||||
/**
|
||||
* 根据筛选条件查询流调记录数量
|
||||
*
|
||||
* @param userPhone 用户电话号码
|
||||
* @param projectName 项目名
|
||||
* @return 符合筛选条件的调查记录数量
|
||||
*/
|
||||
long countRecord(String userPhone, String projectName);
|
||||
|
||||
|
||||
/**
|
||||
* 审核流调记录
|
||||
@ -55,8 +46,9 @@ public interface RecordService {
|
||||
* @param questionnaireNumber 问卷编号
|
||||
* @return 流调记录数量
|
||||
*/
|
||||
long countRecord(String idNumber, String userPhone, String projectName, String state, String version, String questionnaireNumber);
|
||||
|
||||
long countRecord(String idNumber, String state, String uuid,
|
||||
String templateName, String templateType,
|
||||
long submitTimeGt, long submitTimeLt, String projectName);
|
||||
/**
|
||||
* 根据筛选条件查询流调记录
|
||||
*
|
||||
@ -70,7 +62,9 @@ public interface RecordService {
|
||||
* @param pageSize 页大小
|
||||
* @return 流调记录VO
|
||||
*/
|
||||
List<RecordVO> listRecordLimit(String idNumber, String userPhone, String projectName, String state, String version, String questionnaireNumber, int currentPage, int pageSize);
|
||||
List<RecordVO> listRecordLimit(String idNumber, String state, String uuid,
|
||||
String templateName, String templateType,
|
||||
long submitTimeGt, long submitTimeLt, String projectName, int offset, int pageSize);
|
||||
|
||||
/**
|
||||
* 根据筛选条件查询流调记录的values
|
||||
@ -80,7 +74,7 @@ public interface RecordService {
|
||||
* @param version 版本号
|
||||
* @return 流调记录的values
|
||||
*/
|
||||
Map<String,Object> getRecordValues(String projectName, String idNumber, String version);
|
||||
Map<String,Object> getRecordValues(String uuid);
|
||||
|
||||
/**
|
||||
* 上传文件
|
||||
@ -104,14 +98,8 @@ public interface RecordService {
|
||||
* @param projectName 项目名
|
||||
* @param response 响应
|
||||
*/
|
||||
void record2word(String idNumber, String projectName, HttpServletResponse response);
|
||||
void record2word(String idNumber, HttpServletResponse response);
|
||||
|
||||
/**
|
||||
* 修改流调记录对应项目
|
||||
*
|
||||
* @param modifyProjectDTO 修改信息
|
||||
*/
|
||||
void modifyProject(ModifyProjectDTO modifyProjectDTO);
|
||||
|
||||
/**
|
||||
* 修改流调记录所绑定元数据
|
||||
|
@ -1,74 +0,0 @@
|
||||
package com.example.survey.service;
|
||||
|
||||
import com.example.survey.dto.respondent.*;
|
||||
import com.example.survey.vo.RespondentVO;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @author Pope
|
||||
*/
|
||||
public interface RespondentService {
|
||||
/**
|
||||
* 创建待调查对象
|
||||
*
|
||||
* @param createRespondentDTO 待调查对象信息
|
||||
* @return 是否创建成功
|
||||
*/
|
||||
void createRespondent(CreateRespondentDTO createRespondentDTO);
|
||||
|
||||
/**
|
||||
* 根据流调人员电话号码分页查询待调查对象数据
|
||||
*
|
||||
* @param userPhone 分配的人员电话号码
|
||||
* @param state 状态
|
||||
* @param idNumber 身份证号
|
||||
* @param name 调查对象姓名
|
||||
* @param phone 调查对象电话
|
||||
* @param province 省份
|
||||
* @param city 城市
|
||||
* @param county 区县
|
||||
* @param projectName 项目名
|
||||
* @param currentPage 当前页数
|
||||
* @param pageSize 页大小
|
||||
* @return 页数据
|
||||
*/
|
||||
List<RespondentVO> listRespondentLimit(String userPhone, String state, String idNumber, String name, String phone, String province, String city, String county, String projectName, int currentPage, int pageSize);
|
||||
|
||||
/**
|
||||
* 根据筛选条件查询调查对象数量
|
||||
*
|
||||
* @param userPhone 分配的人员电话号码
|
||||
* @param state 状态
|
||||
* @param idNumber 身份证号
|
||||
* @param name 调查对象姓名
|
||||
* @param phone 调查对象电话
|
||||
* @param province 省份
|
||||
* @param city 城市
|
||||
* @param county 区县
|
||||
* @param projectName 项目名
|
||||
* @return 数量
|
||||
*/
|
||||
long countRespondent(String userPhone, String state, String idNumber, String name, String phone, String province, String city, String county, String projectName);
|
||||
|
||||
/**
|
||||
* 修改调查对象信息
|
||||
*
|
||||
* @param modifyRespondentDTO 修改信息
|
||||
*/
|
||||
void modifyRespondent(ModifyRespondentDTO modifyRespondentDTO);
|
||||
|
||||
/**
|
||||
* 分配人员
|
||||
*
|
||||
* @param modifyRespondentUserDTO 绑定用户信息
|
||||
*/
|
||||
void modifyUser(ModifyRespondentUserDTO modifyRespondentUserDTO);
|
||||
|
||||
/**
|
||||
* 删除调查对象
|
||||
*
|
||||
* @param deleteRespondentDTO 删除信息
|
||||
*/
|
||||
void deleteRespondent(DeleteRespondentDTO deleteRespondentDTO);
|
||||
}
|
@ -5,6 +5,7 @@ import com.example.survey.dto.metaData.CreateMetaDataDTO;
|
||||
import com.example.survey.dto.metaData.DeleteMetaDataDTO;
|
||||
import com.example.survey.dto.metaData.ModifyMetaDataDTO;
|
||||
import com.example.survey.entity.MetaData;
|
||||
import com.example.survey.enumeration.MetaDataTypeEnum;
|
||||
import com.example.survey.enumeration.ResultEnum;
|
||||
import com.example.survey.exception.MetaDataException;
|
||||
import com.example.survey.service.MetaDataService;
|
||||
@ -43,15 +44,16 @@ public class MetaDataServiceImpl implements MetaDataService {
|
||||
MetaData metaData = new MetaData();
|
||||
metaData.setName(createMetaDataDTO.getName());
|
||||
metaData.setForm(createMetaDataDTO.getForm());
|
||||
metaData.setFieldToNameList(createMetaDataDTO.getFieldToNameList());
|
||||
metaData.setConfig(createMetaDataDTO.getConfig());
|
||||
metaData.setWordTemplate(createMetaDataDTO.getWordTemplate());
|
||||
metaData.setType(createMetaDataDTO.getType());
|
||||
// metaData.setFieldToNameList(createMetaDataDTO.getFieldToNameList());
|
||||
// metaData.setConfig(createMetaDataDTO.getConfig());
|
||||
// metaData.setWordTemplate(createMetaDataDTO.getWordTemplate());
|
||||
metaDataDao.saveMetaData(metaData);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<String> listMetaDataNameLimit(String name, int currentPage, int pageSize) {
|
||||
List<MetaData> metaDataList = metaDataDao.listMetaDataLimit(name, currentPage * pageSize, pageSize);
|
||||
public List<String> listMetaDataNameLimit(String name, String type, int currentPage, int pageSize) {
|
||||
List<MetaData> metaDataList = metaDataDao.listMetaDataLimit(name, type, currentPage * pageSize, pageSize);
|
||||
if (metaDataList == null) {
|
||||
return new ArrayList<>();
|
||||
}
|
||||
@ -61,8 +63,8 @@ public class MetaDataServiceImpl implements MetaDataService {
|
||||
}
|
||||
|
||||
@Override
|
||||
public long countMetaData(String name) {
|
||||
return metaDataDao.countMetaData(name);
|
||||
public long countMetaData(String name, String type) {
|
||||
return metaDataDao.countMetaData(name, type);
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -77,8 +79,12 @@ public class MetaDataServiceImpl implements MetaDataService {
|
||||
}
|
||||
MetaData metaData = metaDataDao.selectMetaData(modifyMetaDataDTO.getName());
|
||||
metaData.setForm(modifyMetaDataDTO.getForm());
|
||||
metaData.setFieldToNameList(modifyMetaDataDTO.getFieldToNameList());
|
||||
metaData.setConfig(modifyMetaDataDTO.getConfig());
|
||||
if(modifyMetaDataDTO.getType() != null) {
|
||||
metaData.setType(modifyMetaDataDTO.getType());
|
||||
}
|
||||
|
||||
// metaData.setFieldToNameList(modifyMetaDataDTO.getFieldToNameList());
|
||||
// metaData.setConfig(modifyMetaDataDTO.getConfig());
|
||||
metaDataDao.saveMetaData(metaData);
|
||||
}
|
||||
|
||||
@ -93,50 +99,9 @@ public class MetaDataServiceImpl implements MetaDataService {
|
||||
@Override
|
||||
public void deleteMetaData(DeleteMetaDataDTO deleteMetaDataDTO) {
|
||||
if (!metaDataDao.existMetaData(deleteMetaDataDTO.getName())) {
|
||||
throw new MetaDataException(ResultEnum.ALREADY_EXIST_METADATA);
|
||||
throw new MetaDataException(ResultEnum.NOT_EXIST_METADATA);
|
||||
}
|
||||
metaDataDao.deleteMetaData(deleteMetaDataDTO.getName());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void bindWordTemplate(MultipartFile template, String name) {
|
||||
if (!metaDataDao.existMetaData(name)) {
|
||||
throw new MetaDataException(ResultEnum.ALREADY_EXIST_METADATA);
|
||||
}
|
||||
MetaData metaData = metaDataDao.selectMetaData(name);
|
||||
|
||||
String filename = template.getOriginalFilename();
|
||||
String suffix = filename.substring(filename.lastIndexOf('.'));
|
||||
String newName = UUID.randomUUID().toString() + suffix;
|
||||
File newFile = new File(path + newName);
|
||||
|
||||
OutputStream os = null;
|
||||
InputStream is = null;
|
||||
|
||||
try {
|
||||
os = new FileOutputStream(newFile);
|
||||
is = template.getInputStream();
|
||||
|
||||
byte[] buffer = new byte[1024];
|
||||
int len;
|
||||
while ((len = is.read(buffer)) != -1) {
|
||||
os.write(buffer, 0, len);
|
||||
}
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
} finally {
|
||||
try {
|
||||
if (os != null) {
|
||||
os.close();
|
||||
}
|
||||
if (is != null) {
|
||||
is.close();
|
||||
}
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
metaData.setWordTemplate(path + newName);
|
||||
metaDataDao.saveMetaData(metaData);
|
||||
}
|
||||
}
|
||||
|
@ -2,24 +2,31 @@ package com.example.survey.service.impl;
|
||||
|
||||
import com.example.survey.dao.MetaDataDao;
|
||||
import com.example.survey.dao.ProjectDao;
|
||||
import com.example.survey.dao.RespondentDao;
|
||||
import com.example.survey.dao.RecordDao;
|
||||
import com.example.survey.dao.UserDao;
|
||||
import com.example.survey.dto.project.AddRecordDTO;
|
||||
import com.example.survey.dto.project.CreateProjectDTO;
|
||||
import com.example.survey.dto.project.DeleteRecordDTO;
|
||||
import com.example.survey.dto.project.ModifyProjectDTO;
|
||||
import com.example.survey.dto.project.ModifyStateDTO;
|
||||
|
||||
import com.example.survey.entity.MetaData;
|
||||
import com.example.survey.entity.Project;
|
||||
import com.example.survey.entity.Record;
|
||||
import com.example.survey.entity.User;
|
||||
import com.example.survey.enumeration.ProjectStateEnum;
|
||||
import com.example.survey.enumeration.ResultEnum;
|
||||
import com.example.survey.exception.MetaDataException;
|
||||
import com.example.survey.exception.ProjectException;
|
||||
import com.example.survey.exception.RecordException;
|
||||
import com.example.survey.exception.UserException;
|
||||
import com.example.survey.service.ProjectService;
|
||||
import com.example.survey.vo.ProjectVO;
|
||||
|
||||
// import org.apache.poi.ss.formula.functions.T;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
@ -32,108 +39,127 @@ public class ProjectServiceImpl implements ProjectService {
|
||||
@Autowired
|
||||
ProjectDao projectDao;
|
||||
|
||||
@Autowired
|
||||
RespondentDao respondentDao;
|
||||
|
||||
@Autowired
|
||||
MetaDataDao metaDataDao;
|
||||
|
||||
@Autowired
|
||||
UserDao userDao;
|
||||
|
||||
@Autowired
|
||||
RecordDao recordDao;
|
||||
|
||||
@Override
|
||||
public void createProject(CreateProjectDTO createProjectDTO) {
|
||||
if (!userDao.existUser(createProjectDTO.getUserPhone())) {
|
||||
throw new UserException(ResultEnum.NOT_EXIST_USER);
|
||||
}
|
||||
if (!metaDataDao.existMetaData(createProjectDTO.getMetaDataName())) {
|
||||
throw new MetaDataException(ResultEnum.NOT_EXIST_METADATA);
|
||||
}
|
||||
User user = userDao.selectUser(createProjectDTO.getUserPhone());
|
||||
MetaData metaData = metaDataDao.selectMetaData(createProjectDTO.getMetaDataName());
|
||||
|
||||
Project project = new Project();
|
||||
project.setName(createProjectDTO.getName());
|
||||
// project.setMetaData(metaData);
|
||||
project.setStartTime(createProjectDTO.getStartTime());
|
||||
project.setEndTime(createProjectDTO.getEndTime());
|
||||
project.setDetail(createProjectDTO.getDetail());
|
||||
project.setState(ProjectStateEnum.IN_PROGRESS.getValue());
|
||||
project.setDate(System.currentTimeMillis());
|
||||
User user = userDao.selectUser(createProjectDTO.getPhone());
|
||||
project.setUser(user);
|
||||
projectDao.saveProject(project);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<ProjectVO> listProjectLimit(String name, String state, int currentPage, int pageSize) {
|
||||
return projectDao.listProjectLimit(name, state, currentPage * pageSize, pageSize).stream()
|
||||
public List<ProjectVO> listProjectLimit(String name, long date_gt, long date_lt, int currentPage, int pageSize) {
|
||||
return projectDao.listProjectLimit(name, date_gt, date_lt, currentPage * pageSize, pageSize).stream()
|
||||
.map(project -> {
|
||||
ProjectVO projectVO = new ProjectVO();
|
||||
projectVO.setName(project.getName());
|
||||
projectVO.setDetail(project.getDetail());
|
||||
projectVO.setStartTime(project.getStartTime());
|
||||
projectVO.setEndTime(project.getEndTime());
|
||||
projectVO.setUsername(project.getUser().getUsername());
|
||||
// if (project.getMetaData() != null) {
|
||||
// projectVO.setMetaDataName(project.getMetaData().getName());
|
||||
// }
|
||||
projectVO.setState(project.getState());
|
||||
projectVO.setDate(project.getDate());
|
||||
projectVO.setUserName(project.getUser().getUsername());
|
||||
projectVO.setUserPhone(project.getUser().getPhone());
|
||||
projectVO.setCount(project.getCount());
|
||||
|
||||
return projectVO;
|
||||
}).collect(Collectors.toList());
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public long countRespondent(String name) {
|
||||
public long countRecord(String name) {
|
||||
if (!projectDao.existProject(name)) {
|
||||
throw new ProjectException(ResultEnum.NOT_EXIST_PROJECT);
|
||||
}
|
||||
return projectDao.selectProject(name).getRespondentCount();
|
||||
|
||||
return recordDao.countRecord(null, null, null,
|
||||
null, null, 0, 0, name);
|
||||
}
|
||||
|
||||
@Override
|
||||
public long countRespondent(String name, String respondentState) {
|
||||
if (!projectDao.existProject(name)) {
|
||||
throw new ProjectException(ResultEnum.NOT_EXIST_PROJECT);
|
||||
}
|
||||
Project project = projectDao.selectProject(name);
|
||||
return project.getNotInvestigatedRespondentCount();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void modifyProjectState(ModifyStateDTO modifyStateDTO) {
|
||||
if (!projectDao.existProject(modifyStateDTO.getName())) {
|
||||
throw new ProjectException(ResultEnum.NOT_EXIST_PROJECT);
|
||||
}
|
||||
Project project = projectDao.selectProject(modifyStateDTO.getName());
|
||||
for (ProjectStateEnum value : ProjectStateEnum.values()) {
|
||||
if (value.getValue().equals(modifyStateDTO.getState())) {
|
||||
project.setState(modifyStateDTO.getState());
|
||||
projectDao.saveProject(project);
|
||||
return;
|
||||
}
|
||||
}
|
||||
throw new ProjectException(ResultEnum.NOT_EXIST_PROJECT_STATE);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void modifyProject(ModifyProjectDTO modifyProjectDTO) {
|
||||
if (!userDao.existUser(modifyProjectDTO.getUserPhone())) {
|
||||
throw new UserException(ResultEnum.NOT_EXIST_USER);
|
||||
}
|
||||
|
||||
if (!projectDao.existProject(modifyProjectDTO.getName())) {
|
||||
throw new ProjectException(ResultEnum.NOT_EXIST_PROJECT);
|
||||
}
|
||||
User user = userDao.selectUser(modifyProjectDTO.getUserPhone());
|
||||
User user = userDao.selectUser(modifyProjectDTO.getPhone());
|
||||
Project project = projectDao.selectProject(modifyProjectDTO.getName());
|
||||
project.setDetail(modifyProjectDTO.getDetail());
|
||||
project.setStartTime(modifyProjectDTO.getStartTime());
|
||||
project.setEndTime(modifyProjectDTO.getEndTime());
|
||||
project.setUser(user);
|
||||
projectDao.saveProject(project);
|
||||
}
|
||||
|
||||
@Override
|
||||
public long countProject(String name, String state) {
|
||||
return projectDao.countProject(name, state);
|
||||
public long countProject(String name, long date_gt, long date_lt) {
|
||||
return projectDao.countProject(name, date_gt, date_lt);
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addRecord(AddRecordDTO addRecordDTO) {
|
||||
if(!projectDao.existProject(addRecordDTO.getName()))
|
||||
{
|
||||
throw new ProjectException(ResultEnum.NOT_EXIST_PROJECT);
|
||||
}
|
||||
if(!recordDao.existRecord(addRecordDTO.getUuid()))
|
||||
{
|
||||
throw new RecordException(ResultEnum.NOT_EXIST_RECORD);
|
||||
}
|
||||
|
||||
Project project = projectDao.selectProject(addRecordDTO.getName());
|
||||
|
||||
Record record = recordDao.getRecord(addRecordDTO.getUuid());
|
||||
List<String> t = record.getProjectList();
|
||||
if(t == null) {
|
||||
t = new ArrayList<>();
|
||||
}
|
||||
if(!t.contains(project.getName()))
|
||||
{
|
||||
t.add(project.getName());
|
||||
record.setProjectList(t);
|
||||
recordDao.saveRecord(record);
|
||||
project.setCount(project.getCount() + 1);
|
||||
projectDao.saveProject(project);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void deleteRecord(DeleteRecordDTO deleteRecordDTO) {
|
||||
if(!projectDao.existProject(deleteRecordDTO.getName()))
|
||||
{
|
||||
throw new ProjectException(ResultEnum.NOT_EXIST_PROJECT);
|
||||
}
|
||||
if(!recordDao.existRecord(deleteRecordDTO.getUuid()))
|
||||
{
|
||||
throw new RecordException(ResultEnum.NOT_EXIST_RECORD);
|
||||
}
|
||||
|
||||
Project project = projectDao.selectProject(deleteRecordDTO.getName());
|
||||
|
||||
Record record = recordDao.getRecord(deleteRecordDTO.getUuid());
|
||||
List<String> t = record.getProjectList();
|
||||
if(t == null) {
|
||||
return;
|
||||
}
|
||||
if(t.contains(project.getName()))
|
||||
{
|
||||
// List<String> t = record.getProjectList();
|
||||
t.remove(project.getName());
|
||||
record.setProjectList(t);
|
||||
recordDao.saveRecord(record);
|
||||
project.setCount(project.getCount() - 1);
|
||||
projectDao.saveProject(project);
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
@ -5,7 +5,7 @@ import com.example.survey.dto.record.*;
|
||||
import com.example.survey.entity.*;
|
||||
import com.example.survey.entity.inner.Operation;
|
||||
import com.example.survey.enumeration.RecordStateEnum;
|
||||
import com.example.survey.enumeration.RespondentStateEnum;
|
||||
|
||||
import com.example.survey.enumeration.ResultEnum;
|
||||
import com.example.survey.exception.*;
|
||||
import com.example.survey.service.RecordService;
|
||||
@ -33,13 +33,9 @@ import java.util.stream.Collectors;
|
||||
@Service
|
||||
public class RecordServiceImpl implements RecordService {
|
||||
|
||||
|
||||
@Autowired
|
||||
private RecordDao recordDao;
|
||||
|
||||
@Autowired
|
||||
private RespondentDao respondentDao;
|
||||
|
||||
@Autowired
|
||||
private UserDao userDao;
|
||||
|
||||
@ -55,18 +51,6 @@ public class RecordServiceImpl implements RecordService {
|
||||
@Value("${file.url}")
|
||||
private String url;
|
||||
|
||||
@Override
|
||||
public long countRecord(String userPhone, String projectName) {
|
||||
if (userPhone != null && !userDao.existUser(userPhone)) {
|
||||
throw new UserException(ResultEnum.NOT_EXIST_USER);
|
||||
}
|
||||
if (projectName != null && !projectDao.existProject(projectName)) {
|
||||
throw new ProjectException(ResultEnum.NOT_EXIST_PROJECT);
|
||||
}
|
||||
User user = userDao.selectUser(userPhone);
|
||||
Project project = projectDao.selectProject(projectName);
|
||||
return recordDao.countRecord(null, user, project, RecordStateEnum.UNDER_REVIEW.getValue(), null, null);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void reviewRecord(ReviewRecordDTO reviewRecordDTO) {
|
||||
@ -74,23 +58,15 @@ public class RecordServiceImpl implements RecordService {
|
||||
throw new UserException(ResultEnum.NOT_EXIST_USER);
|
||||
}
|
||||
User user = userDao.selectUser(reviewRecordDTO.getReviewerPhone());
|
||||
if (!projectDao.existProject(reviewRecordDTO.getProjectName())) {
|
||||
throw new ProjectException(ResultEnum.NOT_EXIST_PROJECT);
|
||||
}
|
||||
Project project = projectDao.selectProject(reviewRecordDTO.getProjectName());
|
||||
if (!respondentDao.existRespondent(reviewRecordDTO.getIdNumber(), project, RespondentStateEnum.INVESTIGATED.getValue())) {
|
||||
throw new RespondentException(ResultEnum.NOT_EXIST_RESPONDENT);
|
||||
}
|
||||
Respondent respondent = respondentDao.selectRespondent(reviewRecordDTO.getIdNumber(), project);
|
||||
if (!recordDao.existRecord(respondent, project, RecordStateEnum.UNDER_REVIEW.getValue())) {
|
||||
|
||||
if (!recordDao.existRecord(reviewRecordDTO.getUuid())) {
|
||||
throw new RecordException(ResultEnum.NOT_EXIST_RECORD);
|
||||
}
|
||||
Record record = recordDao.getRecord(respondent, project, RecordStateEnum.UNDER_REVIEW.getValue());
|
||||
|
||||
Record record = recordDao.getRecord( reviewRecordDTO.getUuid());
|
||||
|
||||
record.setState(reviewRecordDTO.getPass() ? RecordStateEnum.REVIEWED.getValue() : RecordStateEnum.NOT_PASS.getValue());
|
||||
record.setVersion(UUID.randomUUID().toString());
|
||||
Operation reviewOp = Operation.reviewOp(user, reviewRecordDTO.getMsg(), record.getVersion(), reviewRecordDTO.getPass());
|
||||
// record.setVersion(UUID.randomUUID().toString());
|
||||
Operation reviewOp = Operation.reviewOp(user, reviewRecordDTO.getMsg(), reviewRecordDTO.getPass());
|
||||
List<Operation> opList = record.getOperationList();
|
||||
opList.add(reviewOp);
|
||||
record.setOperationList(opList);
|
||||
@ -104,44 +80,18 @@ public class RecordServiceImpl implements RecordService {
|
||||
throw new UserException(ResultEnum.NOT_EXIST_USER);
|
||||
}
|
||||
User user = userDao.selectUser(modifyRecordDTO.getUserPhone());
|
||||
if (!projectDao.existProject(modifyRecordDTO.getProjectName())) {
|
||||
throw new ProjectException(ResultEnum.NOT_EXIST_PROJECT);
|
||||
}
|
||||
Project project = projectDao.selectProject(modifyRecordDTO.getProjectName());
|
||||
if (!respondentDao.existRespondent(modifyRecordDTO.getIdNumber(), project, RespondentStateEnum.INVESTIGATED.getValue())) {
|
||||
throw new RespondentException(ResultEnum.NOT_EXIST_RESPONDENT);
|
||||
}
|
||||
Respondent respondent = respondentDao.selectRespondent(modifyRecordDTO.getIdNumber(), project);
|
||||
|
||||
List<String> stateList = new ArrayList<>();
|
||||
stateList.add(RecordStateEnum.UNDER_REVIEW.getValue());
|
||||
stateList.add(RecordStateEnum.REVIEWED.getValue());
|
||||
Record record = recordDao.selectRecord(respondent, project, stateList);
|
||||
Record record = recordDao.getRecord(modifyRecordDTO.getUuid());
|
||||
if (record == null) {
|
||||
throw new RecordException(ResultEnum.NOT_EXIST_RECORD);
|
||||
}
|
||||
List<Operation> operationList = record.getOperationList();
|
||||
Operation modifyOp = Operation.modifyOp(user, modifyRecordDTO.getMsg());
|
||||
operationList.add(modifyOp);
|
||||
|
||||
String newVersion = UUID.randomUUID().toString();
|
||||
List<Operation> oldOperationList = record.getOperationList();
|
||||
List<Operation> newOperationList = record.getOperationList();
|
||||
|
||||
Operation coverOp = Operation.coverOp(user, newVersion);
|
||||
oldOperationList.add(coverOp);
|
||||
|
||||
Operation modifyOp = Operation.modifyOp(user, modifyRecordDTO.getMsg(), newVersion);
|
||||
newOperationList.add(modifyOp);
|
||||
|
||||
record.setOperationList(oldOperationList);
|
||||
record.setState(RecordStateEnum.FILED.getValue());
|
||||
recordDao.saveRecord(record);
|
||||
|
||||
record.setId(null);
|
||||
record.setValues(modifyRecordDTO.getValues());
|
||||
record.setOperationList(newOperationList);
|
||||
record.setOperationList(operationList);
|
||||
record.setState(RecordStateEnum.UNDER_REVIEW.getValue());
|
||||
|
||||
recordDao.saveRecord(record);
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -150,128 +100,67 @@ public class RecordServiceImpl implements RecordService {
|
||||
throw new UserException(ResultEnum.NOT_EXIST_USER);
|
||||
}
|
||||
User user = userDao.selectUser(submitRecordDTO.getUserPhone());
|
||||
if (!projectDao.existProject(submitRecordDTO.getProjectName())) {
|
||||
throw new ProjectException(ResultEnum.NOT_EXIST_PROJECT);
|
||||
}
|
||||
Project project = projectDao.selectProject(submitRecordDTO.getProjectName());
|
||||
|
||||
if (!metaDataDao.existMetaData(submitRecordDTO.getMetaDataName())) {
|
||||
throw new MetaDataException(ResultEnum.NOT_EXIST_METADATA);
|
||||
}
|
||||
MetaData metaData = metaDataDao.selectMetaData(submitRecordDTO.getMetaDataName());
|
||||
if (!respondentDao.existRespondent(submitRecordDTO.getIdNumber(), project)) {
|
||||
throw new RespondentException(ResultEnum.NOT_EXIST_RESPONDENT);
|
||||
}
|
||||
Respondent respondent = respondentDao.selectRespondent(submitRecordDTO.getIdNumber(), project);
|
||||
//设置调查对象为已调查
|
||||
respondent.setState(RespondentStateEnum.INVESTIGATED.getValue());
|
||||
respondentDao.saveRespondent(respondent);
|
||||
Record record = new Record();
|
||||
|
||||
List<String> stateList = new ArrayList<>();
|
||||
stateList.add(RecordStateEnum.UNDER_REVIEW.getValue());
|
||||
stateList.add(RecordStateEnum.REVIEWED.getValue());
|
||||
Record record = recordDao.selectRecord(respondent, project, stateList);
|
||||
|
||||
String newVersion = UUID.randomUUID().toString();
|
||||
List<Operation> oldOperationList = new ArrayList<>();
|
||||
List<Operation> newOperationList = new ArrayList<>();
|
||||
|
||||
if (record != null) {
|
||||
oldOperationList = record.getOperationList();
|
||||
newOperationList = record.getOperationList();
|
||||
Operation coverOp = Operation.coverOp(user, newVersion);
|
||||
oldOperationList.add(coverOp);
|
||||
record.setOperationList(oldOperationList);
|
||||
record.setState(RecordStateEnum.FILED.getValue());
|
||||
recordDao.saveRecord(record);
|
||||
} else {
|
||||
record = new Record();
|
||||
}
|
||||
|
||||
record.setProject(project);
|
||||
record.setUser(user);
|
||||
record.setValues(submitRecordDTO.getValues());
|
||||
Operation submitOp = Operation.submitOp(user, submitRecordDTO.getMsg(), newVersion);
|
||||
newOperationList.add(submitOp);
|
||||
record.setOperationList(newOperationList);
|
||||
Operation submitOp = Operation.submitOp(user, submitRecordDTO.getMsg());
|
||||
List<Operation> operations = new ArrayList<>();
|
||||
operations.add(submitOp);
|
||||
record.setOperationList(operations);
|
||||
record.setUuid(submitRecordDTO.getUuid());
|
||||
record.setIdNumber(submitRecordDTO.getIdNumber());
|
||||
record.setState(RecordStateEnum.UNDER_REVIEW.getValue());
|
||||
record.setMetaData(metaData);
|
||||
record.setVersion(newVersion);
|
||||
record.setMetaDataType(metaData.getType());
|
||||
record.setSubmitTime(System.currentTimeMillis());
|
||||
recordDao.saveRecord(record);
|
||||
}
|
||||
|
||||
@Override
|
||||
public long countRecord(String idNumber, String userPhone, String projectName, String state, String version, String questionnaireNumber) {
|
||||
if (projectName != null && !projectDao.existProject(projectName)) {
|
||||
throw new ProjectException(ResultEnum.NOT_EXIST_PROJECT);
|
||||
}
|
||||
Project project = projectDao.selectProject(projectName);
|
||||
public long countRecord(String idNumber, String state, String uuid,
|
||||
String templateName, String templateType,
|
||||
long submitTimeGt, long submitTimeLt, String projectName) {
|
||||
|
||||
if (userPhone != null && !userDao.existUser(userPhone)) {
|
||||
throw new UserException(ResultEnum.NOT_EXIST_USER);
|
||||
}
|
||||
User user = userDao.selectUser(userPhone);
|
||||
|
||||
if (idNumber != null && !respondentDao.existRespondent(idNumber, project)) {
|
||||
throw new RespondentException(ResultEnum.NOT_EXIST_RESPONDENT);
|
||||
}
|
||||
|
||||
Respondent respondent = respondentDao.selectRespondent(idNumber, project);
|
||||
|
||||
|
||||
return recordDao.countRecord(respondent, user, project, state, version, questionnaireNumber);
|
||||
return recordDao.countRecord(idNumber, state, uuid, templateName, templateType, submitTimeGt, submitTimeLt, projectName);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<RecordVO> listRecordLimit(String idNumber, String userPhone, String projectName, String state, String version, String questionnaireNumber, int currentPage, int pageSize) {
|
||||
if (userPhone != null && !userDao.existUser(userPhone)) {
|
||||
throw new UserException(ResultEnum.NOT_EXIST_USER);
|
||||
}
|
||||
User user = userDao.selectUser(userPhone);
|
||||
public List<RecordVO> listRecordLimit(String idNumber, String state, String uuid,
|
||||
String templateName, String templateType,
|
||||
long submitTimeGt, long submitTimeLt, String projectName, int currentPage, int pageSize) {
|
||||
|
||||
if (projectName != null && !projectDao.existProject(projectName)) {
|
||||
throw new ProjectException(ResultEnum.NOT_EXIST_PROJECT);
|
||||
}
|
||||
Project project = projectDao.selectProject(projectName);
|
||||
|
||||
if (idNumber != null && !respondentDao.existRespondent(idNumber, project)) {
|
||||
throw new RespondentException(ResultEnum.NOT_EXIST_RESPONDENT);
|
||||
}
|
||||
Respondent respondent = respondentDao.selectRespondent(idNumber, project);
|
||||
|
||||
|
||||
List<Record> recordList = recordDao.listRecordLimit(respondent, user, project, state, version, questionnaireNumber, currentPage * pageSize, pageSize);
|
||||
List<Record> recordList = recordDao.listRecordLimit(idNumber, state, uuid, templateName, templateType, submitTimeGt, submitTimeLt, projectName, currentPage * pageSize, pageSize);
|
||||
return recordList.stream().map(record -> {
|
||||
RecordVO recordVO = new RecordVO();
|
||||
recordVO.setIdNumber(record.getRespondent().getIdNumber());
|
||||
recordVO.setUserPhone(record.getUser().getPhone());
|
||||
recordVO.setProjectName(record.getProject().getName());
|
||||
recordVO.setIdNumber(record.getIdNumber());
|
||||
recordVO.setUuid(record.getUuid());
|
||||
recordVO.setTemplate(record.getMetaData().getName());
|
||||
recordVO.setOperationInfoList(record.getOperationList().stream().map(op -> {
|
||||
OperationInfo operationInfo = new OperationInfo();
|
||||
operationInfo.setType(op.getType());
|
||||
operationInfo.setTime(op.getTime());
|
||||
operationInfo.setUserPhone(op.getUser().getPhone());
|
||||
operationInfo.setPersonId(op.getUser().getPhone());
|
||||
operationInfo.setPersonName(op.getUser().getUsername());
|
||||
operationInfo.setMsg(op.getMsg());
|
||||
operationInfo.setResult(op.getResult());
|
||||
operationInfo.setVersion(op.getVersion());
|
||||
return operationInfo;
|
||||
}).collect(Collectors.toList()));
|
||||
recordVO.setVersion(record.getVersion());
|
||||
recordVO.setState(record.getState());
|
||||
recordVO.setSubmitTime(record.getSubmitTime());
|
||||
return recordVO;
|
||||
}).collect(Collectors.toList());
|
||||
}
|
||||
|
||||
@Override
|
||||
public Map<String, Object> getRecordValues(String projectName, String idNumber, String version) {
|
||||
if (!projectDao.existProject(projectName)) {
|
||||
throw new ProjectException(ResultEnum.NOT_EXIST_PROJECT);
|
||||
}
|
||||
Project project = projectDao.selectProject(projectName);
|
||||
if (!respondentDao.existRespondent(idNumber, project)) {
|
||||
throw new RespondentException(ResultEnum.NOT_EXIST_RESPONDENT);
|
||||
}
|
||||
Respondent respondent = respondentDao.selectRespondent(idNumber, project);
|
||||
Record record = recordDao.selectRecord(respondent, project, version);
|
||||
public Map<String, Object> getRecordValues(String uuid) {
|
||||
|
||||
Record record = recordDao.getRecord(uuid);
|
||||
if (record == null) {
|
||||
throw new RecordException(ResultEnum.NOT_EXIST_RECORD);
|
||||
}
|
||||
@ -317,29 +206,17 @@ public class RecordServiceImpl implements RecordService {
|
||||
|
||||
@Override
|
||||
public void deleteRecord(DeleteRecordDTO deleteRecordDTO) {
|
||||
if (!userDao.existUser(deleteRecordDTO.getUserPhone())) {
|
||||
if (!userDao.existUser(deleteRecordDTO.getPhone())) {
|
||||
throw new UserException(ResultEnum.NOT_EXIST_USER);
|
||||
}
|
||||
User user = userDao.selectUser(deleteRecordDTO.getUserPhone());
|
||||
if (!projectDao.existProject(deleteRecordDTO.getProjectName())) {
|
||||
throw new ProjectException(ResultEnum.NOT_EXIST_PROJECT);
|
||||
}
|
||||
Project project = projectDao.selectProject(deleteRecordDTO.getProjectName());
|
||||
if (!respondentDao.existRespondent(deleteRecordDTO.getIdNumber(), project)) {
|
||||
throw new RespondentException(ResultEnum.NOT_EXIST_RESPONDENT);
|
||||
}
|
||||
Respondent respondent = respondentDao.selectRespondent(deleteRecordDTO.getIdNumber(), project);
|
||||
User user = userDao.selectUser(deleteRecordDTO.getPhone());
|
||||
|
||||
List<String> stateList = new ArrayList<>();
|
||||
stateList.add(RecordStateEnum.UNDER_REVIEW.getValue());
|
||||
stateList.add(RecordStateEnum.REVIEWED.getValue());
|
||||
stateList.add(RecordStateEnum.NOT_PASS.getValue());
|
||||
Record record = recordDao.selectRecord(respondent, project, stateList);
|
||||
Record record = recordDao.getRecord(deleteRecordDTO.getUuid());
|
||||
if (record == null) {
|
||||
throw new RecordException(ResultEnum.NOT_EXIST_RECORD);
|
||||
}
|
||||
List<Operation> operationList = record.getOperationList();
|
||||
Operation deleteOp = Operation.deleteOp(user, deleteRecordDTO.getMsg(), record.getVersion());
|
||||
Operation deleteOp = Operation.deleteOp(user, deleteRecordDTO.getMsg());
|
||||
operationList.add(deleteOp);
|
||||
record.setOperationList(operationList);
|
||||
record.setState(RecordStateEnum.FILED.getValue());
|
||||
@ -347,70 +224,37 @@ public class RecordServiceImpl implements RecordService {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void record2word(String idNumber, String projectName, HttpServletResponse response) {
|
||||
//TODO 导出为word
|
||||
}
|
||||
public void record2word(String uuid, HttpServletResponse response) {
|
||||
Record record = recordDao.getRecord(uuid);
|
||||
|
||||
@Override
|
||||
public void modifyProject(ModifyProjectDTO modifyProjectDTO) {
|
||||
if (!projectDao.existProject(modifyProjectDTO.getProjectName())) {
|
||||
throw new ProjectException(ResultEnum.NOT_EXIST_PROJECT);
|
||||
}
|
||||
Project project = projectDao.selectProject(modifyProjectDTO.getProjectName());
|
||||
if(!projectDao.existProject(modifyProjectDTO.getNewProjectName())){
|
||||
throw new ProjectException(ResultEnum.NOT_EXIST_PROJECT);
|
||||
}
|
||||
Project newProject = projectDao.selectProject(modifyProjectDTO.getNewProjectName());
|
||||
if (!respondentDao.existRespondent(modifyProjectDTO.getIdNumber(), project)) {
|
||||
throw new RespondentException(ResultEnum.NOT_EXIST_RESPONDENT);
|
||||
}
|
||||
Respondent respondent = respondentDao.selectRespondent(modifyProjectDTO.getIdNumber(), project);
|
||||
|
||||
List<String> states = new ArrayList<>();
|
||||
states.add(RecordStateEnum.REVIEWED.getValue());
|
||||
states.add(RecordStateEnum.UNDER_REVIEW.getValue());
|
||||
Record record = recordDao.selectRecord(respondent, project, states);
|
||||
|
||||
//如果新项目已经存在调查对象则覆盖
|
||||
respondent.setId(null);
|
||||
respondent.setPhone(modifyProjectDTO.getPhone());
|
||||
respondent.setName(modifyProjectDTO.getName());
|
||||
respondent.setMsg(modifyProjectDTO.getMsg());
|
||||
respondent.setGender(modifyProjectDTO.getGender());
|
||||
respondent.setAdministrativeArea(modifyProjectDTO.getAdministrativeArea());
|
||||
respondent.setProject(newProject);
|
||||
if(respondentDao.existRespondent(modifyProjectDTO.getIdNumber(),newProject)){
|
||||
respondent.setId(respondentDao.selectRespondent(modifyProjectDTO.getIdNumber(), project).getId());
|
||||
}
|
||||
respondentDao.saveRespondent(respondent);
|
||||
|
||||
record.setRespondent(respondent);
|
||||
record.setProject(project);
|
||||
recordDao.saveRecord(record);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void modifyMetaData(ModifyMetaDataDTO modifyMetaDataDTO) {
|
||||
if (!projectDao.existProject(modifyMetaDataDTO.getProjectName())) {
|
||||
throw new ProjectException(ResultEnum.NOT_EXIST_PROJECT);
|
||||
}
|
||||
Project project = projectDao.selectProject(modifyMetaDataDTO.getProjectName());
|
||||
|
||||
if (!metaDataDao.existMetaData(modifyMetaDataDTO.getMetaDataName())) {
|
||||
throw new MetaDataException(ResultEnum.NOT_EXIST_METADATA);
|
||||
}
|
||||
MetaData metaData = metaDataDao.selectMetaData(modifyMetaDataDTO.getMetaDataName());
|
||||
if (!respondentDao.existRespondent(modifyMetaDataDTO.getIdNumber(), project)) {
|
||||
throw new RespondentException(ResultEnum.NOT_EXIST_RESPONDENT);
|
||||
}
|
||||
Respondent respondent = respondentDao.selectRespondent(modifyMetaDataDTO.getIdNumber(), project);
|
||||
|
||||
List<String> states = new ArrayList<>();
|
||||
states.add(RecordStateEnum.REVIEWED.getValue());
|
||||
states.add(RecordStateEnum.UNDER_REVIEW.getValue());
|
||||
Record record = recordDao.selectRecord(respondent, project, states);
|
||||
Record record = recordDao.getRecord(modifyMetaDataDTO.getUuid());
|
||||
if(record == null) {
|
||||
throw new RecordException(ResultEnum.NOT_EXIST_RECORD);
|
||||
}
|
||||
|
||||
if (!userDao.existUser(modifyMetaDataDTO.getPhone())) {
|
||||
throw new UserException(ResultEnum.NOT_EXIST_USER);
|
||||
}
|
||||
User user = userDao.selectUser(modifyMetaDataDTO.getPhone());
|
||||
|
||||
List<Operation> operationList = record.getOperationList();
|
||||
String msg = record.getMetaData().getName() +"->" + modifyMetaDataDTO.getMetaDataName();
|
||||
Operation modifyMetaOp = Operation.modifyMetaOp(user, msg);
|
||||
// modifyMetaOp.setMsg();
|
||||
operationList.add(modifyMetaOp);
|
||||
record.setOperationList(operationList);
|
||||
record.setMetaData(metaData);
|
||||
recordDao.saveRecord(record);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
@ -1,175 +0,0 @@
|
||||
package com.example.survey.service.impl;
|
||||
|
||||
import com.example.survey.dao.ProjectDao;
|
||||
import com.example.survey.dao.RespondentDao;
|
||||
import com.example.survey.dao.UserDao;
|
||||
import com.example.survey.dto.respondent.CreateRespondentDTO;
|
||||
import com.example.survey.dto.respondent.DeleteRespondentDTO;
|
||||
import com.example.survey.dto.respondent.ModifyRespondentDTO;
|
||||
import com.example.survey.dto.respondent.ModifyRespondentUserDTO;
|
||||
import com.example.survey.entity.Project;
|
||||
import com.example.survey.entity.Respondent;
|
||||
import com.example.survey.entity.User;
|
||||
import com.example.survey.enumeration.RespondentStateEnum;
|
||||
import com.example.survey.enumeration.ResultEnum;
|
||||
import com.example.survey.exception.ProjectException;
|
||||
import com.example.survey.exception.RespondentException;
|
||||
import com.example.survey.exception.UserException;
|
||||
import com.example.survey.service.RespondentService;
|
||||
import com.example.survey.vo.RespondentVO;
|
||||
import com.example.survey.vo.inner.UserInfo;
|
||||
import lombok.extern.log4j.Log4j2;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
/**
|
||||
* @author Pope
|
||||
*/
|
||||
@Log4j2
|
||||
@Service
|
||||
public class RespondentServiceImpl implements RespondentService {
|
||||
|
||||
@Autowired
|
||||
private RespondentDao respondentDao;
|
||||
|
||||
@Autowired
|
||||
private ProjectDao projectDao;
|
||||
|
||||
@Autowired
|
||||
private UserDao userDao;
|
||||
|
||||
@Override
|
||||
public void createRespondent(CreateRespondentDTO createRespondentDTO) {
|
||||
if (!projectDao.existProject(createRespondentDTO.getProjectName())) {
|
||||
throw new ProjectException(ResultEnum.NOT_EXIST_PROJECT);
|
||||
}
|
||||
if (!userDao.existUser(createRespondentDTO.getUserPhone())) {
|
||||
throw new UserException(ResultEnum.NOT_EXIST_USER);
|
||||
}
|
||||
Project project = projectDao.selectProject(createRespondentDTO.getProjectName());
|
||||
User user = userDao.selectUser(createRespondentDTO.getPhone());
|
||||
|
||||
Respondent respondent = new Respondent();
|
||||
respondent.setIdNumber(createRespondentDTO.getIdNumber());
|
||||
respondent.setPhone(createRespondentDTO.getPhone());
|
||||
respondent.setName(createRespondentDTO.getName());
|
||||
respondent.setGender(createRespondentDTO.getGender());
|
||||
respondent.setMsg(createRespondentDTO.getMsg());
|
||||
respondent.setAdministrativeArea(createRespondentDTO.getAdministrativeArea());
|
||||
respondent.setProject(project);
|
||||
respondent.setUser(user);
|
||||
respondent.setState(RespondentStateEnum.NOT_INVESTIGATED.getValue());
|
||||
respondentDao.saveRespondent(respondent);
|
||||
|
||||
project.setRespondentCount(project.getRespondentCount() + 1);
|
||||
project.setNotInvestigatedRespondentCount(project.getNotInvestigatedRespondentCount() + 1);
|
||||
projectDao.saveProject(project);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<RespondentVO> listRespondentLimit(String userPhone, String state, String idNumber, String name, String phone, String province, String city, String county, String projectName, int currentPage, int pageSize) {
|
||||
if (userPhone != null && !userDao.existUser(userPhone)) {
|
||||
throw new UserException(ResultEnum.NOT_EXIST_USER);
|
||||
}
|
||||
if (projectName != null && !projectDao.existProject(projectName)) {
|
||||
throw new ProjectException(ResultEnum.NOT_EXIST_PROJECT);
|
||||
}
|
||||
User tmpUser = userDao.selectUser(userPhone);
|
||||
Project tmpProject = projectDao.selectProject(projectName);
|
||||
|
||||
List<Respondent> respondentList = respondentDao.listRespondentLimit(tmpUser, state, idNumber, name, phone, province, city, county, tmpProject, currentPage * pageSize, pageSize);
|
||||
if (respondentList == null) {
|
||||
return new ArrayList<>();
|
||||
}
|
||||
return respondentList.stream().map(respondent -> {
|
||||
RespondentVO respondentVO = new RespondentVO();
|
||||
respondentVO.setIdNumber(respondent.getIdNumber());
|
||||
respondentVO.setPhone(respondent.getPhone());
|
||||
respondentVO.setName(respondent.getName());
|
||||
respondentVO.setMsg(respondent.getMsg());
|
||||
respondentVO.setGender(respondent.getGender());
|
||||
respondentVO.setAdministrativeArea(respondent.getAdministrativeArea());
|
||||
respondentVO.setProjectName(respondent.getProject().getName());
|
||||
respondentVO.setState(respondent.getState());
|
||||
User user = respondent.getUser();
|
||||
if (user != null) {
|
||||
UserInfo userInfo = new UserInfo();
|
||||
userInfo.setIdNumber(user.getIdNumber());
|
||||
userInfo.setUsername(user.getUsername());
|
||||
userInfo.setPhone(user.getPhone());
|
||||
respondentVO.setUserInfo(userInfo);
|
||||
}
|
||||
return respondentVO;
|
||||
}).collect(Collectors.toList());
|
||||
}
|
||||
|
||||
@Override
|
||||
public long countRespondent(String userPhone, String state, String idNumber, String name, String phone, String province, String city, String county, String projectName) {
|
||||
if (userPhone != null && !userDao.existUser(userPhone)) {
|
||||
throw new UserException(ResultEnum.NOT_EXIST_USER);
|
||||
}
|
||||
if (projectName != null && !projectDao.existProject(projectName)) {
|
||||
throw new ProjectException(ResultEnum.NOT_EXIST_PROJECT);
|
||||
}
|
||||
User user = userDao.selectUser(userPhone);
|
||||
Project project = projectDao.selectProject(projectName);
|
||||
return respondentDao.countRespondent(user, state, idNumber, name, phone, province, city, county, project);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void modifyRespondent(ModifyRespondentDTO modifyRespondentDTO) {
|
||||
if (!projectDao.existProject(modifyRespondentDTO.getProjectName())) {
|
||||
throw new ProjectException(ResultEnum.NOT_EXIST_PROJECT);
|
||||
}
|
||||
Project project = projectDao.selectProject(modifyRespondentDTO.getProjectName());
|
||||
if (!respondentDao.existRespondent(modifyRespondentDTO.getIdNumber(), project)) {
|
||||
throw new RespondentException(ResultEnum.NOT_EXIST_RESPONDENT);
|
||||
}
|
||||
Respondent respondent = respondentDao.selectRespondent(modifyRespondentDTO.getIdNumber(), project);
|
||||
respondent.setPhone(modifyRespondentDTO.getPhone());
|
||||
respondent.setName(modifyRespondentDTO.getName());
|
||||
respondent.setMsg(modifyRespondentDTO.getMsg());
|
||||
respondent.setGender(modifyRespondentDTO.getGender());
|
||||
respondent.setAdministrativeArea(modifyRespondentDTO.getAdministrativeArea());
|
||||
respondentDao.saveRespondent(respondent);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void modifyUser(ModifyRespondentUserDTO modifyRespondentUserDTO) {
|
||||
if (!userDao.existUser(modifyRespondentUserDTO.getUserPhone())) {
|
||||
throw new UserException(ResultEnum.NOT_EXIST_USER);
|
||||
}
|
||||
User user = userDao.selectUser(modifyRespondentUserDTO.getUserPhone());
|
||||
if (!projectDao.existProject(modifyRespondentUserDTO.getProjectName())) {
|
||||
throw new ProjectException(ResultEnum.NOT_EXIST_PROJECT);
|
||||
}
|
||||
Project project = projectDao.selectProject(modifyRespondentUserDTO.getProjectName());
|
||||
if (!respondentDao.existRespondent(modifyRespondentUserDTO.getIdNumber(), project)) {
|
||||
throw new RespondentException(ResultEnum.NOT_EXIST_RESPONDENT);
|
||||
}
|
||||
Respondent respondent = respondentDao.selectRespondent(modifyRespondentUserDTO.getIdNumber(), project);
|
||||
|
||||
respondent.setUser(user);
|
||||
respondentDao.saveRespondent(respondent);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void deleteRespondent(DeleteRespondentDTO deleteRespondentDTO) {
|
||||
if (!projectDao.existProject(deleteRespondentDTO.getProjectName())) {
|
||||
throw new ProjectException(ResultEnum.NOT_EXIST_PROJECT);
|
||||
}
|
||||
Project project = projectDao.selectProject(deleteRespondentDTO.getProjectName());
|
||||
if (!respondentDao.existRespondent(deleteRespondentDTO.getIdNumber(), project)) {
|
||||
throw new RespondentException(ResultEnum.NOT_EXIST_RESPONDENT);
|
||||
}
|
||||
Respondent respondent = respondentDao.selectRespondent(deleteRespondentDTO.getIdNumber(), project);
|
||||
respondent.setState(RespondentStateEnum.FILED.getValue());
|
||||
respondentDao.saveRespondent(respondent);
|
||||
|
||||
}
|
||||
}
|
@ -57,7 +57,7 @@ public class WordUtil {
|
||||
|
||||
public static void export2Word(HttpServletResponse response, MetaData metaData, Record record){
|
||||
Map<String, Object> values = record.getValues();
|
||||
String templatePath = metaData.getWordTemplate();
|
||||
// String templatePath = metaData.getWordTemplate();
|
||||
for (Map.Entry<String, Object> entry : metaData.getForm().entrySet()) {
|
||||
|
||||
}
|
||||
|
@ -13,6 +13,7 @@ import java.util.Map;
|
||||
public class MetaDataVO {
|
||||
private String name;
|
||||
private Map<String,Object> form;
|
||||
private List<FieldToName> fieldToNameList;
|
||||
private Map<String, Object> config;
|
||||
private String type;
|
||||
// private List<FieldToName> fieldToNameList;
|
||||
// private Map<String, Object> config;
|
||||
}
|
||||
|
@ -1,7 +1,9 @@
|
||||
package com.example.survey.vo;
|
||||
|
||||
import com.example.survey.entity.MetaData;
|
||||
import com.example.survey.entity.Respondent;
|
||||
// import com.example.survey.entity.Respondent;
|
||||
import com.fasterxml.jackson.annotation.JsonFormat;
|
||||
|
||||
import lombok.Data;
|
||||
import org.springframework.data.mongodb.core.index.Indexed;
|
||||
import org.springframework.data.mongodb.core.mapping.DBRef;
|
||||
@ -19,33 +21,11 @@ public class ProjectVO {
|
||||
*/
|
||||
private String name;
|
||||
|
||||
/**
|
||||
* 描述信息
|
||||
*/
|
||||
private String detail;
|
||||
private long date;
|
||||
|
||||
/**
|
||||
* 元数据
|
||||
*/
|
||||
private String metaDataName;
|
||||
private String userPhone;
|
||||
|
||||
/**
|
||||
* 开始时间
|
||||
*/
|
||||
private Date startTime;
|
||||
private String userName;
|
||||
|
||||
/**
|
||||
* 结束时间
|
||||
*/
|
||||
private Date endTime;
|
||||
|
||||
/**
|
||||
* 负责人姓名
|
||||
*/
|
||||
private String username;
|
||||
|
||||
/**
|
||||
* 状态
|
||||
*/
|
||||
private String state;
|
||||
private long count;
|
||||
}
|
||||
|
@ -14,15 +14,15 @@ public class RecordVO {
|
||||
|
||||
private String idNumber;
|
||||
|
||||
private String userPhone;
|
||||
// private List<String> projectList;
|
||||
|
||||
private String projectName;
|
||||
private String template;
|
||||
|
||||
private String uuid;
|
||||
|
||||
private long submitTime;
|
||||
|
||||
private List<OperationInfo> operationInfoList;
|
||||
|
||||
private String version;
|
||||
|
||||
private String state;
|
||||
|
||||
|
||||
}
|
||||
|
@ -4,6 +4,8 @@ import lombok.Data;
|
||||
|
||||
import java.util.Date;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonFormat;
|
||||
|
||||
/**
|
||||
* @author Pope
|
||||
*/
|
||||
@ -17,17 +19,15 @@ public class OperationInfo {
|
||||
/**
|
||||
* 时间
|
||||
*/
|
||||
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
|
||||
private Date time;
|
||||
|
||||
/**
|
||||
* 操作者
|
||||
*/
|
||||
private String userPhone;
|
||||
private String personId;
|
||||
|
||||
/**
|
||||
* 版本信息
|
||||
*/
|
||||
private String version;
|
||||
private String personName;
|
||||
|
||||
/**
|
||||
* 备注
|
||||
|
@ -6,7 +6,7 @@ spring:
|
||||
auto-index-creation: true
|
||||
host: 8.136.133.77
|
||||
port: 27017
|
||||
database: survey
|
||||
database: dev
|
||||
username: cveo
|
||||
password: cveo123456
|
||||
authentication-database: admin
|
||||
@ -16,5 +16,5 @@ spring:
|
||||
port: 6379
|
||||
|
||||
file:
|
||||
path: E:\
|
||||
url: E:\
|
||||
path: ./upload/
|
||||
url: /upload/
|
||||
|
Loading…
x
Reference in New Issue
Block a user