From 48783ba096156931d2f01c049b48323c28fb6af7 Mon Sep 17 00:00:00 2001 From: gongzhenkun <1658878546@qq.com> Date: Mon, 9 Jan 2023 15:36:16 +0800 Subject: [PATCH] =?UTF-8?q?app37=E7=89=88=E6=9C=AC=E9=97=AE=E9=A2=98?= =?UTF-8?q?=E4=BF=AE=E5=A4=8D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../web/controller/api/AppController.java | 48 ++++++------------- .../main/resources/i18n/messages.properties | 4 +- .../web/service/SysLoginService.java | 15 ++++-- .../service/impl/TRecordServiceImpl.java | 48 +++++++++---------- 4 files changed, 49 insertions(+), 66 deletions(-) diff --git a/ruoyi-admin/src/main/java/com/ruoyi/web/controller/api/AppController.java b/ruoyi-admin/src/main/java/com/ruoyi/web/controller/api/AppController.java index f421640..623c14d 100644 --- a/ruoyi-admin/src/main/java/com/ruoyi/web/controller/api/AppController.java +++ b/ruoyi-admin/src/main/java/com/ruoyi/web/controller/api/AppController.java @@ -49,39 +49,6 @@ import java.util.stream.Collectors; @RequestMapping("/api/app") public class AppController extends BaseController { - /** - * 01.06新需求,以下字段新增bar字段,需要把base64转为图片保存 - */ - private static final List BAR_PROPERTY = new ArrayList(){{ - add("sz_pangshou"); - add("st_houbo"); - add("st_funi"); - add("st_runzao"); - add("st_cao"); - }}; - - /** - * 所有带图片的键集合 - */ - private static final List jsonKeyList = new ArrayList(){{ - add("st_avg_yellow"); - add("img_sz"); - add("img_sz_yudian"); - add("img_sz_yuban"); - add("img_sz_liewen"); - add("img_st"); - add("img_sx"); - add("img_sx_vein"); - add("sz_avg_red"); - add("sz_avg_purple"); - add("sx_vein_avg_purple"); - add("sz_pangshou"); - add("st_houbo"); - add("st_funi"); - add("st_runzao"); - add("st_cao"); - }}; - @Autowired private ITRecordService tRecordService; @@ -725,6 +692,19 @@ public class AppController extends BaseController public JSONObject removeBase64Image(JSONObject jsonObject,Long recordId) { + List jsonKeyList = new ArrayList(){{ + add("st_avg_yellow"); + add("img_sz"); + add("img_sz_yudian"); + add("img_sz_yuban"); + add("img_sz_liewen"); + add("img_st"); + add("img_sx"); + add("img_sx_vein"); + add("sz_avg_red"); + add("sz_avg_purple"); + add("sx_vein_avg_purple"); + }}; try { doRemoveBase64Image(jsonObject.getJSONObject("data"), "data", jsonKeyList, recordId); } @@ -763,7 +743,7 @@ public class AppController extends BaseController String imageKey = null; if (entry.getValue() instanceof JSONObject) { logger.info("entry key is {}", entry.getKey()); - if (entry.getKey().contains("avg") || BAR_PROPERTY.contains(entry.getKey())) { + if (entry.getKey().contains("avg")) { imageStr = ((JSONObject) entry.getValue()).getString("bar"); imageKey = "bar"; } else { diff --git a/ruoyi-admin/src/main/resources/i18n/messages.properties b/ruoyi-admin/src/main/resources/i18n/messages.properties index 71cf52d..f712bab 100644 --- a/ruoyi-admin/src/main/resources/i18n/messages.properties +++ b/ruoyi-admin/src/main/resources/i18n/messages.properties @@ -2,8 +2,8 @@ not.null=* 必须填写 user.jcaptcha.error=验证码错误 user.jcaptcha.expire=验证码已失效 -user.not.exists=用户不存在/密码错误 -user.password.not.match=用户不存在/密码错误 +user.not.exists=用户不存在 +user.password.not.match=密码错误 user.password.retry.limit.count=密码输入错误{0}次 user.password.retry.limit.exceed=密码输入错误{0}次,帐户锁定10分钟 user.password.delete=对不起,您的账号已被删除 diff --git a/ruoyi-framework/src/main/java/com/ruoyi/framework/web/service/SysLoginService.java b/ruoyi-framework/src/main/java/com/ruoyi/framework/web/service/SysLoginService.java index 3ca671e..3cafd60 100644 --- a/ruoyi-framework/src/main/java/com/ruoyi/framework/web/service/SysLoginService.java +++ b/ruoyi-framework/src/main/java/com/ruoyi/framework/web/service/SysLoginService.java @@ -5,6 +5,7 @@ import javax.annotation.Resource; import com.alibaba.fastjson.JSONObject; import com.ruoyi.common.config.RuoYiConfig; import com.ruoyi.common.core.domain.AjaxResult; +import com.ruoyi.common.core.domain.entity.SysUserEX; import com.ruoyi.common.enums.UserStatus; import com.ruoyi.common.utils.*; import com.ruoyi.common.utils.file.FileUploadUtils; @@ -14,6 +15,7 @@ import com.ruoyi.system.mapper.TDoctorMapper; import com.ruoyi.system.service.impl.UserTokenService; import org.slf4j.Logger; import org.slf4j.LoggerFactory; +import org.springframework.beans.BeanUtils; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.security.authentication.AuthenticationManager; import org.springframework.security.authentication.BadCredentialsException; @@ -130,7 +132,7 @@ public class SysLoginService if (!SecurityUtils.matchesPassword(password, sysUser.getPassword())) { log.info("登录用户:{} 密码不正确.", username); AsyncManager.me().execute(AsyncFactory.recordLogininfor(username, Constants.LOGIN_FAIL, MessageUtils.message("user.password.not.match"))); - return AjaxResult.success(MessageUtils.message("user.password.not.match")); + return AjaxResult.error(MessageUtils.message("user.password.not.match")); } LoginUser loginUser = new LoginUser(); sysUser.setDoctorId(tDoctor.getId()); @@ -153,15 +155,20 @@ public class SysLoginService log.info("login for app fill info req :{}", req); // 查询sys_user数据 SysUser sysUser = userService.selectUserByPhone(req.getPhone()); + // 查询医生表数据 + TDoctor tDoctor = tDoctorMapper.selectTDoctorByPhone(req.getPhone()); if (Objects.nonNull(sysUser)) { - if ("2".equals(sysUser.getDelFlag())) { + if ("2".equals(tDoctor.getDelFlag())) { // 医生账号被删除 重新注册 sysUser.setDelFlag("0"); sysUser.setPassword(SecurityUtils.encryptPassword("123456")); sysUser.setUserName(req.getPhone()); sysUser.setNickName(req.getName()); sysUser.setStatus("0"); - userService.updateUser(sysUser); + // 向下转型 + SysUserEX sysUserEX = new SysUserEX(); + BeanUtils.copyProperties(sysUser, sysUserEX); + userService.updateUser(sysUserEX); } else { // delFlag = 0 : 医生账号已存在 return AjaxResult.error("当前手机号已经注册!"); @@ -180,7 +187,7 @@ public class SysLoginService userService.insertUser(sysUser); } // 查询医生表数据 - TDoctor tDoctor = tDoctorMapper.selectTDoctorByPhone(req.getPhone()); +// TDoctor tDoctor = tDoctorMapper.selectTDoctorByPhone(req.getPhone()); if (Objects.nonNull(tDoctor)) { if ("2".equals(tDoctor.getDelFlag())) { // 重新注册 diff --git a/ruoyi-system/src/main/java/com/ruoyi/system/service/impl/TRecordServiceImpl.java b/ruoyi-system/src/main/java/com/ruoyi/system/service/impl/TRecordServiceImpl.java index 3cd3aab..a988605 100644 --- a/ruoyi-system/src/main/java/com/ruoyi/system/service/impl/TRecordServiceImpl.java +++ b/ruoyi-system/src/main/java/com/ruoyi/system/service/impl/TRecordServiceImpl.java @@ -37,6 +37,8 @@ public class TRecordServiceImpl implements ITRecordService private static Map jsonKeyMap = new HashMap<>(); + private static int index = 0; + private static Map newJsonKeyMap = new HashMap(){{ put("sx_vein_color", "sx_vein_color2"); put("sz_color", "sz_color2"); @@ -67,24 +69,13 @@ public class TRecordServiceImpl implements ITRecordService }}; /** - * 只需要获取量化值的key + * 需要获取量化值的key */ private static final List getQuantificationKeys = new ArrayList(){{ add("sx_vein_width"); add("sx_vein_length"); }}; - /** - * 需要追加量化值的keys - */ - private static final List addQuantificationKeys = new ArrayList(){{ - add("sz_pangshou"); - add("st_houbo"); - add("st_funi"); - add("st_runzao"); - add("st_cao"); - }}; - @Autowired private TRecordMapper tRecordMapper; @@ -203,6 +194,7 @@ public class TRecordServiceImpl implements ITRecordService return ""; } // 将老数据结构对应的数据读出来 + jsonKeyMap.clear(); JSONObject jsonObject = JSONObject.parseObject(jsonString); readJsonToMap(jsonObject.getJSONObject("data")); logger.info("jsonKeyMap is {}", jsonKeyMap); @@ -295,11 +287,11 @@ public class TRecordServiceImpl implements ITRecordService { logger.info("get history list param is : {} ", tRecord); List tRecords = tRecordMapper.selectTRecordList(tRecord); - tRecords.removeIf(o->"0".equals(o.getStatus())); - if (CollectionUtils.isEmpty(tRecords)){ + List collect = tRecords.stream().filter(tRecord1 -> "1".equals(tRecord1.getStatus())).collect(Collectors.toList()); + if (CollectionUtils.isEmpty(collect)){ return AjaxResult.success(); } - List records = tRecords.stream().sorted(Comparator.comparing(TRecord::getCreateTime)).collect(Collectors.toList()); + List records = collect.stream().sorted(Comparator.comparing(TRecord::getCreateTime)).collect(Collectors.toList()); RecordHistoryDataResp recordHistoryDataRespMap = getDataList(records); return AjaxResult.success(recordHistoryDataRespMap); } @@ -328,17 +320,20 @@ public class TRecordServiceImpl implements ITRecordService }).filter(Objects::nonNull).collect(Collectors.toList()); if (!CollectionUtils.isEmpty(result)){ HashMap> map = new HashMap<>(); - result.forEach(jsonObject -> { - getJsonData(jsonObject.getJSONObject("data"), "data", map, ignoreKeys); - logger.info("history map is {} ", map); + for (int i = 0; i < result.size(); i++) { + index = i + 1; + getJsonData(result.get(i).getJSONObject("data"), "data", map, ignoreKeys); map.forEach((key, value) -> { - if (value.size() < result.indexOf(jsonObject) + 1) { + // 向后插入 + if (value.size() < index) { value.add("-1"); } }); - }); + logger.info("index is '{}', history map is '{}' ", index, map); + } recordHistoryDataResp.setHistoryDataMap(map); } + index = 0; return recordHistoryDataResp; } @@ -358,7 +353,7 @@ public class TRecordServiceImpl implements ITRecordService // 这两种情况应该添加默认值 if (nullValKeys.contains(listName) && null == ((JSONObject) obj).get("v")) { // 加默认值 - doSetHistoryData(historyDataMap, listName, "0"); + doSetHistoryData(historyDataMap, listName, "-1"); } for (Map.Entry entry : ((JSONObject) obj).entrySet()) { // 忽略带图片字段 @@ -378,11 +373,6 @@ public class TRecordServiceImpl implements ITRecordService if (!getQuantificationKeys.contains(listName) && "v".equals(entry.getKey())) { doSetHistoryData(historyDataMap, listName, entry.getValue()); } - // 追加量化值数据 - if (addQuantificationKeys.contains(listName) && "quantification".equals(entry.getKey())) { - String newListName = listName + "_q"; - doSetHistoryData(historyDataMap, newListName, entry.getValue()); - } } } } @@ -402,6 +392,12 @@ public class TRecordServiceImpl implements ITRecordService } else { list = historyDataMap.get(listName); } + // 判断是否需要向前补数据 + if ((list.size() + 1) < index) { + for (int i = 0; i < index - list.size(); i++) { + list.add(0, "-1"); + } + } list.add(StringUtils.isNull(val) || StringUtils.isEmpty(val.toString()) ? "-1" : val); historyDataMap.put(listName, list); }