Commit 28f637a0afa725c1e45f017c37c72635e4219618

Authored by 娄高锋
1 parent 944896e0

出勤异常(缺人烂班)自获取已过计发时间的班次

src/main/java/com/bsth/server_rs/bigdata/BigscreenService.java
@@ -26,7 +26,6 @@ import javax.ws.rs.Produces; @@ -26,7 +26,6 @@ import javax.ws.rs.Produces;
26 import javax.ws.rs.core.MediaType; 26 import javax.ws.rs.core.MediaType;
27 27
28 import org.apache.commons.lang.StringUtils; 28 import org.apache.commons.lang.StringUtils;
29 -import org.codehaus.stax2.evt.DTD2;  
30 import org.slf4j.Logger; 29 import org.slf4j.Logger;
31 import org.slf4j.LoggerFactory; 30 import org.slf4j.LoggerFactory;
32 import org.springframework.beans.factory.annotation.Autowired; 31 import org.springframework.beans.factory.annotation.Autowired;
@@ -40,7 +39,6 @@ import com.bsth.entity.ChildTaskPlan; @@ -40,7 +39,6 @@ import com.bsth.entity.ChildTaskPlan;
40 import com.bsth.entity.ScheduleRealInfo; 39 import com.bsth.entity.ScheduleRealInfo;
41 import com.bsth.repository.ScheduleRealInfoRepository; 40 import com.bsth.repository.ScheduleRealInfoRepository;
42 import com.bsth.util.Arith; 41 import com.bsth.util.Arith;
43 -import com.mysql.fabric.xmlrpc.base.Array;  
44 42
45 @Component 43 @Component
46 @Path("/bigscreen") 44 @Path("/bigscreen")
@@ -1203,6 +1201,7 @@ public class BigscreenService { @@ -1203,6 +1201,7 @@ public class BigscreenService {
1203 @Path("/selectData/attendance") 1201 @Path("/selectData/attendance")
1204 public JSONObject attendance(){ 1202 public JSONObject attendance(){
1205 Map<String, Object> resMap = new HashMap<String, Object>(); 1203 Map<String, Object> resMap = new HashMap<String, Object>();
  1204 + SimpleDateFormat dateTime = new SimpleDateFormat("yyyy-MM-dd HH:mm");
1206 1205
1207 int day = 7;//天数 1206 int day = 7;//天数
1208 1207
@@ -1278,53 +1277,65 @@ public class BigscreenService { @@ -1278,53 +1277,65 @@ public class BigscreenService {
1278 } 1277 }
1279 1278
1280 for(ScheduleRealInfo s : findAll){ 1279 for(ScheduleRealInfo s : findAll){
1281 - if(s.getXlBm() != null && yyLine.contains(s.getXlBm())){//营运线路  
1282 - if (s.isSflj() || isInOut(s)){  
1283 - continue;  
1284 - }  
1285 - Set<ChildTaskPlan> cts;  
1286 - cts = s.getcTasks();  
1287 - //有子任务  
1288 - if (cts != null && cts.size() > 0) {  
1289 - for(ChildTaskPlan c : cts){  
1290 - if(c.getMileageType().equals("service") && c.getCcId() == null){  
1291 - if(c.isDestroy() && (c.getDestroyReason()==null? "" : c.getDestroyReason()).equals("缺人")){  
1292 - Map<String, Object> m = new HashMap<String, Object>();  
1293 - m.put("gsName", s.getGsName());  
1294 - m.put("lineName", s.getXlName());  
1295 - m.put("driverName", s.getjName());  
1296 - m.put("date", s.getRealExecDate());  
1297 - m.put("time", c.getStartDate());  
1298 - if(c.getRemarks() != null && c.getRemarks().trim().length() > 0){  
1299 - m.put("explain", c.getRemarks());  
1300 - } else {  
1301 - m.put("explain", s.getRemarks()!=null?s.getRemarks():"");  
1302 - }  
1303 -  
1304 - String str = s.getScheduleDateStr()+"/"+s.getXlName()+"/"+s.getjGh()+"/"+s.getjName();  
1305 - if(lackSet.add(str)){  
1306 - lackList.add(m);  
1307 - }  
1308 - }  
1309 - }  
1310 - }  
1311 - }  
1312 - //主任务烂班  
1313 - else if(s.getStatus() == -1 && s.getAdjustExps().equals("缺人")){  
1314 - Map<String, Object> m = new HashMap<String, Object>();  
1315 - m.put("gsName", s.getGsName());  
1316 - m.put("lineName", s.getXlName());  
1317 - m.put("driverName", s.getjName());  
1318 - m.put("date", s.getRealExecDate());  
1319 - m.put("time", s.getFcsj());  
1320 - m.put("explain", s.getRemarks()!=null?s.getRemarks():"");  
1321 -  
1322 - String str = s.getScheduleDateStr()+"/"+s.getXlName()+"/"+s.getjGh()+"/"+s.getjName();  
1323 - if(lackSet.add(str)){  
1324 - lackList.add(m); 1280 + try {
  1281 + if(s.getXlBm() != null && yyLine.contains(s.getXlBm())){//营运线路
  1282 + if (s.isSflj() || isInOut(s)){
  1283 + continue;
  1284 + }
  1285 +
  1286 + String time = s.getRealExecDate() + " " + s.getFcsj();
  1287 + Date d = dateTime.parse(time);
  1288 + if(dd.getTime() - d.getTime() < 300000l){ //只取当前时间5分钟前的数据
  1289 + continue;
1325 } 1290 }
1326 - }  
1327 - } 1291 +
  1292 + Set<ChildTaskPlan> cts;
  1293 + cts = s.getcTasks();
  1294 + //有子任务
  1295 + if (cts != null && cts.size() > 0) {
  1296 + for(ChildTaskPlan c : cts){
  1297 + if(c.getMileageType().equals("service") && c.getCcId() == null){
  1298 + if(c.isDestroy() && (c.getDestroyReason()==null? "" : c.getDestroyReason()).equals("缺人")){
  1299 + Map<String, Object> m = new HashMap<String, Object>();
  1300 + m.put("gsName", s.getGsName());
  1301 + m.put("lineName", s.getXlName());
  1302 + m.put("driverName", s.getjName());
  1303 + m.put("date", s.getRealExecDate());
  1304 + m.put("time", c.getStartDate());
  1305 + if(c.getRemarks() != null && c.getRemarks().trim().length() > 0){
  1306 + m.put("explain", c.getRemarks());
  1307 + } else {
  1308 + m.put("explain", s.getRemarks()!=null?s.getRemarks():"");
  1309 + }
  1310 +
  1311 + String str = s.getScheduleDateStr()+"/"+s.getXlName()+"/"+s.getjGh()+"/"+s.getjName();
  1312 + if(lackSet.add(str)){
  1313 + lackList.add(m);
  1314 + }
  1315 + }
  1316 + }
  1317 + }
  1318 + }
  1319 + //主任务烂班
  1320 + else if(s.getStatus() == -1 && s.getAdjustExps().equals("缺人")){
  1321 + Map<String, Object> m = new HashMap<String, Object>();
  1322 + m.put("gsName", s.getGsName());
  1323 + m.put("lineName", s.getXlName());
  1324 + m.put("driverName", s.getjName());
  1325 + m.put("date", s.getRealExecDate());
  1326 + m.put("time", s.getFcsj());
  1327 + m.put("explain", s.getRemarks()!=null?s.getRemarks():"");
  1328 +
  1329 + String str = s.getScheduleDateStr()+"/"+s.getXlName()+"/"+s.getjGh()+"/"+s.getjName();
  1330 + if(lackSet.add(str)){
  1331 + lackList.add(m);
  1332 + }
  1333 + }
  1334 + }
  1335 + } catch (Exception e) {
  1336 + // TODO: handle exception
  1337 + e.printStackTrace();
  1338 + }
1328 } 1339 }
1329 1340
1330 Map<String, Object> att = new HashMap<String, Object>(); 1341 Map<String, Object> att = new HashMap<String, Object>();
@@ -1432,6 +1443,7 @@ public class BigscreenService { @@ -1432,6 +1443,7 @@ public class BigscreenService {
1432 @Path("/selectData/attendance/{gsdm}") 1443 @Path("/selectData/attendance/{gsdm}")
1433 public JSONObject attendance(@PathParam("gsdm") String gsdm){ 1444 public JSONObject attendance(@PathParam("gsdm") String gsdm){
1434 Map<String, Object> resMap = new HashMap<String, Object>(); 1445 Map<String, Object> resMap = new HashMap<String, Object>();
  1446 + SimpleDateFormat dateTime = new SimpleDateFormat("yyyy-MM-dd HH:mm");
1435 1447
1436 int day = 7;//天数 1448 int day = 7;//天数
1437 1449
@@ -1509,55 +1521,66 @@ public class BigscreenService { @@ -1509,55 +1521,66 @@ public class BigscreenService {
1509 } 1521 }
1510 1522
1511 for(ScheduleRealInfo s : findAll){ 1523 for(ScheduleRealInfo s : findAll){
1512 - if(s.getGsBm() != null && s.getGsBm().equals(gsdm)){//直属公司  
1513 - if(s.getXlBm() != null && yyLine.contains(s.getXlBm())){//营运线路  
1514 - if (s.isSflj() || isInOut(s)){  
1515 - continue;  
1516 - }  
1517 - Set<ChildTaskPlan> cts;  
1518 - cts = s.getcTasks();  
1519 - //有子任务  
1520 - if (cts != null && cts.size() > 0) {  
1521 - for(ChildTaskPlan c : cts){  
1522 - if(c.getMileageType().equals("service") && c.getCcId() == null){  
1523 - if(c.isDestroy() && (c.getDestroyReason()==null? "" : c.getDestroyReason()).equals("缺人")){  
1524 - Map<String, Object> m = new HashMap<String, Object>();  
1525 - m.put("gsName", s.getGsName());  
1526 - m.put("lineName", s.getXlName());  
1527 - m.put("driverName", s.getjName());  
1528 - m.put("date", s.getRealExecDate());  
1529 - m.put("time", c.getStartDate());  
1530 - if(c.getRemarks() != null && c.getRemarks().trim().length() > 0){  
1531 - m.put("explain", c.getRemarks());  
1532 - } else {  
1533 - m.put("explain", s.getRemarks()!=null?s.getRemarks():"");  
1534 - }  
1535 -  
1536 - String str = s.getScheduleDateStr()+"/"+s.getXlName()+"/"+s.getjGh()+"/"+s.getjName();  
1537 - if(lackSet.add(str)){  
1538 - lackList.add(m);  
1539 - }  
1540 - }  
1541 - }  
1542 - }  
1543 - }  
1544 - //主任务烂班  
1545 - else if(s.getStatus() == -1 && s.getAdjustExps().equals("缺人")){  
1546 - Map<String, Object> m = new HashMap<String, Object>();  
1547 - m.put("gsName", s.getGsName());  
1548 - m.put("lineName", s.getXlName());  
1549 - m.put("driverName", s.getjName());  
1550 - m.put("date", s.getRealExecDate());  
1551 - m.put("time", s.getFcsj());  
1552 - m.put("explain", s.getRemarks()!=null?s.getRemarks():"");  
1553 -  
1554 - String str = s.getScheduleDateStr()+"/"+s.getXlName()+"/"+s.getjGh()+"/"+s.getjName();  
1555 - if(lackSet.add(str)){  
1556 - lackList.add(m); 1524 + try {
  1525 + if(s.getGsBm() != null && s.getGsBm().equals(gsdm)){//直属公司
  1526 + if(s.getXlBm() != null && yyLine.contains(s.getXlBm())){//营运线路
  1527 + if (s.isSflj() || isInOut(s)){
  1528 + continue;
  1529 + }
  1530 +
  1531 + String time = s.getRealExecDate() + " " + s.getFcsj();
  1532 + Date d = dateTime.parse(time);
  1533 + if(dd.getTime() - d.getTime() < 300000l){ //只取当前时间5分钟前的数据
  1534 + continue;
1557 } 1535 }
1558 - } 1536 +
  1537 + Set<ChildTaskPlan> cts;
  1538 + cts = s.getcTasks();
  1539 + //有子任务
  1540 + if (cts != null && cts.size() > 0) {
  1541 + for(ChildTaskPlan c : cts){
  1542 + if(c.getMileageType().equals("service") && c.getCcId() == null){
  1543 + if(c.isDestroy() && (c.getDestroyReason()==null? "" : c.getDestroyReason()).equals("缺人")){
  1544 + Map<String, Object> m = new HashMap<String, Object>();
  1545 + m.put("gsName", s.getGsName());
  1546 + m.put("lineName", s.getXlName());
  1547 + m.put("driverName", s.getjName());
  1548 + m.put("date", s.getRealExecDate());
  1549 + m.put("time", c.getStartDate());
  1550 + if(c.getRemarks() != null && c.getRemarks().trim().length() > 0){
  1551 + m.put("explain", c.getRemarks());
  1552 + } else {
  1553 + m.put("explain", s.getRemarks()!=null?s.getRemarks():"");
  1554 + }
  1555 +
  1556 + String str = s.getScheduleDateStr()+"/"+s.getXlName()+"/"+s.getjGh()+"/"+s.getjName();
  1557 + if(lackSet.add(str)){
  1558 + lackList.add(m);
  1559 + }
  1560 + }
  1561 + }
  1562 + }
  1563 + }
  1564 + //主任务烂班
  1565 + else if(s.getStatus() == -1 && s.getAdjustExps().equals("缺人")){
  1566 + Map<String, Object> m = new HashMap<String, Object>();
  1567 + m.put("gsName", s.getGsName());
  1568 + m.put("lineName", s.getXlName());
  1569 + m.put("driverName", s.getjName());
  1570 + m.put("date", s.getRealExecDate());
  1571 + m.put("time", s.getFcsj());
  1572 + m.put("explain", s.getRemarks()!=null?s.getRemarks():"");
  1573 +
  1574 + String str = s.getScheduleDateStr()+"/"+s.getXlName()+"/"+s.getjGh()+"/"+s.getjName();
  1575 + if(lackSet.add(str)){
  1576 + lackList.add(m);
  1577 + }
  1578 + }
  1579 + }
1559 } 1580 }
1560 - } 1581 + } catch (Exception e) {
  1582 + // TODO: handle exception
  1583 + }
1561 } 1584 }
1562 1585
1563 Map<String, Object> att = new HashMap<String, Object>(); 1586 Map<String, Object> att = new HashMap<String, Object>();