| | |
| | | import cn.exrick.xboot.your.mapper.SignCountMapper; |
| | | import cn.exrick.xboot.your.entity.SignCount; |
| | | import cn.exrick.xboot.your.service.ISignCountService; |
| | | import cn.hutool.core.util.StrUtil; |
| | | import com.baomidou.mybatisplus.core.metadata.IPage; |
| | | import com.baomidou.mybatisplus.core.toolkit.StringUtils; |
| | | import com.baomidou.mybatisplus.extension.plugins.pagination.Page; |
| | | import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; |
| | | import jodd.util.StringUtil; |
| | |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.stereotype.Service; |
| | | import org.springframework.transaction.annotation.Transactional; |
| | | import org.springframework.util.StringUtils; |
| | | |
| | | import java.math.BigDecimal; |
| | | import java.text.DecimalFormat; |
| | | import java.util.ArrayList; |
| | | import java.util.List; |
| | | import java.util.Map; |
| | | import java.util.stream.Collectors; |
| | | |
| | | /** |
| | | * 状态统计表接口实现 |
| | |
| | | page.setSize(-1); |
| | | } |
| | | if(StringUtil.isNotBlank(orderStatusCount.getStatisticalType())){ |
| | | IPage<OrderStatusCount> orderStatusCountIPage = this.signCountMapper.signCount(orderStatusCount, page); |
| | | List<OrderStatusCount> records = orderStatusCountIPage.getRecords(); |
| | | List<OrderStatusCount> recordsLast = new ArrayList<>(); |
| | | Map<String, List<OrderStatusCount>> collect = records.stream().collect(Collectors.groupingBy(OrderStatusCount::getCarName)); |
| | | for (Map.Entry<String, List<OrderStatusCount>> stringListEntry : collect.entrySet()) { |
| | | List<OrderStatusCount> recordsNew = new ArrayList<>(); |
| | | for (OrderStatusCount statusCount : stringListEntry.getValue()) { |
| | | statusCount.setSendDate(statusCount.getSendMonth()); |
| | | recordsNew.add(statusCount); |
| | | } |
| | | |
| | | return this.signCountMapper.signCounts(orderStatusCount,page); |
| | | for (Map.Entry<String, List<OrderStatusCount>> listEntry : recordsNew.stream().collect(Collectors.groupingBy(OrderStatusCount::getBatch)).entrySet()) { |
| | | for (Map.Entry<String, List<OrderStatusCount>> listEntry1 : listEntry.getValue().stream().collect(Collectors.groupingBy(OrderStatusCount::getSendMonth)).entrySet()) { |
| | | if(listEntry1.getValue().size() > 0){ |
| | | List<OrderStatusCount> value = listEntry1.getValue(); |
| | | Integer amount = 0; |
| | | Integer notSignCount = 0; |
| | | Integer abnormalSign = 0; |
| | | Integer signCount= 0; |
| | | OrderStatusCount orderStatusCount1 = value.get(0); |
| | | for (OrderStatusCount statusCount : value) { |
| | | amount += Integer.parseInt(statusCount.getAmount()); |
| | | notSignCount += Integer.parseInt(statusCount.getNotSignCount()); |
| | | if(statusCount.getAbnormalSign() != null){ |
| | | abnormalSign += Integer.parseInt(statusCount.getAbnormalSign()); |
| | | }else { |
| | | abnormalSign = 0; |
| | | } |
| | | signCount += Integer.parseInt(statusCount.getSignCount()); |
| | | } |
| | | DecimalFormat df = new DecimalFormat("0.00"); |
| | | String maerialRatio = df.format((float)signCount/amount); |
| | | double v = Double.parseDouble(maerialRatio)*100; |
| | | orderStatusCount1.setProportion(v+"%"); |
| | | orderStatusCount1.setAmount(amount+""); |
| | | orderStatusCount1.setNotSignCount(notSignCount+""); |
| | | orderStatusCount1.setAbnormalSign(abnormalSign+""); |
| | | orderStatusCount1.setSignCount(signCount+""); |
| | | value.clear(); |
| | | value.add(orderStatusCount1); |
| | | listEntry1.setValue(value); |
| | | recordsLast.add(orderStatusCount1); |
| | | } |
| | | } |
| | | |
| | | } |
| | | stringListEntry.setValue(recordsNew); |
| | | } |
| | | orderStatusCountIPage.setRecords(recordsLast); |
| | | return orderStatusCountIPage; |
| | | } |
| | | return this.signCountMapper.signCount(orderStatusCount,page); |
| | | } |
| | | |
| | | @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++) { |
| | | //if(records.get(i).getCarName()==null) continue; |
| | | for (OrderStatusCount statusCountx: recordsAll) { |
| | | //if(statusCountx.getCarName()==null) continue; |
| | | if(records.get(i).getCarName().equals(statusCountx.getCarName())){ |
| | | if(statusCountx.getProportion().length()>6){ |
| | | String ss = statusCountx.getProportion().replace("%",""); |
| | | BigDecimal bigDecimal = new BigDecimal(ss); |
| | | double sss = bigDecimal.setScale(2, BigDecimal.ROUND_HALF_UP).doubleValue(); |
| | | records.get(i).setName(sss + "%"); |
| | | }else{ |
| | | records.get(i).setName(statusCountx.getProportion()); |
| | | } |
| | | break; |
| | | } |
| | | } |
| | | if(!StrUtil.isEmpty(records.get(i).getSignCount()) && !StrUtil.isEmpty(records.get(i).getAmount()) && !StrUtil.isEmpty(records.get(i).getNotSignCount())){ |
| | | int abnormalSign = Integer.parseInt(records.get(i).getAmount())-Integer.parseInt(records.get(i).getSignCount())-Integer.parseInt(records.get(i).getNotSignCount()); |
| | | if(abnormalSign<0){ |
| | | abnormalSign = 0; |
| | | } |
| | | records.get(i).setAbnormalSign(abnormalSign + ""); |
| | | } |
| | | if(records.get(i).getProportion().length()>6){ |
| | | String ss = records.get(i).getProportion().replace("%",""); |
| | | BigDecimal bigDecimal = new BigDecimal(ss); |
| | | double sss = bigDecimal.setScale(2, BigDecimal.ROUND_HALF_UP).doubleValue(); |
| | | records.get(i).setProportion(sss+ "%"); |
| | | } |
| | | //"oneBatch":"01段","twoBatch":"0","threeBatch":"0","fourBatch":"0","fiveBatch":"0" |
| | | if("0".equals(records.get(i).getOneBatch())){ |
| | | records.get(i).setOneBatch(null); |
| | | }else{ |
| | | records.get(i).setBatch("01段"); |
| | | } |
| | | if("0".equals(records.get(i).getTwoBatch())){ |
| | | records.get(i).setTwoBatch(null); |
| | | }else{ |
| | | records.get(i).setBatch("02段"); |
| | | } |
| | | if("0".equals(records.get(i).getThreeBatch())){ |
| | | records.get(i).setThreeBatch(null); |
| | | }else{ |
| | | records.get(i).setBatch("03段"); |
| | | } |
| | | if("0".equals(records.get(i).getFourBatch())){ |
| | | records.get(i).setFourBatch(null); |
| | | }else{ |
| | | records.get(i).setBatch("04段"); |
| | | } |
| | | if("0".equals(records.get(i).getFiveBatch())){ |
| | | records.get(i).setFiveBatch(null); |
| | | }else{ |
| | | records.get(i).setBatch("05段"); |
| | | } |
| | | } |
| | | 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(queryRequest.getPageNum()); |
| | | page.setSize(queryRequest.getPageSize()); |
| | | } else { |
| | | 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(); |
| | | |
| | | for (int i=0;i<records.size();i++) { |
| | | for (OrderStatusCount statusCountx: recordsAll) { |
| | | if(records.get(i).getCarName().equals(statusCountx.getCarName())){ |
| | | if(statusCountx.getProportion().length()>6){ |
| | | String ss = statusCountx.getProportion().replace("%",""); |
| | | BigDecimal bigDecimal = new BigDecimal(ss); |
| | | double sss = bigDecimal.setScale(2, BigDecimal.ROUND_HALF_UP).doubleValue(); |
| | | records.get(i).setSendMonth(sss + "%"); |
| | | }else{ |
| | | records.get(i).setSendMonth(statusCountx.getProportion()); |
| | | } |
| | | break; |
| | | } |
| | | } |
| | | if(records.get(i).getProportion().length()>6){ |
| | | String ss = records.get(i).getProportion().replace("%",""); |
| | | BigDecimal bigDecimal = new BigDecimal(ss); |
| | | double sss = bigDecimal.setScale(2, BigDecimal.ROUND_HALF_UP).doubleValue(); |
| | | records.get(i).setProportion(sss+ "%"); |
| | | } |
| | | //"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); |
| | | return orderStatusCountIPage; |
| | | } |
| | | } |