This commit is contained in:
戴凡 2021-12-26 17:54:05 +08:00
parent f2f6078600
commit 7e32f84cf1
19 changed files with 57 additions and 61 deletions

View File

@ -33,7 +33,6 @@ public class UserServiceImpl implements UserService {
@Autowired @Autowired
private RoleDao roleDao; private RoleDao roleDao;
@Override @Override
public LoginVO matchAuth(LoginDTO loginDTO) { public LoginVO matchAuth(LoginDTO loginDTO) {
if (!userDao.existUser(loginDTO.getPhone())) { if (!userDao.existUser(loginDTO.getPhone())) {
@ -45,22 +44,23 @@ public class UserServiceImpl implements UserService {
} }
LoginVO loginVO = new LoginVO(); LoginVO loginVO = new LoginVO();
//判断是否已经登录过 String newToken = null;
// 判断是否已经登录过
if (TokenUtil.existKey(user.getPhone())) { if (TokenUtil.existKey(user.getPhone())) {
String oldToken = (String) TokenUtil.get(user.getPhone()); newToken = (String) TokenUtil.get(user.getPhone());
if (TokenUtil.existKey(oldToken)) { // if (TokenUtil.existKey(oldToken)) {
//已经登录将旧token过期 // // 已经登录将旧token过期
TokenUtil.expireKey(oldToken); // TokenUtil.expireKey(oldToken);
TokenUtil.expireKey(oldToken + " : USER_PHONE"); // TokenUtil.expireKey(oldToken + " : USER_PHONE");
} // }
} else {
// 生成新的token并存入redis
newToken = UUID.randomUUID().toString();
TokenUtil.set(user.getPhone(), newToken);
TokenUtil.set(newToken + " : USER_PHONE", user.getPhone());
} }
//生成新的token并存入redis // 生成角色列表
String newToken = UUID.randomUUID().toString();
TokenUtil.set(user.getPhone(), newToken);
TokenUtil.set(newToken + " : USER_PHONE", user.getPhone());
//生成角色列表
Set<String> roleNameSet = new HashSet<>(); Set<String> roleNameSet = new HashSet<>();
for (Role role : user.getRoleSet()) { for (Role role : user.getRoleSet()) {
Set<String> routeSet = new HashSet<>(); Set<String> routeSet = new HashSet<>();
@ -77,17 +77,13 @@ public class UserServiceImpl implements UserService {
loginVO.setIdNumber(user.getIdNumber()); loginVO.setIdNumber(user.getIdNumber());
loginVO.setPhone(user.getPhone()); loginVO.setPhone(user.getPhone());
if (user.getRoleSet() != null) { if (user.getRoleSet() != null) {
loginVO.setRoleSet(user.getRoleSet().stream() loginVO.setRoleSet(user.getRoleSet().stream().map(role -> {
.map(role -> { RoleVO roleVO = new RoleVO();
RoleVO roleVO = new RoleVO(); roleVO.setName(role.getName());
roleVO.setName(role.getName()); roleVO.setAuthoritySet(
roleVO.setAuthoritySet(role.getAuthoritySet().stream() role.getAuthoritySet().stream().map(AuthEnum::getName).collect(Collectors.toSet()));
.map(AuthEnum::getName) return roleVO;
.collect(Collectors.toSet()) }).collect(Collectors.toSet()));
);
return roleVO;
})
.collect(Collectors.toSet()));
} }
loginVO.setDepartmentList(user.getDepartmentList()); loginVO.setDepartmentList(user.getDepartmentList());
loginVO.setAdministrativeArea(user.getAdministrativeArea()); loginVO.setAdministrativeArea(user.getAdministrativeArea());
@ -136,18 +132,13 @@ public class UserServiceImpl implements UserService {
userVO.setIdNumber(user.getIdNumber()); userVO.setIdNumber(user.getIdNumber());
userVO.setAdministrativeArea(user.getAdministrativeArea()); userVO.setAdministrativeArea(user.getAdministrativeArea());
if (user.getRoleSet() != null) { if (user.getRoleSet() != null) {
userVO.setRoleSet(user.getRoleSet().stream() userVO.setRoleSet(user.getRoleSet().stream().map(role -> {
.map(role -> { RoleVO roleVO = new RoleVO();
RoleVO roleVO = new RoleVO(); roleVO.setName(role.getName());
roleVO.setName(role.getName()); roleVO.setAuthoritySet(
roleVO.setAuthoritySet(role.getAuthoritySet().stream() role.getAuthoritySet().stream().map(AuthEnum::getName).collect(Collectors.toSet()));
.map(AuthEnum::getName) return roleVO;
.collect(Collectors.toSet()) }).collect(Collectors.toSet()));
);
return roleVO;
})
.collect(Collectors.toSet())
);
} }
return userVO; return userVO;
}).collect(Collectors.toList()); }).collect(Collectors.toList());
@ -200,5 +191,4 @@ public class UserServiceImpl implements UserService {
return null; return null;
} }
} }

View File

@ -8,6 +8,7 @@ import java.util.Map;
import com.example.survey.dao.RecordDao; import com.example.survey.dao.RecordDao;
import com.example.survey.entity.Record; import com.example.survey.entity.Record;
import com.example.survey.enumeration.RecordStateEnum; import com.example.survey.enumeration.RecordStateEnum;
import com.google.common.collect.Multiset.Entry;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value; import org.springframework.beans.factory.annotation.Value;
@ -21,9 +22,9 @@ public class CaseQuestionnaireUtil implements Runnable {
public static void main() { public static void main() {
CaseQuestionnaireUtil c = new CaseQuestionnaireUtil(); CaseQuestionnaireUtil c = new CaseQuestionnaireUtil();
// Record record = // Record record =
// c.setRecord(record); // c.setRecord(record);
c.start(); c.start();
} }
private Record record; private Record record;
@ -50,12 +51,17 @@ public class CaseQuestionnaireUtil implements Runnable {
String outputPath = this.report + record.getUuid() + ".docx"; String outputPath = this.report + record.getUuid() + ".docx";
try { try {
Map<String, Object> values = record.getValues(); Map<String, Object> values = record.getValues();
if (!values.containsKey("调查人")) Map<String, Object> newValues = new HashMap<String, Object>();
values.put("调查人", record.getOperationList().get(0).getUser().getUsername()); for (Map.Entry<String, Object> entry : values.entrySet()) {
if (!values.containsKey("调查日期")) newValues.put(entry.getKey().trim(), entry.getValue());
values.put("调查日期", new SimpleDateFormat("yyyy年MM月dd日").format(new java.util.Date())); }
WordUtil wordUtil = new WordUtil(values, templatePath, outputPath); if (!newValues.containsKey("调查人"))
newValues.put("调查人", record.getOperationList().get(0).getUser().getUsername());
if (!newValues.containsKey("调查日期"))
newValues.put("调查日期", new SimpleDateFormat("yyyy年MM月dd日").format(new java.util.Date()));
WordUtil wordUtil = new WordUtil(newValues, templatePath, outputPath);
wordUtil.export2QuestionnaireWord(); wordUtil.export2QuestionnaireWord();
record.setState(RecordStateEnum.REVIEWED.getValue()); record.setState(RecordStateEnum.REVIEWED.getValue());
recordDao.saveRecord(record); recordDao.saveRecord(record);

View File

@ -127,7 +127,7 @@ public class WordUtil {
SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss.SSS'Z'"); SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss.SSS'Z'");
if (valueObj instanceof ArrayList<?>) { if (valueObj instanceof ArrayList<?>) {
for (Object o : (List<?>) valueObj) { for (Object o : (List<?>) valueObj) {
String value = o.toString(); String value = o.toString().trim();
try { try {
Date date = dateFormat.parse(value); Date date = dateFormat.parse(value);
replaceInParagragh(paragraph, key, new SimpleDateFormat("yyyy年MM月dd日").format(date)); replaceInParagragh(paragraph, key, new SimpleDateFormat("yyyy年MM月dd日").format(date));
@ -139,13 +139,13 @@ public class WordUtil {
} else if (valueObj.getClass().isArray()) { } else if (valueObj.getClass().isArray()) {
Object[] arr = (Object[]) valueObj; Object[] arr = (Object[]) valueObj;
try { try {
Date date = dateFormat.parse(arr[0].toString()); Date date = dateFormat.parse(arr[0].toString().trim());
replaceInParagragh(paragraph, key, new SimpleDateFormat("yyyy年MM月dd日").format(date)); replaceInParagragh(paragraph, key, new SimpleDateFormat("yyyy年MM月dd日").format(date));
} catch (Exception e) { } catch (Exception e) {
replaceInParagragh(paragraph, key, arr[0].toString()); replaceInParagragh(paragraph, key, arr[0].toString().trim());
} }
} else { } else {
String value = valueObj.toString(); String value = valueObj.toString().trim();
try { try {
Date date = dateFormat.parse(value); Date date = dateFormat.parse(value);
replaceInParagragh(paragraph, key, new SimpleDateFormat("yyyy年MM月dd日").format(date)); replaceInParagragh(paragraph, key, new SimpleDateFormat("yyyy年MM月dd日").format(date));
@ -171,17 +171,17 @@ public class WordUtil {
Object valueObj = values.get(trueKey); Object valueObj = values.get(trueKey);
if (valueObj instanceof ArrayList<?>) { if (valueObj instanceof ArrayList<?>) {
for (Object o : (List<?>) valueObj) { for (Object o : (List<?>) valueObj) {
String oldText = o.toString() + ""; String oldText = o.toString().trim() + "";
TextSegment tSegment = paragraph.searchText(oldText, TextSegment tSegment = paragraph.searchText(oldText,
new PositionInParagraph(startPosRun, 0, 0)); new PositionInParagraph(startPosRun, 0, 0));
if (tSegment != null) { if (tSegment != null) {
String newText = o.toString(); String newText = o.toString().trim();
replaceInParagragh(paragraph, tSegment, oldText, newText); replaceInParagragh(paragraph, tSegment, oldText, newText);
} else { } else {
oldText = "" + o.toString(); oldText = "" + o.toString().trim();
tSegment = paragraph.searchText(oldText, new PositionInParagraph(startPosRun, 0, 0)); tSegment = paragraph.searchText(oldText, new PositionInParagraph(startPosRun, 0, 0));
if (tSegment != null) { if (tSegment != null) {
String newText = o.toString(); String newText = o.toString().trim();
replaceInParagragh(paragraph, tSegment, oldText, newText); replaceInParagragh(paragraph, tSegment, oldText, newText);
} }
} }
@ -189,33 +189,33 @@ public class WordUtil {
} else if (valueObj.getClass().isArray()) { } else if (valueObj.getClass().isArray()) {
Object[] arr = (Object[]) valueObj; Object[] arr = (Object[]) valueObj;
for (int i = 0; i < arr.length; i++) { for (int i = 0; i < arr.length; i++) {
String oldText = arr[i] + ""; String oldText = arr[i].toString().trim() + "";
TextSegment tSegment = paragraph.searchText(oldText, TextSegment tSegment = paragraph.searchText(oldText,
new PositionInParagraph(startPosRun, 0, 0)); new PositionInParagraph(startPosRun, 0, 0));
if (tSegment != null) { if (tSegment != null) {
String newText = arr[i].toString(); String newText = arr[i].toString().trim();
replaceInParagragh(paragraph, tSegment, oldText, newText); replaceInParagragh(paragraph, tSegment, oldText, newText);
} else { } else {
oldText = "" + arr[i]; oldText = "" + arr[i].toString().trim();
tSegment = paragraph.searchText(oldText, new PositionInParagraph(startPosRun, 0, 0)); tSegment = paragraph.searchText(oldText, new PositionInParagraph(startPosRun, 0, 0));
if (tSegment != null) { if (tSegment != null) {
String newText = arr[i].toString(); String newText = arr[i].toString().trim();
replaceInParagragh(paragraph, tSegment, oldText, newText); replaceInParagragh(paragraph, tSegment, oldText, newText);
} }
} }
} }
} else { } else {
String oldText = valueObj.toString() + ""; String oldText = valueObj.toString().trim() + "";
TextSegment tSegment = paragraph.searchText(oldText, TextSegment tSegment = paragraph.searchText(oldText,
new PositionInParagraph(startPosRun, 0, 0)); new PositionInParagraph(startPosRun, 0, 0));
if (tSegment != null) { if (tSegment != null) {
String newText = valueObj.toString(); String newText = valueObj.toString().trim();
replaceInParagragh(paragraph, tSegment, oldText, newText); replaceInParagragh(paragraph, tSegment, oldText, newText);
} else { } else {
oldText = "" + valueObj.toString(); oldText = "" + valueObj.toString().trim();
tSegment = paragraph.searchText(oldText, new PositionInParagraph(startPosRun, 0, 0)); tSegment = paragraph.searchText(oldText, new PositionInParagraph(startPosRun, 0, 0));
if (tSegment != null) { if (tSegment != null) {
String newText = valueObj.toString(); String newText = valueObj.toString().trim();
replaceInParagragh(paragraph, tSegment, oldText, newText); replaceInParagragh(paragraph, tSegment, oldText, newText);
} }
} }

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.