package com.b.shift.service;
import java.io.Serializable;
import java.math.BigDecimal;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Calendar;
import java.util.Date;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.logging.Level;
import javax.persistence.EntityManager;
import javax.persistence.Query;
import com.b.helper.EntityManagerHelper;
import com.b.inforeceive.dao.PTemplate;
import com.b.shift.dao.ShiftInfo;
import com.b.shift.dao.ShiftInfoDAO;
import com.b.shift.dao.ShiftProductInfo;
import com.b.shift.dao.ShiftProductInfoDAO;
import com.b.shift.vo.ShiftInfoVO;
import com.b.shift.vo.ShiftProductInfoVO;
@SuppressWarnings("serial")
public class ShiftInfoService implements Serializable {
private static final long serialVersionUID = -3842248385950368874L;
private static final String fromTimeInterval = "08:40:00";
private static final String toTimeInterval = "08:40:00";
private static final String tplPrefix = "tpl_";
private static final String tplPrefix1 = "tpl1_";
private static final List<String> colNamesStatic = new ArrayList<String>();
static {
colNamesStatic.add("shiftid");
colNamesStatic.add("shift_date");
colNamesStatic.add("shift_leader");
colNamesStatic.add("shift_chief");
colNamesStatic.add("shift_onduty");
colNamesStatic.add("cnt_netinfo");
colNamesStatic.add("cnt_singleinfo");
colNamesStatic.add("cnt_ciphertele");
colNamesStatic.add("cnt_crimerpt");
colNamesStatic.add("cnt_crimeeffct");
colNamesStatic.add("status_equipment");
colNamesStatic.add("status_hygiene");
colNamesStatic.add("status_device");
colNamesStatic.add("status_vehicle");
colNamesStatic.add("recorder");
colNamesStatic.add("note_items");
}
private static final List<String> colLabelsStatic = new ArrayList<String>();
static {
colLabelsStatic.add("编号");
colLabelsStatic.add("值班日期");
colLabelsStatic.add("带班领导");
colLabelsStatic.add("值班长");
colLabelsStatic.add("值班员");
colLabelsStatic.add("接收网络信息数");
colLabelsStatic.add("接收单机信息数");
colLabelsStatic.add("接收密电数");
colLabelsStatic.add("12110接警数");
colLabelsStatic.add("有效接警数");
colLabelsStatic.add("设备情况");
colLabelsStatic.add("勤务卫生");
colLabelsStatic.add("值班装备");
colLabelsStatic.add("车辆使用情况");
colLabelsStatic.add("记录人");
colLabelsStatic.add("交班事项");
}
private static final List<String> colFeatures = new ArrayList<String>();
static {
colFeatures.add("align:\"center\",width:\"50px\",fixed:\"true\",classes:\"myFontClass\"}, ");
colFeatures.add("align:\"center\",width:\"65px\",fixed:\"true\",classes:\"myFontClass\"}, ");
colFeatures.add("align:\"center\",width:\"53px\",fixed:\"true\",classes:\"myFontClass\"}, ");
colFeatures.add("align:\"center\",width:\"45px\",fixed:\"true\",classes:\"myFontClass\"}, ");
colFeatures.add("align:\"center\",width:\"45px\",fixed:\"true\",classes:\"myFontClass\"}, ");
colFeatures.add("align:\"center\",width:\"85px\",fixed:\"true\",classes:\"myFontClass\"}, ");
colFeatures.add("align:\"center\",width:\"85px\",fixed:\"true\",classes:\"myFontClass\"}, ");
colFeatures.add("align:\"center\",width:\"65px\",fixed:\"true\",classes:\"myFontClass\"}, ");
colFeatures.add("align:\"center\",width:\"73px\",fixed:\"true\",classes:\"myFontClass\"}, ");
colFeatures.add("align:\"center\",width:\"65px\",fixed:\"true\",classes:\"myFontClass\"}, ");
colFeatures.add("align:\"center\",width:\"53px\",fixed:\"true\",classes:\"myFontClass\"}, ");
colFeatures.add("align:\"center\",width:\"53px\",fixed:\"true\",classes:\"myFontClass\"}, ");
colFeatures.add("align:\"center\",width:\"53px\",fixed:\"true\",classes:\"myFontClass\"}, ");
colFeatures.add("align:\"center\",width:\"75px\",fixed:\"true\",classes:\"myFontClass\"}, ");
colFeatures.add("align:\"center\",width:\"45px\",fixed:\"true\",classes:\"myFontClass\"}, ");
colFeatures.add("hidden:true,align:\"center\",classes:\"myFontClass\"}, ");
}
private static final Map<String, List<String>> colInfosStatic = new HashMap<String, List<String>>();
static {
colInfosStatic.put("shiftid", new ArrayList<String>(){{add(colLabelsStatic.get(0)); add(colFeatures.get(0));}});
colInfosStatic.put("shift_date", new ArrayList<String>(){{add(colLabelsStatic.get(1)); add(colFeatures.get(1));}});
colInfosStatic.put("shift_leader", new ArrayList<String>(){{add(colLabelsStatic.get(2)); add(colFeatures.get(2));}});
colInfosStatic.put("shift_chief", new ArrayList<String>(){{add(colLabelsStatic.get(3)); add(colFeatures.get(3));}});
colInfosStatic.put("shift_onduty", new ArrayList<String>(){{add(colLabelsStatic.get(4)); add(colFeatures.get(4));}});
colInfosStatic.put("cnt_netinfo", new ArrayList<String>(){{add(colLabelsStatic.get(5)); add(colFeatures.get(5));}});
colInfosStatic.put("cnt_singleinfo", new ArrayList<String>(){{add(colLabelsStatic.get(6)); add(colFeatures.get(6));}});
colInfosStatic.put("cnt_ciphertele", new ArrayList<String>(){{add(colLabelsStatic.get(7)); add(colFeatures.get(7));}});
colInfosStatic.put("cnt_crimerpt", new ArrayList<String>(){{add(colLabelsStatic.get(8)); add(colFeatures.get(8));}});
colInfosStatic.put("cnt_crimeeffct", new ArrayList<String>(){{add(colLabelsStatic.get(9)); add(colFeatures.get(9));}});
colInfosStatic.put("status_equipment", new ArrayList<String>(){{add(colLabelsStatic.get(10)); add(colFeatures.get(10));}});
colInfosStatic.put("status_hygiene", new ArrayList<String>(){{add(colLabelsStatic.get(11)); add(colFeatures.get(11));}});
colInfosStatic.put("status_device", new ArrayList<String>(){{add(colLabelsStatic.get(12)); add(colFeatures.get(12));}});
colInfosStatic.put("status_vehicle", new ArrayList<String>(){{add(colLabelsStatic.get(13)); add(colFeatures.get(13));}});
colInfosStatic.put("recorder", new ArrayList<String>(){{add(colLabelsStatic.get(14)); add(colFeatures.get(14));}});
colInfosStatic.put("note_items", new ArrayList<String>(){{add(colLabelsStatic.get(15)); add(colFeatures.get(15));}});
}
private static Map<String, List<String>> colInfosAll = new HashMap<String, List<String>>();
private static final int colBreak = 2;
public ShiftInfoService() {
}
public static void create() throws Exception {
try {
} catch (Exception ex) {
throw ex;
} finally {
}
}
/*
* 获取交接班信息的所有信息
*/
public static List<ShiftInfoVO> getShiftInfoList() {
List<ShiftInfoVO> listInfoVOs = new ArrayList<ShiftInfoVO>();
ShiftInfoDAO ShiftinfoDAO = new ShiftInfoDAO();
List<ShiftInfo> listInfo = ShiftinfoDAO.findAll();
for (ShiftInfo shiftInfo : listInfo) {
ShiftInfoVO infoVO = new ShiftInfoVO();
infoVO = infoVO.EntityToVo(shiftInfo);
listInfoVOs.add(infoVO);
}
return listInfoVOs;
}
@SuppressWarnings("unchecked")
public static List<ShiftInfoVO> getShiftInfoListCondition(String kwString,
String ci) {
List<ShiftInfoVO> listInfoVOs = new ArrayList<ShiftInfoVO>();
String sql = "select * from shift_baseinfo where " + ci + " like '%"
+ kwString + "%'";
EntityManager manager = EntityManagerHelper.getEntityManager();
Query query = manager.createNativeQuery(sql, ShiftInfo.class);
List<ShiftInfo> list = query.getResultList();
for (ShiftInfo shiftInfo : list) {
ShiftInfoVO infoVO = new ShiftInfoVO();
infoVO = infoVO.EntityToVo(shiftInfo);
listInfoVOs.add(infoVO);
}
return listInfoVOs;
}
/*
* 根据typecode返回dictoryinfo结果集
*/
@SuppressWarnings("unchecked")
public static List<ShiftInfoVO> getShiftInfoByTypeCode(String shiftLeader,
int... startAndCount) {
List<ShiftInfoVO> lists = new ArrayList<ShiftInfoVO>();
String sql = "select * from shift_baseinfo where shift_leader='"
+ shiftLeader + "' order by