package com.fitweber.service;
import java.io.IOException;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import net.sf.json.JSONObject;
import com.fitweber.dao.ReportDao;
import com.fitweber.pojo.Report;
import com.fitweber.util.CommonUtils;
public class WorkdailyService {
private ReportDao reportDao;
public String saveReport(String reportData) throws IOException{
JSONObject jsonObject =JSONObject.fromObject(reportData);
Report report = (Report) JSONObject.toBean(jsonObject, Report.class);
HashMap<String,String> requestMap = new HashMap<String, String>();
String reportId,planId,planRemarkId;
if(report.getReportId()==null||"".equals(report.getReportId())){
reportId = CommonUtils.generateUUID();
requestMap.put("UUID", reportId);
requestMap.put("REPORTID", reportId);
requestMap.put("REPORTDATE", report.getWorkdate());
requestMap.put("WEEKCOUNT", report.getWeekcount());
reportDao.saveReport(requestMap);
planRemarkId = CommonUtils.generateUUID();
requestMap.clear();
requestMap.put("UUID",planRemarkId);
requestMap.put("PLANREMARKID",planRemarkId);
requestMap.put("REPORTID", reportId);
requestMap.put("REMARKCONTEXT", report.getPlanRemark());
reportDao.savePlanRemark(requestMap);
int size = report.getPlanIns().length,i;
String[] planIns = report.getPlanIns();
String[] planOuts = report.getPlanOuts();
String[] planIsFinishs = report.getPlanIsFinishs();
for(i=0;i<size;i++){
requestMap.clear();
planId = CommonUtils.generateUUID();
requestMap.put("UUID",planId);
requestMap.put("PLANID",planId);
requestMap.put("REPORTID", reportId);
requestMap.put("INCONTEXT", planIns[i]);
requestMap.put("OUTCONTEXT", planOuts[i]);
requestMap.put("ISFINISHED", planIsFinishs[i]);
reportDao.savePlan(requestMap);
}
}else{
reportId=report.getReportId();
requestMap.put("REPORTID", reportId);
requestMap.put("REPORTDATE", report.getWorkdate());
requestMap.put("WEEKCOUNT", report.getWeekcount());
reportDao.updateReport(requestMap);
planRemarkId = CommonUtils.generateUUID();
requestMap.clear();
requestMap.put("UUID",planRemarkId);
requestMap.put("PLANREMARKID",planRemarkId);
requestMap.put("REPORTID", reportId);
requestMap.put("REMARKCONTEXT", report.getPlanRemark());
reportDao.updatePlanRemark(requestMap);
requestMap.clear();
requestMap.put("REPORTID", reportId);
reportDao.delPlan(requestMap);
String[] planIns = report.getPlanIns();
String[] planOuts = report.getPlanOuts();
String[] planIsFinishs = report.getPlanIsFinishs();
int size = planIns.length,i;
for(i=0;i<size;i++){
requestMap.clear();
planId = CommonUtils.generateUUID();
requestMap.put("UUID",planId);
requestMap.put("PLANID",planId);
requestMap.put("REPORTID", reportId);
requestMap.put("INCONTEXT", planIns[i]);
requestMap.put("OUTCONTEXT", planOuts[i]);
requestMap.put("ISFINISHED", planIsFinishs[i]);
reportDao.savePlan(requestMap);
}
}
String[] dateSplit = report.getWorkdate().split("-");String month=null;
switch (Integer.valueOf(dateSplit[1])) {
case 1:month="January";break;case 2:month="February";break;case 3:month="March";break;
case 4:month="April";break;case 5:month="May";break;case 6:month="June";break;
case 7:month="July";break;case 8:month="August";break;case 9:month="September";break;
case 10:month="October";break;case 11:month="November";break;case 12:month="December";break;
default:month="unknown";break;
}
CommonUtils.saveFile(null,"D:/project/Week Report/"+month+","+dateSplit[0]+",Week"+report.getWeekcount()+"/"+report.getWorkdate()+".txt", reportData);
return reportId;
}
@SuppressWarnings("rawtypes")
public String viewWorkdaily(String reportId,String selectDate){
HashMap<String,String> requestMap = new HashMap<String, String>();
requestMap.put("REPORTID", reportId);
requestMap.put("REPORTDATE", selectDate);
List reports = reportDao.queryReport(requestMap);
Report report = new Report();
report.setReportId(reportId);
for(Object o:reports){
Map map = (Map) o;
report.setReportId(map.get("REPORTID").toString());
report.setWorkdate(map.get("REPORTDATE").toString());
report.setWeekcount(map.get("WEEKCOUNT").toString());
requestMap.clear();
requestMap.put("REPORTID", report.getReportId());
List remarks = reportDao.queryRemark(requestMap);
for(Object o1:remarks){
Map map1 = (Map) o1;
report.setPlanRemark((String)map1.get("REMARKCONTEXT"));
}
requestMap.clear();
requestMap.put("REPORTID", report.getReportId());
List plans = reportDao.queryPlan(requestMap);
ArrayList<String> planIns = new ArrayList<String>(),planOuts= new ArrayList<String>(),planIsFinishs= new ArrayList<String>();
for(Object o2:plans){
Map map2 = (Map) o2;
planIns.add((String)map2.get("INCONTEXT"));
planOuts.add((String)map2.get("OUTCONTEXT"));
planIsFinishs.add(map2.get("ISFINISHED").toString());
}
report.setPlanIns(planIns.toArray(new String[planIns.size()]));
report.setPlanOuts(planOuts.toArray(new String[planOuts.size()]));
report.setPlanIsFinishs(planIsFinishs.toArray(new String[planIsFinishs.size()]));
}
JSONObject jsonObject =JSONObject.fromObject(report);
return jsonObject.toString();
}
/**
* @return the reportDao
*/
public ReportDao getReportDao() {
return reportDao;
}
/**
* @param reportDao the reportDao to set
*/
public void setReportDao(ReportDao reportDao) {
this.reportDao = reportDao;
}
}
没有合适的资源?快使用搜索试试~ 我知道了~
温馨提示
1.此工程使用的是Spring+SpringMVC+Mybatis。数据库为MySQL 5.0.22。 2.数据库导入文件为com.fitweber.fans工程下的SQLScript文件夹下fitweber_20121203 0949.sql。 3.此工程的使用环境为IE8.0。其他浏览器版本正在开发中。 4.工作日志的访问路径为:http://localhost:8080/fitweber/workdaily/workdailyList.html 5.使用的IDE为:Eclipse 3.7.2。导入工程后注意修改buildpath修改为本场jre环境。 6.其他的controler和dao为未完成的开发。可以删除。
资源推荐
资源详情
资源评论
收起资源包目录
Spring+SpringMVC+Mybatis实现的工作日志系统 (709个子文件)
index.asp 45B
addScript.bak 13KB
common.css.bak 2KB
temp.html.bak 929B
common.js.bak 911B
WorkdailyService.class 6KB
DataBase.class 5KB
parseXML.class 4KB
testMyBatis.class 3KB
WorkdailyController.class 3KB
VisitingCardController.class 3KB
VisitingCardController.class 3KB
BasicController.class 3KB
CommonUtils.class 2KB
Report.class 2KB
TelephoneNumberService.class 2KB
VisitingCardService.class 2KB
SqlSessionFactoryService.class 1KB
User.class 1KB
Question.class 1KB
Option.class 1KB
Tips.class 1KB
VisitingCard.class 1KB
Questionnaire.class 1KB
CategoryVo.class 1016B
PhoneCard.class 1015B
BaseAction.class 993B
TelephoneNumber.class 973B
CategoryService.class 900B
QuestionnaireService.class 892B
ReportDao.class 603B
TelephoneNumberMapper.class 502B
VisitingCardMapper.class 472B
OptionCategoryDao.class 421B
QuestionnaireDao.class 410B
TipsMapper.class 392B
BasicController.class 388B
SampleServlet.class 354B
QuestionnaireController.class 344B
QuestionDao.class 120B
OptionDao.class 116B
.classpath 1KB
.classpath 1020B
org.eclipse.wst.common.component 697B
org.eclipse.wst.common.component 307B
org.eclipse.wst.jsdt.ui.superType.container 49B
jquery-ui.css 31KB
common_mini.css 26KB
jquery-ui.custom.min.css 25KB
documentation.css 5KB
datepicker.css 5KB
datepicker.css 5KB
ivy-report.css 5KB
datepicker.css 4KB
datepicker.css 4KB
common.css 2KB
jquery.chili-toolbar.css 2KB
WdatePicker.css 158B
WdatePicker.css 158B
wc.db 54KB
spring-beans-2.0.dtd 23KB
spring-beans.dtd 21KB
entries 3B
format 3B
126_f2.gif 2KB
f1_03.gif 2KB
mun_bg.gif 2KB
xxbg_dd.gif 2KB
xxbg_cc.gif 2KB
xxbg_bb.gif 2KB
img.gif 2KB
img.gif 2KB
xxbg_aa.gif 2KB
img.gif 2KB
img.gif 2KB
126logo_tsp.gif 1KB
inputbg_02.gif 1KB
datePicker.gif 1KB
datePicker.gif 1KB
spring-mvc.gif 1KB
spring-jee.gif 1015B
tabbg1.gif 1005B
f2_10.gif 898B
126_f2_01.gif 897B
sysbg_01.gif 883B
icon01.gif 832B
off.gif 828B
tabbg2.gif 653B
spring-lang.gif 592B
spring-cache.gif 592B
spring-tx.gif 581B
spring-jdbc.gif 581B
spring-jms.gif 577B
spring-context.gif 573B
spring-util.gif 553B
spring-task.gif 541B
spring-oxm.gif 321B
spring-beans.gif 310B
folder.gif 293B
js.gif 198B
共 709 条
- 1
- 2
- 3
- 4
- 5
- 6
- 8
super2007
- 粉丝: 14
- 资源: 42
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
最新资源
资源上传下载、课程学习等过程中有任何疑问或建议,欢迎提出宝贵意见哦~我们会及时处理!
点击此处反馈
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功
- 1
- 2
- 3
- 4
- 5
- 6
前往页