- 博客(22)
- 收藏
- 关注
原创 int类型相除保留两位小数
方法一: double rate = new BigDecimal(((double) count / all) * 100).setScale(1, BigDecimal.ROUND_DOWN).doubleValue();方法二: // 创建一个数值格式化对象 NumberFormat numberFormat = NumberFormat.getInstance(); // 设置精确到小数点后2位
2022-04-27 11:29:37 2084
原创 SpringCloud(6)---熔断降级理解、Hystrix实战
https://www.cnblogs.com/qdhxhz/p/9581440.html
2021-10-26 17:55:49 93
原创 数据库根据业务分表取模
String contractNo = "VSP-20211021144142";int num= HashModel.getHashNmu(contractNo, 32);String tableName = "contract_commodity_"+num;// 得到 "contract_commodity_0~31` 中的某一个表public class HashModel { /** * hash 取模 */ public static int ge
2021-10-25 11:06:49 229
原创 给图片添加围栏
/** * 根据图片路径获取图片流+ 围栏渲染 动态设置图片大小,并以图片流的方式返回 * @param response * @param filePath 文件路径 eg: E:\\datacenter\\zhqb_electronicfence\\zhqb_electronicfence\\106051260944084055\\wpy-001\\2\\20210413202127.jpg * @param fenceArea 围栏坐标 [{"x":308.609375,"y":111
2021-04-15 20:59:48 171
原创 文件以流的方式返回,图片流返回
文件以流的方式返回 /** * 根据图片路径获取文件流 * * @param response 返回值 * @param path 图片路径 * @throws ServletException * @throws IOException */ @ApiOperation("根据图片路径获取文件流") @GetMapping("/getPresentImageStream") public void service(HttpServletResponse respo.
2021-04-15 20:31:07 1318
原创 文件上传 1. 从路径A复制到路径B 2. 通过流上传文件
从路径A复制到路径B/** * 根据文件路径上传文件 * @param path * @param fileDocment * @return */ private String fileUploadByFilePath(String path, String fileDocment) { // 读取图片 File fileImage = new File(path); String filepath = fileDocment + File.separator + .
2021-04-15 20:21:42 103
原创 jpa查询方式
sql查询@Query(value = "select * from base_preset where base_sensor_id = ?1 and preset_no in (?2)" ,nativeQuery = true) List<BasePreset> findBySensorIdAndPresetNo(Long sensorId, List<String> presetNos);多条件无sql查询@Autowiredprivate BaseDept.
2021-04-10 16:17:32 253
原创 java 中文按照字母排序
List<String> supplierNames = null; if(equipmentInfoVOList != null && equipmentInfoVOList.size() !=0){ supplierNames = equipmentInfoVOList.stream().filter(f -> f != null).filter(f -> StringUtils.isNotEmpty(f.getManufact
2021-02-08 15:49:31 314 1
原创 使用mongoTemplate进行Aggregation聚合查询
1.Criteria criteria = getCriteria(materialInfoDTO,userVo); Query query = new Query(); query.addCriteria(criteria); long sumCount = mongoTemplate.count(query, MaterialInfo.class); Aggregation aggregation = Aggregation.newA
2021-01-08 17:49:39 5302 1
原创 apache.poi 处理word模板
<!--word模板--> <dependency> <groupId>org.apache.poi</groupId> <artifactId>poi</artifactId> <version>3.17</version> </dependency> <dependenc.
2020-10-20 18:39:39 612
原创 1.文件从服务器下载到本地,2.文件删除,3文件从服务器下载到浏览器,4文件从本地下载到浏览器 等
**import javax.servlet.http.HttpServletRequest;import java.io.*;import java.net.HttpURLConnection;import java.net.MalformedURLException;import java.net.URL;import java.net.URLConnection;public class FileUtil { /* * 根据指定URL将文件下载到指定目标
2020-10-20 10:42:23 236
原创 word转PDF
docx4j依赖: <dependency> <groupId>org.docx4j</groupId> <artifactId>docx4j-export-fo</artifactId> <version>6.1.0</version> </dependency> /** * docx4j .
2020-10-17 11:35:05 198
原创 mybatis分页
//获取数据 PageHelper.startPage(outsourceunitDTO.getPage(),outsourceunitDTO.getSize()); List<OutsourceunitVo> outsourceunitVos = outsourceUnitMapper.getOutsourceUnit(outsourceunitDTO); PageInfo<OutsourceunitVo> pageData = ne
2020-07-20 09:57:04 90
原创 mybatis sql一对多查询 返回对象或list中包含子list
数据库对应关系如下图: 两个表的关联关系 是store_code 和 sku_code 同时相等要求查询结果(图一)"list": [ { "storeCode": "0001", "skuCode": "0200000306", "proStatus": 0, "curNumber": 3, ...
2020-06-05 18:18:57 6181 1
原创 极光推送:后台向APP:android,ios极光推送消息
1. 添加依赖//jpush compile group: 'cn.jpush.api', name: 'jpush-client', version: '3.3.4'2. 注册极光用户//APP端注册极光Id,jpushId为每个用户在各个设备的唯一标识 public void registeAuroral(String jpushId) { JPushInterfac...
2019-06-06 15:39:04 2136
翻译 zuul简单搭建
创建好eureka实现zuul:首先是添加pom.xml文件的依赖: <dependency> <groupId>org.springframework.cloud</groupId> <artifactId>spring-cloud-starter-eureka</artifactId> &l...
2019-05-31 09:33:20 528
翻译 mysqlsla安装和使用介绍
安装mysqlsla源码路径:https://github.com/daniel-nichter/hackmysql.com源码存放路径:/usr/local/src1、获取源码如果没有git命令,请先安装gityum -y install gityum -y install perl-ExtUtils-Embedcd /usr/local/srcgit clone http...
2019-05-16 20:27:15 1405
原创 mongoDB操作
1. 查询Query query = new Query(Criteria.where(“sourceId”).is(sourceId).and(“userId”).is(userId).and(“createDate”).in(times));query.with(new Sort(Sort.Direction.DESC, “createDate”));List userHealthDat...
2019-05-08 15:08:42 274
原创 使用restFul进行post和get请求
1.1 postForObjectString urlAddPatients = “http://192.168.10.180:8000/life-account/”+"/static/patients/addpatients";CompleteUserInfo completeUserInfo = new CompleteUserInfo();completeUserInfo.se...
2019-05-07 16:50:29 3047
原创 mysql行转列
SELECT user_id userId,update_date datatime, MAX(CASE dictionary_code WHEN 'LRTZ_JKZB_XY1' THEN num ELSE 0 END ) xueyang, MAX(CASE dictionary_code WHEN 'LRTZ_JKZB_XY' THEN num ELSE 0 E...
2019-05-07 16:39:16 795
原创 Excel导出
String fileName = “导出Excel.xlsx”; //创建名称String rpath = null;ClassLoader cldr=getClass().getClassLoader();if(null!=cldr){rpath = cldr.getResource("/").getPath();}else{rpath="###";}String os = S...
2019-04-02 12:03:22 98
空空如也
空空如也
TA创建的收藏夹 TA关注的收藏夹
TA关注的人