【JCZH】知识笔记整理

1.连接超时:

在这里插入图片描述

在这里插入图片描述

2.getOutputStream()被占用:

java.lang.IllegalStateException: getOutputStream() has already been called for this response
下载PDF文件时报错,HttpResponse response在方法的参数列表里面,请求并没有进入控制器,将HttpResponse response设置成成员变量自动注入之后,报以下错误:

在这里插入图片描述

在这里插入图片描述

在这里插入图片描述

3.没有导入合同模板文件:

freemarker.template.TemplateNotFoundException: Template not found for name “Test.ftl”.
The name was interpreted by this TemplateLoader: MultiTemplateLoader(loader1 = org.springframework.ui.freemarker.SpringTemplateLoader@59862826, loader2 = ClassTemplateLoader(resourceLoaderClass=org.springframework.web.servlet.view.freemarker.FreeMarkerConfigurer, basePackagePath="" /* relatively to resourceLoaderClass pkg */)).

解决:
添加template目录,在下面新增Test.ftl和Test.ft2两个文件

4.合同模板中,日期转化成字符串报错:

在这里插入图片描述
在这里插入图片描述

在要转化的字段中添加以下注解:
?string(“yyyy-MM-dd HH:mm:ss”)

5.字体找不到问题:

在这里插入图片描述

在dao层的resource目录下放字体的文件,即可解决

6.前端传字符串,后端转化成Date类型的时间问题:

在这里插入图片描述

在对应的属性上面添加注解即可解决
@JsonFormat(pattern = “yyyy-MM-dd HH:mm:ss”)

7.字符串转日期:

在这里插入图片描述

8.日期转字符串(解决时间不一致问题):

框架协议
时间不一致问题:查询出来的数据中,时间比数据库里的时间慢了八个小时
在这里插入图片描述

在model类里面用字符串类型的***DateModel,前端日期给validityEndDate,然后通过DateUtils将validityEndDate转换成字符串类型赋值给endDate,前端取值显示的时候就取endDate显示

新增的时候前端传字符串类型的日期参数,然后通过以下方式转换成Date类型
在这里插入图片描述
在这里插入图片描述

9.导出Excel文件:

海运结算单管理
在这里插入图片描述

从db_sys库里面的t_column表中找form_id为form_payable_settlement
且grid_id为grid1的所有数据,作为导出Excel文件的列名

在这里插入图片描述

10.文件上传:

LINUX环境下不加”/”会报错,因为temp目录是临时目录,长时间没用会被删除,会找不到目录
在这里插入图片描述

11.字符串转时间格式(长度要对应):

在这里插入图片描述

12.生成userId:

在这里插入图片描述

//生成新的userId
TCodeRule codeRule = new TCodeRule();
codeRule.setPlatId("");
codeRule.setSeqTypeId(CodeRuleEnum.USER_ID.getCode());
codeRule.setSize(1);
String userId = generatorCodeForMysql.GeneratorCode(codeRule);

tUserModel.setUserId(userId);

13.生成公司id:

在这里插入图片描述
在这里插入图片描述

/**
 * 生成公司id
 * @param key
 * @param i
 * @return
 */
private String getGeneratorId(String key, int i) {
    TCodeRule codeRule = new TCodeRule();
    codeRule.setPlatId("");
    codeRule.setSeqTypeId(CodeRuleEnum.COMPANY_NUMBER.getCode());
    codeRule.setSize(i);
    String companyId = generatorCodeForMysql.GeneratorCode(codeRule);
    return companyId;
}

14.调用外部接口:

在这里插入图片描述
在这里插入图片描述

在这里插入图片描述

/**
 * post请求封装
 * @param url
 * @param data
 * @return
 */
public ResultDto doPost(String url,Object data){
    HttpHeaders headers = new HttpHeaders();
    //请求头设置
    headers.setContentType(MediaType.APPLICATION_JSON);
    HttpEntity<Object> requestEntity = new HttpEntity<>(data, headers);
    return restTemplate.postForObject(url, requestEntity, ResultDto.class);
}

15.高级查询

在这里插入图片描述
在这里插入图片描述

高级查询SQL语句里面不能写page,要写start。代表从第几条开始,而不是第几页,一般默认从第0条开始查询

16.生成结算单id

在这里插入图片描述
在这里插入图片描述

17.保留两位小数

java使double保留两位小数的多方法 java保留两位小数_java_脚本之家 (jb51.net)

在这里插入图片描述
在这里插入图片描述

在这里插入图片描述

Double四舍五入保留两位小数,转化成String:

在这里插入图片描述

18.调FeignClient接口

在这里插入图片描述

在这里插入图片描述

在这里插入图片描述

在这里插入图片描述

19.定时任务

在这里插入图片描述

测试地址:
http://192.168.1.70:8091/job/insertJob
正式地址:
http://172.16.30.216:8091/job/insertJob
{
“id”:17,
“methodSys”:“CALCULATION”,
“methodName”:“UPDATE_STATUS_CONTRACT”,
“methodUrl”:“http://192.168.1.70:8099/outlineAgreement/updateStatus”,
“cronExpression”:"0 0/2 * * * ? "
}

20.查询当前日期在有效期内的数据:

方法一:
SELECT
	*
FROM
	db_sys.t_trans_outprice
WHERE
	company_id = 'C000000885'
AND segment_id = '025'
AND prod_kind_price = '无缝热镀管'
AND province = '370000000'
AND city = '370200000'
AND NOW() BETWEEN start_date AND date_add(end_date,INTERVAL 1 DAY )
ORDER BY
	total_price ASC





方法二:
SELECT
	*
FROM
	db_sys.t_trans_outprice
WHERE
	company_id = 'C000000885'
AND segment_id = '025'
AND prod_kind_price = '无缝热镀管'
AND province = '370000000'
AND city = '370200000'
AND datediff(start_date, NOW())<0
AND datediff(end_date, NOW())>0
ORDER BY
	total_price ASC

21.打印PDF通用方法:

在这里插入图片描述
在这里插入图片描述

private void print(String templateName, List<Map<String, Object>> listVars) throws Exception {
    //防止乱码,设置HttpServletResponse编码
    response.setCharacterEncoding("utf-8");
    //设置页面禁止缓存
    response.setDateHeader("Expires", 0);
    response.setHeader("Cache-Control", "no-cache");
    response.setHeader("Pragma", "no-cache");
    ByteArrayOutputStream byteArrayOutputStream = 
PdfUtils.generatePDF(freeMarkerConfigurer, templateName, listVars);
byteArrayOutputStream.writeTo(response.getOutputStream());
    response.getOutputStream().flush();
}

22.对Map进行排序(转化为list进行操作)

在这里插入图片描述

Map<String,Integer> map = new HashMap<>();
List<String> list = new ArrayList<>(map.keySet());
Collections.sort(list, (a, b) -> map.get(b) - map.get(a));
map.entrySet().forEach(entry -> System.out.println(String.format("%s=%s", entry.getKey(), entry.getValue())));

23.BigDecimal 类型数据进行加减乘除法:

Java BigDecimal类型的 加减乘除运算不能像C#一样简单,需要调用方法:

加法:add
减法:subtract
乘法:multiply
除法:divide

可参考下面代码:

BigDecimal bignum1 = new BigDecimal("10"); 

BigDecimal bignum2 = new BigDecimal("5"); 

BigDecimal bignum3 = null; 

//加法 
bignum3 =  bignum1.add(bignum2);      
System.out.println("求和:" + bignum3); 

//减法 
bignum3 = bignum1.subtract(bignum2); 
System.out.println("求差:" + bignum3); 

//乘法 
bignum3 = bignum1.multiply(bignum2); 
System.out.println("乘法积:" + bignum3); 

//除法 
bignum3 = bignum1.divide(bignum2); 
System.out.println("除法结果:" + bignum3);

24.导出Excel文件金额保留两位小数

在这里插入图片描述

model.setRevSettlePrice(EmptyUtil.isEmpty(model.getRevSettlePrice())? "0.00": new BigDecimal(model.getRevSettlePrice()).setScale(2,BigDecimal.ROUND_HALF_UP).toString());
model.setRevTotAmount(EmptyUtil.isEmpty(model.getRevTotAmount())? "0.00":new                 BigDecimal(model.getRevTotAmount()).setScale(2,BigDecimal.ROUND_HALF_UP).toString());
model.setPaySettlePrice(EmptyUtil.isEmpty(model.getPaySettlePrice())? "0.00":new BigDecimal(model.getPaySettlePrice()).setScale(2,BigDecimal.ROUND_HALF_UP).toString());
model.setPayTotAmount(EmptyUtil.isEmpty(model.getPayTotAmount())? "0.00":new BigDecimal(model.getPayTotAmount()).setScale(2,BigDecimal.ROUND_HALF_UP).toString());


25.调用Jcos

在这里插入图片描述
方法一:
在这里插入图片描述
方法二:
在这里插入图片描述




//调用(方法一)
//Result result = jcosFeignClient.queryWaybillReview(object);
// TWaybillSendModel model1 = JSONObject.parseObject(JSONObject.toJSONString(result.getData()), TWaybillSendModel.class);





方法二:
![在这里插入图片描述](https://img-blog.csdnimg.cn/0987f12a4cb44941a232058bcb6cd88c.png?x-oss-process=image/watermark,type_d3F5LXplbmhlaQ,shadow_50,text_Q1NETiBAR29kT2ZDb2RlXw==,size_20,color_FFFFFF,t_70,g_se,x_16)

//调用jcos  我家接口  (方法二)
JcosResult s = this.postCall(object, jcosUrl + queryCapacityApprovalStatusWojia);
 TWaybillSendModel model1 = JSONObject.parseObject(JSONObject.toJSONString(s.getData()), TWaybillSendModel.class);
/**
 * 数据发送
 */
@Override
public JcosResult postCall(Object param, String url) {
    try {
        HttpHeaders headers = new HttpHeaders();
        //请求头设置
        headers.setContentType(MediaType.APPLICATION_JSON);
        RestTemplate restTemplate = new RestTemplate();
        restTemplate.getMessageConverters().set(1, new StringHttpMessageConverter(StandardCharsets.UTF_8));
        HttpEntity<Object> requestEntity = new HttpEntity<Object>(param, headers);
        logger.info("==============================调用  " + url + "  start=================================");
        logger.info("传输报文 :" + JSON.toJSONString(requestEntity));
        JcosResult result = restTemplate.postForObject(url, requestEntity, JcosResult.class);
        logger.info("返回报文 :" + JSON.toJSONString(result));
        logger.info("==============================调用  " + url + "  end====================================");
        return result;
    } catch (Exception e) {
        e.printStackTrace();
        logger.info(e.getMessage());
        throw new MyException(ResultEnum.ERROR.getCode(), e.getMessage());
    }
}

26.迭代器,移除集合元素:

在这里插入图片描述

List<BclpBillOfLoadingNoModel> recordByDate = lmsBclpLoadingDao.getRecordByDate(bclpBillOfLoadingNoModel);

Iterator<BclpBillOfLoadingNoModel> iterator = recordByDate.iterator();
while (iterator.hasNext()) {
    BclpBillOfLoadingNoModel next = iterator.next();
    if (ProdCompanyNameLimit.containsLimitName(next.getProdCompany())) {
        iterator.remove();
    }
}

27.高级查询分页设置起始条数

在这里插入图片描述


modelNew.setStart((modelNew.getPage()-1)*modelNew.getLength());

28.查询数据库的时候求和并取余:

在这里插入图片描述

29.steam的map和collectors操作

在这里插入图片描述
在这里插入图片描述
在这里插入图片描述

List<String> collect= roleButtonsTarget.stream().map(TFormButtonModel::getRowid).collect(Collectors.toList());



Map<Integer, List<String>> map =list.stream().sorted(Comparator.comparing(String::length)).collect(Collectors.groupingBy(String::length));

30.String.join()方法和Collectors.joining()方法:

List<String> repeatLine = new ArrayList<>();
repeatLine.add("1");
repeatLine.add("2");
repeatLine.add("3");
repeatLine.add("4");
repeatLine.add("5");

String collect = repeatLine.stream().collect(Collectors.joining(","));
System.out.println("collect:"+collect);
String b = "'"+String.join("!",repeatLine)+"'";
//字符串数组
String[] strArray = new String[]{"ni","zhen","hao","kan"};
//第2个参数是字符串数组
String a = String.join("!",strArray);
//第1个参数之后是多个字符串
String c = String.join("!","ni","zhen","hao","kan");

System.out.println("a:"+a);
System.out.println("b:"+b);
System.out.println("c:"+c);
结果:在每个元素中间拼接一个占位符:
collect:1,2,3,4,5
a:ni!zhen!hao!kan
b:'1!2!3!4!5'
c:ni!zhen!hao!kan

31:list分页

(1)工具类ListUtils.split()
List<List> split = ListUtils.split(param.getPalletModelList());
split.forEach(item-> palletDao.insertPalletBatch(item));
把大集合拆分成多个小集合,可以输入第二个参数作为小集合的大小
(2)google的guava工具
用的google的guava工具中的Lists.partition方法,用它来做分页

在这里插入图片描述

32.集合过滤找到符合条件的一条元素:在这里插入图片描述

TOrderTransport transport = transportById.stream()
        .filter(item1 -> Objects.equals(item.get("boatCode"), item1.getBoatId()))
        .findFirst().orElse(null);

33.MySQL中concat case when的使用:

在这里插入图片描述
在这里插入图片描述

SELECT
t.order_no,
t.pallet_no,
t.trans_type,
tp.supply_type,
t.status,
concat( tp.start_province, tp.start_city, tp.start_address, '->', tp.end_province, tp.end_city, tp.end_address ) AS line,
ts.`name` AS trans_type_name,
ts1.`name` AS status_name,
tp.product_name,
case when tp.total_weight=-1 then '--' else (tp.total_weight-IFNULL(tp.receive_weight,0)) end AS allow_weight,
case when t.this_weight=-1 then '-1' else t.this_weight end AS this_weight,
tb.company_name AS carrier_company_name,
t.contacts,
t.contact_phone,
tu.`name` as application_name,
tu.mobile as application_phone,
t.application_date,
case when tp.total_weight=-1 then '运量待定' else tp.total_weight end AS total_weight,
tp.receive_weight,
tp.ship_requirements,
concat(
concat(cast(year(t.load_date_start) as char),'年',cast(month(t.load_date_start) as char),'月',cast(day(t.load_date_start) as char),'日'), '~',
IFNULL(concat(cast(year(t.load_date_end) as char),'年',cast(month(t.load_date_end) as char),'月',cast(day(t.load_date_end) as char),'日'), '' )
) AS load_date_start,
concat(
concat(cast(year(t.pallet_date_start) as char),'年',cast(month(t.pallet_date_start) as char),'月',cast(day(t.pallet_date_start) as char),'日'), '~',
IFNULL(concat(cast(year(t.pallet_date_end) as char),'年',cast(month(t.pallet_date_end) as char),'月',cast(day(t.pallet_date_end) as char),'日'), '' )
) AS pallet_date_start,
tp.load_days,
(case tp.price_type
WHEN 'JGLX10' THEN
concat( t.report_price, ts4.`name`, '/吨(', ts2.`name`,')' )
WHEN 'JGLX20' THEN
concat( t.report_price, ts4.`name`, '/吨(', ts2.`name`,')' )
WHEN 'JGLX30' THEN
ts3.`name`
else '' end
)as unit_price
FROM
<include refid="select-tables"></include>
WHERE
t.order_no=#{orderNo}

34.MySQL 取得两个时间相差的分钟数 及 常用时间函数

在这里插入图片描述

– 取得相隔秒数

SELECT UNIX_TIMESTAMP('2012-06-09 00:10:11')-UNIX_TIMESTAMP('2012-06-09 00:09:12')

– 取得相隔分钟数

SELECT round((UNIX_TIMESTAMP('2012-06-09 00:10:11')-UNIX_TIMESTAMP('2012-06-09 00:09:12'))/60)
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
To interpret the set of individual think-aloud results, you would typically follow a systematic process that involves the following steps: 1. Transcription: The first step is to transcribe the think-aloud sessions into a written format that can be easily analyzed. This involves listening to the recorded sessions and writing down the participant's verbalizations as accurately as possible. 2. Coding: The next step is to code the transcriptions by identifying themes or categories that represent the different aspects of the participant's performance. The coding scheme should be developed based on the research questions or objectives of the study. 3. Analysis: Once the coding scheme has been established, the transcriptions can be analyzed by reviewing each instance of a particular code and identifying patterns or trends. For example, if one of the codes is "comprehension," the analysis would involve reviewing all instances where the participant demonstrated good or poor comprehension skills. 4. Interpretation: The final step is to interpret the analysis by drawing conclusions from the data. This involves identifying the strengths and weaknesses of the participants based on the patterns observed in the data. For example, if the research question is to evaluate the effectiveness of a new educational software program, the coding scheme might include categories such as "correctness of responses," "time to complete tasks," and "ease of use." The analysis would involve reviewing each instance of these categories and identifying patterns in the data. The interpretation would then involve drawing conclusions about the strengths and weaknesses of the software program based on the patterns observed in the data. Overall, interpreting think-aloud results requires a careful and systematic approach that involves transcription, coding, analysis, and interpretation. By following this process, researchers can gain valuable insights into the cognitive processes of participants and identify areas for improvement in educational or training programs.
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值