Commit 146b16c0 authored by jiaorz's avatar jiaorz

Merge remote-tracking branch 'origin/dev' into dev

parents 62ae7bd4 d83fb2d2
...@@ -21,8 +21,8 @@ public class StaffStatisticsFindDTO extends PageParam { ...@@ -21,8 +21,8 @@ public class StaffStatisticsFindDTO extends PageParam {
private Date startDate; private Date startDate;
private Date endDate; private Date endDate;
private String companyName; private String companyName;
private String postionName;
private Integer userPostionId; private Integer userPostionId;
private Integer companyId; private Integer companyId;
private List<Integer> userIds; private List<Integer> userIds;
private Boolean isExport;
} }
...@@ -185,6 +185,11 @@ public class AppUserDetailBiz extends BaseBiz<AppUserDetailMapper, AppUserDetail ...@@ -185,6 +185,11 @@ public class AppUserDetailBiz extends BaseBiz<AppUserDetailMapper, AppUserDetail
} }
public PageDataVO<UserStaffBo> findAllStaffsByCompanyIdAndPostionIdWithPage(StaffStatisticsFindDTO staffStatisticsFindDTO) { public PageDataVO<UserStaffBo> findAllStaffsByCompanyIdAndPostionIdWithPage(StaffStatisticsFindDTO staffStatisticsFindDTO) {
return PageDataVO.pageInfo(staffStatisticsFindDTO.getPage(),staffStatisticsFindDTO.getLimit(),()->mapper.findAllStaffsByCompanyIdAndPostionIdWithPage(staffStatisticsFindDTO)); return PageDataVO.pageInfo(staffStatisticsFindDTO.getPage(),staffStatisticsFindDTO.getLimit(),()->mapper.findAllStaffsByCompanyIdAndPostionId(staffStatisticsFindDTO));
}
public List<UserStaffBo> findStaffsByIdsAndCompanyAndPostion(StaffStatisticsFindDTO staffStatisticsFindDTO) {
List<UserStaffBo> staffBos = mapper.findAllStaffsByCompanyIdAndPostionId(staffStatisticsFindDTO);
return CollectionUtils.isEmpty(staffBos)?Collections.EMPTY_LIST:staffBos;
} }
} }
...@@ -32,5 +32,5 @@ public interface AppUserDetailMapper extends Mapper<AppUserDetail> { ...@@ -32,5 +32,5 @@ public interface AppUserDetailMapper extends Mapper<AppUserDetail> {
List<AppUserVo> getUserByUserIdList(@Param("userIds") List<Integer> userIds); List<AppUserVo> getUserByUserIdList(@Param("userIds") List<Integer> userIds);
List<UserStaffBo> findAllStaffsByCompanyIdAndPostionIdWithPage(StaffStatisticsFindDTO staffStatisticsFindDTO); List<UserStaffBo> findAllStaffsByCompanyIdAndPostionId(StaffStatisticsFindDTO staffStatisticsFindDTO);
} }
\ No newline at end of file
...@@ -9,7 +9,11 @@ import org.springframework.web.bind.annotation.PostMapping; ...@@ -9,7 +9,11 @@ import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody; import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController; import org.springframework.web.bind.annotation.RestController;
import com.github.wxiaoqi.security.common.exception.BaseException;
import javax.servlet.ServletOutputStream;
import javax.servlet.http.HttpServletResponse;
import java.time.LocalDateTime;
import java.time.format.DateTimeFormatter;
import java.util.Map; import java.util.Map;
/** /**
...@@ -30,4 +34,19 @@ public class StaffStatisticsAdminController { ...@@ -30,4 +34,19 @@ public class StaffStatisticsAdminController {
Map<String,Object> result = staffStatisticsBiz.listStaffStatisticsWithPage(staffStatisticsFindDTO); Map<String,Object> result = staffStatisticsBiz.listStaffStatisticsWithPage(staffStatisticsFindDTO);
return ObjectRestResponse.succ(result); return ObjectRestResponse.succ(result);
} }
@PostMapping("/export")
public void exportStaffStatistics(@RequestBody StaffStatisticsFindDTO staffStatisticsFindDTO, HttpServletResponse response){
try {
String name = DateTimeFormatter.ofPattern("YYYYMMddHHmmss").format(LocalDateTime.now());
response.setContentType("application/vnd.ms-excel;charset=utf-8");
String filename = String.format("%s-staff-statistics.xlsx",name);
response.setHeader("Content-Disposition","attachment;filename="+ new String(filename.getBytes(), "iso8859-1"));
ServletOutputStream outputStream = response.getOutputStream();
staffStatisticsBiz.exportStaffStistics(staffStatisticsFindDTO, outputStream);
response.setCharacterEncoding("UTF-8");
}catch (Exception ex){
throw new BaseException("导出数据失败");
}
}
} }
...@@ -261,19 +261,53 @@ from `app_user_detail` as `aud` left join `app_user_login` as `aul` on aul.id= ...@@ -261,19 +261,53 @@ from `app_user_detail` as `aud` left join `app_user_login` as `aul` on aul.id=
</foreach> </foreach>
</select> </select>
<select id="findAllStaffsByCompanyIdAndPostionIdWithPage" <select id="findAllStaffsByCompanyIdAndPostionId"
resultType="com.github.wxiaoqi.security.admin.bo.UserStaffBo"> resultType="com.github.wxiaoqi.security.admin.bo.UserStaffBo">
select aud.userid as `userId`,aud.realname as `realName`,aud.nickname as `nickName`,aul.username as `phone`,aud.position_id as `postionId`,aup.name as `postionName`,aupt.company_id as `companyId`,aupt.company_name as `companyName` select * from (select aud.userid as `userId`,aud.realname as `realName`,aud.nickname as `nickName`,aul.username as `phone`,aud.position_id
from `app_user_detail` as `aud` left join `app_user_login` as `aul` on aul.id=aud.userid as `postionId`,aup.name as `postionName`,aupt.company_id as `companyId`,aupt.company_name as `companyName` from `app_user_detail` as `aud`
left join `app_user_position_temp` as `aupt` on aupt.user_id=aul.id left join `app_user_login` as `aul` on aul.id=aud.userid
left join `app_user_position` as `aup` on aup.id=aud.position_id left join (select * from `app_user_position_temp` where is_del=0) as `aupt` on aupt.user_id=aul.id
where <![CDATA[aud.position_id<>6]]> and aud.isdel=0 left join `app_user_position` as `aup` on aup.id=aud.position_id where <![CDATA[aud.position_id<>6]]> and aud.isdel=0
<if test="userPostionId!=null"> <if test="userPostionId!=null">
and aud.`position_id`=#{userPostionId} and aud.`position_id`=#{userPostionId}
</if> </if>
<if test="companyId!=null"> <if test="companyId!=null">
and aupt.`company_id`=#{companyId} and aupt.`company_id`=#{companyId}
</if>
<if test="userIds!=null and userIds.size>0">
and aud.userid in
<foreach collection="userIds" item="userId" open="(" close=")" separator=",">
#{userId}
</foreach>
</if>) as `saff`
left join (
select auswp.user_id, IFNULL(auswp.upIncome, 0) - IFNULL(auswd.dowIncome, 0) as `sellAmount`
from (select `user_id`, sum(price) as `upIncome`
from `app_user_selling_water`
where <![CDATA[position_id<>6]]>
and status = 0
<if test="startDate!=null and endDate!=null">
and `crt_time` between #{startDate} and #{endDate}
</if>
<if test="startDate!=null and endDate==null">
and <![CDATA[
`crt_time` >=#{startDate}
]]>
</if>
<if test="startDate==null and endDate!=null">
and <![CDATA[
`crt_time` <=#{endDate}
]]>
</if> </if>
group by user_id) as auswp
left join (select `user_id`, sum(price) as `dowIncome`
from `app_user_selling_water`
where <![CDATA[position_id<>6]]>
and status = 1
group by user_id) as auswd
on auswd.user_id = auswp.user_id
) as `sell` on sell.user_id=saff.userId
order by sell.sellAmount desc
</select> </select>
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment