GAT專案新需求:ETC管理增加查詢統計
需求:按車牌號HOST_NO分組合計CAR_PAY金額,最後合計所有金額,還要過濾出本月的時間
因為要顯示明細,不是真的group by分組,而是按車牌號排序
消費合計和合計則是這種格式,前臺需要這樣的格式方便展示:
{
"retCode":1,
"retMsg":"操作成功",
"list":[
{
"recordId":"20161201200445671015895",
"carEtcNo":"測試0002",
"carHostNO":"蘇AM10001",
"carStartEtcTime":"2017-04-01 17:43:50",
"carEndEtcTime":"2017-04-18 20:05:44",
"carLine":"三牌樓--古林公園111",
"carPay":10,
"carProvince":"320000",
"carProvinceDesc":"江蘇省"
},
{
"carPay":10,
"carProvinceDesc":"消費合計"
},
{
"recordId":"20161129180514209018381",
"carEtcNo":"1333333333",
"carHostNO":"蘇A2002",
"carStartEtcTime":"2017-04-02 17:43:50",
"carEndEtcTime":"2017-04-15 12:12:12",
"carLine":"中山門到漢中門",
"carPay":66,
"carProvince":"120000",
"carProvinceDesc":"天津市"
},
{
"recordId":"20161129180325044015371",
"carEtcNo":"1333333333",
"carHostNO":"蘇A2002",
"carStartEtcTime":"2017-04-02 17:43:50",
"carEndEtcTime":"2017-04-15 12:12:12",
"carLine":"中山門到漢中門",
"carPay":66,
"carProvince":"120000",
"carProvinceDesc":"天津市"
},
{
"recordId":"20161129175757881014238",
"carEtcNo":"1333333333",
"carHostNO":"蘇A2002",
"carStartEtcTime":"2017-04-02 17:43:50",
"carEndEtcTime":"2017-04-15 12:12:12",
"carLine":"中山門到漢中門",
"carPay":14,
"carProvince":"120000",
"carProvinceDesc":"天津市"
},
{
"carPay":146,
"carProvinceDesc":"消費合計"
},
{
"recordId":"20161129180513905010007",
"carEtcNo":"1222222222",
"carHostNO":"蘇A2001",
"carStartEtcTime":"2017-04-02 17:43:50",
"carEndEtcTime":"2017-04-15 12:12:12",
"carLine":"中山門到漢中門",
"carPay":88,
"carProvince":"120000",
"carProvinceDesc":"天津市"
},
{
"recordId":"20161129180309437011679",
"carEtcNo":"1222222222",
"carHostNO":"蘇A2001",
"carStartEtcTime":"2017-04-02 17:43:50",
"carEndEtcTime":"2017-04-15 12:12:12",
"carLine":"中山門到漢中門",
"carPay":55,
"carProvince":"120000",
"carProvinceDesc":"天津市"
},
{
"carPay":143,
"carProvinceDesc":"消費合計"
},
{
"recordId":"20170323192547109019398",
"carEtcNo":"ee94",
"carHostNO":"人a1002",
"carStartEtcTime":"2017-04-01 12:12:12",
"carEndEtcTime":"2017-04-15 12:12:12",
"carLine":"中山門到漢中門",
"carPay":16,
"carProvince":"120000",
"carProvinceDesc":"天津市"
},
{
"recordId":"20170323192547121011329",
"carEtcNo":"ee96",
"carHostNO":"人a1002",
"carStartEtcTime":"2017-04-03 12:12:12",
"carEndEtcTime":"2017-04-15 12:12:12",
"carLine":"中山門到漢中門",
"carPay":150,
"carProvince":"120000",
"carProvinceDesc":"天津市"
},
{
"recordId":"20170323192547128013962",
"carEtcNo":"ee97",
"carHostNO":"人a1002",
"carStartEtcTime":"2017-04-02 12:12:12",
"carEndEtcTime":"2017-04-15 12:12:12",
"carLine":"中山門到漢中門",
"carPay":100,
"carProvince":"120000",
"carProvinceDesc":"天津市"
},
{
"recordId":"20170323192547134010071",
"carEtcNo":"ee98",
"carHostNO":"人a1002",
"carStartEtcTime":"2017-04-05 12:12:12",
"carEndEtcTime":"2017-04-15 12:12:12",
"carLine":"中山門到漢中門",
"carPay":100,
"carProvince":"120000",
"carProvinceDesc":"天津市"
},
{
"recordId":"20170323192547140018430",
"carEtcNo":"ee99",
"carHostNO":"人a1002",
"carStartEtcTime":"2017-04-20 12:12:12",
"carEndEtcTime":"2017-04-25 12:12:12",
"carLine":"中山門到漢中門",
"carPay":100,
"carProvince":"120000",
"carProvinceDesc":"天津市"
},
{
"recordId":"20170323192547147016616",
"carEtcNo":"ee100",
"carHostNO":"人a1002",
"carStartEtcTime":"2017-04-01 12:12:12",
"carEndEtcTime":"2017-04-15 12:12:12",
"carLine":"中山門到漢中門",
"carPay":100,
"carProvince":"120000",
"carProvinceDesc":"天津市"
},
{
"recordId":"20170323192547115010841",
"carEtcNo":"ee95",
"carHostNO":"人a1002",
"carStartEtcTime":"2017-04-01 12:12:12",
"carEndEtcTime":"2017-04-15 12:12:12",
"carLine":"中山門到漢中門",
"carPay":100,
"carProvince":"120000",
"carProvinceDesc":"天津市"
},
{
"carPay":666,
"carProvinceDesc":"消費合計"
},
{
"recordId":"20161202101559495018075",
"carEtcNo":"333",
"carHostNO":"2900",
"carStartEtcTime":"2017-04-01 17:43:50",
"carEndEtcTime":"2017-04-15 12:12:12",
"carLine":"中山門到漢中門",
"carPay":44,
"carProvince":"120000",
"carProvinceDesc":"天津市"
},
{
"carPay":44,
"carProvinceDesc":"消費合計"
},
{
"recordId":"20161130111132840016135",
"carEtcNo":"2656",
"carHostNO":"15000",
"carStartEtcTime":"2017-04-02 17:43:50",
"carEndEtcTime":"2017-04-15 12:12:12",
"carLine":"中山門到漢中門",
"carPay":15,
"carProvince":"120000",
"carProvinceDesc":"天津市"
},
{
"carPay":15,
"carProvinceDesc":"消費合計"
},
{
"recordId":"20161202110607795014435",
"carEtcNo":"003",
"carHostNO":"14000",
"carStartEtcTime":"2017-04-02 17:43:50",
"carEndEtcTime":"2017-04-15 12:12:12",
"carLine":"中山門到漢中門",
"carPay":42,
"carProvince":"120000",
"carProvinceDesc":"天津市"
},
{
"carPay":42,
"carProvinceDesc":"消費合計"
},
{
"recordId":"20161130183025739012483",
"carEtcNo":"2",
"carHostNO":"1301",
"carStartEtcTime":"2017-04-01 17:43:50",
"carEndEtcTime":"2017-04-23 18:47:04",
"carLine":"中山門到漢中門",
"carPay":87,
"carProvince":"120000",
"carProvinceDesc":"天津市"
},
{
"carPay":87,
"carProvinceDesc":"消費合計"
},
{
"recordId":"20170221091233259012244",
"carEtcNo":"112233",
"carHostNO":"1010",
"carStartEtcTime":"2017-04-02 17:43:50",
"carEndEtcTime":"2017-04-23 18:47:04",
"carLine":"中山門到漢中門",
"carPay":25,
"carProvince":"230000",
"carProvinceDesc":"黑龍江省"
},
{
"carPay":25,
"carProvinceDesc":"消費合計"
},
{
"recordId":"20161202110501256014722",
"carEtcNo":"3",
"carHostNO":"0213",
"carStartEtcTime":"2017-04-01 17:43:50",
"carEndEtcTime":"2017-04-23 18:47:04",
"carLine":"中山門到漢中門",
"carPay":10,
"carProvince":"120000",
"carProvinceDesc":"天津市"
},
{
"carPay":10,
"carProvinceDesc":"消費合計"
},
{
"carEtcNo":"合計",
"carPay":1188
}
]
}
資料庫查出來的依然是明細:
只不過是在程式碼中拼出消費合計和合計的列
-------------------------------------------------------------------------------------------------------------------------------
下面看程式碼:
關鍵是要動態增加索引,這樣才可以在每個車牌號下增加消費合計的一列
@SuppressWarnings("unchecked")
@Override
public ListResp queryCarUseEtcListTotal(CarUseEtcListReq req) throws Exception{
ListResp resp = new ListResp();
List<CarUseEtcListResp> list = new ArrayList<CarUseEtcListResp>();
long begin = System.currentTimeMillis();
list = carUseEtcDAO.queryCarUseEtcListTotal(req);
//儲存有序的車牌號
List<String> listTemp = new ArrayList<String>();
//儲存車牌號,隨著list中的車牌號索引的增加而增加
List<String> noList = new ArrayList<String>();
if(Util.isNotEmpty(list)){
for(int i=0;i<list.size();i++){
if(!listTemp.contains(list.get(i).getCarHostNO())){
listTemp.add(list.get(i).getCarHostNO());
}
noList.add(list.get(i).getCarHostNO());
}
}
//總的合計
Double total = 0.0;
if(Util.isNotEmpty(listTemp)){
for (String cardNo : listTemp) {
//相同車牌號的消費合計
Double num = 0.0;
for(int i=0;i<list.size();i++){
CarUseEtcListResp one = list.get(i);
if(Util.isNotEmpty(one) && Util.isNotEmpty(one.getCarHostNO())){
if(one.getCarHostNO().equals(cardNo)){
num += one.getCarPay();
}
}
}
CarUseEtcListResp beanC = new CarUseEtcListResp();
//得到noList集合中車牌號的索引
Integer a = noList.lastIndexOf(cardNo);
//消費合計的金額
beanC.setCarPay(num);
//給前臺的文字"消費合計",頁面放在省份列表下了
//beanC.setCarProvince("消費合計");
beanC.setCarProvinceDesc("消費合計");
//在需要的索引下增加一列
list.add(a+1, beanC);
//noList集合也增加索引
noList.add(a+1,beanC.getCarHostNO());
//總的合計
total += num;
}
}
CarUseEtcListResp bean = new CarUseEtcListResp();
//給前臺的文字"合計",頁面放在ETC卡號列表下了
bean.setCarEtcNo("合計");
//合計的金額
bean.setCarPay(total);
list.add(list.size(),bean);
//System.out.println(sumCarPay + "," + total);
boolean isDebug = log.isDebugEnabled();
if(isDebug) {
log.debug("資料庫查詢耗時 " + (System.currentTimeMillis() - begin) + " ms");
}
if(!Util.isEmpty(list)){
begin = System.currentTimeMillis();
DictionaryUtil.translate(list);
resp.getList().addAll(list);
if(isDebug) {
log.debug("結果集轉換耗時 " + (System.currentTimeMillis() - begin) + " ms");
}
}
return resp;
}
時間引數沒傳值,預設查當月的:
時間引數傳值:
引數都傳值:
{
"retCode":1,
"retMsg":"操作成功",
"list":[
{
"recordId":"20161129180514209018381",
"carEtcNo":"1333333333",
"carHostNO":"蘇A2002",
"carStartEtcTime":"2017-04-02 17:43:50",
"carEndEtcTime":"2017-04-15 12:12:12",
"carLine":"中山門到漢中門",
"carPay":66,
"carProvince":"120000",
"carProvinceDesc":"天津市"
},
{
"recordId":"20161129180325044015371",
"carEtcNo":"1333333333",
"carHostNO":"蘇A2002",
"carStartEtcTime":"2017-04-02 17:43:50",
"carEndEtcTime":"2017-04-15 12:12:12",
"carLine":"中山門到漢中門",
"carPay":66,
"carProvince":"120000",
"carProvinceDesc":"天津市"
},
{
"recordId":"20161129175757881014238",
"carEtcNo":"1333333333",
"carHostNO":"蘇A2002",
"carStartEtcTime":"2017-04-02 17:43:50",
"carEndEtcTime":"2017-04-15 12:12:12",
"carLine":"中山門到漢中門",
"carPay":14,
"carProvince":"120000",
"carProvinceDesc":"天津市"
},
{
"carPay":146,
"carProvinceDesc":"消費合計"
},
{
"carEtcNo":"合計",
"carPay":146
}
]
}
開發完成後的頁面效果圖:
相關文章
- 哪些需求管理工具管理專案需求比較好?
- 新管理時代,如何制定專案管理計劃專案管理
- 電商發退貨後臺管理系統專案需求
- MVC + EFCore 專案實戰 - 數倉管理系統4 – 需求分解MVC
- 傳統專案管理VS敏捷專案管理專案管理敏捷
- PMP®|專案管理中需求管理做不好怎麼辦?專案管理
- 專案需求管理的五大過程
- 軟體專案管理 4.1.軟體需求管理過程專案管理
- 軟體專案管理 4.3.敏捷需求建模方法專案管理敏捷
- java版工程專案管理系統原始碼+系統管理+系統設定+專案管理Java專案管理原始碼
- 測試驅動專案設計需求迭代
- 專案管理中如何更好的控制客戶的需求?專案管理
- 專案管理中的需求變更分析和解決之道專案管理
- EasyWork專案管理系統專案管理
- 專案風險管理系統有哪些?分享11款主流專案管理系統專案管理
- 如何避免軟體開發專案中的需求管理陷阱?
- Linux系統環境變數檔案解析(etc/profile ,/etc/bashrc ,~/.bash_profile)Linux變數
- 《系統整合專案管理》第九章 專案成本管理專案管理
- 資訊系統專案管理系列之三:專案管理過程專案管理
- 資訊系統專案管理系列之五:專案整體管理專案管理
- 資訊系統專案管理系列之六:專案範圍管理專案管理
- 專案微管理35 - 系統
- 微專案:名片管理系統
- 專案管理系統中的任務和專案專案管理
- java版工程專案管理系統原始碼+系統管理+系統設定+專案管理+合同管理+二次開發Java專案管理原始碼
- SAP MM 為MB51報表增加查詢欄位
- 研發管理案例-專案管理平臺-需求任務變更歷史分析專案管理
- 諮詢行業專案管理軟體推薦行業專案管理
- 面對需求的頻繁變更,如何做好專案管理專案管理
- 處理需求變更:軟體專案管理的必備技能專案管理
- 專案範圍管理不受控,需求不斷蔓延,怎麼辦?
- 如何使用專案管理設計專案五個階段專案管理
- 系統整合專案管理師和高階專案管理師考試心得專案管理
- 專案管理系統使用指南專案管理
- 測試專案管理系統 — TPA專案管理
- 鴻仁科研專案管理系統專案管理
- 什麼是專案管理系統?專案管理
- 工程師計劃3 -> 專案管理2 | 專案組織與團隊管理工程師專案管理
- zoho projects 專案管理軟體新亮點Project專案管理