com.frameworkset.platform.holiday.area.action.AreaController Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of pdp-system Show documentation
Show all versions of pdp-system Show documentation
bboss public development platform base on bboss.
package com.frameworkset.platform.holiday.area.action;
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.UUID;
import org.frameworkset.util.annotations.PagerParam;
import org.frameworkset.util.annotations.ResponseBody;
import org.frameworkset.web.servlet.ModelMap;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import com.frameworkset.orm.transaction.TransactionManager;
import com.frameworkset.platform.holiday.area.bean.Area;
import com.frameworkset.platform.holiday.area.bean.Arrange;
import com.frameworkset.platform.holiday.area.bean.Day;
import com.frameworkset.platform.holiday.area.bean.Org;
import com.frameworkset.platform.holiday.area.bean.OrgLeaf;
import com.frameworkset.platform.holiday.area.bean.WorkDate;
import com.frameworkset.platform.holiday.area.bean.WorkTime;
import com.frameworkset.platform.holiday.area.service.AreaManager;
import com.frameworkset.platform.security.AccessControl;
import com.frameworkset.util.ListInfo;
public class AreaController {
private AreaManager areaManager;
// private SimpleDateFormat df = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");//设置日期格式
private static Logger logger = LoggerFactory.getLogger(AreaController.class);
public String index(){
return "path:index";
}
public String queryAreaList(
@PagerParam(name = PagerParam.SORT, defaultvalue = "") String sortKey,
@PagerParam(name = PagerParam.DESC, defaultvalue = "false") boolean desc,
@PagerParam(name = PagerParam.OFFSET) long offset,
@PagerParam(name = PagerParam.PAGE_SIZE, defaultvalue = "20") int pagesize, ModelMap model) throws Exception {
ListInfo datas = areaManager.queryAreaList((int) offset, pagesize);
model.addAttribute("datas", datas);
return "path:areaList";
}
@SuppressWarnings("unchecked")
public @ResponseBody String updateArea(String areaId,String areaName,String areaDesc,String areaDefault) throws Exception {
/*判断默认区域是否重复设置 */
if("1".equals(areaDefault)){
if(areaManager.checkDuplicateDefaultArea(areaId,2)){//true 表示重复
return "error";
}
}
try{
areaManager.updateArea( areaId, areaName, areaDesc,areaDefault);
return "success";
}catch(Exception e){
e.printStackTrace();
logger.error("更新区域信息报错",e);
return "error";
}
}
@SuppressWarnings("unchecked")
public @ResponseBody List getOrgTree() throws Exception {
List list = areaManager.getAllOrgLeaf();
return list;
}
public String queryOrgList(String areaId,ModelMap model) throws Exception {
List list = areaManager.queryOrgList(areaId);
model.addAttribute("datas", list);
return "path:orgList";
}
@SuppressWarnings("unchecked")
public @ResponseBody String addOrg(String orgId,String orgName,String areaId) throws Exception {
try{
List list = areaManager.querySingleOrg(areaId,orgId);
if(null != list && list.size()>0){
return "机构重复!";
}
areaManager.addOrg(orgId, orgName, areaId);
return "success";
}catch(Exception e){
logger.error("添加机构报错",e);
e.printStackTrace();
return "添加失败";
}
}
@SuppressWarnings("unchecked")
public @ResponseBody String deleteOrg(String orgId,String areaId) throws Exception {
try{
areaManager.deleteOrg(orgId, areaId);
return "success";
}catch(Exception e){
logger.error("删除机构报错",e);
e.printStackTrace();
return "error";
}
}
@SuppressWarnings("unchecked")
public @ResponseBody Area querySingleArea(String areaId) throws Exception {
try{
List list = areaManager.querySingleArea(areaId);
return (null != list && list.size()>0)?list.get(0):null;
}catch(Exception e){
logger.error("查询单个区域报错",e);
e.printStackTrace();
return null;
}
}
@SuppressWarnings("unchecked")
public @ResponseBody String addArea(String areaName , String areaDesc,String areaDefault) throws Exception {
String areaId = UUID.randomUUID().toString();
SimpleDateFormat df = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");//设置日期格式
String createTime = df.format(new Date());
String creator = AccessControl.getAccessControl().getUserAccount();
/*判断默认区域是否重复设置 */
if("1".equals(areaDefault)){
if(areaManager.checkDuplicateDefaultArea(areaId,1)){//true 表示重复
return "error";
}
}
try{
areaManager.addArea(areaId, areaName , areaDesc, creator , createTime,areaDefault);
return "success";
}catch(Exception e){
logger.error("添加报错",e);
return "error";
}
}
/**
*初始化全年的日历结构
*@param year 年份
*@param areaId 区域Id
*
*/
@SuppressWarnings("unchecked")
public @ResponseBody(datatype = "json")List initArrangeTable(String year) throws Exception {
/* 获取全年每月第一天对应是该月第几周的星期几 */
List