1.模糊查询:
SELECT proj_id,emp_id,emp_name,schedule_date,briefing,proj_name,task_name,work_hours FROM
(SELECT a.proj_id,
a.emp_id,
(SELECT b.emp_name from emp_info b where a.emp_id = b.emp_id) emp_name,
a.schedule_date,
a.briefing,
(SELECT c.proj_name from proj_info c WHERE a.proj_id = c.proj_id) proj_name,
(SELECT d.task_name from proj_task d where a.task_id = d.task_id) task_name,
(SELECT SUM(e.work_hours) from emp_schedule e GROUP BY e.emp_id) work_hours
from emp_schedule a GROUP BY a.emp_id) t
<where>
<if test="fuzzy !=null and fuzzy!=''">
t.emp_name LIKE concat(concat('%',#{fuzzy}),'%') or t.proj_name LIKE concat(concat('%',#{fuzzy}),'%') or t.task_name LIKE concat(concat('%',#{fuzzy}),'%') or
t.work_hours LIKE concat(concat('%',#{fuzzy}),'%') or t.schedule_date LIKE concat(concat('%',#{fuzzy}),'%') or t.briefing LIKE concat(concat('%',#{fuzzy}),'%')
</if>
<if test="projName !=null and projName!=''">
t.proj_name = #{projName}
</if>
</where>
2.String转List
String idlist = "123,234,435,121,126"
List <String> idsList= Arrays.asList(idlist .split(","));
idsList.stream().forEach(
ids -> {
custQuestionRecordDto.setRecordId(ids);
int result = custQuestionRecordDao.reDistribution(custQuestionRecordDto);
if (result <= 0) {
throw new ServiceException("99", "内部异常");
}
}
);
3.map.toString() 和 JSONObject.toJSONString( map )区别:
Map<String, Integer> map = new HashMap<>();
map.put( "a", 1 );
map.put( "b", 2 );
System.out.println( map.toString() ); // 结果是 {a=1, b=2}
// JSONObject 是 com.alibaba.fastjson.JSONObject
System.out.println( JSONObject.toJSONString( map ) ); // 结果是 {"a":1,"b":2}