| | |
| | | import org.springframework.web.bind.annotation.ResponseBody; |
| | | import org.springframework.web.bind.annotation.RestController; |
| | | |
| | | import java.math.BigDecimal; |
| | | import java.math.MathContext; |
| | | import java.math.RoundingMode; |
| | | import java.text.SimpleDateFormat; |
| | | import java.util.Calendar; |
| | | import java.util.Date; |
| | | |
| | | /** |
| | |
| | | try { |
| | | Html html = htmlService.selectOne(new EntityWrapper<Html>().eq("type",10)); |
| | | StartPriceWarpper startPriceWarpper = new StartPriceWarpper(); |
| | | //{"ChargeStandard":[{"num1":"06:00","num2":"08:00","num3":2,"num4":2,"num5":2,"num6":2,"num7":2,"num8":2,"num9":2,"num10":2,"num11":2},{"num1":"06:00","num2":"08:00","num3":2,"num4":2,"num5":2,"num6":2,"num7":2,"num8":2,"num9":2,"num10":2,{"num1":"06:00","num2":"08:00","num3":2,"num4":2,"num5":2,"num6":2,"num7":2,"num8":2,"num9":2,"num10":2,"num11":2}],"ExtraCost":{"num1":1,"num2":1,"num3":1,"num4":1,"num5":1,"num6":1,"num7":1,"num8":1,"num9":1},"description":"这是一段说明文本"} |
| | | SystemConfig systemConfig = systemConfigService.selectOne(new EntityWrapper<SystemConfig>().eq("type", 5)); |
| | | JSONObject jsonObject = JSON.parseObject(systemConfig.getContent()); |
| | | JSONArray chargeStandard = jsonObject.getJSONArray("ChargeStandard"); |
| | | SimpleDateFormat sdf = new SimpleDateFormat("HHmm"); |
| | | Integer integer = Integer.valueOf(sdf.format(new Date())); |
| | | for (int i = 0; i < chargeStandard.size(); i++) { |
| | | boolean b = true; |
| | | Date date = new Date(); |
| | | for (int i = 1; i < chargeStandard.size(); i++) {//各种时间段 |
| | | JSONObject jsonObject1 = chargeStandard.getJSONObject(i); |
| | | String num1 = jsonObject1.getString("num1"); |
| | | String num2 = jsonObject1.getString("num2"); |
| | | num1 = num1.replaceAll(":", ""); |
| | | num2 = num2.replaceAll(":", ""); |
| | | JSONArray num3 = jsonObject1.getJSONArray("num3");//起步里程 |
| | | |
| | | Double num3 = jsonObject1.getDouble("num3"); |
| | | Double num4 = jsonObject1.getDouble("num4"); |
| | | Double num5 = jsonObject1.getDouble("num5"); |
| | | Double num6 = jsonObject1.getDouble("num6"); |
| | | if(integer >= Integer.valueOf(num1) && integer < Integer.valueOf(num2)){ |
| | | startPriceWarpper.setStartPrice(num4); |
| | | startPriceWarpper.setStartDistance(num3); |
| | | startPriceWarpper.setExcessMileageUnitPrice(num6); |
| | | startPriceWarpper.setOvermileage(num5); |
| | | break; |
| | | String[] split = num1.split(":"); |
| | | Calendar s = Calendar.getInstance(); |
| | | s.setTime(date); |
| | | s.set(Calendar.HOUR_OF_DAY, Integer.valueOf(split[0])); |
| | | s.set(Calendar.MINUTE, Integer.valueOf(split[1])); |
| | | s.set(Calendar.SECOND, 0); |
| | | |
| | | split = num2.split(":"); |
| | | Calendar e = Calendar.getInstance(); |
| | | e.setTime(date); |
| | | e.set(Calendar.HOUR_OF_DAY, Integer.valueOf(split[0])); |
| | | e.set(Calendar.MINUTE, Integer.valueOf(split[1])); |
| | | e.set(Calendar.SECOND, 0); |
| | | |
| | | if(date.getTime() >= s.getTimeInMillis() && date.getTime() < e.getTimeInMillis()){ |
| | | b = false; |
| | | for (int j = 0; j < num3.size(); j++) { |
| | | JSONObject jsonObject2 = num3.getJSONObject(j); |
| | | Double num1_1 = jsonObject2.getDouble("num1"); |
| | | Double num2_1 = jsonObject2.getDouble("num2"); |
| | | Double num3_1 = jsonObject2.getDouble("num3"); |
| | | startPriceWarpper.setStartPrice(num3_1); |
| | | startPriceWarpper.setStartDistance(num1_1); |
| | | break; |
| | | } |
| | | } |
| | | } |
| | | |
| | | if(b){//默认配置 |
| | | JSONObject jsonObject1 = chargeStandard.getJSONObject(0); |
| | | JSONArray num3 = jsonObject1.getJSONArray("num3");//起步里程 |
| | | for (int j = 0; j < num3.size(); j++) { |
| | | JSONObject jsonObject2 = num3.getJSONObject(j); |
| | | Double num1_1 = jsonObject2.getDouble("num1"); |
| | | Double num2_1 = jsonObject2.getDouble("num2"); |
| | | Double num3_1 = jsonObject2.getDouble("num3"); |
| | | startPriceWarpper.setStartPrice(num3_1); |
| | | startPriceWarpper.setStartDistance(num1_1); |
| | | } |
| | | } |
| | | startPriceWarpper.setDescription(null == html ? "" : html.getHtml()); |