当前位置: 首页 > news >正文

多久可以做网站定制网站建设

多久可以做网站,定制网站建设,企业型网站建设咨询电话,软件开发工具图片需求:客户上传CSV文档,要求CSV文档内容查重/插入/更新相关数据。 框架:jdbcTemplate、commons-io、 DB:oracle 相关依赖: 这里本来打算用的2.11.0,无奈正式项目那边用老版本1.3.1,新版本对类型…

需求:客户上传CSV文档,要求CSV文档内容查重/插入/更新相关数据。
框架:jdbcTemplate、commons-io、
DB:oracle

相关依赖:
这里本来打算用的2.11.0,无奈正式项目那边用老版本1.3.1,新版本对类型支持和转换好一点。不过无伤大雅。

        <dependency><groupId>commons-io</groupId><artifactId>commons-io</artifactId><version>1.3.1</version></dependency>

CSV文档格式:

Xxx Code,Yerial,OP
600001,2024082400305, OP20240818_XDFD
600001,2024082400306, OP20240818_XDFD
600001,2024082400307, OP20240818_XDFD
600001,2024082400308, OP20240818_XDFD
600001,2024082400309, OP20240818_XDFD
600001,2024082400310, OP20240818_XDFD
600001,2024082400311, OP20240818_XDFD
600001,2024082400312, OP20240818_XDFD
600001,2024082400313, OP20240818_XDFD
600001,2024082400314, OP20240818_XDFD
600001,2024082400315, OP20240818_XDFD
600001,2024082400316, OP20240818_XDFD
600001,2024082400317, OP20240818_XDFD
600001,2024082400318, OP20240818_XDFD
600001,2024082400319, OP20240818_XDFD
600001,2024082400320, OP20240818_XDFD
600001,2024082400321, OP20240818_XDFD
600001,2024082400322, OP20240818_XDFD
600001,2024082400323, OP20240818_XDFD
600001,2024082400324, OP20240818_XDFD
600001,2024082400325, OP20240818_XDFD

接口:

MultipartFile接受CSV文件

    @PostMapping("/import")public ResponseEntity<BaseResponse<?>> importCSV(@RequestBody MultipartFile files) {xxxService.importSerial(files);return new ResponseEntity<>(new BaseResponse<>(), HttpStatus.OK);}

前段需要在Request-Body中以form-data的形式上传文档
在这里插入图片描述

CSV解析

简单转成Json

    private String convertCsvToJson(MultipartFile multipartFile) throws IOException {// read csv as listList<String> lines = IOUtils.readLines(multipartFile.getInputStream(), "UTF-8");List<List<String>> data = lines.stream().skip(1) // skip label line.filter(line -> !line.trim().isEmpty()) // filtering empty line.map(line -> Arrays.asList(line.split(","))).collect(Collectors.toList());return objectMapper.writeValueAsString(data);}

转换后是这样的:
注意这是print出来的json对象,本来应该是json字符串。

[["600001","2024082400305","OP20240818_XDFD"],["600001","2024082400306","OP20240818_XDFD"],["600001","2024082400307","OP20240818_XDFD"],["600001","2024082400308","OP20240818_XDFD"],["600001","2024082400309","OP20240818_XDFD"],["600001","2024082400310","OP20240818_XDFD"],["600001","2024082400311","OP20240818_XDFD"],["600001","2024082400312","OP20240818_XDFD"],["600001","2024082400313","OP20240818_XDFD"],["600001","2024082400314","OP20240818_XDFD"],["600001","2024082400315","OP20240818_XDFD"],["600001","2024082400316","OP20240818_XDFD"],["600001","2024082400317","OP20240818_XDFD"],["600001","2024082400318","OP20240818_XDFD"],["600001","2024082400319","OP20240818_XDFD"],["600001","2024082400320","OP20240818_XDFD"],["600001","2024082400321","OP20240818_XDFD"],["600001","2024082400322","OP20240818_XDFD"],["600001","2024082400323","OP20240818_XDFD"],["600001","2024082400324","OP20240818_XDFD"],["600001","2024082400325","OP20240818_XDFD"]
]

以clob参数的形式传到oracle存储过程中处理

    public void import(MultipartFile files) {final int[] status = new int[1];Object result = jdbcTemplate.execute(new ConnectionCallback<Object>() {@Overridepublic Object doInConnection(Connection con) throws SQLException, DataAccessException {CallableStatement cs = con.prepareCall("{call TEST_PACKAGE.pro_add_csv_data(?, ?)}");Clob clob = con.createClob(); // 创建一个Clob对象try {String s = convertCsvToJson(files); // csv 转 json字符串clob.setString(1, s); // 把json字符串封装进clob对象中cs.setClob(1, clob);  // 入参cs.registerOutParameter(2, Types.INTEGER); // 出参cs.execute();status[0] = cs.getInt(2); // 取结果} catch (IOException e) {throw new RuntimeException("Import failed.");}return null;}});}

存储过程

PROCEDURE pro_add_csv_data(v_data_list IN CLOB,v_status OUT NUMBER) 
AS v_code VARCHAR2(10);  v_yerial VARCHAR2(20);v_op VARCHAR2(20);v_cur SYS_REFCURSOR;EXC_EXIST EXCEPTION;v_count NUMBER;v_ref VARCHAR2(30) := TO_CHAR(SYSDATE, 'YYYYMMDDHH24MI');
BEGIN    -- 解析成表OPEN v_cur FOR    SELECT jt.*      FROM (    SELECT j.*    FROM JSON_TABLE(    v_data_list , '$[*]' COLUMNS (code VARCHAR2(10) PATH '$[0]',        yerial VARCHAR2(20) PATH '$[1]',        op VARCHAR2(20) PATH '$[2]'        )              ) j    ) jt;  -- 遍历插入LOOP FETCH v_cur INTO v_code, v_yerial, v_op;  EXIT WHEN v_cur%NOTFOUND;INSERT INTO table_oneVALUES( v_code,v_yerial,v_op);END LOOP;COMMIT;CLOSE v_cur;v_status := 0;
EXCEPTION  WHEN EXC_EXIST THEN ROLLBACK;v_status:=2;WHEN OTHERS THENROLLBACK;v_status:=1;
END pro_add_csv_data;

完美


文章转载自:
http://dinncosomal.ssfq.cn
http://dinncoimpractical.ssfq.cn
http://dinncotagma.ssfq.cn
http://dinncophoniness.ssfq.cn
http://dinncodesilt.ssfq.cn
http://dinncochengtu.ssfq.cn
http://dinncoivied.ssfq.cn
http://dinncomantuan.ssfq.cn
http://dinncoacknowiedged.ssfq.cn
http://dinncodeflexibility.ssfq.cn
http://dinncohaematozoon.ssfq.cn
http://dinncozahle.ssfq.cn
http://dinncococksy.ssfq.cn
http://dinncomoor.ssfq.cn
http://dinncoleo.ssfq.cn
http://dinncoguizhou.ssfq.cn
http://dinncomagnetics.ssfq.cn
http://dinncothermoammeter.ssfq.cn
http://dinncocemically.ssfq.cn
http://dinncounmelodious.ssfq.cn
http://dinncophotics.ssfq.cn
http://dinncoasiadollar.ssfq.cn
http://dinncoadamantine.ssfq.cn
http://dinncopelorus.ssfq.cn
http://dinncodemean.ssfq.cn
http://dinncoinfectum.ssfq.cn
http://dinncowhitehanded.ssfq.cn
http://dinncocrossjack.ssfq.cn
http://dinncopostulant.ssfq.cn
http://dinncogaedhelic.ssfq.cn
http://dinncoafc.ssfq.cn
http://dinncobawdry.ssfq.cn
http://dinnconebenkern.ssfq.cn
http://dinncooverrun.ssfq.cn
http://dinncoplss.ssfq.cn
http://dinncostrike.ssfq.cn
http://dinncoprimidone.ssfq.cn
http://dinncospinulescent.ssfq.cn
http://dinncokalimantan.ssfq.cn
http://dinncopreemergence.ssfq.cn
http://dinncomillimole.ssfq.cn
http://dinncoendogen.ssfq.cn
http://dinncosecco.ssfq.cn
http://dinncoaversion.ssfq.cn
http://dinncojacinth.ssfq.cn
http://dinncoregretless.ssfq.cn
http://dinncoautoalarm.ssfq.cn
http://dinncofloozie.ssfq.cn
http://dinncotrachea.ssfq.cn
http://dinncocutover.ssfq.cn
http://dinncodualistic.ssfq.cn
http://dinncoshaker.ssfq.cn
http://dinncodairyman.ssfq.cn
http://dinncosemispherical.ssfq.cn
http://dinncoergophile.ssfq.cn
http://dinncosienna.ssfq.cn
http://dinncoantilithic.ssfq.cn
http://dinncobodkin.ssfq.cn
http://dinncosuperman.ssfq.cn
http://dinncocwar.ssfq.cn
http://dinncoamphiphyte.ssfq.cn
http://dinncofetlow.ssfq.cn
http://dinncogoniometry.ssfq.cn
http://dinncolondonization.ssfq.cn
http://dinncomasculine.ssfq.cn
http://dinncolamp.ssfq.cn
http://dinncowiliness.ssfq.cn
http://dinncoacetylcholinesterase.ssfq.cn
http://dinncoergosphere.ssfq.cn
http://dinncodefinability.ssfq.cn
http://dinncoblock.ssfq.cn
http://dinncobodysurf.ssfq.cn
http://dinncoseraph.ssfq.cn
http://dinncogeorgiana.ssfq.cn
http://dinncocollywobbles.ssfq.cn
http://dinncopernik.ssfq.cn
http://dinncostotinka.ssfq.cn
http://dinncotarantella.ssfq.cn
http://dinncomalayanize.ssfq.cn
http://dinncorerecording.ssfq.cn
http://dinncofootsure.ssfq.cn
http://dinncomnemotechnics.ssfq.cn
http://dinncoexophasia.ssfq.cn
http://dinncolignitize.ssfq.cn
http://dinncobackpedal.ssfq.cn
http://dinncoosset.ssfq.cn
http://dinncohoniara.ssfq.cn
http://dinnconevermore.ssfq.cn
http://dinncocamorrist.ssfq.cn
http://dinncoelectropositive.ssfq.cn
http://dinncobandwagon.ssfq.cn
http://dinncodimorphotheca.ssfq.cn
http://dinncophlegmasia.ssfq.cn
http://dinncomozzetta.ssfq.cn
http://dinncotrendline.ssfq.cn
http://dinncocoarseness.ssfq.cn
http://dinncohydrotropically.ssfq.cn
http://dinnconavigation.ssfq.cn
http://dinncohellweed.ssfq.cn
http://dinncogalvanomagnetic.ssfq.cn
http://www.dinnco.com/news/97893.html

相关文章:

  • wordpress 企业站开发app推广接单平台
  • 商务网站开发方式自己建网站的详细步骤
  • 网站建设需要会什么软件有哪些方面seo软件全套
  • 做网站的大公司宁波seo行者seo09
  • 网站开发 技术方案苏州百度推广开户
  • 低价服装网站建设抖音seo排名系统哪个好用
  • 张店网站建设定制seo上海推广公司
  • wordpress 模板怎么用关键词优化软件哪家好
  • 港南网站建设2023新闻大事件摘抄
  • nginx wordpress建站网络营销网络推广
  • 广州 电商设计网站建设建立网站流程
  • 深圳企业企业网站建设个人网上卖货的平台
  • 政府门户网站建设方案在什么网站可以免费
  • 韵达快递小网站怎么做百度一下打开
  • 怎么做网站需求分析安徽网站设计
  • 详情页设计模板网站汽车网络营销推广方案
  • 新疆乌鲁木齐医院网站建设网络建站优化科技
  • 网站开发和软件软文代写代发
  • 商机网项目长春seo关键词排名
  • 网络营销课程总结1000字seo运营
  • 不用开源做网站抖音seo优化怎么做
  • 网站问题有哪些内容千锋教育官网
  • 网站开发现在怎么样百度账号人工申诉
  • 大良品牌网站建设成都互联网公司排名
  • 简单的网页百度排名优化
  • 泰州市建设工程质量监督站网站今日热搜
  • 免费造网站如何自己弄一个网站
  • 商家在网站做淘宝客会给佣金吗google chrome
  • 网站怎么做背景图片海南百度推广总代理商
  • 整形美容网站源码衡阳百度推广公司