|
@@ -1,21 +1,35 @@
|
|
|
package cn.hnthyy.thmz.controller.mz;
|
|
|
|
|
|
+import cn.hnthyy.thmz.Utils.AssertUtil;
|
|
|
+import cn.hnthyy.thmz.Utils.R;
|
|
|
import cn.hnthyy.thmz.Utils.TokenUtil;
|
|
|
import cn.hnthyy.thmz.comment.UserLoginToken;
|
|
|
+import cn.hnthyy.thmz.entity.his.mz.CriticalMessage;
|
|
|
import cn.hnthyy.thmz.entity.thmz.CriticalValue;
|
|
|
import cn.hnthyy.thmz.entity.thmz.User;
|
|
|
-import cn.hnthyy.thmz.entity.thmz.UserRoleRelation;
|
|
|
-import cn.hnthyy.thmz.enums.YesNoEnum;
|
|
|
+import cn.hnthyy.thmz.service.his.mz.CriticalMessageService;
|
|
|
import cn.hnthyy.thmz.service.thmz.CriticalValueService;
|
|
|
import cn.hnthyy.thmz.service.thmz.UserRoleRelationService;
|
|
|
+import cn.hnthyy.thmz.service.thmz.UserService;
|
|
|
+import cn.hutool.core.collection.CollUtil;
|
|
|
+import cn.hutool.core.convert.Convert;
|
|
|
+import cn.hutool.core.util.StrUtil;
|
|
|
+import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
|
|
+import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
|
|
import lombok.extern.slf4j.Slf4j;
|
|
|
import org.apache.commons.lang3.StringUtils;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
-import org.springframework.web.bind.annotation.*;
|
|
|
+import org.springframework.web.bind.annotation.PostMapping;
|
|
|
+import org.springframework.web.bind.annotation.RequestBody;
|
|
|
+import org.springframework.web.bind.annotation.RequestMapping;
|
|
|
+import org.springframework.web.bind.annotation.RequestMethod;
|
|
|
+import org.springframework.web.bind.annotation.RequestParam;
|
|
|
+import org.springframework.web.bind.annotation.RestController;
|
|
|
|
|
|
+import javax.annotation.Resource;
|
|
|
import javax.servlet.http.HttpServletRequest;
|
|
|
+import java.util.Date;
|
|
|
import java.util.HashMap;
|
|
|
-import java.util.List;
|
|
|
import java.util.Map;
|
|
|
|
|
|
@Slf4j
|
|
@@ -23,8 +37,10 @@ import java.util.Map;
|
|
|
public class CriticalValueController {
|
|
|
@Autowired
|
|
|
private CriticalValueService criticalValueService;
|
|
|
- @Autowired
|
|
|
- private UserRoleRelationService userRoleRelationService;
|
|
|
+ @Resource
|
|
|
+ private CriticalMessageService service;
|
|
|
+ @Resource
|
|
|
+ private UserService userService;
|
|
|
|
|
|
/**
|
|
|
* 获取危急值列表
|
|
@@ -41,26 +57,6 @@ public class CriticalValueController {
|
|
|
resultMap.put("message", "查询参数不能为空");
|
|
|
return resultMap;
|
|
|
}
|
|
|
- if (StringUtils.isBlank(criticalValue.getCommonParams())) {
|
|
|
- criticalValue.setCommonParams(null);
|
|
|
- } else {
|
|
|
- criticalValue.setCommonParams("%" + criticalValue.getCommonParams() + "%");
|
|
|
- }
|
|
|
- User tokenUser = TokenUtil.getUser(httpServletRequest);
|
|
|
- List<UserRoleRelation> userRoleRelationList=userRoleRelationService.queryByUserId(tokenUser.getId());
|
|
|
- //超级管理员可以看所有的数据
|
|
|
- boolean isAdmin = false;
|
|
|
- if(userRoleRelationList!=null && userRoleRelationList.size()>0){
|
|
|
- for(UserRoleRelation userRoleRelation:userRoleRelationList){
|
|
|
- if(userRoleRelation!=null && userRoleRelation.getRoleId()==1){
|
|
|
- isAdmin=true;
|
|
|
- break;
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
- if(!isAdmin){
|
|
|
- criticalValue.setEmployeeCodes("%" + tokenUser.getUserCode() + "%");
|
|
|
- }
|
|
|
if (StringUtils.isBlank(criticalValue.getBeginDate())) {
|
|
|
resultMap.put("code", -1);
|
|
|
resultMap.put("message", "查询记录失败,开始日期参数为空");
|
|
@@ -81,17 +77,24 @@ public class CriticalValueController {
|
|
|
resultMap.put("message", "查询记录失败,当前所在页参数为空");
|
|
|
return resultMap;
|
|
|
}
|
|
|
- Integer total = criticalValueService.queryCountCriticalValue(criticalValue);
|
|
|
- if(total==0){
|
|
|
- resultMap.put("code", -1);
|
|
|
- resultMap.put("message", "未查询到危急值信息");
|
|
|
- return resultMap;
|
|
|
+ Page<CriticalMessage> page = new Page<>(criticalValue.getOffset()/criticalValue.getPageSize()+1,criticalValue.getPageSize());
|
|
|
+ QueryWrapper queryWrapper = new QueryWrapper();
|
|
|
+ queryWrapper.ge("create_time", criticalValue.getBeginDate());
|
|
|
+ queryWrapper.le( "create_time", criticalValue.getEndDate());
|
|
|
+ queryWrapper.like(StrUtil.isNotBlank(criticalValue.getCommonParams()), "pat_no", criticalValue.getCommonParams());
|
|
|
+ Page<CriticalMessage> data = service.page(page, queryWrapper);
|
|
|
+ if(CollUtil.isNotEmpty(data.getRecords())){
|
|
|
+ for(CriticalMessage item :data.getRecords()){
|
|
|
+ if(StrUtil.isNotBlank(item.getHandleStaff())){
|
|
|
+ User user = userService.queryUserByUserIdCode(item.getHandleStaff());
|
|
|
+ item.setHandleStaff(user ==null ? "" : user.getUserName());
|
|
|
+ }
|
|
|
+ }
|
|
|
}
|
|
|
- List<CriticalValue> criticalValueList = criticalValueService.queryCriticalValueWithPage(criticalValue);
|
|
|
resultMap.put("code", 0);
|
|
|
resultMap.put("message", "获取危急值列表成功");
|
|
|
- resultMap.put("total", total);
|
|
|
- resultMap.put("data", criticalValueList);
|
|
|
+ resultMap.put("total", data.getTotal());
|
|
|
+ resultMap.put("data", data.getRecords());
|
|
|
return resultMap;
|
|
|
} catch (Exception e) {
|
|
|
e.printStackTrace();
|
|
@@ -102,6 +105,21 @@ public class CriticalValueController {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+ @UserLoginToken
|
|
|
+ @PostMapping("/dealCriticalMessage")
|
|
|
+ public R dealCriticalMessage(@RequestBody Map<String,Object> param) {
|
|
|
+ Integer id = Convert.toInt(param.get("id"));
|
|
|
+ AssertUtil.isNotBlank(id,"id 不能为空");
|
|
|
+ CriticalMessage criticalMessage = CriticalMessage.builder()
|
|
|
+ .id(id)
|
|
|
+ .handleStaff(TokenUtil.getUser().getUserIdCode())
|
|
|
+ .handleTime(new Date())
|
|
|
+ .build();
|
|
|
+ service.updateById(criticalMessage);
|
|
|
+ return R.ok();
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
/**
|
|
|
* 根据ID查询危急值
|
|
|
*
|