2021-4-19
修复了一些bug
This commit is contained in:
parent
dcf4b04e43
commit
9c75d90d65
1
.gitignore
vendored
1
.gitignore
vendored
@ -22,6 +22,7 @@ gen
|
||||
|
||||
# Log file
|
||||
*.log
|
||||
/log
|
||||
|
||||
# BlueJ files
|
||||
*.ctxt
|
||||
|
Binary file not shown.
Binary file not shown.
Binary file not shown.
13
pom.xml
13
pom.xml
@ -60,19 +60,18 @@
|
||||
<dependency>
|
||||
<groupId>org.apache.poi</groupId>
|
||||
<artifactId>poi</artifactId>
|
||||
<version>3.17</version>
|
||||
<version>4.1.2</version>
|
||||
</dependency>
|
||||
|
||||
<!-- https://mvnrepository.com/artifact/org.apache.poi/poi-ooxml -->
|
||||
<dependency>
|
||||
<groupId>org.apache.poi</groupId>
|
||||
<artifactId>poi-ooxml</artifactId>
|
||||
<version>3.17</version>
|
||||
<version>4.1.2</version>
|
||||
</dependency>
|
||||
<!-- https://mvnrepository.com/artifact/org.apache.poi/ooxml-schemas -->
|
||||
<dependency>
|
||||
<groupId>org.apache.poi</groupId>
|
||||
<artifactId>ooxml-schemas</artifactId>
|
||||
<version>1.1</version>
|
||||
<groupId>com.deepoove</groupId>
|
||||
<artifactId>poi-tl</artifactId>
|
||||
<version>1.9.1</version>
|
||||
</dependency>
|
||||
<dependency> <!-- 引入log4j2依赖 -->
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
|
@ -5,6 +5,7 @@ import com.example.survey.enumeration.ResultEnum;
|
||||
import com.example.survey.util.TokenUtil;
|
||||
import com.example.survey.vo.ResultVO;
|
||||
import lombok.extern.log4j.Log4j2;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
|
||||
import javax.servlet.*;
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
@ -19,16 +20,16 @@ import java.util.Set;
|
||||
* 权限过滤器
|
||||
*/
|
||||
@Log4j2
|
||||
//@Configuration
|
||||
@Configuration
|
||||
public class AuthFilterConfig implements Filter {
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* 不需要token就能访问的路由
|
||||
*/
|
||||
private static final Set<String> URIS = new HashSet<String>() {{
|
||||
add("/user/login");
|
||||
add("/user/signup");
|
||||
|
||||
}};
|
||||
|
||||
@Override
|
||||
|
@ -6,9 +6,9 @@ import com.example.survey.dto.metaData.ModifyMetaDataDTO;
|
||||
import com.example.survey.enumeration.ResultEnum;
|
||||
import com.example.survey.service.MetaDataService;
|
||||
import com.example.survey.vo.ResultVO;
|
||||
import lombok.Getter;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
import org.springframework.web.multipart.MultipartFile;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
@ -25,7 +25,7 @@ public class MetaDataController {
|
||||
|
||||
@PostMapping("/metaData")
|
||||
public ResultVO createMetaData(@RequestBody CreateMetaDataDTO createMetaDataDTO){
|
||||
metaDataService.addMetaData(createMetaDataDTO);
|
||||
metaDataService.createMetaData(createMetaDataDTO);
|
||||
return new ResultVO(ResultEnum.SUCCESS);
|
||||
}
|
||||
|
||||
@ -70,4 +70,11 @@ 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);
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -34,13 +34,14 @@ public class ProjectController {
|
||||
|
||||
@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 = "pageSize", defaultValue = "30") int pageSize) {
|
||||
Map<String, Object> resultMap = new HashMap<>(16,0.75F);
|
||||
resultMap.put("totalCount", projectService.countProject(name));
|
||||
resultMap.put("totalCount", projectService.countProject(name,state));
|
||||
resultMap.put("currentPage", currentPage);
|
||||
resultMap.put("pageSize", pageSize);
|
||||
resultMap.put("data", projectService.listProjectLimit(name, currentPage, pageSize));
|
||||
resultMap.put("data", projectService.listProjectLimit(name,state, currentPage, pageSize));
|
||||
ResultVO resultVO = new ResultVO(ResultEnum.SUCCESS);
|
||||
resultVO.setData(resultMap);
|
||||
return resultVO;
|
||||
|
@ -1,5 +1,6 @@
|
||||
package com.example.survey.controller;
|
||||
|
||||
import com.example.survey.dto.record.DeleteRecordDTO;
|
||||
import com.example.survey.dto.record.ModifyRecordDTO;
|
||||
import com.example.survey.dto.record.ReviewRecordDTO;
|
||||
import com.example.survey.dto.record.SubmitRecordDTO;
|
||||
@ -9,7 +10,9 @@ import com.example.survey.vo.ResultVO;
|
||||
import lombok.extern.log4j.Log4j2;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
import org.springframework.web.multipart.MultipartFile;
|
||||
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
@ -46,17 +49,17 @@ 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("projectName") String projectName,
|
||||
@RequestParam("idNumber") String idNumber,
|
||||
@RequestParam(value = "version", required = false) String version) {
|
||||
ResultVO resultVO = new ResultVO(ResultEnum.SUCCESS);
|
||||
resultVO.setData(recordService.getRecordValues(projectName,idNumber,version));
|
||||
resultVO.setData(recordService.getRecordValues(projectName, idNumber, version));
|
||||
return resultVO;
|
||||
}
|
||||
|
||||
@GetMapping("/underReviewRecordCount")
|
||||
public ResultVO countUnderReviewRecord(@RequestParam(value = "userPhone") String userPhone,
|
||||
@RequestParam(value = "projectName")String projectName) {
|
||||
@RequestParam(value = "projectName") String projectName) {
|
||||
ResultVO resultVo = new ResultVO(ResultEnum.SUCCESS);
|
||||
resultVo.setData(recordService.countRecord(userPhone, projectName));
|
||||
return resultVo;
|
||||
@ -81,5 +84,27 @@ public class RecordController {
|
||||
return new ResultVO(ResultEnum.SUCCESS);
|
||||
}
|
||||
|
||||
@DeleteMapping("/record")
|
||||
public ResultVO deleteRecord(@RequestBody DeleteRecordDTO deleteRecordDTO){
|
||||
recordService.deleteRecord(deleteRecordDTO);
|
||||
return new ResultVO(ResultEnum.SUCCESS);
|
||||
}
|
||||
|
||||
@PostMapping("/file")
|
||||
public ResultVO uploadFile(@RequestParam("file") MultipartFile file) {
|
||||
ResultVO resultVO = new ResultVO(ResultEnum.SUCCESS);
|
||||
resultVO.setData(recordService.uploadFile(file));
|
||||
return resultVO;
|
||||
}
|
||||
|
||||
@GetMapping("/record2word")
|
||||
public void record2word(@RequestParam("idNumber")String idNumber,
|
||||
@RequestParam("projectName")String projectName,
|
||||
HttpServletResponse response){
|
||||
recordService.record2word(idNumber,projectName,response);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
@ -37,17 +37,19 @@ public interface ProjectDao {
|
||||
* 根绝筛选条件分页查询项目
|
||||
*
|
||||
* @param name 项目名
|
||||
* @param state 状态
|
||||
* @param offset 偏移量
|
||||
* @param pageSize 页大小
|
||||
* @return 项目列表
|
||||
*/
|
||||
List<Project> listProjectLimit(String name, int offset, int pageSize);
|
||||
List<Project> listProjectLimit(String name,String state, int offset, int pageSize);
|
||||
|
||||
/**
|
||||
* 根据项目名查询数量
|
||||
*
|
||||
* @param name 项目名
|
||||
* @param state 状态
|
||||
* @return 数量
|
||||
*/
|
||||
long countProject(String name);
|
||||
long countProject(String name,String state);
|
||||
}
|
||||
|
@ -75,4 +75,13 @@ public interface RecordDao {
|
||||
* @return 流调记录
|
||||
*/
|
||||
Record selectRecord(Respondent respondent, Project project, String version);
|
||||
|
||||
/**
|
||||
* 查询流调记录列表
|
||||
*
|
||||
* @param project 项目
|
||||
* @param respondent 调查对象
|
||||
* @return 流调记录列表
|
||||
*/
|
||||
List<Record> listRecord(Project project, Respondent respondent);
|
||||
}
|
||||
|
@ -28,7 +28,7 @@ public interface RespondentDao {
|
||||
* @param province 省份
|
||||
* @param city 城市
|
||||
* @param county 区县
|
||||
* @param project 项目
|
||||
* @param project 项目
|
||||
* @param offset 偏移量
|
||||
* @param pageSize 大小
|
||||
* @return 待调查对象列表
|
||||
@ -39,18 +39,20 @@ public interface RespondentDao {
|
||||
* 判断是否存在对应id的调查对象
|
||||
*
|
||||
* @param idNumber 身份证号
|
||||
* @param project 项目
|
||||
* @return 是否存在该调查对象
|
||||
*/
|
||||
boolean existRespondent(String idNumber);
|
||||
boolean existRespondent(String idNumber, Project project);
|
||||
|
||||
/**
|
||||
* 判断是否存在符合条件的调查对象
|
||||
*
|
||||
* @param idNumber 身份证号
|
||||
* @param project 项目
|
||||
* @param state 调查对象状态
|
||||
* @return 是否存在该调查对象
|
||||
*/
|
||||
boolean existRespondent(String idNumber, String state);
|
||||
boolean existRespondent(String idNumber, Project project, String state);
|
||||
|
||||
/**
|
||||
* 根绝筛选条件获取调查对象数量
|
||||
@ -73,10 +75,10 @@ public interface RespondentDao {
|
||||
* 根据身份证号查询调查对象
|
||||
*
|
||||
* @param idNumber 身份证号
|
||||
* @param project 项目
|
||||
* @param project 项目
|
||||
* @return 调查对象
|
||||
*/
|
||||
Respondent selectRespondent(String idNumber,Project project);
|
||||
Respondent selectRespondent(String idNumber, Project project);
|
||||
|
||||
/**
|
||||
* 删除调查对象
|
||||
|
@ -45,22 +45,28 @@ public class ProjectDaoImpl implements ProjectDao {
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<Project> listProjectLimit(String name, int offset, int pageSize) {
|
||||
public List<Project> listProjectLimit(String name,String state, int offset, int pageSize) {
|
||||
Criteria criteria = new Criteria();
|
||||
if (name != null) {
|
||||
criteria.and("name").regex(name);
|
||||
}
|
||||
if(state!=null){
|
||||
criteria.and("state").is(state);
|
||||
}
|
||||
Query query = new Query(criteria).skip(offset).limit(pageSize);
|
||||
return mongoTemplate.find(query, Project.class);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public long countProject(String name) {
|
||||
public long countProject(String name,String state) {
|
||||
Criteria criteria = new Criteria();
|
||||
if (name != null) {
|
||||
criteria.and("name").regex(name);
|
||||
}
|
||||
if(state!=null){
|
||||
criteria.and("state").is(state);
|
||||
}
|
||||
Query query = new Query(criteria);
|
||||
return mongoTemplate.count(query, Project.class);
|
||||
}
|
||||
|
@ -30,7 +30,8 @@ public class RecordDaoImpl implements RecordDao {
|
||||
public boolean existRecord(Respondent respondent, Project project, String state) {
|
||||
Criteria criteria = new Criteria()
|
||||
.and("respondent.$id").is(respondent.getId())
|
||||
.elemMatch(Criteria.where("project.$id").is(project.getId()).and("state").is(state));
|
||||
.and("project.$id").is(project.getId())
|
||||
.and("state").is(state);
|
||||
Query query = new Query(criteria);
|
||||
return mongoTemplate.exists(query, Record.class);
|
||||
}
|
||||
@ -121,4 +122,12 @@ public class RecordDaoImpl implements RecordDao {
|
||||
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);
|
||||
}
|
||||
}
|
||||
|
@ -57,18 +57,15 @@ public class RespondentDaoImpl implements RespondentDao {
|
||||
if (county != null) {
|
||||
criteria.and("administrativeArea.county").is(county);
|
||||
}
|
||||
|
||||
Criteria elementMatch = new Criteria();
|
||||
if (project != null) {
|
||||
elementMatch.and("project.$id").is(project.getId());
|
||||
criteria.and("project.$id").is(project.getId());
|
||||
}
|
||||
if (user != null) {
|
||||
elementMatch.and("user.$id").is(user.getId());
|
||||
criteria.and("user.$id").is(user.getId());
|
||||
}
|
||||
if (state != null) {
|
||||
elementMatch.and("state").is(state);
|
||||
criteria.and("state").is(state);
|
||||
}
|
||||
criteria.and("projectPartSet").elemMatch(elementMatch);
|
||||
|
||||
Query query = new Query(criteria).skip(offset).limit(pageSize);
|
||||
return mongoTemplate.find(query, Respondent.class);
|
||||
@ -78,6 +75,16 @@ public class RespondentDaoImpl implements RespondentDao {
|
||||
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);
|
||||
}
|
||||
@ -87,32 +94,36 @@ public class RespondentDaoImpl implements RespondentDao {
|
||||
if (county != null) {
|
||||
criteria.and("administrativeArea.county").is(county);
|
||||
}
|
||||
|
||||
Criteria elementMatch = new Criteria();
|
||||
if (project != null) {
|
||||
elementMatch.and("project.$id").is(project.getId());
|
||||
criteria.and("project.$id").is(project.getId());
|
||||
}
|
||||
if (user != null) {
|
||||
elementMatch.and("user.$id").is(user.getId());
|
||||
criteria.and("user.$id").is(user.getId());
|
||||
}
|
||||
if (state != null) {
|
||||
elementMatch.and("state").is(state);
|
||||
criteria.and("state").is(state);
|
||||
}
|
||||
criteria.and("projectPartSet").elemMatch(elementMatch);
|
||||
|
||||
Query query = new Query(criteria);
|
||||
return mongoTemplate.count(query, Respondent.class);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean existRespondent(String idNumber) {
|
||||
Query query = new Query(Criteria.where("idNumber").is(idNumber));
|
||||
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, String state) {
|
||||
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);
|
||||
}
|
||||
@ -132,8 +143,8 @@ public class RespondentDaoImpl implements RespondentDao {
|
||||
|
||||
@Override
|
||||
public long countRespondent(Project project, String state) {
|
||||
Criteria elementMatch = Criteria.where("project.$id").is(project.getId()).and("state").is(state);
|
||||
Query query = new Query(Criteria.where("projectPartSet").elemMatch(elementMatch));
|
||||
Criteria criteria = Criteria.where("project.$id").is(project.getId()).and("state").is(state);
|
||||
Query query = new Query(criteria);
|
||||
return mongoTemplate.count(query, Respondent.class);
|
||||
}
|
||||
|
||||
|
@ -15,4 +15,5 @@ public class CreateMetaDataDTO {
|
||||
private Map<String,Object> form;
|
||||
private List<FieldToName> fieldToNameList;
|
||||
private Map<String, Object> config;
|
||||
private String wordTemplate;
|
||||
}
|
||||
|
@ -0,0 +1,17 @@
|
||||
package com.example.survey.dto.record;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
/**
|
||||
* @author Pope
|
||||
*/
|
||||
@Data
|
||||
public class DeleteRecordDTO {
|
||||
private String idNumber;
|
||||
|
||||
private String userPhone;
|
||||
|
||||
private String msg;
|
||||
|
||||
private String projectName;
|
||||
}
|
@ -5,6 +5,8 @@ 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;
|
||||
@ -17,6 +19,9 @@ import java.util.Set;
|
||||
*/
|
||||
@Data
|
||||
@Document(collection = "respondent")
|
||||
@CompoundIndexes({
|
||||
@CompoundIndex(name = "unique",def = "{idNumber : 1, project : 1}",unique = true)
|
||||
})
|
||||
public class Respondent {
|
||||
|
||||
/**
|
||||
@ -28,7 +33,6 @@ public class Respondent {
|
||||
/**
|
||||
* 身份证号
|
||||
*/
|
||||
@Indexed(unique = true)
|
||||
private String idNumber;
|
||||
|
||||
/**
|
||||
@ -59,11 +63,13 @@ public class Respondent {
|
||||
/**
|
||||
* 分配的人员
|
||||
*/
|
||||
@DBRef
|
||||
private User user;
|
||||
|
||||
/**
|
||||
* 项目
|
||||
*/
|
||||
@DBRef
|
||||
private Project project;
|
||||
|
||||
/**
|
||||
|
@ -15,141 +15,170 @@ public enum AuthEnum {
|
||||
* 管理员权限,可以访问所有接口
|
||||
*/
|
||||
ADMIN("管理员", new HashSet<String>() {{
|
||||
add("/investigator/investigator : POST");
|
||||
add("/investigationRecord/underReviewRecord : GET");
|
||||
add("/investigationRecord/underReviewRecordCount : GET");
|
||||
add("/investigationRecord/investigationRecord : POST");
|
||||
add("/investigationRecord/investigationRecord : PUT");
|
||||
add("/investigationRecord/underReviewRecord : PUT");
|
||||
add("/investigationRecord/record2word : GET");
|
||||
add("/project/projectList : GET");
|
||||
add("/project/respondentCount : GET");
|
||||
add("/project/projectState : PUT");
|
||||
add("/project/project : PUT");
|
||||
add("/project/project : POST");
|
||||
|
||||
add("/respondent/respondent : POST");
|
||||
add("/respondent/respondent : GET");
|
||||
add("/user/userRole : PUT");
|
||||
add("/user/user : GET");
|
||||
add("/user/user : DELETE");
|
||||
add("/respondent/respondent : PUT");
|
||||
add("/respondent/user : PUT");
|
||||
add("/respondent/respondent : DELETE");
|
||||
add("/respondent/respondentList : GET");
|
||||
|
||||
add("/record/record : POST");
|
||||
add("/record/recordList : GET");
|
||||
add("/record/recordValues : GET");
|
||||
add("/record/record : PUT");
|
||||
add("/record/record : DELETE");
|
||||
add("/record/underReviewRecord : PUT");
|
||||
add("/record/file : POST");
|
||||
|
||||
add("/user/userList : GET");
|
||||
add("/user/user : POST");
|
||||
add("/role/role : POST");
|
||||
add("/role/role : GET");
|
||||
add("/role/role : DELETE");
|
||||
add("/role/role : PUT");
|
||||
add("/role/authList : GET");
|
||||
add("/user/user : DELETE");
|
||||
add("/user/userInfo : PUT");
|
||||
add("/user/userRole : PUT");
|
||||
add("/user/pwd : PUT");
|
||||
|
||||
add("/role/roleList : GET");
|
||||
add("/role/role : PUT");
|
||||
add("/role/role : DELETE");
|
||||
add("/role/role : POST");
|
||||
add("/role/authorityList : GET");
|
||||
|
||||
add("/metaData/metaData : GET");
|
||||
add("/metaData/metaData : DELETE");
|
||||
add("/metaData/metaDataList : GET");
|
||||
add("/metaData/nameList : GET");
|
||||
add("/metaData/metaData : PUT");
|
||||
add("/metaData/metaData : POST");
|
||||
add("/metaData/wordTemplate : POST");
|
||||
}}),
|
||||
|
||||
/**
|
||||
* 项目
|
||||
*/
|
||||
QUERY_PROJECT("查询项目的权限", new HashSet<String>() {{
|
||||
add("/project/projectList : GET");
|
||||
add("/project/respondentCount : GET");
|
||||
}}),
|
||||
MODIFY_PROJECT("修改项目的权限", new HashSet<String>() {{
|
||||
add("/project/projectState : PUT");
|
||||
add("/project/project : PUT");
|
||||
|
||||
}}),
|
||||
CREATE_PROJECT("创建项目的权限", new HashSet<String>() {{
|
||||
add("/project/project : POST");
|
||||
}}),
|
||||
|
||||
/**
|
||||
* 调查对象
|
||||
*/
|
||||
CREATE_RESPONDENT("添加调查对象的权限", new HashSet<String>() {{
|
||||
add("/respondent/respondent : POST");
|
||||
}}),
|
||||
MODIFY_RESPONDENT("修改调查对象的权限", new HashSet<String>() {{
|
||||
add("/respondent/respondent : PUT");
|
||||
add("/respondent/user : PUT");
|
||||
}}),
|
||||
DELETE_RESPONDENT("删除调查对象的权限", new HashSet<String>() {{
|
||||
add("/respondent/respondent : DELETE");
|
||||
}}),
|
||||
QUERY_RESPONDENT("查询调查对象的权限", new HashSet<String>() {{
|
||||
add("/respondent/respondentList : GET");
|
||||
}}),
|
||||
|
||||
/**
|
||||
* 流调记录
|
||||
*/
|
||||
CREATE_RECORD("添加流调记录的权限", new HashSet<String>() {{
|
||||
add("/record/record : POST");
|
||||
}}),
|
||||
QUERY_RECORD("查询流调记录的权限", new HashSet<String>() {{
|
||||
add("/record/recordList : GET");
|
||||
}}),
|
||||
VIEW_RECORD_DETAILS("查看流调记录详情的权限", new HashSet<String>() {{
|
||||
add("/record/recordValues : GET");
|
||||
}}),
|
||||
MODIFY_RECORD("修改流调记录的权限", new HashSet<String>() {{
|
||||
add("/record/record : PUT");
|
||||
}}),
|
||||
DELETE_RECORD("删除流调记录的权限", new HashSet<String>() {{
|
||||
add("/record/record : DELETE");
|
||||
}}),
|
||||
EXAMINE_RECORD("审核流调记录的权限", new HashSet<String>() {{
|
||||
add("/record/underReviewRecord : PUT");
|
||||
}}),
|
||||
UPLOAD_RECORD_FILE("上传流调记录相关文件的权限", new HashSet<String>() {{
|
||||
add("/record/file : POST");
|
||||
}}),
|
||||
|
||||
/**
|
||||
* 用户
|
||||
*/
|
||||
QUERY_USER("查询用户的权限", new HashSet<String>() {{
|
||||
add("/user/userList : GET");
|
||||
}}),
|
||||
CREATE_USER("添加用户的权限", new HashSet<String>() {{
|
||||
add("/user/user : POST");
|
||||
}}),
|
||||
DELETE_USER("删除用户的权限", new HashSet<String>() {{
|
||||
add("/user/user : DELETE");
|
||||
}}),
|
||||
MODIFY_USER("修改用户的权限", new HashSet<String>() {{
|
||||
add("/user/userInfo : PUT");
|
||||
add("/user/userRole : PUT");
|
||||
add("/user/pwd : PUT");
|
||||
}}),
|
||||
|
||||
/**
|
||||
* 查询调查记录的权限
|
||||
* 角色
|
||||
*/
|
||||
RETRIEVE_RECORD("查询调查记录的权限", new HashSet<String>() {{
|
||||
add("/investigationRecord/underReviewRecord : GET");
|
||||
add("/investigationRecord/underReviewRecordCount : GET");
|
||||
QUERY_ROLE("查询角色的权限", new HashSet<String>() {{
|
||||
add("/role/roleList : GET");
|
||||
}}),
|
||||
|
||||
/**
|
||||
* 提交记录的权限
|
||||
*/
|
||||
CREATE_RECORD("提交调查记录权限", new HashSet<String>() {{
|
||||
add("/investigationRecord/investigationRecord : POST");
|
||||
MODIFY_ROLE("修改角色的权限", new HashSet<String>() {{
|
||||
add("/role/role : PUT");
|
||||
}}),
|
||||
|
||||
/**
|
||||
* 修改调查记录信息的权限
|
||||
*/
|
||||
UPDATE_RECORD("修改调查记录权限", new HashSet<String>() {{
|
||||
add("/investigationRecord/investigationRecord : PUT");
|
||||
}}),
|
||||
|
||||
/**
|
||||
* 审核调查记录权限
|
||||
*/
|
||||
REVIEW_RECORD("审核调查记录权限", new HashSet<String>() {{
|
||||
add("/investigationRecord/underReviewRecord : PUT");
|
||||
}}),
|
||||
|
||||
/**
|
||||
* 删除调查记录权限
|
||||
*/
|
||||
DELETE_RECORD("删除调查记录权限", new HashSet<String>() {{
|
||||
|
||||
}}),
|
||||
|
||||
/**
|
||||
* 分析调查记录的权限
|
||||
*/
|
||||
ANALYSE_RECORD("分析调查记录权限", new HashSet<String>() {{
|
||||
|
||||
}}),
|
||||
|
||||
/**
|
||||
* 可以增删改流调人员信息
|
||||
*/
|
||||
CUD_INVESTIGATOR("增删改流调人员信息的权限", new HashSet<String>() {{
|
||||
|
||||
}}),
|
||||
|
||||
/**
|
||||
* 查询流调人员信息
|
||||
*/
|
||||
RETRIEVE_INVESTIGATOR("查询流调人员信息的权限", new HashSet<String>() {{
|
||||
|
||||
}}),
|
||||
|
||||
/**
|
||||
* 增删改调查对象信息的权限
|
||||
*/
|
||||
CUD_RESPONDENT("增删改调查对象信息的权限", new HashSet<String>() {{
|
||||
add("/respondent/respondent : POST");
|
||||
}}),
|
||||
|
||||
/**
|
||||
* 查询调查对象信息的权限
|
||||
*/
|
||||
RETRIEVE_RESPONDENT("查询调查对象信息的权限", new HashSet<String>() {{
|
||||
add("/respondent/respondent : GET");
|
||||
}}),
|
||||
|
||||
/**
|
||||
* 查看用户的权限
|
||||
*/
|
||||
RETRIEVE_USER("查看用户的权限", new HashSet<String>() {{
|
||||
add("/user/user : GET");
|
||||
}}),
|
||||
|
||||
/**
|
||||
* 删除用户的权限
|
||||
*/
|
||||
DELETE_USER("删除用户的权限", new HashSet<String>() {{
|
||||
add("/user/user : DELETE");
|
||||
}}),
|
||||
|
||||
/**
|
||||
* 查看角色的权限
|
||||
*/
|
||||
RETRIEVE_ROLE("查看角色的权限", new HashSet<String>() {{
|
||||
add("/role/role : GET");
|
||||
}}),
|
||||
|
||||
/**
|
||||
* 删除角色的权限
|
||||
*/
|
||||
DELETE_ROLE("删除角色的权限", new HashSet<String>() {{
|
||||
add("/role/role : DELETE");
|
||||
}}),
|
||||
|
||||
/**
|
||||
* 修改角色的权限
|
||||
*/
|
||||
UPDATE_ROLE("修改角色的权限", new HashSet<String>() {{
|
||||
add("/role/role : PUT");
|
||||
CREATE_ROLE("增加角色的权限", new HashSet<String>() {{
|
||||
add("/role/role : POST");
|
||||
}}),
|
||||
QUERY_AUTHORITY_LIST("查询权限列表的权限", new HashSet<String>() {{
|
||||
add("/role/authorityList : GET");
|
||||
}}),
|
||||
|
||||
/**
|
||||
* 查看权限列表
|
||||
* 元数据
|
||||
*/
|
||||
LIST_AUTHORITY("查看权限列表的权限", new HashSet<String>() {{
|
||||
add("/role/authList : GET");
|
||||
}});
|
||||
QUERY_METADATA("查询元数据的权限", new HashSet<String>() {{
|
||||
add("/metadata/metadata : GET");
|
||||
add("/metadata/metadataList : GET");
|
||||
add("/metadata/nameList : GET");
|
||||
}}),
|
||||
MODIFY_METADATA("修改元数据的权限", new HashSet<String>() {{
|
||||
add("/metadata/metadata : PUT");
|
||||
}}),
|
||||
DELETE_METADATA("删除元数据的权限", new HashSet<String>() {{
|
||||
|
||||
}}),
|
||||
CREATE_METADATA("添加元数据的权限", new HashSet<String>() {{
|
||||
add("/metadata/metadata : POST");
|
||||
}}),
|
||||
BIND_TEMPLATE("上传元数据对应模板的权限", new HashSet<String>() {{
|
||||
add("/metaData/wordTemplate : POST");
|
||||
}}),
|
||||
|
||||
/**
|
||||
* 审计
|
||||
*/
|
||||
QUERY_AUDIT("查询审计记录", new HashSet<String>() {{
|
||||
|
||||
}});
|
||||
|
||||
private String name;
|
||||
private Set<String> routes;
|
||||
|
@ -18,10 +18,6 @@ public enum RecordStateEnum {
|
||||
* 未通过状态
|
||||
*/
|
||||
NOT_PASS("未通过"),
|
||||
/**
|
||||
* 已删除状态
|
||||
*/
|
||||
DELETED("已删除"),
|
||||
/**
|
||||
* 已归档状态
|
||||
*/
|
||||
|
@ -5,6 +5,7 @@ import com.example.survey.dto.metaData.DeleteMetaDataDTO;
|
||||
import com.example.survey.dto.metaData.ModifyMetaDataDTO;
|
||||
import com.example.survey.entity.MetaData;
|
||||
import com.example.survey.vo.MetaDataVO;
|
||||
import org.springframework.web.multipart.MultipartFile;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@ -17,7 +18,7 @@ public interface MetaDataService {
|
||||
*
|
||||
* @param createMetaDataDTO 元数据信息
|
||||
*/
|
||||
void addMetaData(CreateMetaDataDTO createMetaDataDTO);
|
||||
void createMetaData(CreateMetaDataDTO createMetaDataDTO);
|
||||
|
||||
/**
|
||||
* 根据筛选条件模糊查询元数据
|
||||
@ -61,4 +62,12 @@ public interface MetaDataService {
|
||||
* @param deleteMetaDataDTO 删除信息
|
||||
*/
|
||||
void deleteMetaData(DeleteMetaDataDTO deleteMetaDataDTO);
|
||||
|
||||
/**
|
||||
* 给元数据绑定模板文件
|
||||
*
|
||||
* @param template 模板文件
|
||||
* @param name 元数据名
|
||||
*/
|
||||
void bindWordTemplate(MultipartFile template, String name);
|
||||
}
|
||||
|
@ -25,11 +25,12 @@ public interface ProjectService {
|
||||
* 根据筛选条件分页查询项目
|
||||
*
|
||||
* @param name 项目名
|
||||
* @param state 状态
|
||||
* @param currentPage 当前页数
|
||||
* @param pageSize 页大小
|
||||
* @return 项目vo
|
||||
*/
|
||||
List<ProjectVO> listProjectLimit(String name, int currentPage, int pageSize);
|
||||
List<ProjectVO> listProjectLimit(String name, String state, int currentPage, int pageSize);
|
||||
|
||||
/**
|
||||
* 根据项目名查询调查对象数量
|
||||
@ -65,8 +66,9 @@ public interface ProjectService {
|
||||
/**
|
||||
* 根据项目吗查询数量
|
||||
*
|
||||
* @param name 项目名
|
||||
* @param name 项目名
|
||||
* @param state 项目状态
|
||||
* @return 数量
|
||||
*/
|
||||
long countProject(String name);
|
||||
long countProject(String name, String state);
|
||||
}
|
||||
|
@ -1,10 +1,13 @@
|
||||
package com.example.survey.service;
|
||||
|
||||
import com.example.survey.dto.record.DeleteRecordDTO;
|
||||
import com.example.survey.dto.record.ModifyRecordDTO;
|
||||
import com.example.survey.dto.record.ReviewRecordDTO;
|
||||
import com.example.survey.dto.record.SubmitRecordDTO;
|
||||
import com.example.survey.vo.RecordVO;
|
||||
import org.springframework.web.multipart.MultipartFile;
|
||||
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
@ -81,4 +84,28 @@ public interface RecordService {
|
||||
* @return 流调记录的values
|
||||
*/
|
||||
Map<String,Object> getRecordValues(String projectName, String idNumber, String version);
|
||||
|
||||
/**
|
||||
* 上传文件
|
||||
*
|
||||
* @param file 文件
|
||||
* @return 文件的可访问路径
|
||||
*/
|
||||
String uploadFile(MultipartFile file);
|
||||
|
||||
/**
|
||||
* 删除记录
|
||||
*
|
||||
* @param deleteRecordDTO 删除信息
|
||||
*/
|
||||
void deleteRecord(DeleteRecordDTO deleteRecordDTO);
|
||||
|
||||
/**
|
||||
* 项目导出为word文档
|
||||
*
|
||||
* @param idNumber 身份证号
|
||||
* @param projectName 项目名
|
||||
* @param response 响应
|
||||
*/
|
||||
void record2word(String idNumber, String projectName, HttpServletResponse response);
|
||||
}
|
||||
|
@ -10,10 +10,14 @@ import com.example.survey.exception.MetaDataException;
|
||||
import com.example.survey.service.MetaDataService;
|
||||
import com.example.survey.vo.MetaDataVO;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.web.multipart.MultipartFile;
|
||||
|
||||
import java.io.*;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.UUID;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
/**
|
||||
@ -25,8 +29,14 @@ public class MetaDataServiceImpl implements MetaDataService {
|
||||
@Autowired
|
||||
MetaDataDao metaDataDao;
|
||||
|
||||
@Value("${file.path}")
|
||||
private String path;
|
||||
|
||||
@Value("${file.url}")
|
||||
private String url;
|
||||
|
||||
@Override
|
||||
public void addMetaData(CreateMetaDataDTO createMetaDataDTO) {
|
||||
public void createMetaData(CreateMetaDataDTO createMetaDataDTO) {
|
||||
if (metaDataDao.existMetaData(createMetaDataDTO.getName())) {
|
||||
throw new MetaDataException(ResultEnum.ALREADY_EXIST_METADATA);
|
||||
}
|
||||
@ -35,6 +45,7 @@ public class MetaDataServiceImpl implements MetaDataService {
|
||||
metaData.setForm(createMetaDataDTO.getForm());
|
||||
metaData.setFieldToNameList(createMetaDataDTO.getFieldToNameList());
|
||||
metaData.setConfig(createMetaDataDTO.getConfig());
|
||||
metaData.setWordTemplate(createMetaDataDTO.getWordTemplate());
|
||||
metaDataDao.saveMetaData(metaData);
|
||||
}
|
||||
|
||||
@ -81,7 +92,7 @@ public class MetaDataServiceImpl implements MetaDataService {
|
||||
@Override
|
||||
public MetaData getMetaData(String name) {
|
||||
if (!metaDataDao.existMetaData(name)) {
|
||||
throw new MetaDataException(ResultEnum.ALREADY_EXIST_METADATA);
|
||||
throw new MetaDataException(ResultEnum.NOT_EXIST_METADATA);
|
||||
}
|
||||
return metaDataDao.selectMetaData(name);
|
||||
}
|
||||
@ -93,4 +104,46 @@ public class MetaDataServiceImpl implements MetaDataService {
|
||||
}
|
||||
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);
|
||||
}
|
||||
}
|
||||
|
@ -63,14 +63,15 @@ public class ProjectServiceImpl implements ProjectService {
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<ProjectVO> listProjectLimit(String name, int currentPage, int pageSize) {
|
||||
return projectDao.listProjectLimit(name, currentPage * pageSize, pageSize).stream()
|
||||
public List<ProjectVO> listProjectLimit(String name, String state, int currentPage, int pageSize) {
|
||||
return projectDao.listProjectLimit(name, state, 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());
|
||||
}
|
||||
@ -131,8 +132,8 @@ public class ProjectServiceImpl implements ProjectService {
|
||||
}
|
||||
|
||||
@Override
|
||||
public long countProject(String name) {
|
||||
return projectDao.countProject(name);
|
||||
public long countProject(String name, String state) {
|
||||
return projectDao.countProject(name, state);
|
||||
|
||||
}
|
||||
|
||||
|
@ -4,6 +4,7 @@ import com.example.survey.dao.ProjectDao;
|
||||
import com.example.survey.dao.RecordDao;
|
||||
import com.example.survey.dao.RespondentDao;
|
||||
import com.example.survey.dao.UserDao;
|
||||
import com.example.survey.dto.record.DeleteRecordDTO;
|
||||
import com.example.survey.dto.record.ModifyRecordDTO;
|
||||
import com.example.survey.dto.record.ReviewRecordDTO;
|
||||
import com.example.survey.dto.record.SubmitRecordDTO;
|
||||
@ -15,17 +16,19 @@ 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.ProjectException;
|
||||
import com.example.survey.exception.RecordException;
|
||||
import com.example.survey.exception.RespondentException;
|
||||
import com.example.survey.exception.UserException;
|
||||
import com.example.survey.exception.*;
|
||||
import com.example.survey.service.RecordService;
|
||||
import com.example.survey.util.WordUtil;
|
||||
import com.example.survey.vo.RecordVO;
|
||||
import com.example.survey.vo.inner.OperationInfo;
|
||||
import lombok.extern.log4j.Log4j2;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.web.multipart.MultipartFile;
|
||||
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import java.io.*;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
@ -52,6 +55,12 @@ public class RecordServiceImpl implements RecordService {
|
||||
@Autowired
|
||||
private ProjectDao projectDao;
|
||||
|
||||
@Value("${file.path}")
|
||||
private String path;
|
||||
|
||||
@Value("${file.url}")
|
||||
private String url;
|
||||
|
||||
@Override
|
||||
public long countRecord(String userPhone, String projectName) {
|
||||
if (userPhone != null && !userDao.existUser(userPhone)) {
|
||||
@ -67,19 +76,20 @@ public class RecordServiceImpl implements RecordService {
|
||||
|
||||
@Override
|
||||
public void reviewRecord(ReviewRecordDTO reviewRecordDTO) {
|
||||
if (!respondentDao.existRespondent(reviewRecordDTO.getIdNumber(), RespondentStateEnum.NOT_INVESTIGATED.getValue())) {
|
||||
throw new RespondentException(ResultEnum.NOT_EXIST_RESPONDENT);
|
||||
}
|
||||
if (!userDao.existUser(reviewRecordDTO.getReviewerPhone())) {
|
||||
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());
|
||||
Respondent respondent = respondentDao.selectRespondent(reviewRecordDTO.getIdNumber(), project);
|
||||
User user = userDao.selectUser(reviewRecordDTO.getReviewerPhone());
|
||||
|
||||
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())) {
|
||||
throw new RecordException(ResultEnum.NOT_EXIST_RECORD);
|
||||
@ -98,61 +108,61 @@ public class RecordServiceImpl implements RecordService {
|
||||
|
||||
@Override
|
||||
public void modifyRecord(ModifyRecordDTO modifyRecordDTO) {
|
||||
if (!respondentDao.existRespondent(modifyRecordDTO.getIdNumber(), RespondentStateEnum.NOT_INVESTIGATED.getValue())) {
|
||||
throw new RespondentException(ResultEnum.NOT_EXIST_RESPONDENT);
|
||||
}
|
||||
if (!userDao.existUser(modifyRecordDTO.getUserPhone())) {
|
||||
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);
|
||||
User user = userDao.selectUser(modifyRecordDTO.getUserPhone());
|
||||
|
||||
|
||||
if (!recordDao.existRecord(respondent, project, RecordStateEnum.UNDER_REVIEW.getValue())) {
|
||||
List<Record> recordList = recordDao.listRecord(project, respondent);
|
||||
if (recordList == null) {
|
||||
throw new RecordException(ResultEnum.NOT_EXIST_RECORD);
|
||||
}
|
||||
Record record = recordDao.getRecord(respondent, project, RecordStateEnum.REVIEWED.getValue());
|
||||
recordList.forEach(record -> {
|
||||
//将原来的设为已归档 添加覆盖操作
|
||||
record.setState(RecordStateEnum.FILED.getValue());
|
||||
Operation coverOp = Operation.coverOp(user, record.getVersion());
|
||||
List<Operation> oldOpList = record.getOperationList();
|
||||
List<Operation> newOpList = record.getOperationList();
|
||||
oldOpList.add(coverOp);
|
||||
record.setOperationList(oldOpList);
|
||||
record.setVersion(UUID.randomUUID().toString());
|
||||
recordDao.saveRecord(record);
|
||||
|
||||
//将原来的设为已归档 添加覆盖操作
|
||||
record.setState(RecordStateEnum.FILED.getValue());
|
||||
Operation coverOp = Operation.coverOp(user, record.getVersion());
|
||||
List<Operation> oldOpList = record.getOperationList();
|
||||
List<Operation> newOpList = record.getOperationList();
|
||||
oldOpList.add(coverOp);
|
||||
record.setOperationList(oldOpList);
|
||||
record.setVersion(UUID.randomUUID().toString());
|
||||
recordDao.saveRecord(record);
|
||||
|
||||
//生成新的流调记录
|
||||
record.setId(null);
|
||||
record.setValues(modifyRecordDTO.getValues());
|
||||
record.setState(RecordStateEnum.UNDER_REVIEW.getValue());
|
||||
Operation modifyOp = Operation.modifyOp(user, modifyRecordDTO.getMsg(), record.getVersion());
|
||||
newOpList.add(modifyOp);
|
||||
record.setOperationList(newOpList);
|
||||
record.setVersion(UUID.randomUUID().toString());
|
||||
recordDao.saveRecord(record);
|
||||
//生成新的流调记录
|
||||
record.setId(null);
|
||||
record.setValues(modifyRecordDTO.getValues());
|
||||
record.setState(RecordStateEnum.UNDER_REVIEW.getValue());
|
||||
Operation modifyOp = Operation.modifyOp(user, modifyRecordDTO.getMsg(), record.getVersion());
|
||||
newOpList.add(modifyOp);
|
||||
record.setOperationList(newOpList);
|
||||
record.setVersion(UUID.randomUUID().toString());
|
||||
recordDao.saveRecord(record);
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
public void createRecord(SubmitRecordDTO submitRecordDTO) {
|
||||
if (!respondentDao.existRespondent(submitRecordDTO.getIdNumber())) {
|
||||
throw new RespondentException(ResultEnum.NOT_EXIST_RESPONDENT);
|
||||
}
|
||||
if (!userDao.existUser(submitRecordDTO.getUserPhone())) {
|
||||
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 (!respondentDao.existRespondent(submitRecordDTO.getIdNumber(), project)) {
|
||||
throw new RespondentException(ResultEnum.NOT_EXIST_RESPONDENT);
|
||||
}
|
||||
Respondent respondent = respondentDao.selectRespondent(submitRecordDTO.getIdNumber(), project);
|
||||
User user = userDao.selectUser(submitRecordDTO.getUserPhone());
|
||||
|
||||
//设置调查对象为已调查
|
||||
respondent.setState(RespondentStateEnum.INVESTIGATED.getValue());
|
||||
respondentDao.saveRespondent(respondent);
|
||||
@ -198,37 +208,42 @@ public class RecordServiceImpl implements RecordService {
|
||||
|
||||
@Override
|
||||
public long countRecord(String idNumber, String userPhone, String projectName, String state, String version, String questionnaireNumber) {
|
||||
if (idNumber != null && !respondentDao.existRespondent(idNumber)) {
|
||||
throw new RespondentException(ResultEnum.NOT_EXIST_RESPONDENT);
|
||||
}
|
||||
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);
|
||||
}
|
||||
Project project = projectDao.selectProject(projectName);
|
||||
Respondent respondent = respondentDao.selectRespondent(idNumber, project);
|
||||
|
||||
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);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<RecordVO> listRecordLimit(String idNumber, String userPhone, String projectName, String state, String version, String questionnaireNumber, int currentPage, int pageSize) {
|
||||
if (idNumber != null && !respondentDao.existRespondent(idNumber)) {
|
||||
throw new RespondentException(ResultEnum.NOT_EXIST_RESPONDENT);
|
||||
}
|
||||
if (userPhone != null && !userDao.existUser(userPhone)) {
|
||||
throw new UserException(ResultEnum.NOT_EXIST_USER);
|
||||
}
|
||||
User user = userDao.selectUser(userPhone);
|
||||
|
||||
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);
|
||||
User user = userDao.selectUser(userPhone);
|
||||
|
||||
|
||||
List<Record> recordList = recordDao.listRecordLimit(respondent, user, project, state, version, questionnaireNumber, currentPage * pageSize, pageSize);
|
||||
@ -258,10 +273,10 @@ public class RecordServiceImpl implements RecordService {
|
||||
if (!projectDao.existProject(projectName)) {
|
||||
throw new ProjectException(ResultEnum.NOT_EXIST_PROJECT);
|
||||
}
|
||||
if (!respondentDao.existRespondent(idNumber)) {
|
||||
Project project = projectDao.selectProject(projectName);
|
||||
if (!respondentDao.existRespondent(idNumber, project)) {
|
||||
throw new RespondentException(ResultEnum.NOT_EXIST_RESPONDENT);
|
||||
}
|
||||
Project project = projectDao.selectProject(projectName);
|
||||
Respondent respondent = respondentDao.selectRespondent(idNumber, project);
|
||||
Record record = recordDao.selectRecord(respondent, project, version);
|
||||
if (record == null) {
|
||||
@ -270,5 +285,90 @@ public class RecordServiceImpl implements RecordService {
|
||||
return record.getValues();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String uploadFile(MultipartFile file) {
|
||||
String name = file.getOriginalFilename();
|
||||
assert name != null;
|
||||
String suffix = name.substring(name.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 = file.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();
|
||||
}
|
||||
}
|
||||
return url + newName;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void deleteRecord(DeleteRecordDTO deleteRecordDTO) {
|
||||
if (!userDao.existUser(deleteRecordDTO.getUserPhone())) {
|
||||
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);
|
||||
|
||||
List<Record> recordList = recordDao.listRecord(project, respondent);
|
||||
recordList.forEach(record -> {
|
||||
String version = UUID.randomUUID().toString();
|
||||
record.setVersion(version);
|
||||
Operation operation = Operation.deleteOp(user, deleteRecordDTO.getMsg(), version);
|
||||
List<Operation> operationList = record.getOperationList();
|
||||
operationList.add(operation);
|
||||
record.setOperationList(operationList);
|
||||
recordDao.saveRecord(record);
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
public void record2word(String idNumber, String projectName, HttpServletResponse response) {
|
||||
if (!projectDao.existProject(projectName)) {
|
||||
throw new ProjectException(ResultEnum.NOT_EXIST_PROJECT);
|
||||
}
|
||||
Project project = projectDao.selectProject(projectName);
|
||||
if (project.getMetaData() == null || project.getMetaData().getWordTemplate() == null) {
|
||||
throw new MetaDataException(ResultEnum.NOT_EXIST_METADATA);
|
||||
}
|
||||
if (!respondentDao.existRespondent(idNumber, project)) {
|
||||
throw new RespondentException(ResultEnum.NOT_EXIST_RESPONDENT);
|
||||
}
|
||||
Respondent respondent = respondentDao.selectRespondent(idNumber, project);
|
||||
Record record = recordDao.getRecord(respondent, project, RecordStateEnum.REVIEWED.getValue());
|
||||
if (record == null) {
|
||||
throw new RecordException(ResultEnum.NOT_EXIST_RECORD);
|
||||
}
|
||||
Map<String, Object> values = record.getValues();
|
||||
WordUtil.export2word(response, values, "E:\\wordTemplate.docx");
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
@ -20,9 +20,7 @@ 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.scheduling.annotation.Scheduled;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
@ -127,10 +125,10 @@ public class RespondentServiceImpl implements RespondentService {
|
||||
if (!projectDao.existProject(modifyRespondentDTO.getProjectName())) {
|
||||
throw new ProjectException(ResultEnum.NOT_EXIST_PROJECT);
|
||||
}
|
||||
if (!respondentDao.existRespondent(modifyRespondentDTO.getIdNumber())) {
|
||||
Project project = projectDao.selectProject(modifyRespondentDTO.getProjectName());
|
||||
if (!respondentDao.existRespondent(modifyRespondentDTO.getIdNumber(), project)) {
|
||||
throw new RespondentException(ResultEnum.NOT_EXIST_RESPONDENT);
|
||||
}
|
||||
Project project = projectDao.selectProject(modifyRespondentDTO.getProjectName());
|
||||
Respondent respondent = respondentDao.selectRespondent(modifyRespondentDTO.getIdNumber(), project);
|
||||
respondent.setPhone(modifyRespondentDTO.getPhone());
|
||||
respondent.setName(modifyRespondentDTO.getName());
|
||||
@ -143,31 +141,32 @@ public class RespondentServiceImpl implements RespondentService {
|
||||
|
||||
@Override
|
||||
public void modifyUser(ModifyRespondentUserDTO modifyRespondentUserDTO) {
|
||||
if (!respondentDao.existRespondent(modifyRespondentUserDTO.getIdNumber())) {
|
||||
throw new RespondentException(ResultEnum.NOT_EXIST_RESPONDENT);
|
||||
}
|
||||
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);
|
||||
User user = userDao.selectUser(modifyRespondentUserDTO.getUserPhone());
|
||||
|
||||
respondent.setUser(user);
|
||||
respondentDao.saveRespondent(respondent);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void deleteRespondent(DeleteRespondentDTO deleteRespondentDTO) {
|
||||
if (!respondentDao.existRespondent(deleteRespondentDTO.getIdNumber())) {
|
||||
throw new RespondentException(ResultEnum.NOT_EXIST_RESPONDENT);
|
||||
}
|
||||
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
src/main/java/com/example/survey/util/WordUtil.java
Normal file
57
src/main/java/com/example/survey/util/WordUtil.java
Normal file
@ -0,0 +1,57 @@
|
||||
package com.example.survey.util;
|
||||
|
||||
import com.deepoove.poi.XWPFTemplate;
|
||||
import com.deepoove.poi.config.Configure;
|
||||
import com.deepoove.poi.config.ConfigureBuilder;
|
||||
import com.deepoove.poi.policy.HackLoopTableRenderPolicy;
|
||||
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import java.io.BufferedOutputStream;
|
||||
import java.io.IOException;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.UUID;
|
||||
|
||||
/**
|
||||
* @author Pope
|
||||
*/
|
||||
public class WordUtil {
|
||||
public static void export2word(HttpServletResponse response, Map<String, Object> values, String templatePath) {
|
||||
|
||||
response.addHeader("Content-Disposition", "attachment;filename=" + UUID.randomUUID().toString() + ".docx");
|
||||
|
||||
ConfigureBuilder configureBuilder = Configure.builder();
|
||||
HackLoopTableRenderPolicy policy = new HackLoopTableRenderPolicy();
|
||||
for (String key : values.keySet()) {
|
||||
Object value = values.get(key);
|
||||
if (value instanceof List) {
|
||||
List<Object> newValue = (List<Object>) value;
|
||||
if(newValue.size()==0){
|
||||
continue;
|
||||
}
|
||||
Object o = newValue.get(0);
|
||||
if (o instanceof String) {
|
||||
StringBuilder sb = new StringBuilder();
|
||||
newValue.forEach(str -> {
|
||||
sb.append(str + " ");
|
||||
});
|
||||
values.put(key, sb.toString());
|
||||
} else {
|
||||
configureBuilder = configureBuilder.bind(key, policy);
|
||||
}
|
||||
}
|
||||
}
|
||||
XWPFTemplate template = XWPFTemplate.compile(templatePath, configureBuilder.build()).render(values);
|
||||
try (BufferedOutputStream os = new BufferedOutputStream(response.getOutputStream())) {
|
||||
template.write(os);
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
} finally {
|
||||
try {
|
||||
template.close();
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@ -39,6 +39,11 @@ public class ProjectVO {
|
||||
*/
|
||||
private Date endTime;
|
||||
|
||||
/**
|
||||
* 负责人姓名
|
||||
*/
|
||||
private String username;
|
||||
|
||||
/**
|
||||
* 状态
|
||||
*/
|
||||
|
@ -4,10 +4,17 @@ spring:
|
||||
# uri: mongodb://cveo:cveo123456@120.78.177.67:27017/survey
|
||||
#创建索引
|
||||
auto-index-creation: true
|
||||
host: 127.0.0.1
|
||||
host: 8.136.133.77
|
||||
port: 27017
|
||||
database: survey
|
||||
username: cveo
|
||||
password: cveo123456
|
||||
authentication-database: admin
|
||||
|
||||
redis:
|
||||
host: 127.0.0.1
|
||||
port: 6379
|
||||
|
||||
file:
|
||||
path: E:\
|
||||
url: E:\
|
||||
|
@ -1,7 +1,7 @@
|
||||
spring:
|
||||
data:
|
||||
mongodb:
|
||||
# uri: mongodb://cveo:cveo123456@120.78.177.67:27017/survey
|
||||
# uri: mongodb://cveo:cveo123456@120.78.177.67:27017/survey
|
||||
#创建索引
|
||||
auto-index-creation: true
|
||||
host: mongo
|
||||
@ -16,6 +16,10 @@ spring:
|
||||
port: 6379
|
||||
password: cveo
|
||||
|
||||
file:
|
||||
path: ./data/upload/
|
||||
url: /upload/
|
||||
|
||||
# kafka:
|
||||
# bootstrap-servers: localhost:9092 # 指定kafka 代理地址,可以多个
|
||||
# producer: # 生产者
|
||||
|
@ -0,0 +1,4 @@
|
||||
#上传模板
|
||||
POST http://{{host}}:{{port}}{{prefix}}/metaData/wordTemplate
|
||||
Content-Type: multipart/form-data
|
||||
|
@ -59,3 +59,20 @@ Authorization: 8f6b21a0-fa4b-4241-b5f7-58355048e1f9
|
||||
"userPhone": "cveo"
|
||||
}
|
||||
|
||||
###
|
||||
|
||||
#上传文件
|
||||
POST http://{{host}}:{{port}}{{prefix}}/record/file
|
||||
Content-Type: multipart/form-data; boundary=WebAppBoundary
|
||||
|
||||
|
||||
--WebAppBoundary
|
||||
Content-Disposition: form-data;name="file"; filename="wordTemplate.doc"
|
||||
Content-Type: application/json
|
||||
|
||||
< E:\\wordTemplate.doc
|
||||
|
||||
###
|
||||
|
||||
#导出为word
|
||||
GET http://{{host}}:{{port}}{{prefix}}/record/record2word?idNumber=rrrrrrrrr&projectName=111
|
||||
|
@ -3,8 +3,8 @@ POST http://{{host}}:{{port}}{{prefix}}/user/login
|
||||
Content-Type: application/json
|
||||
|
||||
{
|
||||
"phone": "cveo",
|
||||
"password": "cveo123456"
|
||||
"phone": "cveo111",
|
||||
"password": "cveo111"
|
||||
}
|
||||
|
||||
###
|
||||
|
Loading…
x
Reference in New Issue
Block a user