parent
a6db6a4c41
commit
644f98b934
|
|
@ -3,6 +3,10 @@ package com.ruoyi.basedata.controller;
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import javax.servlet.http.HttpServletResponse;
|
import javax.servlet.http.HttpServletResponse;
|
||||||
|
|
||||||
|
import com.ruoyi.common.core.domain.entity.SysUser;
|
||||||
|
import com.ruoyi.common.utils.SecurityUtils;
|
||||||
|
import com.ruoyi.util.importRunnable;
|
||||||
import org.springframework.security.access.prepost.PreAuthorize;
|
import org.springframework.security.access.prepost.PreAuthorize;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.web.bind.annotation.GetMapping;
|
import org.springframework.web.bind.annotation.GetMapping;
|
||||||
|
|
@ -21,6 +25,7 @@ import com.ruoyi.basedata.domain.Pounddata;
|
||||||
import com.ruoyi.basedata.service.IPounddataService;
|
import com.ruoyi.basedata.service.IPounddataService;
|
||||||
import com.ruoyi.common.utils.poi.ExcelUtil;
|
import com.ruoyi.common.utils.poi.ExcelUtil;
|
||||||
import com.ruoyi.common.core.page.TableDataInfo;
|
import com.ruoyi.common.core.page.TableDataInfo;
|
||||||
|
import org.springframework.web.multipart.MultipartFile;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 计量基础资料Controller
|
* 计量基础资料Controller
|
||||||
|
|
@ -35,6 +40,9 @@ public class PounddataController extends BaseController
|
||||||
@Autowired
|
@Autowired
|
||||||
private IPounddataService pounddataService;
|
private IPounddataService pounddataService;
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private importRunnable importRunnable;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 查询计量基础资料列表
|
* 查询计量基础资料列表
|
||||||
*/
|
*/
|
||||||
|
|
@ -102,4 +110,27 @@ public class PounddataController extends BaseController
|
||||||
{
|
{
|
||||||
return toAjax(pounddataService.removeByIds(Arrays.asList(ids)));
|
return toAjax(pounddataService.removeByIds(Arrays.asList(ids)));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 下载模板
|
||||||
|
*/
|
||||||
|
@PostMapping("/importTemplate")
|
||||||
|
public void downTemplate(HttpServletResponse response) {
|
||||||
|
ExcelUtil<Pounddata> util = new ExcelUtil<>(Pounddata.class);
|
||||||
|
util.importTemplateExcel(response, "类别");
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@PostMapping("/importData")
|
||||||
|
public AjaxResult importData(MultipartFile file, boolean updateSupport) throws Exception
|
||||||
|
{
|
||||||
|
ExcelUtil<Pounddata> util = new ExcelUtil<Pounddata>(Pounddata.class);
|
||||||
|
List<Pounddata> poundList = util.importExcel(file.getInputStream());
|
||||||
|
importRunnable.removeParam();
|
||||||
|
importRunnable.setPounddataList(poundList);
|
||||||
|
importRunnable.setOperName(SecurityUtils.getLoginUser().getUsername());
|
||||||
|
Thread thread = new Thread(importRunnable);
|
||||||
|
thread.start();
|
||||||
|
return success("后台导入中...");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -39,7 +39,6 @@ public class Pounddata extends BaseEntity
|
||||||
private String type;
|
private String type;
|
||||||
|
|
||||||
/** 业务磅点id */
|
/** 业务磅点id */
|
||||||
@Excel(name = "业务磅点id")
|
|
||||||
private Long poundid;
|
private Long poundid;
|
||||||
|
|
||||||
/** 助记码 */
|
/** 助记码 */
|
||||||
|
|
@ -47,29 +46,27 @@ public class Pounddata extends BaseEntity
|
||||||
private String helpcode;
|
private String helpcode;
|
||||||
|
|
||||||
/** 登记部门 */
|
/** 登记部门 */
|
||||||
@Excel(name = "登记部门")
|
|
||||||
private Long crtorgid;
|
private Long crtorgid;
|
||||||
|
|
||||||
/** 是否启用 */
|
/** 是否启用 */
|
||||||
@Excel(name = "是否启用")
|
|
||||||
private String isinuse;
|
private String isinuse;
|
||||||
|
|
||||||
|
/** 备注 */
|
||||||
|
@Excel(name = "备注")
|
||||||
|
private String remark;
|
||||||
|
|
||||||
/** 创建时间 */
|
/** 创建时间 */
|
||||||
@JsonFormat(pattern = "yyyy-MM-dd")
|
@JsonFormat(pattern = "yyyy-MM-dd")
|
||||||
@Excel(name = "创建时间", width = 30, dateFormat = "yyyy-MM-dd")
|
|
||||||
private Date crtdt;
|
private Date crtdt;
|
||||||
|
|
||||||
/** 创建人 */
|
/** 创建人 */
|
||||||
@Excel(name = "创建人")
|
|
||||||
private String crtopr;
|
private String crtopr;
|
||||||
|
|
||||||
/** 最后修改日期 */
|
/** 最后修改日期 */
|
||||||
@JsonFormat(pattern = "yyyy-MM-dd")
|
@JsonFormat(pattern = "yyyy-MM-dd")
|
||||||
@Excel(name = "最后修改日期", width = 30, dateFormat = "yyyy-MM-dd")
|
|
||||||
private Date lstedtdt;
|
private Date lstedtdt;
|
||||||
|
|
||||||
/** 最后修改人 */
|
/** 最后修改人 */
|
||||||
@Excel(name = "最后修改人")
|
|
||||||
private String lstedtopr;
|
private String lstedtopr;
|
||||||
|
|
||||||
public void setId(String id)
|
public void setId(String id)
|
||||||
|
|
@ -192,6 +189,16 @@ public class Pounddata extends BaseEntity
|
||||||
return lstedtopr;
|
return lstedtopr;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getRemark() {
|
||||||
|
return remark;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void setRemark(String remark) {
|
||||||
|
this.remark = remark;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String toString() {
|
public String toString() {
|
||||||
return new ToStringBuilder(this,ToStringStyle.MULTI_LINE_STYLE)
|
return new ToStringBuilder(this,ToStringStyle.MULTI_LINE_STYLE)
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,60 @@
|
||||||
|
package com.ruoyi.util;
|
||||||
|
|
||||||
|
import com.ruoyi.common.core.domain.entity.SysDictData;
|
||||||
|
import com.ruoyi.common.utils.DictUtils;
|
||||||
|
import com.ruoyi.common.utils.StringUtils;
|
||||||
|
import com.ruoyi.system.service.ISysDictTypeService;
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.stereotype.Component;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
@Component
|
||||||
|
public class Util {
|
||||||
|
@Autowired
|
||||||
|
private ISysDictTypeService dictTypeService;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 根据字典类型获取字典所有标签
|
||||||
|
* @param dictType
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
public static String getDictLabel(String dictType){
|
||||||
|
List<SysDictData> bom_wfzbase = DictUtils.getDictCache(dictType);
|
||||||
|
String strings = "";
|
||||||
|
for (int i = 0; i < bom_wfzbase.size(); i++) {
|
||||||
|
String dictLabel = bom_wfzbase.get(i).getDictLabel();
|
||||||
|
strings += ","+dictLabel;
|
||||||
|
}
|
||||||
|
return strings;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 根据字典键值和类型获取字典备注
|
||||||
|
* @param dictType
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
public String getDictRemark(String dictValue,String dictType){
|
||||||
|
List<SysDictData> bom_wfzbase1 = dictTypeService.selectDictDataByType(dictType);
|
||||||
|
for (int i = 0; i < bom_wfzbase1.size(); i++) {
|
||||||
|
SysDictData sysDictData = bom_wfzbase1.get(i);
|
||||||
|
if(dictValue.equals(sysDictData.getDictValue())){
|
||||||
|
return sysDictData.getRemark();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return "虚拟基地";
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 根据字典类型和字典标签获取对应键值
|
||||||
|
* @param dictType
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
public static String getDictValue(String dictType,String label){
|
||||||
|
if(StringUtils.isBlank(label)){
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
String dictValue = DictUtils.getDictValue(dictType, label);
|
||||||
|
return dictValue;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,115 @@
|
||||||
|
package com.ruoyi.util;
|
||||||
|
|
||||||
|
import com.ruoyi.basedata.domain.Pounddata;
|
||||||
|
import com.ruoyi.basedata.service.IPounddataService;
|
||||||
|
import com.ruoyi.common.utils.SecurityUtils;
|
||||||
|
import com.ruoyi.common.utils.StringUtils;
|
||||||
|
import com.ruoyi.common.utils.bean.BeanValidators;
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.web.bind.annotation.RestController;
|
||||||
|
|
||||||
|
import java.util.Date;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
@RestController
|
||||||
|
public class importRunnable implements Runnable{
|
||||||
|
@Autowired
|
||||||
|
private IPounddataService pounddataService;
|
||||||
|
|
||||||
|
private List<Pounddata> pounddataList;
|
||||||
|
|
||||||
|
private String operName;
|
||||||
|
|
||||||
|
public List<Pounddata> getPounddataList() {
|
||||||
|
return pounddataList;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setPounddataList(List<Pounddata> pounddataList) {
|
||||||
|
this.pounddataList = pounddataList;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getOperName() {
|
||||||
|
return operName;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setOperName(String operName) {
|
||||||
|
this.operName = operName;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void removeParam(){
|
||||||
|
this.pounddataList = null;
|
||||||
|
this.operName = null;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void run() {
|
||||||
|
importData();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void importData(){
|
||||||
|
if(this.pounddataList!=null){
|
||||||
|
List<Pounddata> importList = this.pounddataList;
|
||||||
|
for (int i = 0; i < importList.size(); i++) {
|
||||||
|
Pounddata data = importList.get(i);
|
||||||
|
try
|
||||||
|
{
|
||||||
|
// 验证是否存在这个用户
|
||||||
|
Pounddata pounddata = new Pounddata();
|
||||||
|
System.out.println( 1);
|
||||||
|
String usrcode = data.getUsrcode();
|
||||||
|
String type = Util.getDictValue("measurement_data_type", data.getType());
|
||||||
|
if (StringUtils.isBlank(usrcode)) {
|
||||||
|
Pounddata pounddata2 = new Pounddata();
|
||||||
|
pounddata2.setRemark("第"+(i+1)+"条编码为空");
|
||||||
|
pounddata2.setUsrcode(data.getUsrcode()+"+"+data.getType()+":导入失败");
|
||||||
|
pounddata2.setName(data.getName());
|
||||||
|
pounddata2.setCrtopr(operName);
|
||||||
|
pounddata2.setLstedtopr(operName);
|
||||||
|
pounddata2.setCrtdt(new Date());
|
||||||
|
pounddata2.setLstedtdt(new Date());
|
||||||
|
pounddataService.insertPounddata(pounddata2);
|
||||||
|
continue;
|
||||||
|
}else if(StringUtils.isBlank(type)){
|
||||||
|
Pounddata pounddata2 = new Pounddata();
|
||||||
|
pounddata2.setRemark("第"+(i+1)+"条资料类型为空或资料类型在系统内不存在");
|
||||||
|
pounddata2.setUsrcode(data.getUsrcode()+"+"+data.getType()+":导入失败");
|
||||||
|
pounddata2.setName(data.getName());
|
||||||
|
pounddata2.setCrtopr(operName);
|
||||||
|
pounddata2.setLstedtopr(operName);
|
||||||
|
pounddata2.setCrtdt(new Date());
|
||||||
|
pounddata2.setLstedtdt(new Date());
|
||||||
|
pounddataService.insertPounddata(pounddata2);
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
pounddata.setUsrcode(usrcode);
|
||||||
|
pounddata.setType(type);
|
||||||
|
List<Pounddata> pounddata1 = pounddataService.selectPounddataList(pounddata);
|
||||||
|
if (pounddata1==null||pounddata1.size()==0)
|
||||||
|
{
|
||||||
|
data.setType(type);
|
||||||
|
data.setCrtopr(operName);
|
||||||
|
data.setLstedtopr(operName);
|
||||||
|
data.setCrtdt(new Date());
|
||||||
|
data.setLstedtdt(new Date());
|
||||||
|
pounddataService.insertPounddata(data);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
Pounddata pounddata2 = new Pounddata();
|
||||||
|
pounddata2.setRemark("已存在编码+资料类型为:"+data.getUsrcode()+data.getType()+"的数据");
|
||||||
|
pounddata2.setUsrcode(data.getUsrcode()+"+"+data.getType()+":导入失败");
|
||||||
|
pounddata2.setName(data.getName());
|
||||||
|
pounddata2.setCrtopr(operName);
|
||||||
|
pounddata2.setLstedtopr(operName);
|
||||||
|
pounddata2.setCrtdt(new Date());
|
||||||
|
pounddata2.setLstedtdt(new Date());
|
||||||
|
pounddataService.insertPounddata(pounddata2);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
catch (Exception e)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -33,6 +33,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||||
<if test="poundid != null "> and poundid = #{poundid}</if>
|
<if test="poundid != null "> and poundid = #{poundid}</if>
|
||||||
<if test="helpcode != null and helpcode != ''"> and helpcode like concat('%', #{helpcode}, '%')</if>
|
<if test="helpcode != null and helpcode != ''"> and helpcode like concat('%', #{helpcode}, '%')</if>
|
||||||
</where>
|
</where>
|
||||||
|
order by crtdt desc
|
||||||
</select>
|
</select>
|
||||||
|
|
||||||
<select id="selectPounddataById" parameterType="String" resultMap="PounddataResult">
|
<select id="selectPounddataById" parameterType="String" resultMap="PounddataResult">
|
||||||
|
|
|
||||||
|
|
@ -53,25 +53,20 @@ public class BaseEntity implements Serializable
|
||||||
private Map<String, Object> params;
|
private Map<String, Object> params;
|
||||||
|
|
||||||
/** 是否启用 */
|
/** 是否启用 */
|
||||||
@Excel(name = "是否启用")
|
|
||||||
private String isinuse;
|
private String isinuse;
|
||||||
|
|
||||||
/** 创建时间 */
|
/** 创建时间 */
|
||||||
@JsonFormat(pattern = "yyyy-MM-dd")
|
@JsonFormat(pattern = "yyyy-MM-dd")
|
||||||
@Excel(name = "创建时间", width = 30, dateFormat = "yyyy-MM-dd")
|
|
||||||
private Date crtdt;
|
private Date crtdt;
|
||||||
|
|
||||||
/** 创建人 */
|
/** 创建人 */
|
||||||
@Excel(name = "创建人")
|
|
||||||
private String crtopr;
|
private String crtopr;
|
||||||
|
|
||||||
/** 最后修改日期 */
|
/** 最后修改日期 */
|
||||||
@JsonFormat(pattern = "yyyy-MM-dd")
|
@JsonFormat(pattern = "yyyy-MM-dd")
|
||||||
@Excel(name = "最后修改日期", width = 30, dateFormat = "yyyy-MM-dd")
|
|
||||||
private Date lstedtdt;
|
private Date lstedtdt;
|
||||||
|
|
||||||
/** 最后修改人 */
|
/** 最后修改人 */
|
||||||
@Excel(name = "最后修改人")
|
|
||||||
private String lstedtopr;
|
private String lstedtopr;
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -92,6 +92,10 @@
|
||||||
v-hasPermi="['measurement/basedata:pounddata:export']"
|
v-hasPermi="['measurement/basedata:pounddata:export']"
|
||||||
>导出</el-button>
|
>导出</el-button>
|
||||||
</el-col>
|
</el-col>
|
||||||
|
<el-col :span="1.5">
|
||||||
|
<el-button type="warning" plain size="mini" @click="importExcelsettlementrateentry">导入数据
|
||||||
|
</el-button>
|
||||||
|
</el-col>
|
||||||
<right-toolbar :showSearch.sync="showSearch" @queryTable="getList"></right-toolbar>
|
<right-toolbar :showSearch.sync="showSearch" @queryTable="getList"></right-toolbar>
|
||||||
</el-row>
|
</el-row>
|
||||||
|
|
||||||
|
|
@ -188,11 +192,31 @@
|
||||||
<el-button @click="cancel">取 消</el-button>
|
<el-button @click="cancel">取 消</el-button>
|
||||||
</div>
|
</div>
|
||||||
</el-dialog>
|
</el-dialog>
|
||||||
|
|
||||||
|
<!-- 用户导入对话框 -->
|
||||||
|
<el-dialog :title="upload.title" :visible.sync="upload.open" width="400px" append-to-body>
|
||||||
|
<el-upload ref="upload" :limit="1" accept=".xlsx, .xls" :headers="upload.headers" :action="upload.url + '?updateSupport=' + upload.updateSupport" :disabled="upload.isUploading" :on-progress="handleFileUploadProgress" :on-success="handleFileSuccess" :auto-upload="false" drag>
|
||||||
|
<i class="el-icon-upload"></i>
|
||||||
|
<div class="el-upload__text">将文件拖到此处,或<em>点击上传</em></div>
|
||||||
|
<div class="el-upload__tip text-center" slot="tip">
|
||||||
|
<div class="el-upload__tip" slot="tip">
|
||||||
|
<el-checkbox v-model="upload.updateSupport" />是否更新已经存在的用户数据
|
||||||
|
</div>
|
||||||
|
<span>仅允许导入xls、xlsx格式文件。</span>
|
||||||
|
<el-link type="primary" :underline="false" style="font-size: 12px; vertical-align: baseline" @click="importTemplate">下载模板</el-link>
|
||||||
|
</div>
|
||||||
|
</el-upload>
|
||||||
|
<div slot="footer" class="dialog-footer">
|
||||||
|
<el-button type="primary" @click="submitFileForm">确 定</el-button>
|
||||||
|
<el-button @click="upload.open = false">取 消</el-button>
|
||||||
|
</div>
|
||||||
|
</el-dialog>
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
import { listPounddata, getPounddata, delPounddata, addPounddata, updatePounddata } from "@/api/measurement/basedata/pounddata"
|
import { listPounddata, getPounddata, delPounddata, addPounddata, updatePounddata } from "@/api/measurement/basedata/pounddata"
|
||||||
|
import {getToken} from "@/utils/auth";
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
name: "Pounddata",
|
name: "Pounddata",
|
||||||
|
|
@ -217,6 +241,21 @@ export default {
|
||||||
title: "",
|
title: "",
|
||||||
// 是否显示弹出层
|
// 是否显示弹出层
|
||||||
open: false,
|
open: false,
|
||||||
|
//excel导入模板参数
|
||||||
|
upload: {
|
||||||
|
// 是否显示弹出层(用户导入)
|
||||||
|
open: false,
|
||||||
|
// 弹出层标题(用户导入)
|
||||||
|
title: "",
|
||||||
|
// 是否禁用上传
|
||||||
|
isUploading: false,
|
||||||
|
// 是否更新已经存在的用户数据
|
||||||
|
updateSupport: 0,
|
||||||
|
// 设置上传的请求头部
|
||||||
|
headers: { Authorization: "Bearer " + getToken() },
|
||||||
|
// 上传的地址
|
||||||
|
url: process.env.VUE_APP_BASE_API + "/measurement/basedata/pounddata/importData"
|
||||||
|
},
|
||||||
// 查询参数
|
// 查询参数
|
||||||
queryParams: {
|
queryParams: {
|
||||||
pageNum: 1,
|
pageNum: 1,
|
||||||
|
|
@ -347,6 +386,31 @@ export default {
|
||||||
this.download('measurement/basedata/pounddata/export', {
|
this.download('measurement/basedata/pounddata/export', {
|
||||||
...this.queryParams
|
...this.queryParams
|
||||||
}, `pounddata_${new Date().getTime()}.xlsx`)
|
}, `pounddata_${new Date().getTime()}.xlsx`)
|
||||||
|
},
|
||||||
|
//下载分录模板
|
||||||
|
importTemplate() {
|
||||||
|
this.download('measurement/basedata/pounddata/importTemplate', {}, `导入模板_${new Date().getTime()}.xlsx`)
|
||||||
|
},
|
||||||
|
// 点击进行导入
|
||||||
|
importExcelsettlementrateentry() {
|
||||||
|
this.upload.title = "导入数据"
|
||||||
|
this.upload.open = true
|
||||||
|
},
|
||||||
|
// 文件上传中处理
|
||||||
|
handleFileUploadProgress(event, file, fileList) {
|
||||||
|
this.upload.isUploading = true
|
||||||
|
},
|
||||||
|
// 文件上传成功处理
|
||||||
|
handleFileSuccess(response, file, fileList) {
|
||||||
|
this.upload.open = false
|
||||||
|
this.upload.isUploading = false
|
||||||
|
this.$refs.upload.clearFiles()
|
||||||
|
this.$alert("<div style='overflow: auto;overflow-x: hidden;max-height: 70vh;padding: 10px 20px 0;'>" + response.msg + "</div>", "导入结果", { dangerouslyUseHTMLString: true })
|
||||||
|
this.getList()
|
||||||
|
},
|
||||||
|
// 提交上传文件
|
||||||
|
submitFileForm() {
|
||||||
|
this.$refs.upload.submit()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue