diff --git a/flossom-common/flossom-common-core/src/main/java/com/flossom/common/core/domain/entity/WxInstrumentMode.java b/flossom-common/flossom-common-core/src/main/java/com/flossom/common/core/domain/entity/WxInstrumentMode.java new file mode 100644 index 0000000..087afaa --- /dev/null +++ b/flossom-common/flossom-common-core/src/main/java/com/flossom/common/core/domain/entity/WxInstrumentMode.java @@ -0,0 +1,97 @@ +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_mode + * + * @author flossom + * @date 2024-01-17 + */ +public class WxInstrumentMode extends BaseEntity { + + private static final long serialVersionUID = 1L; + + /** + * $column.columnComment + */ + private Long id; + + /** + * 仪器id + */ + @Excel(name = "仪器id") + private Long instrumentId; + + /** + * 模式id + */ + @Excel(name = "模式id") + private Long modeId; + + /** + * 排序 + */ + private Integer modeSort; + + /** + * 状态(0正常 1停用) + */ + @Excel(name = "状态", readConverterExp = "0=正常,1=停用") + private Integer status; + + public void setId(Long id) { + this.id = id; + } + + public Long getId() { + return id; + } + + 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 setStatus(Integer status) { + this.status = status; + } + + public Integer getStatus() { + return status; + } + + public Integer getModeSort() { + return modeSort; + } + + public void setModeSort(Integer modeSort) { + this.modeSort = modeSort; + } + + @Override + public String toString() { + return new ToStringBuilder(this, ToStringStyle.MULTI_LINE_STYLE) + .append("id", getId()) + .append("instrumentId", getInstrumentId()) + .append("modeId", getModeId()) + .append("status", getStatus()) + .append("createBy", getCreateBy()) + .append("createTime", getCreateTime()) + .toString(); + } +} diff --git a/flossom-common/flossom-common-core/src/main/java/com/flossom/common/core/domain/req/WxInstrumentSaveReq.java b/flossom-common/flossom-common-core/src/main/java/com/flossom/common/core/domain/req/WxInstrumentSaveReq.java index 009b2f6..4b0b708 100644 --- a/flossom-common/flossom-common-core/src/main/java/com/flossom/common/core/domain/req/WxInstrumentSaveReq.java +++ b/flossom-common/flossom-common-core/src/main/java/com/flossom/common/core/domain/req/WxInstrumentSaveReq.java @@ -183,6 +183,12 @@ public class WxInstrumentSaveReq { */ private List introduceList; + /** + * 关联模式 + * @return + */ + private List modeIdsValue; + public Long getId() { return id; } @@ -422,4 +428,12 @@ public class WxInstrumentSaveReq { public void setBindingCredit(Integer bindingCredit) { this.bindingCredit = bindingCredit; } + + public List getModeIdsValue() { + return modeIdsValue; + } + + public void setModeIdsValue(List modeIdsValue) { + this.modeIdsValue = modeIdsValue; + } } diff --git a/flossom-common/flossom-common-core/src/main/java/com/flossom/common/core/mapper/WxInstrumentModeMapper.java b/flossom-common/flossom-common-core/src/main/java/com/flossom/common/core/mapper/WxInstrumentModeMapper.java new file mode 100644 index 0000000..5a828ac --- /dev/null +++ b/flossom-common/flossom-common-core/src/main/java/com/flossom/common/core/mapper/WxInstrumentModeMapper.java @@ -0,0 +1,64 @@ +package com.flossom.common.core.mapper; + +import com.flossom.common.core.domain.entity.WxInstrumentMode; + +import java.util.List; + +/** + * 仪器与模式的关联Mapper接口 + * + * @author flossom + * @date 2024-01-17 + */ +public interface WxInstrumentModeMapper { + /** + * 查询仪器与模式的关联 + * + * @param id 仪器与模式的关联主键 + * @return 仪器与模式的关联 + */ + public WxInstrumentMode selectWxInstrumentModeById(Long id); + + /** + * 查询仪器与模式的关联列表 + * + * @param wxInstrumentMode 仪器与模式的关联 + * @return 仪器与模式的关联集合 + */ + public List selectWxInstrumentModeList(WxInstrumentMode wxInstrumentMode); + + /** + * 新增仪器与模式的关联 + * + * @param wxInstrumentMode 仪器与模式的关联 + * @return 结果 + */ + public int insertWxInstrumentMode(WxInstrumentMode wxInstrumentMode); + + /** + * 修改仪器与模式的关联 + * + * @param wxInstrumentMode 仪器与模式的关联 + * @return 结果 + */ + public int updateWxInstrumentMode(WxInstrumentMode wxInstrumentMode); + + /** + * 删除仪器与模式的关联 + * + * @param id 仪器与模式的关联主键 + * @return 结果 + */ + public int deleteWxInstrumentModeById(Long id); + + /** + * 批量删除仪器与模式的关联 + * + * @param ids 需要删除的数据主键集合 + * @return 结果 + */ + public int deleteWxInstrumentModeByIds(Long[] ids); + + public int deleteByInstrumentId(Long instrumentId); + +} diff --git a/flossom-common/flossom-common-core/src/main/resources/mapper/WxInstrumentMapper.xml b/flossom-common/flossom-common-core/src/main/resources/mapper/WxInstrumentMapper.xml index 0c6403d..7c493dc 100644 --- a/flossom-common/flossom-common-core/src/main/resources/mapper/WxInstrumentMapper.xml +++ b/flossom-common/flossom-common-core/src/main/resources/mapper/WxInstrumentMapper.xml @@ -162,7 +162,6 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" #{miniTagNames}, #{wecomTagIds}, #{wecomTagNames}, - #{sceneNames}, #{nursingTime}, #{iotVersion}, #{iotUpgradeData}, diff --git a/flossom-common/flossom-common-core/src/main/resources/mapper/WxInstrumentModeMapper.xml b/flossom-common/flossom-common-core/src/main/resources/mapper/WxInstrumentModeMapper.xml new file mode 100644 index 0000000..2ba2e2d --- /dev/null +++ b/flossom-common/flossom-common-core/src/main/resources/mapper/WxInstrumentModeMapper.xml @@ -0,0 +1,83 @@ + + + + + + + + + + + + + + + + select id, instrument_id, mode_id, mode_sort, status, create_by, create_time from wx_instrument_mode + + + + + + + + insert into wx_instrument_mode + + instrument_id, + mode_id, + mode_sort, + status, + create_by, + create_time, + + + #{instrumentId}, + #{modeId}, + #{modeSort}, + #{status}, + #{createBy}, + #{createTime}, + + + + + update wx_instrument_mode + + instrument_id = #{instrumentId}, + mode_id = #{modeId}, + mode_sort = #{modeSort}, + status = #{status}, + create_by = #{createBy}, + create_time = #{createTime}, + + where id = #{id} + + + + delete from wx_instrument_mode where id = #{id} + + + + delete from wx_instrument_mode where id in + + #{id} + + + + + delete from wx_instrument_mode where instrument_id = #{instrumentId} + + \ No newline at end of file diff --git a/flossom-modules/flossom-system/src/main/java/com/flossom/system/controller/WxModeController.java b/flossom-modules/flossom-system/src/main/java/com/flossom/system/controller/WxModeController.java index 111cb36..9e40436 100644 --- a/flossom-modules/flossom-system/src/main/java/com/flossom/system/controller/WxModeController.java +++ b/flossom-modules/flossom-system/src/main/java/com/flossom/system/controller/WxModeController.java @@ -4,6 +4,7 @@ import java.util.List; import java.io.IOException; import javax.servlet.http.HttpServletResponse; +import com.flossom.common.core.domain.R; import com.flossom.common.core.domain.entity.WxMode; import com.flossom.common.core.utils.poi.ExcelUtil; import com.flossom.common.core.web.controller.BaseController; @@ -48,6 +49,16 @@ public class WxModeController extends BaseController return getDataTable(list); } + /** + * 查询模式列列表 + */ + @RequiresPermissions("system:mode:list") + @GetMapping("/listAll") + public R listAll(WxMode wxMode) + { + return R.ok(wxModeService.selectWxModeList(wxMode)); + } + /** * 导出模式列列表 */ diff --git a/flossom-modules/flossom-system/src/main/java/com/flossom/system/service/IWxInstrumentModeService.java b/flossom-modules/flossom-system/src/main/java/com/flossom/system/service/IWxInstrumentModeService.java new file mode 100644 index 0000000..26cd906 --- /dev/null +++ b/flossom-modules/flossom-system/src/main/java/com/flossom/system/service/IWxInstrumentModeService.java @@ -0,0 +1,62 @@ +package com.flossom.system.service; + +import com.flossom.common.core.domain.entity.WxInstrumentMode; + +import java.util.List; + + +/** + * 仪器与模式的关联Service接口 + * + * @author flossom + * @date 2024-01-17 + */ +public interface IWxInstrumentModeService { + /** + * 查询仪器与模式的关联 + * + * @param id 仪器与模式的关联主键 + * @return 仪器与模式的关联 + */ + public WxInstrumentMode selectWxInstrumentModeById(Long id); + + /** + * 查询仪器与模式的关联列表 + * + * @param wxInstrumentMode 仪器与模式的关联 + * @return 仪器与模式的关联集合 + */ + public List selectWxInstrumentModeList(WxInstrumentMode wxInstrumentMode); + + /** + * 新增仪器与模式的关联 + * + * @param wxInstrumentMode 仪器与模式的关联 + * @return 结果 + */ + public int insertWxInstrumentMode(WxInstrumentMode wxInstrumentMode); + + /** + * 修改仪器与模式的关联 + * + * @param wxInstrumentMode 仪器与模式的关联 + * @return 结果 + */ + public int updateWxInstrumentMode(WxInstrumentMode wxInstrumentMode); + + /** + * 批量删除仪器与模式的关联 + * + * @param ids 需要删除的仪器与模式的关联主键集合 + * @return 结果 + */ + public int deleteWxInstrumentModeByIds(Long[] ids); + + /** + * 删除仪器与模式的关联信息 + * + * @param id 仪器与模式的关联主键 + * @return 结果 + */ + public int deleteWxInstrumentModeById(Long id); +} diff --git a/flossom-modules/flossom-system/src/main/java/com/flossom/system/service/impl/WxInstrumentModeServiceImpl.java b/flossom-modules/flossom-system/src/main/java/com/flossom/system/service/impl/WxInstrumentModeServiceImpl.java new file mode 100644 index 0000000..ca61448 --- /dev/null +++ b/flossom-modules/flossom-system/src/main/java/com/flossom/system/service/impl/WxInstrumentModeServiceImpl.java @@ -0,0 +1,90 @@ +package com.flossom.system.service.impl; + +import java.util.List; + +import com.flossom.common.core.domain.entity.WxInstrumentMode; +import com.flossom.common.core.mapper.WxInstrumentModeMapper; +import com.flossom.common.core.utils.DateUtils; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; +import com.flossom.system.service.IWxInstrumentModeService; + +/** + * 仪器与模式的关联Service业务层处理 + * + * @author flossom + * @date 2024-01-17 + */ +@Service +public class WxInstrumentModeServiceImpl implements IWxInstrumentModeService { + + @Autowired + private WxInstrumentModeMapper wxInstrumentModeMapper; + + /** + * 查询仪器与模式的关联 + * + * @param id 仪器与模式的关联主键 + * @return 仪器与模式的关联 + */ + @Override + public WxInstrumentMode selectWxInstrumentModeById(Long id) { + return wxInstrumentModeMapper.selectWxInstrumentModeById(id); + } + + /** + * 查询仪器与模式的关联列表 + * + * @param wxInstrumentMode 仪器与模式的关联 + * @return 仪器与模式的关联 + */ + @Override + public List selectWxInstrumentModeList(WxInstrumentMode wxInstrumentMode) { + return wxInstrumentModeMapper.selectWxInstrumentModeList(wxInstrumentMode); + } + + /** + * 新增仪器与模式的关联 + * + * @param wxInstrumentMode 仪器与模式的关联 + * @return 结果 + */ + @Override + public int insertWxInstrumentMode(WxInstrumentMode wxInstrumentMode) { + wxInstrumentMode.setCreateTime(DateUtils.getNowDate()); + return wxInstrumentModeMapper.insertWxInstrumentMode(wxInstrumentMode); + } + + /** + * 修改仪器与模式的关联 + * + * @param wxInstrumentMode 仪器与模式的关联 + * @return 结果 + */ + @Override + public int updateWxInstrumentMode(WxInstrumentMode wxInstrumentMode) { + return wxInstrumentModeMapper.updateWxInstrumentMode(wxInstrumentMode); + } + + /** + * 批量删除仪器与模式的关联 + * + * @param ids 需要删除的仪器与模式的关联主键 + * @return 结果 + */ + @Override + public int deleteWxInstrumentModeByIds(Long[] ids) { + return wxInstrumentModeMapper.deleteWxInstrumentModeByIds(ids); + } + + /** + * 删除仪器与模式的关联信息 + * + * @param id 仪器与模式的关联主键 + * @return 结果 + */ + @Override + public int deleteWxInstrumentModeById(Long id) { + return wxInstrumentModeMapper.deleteWxInstrumentModeById(id); + } +} diff --git a/flossom-modules/flossom-system/src/main/java/com/flossom/system/service/impl/WxInstrumentServiceImpl.java b/flossom-modules/flossom-system/src/main/java/com/flossom/system/service/impl/WxInstrumentServiceImpl.java index e15ba5b..ffcf61b 100644 --- a/flossom-modules/flossom-system/src/main/java/com/flossom/system/service/impl/WxInstrumentServiceImpl.java +++ b/flossom-modules/flossom-system/src/main/java/com/flossom/system/service/impl/WxInstrumentServiceImpl.java @@ -3,16 +3,20 @@ package com.flossom.system.service.impl; import java.util.Arrays; import java.util.Iterator; import java.util.List; +import java.util.stream.Collectors; 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.entity.WxInstrumentMode; 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.enums.Status; 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.mapper.WxInstrumentModeMapper; import com.flossom.common.core.utils.DateUtils; import com.flossom.common.core.utils.StringUtils; import com.flossom.common.security.utils.SecurityUtils; @@ -40,6 +44,9 @@ public class WxInstrumentServiceImpl implements IWxInstrumentService { @Autowired private WxInstrumentFileRelateMapper wxInstrumentFileRelateMapper; + @Autowired + private WxInstrumentModeMapper wxInstrumentModeMapper; + /** * 查询仪器列 * @@ -74,6 +81,16 @@ public class WxInstrumentServiceImpl implements IWxInstrumentService { List instructionRelate = wxInstrumentFileRelateMapper. selectByInstrumentIdAndClassify(wxInstrument.getId(), InstrumentFileClassify.INSTRUMENT_INSTRUCTION.getCode()); wxInstrumentSaveReq.setIntroduceList(instructionRelate); + // 获取模式关联 + WxInstrumentMode wxInstrumentMode = new WxInstrumentMode(); + wxInstrumentMode.setInstrumentId(id); + List wxInstrumentModes = wxInstrumentModeMapper.selectWxInstrumentModeList(wxInstrumentMode); + if (wxInstrumentModes != null && wxInstrumentModes.size() > 0) { + wxInstrumentSaveReq.setModeIdsValue(wxInstrumentModes.stream() + .map(WxInstrumentMode::getModeId) + .map(Long::intValue) + .collect(Collectors.toList())); + } return wxInstrumentSaveReq; } @@ -116,12 +133,14 @@ public class WxInstrumentServiceImpl implements IWxInstrumentService { WxInstrument wxInstrument = new WxInstrument(); BeanUtils.copyProperties(wxInstrumentSaveReq, wxInstrument); // 打卡时间处理 - wxInstrument.setStartTime(wxInstrumentSaveReq.getExtraClockTimeRange().get(0)); - wxInstrument.setEndTime(wxInstrumentSaveReq.getExtraClockTimeRange().get(1)); + if (wxInstrumentSaveReq.getIsExtraClock() != null && wxInstrumentSaveReq.getIsExtraClock() == 1) { + 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); + int insertNum = wxInstrumentMapper.insertWxInstrument(wxInstrument); // 保存初次护理规则 List nurseList = wxInstrumentSaveReq.getNurseList(); @@ -154,7 +173,23 @@ public class WxInstrumentServiceImpl implements IWxInstrumentService { wxInstrumentFileRelateMapper.insertWxInstrumentFileRelate(next); } } - return i; + + // 模式关联 + List modeIdList = wxInstrumentSaveReq.getModeIdsValue(); + if (modeIdList != null && modeIdList.size() > 0) { + wxInstrumentModeMapper.deleteByInstrumentId(wxInstrumentSaveReq.getId()); + for (int i = 0; i < modeIdList.size(); i++) { + WxInstrumentMode wxInstrumentMode = new WxInstrumentMode(); + wxInstrumentMode.setInstrumentId(wxInstrument.getId()); + wxInstrumentMode.setModeId(modeIdList.get(i).longValue()); + wxInstrumentMode.setModeSort(i); + wxInstrumentMode.setStatus(Status.OK.getCode()); + wxInstrumentMode.setCreateBy(SecurityUtils.getUsername()); + wxInstrumentMode.setCreateTime(DateUtils.getNowDate()); + wxInstrumentModeMapper.insertWxInstrumentMode(wxInstrumentMode); + } + } + return insertNum; } /** @@ -201,8 +236,11 @@ public class WxInstrumentServiceImpl implements IWxInstrumentService { wxInstrument.setUpdateTime(DateUtils.getNowDate()); // 打卡时间处理 - wxInstrument.setStartTime(wxInstrumentSaveReq.getExtraClockTimeRange().get(0)); - wxInstrument.setEndTime(wxInstrumentSaveReq.getExtraClockTimeRange().get(1)); + // 打卡时间处理 + if (wxInstrumentSaveReq.getIsExtraClock() != null && wxInstrumentSaveReq.getIsExtraClock() == 1) { + wxInstrument.setStartTime(wxInstrumentSaveReq.getExtraClockTimeRange().get(0)); + wxInstrument.setEndTime(wxInstrumentSaveReq.getExtraClockTimeRange().get(1)); + } // 保存初次护理规则 List nurseList = wxInstrumentSaveReq.getNurseList(); @@ -238,6 +276,21 @@ public class WxInstrumentServiceImpl implements IWxInstrumentService { wxInstrumentFileRelateMapper.insertWxInstrumentFileRelate(next); } + // 模式关联 + List modeIdList = wxInstrumentSaveReq.getModeIdsValue(); + if (modeIdList != null && modeIdList.size() > 0) { + wxInstrumentModeMapper.deleteByInstrumentId(wxInstrumentSaveReq.getId()); + for (int i = 0; i < modeIdList.size(); i++) { + WxInstrumentMode wxInstrumentMode = new WxInstrumentMode(); + wxInstrumentMode.setInstrumentId(wxInstrumentSaveReq.getId()); + wxInstrumentMode.setModeId(modeIdList.get(i).longValue()); + wxInstrumentMode.setModeSort(i); + wxInstrumentMode.setStatus(Status.OK.getCode()); + wxInstrumentMode.setCreateBy(SecurityUtils.getUsername()); + wxInstrumentMode.setCreateTime(DateUtils.getNowDate()); + wxInstrumentModeMapper.insertWxInstrumentMode(wxInstrumentMode); + } + } return wxInstrumentMapper.updateWxInstrument(wxInstrument); } diff --git a/flossom-ui/src/api/system/instrument.js b/flossom-ui/src/api/system/instrument.js index 1a02129..e070ed7 100644 --- a/flossom-ui/src/api/system/instrument.js +++ b/flossom-ui/src/api/system/instrument.js @@ -135,6 +135,13 @@ export function delInstructions(id) { }) } +export function listAllMode(query) { + return request({ + url: '/system/mode/listAll', + method: 'get', + params: query + }) +} diff --git a/flossom-ui/src/views/system/instrument/index.vue b/flossom-ui/src/views/system/instrument/index.vue index 0566b72..5fca60f 100644 --- a/flossom-ui/src/views/system/instrument/index.vue +++ b/flossom-ui/src/views/system/instrument/index.vue @@ -447,7 +447,7 @@ - + - - - - - - - 排序 - - - + + - +
- -