护理记录
parent
f4fbb8d0c4
commit
ddbe949363
@ -0,0 +1,103 @@
|
|||||||
|
package com.flossom.common.core.domain.req;
|
||||||
|
|
||||||
|
import com.flossom.common.core.annotation.Excel;
|
||||||
|
import com.flossom.common.core.web.domain.BaseEntity;
|
||||||
|
import org.apache.commons.lang3.builder.ToStringBuilder;
|
||||||
|
import org.apache.commons.lang3.builder.ToStringStyle;
|
||||||
|
|
||||||
|
import javax.validation.constraints.NotBlank;
|
||||||
|
import javax.validation.constraints.NotNull;
|
||||||
|
import java.time.LocalTime;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 用户护理日志对象 wx_nursing_log
|
||||||
|
*
|
||||||
|
* @author flossom
|
||||||
|
* @date 2024-01-29
|
||||||
|
*/
|
||||||
|
public class WxNursingLogReq {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 设备id
|
||||||
|
*/
|
||||||
|
@NotNull(message = "请选择设备")
|
||||||
|
private Long instrumentId;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 设备名称
|
||||||
|
*/
|
||||||
|
@NotNull(message = "请选择设备")
|
||||||
|
private String instrumentName;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 模式ID
|
||||||
|
*/
|
||||||
|
@NotNull(message = "请选择护理模式")
|
||||||
|
private Long modeId;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 模式名称
|
||||||
|
*/
|
||||||
|
@NotBlank(message = "请选择护理模式")
|
||||||
|
private String modeName;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 护理总时长
|
||||||
|
*/
|
||||||
|
@NotNull(message = "护理时长不能为空")
|
||||||
|
private LocalTime nursingTime;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 完成度
|
||||||
|
*/
|
||||||
|
private Double completionPercentage;
|
||||||
|
|
||||||
|
|
||||||
|
public void setInstrumentId(Long instrumentId) {
|
||||||
|
this.instrumentId = instrumentId;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Long getInstrumentId() {
|
||||||
|
return instrumentId;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setModeId(Long modeId) {
|
||||||
|
this.modeId = modeId;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Long getModeId() {
|
||||||
|
return modeId;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setModeName(String modeName) {
|
||||||
|
this.modeName = modeName;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getModeName() {
|
||||||
|
return modeName;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setNursingTime(LocalTime nursingTime) {
|
||||||
|
this.nursingTime = nursingTime;
|
||||||
|
}
|
||||||
|
|
||||||
|
public LocalTime getNursingTime() {
|
||||||
|
return nursingTime;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getInstrumentName() {
|
||||||
|
return instrumentName;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setInstrumentName(String instrumentName) {
|
||||||
|
this.instrumentName = instrumentName;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Double getCompletionPercentage() {
|
||||||
|
return completionPercentage;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setCompletionPercentage(Double completionPercentage) {
|
||||||
|
this.completionPercentage = completionPercentage;
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -0,0 +1,49 @@
|
|||||||
|
package com.flossom.common.core.domain.ret;
|
||||||
|
|
||||||
|
import com.fasterxml.jackson.annotation.JsonFormat;
|
||||||
|
import com.flossom.common.core.annotation.Excel;
|
||||||
|
|
||||||
|
import java.time.LocalTime;
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.Date;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 当月护理记录统计信息
|
||||||
|
*/
|
||||||
|
public class WxNursingStatisticsRet {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 当月护理天数
|
||||||
|
*/
|
||||||
|
private Integer nursingNum;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 当月护理时长
|
||||||
|
*/
|
||||||
|
private LocalTime nursingTime;
|
||||||
|
|
||||||
|
public WxNursingStatisticsRet() {
|
||||||
|
}
|
||||||
|
|
||||||
|
public WxNursingStatisticsRet(Integer nursingNum, LocalTime nursingTime) {
|
||||||
|
this.nursingNum = nursingNum;
|
||||||
|
this.nursingTime = nursingTime;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Integer getNursingNum() {
|
||||||
|
return nursingNum;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setNursingNum(Integer nursingNum) {
|
||||||
|
this.nursingNum = nursingNum;
|
||||||
|
}
|
||||||
|
|
||||||
|
public LocalTime getNursingTime() {
|
||||||
|
return nursingTime;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setNursingTime(LocalTime nursingTime) {
|
||||||
|
this.nursingTime = nursingTime;
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -0,0 +1,61 @@
|
|||||||
|
package com.flossom.common.core.mapper;
|
||||||
|
|
||||||
|
import com.flossom.common.core.domain.entity.WxNursingLog;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 用户护理日志Mapper接口
|
||||||
|
*
|
||||||
|
* @author flossom
|
||||||
|
* @date 2024-01-29
|
||||||
|
*/
|
||||||
|
public interface WxNursingLogMapper {
|
||||||
|
/**
|
||||||
|
* 查询用户护理日志
|
||||||
|
*
|
||||||
|
* @param id 用户护理日志主键
|
||||||
|
* @return 用户护理日志
|
||||||
|
*/
|
||||||
|
public WxNursingLog selectWxNursingLogById(Long id);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 查询用户护理日志列表
|
||||||
|
*
|
||||||
|
* @param wxNursingLog 用户护理日志
|
||||||
|
* @return 用户护理日志集合
|
||||||
|
*/
|
||||||
|
public List<WxNursingLog> selectWxNursingLogList(WxNursingLog wxNursingLog);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 新增用户护理日志
|
||||||
|
*
|
||||||
|
* @param wxNursingLog 用户护理日志
|
||||||
|
* @return 结果
|
||||||
|
*/
|
||||||
|
public int insertWxNursingLog(WxNursingLog wxNursingLog);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 修改用户护理日志
|
||||||
|
*
|
||||||
|
* @param wxNursingLog 用户护理日志
|
||||||
|
* @return 结果
|
||||||
|
*/
|
||||||
|
public int updateWxNursingLog(WxNursingLog wxNursingLog);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 删除用户护理日志
|
||||||
|
*
|
||||||
|
* @param id 用户护理日志主键
|
||||||
|
* @return 结果
|
||||||
|
*/
|
||||||
|
public int deleteWxNursingLogById(Long id);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 批量删除用户护理日志
|
||||||
|
*
|
||||||
|
* @param ids 需要删除的数据主键集合
|
||||||
|
* @return 结果
|
||||||
|
*/
|
||||||
|
public int deleteWxNursingLogByIds(Long[] ids);
|
||||||
|
}
|
||||||
@ -0,0 +1,119 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8" ?>
|
||||||
|
<!DOCTYPE mapper
|
||||||
|
PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||||
|
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
||||||
|
<mapper namespace="com.flossom.common.core.mapper.WxNursingLogMapper">
|
||||||
|
|
||||||
|
<resultMap type="WxNursingLog" id="WxNursingLogResult">
|
||||||
|
<result property="id" column="id" />
|
||||||
|
<result property="userId" column="user_id" />
|
||||||
|
<result property="instrumentId" column="instrument_id" />
|
||||||
|
<result property="instrumentName" column="instrument_name" />
|
||||||
|
<result property="online" column="online" />
|
||||||
|
<result property="modeId" column="mode_id" />
|
||||||
|
<result property="modeName" column="mode_name" />
|
||||||
|
<result property="nursingTime" column="nursing_time" />
|
||||||
|
<result property="completionPercentage" column="completion_percentage" />
|
||||||
|
<result property="status" column="status" />
|
||||||
|
<result property="createBy" column="create_by" />
|
||||||
|
<result property="createTime" column="create_time" />
|
||||||
|
<result property="updateBy" column="update_by" />
|
||||||
|
<result property="updateTime" column="update_time" />
|
||||||
|
</resultMap>
|
||||||
|
|
||||||
|
<sql id="selectWxNursingLogVo">
|
||||||
|
select id, user_id, instrument_id, instrument_name, online, mode_id, mode_name, nursing_time, completion_percentage, status, create_by, create_time, update_by, update_time from wx_nursing_log
|
||||||
|
</sql>
|
||||||
|
|
||||||
|
<select id="selectWxNursingLogList" parameterType="WxNursingLog" resultMap="WxNursingLogResult">
|
||||||
|
<include refid="selectWxNursingLogVo"/>
|
||||||
|
<where>
|
||||||
|
<if test="userId != null "> and user_id = #{userId}</if>
|
||||||
|
<if test="instrumentId != null "> and instrument_id = #{instrumentId}</if>
|
||||||
|
<if test="instrumentName != null "> and instrument_name = #{instrumentName}</if>
|
||||||
|
<if test="online != null "> and online = #{online}</if>
|
||||||
|
<if test="modeId != null "> and mode_id = #{modeId}</if>
|
||||||
|
<if test="modeName != null and modeName != ''"> and mode_name like concat('%', #{modeName}, '%')</if>
|
||||||
|
<if test="nursingTime != null "> and nursing_time = #{nursingTime}</if>
|
||||||
|
<if test="completionPercentage != null "> and completion_percentage = #{completionPercentage}</if>
|
||||||
|
<if test="status != null "> and status = #{status}</if>
|
||||||
|
<if test="params != null and params.beginTime != null">
|
||||||
|
and create_time >= #{params.beginTime}
|
||||||
|
</if>
|
||||||
|
<if test="params != null and params.endTime != null">
|
||||||
|
and create_time <= #{params.endTime}
|
||||||
|
</if>
|
||||||
|
</where>
|
||||||
|
ORDER BY update_time DESC
|
||||||
|
</select>
|
||||||
|
|
||||||
|
<select id="selectWxNursingLogById" parameterType="Long" resultMap="WxNursingLogResult">
|
||||||
|
<include refid="selectWxNursingLogVo"/>
|
||||||
|
where id = #{id}
|
||||||
|
</select>
|
||||||
|
|
||||||
|
<insert id="insertWxNursingLog" parameterType="WxNursingLog" useGeneratedKeys="true" keyProperty="id">
|
||||||
|
insert into wx_nursing_log
|
||||||
|
<trim prefix="(" suffix=")" suffixOverrides=",">
|
||||||
|
<if test="userId != null">user_id,</if>
|
||||||
|
<if test="instrumentId != null">instrument_id,</if>
|
||||||
|
<if test="instrumentName != null">instrument_name,</if>
|
||||||
|
<if test="online != null">online,</if>
|
||||||
|
<if test="modeId != null">mode_id,</if>
|
||||||
|
<if test="modeName != null">mode_name,</if>
|
||||||
|
<if test="nursingTime != null">nursing_time,</if>
|
||||||
|
<if test="completionPercentage != null">completion_percentage,</if>
|
||||||
|
<if test="status != null">status,</if>
|
||||||
|
<if test="createBy != null">create_by,</if>
|
||||||
|
<if test="createTime != null">create_time,</if>
|
||||||
|
<if test="updateBy != null">update_by,</if>
|
||||||
|
<if test="updateTime != null">update_time,</if>
|
||||||
|
</trim>
|
||||||
|
<trim prefix="values (" suffix=")" suffixOverrides=",">
|
||||||
|
<if test="userId != null">#{userId},</if>
|
||||||
|
<if test="instrumentId != null">#{instrumentId},</if>
|
||||||
|
<if test="instrumentName != null">#{instrumentName},</if>
|
||||||
|
<if test="online != null">#{online},</if>
|
||||||
|
<if test="modeId != null">#{modeId},</if>
|
||||||
|
<if test="modeName != null">#{modeName},</if>
|
||||||
|
<if test="nursingTime != null">#{nursingTime},</if>
|
||||||
|
<if test="completionPercentage != null">#{completionPercentage},</if>
|
||||||
|
<if test="status != null">#{status},</if>
|
||||||
|
<if test="createBy != null">#{createBy},</if>
|
||||||
|
<if test="createTime != null">#{createTime},</if>
|
||||||
|
<if test="updateBy != null">#{updateBy},</if>
|
||||||
|
<if test="updateTime != null">#{updateTime},</if>
|
||||||
|
</trim>
|
||||||
|
</insert>
|
||||||
|
|
||||||
|
<update id="updateWxNursingLog" parameterType="WxNursingLog">
|
||||||
|
update wx_nursing_log
|
||||||
|
<trim prefix="SET" suffixOverrides=",">
|
||||||
|
<if test="userId != null">user_id = #{userId},</if>
|
||||||
|
<if test="instrumentId != null">instrument_id = #{instrumentId},</if>
|
||||||
|
<if test="instrumentName != null">instrument_name = #{instrumentName},</if>
|
||||||
|
<if test="online != null">online = #{online},</if>
|
||||||
|
<if test="modeId != null">mode_id = #{modeId},</if>
|
||||||
|
<if test="modeName != null">mode_name = #{modeName},</if>
|
||||||
|
<if test="nursingTime != null">nursing_time = #{nursingTime},</if>
|
||||||
|
<if test="completionPercentage != null">completion_percentage = #{completionPercentage},</if>
|
||||||
|
<if test="status != null">status = #{status},</if>
|
||||||
|
<if test="createBy != null">create_by = #{createBy},</if>
|
||||||
|
<if test="createTime != null">create_time = #{createTime},</if>
|
||||||
|
<if test="updateBy != null">update_by = #{updateBy},</if>
|
||||||
|
<if test="updateTime != null">update_time = #{updateTime},</if>
|
||||||
|
</trim>
|
||||||
|
where id = #{id}
|
||||||
|
</update>
|
||||||
|
|
||||||
|
<delete id="deleteWxNursingLogById" parameterType="Long">
|
||||||
|
delete from wx_nursing_log where id = #{id}
|
||||||
|
</delete>
|
||||||
|
|
||||||
|
<delete id="deleteWxNursingLogByIds" parameterType="String">
|
||||||
|
delete from wx_nursing_log where id in
|
||||||
|
<foreach item="id" collection="array" open="(" separator="," close=")">
|
||||||
|
#{id}
|
||||||
|
</foreach>
|
||||||
|
</delete>
|
||||||
|
</mapper>
|
||||||
@ -0,0 +1,60 @@
|
|||||||
|
package com.flossom.miniProgram.controller;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
import com.flossom.common.core.domain.R;
|
||||||
|
import com.flossom.common.core.domain.entity.WxNursingLog;
|
||||||
|
import com.flossom.common.core.domain.req.WxNursingLogReq;
|
||||||
|
import com.flossom.common.core.web.controller.BaseController;
|
||||||
|
import com.flossom.common.core.web.domain.AjaxResult;
|
||||||
|
import com.flossom.common.core.web.page.TableDataInfo;
|
||||||
|
import com.flossom.miniProgram.service.IWxNursingLogService;
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.validation.annotation.Validated;
|
||||||
|
import org.springframework.web.bind.annotation.*;
|
||||||
|
|
||||||
|
import javax.validation.Valid;
|
||||||
|
import javax.validation.constraints.NotNull;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 用户护理日志Controller
|
||||||
|
*
|
||||||
|
* @author flossom
|
||||||
|
* @date 2024-01-29
|
||||||
|
*/
|
||||||
|
@RestController
|
||||||
|
@RequestMapping("/nursingLog")
|
||||||
|
public class WxNursingLogController extends BaseController {
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private IWxNursingLogService wxNursingLogService;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 查询用户护理记录
|
||||||
|
*/
|
||||||
|
@GetMapping("/record")
|
||||||
|
public TableDataInfo record(@NotNull(message = "请选择仪器")
|
||||||
|
@RequestParam(value = "instrumentId", required = false) Long instrumentId) {
|
||||||
|
startPage();
|
||||||
|
List<WxNursingLog> list = wxNursingLogService.selectWxNursingLogList(instrumentId);
|
||||||
|
return getDataTable(list);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 查询用户护理记录的当月统计信息
|
||||||
|
*/
|
||||||
|
@GetMapping("/statistics")
|
||||||
|
public R statistics(@NotNull(message = "请选择仪器") @RequestParam(value = "instrumentId") Long instrumentId) {
|
||||||
|
return R.ok(wxNursingLogService.statistics(instrumentId));
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 新增用户护理日志
|
||||||
|
*/
|
||||||
|
@PostMapping("/add")
|
||||||
|
public R add(@Validated @RequestBody WxNursingLogReq wxNursingLogReq) {
|
||||||
|
wxNursingLogService.insertWxNursingLog(wxNursingLogReq);
|
||||||
|
return R.ok();
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -0,0 +1,29 @@
|
|||||||
|
package com.flossom.miniProgram.service;
|
||||||
|
|
||||||
|
import com.flossom.common.core.domain.entity.WxNursingLog;
|
||||||
|
import com.flossom.common.core.domain.req.WxNursingLogReq;
|
||||||
|
import com.flossom.common.core.domain.ret.WxNursingStatisticsRet;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 用户护理日志Service接口
|
||||||
|
*
|
||||||
|
* @author flossom
|
||||||
|
* @date 2024-01-29
|
||||||
|
*/
|
||||||
|
public interface IWxNursingLogService {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 查询用户护理日志列表
|
||||||
|
*/
|
||||||
|
public List<WxNursingLog> selectWxNursingLogList(Long instrumentId);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 新增用户护理日志
|
||||||
|
*/
|
||||||
|
public void insertWxNursingLog(WxNursingLogReq wxNursingLogReq);
|
||||||
|
|
||||||
|
WxNursingStatisticsRet statistics(Long instrumentId);
|
||||||
|
}
|
||||||
@ -0,0 +1,182 @@
|
|||||||
|
package com.flossom.miniProgram.service.impl;
|
||||||
|
|
||||||
|
import java.time.LocalDateTime;
|
||||||
|
import java.time.LocalTime;
|
||||||
|
import java.time.temporal.TemporalAdjusters;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
import com.flossom.common.core.domain.entity.*;
|
||||||
|
import com.flossom.common.core.domain.req.WxNursingLogReq;
|
||||||
|
import com.flossom.common.core.domain.ret.WxNursingStatisticsRet;
|
||||||
|
import com.flossom.common.core.enums.Status;
|
||||||
|
import com.flossom.common.core.exception.ServiceException;
|
||||||
|
import com.flossom.common.core.mapper.WxInstrumentMapper;
|
||||||
|
import com.flossom.common.core.mapper.WxModeMapper;
|
||||||
|
import com.flossom.common.core.mapper.WxNursingLogMapper;
|
||||||
|
import com.flossom.common.core.utils.DateUtils;
|
||||||
|
import com.flossom.common.core.utils.StringUtils;
|
||||||
|
import com.flossom.common.security.utils.DictUtils;
|
||||||
|
import com.flossom.common.security.utils.SecurityUtils;
|
||||||
|
import com.flossom.miniProgram.service.IWxNursingLogService;
|
||||||
|
import org.springframework.beans.BeanUtils;
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 用户护理日志Service业务层处理
|
||||||
|
*
|
||||||
|
* @author flossom
|
||||||
|
* @date 2024-01-29
|
||||||
|
*/
|
||||||
|
@Service
|
||||||
|
public class WxNursingLogServiceImpl implements IWxNursingLogService {
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private WxNursingLogMapper wxNursingLogMapper;
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private WxInstrumentMapper wxInstrumentMapper;
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private WxModeMapper wxModeMapper;
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public WxNursingStatisticsRet statistics(Long instrumentId) {
|
||||||
|
// 排序:最新的护理记录在最上方;图片由后台模式管理-模式封面图片进行配置;
|
||||||
|
WxNursingLog queryNursingLog = new WxNursingLog();
|
||||||
|
queryNursingLog.setInstrumentId(instrumentId);
|
||||||
|
LocalDateTime now = LocalDateTime.now();
|
||||||
|
queryNursingLog.getParams().put("beginTime", now.with(TemporalAdjusters.firstDayOfMonth()).with(LocalTime.MIN));
|
||||||
|
queryNursingLog.getParams().put("endTime", now.with(TemporalAdjusters.lastDayOfMonth()).with(LocalTime.MAX));
|
||||||
|
List<WxNursingLog> wxNursingLogList = wxNursingLogMapper.selectWxNursingLogList(queryNursingLog);
|
||||||
|
if (wxNursingLogList != null) {
|
||||||
|
WxNursingStatisticsRet wxNursingStatisticsRet = new WxNursingStatisticsRet();
|
||||||
|
wxNursingStatisticsRet.setNursingNum(wxNursingLogList.size());
|
||||||
|
Integer totalNursingSecond = 0;
|
||||||
|
if (wxNursingLogList.size() > 0) {
|
||||||
|
for (WxNursingLog wxNursingLog : wxNursingLogList) {
|
||||||
|
if (wxNursingLog.getNursingTime() != null) {
|
||||||
|
totalNursingSecond += wxNursingLog.getNursingTime().toSecondOfDay();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
wxNursingStatisticsRet.setNursingTime(LocalTime.ofSecondOfDay(totalNursingSecond));
|
||||||
|
return wxNursingStatisticsRet;
|
||||||
|
}
|
||||||
|
return new WxNursingStatisticsRet(0, LocalTime.ofSecondOfDay(0));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 查询用户护理日志列表
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public List<WxNursingLog> selectWxNursingLogList(Long instrumentId) {
|
||||||
|
// 排序:最新的护理记录在最上方;图片由后台模式管理-模式封面图片进行配置;
|
||||||
|
WxNursingLog wxNursingLog = new WxNursingLog();
|
||||||
|
wxNursingLog.setInstrumentId(instrumentId);
|
||||||
|
List<WxNursingLog> wxNursingLogList = wxNursingLogMapper.selectWxNursingLogList(wxNursingLog);
|
||||||
|
if (wxNursingLogList != null && wxNursingLogList.size() > 0) {
|
||||||
|
for (WxNursingLog nursingLog : wxNursingLogList) {
|
||||||
|
WxMode wxMode = wxModeMapper.selectWxModeById(nursingLog.getModeId());
|
||||||
|
if (wxMode != null) {
|
||||||
|
nursingLog.setModeImage(wxMode.getModeBanner());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return wxNursingLogList;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 新增用户护理日志
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public void insertWxNursingLog(WxNursingLogReq wxNursingLogReq) {
|
||||||
|
/* 查询 同一仪器,同一模式 下,是否有相同的记录,如果有合并护理时间 */
|
||||||
|
WxInstrument wxInstrument = wxInstrumentMapper.selectWxInstrumentById(wxNursingLogReq.getInstrumentId());
|
||||||
|
if (wxInstrument == null) {
|
||||||
|
throw new ServiceException("保存失败");
|
||||||
|
}
|
||||||
|
WxNursingLog queryNursingLog = new WxNursingLog();
|
||||||
|
queryNursingLog.setUserId(SecurityUtils.getLoginUser().getWxUserMember().getId());
|
||||||
|
queryNursingLog.setInstrumentId(wxNursingLogReq.getInstrumentId());
|
||||||
|
LocalDateTime now = LocalDateTime.now();
|
||||||
|
queryNursingLog.getParams().put("beginTime", LocalDateTime.of(now.toLocalDate(), LocalTime.MIN));
|
||||||
|
queryNursingLog.getParams().put("endTime", LocalDateTime.of(now.toLocalDate(), LocalTime.MAX));
|
||||||
|
List<WxNursingLog> wxNursingLogList = wxNursingLogMapper.selectWxNursingLogList(queryNursingLog);
|
||||||
|
|
||||||
|
if (wxNursingLogList != null && wxNursingLogList.size() > 0) {
|
||||||
|
// 存在,修改
|
||||||
|
WxNursingLog updateNursingLog = new WxNursingLog();
|
||||||
|
WxNursingLog wxNursingLog = wxNursingLogList.get(0);
|
||||||
|
// 非IOT仪器没有护理时间
|
||||||
|
if (wxNursingLog.getNursingTime() != null) {
|
||||||
|
if (wxNursingLogReq.getNursingTime() != null) {
|
||||||
|
updateNursingLog.setNursingTime(wxNursingLog.getNursingTime().plusSeconds(wxNursingLogReq.getNursingTime().toSecondOfDay()));
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
updateNursingLog.setNursingTime(wxNursingLogReq.getNursingTime());
|
||||||
|
}
|
||||||
|
LocalTime nursingTime = wxInstrument.getNursingTime();
|
||||||
|
if (nursingTime != null) {
|
||||||
|
Integer userNursingTime = updateNursingLog.getNursingTime().toSecondOfDay();
|
||||||
|
Integer instrumentNursingTime = nursingTime.toSecondOfDay();
|
||||||
|
if (userNursingTime != null && userNursingTime > instrumentNursingTime) {
|
||||||
|
updateNursingLog.setCompletionPercentage(1.0);
|
||||||
|
} else {
|
||||||
|
if (instrumentNursingTime != null && instrumentNursingTime != 0) {
|
||||||
|
updateNursingLog.setCompletionPercentage(Double.valueOf(userNursingTime) / instrumentNursingTime);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
updateNursingLog.setId(wxNursingLog.getId());
|
||||||
|
updateNursingLog.setUpdateBy(SecurityUtils.getLoginUser().getWxUserMember().getNickname());
|
||||||
|
updateNursingLog.setUpdateTime(DateUtils.getNowDate());
|
||||||
|
wxNursingLogMapper.updateWxNursingLog(updateNursingLog);
|
||||||
|
} else {
|
||||||
|
// 不存在,新增
|
||||||
|
WxNursingLog wxNursingLog = new WxNursingLog();
|
||||||
|
BeanUtils.copyProperties(wxNursingLogReq, wxNursingLog);
|
||||||
|
wxNursingLog.setUserId(SecurityUtils.getLoginUser().getWxUserMember().getId());
|
||||||
|
// 非IOT仪器没有护理时间
|
||||||
|
LocalTime nursingTime = wxInstrument.getNursingTime();
|
||||||
|
if (nursingTime != null) {
|
||||||
|
Integer instrumentNursingTime = nursingTime.toSecondOfDay();
|
||||||
|
Integer userNursingTime = wxNursingLog.getNursingTime().toSecondOfDay();
|
||||||
|
if (instrumentNursingTime != null && instrumentNursingTime != 0) {
|
||||||
|
wxNursingLog.setCompletionPercentage(Double.valueOf(userNursingTime) / instrumentNursingTime);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// 离线状态/在线状态
|
||||||
|
Boolean online = true;
|
||||||
|
List<SysDictData> nursingOfflineInstrumentModelDict = DictUtils.getDictCache("nursing_offline_instrument_model");
|
||||||
|
if (nursingOfflineInstrumentModelDict != null && nursingOfflineInstrumentModelDict.size() > 0) {
|
||||||
|
for (SysDictData sysDictData : nursingOfflineInstrumentModelDict) {
|
||||||
|
if (StringUtils.equals(sysDictData.getDictType(), wxInstrument.getModel())) {
|
||||||
|
List<SysDictData> nursingOfflineInstrumentModeDict = DictUtils.getDictCache("nursing_offline_instrument_mode");
|
||||||
|
if (nursingOfflineInstrumentModeDict != null && nursingOfflineInstrumentModeDict.size() > 0) {
|
||||||
|
for (SysDictData dictData : nursingOfflineInstrumentModeDict) {
|
||||||
|
if (StringUtils.equals(dictData.getDictType(), wxNursingLogReq.getModeName())) {
|
||||||
|
// 离线
|
||||||
|
online = false;
|
||||||
|
wxNursingLog.setOnline(2L);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (online) {
|
||||||
|
// 在线
|
||||||
|
wxNursingLog.setOnline(1L);
|
||||||
|
}
|
||||||
|
wxNursingLog.setCreateBy(SecurityUtils.getLoginUser().getWxUserMember().getNickname());
|
||||||
|
wxNursingLog.setCreateTime(DateUtils.getNowDate());
|
||||||
|
wxNursingLog.setUpdateBy(SecurityUtils.getLoginUser().getWxUserMember().getNickname());
|
||||||
|
wxNursingLog.setUpdateTime(DateUtils.getNowDate());
|
||||||
|
wxNursingLog.setStatus(Status.OK.getCode().longValue());
|
||||||
|
wxNursingLogMapper.insertWxNursingLog(wxNursingLog);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
Loading…
Reference in New Issue