Commit bcf1dcf2439d7c37c55a87ca5c3c18081caa76cf
1 parent
ca3ef82c
油量。。
Showing
6 changed files
with
156 additions
and
24 deletions
src/main/java/com/bsth/controller/oil/YlbController.java
| ... | ... | @@ -62,6 +62,18 @@ public class YlbController extends BaseController<Ylb, Integer>{ |
| 62 | 62 | return list; |
| 63 | 63 | } |
| 64 | 64 | |
| 65 | + | |
| 66 | + @RequestMapping(value = "/saveYlbList",method = RequestMethod.GET) | |
| 67 | + public Map<String, Object> saveYlbList(@RequestParam Map<String, Object> map){ | |
| 68 | + Map<String, Object> list=new HashMap<String, Object>(); | |
| 69 | + try { | |
| 70 | + list = yblService.saveYlbList(map); | |
| 71 | + } catch (Exception e) { | |
| 72 | + // TODO Auto-generated catch block | |
| 73 | + e.printStackTrace(); | |
| 74 | + } | |
| 75 | + return list; | |
| 76 | + } | |
| 65 | 77 | /** |
| 66 | 78 | * 拆分油量 |
| 67 | 79 | * @param map |
| ... | ... | @@ -69,7 +81,12 @@ public class YlbController extends BaseController<Ylb, Integer>{ |
| 69 | 81 | */ |
| 70 | 82 | @RequestMapping(value = "/sort",method = RequestMethod.GET) |
| 71 | 83 | public Map<String, Object> sort(@RequestParam Map<String, Object> map){ |
| 72 | - Map<String, Object> list=yblService.sort(map); | |
| 84 | + Map<String, Object> list=new HashMap<String, Object>(); | |
| 85 | + try { | |
| 86 | + list=yblService.sort(map); | |
| 87 | + } catch (Exception e) { | |
| 88 | + // TODO: handle exception | |
| 89 | + } | |
| 73 | 90 | return list; |
| 74 | 91 | } |
| 75 | 92 | |
| ... | ... | @@ -97,7 +114,12 @@ public class YlbController extends BaseController<Ylb, Integer>{ |
| 97 | 114 | */ |
| 98 | 115 | @RequestMapping(value = "/checkYl",method = RequestMethod.GET) |
| 99 | 116 | public Map<String, Object> checkYl(@RequestParam Map<String, Object> map){ |
| 100 | - Map<String, Object> list=yblService.checkYl(map); | |
| 117 | + Map<String, Object> list=new HashMap<String, Object>(); | |
| 118 | + try { | |
| 119 | + list=yblService.checkYl(map); | |
| 120 | + } catch (Exception e) { | |
| 121 | + // TODO: handle exception | |
| 122 | + } | |
| 101 | 123 | return list; |
| 102 | 124 | } |
| 103 | 125 | ... | ... |
src/main/java/com/bsth/entity/oil/Ylb.java
src/main/java/com/bsth/repository/oil/YlbRepository.java
| ... | ... | @@ -98,4 +98,16 @@ public interface YlbRepository extends BaseRepository<Ylb, Integer>{ |
| 98 | 98 | + " and s.xlbm like %?4% " |
| 99 | 99 | + " and s.nbbm in ?5 ") |
| 100 | 100 | List<Ylb> listYlb(String rq, String gsbm,String fgsbm,String xlbm,List<String> listNbbm); |
| 101 | + | |
| 102 | + | |
| 103 | + @Transactional | |
| 104 | + @Modifying | |
| 105 | + @Query(value="UPDATE bsth_c_ylb SET " + | |
| 106 | + " jzyl = ?2, " + | |
| 107 | + " sh = ?3," + | |
| 108 | + " shyy = ?4," + | |
| 109 | + " ns = ?5," + | |
| 110 | + " rylx = ?6" + | |
| 111 | + " WHERE id = ?1", nativeQuery=true) | |
| 112 | + public void ylbUpdate(Integer id,double jzyl,double sh,String shyy,double ns,String rylx); | |
| 101 | 113 | } | ... | ... |
src/main/java/com/bsth/service/oil/YlbService.java
| ... | ... | @@ -8,12 +8,13 @@ import com.bsth.service.BaseService; |
| 8 | 8 | |
| 9 | 9 | public interface YlbService extends BaseService<Ylb, Integer>{ |
| 10 | 10 | Map<String, Object> obtain(Map<String, Object> map) throws Exception; |
| 11 | + Map<String, Object> saveYlbList(Map<String, Object> map) throws Exception; | |
| 11 | 12 | String obtainDsq() throws Exception; |
| 12 | - Map<String, Object> sort(Map<String, Object> map); | |
| 13 | + Map<String, Object> sort(Map<String, Object> map) throws Exception; | |
| 13 | 14 | |
| 14 | 15 | Map<String, Object> outAndIn(Map<String, Object> map) throws Exception; |
| 15 | 16 | |
| 16 | - Map<String, Object> checkYl(Map<String, Object> map); | |
| 17 | + Map<String, Object> checkYl(Map<String, Object> map) throws Exception; | |
| 17 | 18 | |
| 18 | 19 | Map<String, Object> sumYlb(Map<String, Object> map); |
| 19 | 20 | ... | ... |
src/main/java/com/bsth/service/oil/impl/YlbServiceImpl.java
| ... | ... | @@ -15,6 +15,7 @@ import java.util.Map; |
| 15 | 15 | |
| 16 | 16 | import javax.transaction.Transactional; |
| 17 | 17 | |
| 18 | +import org.apache.commons.lang3.StringEscapeUtils; | |
| 18 | 19 | import org.slf4j.Logger; |
| 19 | 20 | import org.slf4j.LoggerFactory; |
| 20 | 21 | import org.springframework.beans.factory.annotation.Autowired; |
| ... | ... | @@ -24,6 +25,8 @@ import org.springframework.jdbc.core.JdbcTemplate; |
| 24 | 25 | import org.springframework.jdbc.core.RowMapper; |
| 25 | 26 | import org.springframework.stereotype.Service; |
| 26 | 27 | |
| 28 | +import com.alibaba.fastjson.JSONArray; | |
| 29 | +import com.alibaba.fastjson.JSONObject; | |
| 27 | 30 | import com.bsth.common.ResponseCode; |
| 28 | 31 | import com.bsth.data.BasicData; |
| 29 | 32 | import com.bsth.entity.Cars; |
| ... | ... | @@ -525,7 +528,7 @@ public class YlbServiceImpl extends BaseServiceImpl<Ylb,Integer> implements YlbS |
| 525 | 528 | */ |
| 526 | 529 | @Transactional |
| 527 | 530 | @Override |
| 528 | - public Map<String, Object> sort(Map<String, Object> map) { | |
| 531 | + public Map<String, Object> sort(Map<String, Object> map) throws Exception{ | |
| 529 | 532 | // TODO Auto-generated method stub |
| 530 | 533 | Map<String, Object> newMap = new HashMap<String, Object>(); |
| 531 | 534 | SimpleDateFormat sdf =new SimpleDateFormat("yyyy-MM-dd"); |
| ... | ... | @@ -663,6 +666,7 @@ public class YlbServiceImpl extends BaseServiceImpl<Ylb,Integer> implements YlbS |
| 663 | 666 | } catch (Exception e) { |
| 664 | 667 | newMap.put("status", ResponseCode.ERROR); |
| 665 | 668 | logger.error("save erro.", e); |
| 669 | + throw e; | |
| 666 | 670 | } |
| 667 | 671 | return newMap; |
| 668 | 672 | } |
| ... | ... | @@ -674,7 +678,7 @@ public class YlbServiceImpl extends BaseServiceImpl<Ylb,Integer> implements YlbS |
| 674 | 678 | */ |
| 675 | 679 | @Transactional |
| 676 | 680 | @Override |
| 677 | - public Map<String, Object> checkYl(Map<String, Object> map) { | |
| 681 | + public Map<String, Object> checkYl(Map<String, Object> map) throws Exception{ | |
| 678 | 682 | Map<String, Object> newMap=new HashMap<String,Object>(); |
| 679 | 683 | // String xlbm=""; |
| 680 | 684 | // if(map.get("xlbm_like")!=null){ |
| ... | ... | @@ -918,8 +922,9 @@ public class YlbServiceImpl extends BaseServiceImpl<Ylb,Integer> implements YlbS |
| 918 | 922 | String clbm=objectLists.get(i)[0].toString(); |
| 919 | 923 | stringList.add(clbm); |
| 920 | 924 | } |
| 921 | - | |
| 922 | - listYlb=repository.listYlb(rq, gsbm, fgsbm, xlbm, stringList); | |
| 925 | + if(stringList.size()>0){ | |
| 926 | + listYlb=repository.listYlb(rq, gsbm, fgsbm, xlbm, stringList); | |
| 927 | + } | |
| 923 | 928 | }else{ |
| 924 | 929 | List<Object[]> objectLists=repository.checkNbmmNum(rq, gsbm, fgsbm, xlbm,nbbm); |
| 925 | 930 | for (int i = 0; i < objectLists.size(); i++) { |
| ... | ... | @@ -938,12 +943,53 @@ public class YlbServiceImpl extends BaseServiceImpl<Ylb,Integer> implements YlbS |
| 938 | 943 | } |
| 939 | 944 | } |
| 940 | 945 | } |
| 941 | - listYlb=repository.listYlb(rq, gsbm, fgsbm, xlbm, stringList); | |
| 946 | + if(stringList.size()>0){ | |
| 947 | + listYlb=repository.listYlb(rq, gsbm, fgsbm, xlbm, stringList); | |
| 948 | + } | |
| 942 | 949 | } |
| 943 | 950 | } |
| 944 | 951 | |
| 945 | 952 | return listYlb; |
| 946 | 953 | } |
| 947 | 954 | |
| 955 | + @Transactional | |
| 956 | + @Override | |
| 957 | + public Map<String, Object> saveYlbList(Map<String, Object> map) throws Exception { | |
| 958 | + // TODO Auto-generated method stub | |
| 959 | + Map<String, Object> newMap=new HashMap<String,Object>(); | |
| 960 | + try{ | |
| 961 | + String json =StringEscapeUtils.unescapeHtml4(map.get("ylbList").toString()); | |
| 962 | + JSONArray jsonArray=JSONArray.parseArray(json); | |
| 963 | + JSONObject jsonObject; | |
| 964 | + | |
| 965 | + for (int i = 0; i < jsonArray.size(); i++) { | |
| 966 | +// Ylb t=new Ylb(); | |
| 967 | + jsonObject=jsonArray.getJSONObject(i); | |
| 968 | + | |
| 969 | + Double jzyl =jsonObject.getDoubleValue("jzyl"); | |
| 970 | + Double sh =jsonObject.getDoubleValue("sh"); | |
| 971 | + String shyy =jsonObject.getString("shyy"); | |
| 972 | + Double ns = jsonObject.getDoubleValue("ns"); | |
| 973 | + String rylx =jsonObject.getString("rylx"); | |
| 974 | + Integer id =jsonObject.getInteger("id"); | |
| 975 | + /*t.setJzyl(jzyl); | |
| 976 | + t.setSh(sh); | |
| 977 | + t.setShyy(shyy); | |
| 978 | + t.setNs(ns); | |
| 979 | + t.setRylx(rylx); | |
| 980 | + t.setId(jsonObject.getInteger("id"));*/ | |
| 981 | + repository.ylbUpdate(id, jzyl, sh, shyy, ns, rylx); | |
| 982 | + } | |
| 983 | +// List<Map<String, Object>> list=(List<Map<String, Object>>) map.get("ylbList"); | |
| 984 | + | |
| 985 | + newMap.put("status", ResponseCode.SUCCESS); | |
| 986 | + }catch(Exception e){ | |
| 987 | + newMap.put("status", ResponseCode.ERROR); | |
| 988 | + logger.error("save erro.", e); | |
| 989 | + throw e; | |
| 990 | + } | |
| 991 | + return newMap; | |
| 992 | + } | |
| 993 | + | |
| 948 | 994 | |
| 949 | 995 | } | ... | ... |
src/main/resources/static/pages/oil/list_ph.html
| ... | ... | @@ -23,7 +23,10 @@ |
| 23 | 23 | <a class="btn btn-circle blue" href="add.html" data-pjax><i class="fa fa-plus"></i> 添加</a> |
| 24 | 24 | <button type="button" class="btn btn-circle blue" id="removeButton"><i class="fa fa-trash-o"></i> 删除</button> |
| 25 | 25 | <button type="button" class="btn btn-circle blue" id="sortButton"><i class="fa fa-minus-square"></i> |
| 26 | - 拆分/保存 | |
| 26 | + 拆分 | |
| 27 | + </button> | |
| 28 | + <button type="button" class="btn btn-circle blue" id="saveButton"><i class="fa fa-check-circle"></i> | |
| 29 | + 保存 | |
| 27 | 30 | </button> |
| 28 | 31 | <!-- <button type="button" class="btn btn-circle red" disabled="disabled" id="removeButton"><i class="fa fa-trash"></i> 删除用户</button> --> |
| 29 | 32 | <div class="btn-group"> |
| ... | ... | @@ -187,7 +190,7 @@ |
| 187 | 190 | {{each list as obj i}} |
| 188 | 191 | <tr> |
| 189 | 192 | <td style="vertical-align: middle;"> |
| 190 | - <input type="radio" name="id" class="group-checkable icheck" data-id="{{obj.id}}"> | |
| 193 | + <input type="checkbox" name="id" class="group-checkable icheck" data-id="{{obj.id}}"> | |
| 191 | 194 | </td> |
| 192 | 195 | |
| 193 | 196 | <td> |
| ... | ... | @@ -212,18 +215,23 @@ |
| 212 | 215 | {{obj.czyl}} |
| 213 | 216 | </td> |
| 214 | 217 | <td> |
| 215 | - <a data-id="{{obj.id}}" href="javascript:;" class="in_carpark_jzyl"> | |
| 216 | - {{obj.jzyl}} | |
| 217 | - </a> | |
| 218 | + <input data-id="{{obj.id}}" href="javascript:;" class="in_carpark_jzyl" | |
| 219 | +type="text" value=" {{obj.jzyl}}" style=" width:40px" onkeyup="this.value=this.value.replace(/[^(\d||/.)]/g,'')" | |
| 220 | +onafterpaste="this.value=this.value.replace(/[^(\d||/.)]/g,'')"> | |
| 218 | 221 | </td> |
| 219 | 222 | <td> |
| 220 | 223 | {{obj.yh}} |
| 221 | 224 | </td> |
| 222 | 225 | <td> |
| 223 | - {{obj.rylx}} | |
| 226 | + <select data-id="{{obj.id}}" class="in_carpark_rylx"> | |
| 227 | + <option value='0' {{if obj.rylx==0}} selected = 'selected' {{/if}}>0号柴油</option> | |
| 228 | + <option value='1' {{if obj.rylx==1}} selected = 'selected' {{/if}}>负10号柴油</option> | |
| 229 | + </select> | |
| 224 | 230 | </td> |
| 225 | 231 | <td> |
| 226 | - {{obj.ns}} | |
| 232 | + <input data-id="{{obj.id}}" href="javascript:;" | |
| 233 | +class="in_carpark_ns" type="text" value=" {{obj.ns}}" style=" width:40px" onkeyup="this.value=this.value.replace(/[^(\d||/.)]/g,'')" | |
| 234 | +onafterpaste="this.value=this.value.replace(/[^(\d||/.)]/g,'')"> | |
| 227 | 235 | </td> |
| 228 | 236 | <td> |
| 229 | 237 | <select data-id="{{obj.id}}" class="in_carpark_shyy"> |
| ... | ... | @@ -239,9 +247,9 @@ |
| 239 | 247 | </select> |
| 240 | 248 | </td> |
| 241 | 249 | <td> |
| 242 | - <a data-id="{{obj.id}}" href="javascript:;" class="in_carpark_shyl"> | |
| 243 | - {{obj.sh}} | |
| 244 | - </a> | |
| 250 | + <input data-id="{{obj.id}}" href="javascript:;" class="in_carpark_shyl" type="text" | |
| 251 | +value=" {{obj.sh}}" style=" width:40px" onkeyup="this.value=this.value.replace(/[^(\d||/.)]/g,'')" | |
| 252 | +onafterpaste="this.value=this.value.replace(/[^(\d||/.)]/g,'')" > | |
| 245 | 253 | </td> |
| 246 | 254 | <td> |
| 247 | 255 | {{obj.zlc}} |
| ... | ... | @@ -294,7 +302,49 @@ |
| 294 | 302 | layer.msg('请选择日期.'); |
| 295 | 303 | } |
| 296 | 304 | }); |
| 297 | - | |
| 305 | + | |
| 306 | + | |
| 307 | + //保存 | |
| 308 | + $("#saveButton").on('click',function(){ | |
| 309 | + var ylArray = []; | |
| 310 | + /* $('input.icheck:checked').each(function(){ | |
| 311 | + var map = {}; | |
| 312 | + var id=$(this).data('id'); | |
| 313 | + var jzyl=$('.in_carpark_jzyl[data-id='+id+']', '#ll_oil_list').html(); | |
| 314 | + var sh = $('.in_carpark_shyl[data-id='+id+']', '#ll_oil_list').html(); | |
| 315 | + var shyy = $('.in_carpark_shyy[data-id='+id+']', '#ll_oil_list').val(); | |
| 316 | + map['id']=id; | |
| 317 | + map['jzyl']=jzyl; | |
| 318 | + map['sh']=sh; | |
| 319 | + map['shyy']=shyy; | |
| 320 | + ylArray.push(map); | |
| 321 | + }) */ | |
| 322 | + | |
| 323 | + $('input.icheck').each(function(){ | |
| 324 | + var map = {}; | |
| 325 | + var id=$(this).data('id'); | |
| 326 | + var jzyl=$('.in_carpark_jzyl[data-id='+id+']', '#ll_oil_list').val(); | |
| 327 | + var sh = $('.in_carpark_shyl[data-id='+id+']', '#ll_oil_list').val(); | |
| 328 | + var shyy = $('.in_carpark_shyy[data-id='+id+']', '#ll_oil_list').val(); | |
| 329 | + var ns = $('.in_carpark_ns[data-id='+id+']', '#ll_oil_list').val(); | |
| 330 | + var rylx= $('.in_carpark_rylx[data-id='+id+']', '#ll_oil_list').val(); | |
| 331 | + map['id']=id; | |
| 332 | + map['jzyl']=jzyl; | |
| 333 | + map['sh']=sh; | |
| 334 | + map['shyy']=shyy; | |
| 335 | + map['ns']=ns; | |
| 336 | + map['rylx']=rylx; | |
| 337 | + ylArray.push(map); | |
| 338 | + }) | |
| 339 | + var params = {}; | |
| 340 | + params['ylbList']=JSON.stringify(ylArray); | |
| 341 | + var i = layer.load(2); | |
| 342 | + $get('/ylb/saveYlbList', params, function () { | |
| 343 | + layer.close(i); | |
| 344 | + var params1 =getParamsList(); | |
| 345 | + jsDoQuery(params1, true); | |
| 346 | + }); | |
| 347 | + }) | |
| 298 | 348 | //拆分 |
| 299 | 349 | $("#sortButton").on('click', function () { |
| 300 | 350 | if ($("#rq").val() != "") { |
| ... | ... | @@ -348,7 +398,7 @@ |
| 348 | 398 | |
| 349 | 399 | var page = 0, initPagination; |
| 350 | 400 | var icheckOptions = { |
| 351 | - radioClass: 'iradio_square-blue icheck', | |
| 401 | + radioClass: 'icheckbox_flat-blue', | |
| 352 | 402 | increaseArea: '20%' |
| 353 | 403 | } |
| 354 | 404 | |
| ... | ... | @@ -474,6 +524,7 @@ |
| 474 | 524 | |
| 475 | 525 | var l = layer.load(2); |
| 476 | 526 | $get('/ylb/ylbList', params, function (data) { |
| 527 | + | |
| 477 | 528 | $.each(data, function (i, obj) { |
| 478 | 529 | obj.rq = moment(obj.rq).format("YYYY-MM-DD"); |
| 479 | 530 | }); |
| ... | ... | @@ -493,8 +544,8 @@ |
| 493 | 544 | $("#sumYh").html(returns.yh); |
| 494 | 545 | $("#sumSh").html(returns.sh); |
| 495 | 546 | }); |
| 496 | - startOptJzylLink($('#ll_oil_list .in_carpark_jzyl')); | |
| 497 | - startOptShylLink($('#ll_oil_list .in_carpark_shyl')); | |
| 547 | +// startOptJzylLink($('#ll_oil_list .in_carpark_jzyl')); | |
| 548 | +// startOptShylLink($('#ll_oil_list .in_carpark_shyl')); | |
| 498 | 549 | }); |
| 499 | 550 | } |
| 500 | 551 | ... | ... |