diff --git a/src/main/java/com/example/survey/service/impl/UserServiceImpl.java b/src/main/java/com/example/survey/service/impl/UserServiceImpl.java index a08b9d0..d0f5fe4 100644 --- a/src/main/java/com/example/survey/service/impl/UserServiceImpl.java +++ b/src/main/java/com/example/survey/service/impl/UserServiceImpl.java @@ -33,7 +33,6 @@ public class UserServiceImpl implements UserService { @Autowired private RoleDao roleDao; - @Override public LoginVO matchAuth(LoginDTO loginDTO) { if (!userDao.existUser(loginDTO.getPhone())) { @@ -45,22 +44,23 @@ public class UserServiceImpl implements UserService { } LoginVO loginVO = new LoginVO(); - //判断是否已经登录过 + String newToken = null; + // 判断是否已经登录过 if (TokenUtil.existKey(user.getPhone())) { - String oldToken = (String) TokenUtil.get(user.getPhone()); - if (TokenUtil.existKey(oldToken)) { - //已经登录,将旧token过期, - TokenUtil.expireKey(oldToken); - TokenUtil.expireKey(oldToken + " : USER_PHONE"); - } + newToken = (String) TokenUtil.get(user.getPhone()); + // if (TokenUtil.existKey(oldToken)) { + // // 已经登录,将旧token过期, + // TokenUtil.expireKey(oldToken); + // 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 roleNameSet = new HashSet<>(); for (Role role : user.getRoleSet()) { Set routeSet = new HashSet<>(); @@ -77,17 +77,13 @@ public class UserServiceImpl implements UserService { loginVO.setIdNumber(user.getIdNumber()); loginVO.setPhone(user.getPhone()); if (user.getRoleSet() != null) { - loginVO.setRoleSet(user.getRoleSet().stream() - .map(role -> { - RoleVO roleVO = new RoleVO(); - roleVO.setName(role.getName()); - roleVO.setAuthoritySet(role.getAuthoritySet().stream() - .map(AuthEnum::getName) - .collect(Collectors.toSet()) - ); - return roleVO; - }) - .collect(Collectors.toSet())); + loginVO.setRoleSet(user.getRoleSet().stream().map(role -> { + RoleVO roleVO = new RoleVO(); + roleVO.setName(role.getName()); + roleVO.setAuthoritySet( + role.getAuthoritySet().stream().map(AuthEnum::getName).collect(Collectors.toSet())); + return roleVO; + }).collect(Collectors.toSet())); } loginVO.setDepartmentList(user.getDepartmentList()); loginVO.setAdministrativeArea(user.getAdministrativeArea()); @@ -136,18 +132,13 @@ public class UserServiceImpl implements UserService { userVO.setIdNumber(user.getIdNumber()); userVO.setAdministrativeArea(user.getAdministrativeArea()); if (user.getRoleSet() != null) { - userVO.setRoleSet(user.getRoleSet().stream() - .map(role -> { - RoleVO roleVO = new RoleVO(); - roleVO.setName(role.getName()); - roleVO.setAuthoritySet(role.getAuthoritySet().stream() - .map(AuthEnum::getName) - .collect(Collectors.toSet()) - ); - return roleVO; - }) - .collect(Collectors.toSet()) - ); + userVO.setRoleSet(user.getRoleSet().stream().map(role -> { + RoleVO roleVO = new RoleVO(); + roleVO.setName(role.getName()); + roleVO.setAuthoritySet( + role.getAuthoritySet().stream().map(AuthEnum::getName).collect(Collectors.toSet())); + return roleVO; + }).collect(Collectors.toSet())); } return userVO; }).collect(Collectors.toList()); @@ -200,5 +191,4 @@ public class UserServiceImpl implements UserService { return null; } - } diff --git a/src/main/java/com/example/survey/util/CaseQuestionnaireUtil.java b/src/main/java/com/example/survey/util/CaseQuestionnaireUtil.java index b4c6d00..75364a2 100644 --- a/src/main/java/com/example/survey/util/CaseQuestionnaireUtil.java +++ b/src/main/java/com/example/survey/util/CaseQuestionnaireUtil.java @@ -8,6 +8,7 @@ import java.util.Map; import com.example.survey.dao.RecordDao; import com.example.survey.entity.Record; 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.Value; @@ -21,9 +22,9 @@ public class CaseQuestionnaireUtil implements Runnable { public static void main() { CaseQuestionnaireUtil c = new CaseQuestionnaireUtil(); - // Record record = + // Record record = // c.setRecord(record); - c.start(); + c.start(); } private Record record; @@ -50,12 +51,17 @@ public class CaseQuestionnaireUtil implements Runnable { String outputPath = this.report + record.getUuid() + ".docx"; try { Map values = record.getValues(); - if (!values.containsKey("调查人")) - values.put("调查人", record.getOperationList().get(0).getUser().getUsername()); - if (!values.containsKey("调查日期")) - values.put("调查日期", new SimpleDateFormat("yyyy年MM月dd日").format(new java.util.Date())); + Map newValues = new HashMap(); + for (Map.Entry entry : values.entrySet()) { + newValues.put(entry.getKey().trim(), entry.getValue()); + } - 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(); record.setState(RecordStateEnum.REVIEWED.getValue()); recordDao.saveRecord(record); diff --git a/src/main/java/com/example/survey/util/WordUtil.java b/src/main/java/com/example/survey/util/WordUtil.java index f19693c..7b39443 100644 --- a/src/main/java/com/example/survey/util/WordUtil.java +++ b/src/main/java/com/example/survey/util/WordUtil.java @@ -127,7 +127,7 @@ public class WordUtil { SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss.SSS'Z'"); if (valueObj instanceof ArrayList) { for (Object o : (List) valueObj) { - String value = o.toString(); + String value = o.toString().trim(); try { Date date = dateFormat.parse(value); replaceInParagragh(paragraph, key, new SimpleDateFormat("yyyy年MM月dd日").format(date)); @@ -139,13 +139,13 @@ public class WordUtil { } else if (valueObj.getClass().isArray()) { Object[] arr = (Object[]) valueObj; 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)); } catch (Exception e) { - replaceInParagragh(paragraph, key, arr[0].toString()); + replaceInParagragh(paragraph, key, arr[0].toString().trim()); } } else { - String value = valueObj.toString(); + String value = valueObj.toString().trim(); try { Date date = dateFormat.parse(value); replaceInParagragh(paragraph, key, new SimpleDateFormat("yyyy年MM月dd日").format(date)); @@ -171,17 +171,17 @@ public class WordUtil { Object valueObj = values.get(trueKey); if (valueObj instanceof ArrayList) { for (Object o : (List) valueObj) { - String oldText = o.toString() + "□"; + String oldText = o.toString().trim() + "□"; TextSegment tSegment = paragraph.searchText(oldText, new PositionInParagraph(startPosRun, 0, 0)); if (tSegment != null) { - String newText = o.toString(); + String newText = o.toString().trim(); replaceInParagragh(paragraph, tSegment, oldText, newText); } else { - oldText = "□" + o.toString(); + oldText = "□" + o.toString().trim(); tSegment = paragraph.searchText(oldText, new PositionInParagraph(startPosRun, 0, 0)); if (tSegment != null) { - String newText = o.toString(); + String newText = o.toString().trim(); replaceInParagragh(paragraph, tSegment, oldText, newText); } } @@ -189,33 +189,33 @@ public class WordUtil { } else if (valueObj.getClass().isArray()) { Object[] arr = (Object[]) valueObj; for (int i = 0; i < arr.length; i++) { - String oldText = arr[i] + "□"; + String oldText = arr[i].toString().trim() + "□"; TextSegment tSegment = paragraph.searchText(oldText, new PositionInParagraph(startPosRun, 0, 0)); if (tSegment != null) { - String newText = arr[i].toString(); + String newText = arr[i].toString().trim(); replaceInParagragh(paragraph, tSegment, oldText, newText); } else { - oldText = "□" + arr[i]; + oldText = "□" + arr[i].toString().trim(); tSegment = paragraph.searchText(oldText, new PositionInParagraph(startPosRun, 0, 0)); if (tSegment != null) { - String newText = arr[i].toString(); + String newText = arr[i].toString().trim(); replaceInParagragh(paragraph, tSegment, oldText, newText); } } } } else { - String oldText = valueObj.toString() + "□"; + String oldText = valueObj.toString().trim() + "□"; TextSegment tSegment = paragraph.searchText(oldText, new PositionInParagraph(startPosRun, 0, 0)); if (tSegment != null) { - String newText = valueObj.toString(); + String newText = valueObj.toString().trim(); replaceInParagragh(paragraph, tSegment, oldText, newText); } else { - oldText = "□" + valueObj.toString(); + oldText = "□" + valueObj.toString().trim(); tSegment = paragraph.searchText(oldText, new PositionInParagraph(startPosRun, 0, 0)); if (tSegment != null) { - String newText = valueObj.toString(); + String newText = valueObj.toString().trim(); replaceInParagragh(paragraph, tSegment, oldText, newText); } } diff --git a/template/58种流行病学调查表-传染病.doc b/template/58种流行病学调查表-传染病.doc new file mode 100644 index 0000000..9fead79 Binary files /dev/null and b/template/58种流行病学调查表-传染病.doc differ diff --git a/template/COVID-19.docx b/template/COVID-19.docx index 5793bea..4806b23 100644 Binary files a/template/COVID-19.docx and b/template/COVID-19.docx differ diff --git a/template/HIV/AIDS个案调查表.docx b/template/HIV/AIDS个案调查表.docx new file mode 100644 index 0000000..4012fa0 Binary files /dev/null and b/template/HIV/AIDS个案调查表.docx differ diff --git a/template/传染性非典型肺炎病例个案调查表.docx b/template/传染性非典型肺炎病例个案调查表.docx new file mode 100644 index 0000000..25742df Binary files /dev/null and b/template/传染性非典型肺炎病例个案调查表.docx differ diff --git a/template/急性弛缓性麻痹病例麻痹60天后随访调查表.docx b/template/急性弛缓性麻痹病例麻痹60天后随访调查表.docx new file mode 100644 index 0000000..e42a236 Binary files /dev/null and b/template/急性弛缓性麻痹病例麻痹60天后随访调查表.docx differ diff --git a/template/流行性乙型脑炎流行病学个案调查表.docx b/template/流行性乙型脑炎流行病学个案调查表.docx new file mode 100644 index 0000000..6800c6a Binary files /dev/null and b/template/流行性乙型脑炎流行病学个案调查表.docx differ diff --git a/template/流行性出血热流行病学个案调查表.docx b/template/流行性出血热流行病学个案调查表.docx new file mode 100644 index 0000000..a70d72f Binary files /dev/null and b/template/流行性出血热流行病学个案调查表.docx differ diff --git a/template/流行病学调查表-传染病.doc b/template/流行病学调查表-传染病.doc new file mode 100644 index 0000000..6e70d71 Binary files /dev/null and b/template/流行病学调查表-传染病.doc differ diff --git a/template/狂犬病流行病学个案调查表.docx b/template/狂犬病流行病学个案调查表.docx new file mode 100644 index 0000000..0f6e99f Binary files /dev/null and b/template/狂犬病流行病学个案调查表.docx differ diff --git a/template/登革热(登革出血热)个案调查表.docx b/template/登革热(登革出血热)个案调查表.docx new file mode 100644 index 0000000..9b39dd5 Binary files /dev/null and b/template/登革热(登革出血热)个案调查表.docx differ diff --git a/template/细菌性痢疾流行病学个案调查表.docx b/template/细菌性痢疾流行病学个案调查表.docx new file mode 100644 index 0000000..9f97996 Binary files /dev/null and b/template/细菌性痢疾流行病学个案调查表.docx differ diff --git a/template/经体液—皮肤(粘膜)传播病毒性肝炎病人个案调查表.docx b/template/经体液—皮肤(粘膜)传播病毒性肝炎病人个案调查表.docx new file mode 100644 index 0000000..7ac3120 Binary files /dev/null and b/template/经体液—皮肤(粘膜)传播病毒性肝炎病人个案调查表.docx differ diff --git a/template/经粪一口途径传播的病毒性肝炎个案调查表.docx b/template/经粪一口途径传播的病毒性肝炎个案调查表.docx new file mode 100644 index 0000000..8380b64 Binary files /dev/null and b/template/经粪一口途径传播的病毒性肝炎个案调查表.docx differ diff --git a/template/肺结核流行病学个案调查表.docx b/template/肺结核流行病学个案调查表.docx new file mode 100644 index 0000000..55e1b31 Binary files /dev/null and b/template/肺结核流行病学个案调查表.docx differ diff --git a/template/霍乱流行病学个案调查表.docx b/template/霍乱流行病学个案调查表.docx new file mode 100644 index 0000000..d7fa54d Binary files /dev/null and b/template/霍乱流行病学个案调查表.docx differ diff --git a/template/鼠疫个案调查表.docx b/template/鼠疫个案调查表.docx new file mode 100644 index 0000000..64fb379 Binary files /dev/null and b/template/鼠疫个案调查表.docx differ