微信打卡

master
382696293@qq.com 2 years ago
parent 67500d3f6e
commit 75b611e724

@ -0,0 +1,83 @@
package com.flossom.common.core.domain.entity;
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;
/**
* wx_clock_img
*
* @author flossom
* @date 2024-01-27
*/
public class WxClockImg extends BaseEntity {
private static final long serialVersionUID = 1L;
/**
* $column.columnComment
*/
private Long id;
/**
* ID
*/
@Excel(name = "打卡ID")
private Long userClockId;
/**
*
*/
@Excel(name = "打卡图片")
private String clockImg;
/**
* 0 1
*/
@Excel(name = "状态", readConverterExp = "0=正常,1=停用")
private Long status;
public void setId(Long id) {
this.id = id;
}
public Long getId() {
return id;
}
public void setUserClockId(Long userClockId) {
this.userClockId = userClockId;
}
public Long getUserClockId() {
return userClockId;
}
public void setClockImg(String clockImg) {
this.clockImg = clockImg;
}
public String getClockImg() {
return clockImg;
}
public void setStatus(Long status) {
this.status = status;
}
public Long getStatus() {
return status;
}
@Override
public String toString() {
return new ToStringBuilder(this, ToStringStyle.MULTI_LINE_STYLE)
.append("id", getId())
.append("userClockId", getUserClockId())
.append("clockImg", getClockImg())
.append("status", getStatus())
.append("createBy", getCreateBy())
.append("createTime", getCreateTime())
.toString();
}
}

@ -0,0 +1,98 @@
package com.flossom.common.core.domain.entity;
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;
/**
* 使 wx_clock_instrument_log
*
* @author flossom
* @date 2024-01-29
*/
public class WxClockInstrumentLog extends BaseEntity {
private static final long serialVersionUID = 1L;
/**
* $column.columnComment
*/
private Long id;
/**
* ID
*/
@Excel(name = "用户ID")
private Long userId;
/**
* ID
*/
@Excel(name = "仪器ID")
private Long instrumentId;
/**
*
*/
@Excel(name = "仪器名称")
private String instrumentName;
/**
* 0 1
*/
@Excel(name = "状态", readConverterExp = "0=正常,1=停用")
private Long status;
public void setId(Long id) {
this.id = id;
}
public Long getId() {
return id;
}
public void setUserId(Long userId) {
this.userId = userId;
}
public Long getUserId() {
return userId;
}
public void setInstrumentId(Long instrumentId) {
this.instrumentId = instrumentId;
}
public Long getInstrumentId() {
return instrumentId;
}
public void setInstrumentName(String instrumentName) {
this.instrumentName = instrumentName;
}
public String getInstrumentName() {
return instrumentName;
}
public void setStatus(Long status) {
this.status = status;
}
public Long getStatus() {
return status;
}
@Override
public String toString() {
return new ToStringBuilder(this, ToStringStyle.MULTI_LINE_STYLE)
.append("id", getId())
.append("userId", getUserId())
.append("instrumentId", getInstrumentId())
.append("instrumentName", getInstrumentName())
.append("status", getStatus())
.append("createBy", getCreateBy())
.append("createTime", getCreateTime())
.toString();
}
}

@ -0,0 +1,113 @@
package com.flossom.common.core.domain.entity;
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;
/**
* wx_clock_log
*
* @author flossom
* @date 2024-01-29
*/
public class WxClockLog extends BaseEntity {
private static final long serialVersionUID = 1L;
/**
* $column.columnComment
*/
private Long id;
/**
*
*/
@Excel(name = "微信用户")
private Long userId;
/**
* 使
*/
@Excel(name = "当天使用过的仪器")
private String instrumentId;
/**
* 使
*/
@Excel(name = "当天使用过的仪器")
private String instrumentName;
/**
*
*/
@Excel(name = "打卡心得")
private String clockContent;
/**
* 0 1
*/
@Excel(name = "状态", readConverterExp = "0=正常,1=停用")
private Long status;
public void setId(Long id) {
this.id = id;
}
public Long getId() {
return id;
}
public void setUserId(Long userId) {
this.userId = userId;
}
public Long getUserId() {
return userId;
}
public void setInstrumentId(String instrumentId) {
this.instrumentId = instrumentId;
}
public String getInstrumentId() {
return instrumentId;
}
public void setInstrumentName(String instrumentName) {
this.instrumentName = instrumentName;
}
public String getInstrumentName() {
return instrumentName;
}
public void setClockContent(String clockContent) {
this.clockContent = clockContent;
}
public String getClockContent() {
return clockContent;
}
public void setStatus(Long status) {
this.status = status;
}
public Long getStatus() {
return status;
}
@Override
public String toString() {
return new ToStringBuilder(this, ToStringStyle.MULTI_LINE_STYLE)
.append("id", getId())
.append("userId", getUserId())
.append("instrumentId", getInstrumentId())
.append("instrumentName", getInstrumentName())
.append("clockContent", getClockContent())
.append("status", getStatus())
.append("createBy", getCreateBy())
.append("createTime", getCreateTime())
.toString();
}
}

@ -0,0 +1,46 @@
package com.flossom.common.core.domain.req;
import javax.validation.constraints.NotBlank;
import javax.validation.constraints.NotNull;
import javax.validation.constraints.Size;
import java.util.List;
/**
* wx_clock_log
*
* @author flossom
* @date 2024-01-27
*/
public class WxClockLogReq {
/**
*
*/
@NotBlank(message = "请输入打卡心得")
@Size(min = 1, max = 120, message = "内容限制120个字符以内")
private String clockContent;
/**
*
*/
@NotNull(message = "请上传打卡图片")
@Size(min = 1, max = 3, message = "打卡图片数限制在3张以内")
List<String> clockImageList;
public String getClockContent() {
return clockContent;
}
public void setClockContent(String clockContent) {
this.clockContent = clockContent;
}
public List<String> getClockImageList() {
return clockImageList;
}
public void setClockImageList(List<String> clockImageList) {
this.clockImageList = clockImageList;
}
}

@ -0,0 +1,62 @@
package com.flossom.common.core.mapper;
import com.flossom.common.core.domain.entity.WxClockImg;
import java.util.List;
/**
* Mapper
*
* @author flossom
* @date 2024-01-27
*/
public interface WxClockImgMapper {
/**
*
*
* @param id
* @return
*/
public WxClockImg selectWxClockImgById(Long id);
/**
*
*
* @param wxClockImg
* @return
*/
public List<WxClockImg> selectWxClockImgList(WxClockImg wxClockImg);
/**
*
*
* @param wxClockImg
* @return
*/
public int insertWxClockImg(WxClockImg wxClockImg);
/**
*
*
* @param wxClockImg
* @return
*/
public int updateWxClockImg(WxClockImg wxClockImg);
/**
*
*
* @param id
* @return
*/
public int deleteWxClockImgById(Long id);
/**
*
*
* @param ids
* @return
*/
public int deleteWxClockImgByIds(Long[] ids);
}

@ -0,0 +1,62 @@
package com.flossom.common.core.mapper;
import com.flossom.common.core.domain.entity.WxClockInstrumentLog;
import java.util.List;
/**
* 使Mapper
*
* @author flossom
* @date 2024-01-29
*/
public interface WxClockInstrumentLogMapper {
/**
* 使
*
* @param id 使
* @return 使
*/
public WxClockInstrumentLog selectWxClockInstrumentLogById(Long id);
/**
* 使
*
* @param wxClockInstrumentLog 使
* @return 使
*/
public List<WxClockInstrumentLog> selectWxClockInstrumentLogList(WxClockInstrumentLog wxClockInstrumentLog);
/**
* 使
*
* @param wxClockInstrumentLog 使
* @return
*/
public int insertWxClockInstrumentLog(WxClockInstrumentLog wxClockInstrumentLog);
/**
* 使
*
* @param wxClockInstrumentLog 使
* @return
*/
public int updateWxClockInstrumentLog(WxClockInstrumentLog wxClockInstrumentLog);
/**
* 使
*
* @param id 使
* @return
*/
public int deleteWxClockInstrumentLogById(Long id);
/**
* 使
*
* @param ids
* @return
*/
public int deleteWxClockInstrumentLogByIds(Long[] ids);
}

@ -0,0 +1,61 @@
package com.flossom.common.core.mapper;
import com.flossom.common.core.domain.entity.WxClockLog;
import java.util.List;
/**
* Mapper
*
* @author flossom
* @date 2024-01-29
*/
public interface WxClockLogMapper {
/**
*
*
* @param id
* @return
*/
public WxClockLog selectWxClockLogById(Long id);
/**
*
*
* @param wxClockLog
* @return
*/
public List<WxClockLog> selectWxClockLogList(WxClockLog wxClockLog);
/**
*
*
* @param wxClockLog
* @return
*/
public int insertWxClockLog(WxClockLog wxClockLog);
/**
*
*
* @param wxClockLog
* @return
*/
public int updateWxClockLog(WxClockLog wxClockLog);
/**
*
*
* @param id
* @return
*/
public int deleteWxClockLogById(Long id);
/**
*
*
* @param ids
* @return
*/
public int deleteWxClockLogByIds(Long[] ids);
}

@ -0,0 +1,74 @@
<?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.WxClockImgMapper">
<resultMap type="WxClockImg" id="WxClockImgResult">
<result property="id" column="id" />
<result property="userClockId" column="user_clock_id" />
<result property="clockImg" column="clock_img" />
<result property="status" column="status" />
<result property="createBy" column="create_by" />
<result property="createTime" column="create_time" />
</resultMap>
<sql id="selectWxClockImgVo">
select id, user_clock_id, clock_img, status, create_by, create_time from wx_clock_img
</sql>
<select id="selectWxClockImgList" parameterType="WxClockImg" resultMap="WxClockImgResult">
<include refid="selectWxClockImgVo"/>
<where>
<if test="userClockId != null "> and user_clock_id = #{userClockId}</if>
<if test="clockImg != null and clockImg != ''"> and clock_img = #{clockImg}</if>
<if test="status != null "> and status = #{status}</if>
</where>
</select>
<select id="selectWxClockImgById" parameterType="Long" resultMap="WxClockImgResult">
<include refid="selectWxClockImgVo"/>
where id = #{id}
</select>
<insert id="insertWxClockImg" parameterType="WxClockImg" useGeneratedKeys="true" keyProperty="id">
insert into wx_clock_img
<trim prefix="(" suffix=")" suffixOverrides=",">
<if test="userClockId != null">user_clock_id,</if>
<if test="clockImg != null">clock_img,</if>
<if test="status != null">status,</if>
<if test="createBy != null">create_by,</if>
<if test="createTime != null">create_time,</if>
</trim>
<trim prefix="values (" suffix=")" suffixOverrides=",">
<if test="userClockId != null">#{userClockId},</if>
<if test="clockImg != null">#{clockImg},</if>
<if test="status != null">#{status},</if>
<if test="createBy != null">#{createBy},</if>
<if test="createTime != null">#{createTime},</if>
</trim>
</insert>
<update id="updateWxClockImg" parameterType="WxClockImg">
update wx_clock_img
<trim prefix="SET" suffixOverrides=",">
<if test="userClockId != null">user_clock_id = #{userClockId},</if>
<if test="clockImg != null">clock_img = #{clockImg},</if>
<if test="status != null">status = #{status},</if>
<if test="createBy != null">create_by = #{createBy},</if>
<if test="createTime != null">create_time = #{createTime},</if>
</trim>
where id = #{id}
</update>
<delete id="deleteWxClockImgById" parameterType="Long">
delete from wx_clock_img where id = #{id}
</delete>
<delete id="deleteWxClockImgByIds" parameterType="String">
delete from wx_clock_img where id in
<foreach item="id" collection="array" open="(" separator="," close=")">
#{id}
</foreach>
</delete>
</mapper>

@ -0,0 +1,85 @@
<?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.WxClockInstrumentLogMapper">
<resultMap type="WxClockInstrumentLog" id="WxClockInstrumentLogResult">
<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="status" column="status" />
<result property="createBy" column="create_by" />
<result property="createTime" column="create_time" />
</resultMap>
<sql id="selectWxClockInstrumentLogVo">
select id, user_id, instrument_id, instrument_name, status, create_by, create_time from wx_clock_instrument_log
</sql>
<select id="selectWxClockInstrumentLogList" parameterType="WxClockInstrumentLog" resultMap="WxClockInstrumentLogResult">
<include refid="selectWxClockInstrumentLogVo"/>
<where>
<if test="userId != null "> and user_id = #{userId}</if>
<if test="instrumentId != null "> and instrument_id = #{instrumentId}</if>
<if test="instrumentName != null and instrumentName != ''"> and instrument_name like concat('%', #{instrumentName}, '%')</if>
<if test="status != null "> and status = #{status}</if>
<if test="params != null and params.beginTime != null">
and create_time &gt;= #{params.beginTime}
</if>
<if test="params != null and params.endTime != null">
and create_time &lt;= #{params.endTime}
</if>
</where>
</select>
<select id="selectWxClockInstrumentLogById" parameterType="Long" resultMap="WxClockInstrumentLogResult">
<include refid="selectWxClockInstrumentLogVo"/>
where id = #{id}
</select>
<insert id="insertWxClockInstrumentLog" parameterType="WxClockInstrumentLog" useGeneratedKeys="true" keyProperty="id">
insert into wx_clock_instrument_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="status != null">status,</if>
<if test="createBy != null">create_by,</if>
<if test="createTime != null">create_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="status != null">#{status},</if>
<if test="createBy != null">#{createBy},</if>
<if test="createTime != null">#{createTime},</if>
</trim>
</insert>
<update id="updateWxClockInstrumentLog" parameterType="WxClockInstrumentLog">
update wx_clock_instrument_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="status != null">status = #{status},</if>
<if test="createBy != null">create_by = #{createBy},</if>
<if test="createTime != null">create_time = #{createTime},</if>
</trim>
where id = #{id}
</update>
<delete id="deleteWxClockInstrumentLogById" parameterType="Long">
delete from wx_clock_instrument_log where id = #{id}
</delete>
<delete id="deleteWxClockInstrumentLogByIds" parameterType="String">
delete from wx_clock_instrument_log where id in
<foreach item="id" collection="array" open="(" separator="," close=")">
#{id}
</foreach>
</delete>
</mapper>

@ -0,0 +1,91 @@
<?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.WxClockLogMapper">
<resultMap type="WxClockLog" id="WxClockLogResult">
<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="clockContent" column="clock_content" />
<result property="status" column="status" />
<result property="createBy" column="create_by" />
<result property="createTime" column="create_time" />
</resultMap>
<sql id="selectWxClockLogVo">
select id, user_id, instrument_id, instrument_name, clock_content, status, create_by, create_time from wx_clock_log
</sql>
<select id="selectWxClockLogList" parameterType="WxClockLog" resultMap="WxClockLogResult">
<include refid="selectWxClockLogVo"/>
<where>
<if test="userId != null "> and user_id = #{userId}</if>
<if test="instrumentId != null and instrumentId != ''"> and instrument_id = #{instrumentId}</if>
<if test="instrumentName != null and instrumentName != ''"> and instrument_name like concat('%', #{instrumentName}, '%')</if>
<if test="clockContent != null and clockContent != ''"> and clock_content = #{clockContent}</if>
<if test="status != null "> and status = #{status}</if>
<if test="params != null and params.beginTime != null">
and create_time &gt;= #{params.beginTime}
</if>
<if test="params != null and params.endTime != null">
and create_time &lt;= #{params.endTime}
</if>
</where>
order by create_time desc
</select>
<select id="selectWxClockLogById" parameterType="Long" resultMap="WxClockLogResult">
<include refid="selectWxClockLogVo"/>
where id = #{id}
</select>
<insert id="insertWxClockLog" parameterType="WxClockLog" useGeneratedKeys="true" keyProperty="id">
insert into wx_clock_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="clockContent != null">clock_content,</if>
<if test="status != null">status,</if>
<if test="createBy != null">create_by,</if>
<if test="createTime != null">create_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="clockContent != null">#{clockContent},</if>
<if test="status != null">#{status},</if>
<if test="createBy != null">#{createBy},</if>
<if test="createTime != null">#{createTime},</if>
</trim>
</insert>
<update id="updateWxClockLog" parameterType="WxClockLog">
update wx_clock_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="clockContent != null">clock_content = #{clockContent},</if>
<if test="status != null">status = #{status},</if>
<if test="createBy != null">create_by = #{createBy},</if>
<if test="createTime != null">create_time = #{createTime},</if>
</trim>
where id = #{id}
</update>
<delete id="deleteWxClockLogById" parameterType="Long">
delete from wx_clock_log where id = #{id}
</delete>
<delete id="deleteWxClockLogByIds" parameterType="String">
delete from wx_clock_log where id in
<foreach item="id" collection="array" open="(" separator="," close=")">
#{id}
</foreach>
</delete>
</mapper>

@ -0,0 +1,48 @@
package com.flossom.miniProgram.controller;
import com.flossom.common.core.domain.R;
import com.flossom.common.core.domain.req.WxClockLogReq;
import com.flossom.common.core.web.controller.BaseController;
import com.flossom.miniProgram.service.IWxClockLogService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;
import javax.validation.constraints.NotNull;
/**
* Controller
*
* @author flossom
* @date 2024-01-27
*/
@RestController
@RequestMapping("/clock")
public class WxClockLogController extends BaseController {
@Autowired
private IWxClockLogService wxClockLogService;
/**
* 使
*/
@GetMapping("/addClockInstrument")
public R addClockInstrument(@NotNull(message = "请选择仪器ID") @RequestParam("instrumentId") Long instrumentId) {
wxClockLogService.addClockInstrument(instrumentId);
return R.ok();
}
/**
*
* 使
*/
@PostMapping("/insertClockLog")
public R insertClockLog(@Validated @RequestBody WxClockLogReq wxClockLogReq) {
wxClockLogService.insertWxClockLog(wxClockLogReq);
return R.ok();
}
}

@ -0,0 +1,10 @@
package com.flossom.miniProgram.service;
import com.flossom.common.core.domain.req.WxClockLogReq;
public interface IWxClockLogService {
public void insertWxClockLog(WxClockLogReq wxClockLogReq);
void addClockInstrument(Long instrumentId);
}

@ -0,0 +1,135 @@
package com.flossom.miniProgram.service.impl;
import com.flossom.common.core.domain.entity.*;
import com.flossom.common.core.domain.req.WxClockLogReq;
import com.flossom.common.core.enums.Status;
import com.flossom.common.core.mapper.WxClockImgMapper;
import com.flossom.common.core.mapper.WxClockInstrumentLogMapper;
import com.flossom.common.core.mapper.WxClockLogMapper;
import com.flossom.common.core.mapper.WxInstrumentMapper;
import com.flossom.common.core.utils.DateUtils;
import com.flossom.common.security.utils.SecurityUtils;
import com.flossom.miniProgram.service.IWxClockLogService;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import java.time.LocalDateTime;
import java.time.LocalTime;
import java.util.Arrays;
import java.util.List;
import java.util.Objects;
import java.util.stream.Collectors;
import java.util.stream.Stream;
@Service
public class WxClockLogServiceImpl implements IWxClockLogService {
@Autowired
private WxClockLogMapper wxClockLogMapper;
@Autowired
private WxClockImgMapper wxClockImgMapper;
@Autowired
private WxClockInstrumentLogMapper wxClockInstrumentLogMapper;
@Autowired
private WxInstrumentMapper wxInstrumentMapper;
@Override
@Transactional
public void insertWxClockLog(WxClockLogReq wxClockLogReq) {
WxUserMember wxUserMember = SecurityUtils.getLoginUser().getWxUserMember();
// 打卡记录
WxClockLog wxClockLog = new WxClockLog();
BeanUtils.copyProperties(wxClockLogReq, wxClockLog);
wxClockLog.setUserId(wxUserMember.getId());
wxClockLog.setCreateBy(wxUserMember.getNickname());
wxClockLog.setCreateTime(DateUtils.getNowDate());
// 当天使用过的仪器
WxClockInstrumentLog queryInstrumentLog = new WxClockInstrumentLog();
queryInstrumentLog.setUserId(wxUserMember.getId());
LocalDateTime now = LocalDateTime.now();
wxClockLog.getParams().put("beginTime", LocalDateTime.of(now.toLocalDate(), LocalTime.MIN));
wxClockLog.getParams().put("endTime", LocalDateTime.of(now.toLocalDate(), LocalTime.MAX));
queryInstrumentLog.setStatus(Status.OK.getCode().longValue());
List<WxClockInstrumentLog> wxClockInstrumentLogList = wxClockInstrumentLogMapper.selectWxClockInstrumentLogList(queryInstrumentLog);
if (wxClockInstrumentLogList != null && wxClockInstrumentLogList.size() > 0) {
String instrumentIdList = wxClockInstrumentLogList.stream()
.map(WxClockInstrumentLog::getInstrumentId)
.distinct()
.map(Objects::toString)
.collect(Collectors.joining(","));
wxClockLog.setInstrumentId(instrumentIdList);
String instrumentNameList = wxClockInstrumentLogList.stream()
.map(WxClockInstrumentLog::getInstrumentName)
.distinct()
.map(Objects::toString)
.collect(Collectors.joining(","));
wxClockLog.setInstrumentName(instrumentNameList);
}
wxClockLogMapper.insertWxClockLog(wxClockLog);
// 打卡图片
if (wxClockLogReq.getClockImageList() != null && wxClockLogReq.getClockImageList().size() > 0) {
for (String image : wxClockLogReq.getClockImageList()) {
WxClockImg wxClockImg = new WxClockImg();
wxClockImg.setUserClockId(wxClockLog.getId());
wxClockImg.setClockImg(image);
wxClockImg.setCreateBy(wxUserMember.getNickname());
wxClockImg.setCreateTime(DateUtils.getNowDate());
wxClockImgMapper.insertWxClockImg(wxClockImg);
}
}
/**
* TODO
*/
}
@Override
@Transactional
public void addClockInstrument(Long instrumentId) {
// 添加仪器使用记录
WxClockInstrumentLog wxClockInstrumentLog = new WxClockInstrumentLog();
wxClockInstrumentLog.setUserId(SecurityUtils.getLoginUser().getWxUserMember().getId());
wxClockInstrumentLog.setInstrumentId(instrumentId);
WxInstrument wxInstrument = wxInstrumentMapper.selectWxInstrumentById(instrumentId);
if (wxInstrument != null) {
wxClockInstrumentLog.setInstrumentName(wxInstrument.getName());
}
wxClockInstrumentLog.setStatus(Status.OK.getCode().longValue());
wxClockInstrumentLog.setCreateBy(SecurityUtils.getLoginUser().getWxUserMember().getNickname());
wxClockInstrumentLog.setCreateTime(DateUtils.getNowDate());
wxClockInstrumentLogMapper.insertWxClockInstrumentLog(wxClockInstrumentLog);
// 查询今天是否有打卡,存在打卡,则将仪器添加到最近一条打卡记录上
WxClockLog queryClockLog = new WxClockLog();
queryClockLog.setUserId(SecurityUtils.getLoginUser().getWxUserMember().getId());
LocalDateTime now = LocalDateTime.now();
queryClockLog.getParams().put("beginTime", LocalDateTime.of(now.toLocalDate(), LocalTime.MIN));
queryClockLog.getParams().put("endTime", LocalDateTime.of(now.toLocalDate(), LocalTime.MAX));
List<WxClockLog> wxClockLogList = wxClockLogMapper.selectWxClockLogList(queryClockLog);
if (wxClockLogList != null && wxClockLogList.size() > 0) {
// 直接获取最新的打卡记录
WxClockLog saveClockLog = new WxClockLog();
WxClockLog newWxClockLog = wxClockLogList.get(0);
// 获取打卡记录的使用过的仪器ID
List<Long> usedList = Arrays.asList(newWxClockLog.getInstrumentId().split(",")).stream().map(Long::valueOf).collect(Collectors.toList());
if (!usedList.contains(instrumentId)) {
saveClockLog.setInstrumentId(newWxClockLog.getInstrumentId() + "," + instrumentId);
WxInstrument instrument = wxInstrumentMapper.selectWxInstrumentById(instrumentId);
if (instrument != null) {
saveClockLog.setInstrumentName(newWxClockLog.getInstrumentName() + "," + instrument.getName());
}
saveClockLog.setId(newWxClockLog.getId());
wxClockLogMapper.updateWxClockLog(saveClockLog);
}
}
}
}
Loading…
Cancel
Save