仪器的新增和编辑

master
382696293@qq.com 2 years ago
parent 2e834acce8
commit dffd37aa06

@ -2,7 +2,6 @@ package com.flossom.common.core.domain.entity;
import java.time.LocalDateTime;
import java.time.LocalTime;
import java.util.Date;
import com.fasterxml.jackson.annotation.JsonFormat;
import com.flossom.common.core.web.domain.BaseEntity;

@ -0,0 +1,128 @@
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_instrument_file_relate
*
* @author flossom
* @date 2024-01-10
*/
public class WxInstrumentFileRelate extends BaseEntity {
private static final long serialVersionUID = 1L;
/**
* $column.columnComment
*/
private Long id;
/**
* 12
*/
@Excel(name = "分类", readConverterExp = "1=、初次护理、2、仪器介绍规则")
private Integer classify;
/**
* id
*/
@Excel(name = "仪器id")
private Long instrumentId;
/**
*
*/
@Excel(name = "文件地址")
private String file;
/**
*
*/
@Excel(name = "文件类型")
private String fileType;
/**
*
*/
@Excel(name = "内容")
private String message;
/**
* 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 setClassify(Integer classify) {
this.classify = classify;
}
public Integer getClassify() {
return classify;
}
public void setInstrumentId(Long instrumentId) {
this.instrumentId = instrumentId;
}
public Long getInstrumentId() {
return instrumentId;
}
public void setFile(String file) {
this.file = file;
}
public String getFile() {
return file;
}
public void setFileType(String fileType) {
this.fileType = fileType;
}
public String getFileType() {
return fileType;
}
public void setMessage(String message) {
this.message = message;
}
public String getMessage() {
return message;
}
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("classify", getClassify())
.append("instrumentId", getInstrumentId())
.append("file", getFile())
.append("fileType", getFileType())
.append("message", getMessage())
.append("status", getStatus())
.append("createBy", getCreateBy())
.append("createTime", getCreateTime())
.toString();
}
}

@ -1,16 +1,13 @@
package com.flossom.common.core.domain.req;
import com.fasterxml.jackson.annotation.JsonFormat;
import com.flossom.common.core.web.domain.BaseEntity;
import org.apache.commons.lang3.builder.ToStringBuilder;
import org.apache.commons.lang3.builder.ToStringStyle;
import com.flossom.common.core.domain.entity.WxInstrumentFileRelate;
import org.hibernate.validator.constraints.Length;
import javax.validation.constraints.NotBlank;
import javax.validation.constraints.NotNull;
import java.time.LocalDateTime;
import java.time.LocalTime;
import java.util.Date;
import java.util.List;
/**
@ -91,6 +88,17 @@ public class WxInstrumentSaveReq {
@JsonFormat(shape = JsonFormat.Shape.STRING, pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
private List<LocalDateTime> extraClockTimeRange;
/**
* ID(xxxx,xxxx,xxx)
*/
private String miniTagIds;
/**
* ID(xxxx,xxxx,xxx)
*/
private String wecomTagIds;
/**
* ID(xxxx,xxxx,xxx)
*/
@ -170,6 +178,17 @@ public class WxInstrumentSaveReq {
*/
private String scanCodeBinding;
/**
* /
*/
private List<WxInstrumentFileRelate> nurseList;
/**
*
*/
private List<WxInstrumentFileRelate> introduceList;
public Long getId() {
return id;
}
@ -385,4 +404,36 @@ public class WxInstrumentSaveReq {
public void setScanCodeBinding(String scanCodeBinding) {
this.scanCodeBinding = scanCodeBinding;
}
public List<WxInstrumentFileRelate> getNurseList() {
return nurseList;
}
public void setNurseList(List<WxInstrumentFileRelate> nurseList) {
this.nurseList = nurseList;
}
public List<WxInstrumentFileRelate> getIntroduceList() {
return introduceList;
}
public void setIntroduceList(List<WxInstrumentFileRelate> introduceList) {
this.introduceList = introduceList;
}
public String getMiniTagIds() {
return miniTagIds;
}
public void setMiniTagIds(String miniTagIds) {
this.miniTagIds = miniTagIds;
}
public String getWecomTagIds() {
return wecomTagIds;
}
public void setWecomTagIds(String wecomTagIds) {
this.wecomTagIds = wecomTagIds;
}
}

@ -0,0 +1,27 @@
package com.flossom.common.core.enums;
/**
* wx_instrument_file_relate: classify
* 12
*
* @author flossom
*/
public enum InstrumentFileClassify {
FIRST_NURSE(1, "初次护理"), INSTRUMENT_INSTRUCTION(2, "仪器介绍");
private final Integer code;
private final String info;
InstrumentFileClassify(Integer code, String info) {
this.code = code;
this.info = info;
}
public Integer getCode() {
return code;
}
public String getInfo() {
return info;
}
}

@ -0,0 +1,72 @@
package com.flossom.common.core.mapper;
import com.flossom.common.core.domain.entity.WxInstrumentFileRelate;
import org.apache.ibatis.annotations.Param;
import java.util.List;
/**
* Mapper
*
* @author flossom
* @date 2024-01-10
*/
public interface WxInstrumentFileRelateMapper {
/**
*
*
* @param id
* @return
*/
public WxInstrumentFileRelate selectWxInstrumentFileRelateById(Long id);
/**
*
*
* @param wxInstrumentFileRelate
* @return
*/
public List<WxInstrumentFileRelate> selectWxInstrumentFileRelateList(WxInstrumentFileRelate wxInstrumentFileRelate);
/**
*
*
* @param wxInstrumentFileRelate
* @return
*/
public int insertWxInstrumentFileRelate(WxInstrumentFileRelate wxInstrumentFileRelate);
/**
*
*
* @param wxInstrumentFileRelate
* @return
*/
public int updateWxInstrumentFileRelate(WxInstrumentFileRelate wxInstrumentFileRelate);
/**
*
*
* @param id
* @return
*/
public int deleteWxInstrumentFileRelateById(Long id);
/**
*
*
* @param ids
* @return
*/
public int deleteWxInstrumentFileRelateByIds(Long[] ids);
/**
*
*
* @return
*/
public int deleteByInstrumentIdAndClassify(@Param("instrumentId") Long instrumentId, @Param("classify") Integer classify);
public List<WxInstrumentFileRelate> selectByInstrumentIdAndClassify(@Param("instrumentId") Long instrumentId, @Param("classify") Integer classify);
}

@ -0,0 +1,98 @@
<?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.WxInstrumentFileRelateMapper">
<resultMap type="WxInstrumentFileRelate" id="WxInstrumentFileRelateResult">
<result property="id" column="id" />
<result property="classify" column="classify" />
<result property="instrumentId" column="instrument_id" />
<result property="file" column="file" />
<result property="fileType" column="file_type" />
<result property="message" column="message" />
<result property="status" column="status" />
<result property="createBy" column="create_by" />
<result property="createTime" column="create_time" />
</resultMap>
<sql id="selectWxInstrumentFileRelateVo">
select id, classify, instrument_id, file, file_type, message, status, create_by, create_time from wx_instrument_file_relate
</sql>
<select id="selectWxInstrumentFileRelateList" parameterType="WxInstrumentFileRelate" resultMap="WxInstrumentFileRelateResult">
<include refid="selectWxInstrumentFileRelateVo"/>
<where>
<if test="classify != null "> and classify = #{classify}</if>
<if test="instrumentId != null "> and instrument_id = #{instrumentId}</if>
<if test="file != null and file != ''"> and file = #{file}</if>
<if test="fileType != null and fileType != ''"> and file_type = #{fileType}</if>
<if test="message != null and message != ''"> and message = #{message}</if>
<if test="status != null "> and status = #{status}</if>
</where>
</select>
<select id="selectWxInstrumentFileRelateById" parameterType="Long" resultMap="WxInstrumentFileRelateResult">
<include refid="selectWxInstrumentFileRelateVo"/>
where id = #{id}
</select>
<select id="selectByInstrumentIdAndClassify" resultMap="WxInstrumentFileRelateResult">
<include refid="selectWxInstrumentFileRelateVo"/>
where instrument_id = #{instrumentId} and classify = #{classify}
</select>
<insert id="insertWxInstrumentFileRelate" parameterType="WxInstrumentFileRelate" useGeneratedKeys="true" keyProperty="id">
insert into wx_instrument_file_relate
<trim prefix="(" suffix=")" suffixOverrides=",">
<if test="classify != null">classify,</if>
<if test="instrumentId != null">instrument_id,</if>
<if test="file != null and file != ''">file,</if>
<if test="fileType != null and fileType != ''">file_type,</if>
<if test="message != null and message != ''">message,</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="classify != null">#{classify},</if>
<if test="instrumentId != null">#{instrumentId},</if>
<if test="file != null and file != ''">#{file},</if>
<if test="fileType != null and fileType != ''">#{fileType},</if>
<if test="message != null and message != ''">#{message},</if>
<if test="status != null">#{status},</if>
<if test="createBy != null">#{createBy},</if>
<if test="createTime != null">#{createTime},</if>
</trim>
</insert>
<update id="updateWxInstrumentFileRelate" parameterType="WxInstrumentFileRelate">
update wx_instrument_file_relate
<trim prefix="SET" suffixOverrides=",">
<if test="classify != null">classify = #{classify},</if>
<if test="instrumentId != null">instrument_id = #{instrumentId},</if>
<if test="file != null and file != ''">file = #{file},</if>
<if test="fileType != null and fileType != ''">file_type = #{fileType},</if>
<if test="message != null and message != ''">message = #{message},</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="deleteWxInstrumentFileRelateById" parameterType="Long">
delete from wx_instrument_file_relate where id = #{id}
</delete>
<delete id="deleteWxInstrumentFileRelateByIds" parameterType="String">
delete from wx_instrument_file_relate where id in
<foreach item="id" collection="array" open="(" separator="," close=")">
#{id}
</foreach>
</delete>
<delete id="deleteByInstrumentIdAndClassify">
delete from wx_instrument_file_relate where instrument_id = #{instrumentId} and classify = #{classify}
</delete>
</mapper>

@ -104,6 +104,9 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
</select>
<insert id="insertWxInstrument" parameterType="WxInstrument" useGeneratedKeys="true" keyProperty="id">
<selectKey keyProperty="id" resultType="Long" order="AFTER">
SELECT LAST_INSERT_ID()
</selectKey>
insert into wx_instrument
<trim prefix="(" suffix=")" suffixOverrides=",">
<if test="name != null and name != ''">name,</if>

@ -56,7 +56,7 @@ public class WxInstrumentController extends BaseController {
@RequiresPermissions("system:instrument:query")
@GetMapping(value = "/{id}")
public AjaxResult getInfo(@PathVariable("id") Long id) {
return success(wxInstrumentService.selectWxInstrumentById(id));
return success(wxInstrumentService.selectWxInstrumentReqById(id));
}
/**
@ -97,12 +97,7 @@ public class WxInstrumentController extends BaseController {
wxInstrumentSaveReq.setShoppingAppid(null);
wxInstrumentSaveReq.setShoppingPath(null);
}
WxInstrument wxInstrument = new WxInstrument();
BeanUtils.copyProperties(wxInstrumentSaveReq, wxInstrument);
wxInstrument.setStartTime(wxInstrumentSaveReq.getExtraClockTimeRange().get(0));
wxInstrument.setEndTime(wxInstrumentSaveReq.getExtraClockTimeRange().get(1));
wxInstrument.setCreateBy(SecurityUtils.getUsername());
return toAjax(wxInstrumentService.insertWxInstrument(wxInstrument));
return toAjax(wxInstrumentService.addWxInstrument(wxInstrumentSaveReq));
}
/**
@ -111,8 +106,8 @@ public class WxInstrumentController extends BaseController {
@RequiresPermissions("system:instrument:edit")
@Log(title = "仪器列", businessType = BusinessType.UPDATE)
@PutMapping
public AjaxResult edit(@RequestBody WxInstrument wxInstrument) {
return toAjax(wxInstrumentService.updateWxInstrument(wxInstrument));
public AjaxResult edit(@RequestBody WxInstrumentSaveReq wxInstrumentSaveReq) {
return toAjax(wxInstrumentService.updateWxInstrument(wxInstrumentSaveReq));
}
/**

@ -2,6 +2,7 @@ package com.flossom.system.service;
import com.flossom.common.core.domain.entity.WxInstrument;
import com.flossom.common.core.domain.req.WxInstrumentReq;
import com.flossom.common.core.domain.req.WxInstrumentSaveReq;
import java.util.List;
@ -44,14 +45,6 @@ public interface IWxInstrumentService {
*/
public int insertWxInstrument(WxInstrument wxInstrument);
/**
*
*
* @param wxInstrument
* @return
*/
public int updateWxInstrument(WxInstrument wxInstrument);
/**
*
*
@ -67,4 +60,15 @@ public interface IWxInstrumentService {
* @return
*/
public int deleteWxInstrumentById(Long id);
int addWxInstrument(WxInstrumentSaveReq wxInstrumentSaveReq);
/**
*
*
* @return
*/
int updateWxInstrument(WxInstrumentSaveReq wxInstrumentSaveReq);
WxInstrumentSaveReq selectWxInstrumentReqById(Long id);
}

@ -1,17 +1,26 @@
package com.flossom.system.service.impl;
import java.util.Arrays;
import java.util.Iterator;
import java.util.List;
import com.flossom.common.core.domain.entity.SysTag;
import com.flossom.common.core.domain.entity.WxInstrument;
import com.flossom.common.core.domain.entity.WxInstrumentFileRelate;
import com.flossom.common.core.domain.req.WxInstrumentReq;
import com.flossom.common.core.domain.req.WxInstrumentSaveReq;
import com.flossom.common.core.enums.InstrumentFileClassify;
import com.flossom.common.core.mapper.SysTagMapper;
import com.flossom.common.core.mapper.WxInstrumentFileRelateMapper;
import com.flossom.common.core.mapper.WxInstrumentMapper;
import com.flossom.common.core.utils.DateUtils;
import com.flossom.common.core.utils.StringUtils;
import com.flossom.common.security.utils.SecurityUtils;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.flossom.system.service.IWxInstrumentService;
import org.springframework.transaction.annotation.Transactional;
/**
* Service
@ -28,6 +37,9 @@ public class WxInstrumentServiceImpl implements IWxInstrumentService {
@Autowired
private SysTagMapper sysTagMapper;
@Autowired
private WxInstrumentFileRelateMapper wxInstrumentFileRelateMapper;
/**
*
*
@ -39,6 +51,32 @@ public class WxInstrumentServiceImpl implements IWxInstrumentService {
return wxInstrumentMapper.selectWxInstrumentById(id);
}
/**
*
*
* @param id
* @return
*/
@Override
public WxInstrumentSaveReq selectWxInstrumentReqById(Long id) {
WxInstrument wxInstrument = wxInstrumentMapper.selectWxInstrumentById(id);
WxInstrumentSaveReq wxInstrumentSaveReq = new WxInstrumentSaveReq();
BeanUtils.copyProperties(wxInstrument, wxInstrumentSaveReq);
// 时间范围
if (wxInstrument.getStartTime() != null && wxInstrument.getEndTime() != null) {
wxInstrumentSaveReq.setExtraClockTimeRange(Arrays.asList(wxInstrument.getStartTime(), wxInstrument.getEndTime()));
}
// 获取护理弹窗关联
List<WxInstrumentFileRelate> firstNurseRelate = wxInstrumentFileRelateMapper.
selectByInstrumentIdAndClassify(wxInstrument.getId(), InstrumentFileClassify.FIRST_NURSE.getCode());
wxInstrumentSaveReq.setNurseList(firstNurseRelate);
// 获取护理弹窗关联
List<WxInstrumentFileRelate> instructionRelate = wxInstrumentFileRelateMapper.
selectByInstrumentIdAndClassify(wxInstrument.getId(), InstrumentFileClassify.INSTRUMENT_INSTRUCTION.getCode());
wxInstrumentSaveReq.setIntroduceList(instructionRelate);
return wxInstrumentSaveReq;
}
/**
*
*
@ -67,17 +105,72 @@ public class WxInstrumentServiceImpl implements IWxInstrumentService {
return wxInstrumentMapper.insertWxInstrument(wxInstrument);
}
/**
*
*
* @return
*/
@Override
@Transactional
public int addWxInstrument(WxInstrumentSaveReq wxInstrumentSaveReq) {
WxInstrument wxInstrument = new WxInstrument();
BeanUtils.copyProperties(wxInstrumentSaveReq, wxInstrument);
// 打卡时间处理
wxInstrument.setStartTime(wxInstrumentSaveReq.getExtraClockTimeRange().get(0));
wxInstrument.setEndTime(wxInstrumentSaveReq.getExtraClockTimeRange().get(1));
wxInstrument.setCreateBy(SecurityUtils.getUsername());
wxInstrument.setCreateTime(DateUtils.getNowDate());
int i = wxInstrumentMapper.insertWxInstrument(wxInstrument);
// 保存初次护理规则
List<WxInstrumentFileRelate> nurseList = wxInstrumentSaveReq.getNurseList();
if (nurseList != null && nurseList.size() > 0) {
Iterator<WxInstrumentFileRelate> nurseIterator = nurseList.iterator();
while (nurseIterator.hasNext()) {
WxInstrumentFileRelate next = nurseIterator.next();
if (StringUtils.isBlank(next.getFile())) {
nurseIterator.remove();
continue;
}
next.setInstrumentId(wxInstrument.getId());
next.setClassify(InstrumentFileClassify.FIRST_NURSE.getCode());
wxInstrumentFileRelateMapper.insertWxInstrumentFileRelate(next);
}
}
// 保存仪器介绍规则
List<WxInstrumentFileRelate> introduceList = wxInstrumentSaveReq.getIntroduceList();
if (introduceList != null && introduceList.size() > 0) {
Iterator<WxInstrumentFileRelate> introduceIterator = introduceList.iterator();
while (introduceIterator.hasNext()) {
WxInstrumentFileRelate next = introduceIterator.next();
if (StringUtils.isBlank(next.getFile())) {
introduceIterator.remove();
continue;
}
next.setInstrumentId(wxInstrument.getId());
next.setClassify(InstrumentFileClassify.INSTRUMENT_INSTRUCTION.getCode());
wxInstrumentFileRelateMapper.insertWxInstrumentFileRelate(next);
}
}
return i;
}
/**
*
*
* @param wxInstrument
* @param wxInstrumentSaveReq
* @return
*/
@Override
public int updateWxInstrument(WxInstrument wxInstrument) {
public int updateWxInstrument(WxInstrumentSaveReq wxInstrumentSaveReq) {
WxInstrument wxInstrument = new WxInstrument();
BeanUtils.copyProperties(wxInstrumentSaveReq, wxInstrument);
// 处理小程序标签和企微标签
if (wxInstrument.getMiniTagIds() != null) {
List<String> tagIdList = Arrays.asList(wxInstrument.getMiniTagIds().split(","));
if (wxInstrumentSaveReq.getMiniTagIds() != null) {
List<String> tagIdList = Arrays.asList(wxInstrumentSaveReq.getMiniTagIds().split(","));
StringBuilder tagNames = new StringBuilder();
for (int i = 0; i < tagIdList.size(); i++) {
SysTag sysTag = sysTagMapper.selectDeptById(Long.valueOf(tagIdList.get(i)));
@ -87,9 +180,12 @@ public class WxInstrumentServiceImpl implements IWxInstrumentService {
}
}
wxInstrument.setMiniTagNames(tagNames.toString());
} else {
wxInstrument.setMiniTagNames(null);
}
if (wxInstrument.getWecomTagIds() != null) {
List<String> tagIdList = Arrays.asList(wxInstrument.getWecomTagIds().split(","));
if (wxInstrumentSaveReq.getWecomTagIds() != null) {
List<String> tagIdList = Arrays.asList(wxInstrumentSaveReq.getWecomTagIds().split(","));
StringBuilder tagNames = new StringBuilder();
for (int i = 0; i < tagIdList.size(); i++) {
SysTag sysTag = sysTagMapper.selectDeptById(Long.valueOf(tagIdList.get(i)));
@ -99,15 +195,55 @@ public class WxInstrumentServiceImpl implements IWxInstrumentService {
}
}
wxInstrument.setWecomTagNames(tagNames.toString());
} else {
wxInstrument.setWecomTagNames(null);
}
wxInstrument.setUpdateTime(DateUtils.getNowDate());
// 打卡时间处理
wxInstrument.setStartTime(wxInstrumentSaveReq.getExtraClockTimeRange().get(0));
wxInstrument.setEndTime(wxInstrumentSaveReq.getExtraClockTimeRange().get(1));
// 保存初次护理规则
List<WxInstrumentFileRelate> nurseList = wxInstrumentSaveReq.getNurseList();
wxInstrumentFileRelateMapper.deleteByInstrumentIdAndClassify(wxInstrumentSaveReq.getId(),
InstrumentFileClassify.FIRST_NURSE.getCode());
if (nurseList != null && nurseList.size() > 0) {
Iterator<WxInstrumentFileRelate> nurseIterator = nurseList.iterator();
while (nurseIterator.hasNext()) {
WxInstrumentFileRelate next = nurseIterator.next();
if (StringUtils.isBlank(next.getFile())) {
nurseIterator.remove();
continue;
}
next.setInstrumentId(wxInstrument.getId());
next.setClassify(InstrumentFileClassify.FIRST_NURSE.getCode());
wxInstrumentFileRelateMapper.insertWxInstrumentFileRelate(next);
}
}
// 保存仪器介绍规则
wxInstrumentFileRelateMapper.deleteByInstrumentIdAndClassify(wxInstrumentSaveReq.getId(),
InstrumentFileClassify.INSTRUMENT_INSTRUCTION.getCode());
List<WxInstrumentFileRelate> introduceList = wxInstrumentSaveReq.getIntroduceList();
Iterator<WxInstrumentFileRelate> introduceIterator = introduceList.iterator();
while (introduceIterator.hasNext()) {
WxInstrumentFileRelate next = introduceIterator.next();
if (StringUtils.isBlank(next.getFile())) {
introduceIterator.remove();
continue;
}
next.setInstrumentId(wxInstrument.getId());
next.setClassify(InstrumentFileClassify.INSTRUMENT_INSTRUCTION.getCode());
wxInstrumentFileRelateMapper.insertWxInstrumentFileRelate(next);
}
return wxInstrumentMapper.updateWxInstrument(wxInstrument);
}
/**
*
*
* @param ids
* @return
*/
@Override

File diff suppressed because it is too large Load Diff
Loading…
Cancel
Save