1.司机和配送员统计信息合一
2.修改签收率统计信息接口
3.修改签收数据导出接口
| | |
| | | |
| | | @GetMapping("/outExcels") |
| | | @ApiOperation(value = "导出签收统计信息表", notes = "导出签收统计信息表") |
| | | public void export1(OrderStatusCount orderStatusCount, HttpServletResponse response,QueryRequest queryRequest) throws IOException { |
| | | List<OrderStatusCount> orderStatus = this.iSignCountService.signCounts(orderStatusCount,queryRequest).getRecords(); |
| | | public void export1(OrderStatusCount orderStatusCount, HttpServletResponse response) throws IOException { |
| | | List<OrderStatusCount> orderStatus = this.iSignCountService.signCounts2New(orderStatusCount); |
| | | response.setContentType("application/vnd.ms-excel"); |
| | | response.setCharacterEncoding("utf-8"); |
| | | String fileName = URLEncoder.encode("签收数量统计报表", "UTF-8"); |
| | |
| | | import cn.exrick.xboot.core.common.utils.ResultUtil; |
| | | import cn.exrick.xboot.core.common.vo.PageVo; |
| | | import cn.exrick.xboot.core.common.vo.Result; |
| | | import cn.exrick.xboot.core.entity.User; |
| | | import cn.exrick.xboot.your.entity.Car; |
| | | import cn.exrick.xboot.your.entity.UserStatistic; |
| | | import cn.exrick.xboot.your.service.ICarService; |
| | | import cn.exrick.xboot.your.service.IUserStatisticService; |
| | | import cn.hutool.core.util.StrUtil; |
| | | import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; |
| | | import com.baomidou.mybatisplus.core.metadata.IPage; |
| | | import com.baomidou.mybatisplus.extension.conditions.query.QueryChainWrapper; |
| | | import io.swagger.annotations.Api; |
| | | import io.swagger.annotations.ApiOperation; |
| | | import lombok.extern.slf4j.Slf4j; |
| | |
| | | @Autowired |
| | | private IUserStatisticService iUserStatisticService; |
| | | |
| | | @Autowired |
| | | private ICarService iCarService; |
| | | |
| | | @RequestMapping(value = "/get/{id}", method = RequestMethod.GET) |
| | | @ApiOperation(value = "通过id获取") |
| | | public Result<UserStatistic> get(@PathVariable String id) { |
| | |
| | | return new ResultUtil<UserStatistic>().setData(userStatistic); |
| | | } |
| | | |
| | | @RequestMapping(value = "/getAllByUserId", method = RequestMethod.GET) |
| | | @ApiOperation(value = "通过用户id获取统计信息") |
| | | public Result<UserStatistic> getStatisticByUserId(String userId,int type) { |
| | | UserStatistic userStatistic0 = getById(userId); |
| | | String otherId = getOtherIdFromCar(userId,type); |
| | | UserStatistic userStatistic1 = getById(otherId); |
| | | if(type==0){//驾驶员 |
| | | userStatistic0.setSends(userStatistic1.getSends()); |
| | | userStatistic0.setService(userStatistic1.getService()); |
| | | userStatistic0.setSends2(userStatistic1.getSends2()); |
| | | userStatistic0.setAbnormalOpen(userStatistic1.getAbnormalOpen()); |
| | | userStatistic0.setLikesRate(userStatistic1.getLikesRate()); |
| | | }else{//配送员 |
| | | userStatistic0.setSafeDriving(userStatistic1.getSafeDriving()); |
| | | userStatistic0.setOutCar(userStatistic1.getOutCar()); |
| | | userStatistic0.setDriving(userStatistic1.getDriving()); |
| | | userStatistic0.setFatigueDriving(userStatistic1.getFatigueDriving()); |
| | | userStatistic0.setSmoking(userStatistic1.getSmoking()); |
| | | userStatistic0.setNoBelt(userStatistic1.getNoBelt()); |
| | | userStatistic0.setLikes(userStatistic1.getLikes()); |
| | | } |
| | | return new ResultUtil<UserStatistic>().setData(userStatistic0); |
| | | } |
| | | |
| | | public UserStatistic getById(String userId){ |
| | | QueryWrapper<UserStatistic> wrapper = new QueryWrapper<>(); |
| | | wrapper.eq("user_id",userId); |
| | | UserStatistic userStatistic = iUserStatisticService.getOne(wrapper); |
| | | if(userStatistic==null){ |
| | | userStatistic = new UserStatistic(); |
| | | } |
| | | return userStatistic; |
| | | } |
| | | |
| | | public String getOtherIdFromCar(String userId,int type){ |
| | | QueryWrapper<Car> wrapper = new QueryWrapper<>(); |
| | | if(type==0){ |
| | | wrapper.eq("user_id",userId); |
| | | Car myCar = iCarService.getOne(wrapper); |
| | | if(myCar!=null){ |
| | | return myCar.getFollowUserId(); |
| | | } |
| | | }else if(type==1){ |
| | | wrapper.eq("follow_user_id",userId); |
| | | Car myCar = iCarService.getOne(wrapper); |
| | | if(myCar!=null){ |
| | | return myCar.getUserId(); |
| | | } |
| | | } |
| | | return null; |
| | | } |
| | | |
| | | @RequestMapping(value = "/getAll", method = RequestMethod.GET) |
| | | @ApiOperation(value = "获取全部数据") |
| | | public Result<List<UserStatistic>> getAll() { |
| | |
| | | |
| | | IPage<OrderStatusCount> signCount( @Param("bo")OrderStatusCount orderStatusCount,Page<OrderStatusCount> page); |
| | | |
| | | List<OrderStatusCount> signCount2New( @Param("bo")OrderStatusCount orderStatusCount); |
| | | |
| | | IPage<OrderStatusCount> signCountNew( @Param("bo")OrderStatusCount orderStatusCount,Page<OrderStatusCount> page); |
| | | |
| | | List<OrderStatusCount> signCountNewTotal( @Param("bo")OrderStatusCount orderStatusCount); |
| | |
| | | public interface ISignCountService extends IService<SignCount> { |
| | | |
| | | IPage<OrderStatusCount> signCounts(OrderStatusCount orderStatusCount, QueryRequest queryRequest); |
| | | List<OrderStatusCount> signCounts2New(OrderStatusCount orderStatusCount); |
| | | IPage<OrderStatusCount> signCountsNew(OrderStatusCount orderStatusCount, QueryRequest queryRequest); |
| | | } |
| | |
| | | } |
| | | |
| | | @Override |
| | | public List<OrderStatusCount> signCounts2New(OrderStatusCount orderStatusCount) { |
| | | List<OrderStatusCount> records = this.signCountMapper.signCount2New(orderStatusCount); |
| | | List<OrderStatusCount> recordsAll = this.signCountMapper.signCountNewTotal(orderStatusCount); |
| | | for (int i=0;i<records.size();i++) { |
| | | for (OrderStatusCount statusCountx: recordsAll) { |
| | | if(records.get(i).getCarName().equals(statusCountx.getCarName())){ |
| | | records.get(i).setSendMonth(statusCountx.getProportion()); |
| | | break; |
| | | } |
| | | } |
| | | //"oneBatch":"01段","twoBatch":"0","threeBatch":"0","fourBatch":"0","fiveBatch":"0" |
| | | if("0".equals(records.get(i).getOneBatch())){ |
| | | records.get(i).setOneBatch(null); |
| | | } |
| | | if("0".equals(records.get(i).getTwoBatch())){ |
| | | records.get(i).setTwoBatch(null); |
| | | } |
| | | if("0".equals(records.get(i).getThreeBatch())){ |
| | | records.get(i).setThreeBatch(null); |
| | | } |
| | | if("0".equals(records.get(i).getFourBatch())){ |
| | | records.get(i).setFourBatch(null); |
| | | } |
| | | if("0".equals(records.get(i).getFiveBatch())){ |
| | | records.get(i).setFiveBatch(null); |
| | | } |
| | | } |
| | | return records; |
| | | } |
| | | |
| | | @Override |
| | | public IPage<OrderStatusCount> signCountsNew(OrderStatusCount orderStatusCount, QueryRequest queryRequest) { |
| | | Page<OrderStatusCount> page = new Page<>(); |
| | | if (org.apache.commons.lang3.StringUtils.isNotBlank(queryRequest.getPageSize() + "") && (queryRequest.getPageSize() != 0)) { |
| | |
| | | page.setCurrent(0); |
| | | page.setSize(-1); |
| | | } |
| | | |
| | | IPage<OrderStatusCount> orderStatusCountIPage = this.signCountMapper.signCountNew(orderStatusCount, page); |
| | | List<OrderStatusCount> recordsAll = this.signCountMapper.signCountNewTotal(orderStatusCount); |
| | | List<OrderStatusCount> records = orderStatusCountIPage.getRecords(); |
| | |
| | | break; |
| | | } |
| | | } |
| | | //"oneBatch":"01段","twoBatch":"0","threeBatch":"0","fourBatch":"0","fiveBatch":"0" |
| | | if("0".equals(records.get(i).getOneBatch())){ |
| | | records.get(i).setOneBatch(null); |
| | | } |
| | | if("0".equals(records.get(i).getTwoBatch())){ |
| | | records.get(i).setTwoBatch(null); |
| | | } |
| | | if("0".equals(records.get(i).getThreeBatch())){ |
| | | records.get(i).setThreeBatch(null); |
| | | } |
| | | if("0".equals(records.get(i).getFourBatch())){ |
| | | records.get(i).setFourBatch(null); |
| | | } |
| | | if("0".equals(records.get(i).getFiveBatch())){ |
| | | records.get(i).setFiveBatch(null); |
| | | } |
| | | } |
| | | // List<OrderStatusCount> recordsLast = new ArrayList<>(); |
| | | orderStatusCountIPage.setRecords(records); |
| | |
| | | line ASC, |
| | | send_date asc |
| | | </select> |
| | | |
| | | <select id="signCount" resultType="cn.exrick.xboot.your.entity.OrderStatusCount"> |
| | | |
| | | SELECT |
| | | CONCAT_WS('',YEAR(send_date),'年',MONTH(send_date),'月')sendMonth, |
| | | DATE(DATE_FORMAT(send_date,'%Y-%m-%d') ) sendDate, |
| | | car_name, |
| | | batch, |
| | | SUM( amount ) amount, |
| | | SUM( abnormal_sign ) as abnormalSign, |
| | | SUM( not_sign_count ) as notSignCount, |
| | | SUM( sign_count ) as signCount , |
| | | CONCAT_WS( '',( FORMAT((SUM( sign_count ) / SUM( amount )),4 ) *100), '%') as proportion, |
| | | (CASE `batch` WHEN '01段' THEN batch ELSE 0 END) as 'oneBatch', |
| | | (CASE `batch` WHEN '02段' THEN batch ELSE 0 END) as 'twoBatch', |
| | | (CASE `batch` WHEN '03段' THEN batch ELSE 0 END) as 'threeBatch', |
| | | (CASE `batch` WHEN '04段' THEN batch ELSE 0 END) as 'fourBatch', |
| | | (CASE `batch` WHEN '05段' THEN batch ELSE 0 END) as 'fiveBatch', |
| | | user_name as userName, |
| | | line |
| | | FROM |
| | | t_sign |
| | | <where> |
| | | 1=1 |
| | | <if test="bo.line != null and bo.line != ''" > |
| | | AND line = #{bo.line} |
| | | </if> |
| | | <if test="bo.carName != null and bo.carName != ''" > |
| | | AND car_name like CONCAT ('%',#{bo.carName},'%') |
| | | </if> |
| | | <if test="bo.batch != null and bo.batch != ''" > |
| | | AND batch = #{bo.batch} |
| | | </if> |
| | | <if test="bo.userName != null and bo.userName != ''" > |
| | | AND user_name = #{bo.userName} |
| | | </if> |
| | | <if test="bo.sendDate != null and bo.sendDate != ''"> |
| | | AND DATE_FORMAT(send_date,'%Y-%m-%d') = #{bo.sendDate} |
| | | </if> |
| | | <if test="bo.sendDateStart != null and bo.sendDateStart != ''"> |
| | | AND send_date >= #{bo.sendDateStart} |
| | | </if> |
| | | <if test="bo.sendDateEnd != null and bo.sendDateEnd != ''"> |
| | | AND send_date <= #{bo.sendDateEnd} |
| | | </if> |
| | | </where> |
| | | GROUP BY |
| | | car_name, |
| | | send_date, |
| | | batch, |
| | | user_name, |
| | | line |
| | | ORDER BY |
| | | line ASC, |
| | | send_date asc |
| | | </select> |
| | | |
| | | <select id="signCountNew" resultType="cn.exrick.xboot.your.entity.OrderStatusCount"> |
| | | SELECT |
| | | line, |
| | |
| | | car_name, |
| | | batch |
| | | </select> |
| | | <select id="signCount2New" resultType="cn.exrick.xboot.your.entity.OrderStatusCount"> |
| | | SELECT |
| | | line, |
| | | user_name as userName, |
| | | car_name,SUM(sign_count) as signCount, |
| | | SUM(amount) as amount, |
| | | CONCAT_WS( '',( FORMAT((SUM( sign_count ) / SUM( amount )),4 ) *100), '%') as proportion, |
| | | (CASE `batch` WHEN '01段' THEN batch ELSE 0 END) as 'oneBatch', |
| | | (CASE `batch` WHEN '02段' THEN batch ELSE 0 END) as 'twoBatch', |
| | | (CASE `batch` WHEN '03段' THEN batch ELSE 0 END) as 'threeBatch', |
| | | (CASE `batch` WHEN '04段' THEN batch ELSE 0 END) as 'fourBatch', |
| | | (CASE `batch` WHEN '05段' THEN batch ELSE 0 END) as 'fiveBatch' |
| | | FROM |
| | | t_sign |
| | | <where> |
| | | 1=1 |
| | | <if test="bo.line != null and bo.line != ''" > |
| | | AND line = #{bo.line} |
| | | </if> |
| | | <if test="bo.carName != null and bo.carName != ''" > |
| | | AND car_name like CONCAT ('%',#{bo.carName},'%') |
| | | </if> |
| | | <if test="bo.batch != null and bo.batch != ''" > |
| | | AND batch = #{bo.batch} |
| | | </if> |
| | | <if test="bo.userName != null and bo.userName != ''" > |
| | | AND user_name = #{bo.userName} |
| | | </if> |
| | | <if test="bo.sendDate != null and bo.sendDate != ''"> |
| | | AND DATE_FORMAT(send_date,'%Y-%m-%d') = #{bo.sendDate} |
| | | </if> |
| | | <if test="bo.sendDateStart != null and bo.sendDateStart != ''"> |
| | | AND send_date >= #{bo.sendDateStart} |
| | | </if> |
| | | <if test="bo.sendDateEnd != null and bo.sendDateEnd != ''"> |
| | | AND send_date <= #{bo.sendDateEnd} |
| | | </if> |
| | | </where> |
| | | GROUP BY line, |
| | | user_name, |
| | | car_name, |
| | | batch |
| | | </select> |
| | | <select id="signCountNewTotal" resultType="cn.exrick.xboot.your.entity.OrderStatusCount"> |
| | | SELECT |
| | | car_name, |