表数据如上。现在要求查询的列表为按outline_group_id分组,分组后组内按照sort_no排序
错误的做法:
这样只能得到分组的第一条记录
正确的做法:
<select id="selectByOutlineGroupIdsAndStudentId" resultMap="ResultMapWithBLOBs">
select
<include refid="Base_Column_List" />
,
<include refid="Blob_Column_List" />
from homework_student_answer
where outline_group_id in
<foreach collection="list" separator="," item="item" index="index" close=")" open="(">
#{item,jdbcType=INTEGER}
</foreach>
and student_user_id = #{studentId,jdbcType=BIGINT}
order by outline_group_id,sort_no
</select>
即:
SELECT
*
FROM
homework_student_answer
WHERE
outline_group_id IN (
336,
337,
338,
339,
340,
341,
342,
343,
348,
349
)
AND student_user_id = 8741544229353865
ORDER BY
outline_group_id,
sort_no;
通过排序方式也能让
outline_group_id相同值的放在一起。
3.如果对日期进行时区转换?这个一般是对有国外业务必须要考虑的事情。
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
sdf.setTimeZone(TimeZone.getTimeZone("GMT+8:00"));
Date enterTime = sdf.parse((String) recordJson.getByPath("first_time"));
Date leaveTime = sdf.parse((String) recordJson.getByPath("last_time"));
对日期的计算:
Date allowStartTime = new Date(minStartTime.getTime() - DateUtil.MILLSECONDS_OF_SCHEDULE_CHECK_INTERVAL);
4.tail命令于条件查询结合
tail -f info.log|grep ‘查询条件’
记得要加上单引号
[ec2-user@ip-172-31-2-159 lingoace-task]$ tail -f info.log|grep 检查未支付订单
[2020-06-01 08:26:00.049] INFO [schedulerFactoryBean_Worker-10] OrderServiceTask.java:28 - 检查未支付订单是否过期任务结束
[2020-06-01 08:27:00.022] INFO [schedulerFactoryBean_Worker-1] OrderServiceTask.java:26 - 检查未支付订单是否过期任务开始
[2020-06-01 08:27:00.061] INFO [schedulerFactoryBean_Worker-1] OrderServiceTask.java:28 - 检查未支付订单是否过期任务结束
[2020-06-01 08:28:00.013] INFO [schedulerFactoryBean_Worker-2] OrderServiceTask.java:26 - 检查未支付订单是否过期任务开始
[2020-06-01 08:28:00.046] INFO [schedulerFactoryBean_Worker-2] OrderServiceTask.java:28 - 检查未支付订单是否过期任务结束
5.对全球手机号校验是否为正确的手机号:主要应用谷歌的 libphonenumber 包
maven引入依赖:
<!--全球电话号码验证-->
<dependency>
<groupId>com.googlecode.libphonenumber</groupId>
<artifactId>libphonenumber</artifactId>
<version>8.10.17</version>
</dependency>
具体应用:
import com.google.i18n.phonenumbers.PhoneNumberUtil;
import com.google.i18n.phonenumbers.Phonenumber;
public boolean isValid(String identify) {
try {
Phonenumber.PhoneNumber number = phoneUtil.parse(identify, "CN");
String regionCodeForNumber = phoneUtil.getRegionCodeForNumber(number);
//放宽校验规则
if(phoneUtil.isValidNumber(number) || !StringUtils.isEmpty(regionCodeForNumber)){
return true;
}
return false;
} catch (Exception e) {
return false;
}
}
public boolean isChinaPhone(String phone) {
try {
Phonenumber.PhoneNumber number = phoneUtil.parse(phone, "CN");
if (phoneUtil.isValidNumber(number)) {
if (number.getCountryCode() == CHINA_PHONE_AREA_NO) {
return true;
}
}
} catch (Exception e) {
return false;
}
return false;
}
6.几个刚接触的使用的linux命令
1.创建目录:创建task目录
mkdir task
2.重命名目录:
mv task edu-task
3.查询指定目录下多个文件中那些包含指定关键字
grep -r 关键字
查询出来的结果列表
左侧为文件名 右侧为对应包含关键字的行信息
String key = String.format("%d-%d", scheduleVirtualclassMember.getVirtualClassId(), scheduleVirtualclassMember.getStudentUserId());
nohup java -Xms4g -Xmx8g -jar edu-transfer-1.0-SNAPSHOT.jar JAVA_OPTS="-Djava.awt.headless=true" >/dev/null 2>&1 &
history | grep 'ng_webapp'
start_time between DATE_ADD(CURDATE(), INTERVAL 8 HOUR) and DATE_ADD(CURDATE()+1, INTERVAL 8 HOUR)
10.微信对接api的最好用jar包依赖。几乎所有方法里面都有。
<!--微信模版消息推送三方sdk-->
<dependency>
<groupId>com.github.binarywang</groupId>
<artifactId>weixin-java-mp</artifactId>
<version>3.4.0</version>
</dependency>