diff --git a/flossom-common/flossom-common-core/src/main/java/com/flossom/common/core/domain/entity/WxInstrumentSerial.java b/flossom-common/flossom-common-core/src/main/java/com/flossom/common/core/domain/entity/WxInstrumentSerial.java index 4199a4d..6206a2a 100644 --- a/flossom-common/flossom-common-core/src/main/java/com/flossom/common/core/domain/entity/WxInstrumentSerial.java +++ b/flossom-common/flossom-common-core/src/main/java/com/flossom/common/core/domain/entity/WxInstrumentSerial.java @@ -5,6 +5,7 @@ import com.flossom.common.core.web.domain.BaseEntity; import org.apache.commons.lang3.builder.ToStringBuilder; import org.apache.commons.lang3.builder.ToStringStyle; +import java.util.ArrayList; import java.util.List; /** @@ -54,6 +55,13 @@ public class WxInstrumentSerial extends BaseEntity private String queryInstrumentIds; + /** + * 自定导出字段 + */ + private List exportFields = new ArrayList<>(); + + private List instrumentSerialIdList = new ArrayList<>(); + public void setId(Long id) { this.id = id; @@ -142,6 +150,22 @@ public class WxInstrumentSerial extends BaseEntity this.source = source; } + public List getExportFields() { + return exportFields; + } + + public void setExportFields(List exportFields) { + this.exportFields = exportFields; + } + + public List getInstrumentSerialIdList() { + return instrumentSerialIdList; + } + + public void setInstrumentSerialIdList(List instrumentSerialIdList) { + this.instrumentSerialIdList = instrumentSerialIdList; + } + @Override public String toString() { return new ToStringBuilder(this,ToStringStyle.MULTI_LINE_STYLE) diff --git a/flossom-common/flossom-common-core/src/main/java/com/flossom/common/core/domain/req/WxInstrumentSerialExportVm.java b/flossom-common/flossom-common-core/src/main/java/com/flossom/common/core/domain/req/WxInstrumentSerialExportVm.java new file mode 100644 index 0000000..3631f3b --- /dev/null +++ b/flossom-common/flossom-common-core/src/main/java/com/flossom/common/core/domain/req/WxInstrumentSerialExportVm.java @@ -0,0 +1,79 @@ +package com.flossom.common.core.domain.req; + +import com.flossom.common.core.annotation.Excel; + +import java.util.Date; + +public class WxInstrumentSerialExportVm { + + @Excel(name = "序号") + private Long id; + + /** 仪器名称 */ + @Excel(name = "仪器名称") + private String instrumentName; + + /** 来源 */ + @Excel(name = "来源") + private String source; + + /** 序列号 */ + @Excel(name = "序列号") + private String serial; + + /** 序列号有效状态,1有效,0无效 */ + @Excel(name = "有效状态") + private String validStatus; + + /** 创建时间 */ + @Excel(name = "操作时间", width = 30, dateFormat = "yyyy-MM-dd HH:mm:ss") + private Date createTime; + + public Long getId() { + return id; + } + + public void setId(Long id) { + this.id = id; + } + + public String getInstrumentName() { + return instrumentName; + } + + public void setInstrumentName(String instrumentName) { + this.instrumentName = instrumentName; + } + + public String getSource() { + return source; + } + + public void setSource(String source) { + this.source = source; + } + + public String getSerial() { + return serial; + } + + public void setSerial(String serial) { + this.serial = serial; + } + + public String getValidStatus() { + return validStatus; + } + + public void setValidStatus(String validStatus) { + this.validStatus = validStatus; + } + + public Date getCreateTime() { + return createTime; + } + + public void setCreateTime(Date createTime) { + this.createTime = createTime; + } +} diff --git a/flossom-common/flossom-common-core/src/main/java/com/flossom/common/core/mapper/WxInstrumentSerialMapper.java b/flossom-common/flossom-common-core/src/main/java/com/flossom/common/core/mapper/WxInstrumentSerialMapper.java index 0282e4a..ffbbf81 100644 --- a/flossom-common/flossom-common-core/src/main/java/com/flossom/common/core/mapper/WxInstrumentSerialMapper.java +++ b/flossom-common/flossom-common-core/src/main/java/com/flossom/common/core/mapper/WxInstrumentSerialMapper.java @@ -59,4 +59,18 @@ public interface WxInstrumentSerialMapper * @return 结果 */ public int deleteWxInstrumentSerialByIds(Long[] ids); + + /** + * 全量删除数据 + * + * @return 结果 + */ + public int deleteAll(); + + /** + * 全量更新状态 + * + * @return 结果 + */ + public int updateAll(WxInstrumentSerial wxInstrumentSerial); } diff --git a/flossom-common/flossom-common-core/src/main/resources/mapper/WxInstrumentSerialMapper.xml b/flossom-common/flossom-common-core/src/main/resources/mapper/WxInstrumentSerialMapper.xml index 5b4a9cd..54d9a22 100644 --- a/flossom-common/flossom-common-core/src/main/resources/mapper/WxInstrumentSerialMapper.xml +++ b/flossom-common/flossom-common-core/src/main/resources/mapper/WxInstrumentSerialMapper.xml @@ -94,10 +94,22 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" where id = #{id} + + + update wx_instrument_serial + + valid_status = #{validStatus}, + + + delete from wx_instrument_serial where id = #{id} + + delete from wx_instrument_serial + + delete from wx_instrument_serial where id in diff --git a/flossom-modules/flossom-system/src/main/java/com/flossom/system/controller/WxInstrumentSerialController.java b/flossom-modules/flossom-system/src/main/java/com/flossom/system/controller/WxInstrumentSerialController.java index 7bbdd41..869759d 100644 --- a/flossom-modules/flossom-system/src/main/java/com/flossom/system/controller/WxInstrumentSerialController.java +++ b/flossom-modules/flossom-system/src/main/java/com/flossom/system/controller/WxInstrumentSerialController.java @@ -5,6 +5,9 @@ import java.io.IOException; import javax.servlet.http.HttpServletResponse; import com.flossom.common.core.domain.entity.WxInstrumentSerial; +import com.flossom.common.core.domain.entity.WxUserInstrument; +import com.flossom.common.core.domain.req.WxInstrumentSerialExportVm; +import com.flossom.common.core.domain.req.WxUserInstrumentExportVm; import com.flossom.common.core.utils.poi.ExcelUtil; import com.flossom.common.core.web.controller.BaseController; import com.flossom.common.core.web.domain.AjaxResult; @@ -93,6 +96,19 @@ public class WxInstrumentSerialController extends BaseController return toAjax(wxInstrumentSerialService.updateWxInstrumentSerial(wxInstrumentSerial)); } + + /** + * 修改仪器序列号关联 + */ + @RequiresPermissions("system:instrumentSerial:edit") + @Log(title = "仪器序列号关联", businessType = BusinessType.UPDATE) + @PutMapping("/updateStatus") + public AjaxResult updateStatus(@RequestBody WxInstrumentSerial wxInstrumentSerial) + { + return toAjax(wxInstrumentSerialService.updateRecordStatus(wxInstrumentSerial)); + } + + /** * 删除仪器序列号关联 */ @@ -103,4 +119,27 @@ public class WxInstrumentSerialController extends BaseController { return toAjax(wxInstrumentSerialService.deleteWxInstrumentSerialByIds(ids)); } + + /** + * 删除仪器序列号关联 + */ + @RequiresPermissions("system:instrumentSerial:remove") + @Log(title = "仪器序列号关联", businessType = BusinessType.DELETE) + @DeleteMapping("/removeAll}") + public AjaxResult removeAll() + { + return toAjax(wxInstrumentSerialService.deleteAll()); + } + + + /** + * 批量导出用户列表 + */ + @Log(title = "批量导出", businessType = BusinessType.EXPORT) + @PostMapping("/batchExport") + public void batchExport(HttpServletResponse response, WxInstrumentSerial wxInstrumentSerial) { + List wxInstrumentSerialExportVms = wxInstrumentSerialService.handleExportData(wxInstrumentSerial); + ExcelUtil util = new ExcelUtil(WxInstrumentSerialExportVm.class); + util.exportExcel(response, wxInstrumentSerialExportVms, "仪器序列号", wxInstrumentSerial.getExportFields()); + } } diff --git a/flossom-modules/flossom-system/src/main/java/com/flossom/system/service/IWxInstrumentSerialService.java b/flossom-modules/flossom-system/src/main/java/com/flossom/system/service/IWxInstrumentSerialService.java index 6a57273..d08c841 100644 --- a/flossom-modules/flossom-system/src/main/java/com/flossom/system/service/IWxInstrumentSerialService.java +++ b/flossom-modules/flossom-system/src/main/java/com/flossom/system/service/IWxInstrumentSerialService.java @@ -1,6 +1,7 @@ package com.flossom.system.service; import com.flossom.common.core.domain.entity.WxInstrumentSerial; +import com.flossom.common.core.domain.req.WxInstrumentSerialExportVm; import java.util.List; @@ -59,4 +60,28 @@ public interface IWxInstrumentSerialService * @return 结果 */ public int deleteWxInstrumentSerialById(Long id); + /** + * 全量删除数据 + * + * @param + * @return 结果 + */ + public int deleteAll(); + + /** + * 更新数据 + * + * @param + * @return 结果 + */ + public int updateRecordStatus(WxInstrumentSerial wxInstrumentSerial); + /** + * 获取导出数据 + * + * @param wxInstrumentSerial 查询实体 + * @return 结果 + */ + public List handleExportData(WxInstrumentSerial wxInstrumentSerial); + + } diff --git a/flossom-modules/flossom-system/src/main/java/com/flossom/system/service/impl/WxInstrumentSerialServiceImpl.java b/flossom-modules/flossom-system/src/main/java/com/flossom/system/service/impl/WxInstrumentSerialServiceImpl.java index ddea0ee..f8aeda9 100644 --- a/flossom-modules/flossom-system/src/main/java/com/flossom/system/service/impl/WxInstrumentSerialServiceImpl.java +++ b/flossom-modules/flossom-system/src/main/java/com/flossom/system/service/impl/WxInstrumentSerialServiceImpl.java @@ -4,8 +4,11 @@ import java.util.List; import java.util.stream.Collectors; import com.flossom.common.core.domain.entity.WxInstrumentSerial; +import com.flossom.common.core.domain.req.WxInstrumentSerialExportVm; import com.flossom.common.core.mapper.WxInstrumentSerialMapper; import com.flossom.common.core.utils.DateUtils; +import org.apache.commons.compress.utils.Lists; +import org.springframework.beans.BeanUtils; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; import com.flossom.system.service.IWxInstrumentSerialService; @@ -100,4 +103,53 @@ public class WxInstrumentSerialServiceImpl implements IWxInstrumentSerialService { return wxInstrumentSerialMapper.deleteWxInstrumentSerialById(id); } + + @Override + public int deleteAll() { + return wxInstrumentSerialMapper.deleteAll(); + } + + @Override + public int updateRecordStatus(WxInstrumentSerial wxInstrumentSerial) { + if(CollectionUtils.isEmpty(wxInstrumentSerial.getInstrumentSerialIdList())) { + // 全量更新数据 + int i = wxInstrumentSerialMapper.updateAll(wxInstrumentSerial); + } else { + List instrumentSerialIdList = wxInstrumentSerial.getInstrumentSerialIdList(); + for (Long id : instrumentSerialIdList) { + WxInstrumentSerial updateRecord = new WxInstrumentSerial(); + updateRecord.setId(id); + updateRecord.setValidStatus(wxInstrumentSerial.getValidStatus()); + wxInstrumentSerialMapper.updateWxInstrumentSerial(updateRecord); + } + } + return 1; + } + + @Override + public List handleExportData(WxInstrumentSerial wxInstrumentSerial) { + List resultList = Lists.newArrayList(); + if (CollectionUtils.isEmpty(wxInstrumentSerial.getInstrumentSerialIdList())) { + // 全量搜素 + List wxInstrumentSerials = this.selectWxInstrumentSerialList(wxInstrumentSerial); + if (!CollectionUtils.isEmpty(wxInstrumentSerials)) { + for (WxInstrumentSerial instrumentSerial : wxInstrumentSerials) { + WxInstrumentSerialExportVm entity = new WxInstrumentSerialExportVm(); + BeanUtils.copyProperties(instrumentSerial,entity); + entity.setValidStatus(instrumentSerial.getValidStatus() == 1 ? "有效": "无效"); + resultList.add(entity); + } + } + } else { + List instrumentSerialIdList = wxInstrumentSerial.getInstrumentSerialIdList(); + for (Long id: instrumentSerialIdList) { + WxInstrumentSerial instrumentSerial = wxInstrumentSerialMapper.selectWxInstrumentSerialById(id); + WxInstrumentSerialExportVm entity = new WxInstrumentSerialExportVm(); + BeanUtils.copyProperties(instrumentSerial,entity); + entity.setValidStatus(instrumentSerial.getValidStatus() == 1 ? "有效": "无效"); + resultList.add(entity); + } + } + return resultList; + } } diff --git a/flossom-ui/src/api/system/instrumentSerial.js b/flossom-ui/src/api/system/instrumentSerial.js index 5bdd36d..2695034 100644 --- a/flossom-ui/src/api/system/instrumentSerial.js +++ b/flossom-ui/src/api/system/instrumentSerial.js @@ -35,6 +35,15 @@ export function updateSerial(data) { }) } +// 修改仪器序列号关联 +export function updateStatus(data) { + return request({ + url: '/system/instrumentSerial/updateStatus', + method: 'put', + data: data + }) +} + // 删除仪器序列号关联 export function delSerial(id) { return request({ @@ -42,3 +51,11 @@ export function delSerial(id) { method: 'delete' }) } + +// 删除仪器序列号关联 +export function delSerialAll() { + return request({ + url: '/system/instrumentSerial/removeAll', + method: 'delete' + }) +} diff --git a/flossom-ui/src/views/system/instrumentSerial/index.vue b/flossom-ui/src/views/system/instrumentSerial/index.vue index 7af680e..1d98375 100644 --- a/flossom-ui/src/views/system/instrumentSerial/index.vue +++ b/flossom-ui/src/views/system/instrumentSerial/index.vue @@ -65,6 +65,28 @@ + + + + + + + + + + + + + 确认 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+ 有效 + 无效 +
+ +
+