| | |
| | | import com.vci.ubcs.system.feign.ISysClient; |
| | | import com.vci.ubcs.system.user.entity.User; |
| | | import com.vci.ubcs.system.user.feign.IUserClient; |
| | | import io.swagger.models.auth.In; |
| | | import net.logstash.logback.encoder.org.apache.commons.lang3.StringUtils; |
| | | import oracle.sql.TIMESTAMP; |
| | | import org.slf4j.Logger; |
| | |
| | | } |
| | | |
| | | /** |
| | | * 获取统计分析数据 |
| | | * @param btmNames 业务类型 |
| | | * @return 数据集 |
| | | */ |
| | | @Override |
| | | public R getStatisticAnalysis(String btmNames) { |
| | | //查询业务类型对应的数据库表 |
| | | R<List<BtmTypeVO>> listR = btmTypeClient.selectByIdCollection(Arrays.asList(btmNames.split(","))); |
| | | if (!listR.isSuccess() || listR.getData().size() == 0) { |
| | | throw new ServiceException("传入业务类型未查询到相应表单,请检查!"); |
| | | } |
| | | List tableData = new ArrayList(); |
| | | for (BtmTypeVO datum : listR.getData()) { |
| | | String sql = "select count(*) countNum, to_char(CREATETIME, 'mm') countDate\n" + |
| | | "from "+ datum.getTableName() +"\n" + |
| | | "where CREATETIME >= to_date(EXTRACT(YEAR FROM SYSDATE) || '-01-01 00:00:00', 'yyyy-mm-dd hh24:mi:ss') AND LASTV = '1'\n" + |
| | | "group by to_char(CREATETIME, 'mm')\n" + |
| | | "order by to_char(CREATETIME, 'mm')"; |
| | | //查询出需要处理的数据 |
| | | List<Map> maps = commonsMapper.selectBySql(sql); |
| | | if(maps.size() == 0){ |
| | | throw new ServiceException("传入类型["+ datum.getName() + ":" + |
| | | datum.getId() +"]未查到相关统计数据,请确认!!!!"); |
| | | } |
| | | //当年每月月份之前之和 |
| | | List<Integer> monthCount = new ArrayList<>(12); |
| | | //当年每月的月份数据 |
| | | List<Integer> month = new ArrayList<>(); |
| | | //获取当前月的数字 |
| | | Calendar instance = Calendar.getInstance(); |
| | | int nowmonth = instance.get(Calendar.MONTH) + 1; |
| | | //从1到12月进行处理 |
| | | for (Integer i = 1; i <= 12; i++) { |
| | | //当前月后所有数据设置为0 |
| | | if(i>nowmonth){ |
| | | monthCount.add(0); |
| | | month.add(0); |
| | | } |
| | | //当前月份之前之和 |
| | | Integer count = 0; |
| | | //当前月份数据 |
| | | Integer sameMonth = 0; |
| | | //对数据库查的数据进行处理,对当前月份进行累加 |
| | | for (Map map : maps) { |
| | | Integer mounDate = Integer.parseInt(String.valueOf(map.get("COUNTDATE"))); |
| | | if(mounDate <= i){ |
| | | count += Integer.parseInt(String.valueOf(map.get("COUNTNUM"))); |
| | | } |
| | | if (mounDate == i) { |
| | | sameMonth = Integer.parseInt(String.valueOf(map.get("COUNTNUM"))); |
| | | } |
| | | } |
| | | monthCount.add(count); |
| | | month.add(sameMonth); |
| | | } |
| | | //对数据进行整合 |
| | | HashMap<String,Object> menuData = new HashMap<>(); |
| | | menuData.put("menuName",datum.getName()); |
| | | menuData.put("codeType",null); |
| | | ArrayList monthData = new ArrayList(); |
| | | monthData.add(monthCount); |
| | | monthData.add(month); |
| | | menuData.put("menuData",monthData); |
| | | tableData.add(menuData); |
| | | } |
| | | return R.data(tableData); |
| | | } |
| | | |
| | | /** |
| | | * 封装关键属性的查询语句 |
| | | * |
| | | * @param value 当前的值 |