/** * @author liushuaic * @date 2015/09/17 15:50 查询某一个月的所有日期 1.查询出某一个月内的,所有的记录 2.没有记录的,自动进行补全,可以添加记录 * 3.在用户点进入第二个页面时,如果那天没有 id 就需要,在方法中返回所有的 时间段,并设置没有选中 * <p>* */ public Map<String, Object> getScheduleListByMonth(Map<String, Object> param) { Map<String, Object> rtnMap = new HashMap<String, Object>(); if (null != param.get("year") && null != param.get("month")) { SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd"); String year = param.get("year").toString(); String month = param.get("month").toString(); String userId = param.get("userId").toString(); Integer yearInt = Integer.valueOf(year); Integer monthInt = Integer.valueOf(month); Long userIdLon = Long.valueOf(userId); List<ServiceSchedule> scheduleList = serviceScheduleManager.getDayListByMonth(yearInt, monthInt, userIdLon); Calendar cl = Calendar.getInstance(); cl.set(Calendar.YEAR, yearInt); cl.set(Calendar.MONTH, monthInt - 1); int d = cl.getActualMaximum(Calendar.DAY_OF_MONTH); List<ServiceSchedule> serviceSchedules = new ArrayList<ServiceSchedule>(); for (int i = 1; i <= d; i++) { ServiceSchedule serviceSchedule = null; // 查找出,那天的对象,跳出并在集合中移除,以减少循环次数 for (int j = 0; j < scheduleList.size(); j++) { int serviceDay = scheduleList.get(j).getServcieDay(); if (i == serviceDay) { serviceSchedule = scheduleList.get(j); serviceSchedule.setIsCanSelected(Byte.valueOf("1")); serviceSchedule.setServiceDateStr(sdf.format(serviceSchedule.getServiceDate())); scheduleList.remove(j); break; } } if (null == serviceSchedule) { serviceSchedule = new ServiceSchedule(); cl.set(Calendar.DATE, i); serviceSchedule.setServiceDate(cl.getTime()); serviceSchedule.setServiceDateStr(sdf.format(cl.getTime())); serviceSchedule.setServcieDay(i); serviceSchedule.setServiceMonth(monthInt); serviceSchedule.setServiceYear(yearInt); // 0 表示是可以选择的 serviceSchedule.setIsCanSelected((byte) isCanSubmit(cl.getTime())); } serviceSchedules.add(serviceSchedule); } rtnMap.put("data", serviceSchedules); rtnMap.put("status", ExceptionConstants.responseSuccess.responseSuccess.code); rtnMap.put("message", ExceptionConstants.responseSuccess.responseSuccess.message); } else { rtnMap.put("status", ExceptionConstants.parameterException.parameterException.errorCode); rtnMap.put("message", ExceptionConstants.parameterException.parameterException.errorMessage); } return rtnMap; }
/** * @author liushuaic * @throws ParseException * @date 2015/09/17 18:58 添加某一天的工作时间 1.判断这天是否可以 提交 2.删除之前的数据 根据 时间,UserId 3.添加新的数据 修改 * serviceSchedule 中的 isCanSelected 为1是已经做了选中 判断serviceSchedule 是否存在,存在修改,不存在添加 * 4.添加serviceScheduleDetail * */ public Map<String, Object> insertServiceScheduleDetail(Map<String, Object> paramData) throws ParseException { Map<String, Object> rtnMap = new HashMap<String, Object>(); if (null != paramData.get("serviceDate") && null != paramData.get("timeQuantumIds")) { String userId = paramData.get("userId").toString(); String serviceDate = paramData.get("serviceDate").toString(); List timeQuantumIds = (ArrayList) paramData.get("timeQuantumIds"); paramData.put("serviceUserId", userId); Calendar cl = Calendar.getInstance(); Long currentDateTime = cl.getTimeInMillis(); SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd"); Date submitDate = sdf.parse(serviceDate); Calendar ca = Calendar.getInstance(); ca.setTime(submitDate); ServiceSchedule serviceSchedule = serviceScheduleManager.getServiceSchedule(paramData); if (null != serviceSchedule) { serviceScheduleManager.updateServiceScheduleIsCanSelected1( serviceSchedule.getServiceScheduleId()); } else { serviceSchedule = new ServiceSchedule(); serviceSchedule.setCreateTime(currentDateTime); serviceSchedule.setUpdateTime(currentDateTime); serviceSchedule.setIsCanSelected(Byte.valueOf("1")); serviceSchedule.setCreateUserId(Long.valueOf(userId)); serviceSchedule.setServiceUserId(Long.valueOf(userId)); serviceSchedule.setServiceYear(ca.get(Calendar.YEAR)); serviceSchedule.setServiceMonth(ca.get(Calendar.MONTH) + 1); serviceSchedule.setServcieDay(ca.get(Calendar.DAY_OF_MONTH)); serviceSchedule.setServiceDate(sdf.parse(serviceDate)); serviceScheduleManager.insertServiceSchduleSelective(serviceSchedule); } ServiceScheduleDetail serviceScheduleDetail = new ServiceScheduleDetail(); serviceScheduleDetail.setCreateTime(currentDateTime); serviceScheduleDetail.setUpdateTime(currentDateTime); serviceScheduleDetail.setServiceScheduleId(serviceSchedule.getServiceScheduleId()); serviceScheduleDetail.setCreateUserId(Long.valueOf(userId)); for (int i = 0; i < timeQuantumIds.size(); i++) { serviceScheduleDetail.setTimeQuantumId(Long.valueOf(timeQuantumIds.get(i).toString())); serviceScheduleManager.insertServiceScheduleDetail(serviceScheduleDetail); } rtnMap.put("status", ExceptionConstants.responseSuccess.responseSuccess.code); rtnMap.put("message", ExceptionConstants.responseSuccess.responseSuccess.message); } else { rtnMap.put("status", ExceptionConstants.parameterException.parameterException.errorCode); rtnMap.put("message", ExceptionConstants.parameterException.parameterException.errorMessage); } return rtnMap; }