日产量转月产量

public void insertMonthP(String params) {//日产量转月产量
        JSONObject p = JSON.parseObject(params);
        JSONArray uwiList = p.getJSONArray("uwiList");
        List<String> list = uwiList.toJavaList(String.class);
        Double cumg = 0d;
        Double cumo = 0d;
        Double cumw = 0d;
        Integer cumproHours = 0;
        Integer cumproDays = 0;
        Long wellId = 0l;
        String uwi = "";
//        String date1 = "";
        String date2 = "";
        if (list != null) {
            for (String s : list) {
                wellId = wellInfoService.getWellIdByUwi(s);
                //方法已被修改不能提交
                List<DailyProduction> dailyProductions = dailyProductionMapper.listByCompanyIdAndUwi(1L, s);
                date2 = dailyProductions.get(0).getDate().substring(0,7);
                for (int i = 0; i < dailyProductions.size(); i++) {
                    String date = dailyProductions.get(i).getDate();
                    uwi = dailyProductions.get(i).getUwi();
                    Double gas = dailyProductions.get(i).getGas();
                    Double oil = dailyProductions.get(i).getOil();
                    Double water = dailyProductions.get(i).getWater();
                    String[] split = date.split("-");
                    String date1 = date.substring(0, 7);
                        if (date1.equals(date2)){
                            if (gas != null && gas!=0) {
                                cumproDays++;
                            }
                            if (gas != null) {
                                cumg += gas;
                            }
                            if (oil != null) {
                                cumo += oil;
                            }
                            if (water != null) {
                                cumw += water;
                            }
                        }else {
                            MonthProduction monthProduction = new MonthProduction();
                            monthProduction.setWellId(wellId);
                            monthProduction.setUserId(UserContext.getUserId());
                            monthProduction.setCompanyId(UserContext.getCompanyId());
                            monthProduction.setUwi(uwi);
                            monthProduction.setOilRate(cumo);
                            monthProduction.setWaterRate(cumw);
                            monthProduction.setGasRate(cumg);
                            monthProduction.setDate(date2);
                            monthProduction.setProdDays(cumproDays);
                            if (wellId != null) {
                                pdsMonthProductionMapper.insert(monthProduction);
                            }
                            date2 = date1;
                            cumproDays = 0;
                            cumg = 0d;
                            cumo = 0d;
                            cumw = 0d;
                            cumproDays ++;
                            cumg = gas;
                            cumo = oil;
                            cumw = water;
                        }
                        if (i == (dailyProductions.size()-1)){
                            if (date1.equals(date2)){
                                MonthProduction monthProduction = new MonthProduction();
                                monthProduction.setWellId(wellId);
                                monthProduction.setUserId(UserContext.getUserId());
                                monthProduction.setCompanyId(UserContext.getCompanyId());
                                monthProduction.setUwi(uwi);
                                monthProduction.setOilRate(cumo);
                                monthProduction.setWaterRate(cumw);
                                monthProduction.setGasRate(cumg);
                                monthProduction.setDate(date2);
                                monthProduction.setProdDays(cumproDays);
                                if (wellId != null) {
                                    pdsMonthProductionMapper.insert(monthProduction);
                                }
                            }else {
                                MonthProduction monthProduction = new MonthProduction();
                                monthProduction.setWellId(wellId);
                                monthProduction.setUserId(UserContext.getUserId());
                                monthProduction.setCompanyId(UserContext.getCompanyId());
                                monthProduction.setUwi(uwi);
                                monthProduction.setOilRate(cumo);
                                monthProduction.setWaterRate(cumw);
                                monthProduction.setGasRate(cumg);
                                monthProduction.setDate(date2);
                                monthProduction.setProdDays(cumproDays);
                                if (wellId != null) {
                                    pdsMonthProductionMapper.insert(monthProduction);
                                }
                            }
                        }
                    }
                cumproDays = 0;
                cumg = 0d;
                cumo = 0d;
                cumw = 0d;
                }
            }
        }

 

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值