Commit 149eefc05683e06c47ac55bbcdc49cf99524cfbf

Authored by 潘钊
1 parent fc664e40

update...

src/main/java/com/bsth/data/abnormal/MainAbnormalClient.java
... ... @@ -105,4 +105,23 @@ public class MainAbnormalClient {
105 105 public AbnormalEntity qiandao(ScheduleInOut sio, JsyAttendance att) {
106 106 return attendanceHandler.qiandao(sio, att);
107 107 }
  108 +
  109 + /**
  110 + * 调整人车后更新异常信息
  111 + * @param sio
  112 + * @return
  113 + */
  114 + public List<AbnormalEntity> updateTzrc(ScheduleInOut sio) {
  115 + List<AbnormalEntity> aes = new ArrayList<>();
  116 + AbnormalEntity ae;
  117 +
  118 + ae = attendanceHandler.updateCp(sio);
  119 + if(null != ae)
  120 + aes.add(ae);
  121 +
  122 + ae = inOutHandler.updateCc(sio);
  123 + if(null != ae)
  124 + aes.add(ae);
  125 + return aes;
  126 + }
108 127 }
... ...
src/main/java/com/bsth/data/abnormal/handler/AttendanceHandler.java
... ... @@ -110,4 +110,23 @@ public class AttendanceHandler {
110 110 schIdMap.remove(ae.getSchId());
111 111 return ae;
112 112 }
  113 +
  114 + public AbnormalEntity updateCp(ScheduleInOut sio) {
  115 + AbnormalEntity ae = schIdMap.get(sio.getId());
  116 + if(null == ae)
  117 + return null;
  118 +
  119 + if(!sio.getJsy().equals(ae.getJsy()))
  120 + ae.setJsy(sio.getJsy());
  121 +
  122 + if(null != sio.getAttSjTime()){
  123 + ae.setHandlerTime(sio.getAttSjTime());
  124 + ae.setHandlerUser("system");
  125 + ae.setHandlerDes(fmtHHmm.print(sio.getAttSjTime()) + " 一体机签到");
  126 +
  127 + sio.reCalcAnStatus();
  128 + schIdMap.remove(ae.getSchId());
  129 + }
  130 + return ae;
  131 + }
113 132 }
... ...
src/main/java/com/bsth/data/abnormal/handler/InOutHandler.java
... ... @@ -96,4 +96,23 @@ public class InOutHandler {
96 96 schIdMap.remove(ae.getSchId());
97 97 return ae;
98 98 }
  99 +
  100 + public AbnormalEntity updateCc(ScheduleInOut sio) {
  101 + AbnormalEntity ae = schIdMap.get(sio.getId());
  102 + if(null == ae)
  103 + return null;
  104 +
  105 + if(!sio.getNbbm().equals(ae.getNbbm()))
  106 + ae.setNbbm(sio.getNbbm());
  107 +
  108 + if(null != sio.getOutTimeRfid()){
  109 + ae.setHandlerTime(sio.getOutTimeRfid());
  110 + ae.setHandlerUser("system");
  111 + ae.setHandlerDes("RFID信号出场," + fmtHHmm.print(sio.getOutTimeRfid()));
  112 +
  113 + sio.reCalcAnStatus();
  114 + schIdMap.remove(ae.getSchId());
  115 + }
  116 + return ae;
  117 + }
99 118 }
... ...
src/main/java/com/bsth/data/attendance/RealAttendaceHandler.java
... ... @@ -4,11 +4,17 @@ import com.bsth.data.abnormal.MainAbnormalClient;
4 4 import com.bsth.data.abnormal.entity.AbnormalEntity;
5 5 import com.bsth.data.attendance.entity.JsyAttendance;
6 6 import com.bsth.data.schedule.dto.ScheduleInOut;
  7 +import com.bsth.data.schedule.real.ScheduleComparator;
7 8 import com.bsth.data.schedule.real.ScheduleDataBuffer;
8 9 import com.bsth.websocket.handler.SendUtils;
  10 +import com.google.common.collect.ArrayListMultimap;
9 11 import org.springframework.beans.factory.annotation.Autowired;
10 12 import org.springframework.stereotype.Component;
11 13  
  14 +import java.util.Collections;
  15 +import java.util.Comparator;
  16 +import java.util.List;
  17 +
12 18 /**
13 19 * 实时签到退数据管理
14 20 * Created by panzhao on 2018/3/27.
... ... @@ -23,9 +29,19 @@ public class RealAttendaceHandler {
23 29 MainAbnormalClient mainAbnormalClient;
24 30  
25 31 /**
  32 + * K:工号 V:签到信息
  33 + */
  34 + private static ArrayListMultimap<String, JsyAttendance> qdListMap;
  35 +
  36 + static {
  37 + qdListMap = ArrayListMultimap.create();
  38 + }
  39 +
  40 + /**
26 41 * 签到
27 42 */
28 43 public void attendace(JsyAttendance att){
  44 + qdListMap.put(att.getUserId(), att);
29 45 //驾驶员的出场计划
30 46 ScheduleInOut sio = ScheduleDataBuffer.getCurrExecOut(att.getCompany(), att.getUserId(), att.getAt());
31 47  
... ... @@ -40,4 +56,63 @@ public class RealAttendaceHandler {
40 56 //通知页面
41 57 sendUtils.scheduleAttendace(sio, ae);
42 58 }
  59 +
  60 + /**
  61 + * 重新匹配驾驶员报到时间
  62 + * @param jGh1
  63 + * @param jGh2
  64 + */
  65 + public void reCalcOutSignal(String company, String jGh1, String jGh2) {
  66 + //获取驾驶员的出场计划
  67 + List<ScheduleInOut> arrayA = ScheduleDataBuffer.getOutsByUserId(company, jGh1)
  68 + , arrayB = ScheduleDataBuffer.getOutsByUserId(company, jGh2);
  69 +
  70 + reCalcOutSignal(arrayA);
  71 + reCalcOutSignal(arrayB);
  72 + }
  73 +
  74 + private void reCalcOutSignal(List<ScheduleInOut> list) {
  75 + if (null == list || list.size() == 0)
  76 + return;
  77 +
  78 + //清空班次上的签到时间
  79 + for (ScheduleInOut sio : list)
  80 + sio.setAttSjTime(null);
  81 +
  82 + List<JsyAttendance> atts = qdListMap.get(list.get(0).getjGh());
  83 +
  84 + if (null == atts || atts.size() == 0)
  85 + return;
  86 +
  87 + Collections.sort(list, new ScheduleComparator());
  88 + Collections.sort(atts, new AttendanceComp());
  89 +
  90 + for (JsyAttendance att : atts) {
  91 +
  92 + for (ScheduleInOut sio : list)
  93 + matchJh2Sj(att, sio);
  94 + }
  95 + }
  96 +
  97 + /**
  98 + * 匹配计划和实际
  99 + *
  100 + * @param att
  101 + * @param sio
  102 + */
  103 + private void matchJh2Sj(JsyAttendance att, ScheduleInOut sio) {
  104 + if(Math.abs(att.getAttTime().getTime() - sio.getAttJhTime()) > ScheduleDataBuffer.SPACE_THRESHOLD)
  105 + return;//2小时内
  106 +
  107 + if (null == sio.getOutTimeRfid())
  108 + sio.setAttSjTime(att.getAttTime().getTime());
  109 + }
  110 +
  111 + class AttendanceComp implements Comparator<JsyAttendance>{
  112 +
  113 + @Override
  114 + public int compare(JsyAttendance o1, JsyAttendance o2) {
  115 + return (int) (o1.getAttTime().getTime() - o2.getAttTime().getTime());
  116 + }
  117 + }
43 118 }
... ...
src/main/java/com/bsth/data/in_out/RealInoutHandler.java
... ... @@ -156,7 +156,8 @@ public class RealInoutHandler {
156 156 */
157 157 public void reCalcOutSignal(String name1, String nbbm2) {
158 158 //获取车辆的出场计划
159   - List<ScheduleInOut> arrayA = ScheduleDataBuffer.getByNbbm(name1), arrayB = ScheduleDataBuffer.getByNbbm(nbbm2);
  159 + List<ScheduleInOut> arrayA = ScheduleDataBuffer.getByNbbm(name1)
  160 + , arrayB = ScheduleDataBuffer.getByNbbm(nbbm2);
160 161  
161 162 reCalcOutSignal(arrayA);
162 163 reCalcOutSignal(arrayB);
... ... @@ -197,6 +198,9 @@ public class RealInoutHandler {
197 198 * @param sio
198 199 */
199 200 private void matchJh2Sj(CarInOutEntity cio, ScheduleInOut sio) {
  201 + if(Math.abs(cio.getT() - sio.getDfsjT()) > ScheduleDataBuffer.SPACE_THRESHOLD)
  202 + return;//2小时内
  203 +
200 204 if (null == sio.getOutTimeRfid()
201 205 || outSignalMatch(sio, cio))
202 206 sio.setOutTimeRfid(cio.getT());
... ...
src/main/java/com/bsth/data/schedule/real/ScheduleDataBuffer.java
... ... @@ -2,6 +2,8 @@ package com.bsth.data.schedule.real;
2 2  
3 3 import com.alibaba.fastjson.JSON;
4 4 import com.bsth.Application;
  5 +import com.bsth.data.abnormal.MainAbnormalClient;
  6 +import com.bsth.data.attendance.RealAttendaceHandler;
5 7 import com.bsth.data.basic.line.LineDataBuffer;
6 8 import com.bsth.data.in_out.RealInoutHandler;
7 9 import com.bsth.data.schedule.dto.ScheduleInOut;
... ... @@ -45,7 +47,7 @@ public class ScheduleDataBuffer implements CommandLineRunner {
45 47 //排序器
46 48 static ScheduleComparator schComparator = new ScheduleComparator();
47 49  
48   - static final int SPACE_THRESHOLD = 1000 * 60 * 60 * 2;
  50 + public static final int SPACE_THRESHOLD = 1000 * 60 * 60 * 2;
49 51  
50 52 static Logger logger = LoggerFactory.getLogger(ScheduleDataBuffer.class);
51 53 @Autowired
... ... @@ -53,6 +55,11 @@ public class ScheduleDataBuffer implements CommandLineRunner {
53 55  
54 56 @Autowired
55 57 RealInoutHandler realInoutHandler;
  58 + @Autowired
  59 + RealAttendaceHandler realAttendaceHandler;
  60 +
  61 + @Autowired
  62 + MainAbnormalClient mainAbnormalClient;
56 63  
57 64 private final static String TYPE_OUT = "out";
58 65 private final static String TYPE_IN = "in";
... ... @@ -223,14 +230,18 @@ public class ScheduleDataBuffer implements CommandLineRunner {
223 230 boolean isCCar = !old.getNbbm().equals(now.getNbbm());//换车
224 231  
225 232 if (isCPerson) {
  233 + String oldJgh = old.getjGh();
  234 + old.setJsy(now.getJsy());
  235 + old.setjGh(now.getjGh());
226 236 //重新匹配人员计划和实际报到
  237 + realAttendaceHandler.reCalcOutSignal(old.getGsbm(), oldJgh, now.getjGh());
227 238 }
228 239  
229 240 if (isCCar) {
230   - String oldName = old.getNbbm();
  241 + String oldNbbm = old.getNbbm();
231 242 old.setNbbm(now.getNbbm());
232 243 //重新匹配车辆计划和实际出场
233   - realInoutHandler.reCalcOutSignal(oldName, now.getNbbm());
  244 + realInoutHandler.reCalcOutSignal(oldNbbm, now.getNbbm());
234 245 }
235 246 }
236 247  
... ...
src/main/java/com/bsth/service/schedule/impl/ScheduleServiceImpl.java
... ... @@ -192,12 +192,17 @@ public class ScheduleServiceImpl implements ScheduleService {
192 192  
193 193 rs = JSON.parseObject(sb.toString());
194 194  
  195 +
195 196 if("SUCCESS".equals(rs.get("status"))){
196   - JSONArray array = rs.getJSONArray("list");
197   - int size = array.size();
198   - for(int i=0; i < size;i ++){
199   - scheduleDataBuffer.put(JSON.toJavaObject(array.getJSONObject(i), ScheduleInOut.class));
  197 + List<ScheduleInOut> list = JSONArray.parseArray(rs.getString("list"), ScheduleInOut.class);//有更新的出场班次
  198 + List<AbnormalEntity> aes = new ArrayList<>();//有更新的异常信息
  199 + for(ScheduleInOut sio : list){
  200 + scheduleDataBuffer.put(sio);
  201 + aes.addAll(mainAbnormalClient.updateTzrc(sio));
200 202 }
  203 +
  204 + rs.put("list", list);
  205 + rs.put("aes", aes);
201 206 }
202 207  
203 208 //重新按人车分组数据
... ...
src/main/resources/static/assets/css/main.css
... ... @@ -4,6 +4,11 @@ html, body, .ct-container {
4 4 font-family: "Arial","Microsoft YaHei","黑体","宋体",sans-serif;
5 5 }
6 6  
  7 +html body .uk-alert-danger {
  8 + background: #ffe5ea;
  9 + color: #ff0030;
  10 +}
  11 +
7 12 /*----------用来移除date向下箭头----------*/
8 13 input[type="date"]::-webkit-calendar-picker-indicator {
9 14 display: none;
... ...
src/main/resources/static/pages/abnormal/fragments/type_0/h_cont_hrcc.html
1 1 <div class="handler_cont_hrcc_wrap tzrc_table_wrap">
  2 +
  3 + <div class="uk-alert-danger disabled_alter" style="display: none;" uk-alert>
  4 + <a class="uk-alert-close" uk-close></a>
  5 + <p><i uk-icon="info"></i>&nbsp;集调班次显示该车辆已出场,你不能再对人车进行调整。</p>
  6 + </div>
  7 +
  8 +
2 9 <table class="uk-table uk-table-small uk-table-divider curr_out_plan_table">
3 10 <thead>
4 11 <tr>
... ... @@ -83,7 +90,7 @@
83 90 <script>
84 91 (function () {
85 92  
86   - var wrap = '.handler_cont_hrcc_wrap', ae, inoutSch;
  93 + var wrap = '.handler_cont_hrcc_wrap', ae, inoutSch,modalId;
87 94  
88 95  
89 96 $(wrap).on('init', function (e, data) {
... ... @@ -92,6 +99,7 @@
92 99 return;
93 100  
94 101 ae = data.ae;
  102 + modalId = data.modalId
95 103  
96 104 inoutSch = gb_os_card.findByLineCode(ae.lineCode)[ae.schId];
97 105 $('.curr_out_plan_table>tbody', wrap).html(template('a_h_hrcc_out_tbody-temp', {obj: inoutSch}));
... ... @@ -105,6 +113,21 @@
105 113 ct_autocompleter.initBus($('#nbbmAutoCompleter', wrap));
106 114  
107 115 $(this).attr('data-init', 1);
  116 +
  117 + //是否禁用
  118 + if(inoutSch.status > 0){
  119 + $('.disabled_alter', wrap).show();
  120 + $('.tzrc_form_card>form input', wrap)
  121 + .attr('disabled', 'disabled')
  122 + .each(function () {
  123 + this.checked=false;
  124 + });
  125 + $('.submit-btn',wrap).attr('disabled', 'disabled');
  126 + }
  127 + else{
  128 + //提交
  129 + $(modalId).on('click', '.submit-btn', _submit);
  130 + }
108 131 });
109 132  
110 133 var readerScheduleList = function (rs) {
... ... @@ -190,6 +213,55 @@
190 213 else
191 214 input.attr('disabled', 'disabled');
192 215 });
  216 +
  217 + /**
  218 + * 提交
  219 + */
  220 + function _submit() {
  221 + var f = $('form', modalId);
  222 + var fData = f.serializeJSON();
  223 +
  224 + if(!fData['nbbm'] && !$('[name=nbbm]', f).attr('disabled')){
  225 + _shake_elem($('[name=nbbm]', f));
  226 + return UIkit.notification('车辆不能为空!', 'danger');
  227 + }
  228 +
  229 + if(!fData['jsy'] && !$('[name=jsy]', f).attr('disabled')){
  230 + _shake_elem($('[name=nbbm]', f));
  231 + return UIkit.notification('驾驶员不能为空!', 'danger');
  232 + }
  233 +
  234 + var checkeds = $('.sch_list_table>tr.active', modalId);
  235 + if (checkeds.length == 0)
  236 + return UIkit.notification('请选中要调整的班次!', 'danger');
  237 +
  238 +
  239 + console.log('fDatafData', fData);
  240 + var data = [];
  241 + var schId;
  242 + $.each(checkeds, function () {
  243 + schId = $(this).data('id');
  244 + data.push({
  245 + schId: schId,
  246 + jsy: fData.jsy,
  247 + spy: fData.spy,
  248 + clZbh: fData.nbbm
  249 + });
  250 + });
  251 +
  252 + gb_common.$post('/in_out/tzrc', {cpcsJson: JSON.stringify(data)}, function (rs) {
  253 +
  254 + UIkit.notification('操作成功!', 'success');
  255 + gb_os_card.update(rs.list);
  256 + UIkit.modal(modalId).hide();
  257 + });
  258 + }
  259 +
  260 + function _shake_elem($e) {
  261 + $e.addClass('uk-animation-shake').one('animationend', function () {
  262 + $(this).removeClass('uk-animation-shake');
  263 + });
  264 + }
193 265 })();
194 266 </script>
195 267 </div>
196 268 \ No newline at end of file
... ...