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);

…持续更新

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值