读取 excel文件组装字典数据
package com.murong.ecp.app.mbu.action.bmbuurm8;
import java.io.FileOutputStream;
import java.io.OutputStream;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.HashSet;
import java.util.List;
import java.util.Map;
import java.util.Set;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.murong.ecp.app.mbu.common.BuiMessageCode;
import com.murong.ecp.app.mbu.dao.bmbuurm8.XyHealthDictMapper;
import com.murong.ecp.app.pub.atc.PUBATCUtil;
import com.yuangou.ecp.biz.transengine.AbstractTransaction;
import com.yuangou.ecp.biz.transengine.Utils;
import com.yuangou.ecp.bp.core.common.exception.YGException;
import com.yuangou.ecp.bp.core.common.message.YGBizMessage;
import com.yuangou.ecp.bp.core.common.message.YGBizMessageContext;
import com.yuangou.ecp.bp.core.common.message.YGEDB;
import com.yuangou.ecp.bp.core.common.yglog4j.Logger;
import com.yuangou.ecp.bp.core.common.yglog4j.YGLogger;
@Service("healthdictexport")
public class XyHealthDictExportAction extends AbstractTransaction{
@Autowired
XyHealthDictMapper xyHealthDictMapper;
@Override
public void doProcess(YGBizMessageContext bizCtx) throws YGException {
YGBizMessage yGBizMessage = bizCtx.getCurrentMsg();
Logger logger = YGLogger.getLogger(yGBizMessage);
YGEDB edb = yGBizMessage.getEDBBody();
edb.setData("rsp_ajx", "true");
PUBATCUtil.GDASetMsg(bizCtx, BuiMessageCode.SUCCESS, "");
logger.info("导出医疗字典到js文件start");
logger.info("开启游标:");
PUBATCUtil.openCursor(bizCtx, "qryHealthDictList", "healthDictListCursor");
logger.info("开启游标:");
List<String> typList = new ArrayList<>();
//将数据拼接成字符串
StringBuffer stringBuffer=new StringBuffer("var mrdict = new Object();");
int i=0;
while (true) {
PUBATCUtil.fetchCursor(bizCtx, "healthDictListCursor", "healthDictListCursor"+i);
if (Utils.eval(bizCtx, "~retcod=2")) {
logger.info("关闭游标:11");
PUBATCUtil.closeCursor(bizCtx, "healthDictListCursor");
logger.info("关闭游标:12");
break;
}else{
String idStr = edb.getData("healthDictListCursor"+i+".id");
String textStr = edb.getData("healthDictListCursor"+i+".text");
String typStr = edb.getData("healthDictListCursor"+i+".typ");
//直接拼接
logger.info("i======================================="+i);
if (typList.contains(typStr)) {
stringBuffer.append(",").append("\""+idStr+"\":\""+textStr+"\"");
}else {
//先将typName放入Set,再拼接
typList.add(typStr);
//非首次进入判断才追加"}"
if (i != 0) {
stringBuffer.append("};");
}
stringBuffer.append("\n").append("mrdict.").append(typStr).append("={\""+idStr+"\":\""+textStr+"\"");
}
i++;
}
}
logger.info("游标执行总数="+i);
logger.info("关闭游标:21");
PUBATCUtil.closeCursor(bizCtx, "healthDictListCursor");
logger.info("关闭游标:22");
String line = "\r\n";
String t ="\t";
String fn = "Formatter = function(val,row) {"+line+t+
"var data = mrdict.";
String fn1 = line+t+"try { "+line+t+
"if( !data.hasOwnProperty(val) ) {"+line+t+
"return val;"+line+t+
"}"+line+t+
" } catch(error) {"+line+t+
"console.error(error);"+line+t+
"return val;"+line+t+
" }"+line+t+
"return data[val];"+line+
"}";
stringBuffer.append("};");
for (int j = 0; j < typList.size(); j++) {
stringBuffer.append("\n").append("mrdict.").append(typList.get(j)).append(fn).append(typList.get(j)+";").append(fn1);
}
//上传到服务器的位置
String path = "/home/iver/ejbs/mrbui/healthDict.js";
try {
OutputStream output = new FileOutputStream(path);
byte[] date=stringBuffer.toString().getBytes();
output.write(date);
output.close();
logger.info(">>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>");
} catch (Exception e) {
logger.info("医疗字典导出js文件异常");
logger.info(e);
}
PUBATCUtil.GDASetMsg(bizCtx, "CMM00000", "");
logger.info("导出医疗字典到js文件over");
}
}
读取 excel文件组装字典数据的更多相关文章
- 用python的pandas读取excel文件中的数据
一.读取Excel文件 使用pandas的read_excel()方法,可通过文件路径直接读取.注意到,在一个excel文件中有多个sheet,因此,对excel文件的读取实际上是读取指定文件.并 ...
- .Net读取Excel文件时丢失数据的问题 (转载)
相信很多人都试过通过OleDB读取Excel文件,这种方法效率十分高,只是有一点会让人十分头痛,就是当一列中既有混合型数据,又有纯数据时,往往容易丢失数据. 百度过后,改连接字符串 “HDR=YES; ...
- matlab读取excel文件中的数据
1.读取sheet1中的所有数据 1.1首先我们建立一个sheet表,表名为‘111’ 1.2 默认这些文本以及数字都放在sheet1中,我们将此excel选入当前工作目录(必要步骤), 选入当前工作 ...
- gridview读取Excel文件中的数据,并将其导入数据库
原文发布时间为:2008-10-16 -- 来源于本人的百度文章 [由搬家工具导入] //将需要导入的文件上传到服务器 string filePath = "" ...
- java 读取Excel文件并数据持久化方法Demo
import java.io.IOException; import java.io.InputStream; import java.util.ArrayList; import java.util ...
- spring boot 使用 POI 读取Excel文件
内容简介 本文主要介绍使用POI进行Excel文件的相关操作,涉及读取文件,获取sheet表格,对单元格内容进行读写操作,以及合并单元格的操作. Excel文件目录 Excel模板文件存了resour ...
- 如何在C#中打开和读取EXCEL文件
这篇文章向您展示如何在C#Windows Forms Application中使用ExcelDataReader,ExcelDataReader.DataSet打开和读取Excel文件.创建一个新的W ...
- 上传读取Excel文件数据
/// <summary> /// 上传读取Excel文件数据 /// 来自http://www.cnblogs.com/cielwater /// </summary> // ...
- python xlwt模块生成excel文件并写入数据 xlrd读取数据
python中一般使用 xlwt (excel write)来生成Excel文件(可以控制单元格格式),用 xlrd 来读取Excel文件,用xlrd读取excel是不能对其进行操作的. 1.xlrd ...
随机推荐
- CentOS 7防火墙的关闭与开启
(1)CentOS 7.0默认使用的是firewall作为防火墙:若没有启用iptables 作为防火墙,则使用以下方式关闭防火墙: systemctl stop firewalld.service ...
- Linux下的MediaWiki的部署启动遇到的问题与解决方案
1. MySQL安装不成功 解决方案:https://bbs.csdn.net/topics/394377536 2. no space left on device ubuntu 解决方案:http ...
- CentOS下搭建简易iSCSI服务
iscsi 服务器端设置 安装target包 yum install scsi-target-utils.x86_64 创建测试裸磁盘 dd if=/dev/zero of=/iSCSIdisk/20 ...
- MySQL 当前时间,今日时间,前日时间 详解
MySQL 获取当前日期及日期格式 获取系统日期: NOW() 格式化日期: DATE_FORMAT(date, format) 注: date:时间字段 format:日期格式 返回系统日期,输出 ...
- 一万字详解 Redis Cluster Gossip 协议
Redis Cluster Gossip 协议 大家好,我是历小冰,今天来讲一下 Reids Cluster 的 Gossip 协议和集群操作,文章的思维导图如下所示. 集群模式和 Gossip 简介 ...
- JZOJ 11.21 提高B组反思
JZOJ 11.21 提高B组反思 T1 第二类斯特林数 直接套公式 \(S(i,j)=S(i-1,j-1)+S(i-1,j)*j\) 由于过大,\(unsigned\ long\ long\)都存不 ...
- Spring Boot + RabbitMQ 使用示例
基础知识 虚拟主机 (Virtual Host): 每个 virtual host 拥有自己的 exchanges, queues 等 (类似 MySQL 中的库) 交换器 (Exchange): 生 ...
- PHP中双引号引起的命令执行漏洞(Kuwebs代码审计 )
在代码审计一书中提到Kuwebs的配置文件中可以利用PHP可变变量的特性执行代码 在PHP语言中,单引号和双引号都可以表示一个字符串,但是对于双引号来说,可能会对引号内的内容进行二次解释,这就可能会出 ...
- 利用promise实现间隔1s打印1,2,3
利用promise结合数组的rduce方法 let arr = [1, 2, 3]; arr.reduce((pre, cur) => { return pre.then(() => { ...
- Codeforces Edu Round 54 A-E
A. Minimizing the String 很明显,贪心之比较从前往后第一个不一样的字符,所以可以从前往后考虑每一位,如果把它删除,他这一位就变成\(str[i + 1]\),所以只要\(str ...