myabtis-plus 自定义列和自定义sql语句

这里先看一段代码示例

// 布纱房间总数
QueryWrapper<ClothEntity> clothEntityQueryWrapper = new QueryWrapper<>();
clothEntityQueryWrapper.select("project_no,cloth_track_type," +
        "sum(zgbms) as zgbms_totle," +
        "sum(width) as width_totle," +
        "sum(hegiht) as hegiht_totle," +
        "sum(slice_amount) as slice_amount_totle," +
        "count(code) as room_no_totle");
clothEntityQueryWrapper.lambda().
        in(ClothEntity::getProjectNo,projectNos);
clothEntityQueryWrapper.groupBy("project_no","cloth_track_type");
List<ClothEntity> clothTotle = clothMapper.selectList(clothEntityQueryWrapper);
// 解释  使用select 来设置显示列  zgbms_totle 列对应属性名是 zgbmsTotle 以此类推。
// 这是查询一个表  如果有多个表  就必须在mapper中自动以sql语句了
  1. 自定义sql 语句示例
@Select(value = "select  \n" +
			"t_project.produce_type as produce_type,\n" +
			"tuwp.project_no as project_no,\n" +
			"tuwp.project_name as project_name,\n" +
			"tuwp.user_code as user_code,\n" +
			"tuwp.user_name as user_name,\n" +
			"tuwp.work_procedure_name as work_procedure_name," +
			"tuwp.cloth_or_track_code as cloth_or_track_code," +
			"tuwp.room_no as room_no,\n" +
			"gd.double_deck as  gd_double_deck,\n" +
			"t_cloth.double_deck as  bs_double_deck,\n" +
			"count(distinct tuwp.room_no )  as  room_no_sum," +
			"(case WHEN tuwp.cloth_track_type <> 3 then tuwp.cloth_track_type\n" +
			"when tuwp.cloth_track_type=3 and gd.track_type='布' then 31  \n" +
			"when tuwp.cloth_track_type=3 and gd.track_type='纱' then 32\n" +
			"end)  as  cloth_track_type,\n" +
			"sum(t_cloth.zgbms) as zgbms_sum,\n" +
			"sum(t_cloth.width)  as width_sum,\n" +
			"sum(t_cloth.hegiht)  as hegiht_sum,\n" +
			"sum(t_cloth.slice_amount) as slice_amount_sum,\n" +
			"max(tuwp.price)  as  price,\n" +
			"sum(tuwp.work_fee) as work_fee,\n" +
			"CONCAT(wp.price_rule, ', 倍率:', wp.multipl) as  price_rule\n" +
			"from t_user_work_procedure tuwp  -- 扫码表\n" +
			"left join\n" +
			"t_cloth   -- 布纱表 \n" +
			"on t_cloth.code = tuwp.cloth_or_track_code\n" +
			" left join \n" +
			"t_project   -- 项目表\n" +
			"on tuwp.project_no = t_project.project_no\n" +
			"left JOIN\n" +
			"t_track gd\n" +
			"on  gd.code = tuwp.cloth_or_track_code\n" +
			"left join t_work_procedure wp \n" +
			"on tuwp.work_procedure_code = wp.code\n" +
			"${ew.customSqlSegment}\n" +
			"group by tuwp.project_no,tuwp.user_code,tuwp.work_procedure_code\n" +
			"order by tuwp.project_no,tuwp.work_procedure_name,cloth_track_type")
	List<SalaryByMonthVO>  exportWorkFeeByMonth(@Param(Constants.WRAPPER)
	 Wrapper<UserWorkProcedureEntity> wrapper);
// 这种 使用条件列就不能用lambda() 了   应该这样写  
QueryWrapper<UserWorkProcedureEntity> wrapper2 = 
new QueryWrapper<UserWorkProcedureEntity>();
wrapper2.ge("tuwp.create_time", startTime);
// 结束时间为 now
wrapper2.le("tuwp.create_time", endTime);
List<SalaryByMonthVO> data = 
userWorkProcedureMapper.exportWorkFeeByMonth(wrapper2);

…持续更新

你可能感兴趣的:(myabtis-plus)