仪器序列号导出模块开发

master
elliott 2 years ago
parent b6c4273f83
commit 69bcfa3fbb

@ -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<String> exportFields = new ArrayList<>();
private List<Long> 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<String> getExportFields() {
return exportFields;
}
public void setExportFields(List<String> exportFields) {
this.exportFields = exportFields;
}
public List<Long> getInstrumentSerialIdList() {
return instrumentSerialIdList;
}
public void setInstrumentSerialIdList(List<Long> instrumentSerialIdList) {
this.instrumentSerialIdList = instrumentSerialIdList;
}
@Override
public String toString() {
return new ToStringBuilder(this,ToStringStyle.MULTI_LINE_STYLE)

@ -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;
}
}

@ -59,4 +59,18 @@ public interface WxInstrumentSerialMapper
* @return
*/
public int deleteWxInstrumentSerialByIds(Long[] ids);
/**
*
*
* @return
*/
public int deleteAll();
/**
*
*
* @return
*/
public int updateAll(WxInstrumentSerial wxInstrumentSerial);
}

@ -94,10 +94,22 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
where id = #{id}
</update>
<update id="updateAll" parameterType="WxInstrumentSerial">
update wx_instrument_serial
<trim prefix="SET" suffixOverrides=",">
<if test="validStatus != null">valid_status = #{validStatus},</if>
</trim>
</update>
<delete id="deleteWxInstrumentSerialById" parameterType="Long">
delete from wx_instrument_serial where id = #{id}
</delete>
<delete id="deleteAll">
delete from wx_instrument_serial
</delete>
<delete id="deleteWxInstrumentSerialByIds" parameterType="String">
delete from wx_instrument_serial where id in
<foreach item="id" collection="array" open="(" separator="," close=")">

@ -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<WxInstrumentSerialExportVm> wxInstrumentSerialExportVms = wxInstrumentSerialService.handleExportData(wxInstrumentSerial);
ExcelUtil<WxInstrumentSerialExportVm> util = new ExcelUtil<WxInstrumentSerialExportVm>(WxInstrumentSerialExportVm.class);
util.exportExcel(response, wxInstrumentSerialExportVms, "仪器序列号", wxInstrumentSerial.getExportFields());
}
}

@ -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<WxInstrumentSerialExportVm> handleExportData(WxInstrumentSerial wxInstrumentSerial);
}

@ -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<Long> 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<WxInstrumentSerialExportVm> handleExportData(WxInstrumentSerial wxInstrumentSerial) {
List<WxInstrumentSerialExportVm> resultList = Lists.newArrayList();
if (CollectionUtils.isEmpty(wxInstrumentSerial.getInstrumentSerialIdList())) {
// 全量搜素
List<WxInstrumentSerial> 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<Long> 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;
}
}

@ -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'
})
}

@ -65,6 +65,28 @@
</el-form>
<el-row :gutter="10" class="mb8">
<el-col :span="1.5">
<el-select v-model="batchOperateValue" placeholder="批量操作" size="mini" clearable>
<el-option label="导出数据" :value="1"></el-option>
<el-option label="导出全量数据" :value="2"></el-option>
<el-option label="批量导入序列号创建" :value="3"></el-option>
<el-option label="删除批量数据" :value="4"></el-option>
<el-option label="删除全量数据" :value="5"></el-option>
<el-option label="修改批量数据" :value="6"></el-option>
<el-option label="修改全量数据" :value="7"></el-option>
</el-select>
</el-col>
<el-col :span="1.5">
<el-button
type="primary"
plain
icon="el-icon-warning"
size="mini"
@click="batchOperate()"
>确认
</el-button>
</el-col>
<right-toolbar :showSearch.sync="showSearch" @queryTable="getList"></right-toolbar>
<el-col :span="1.5">
<el-button
type="primary"
@ -240,11 +262,55 @@
<el-image :key="codeUrl" :src="codeUrl" :preview-src-list="[codeUrl]" lazy></el-image>
</div>
</el-dialog>
<!-- 导出字段选择弹窗 -->
<el-dialog title="自定义导出字段" :visible.sync="exportFieldsVisible" width="50%"
:before-close="cancelExportFieldsDialog">
<el-form ref="form" label-width="150px">
<el-form-item label="全部字段" prop="allFields">
<el-switch v-model="allFields" @click.native="isExportAllFields()"/>
</el-form-item>
</el-form>
<el-form :inline="true" ref="form" :model="exportFieldList" label-width="150px">
<el-form-item label="序号 " prop="nickname">
<el-switch v-model="exportFieldList.id" :active-value="'id'" :inactive-value="null"/>
</el-form-item>
<el-form-item label="仪器 " prop="instrumentName">
<el-switch v-model="exportFieldList.instrumentName" active-value="instrumentName" :inactive-value="null"/>
</el-form-item>
<el-form-item label="来源 " prop="source">
<el-switch v-model="exportFieldList.source" active-value="source" :inactive-value="null"/>
</el-form-item>
<el-form-item label="序列号 " prop="serial">
<el-switch v-model="exportFieldList.serial" active-value="serial" :inactive-value="null"/>
</el-form-item>
<el-form-item label="有效状态 " prop="validStatus">
<el-switch v-model="exportFieldList.validStatus" active-value="validStatus" :inactive-value="null"/>
</el-form-item>
<el-form-item label="创建时间 " prop="createTime">
<el-switch v-model="exportFieldList.createTime" active-value="createTime" :inactive-value="null"/>
</el-form-item>
</el-form>
<div slot="footer" class="dialog-footer">
<el-button @click="cancelExportFieldsDialog()"> </el-button>
<el-button type="primary" @click="submitBatchOperate"> </el-button>
</div>
</el-dialog>
<el-dialog title="修改状态" :visible.sync="validStatusVisible" width="400px">
<div style="margin-left: 10%" >
<el-radio v-model="updateValidStatusForm.validStatus" label="1"></el-radio>
<el-radio v-model="updateValidStatusForm.validStatus" label="0"></el-radio>
</div>
<div slot="footer" class="dialog-footer">
<el-button @click="cancelUpdateStatusDialog()"> </el-button>
<el-button type="primary" @click="submitBatchOperate"> </el-button>
</div>
</el-dialog>
</div>
</template>
<script>
import { listSerial, getSerial, delSerial, addSerial, updateSerial } from "@/api/system/instrumentSerial";
import { listSerial, getSerial, delSerial, addSerial, updateSerial,delSerialAll,updateStatus } from "@/api/system/instrumentSerial";
import {listInstrument} from "@/api/system/instrument";
import {listLog} from "@/api/system/userInstrumentLog"
@ -265,6 +331,8 @@ export default {
userInstrumentLogList: [],
//
instrumentList: [],
//
validStatusVisible: false,
//
loading: true,
//
@ -284,11 +352,32 @@ export default {
title: "",
//
open: false,
batchOperateValue: null,
//
exportFieldsVisible : false,
allFields: false,
//
exportFieldList: {
id: null,
instrumentName: null,
source: null,
serial: null,
validStatus: null,
createTime: null,
},
exportFieldsForm: {
instrumentSerialIdList: null,
exportFields: null,
},
queryLogParams: {
pageNum: 1,
pageSize: 10,
userInstrumentId: null,
},
updateValidStatusForm: {
validStatus: "1",
instrumentSerialIdList: null,
},
//
queryParams: {
pageNum: 1,
@ -451,7 +540,134 @@ export default {
codeShow(row){
this.codeUrl = process.env.VUE_APP_BASE_API + '/system/qrcode/create?serial=' + row.serial;
this.codeOpen = true;
}
},
//
batchOperate() {
if (this.batchOperateValue == null) {
this.$message.error("请选择您的操作");
return;
}
if (this.batchOperateValue == 1) {
if (this.ids.length == 0) {
this.$message.error("请选择数据");
return
}
this.exportFieldsVisible = true;
}
if (this.batchOperateValue == 2) {
this.exportFieldsVisible = true;
}
if (this.batchOperateValue == 4) {
if (this.ids.length == 0) {
this.$message.error("请选择数据");
return
}
this.$modal.confirm('确定将选择的数据删除?【请谨慎操作,一旦成功将无法撤销】').then(function() {
return delSerial(ids);
}).then(() => {
this.getList();
this.$modal.msgSuccess("删除成功");
}).catch(() => {});
}
if (this.batchOperateValue == 5) {
this.$modal.confirm('确定将【全量】的数据删除?【请谨慎操作,一旦成功将无法撤销】').then(function() {
return delSerialAll();
}).then(() => {
this.getList();
this.$modal.msgSuccess("删除成功");
}).catch(() => {});
}
if (this.batchOperateValue == 6 ) {
if (this.ids.length == 0) {
this.$message.error("请选择数据");
return
}
this.validStatusVisible = true;
}
if (this.batchOperateValue == 7 ) {
this.validStatusVisible = true;
}
},
//
cancelExportFieldsDialog() {
this.allFields = false;
this.exportFieldsVisible = false
this.exportFieldList = {
id: null,
instrumentName: null,
source: null,
serial: null,
validStatus: null,
createTime: null,
}
},
//
submitBatchOperate() {
//
if (this.batchOperateValue == 1) {
let exportFields = Object.values(this.exportFieldList).filter(val => val != null);
if (exportFields.length == 0) {
this.$modal.msgError("请选择导出字段");
return;
}
this.exportFieldsForm.instrumentSerialIdList = this.ids;
this.exportFieldsForm.exportFields = exportFields;
this.download('/system/instrumentSerial/batchExport', {
...this.exportFieldsForm
}, `仪器序列号_${new Date().getTime()}.xlsx`);
this.cancelExportFieldsDialog();
}
if (this.batchOperateValue == 2) {
let exportFields = Object.values(this.exportFieldList).filter(val => val != null);
if (exportFields.length == 0) {
this.$modal.msgError("请选择导出字段");
return;
}
this.queryParams.instrumentSerialIdList = null;
this.queryParams.exportFields = exportFields;
this.download('/system/instrumentSerial/batchExport', {
...Object.assign({}, this.queryParams, {exportFields: exportFields})
}, `仪器序列号_${new Date().getTime()}.xlsx`)
this.cancelExportFieldsDialog();
}
if (this.batchOperateValue == 6) {
this.updateValidStatusForm.instrumentSerialIdList = this.ids;
updateStatus(this.updateValidStatusForm).then(response => {
this.$modal.msgSuccess("更新成功");
this.validStatusVisible = false;
this.getList();
});
}
if (this.batchOperateValue == 7) {
this.updateValidStatusForm.instrumentSerialIdList = null;
updateStatus(this.updateValidStatusForm).then(response => {
this.$modal.msgSuccess("更新成功");
this.validStatusVisible = false;
this.getList();
});
}
},
isExportAllFields() {
if (this.allFields) {
this.exportFieldList.instrumentName = "instrumentName";
this.exportFieldList.id = "id";
this.exportFieldList.source = "source";
this.exportFieldList.validStatus = "validStatus";
this.exportFieldList.serial = "serial";
this.exportFieldList.createTime = "createTime";
} else {
this.exportFieldList.instrumentName = null;
this.exportFieldList.id = null;
this.exportFieldList.source = null;
this.exportFieldList.serial = null;
this.exportFieldList.validStatus = null;
this.exportFieldList.createTime = null;
}
},
cancelUpdateStatusDialog (){
this.validStatusVisible = false;
},
}
};
</script>

Loading…
Cancel
Save