Commit ece77815b938b3ee3bfbba6685c122f39e568d37
1 parent
cba212cc
工时填报管理
Showing
9 changed files
with
423 additions
and
39 deletions
src/main/java/com/zteits/oa/api/dto/asradaily/AsraDailyDateChangeDTO.java
0 → 100644
| 1 | +package com.zteits.oa.api.dto.asradaily; | ||
| 2 | + | ||
| 3 | +import com.zteits.oa.api.base.bean.BaiscDTO; | ||
| 4 | + | ||
| 5 | +import java.util.Date; | ||
| 6 | + | ||
| 7 | +public class AsraDailyDateChangeDTO extends BaiscDTO{ | ||
| 8 | + | ||
| 9 | + /**年:2018*/ | ||
| 10 | + private Integer years; | ||
| 11 | + | ||
| 12 | + /**周:1-54周*/ | ||
| 13 | + private Integer weeks; | ||
| 14 | + | ||
| 15 | + /**星期:1-7*/ | ||
| 16 | + private Integer weeksNum; | ||
| 17 | + | ||
| 18 | + public Integer getYears() { | ||
| 19 | + return years; | ||
| 20 | + } | ||
| 21 | + | ||
| 22 | + public void setYears(Integer years) { | ||
| 23 | + this.years = years; | ||
| 24 | + } | ||
| 25 | + | ||
| 26 | + public Integer getWeeks() { | ||
| 27 | + return weeks; | ||
| 28 | + } | ||
| 29 | + | ||
| 30 | + public void setWeeks(Integer weeks) { | ||
| 31 | + this.weeks = weeks; | ||
| 32 | + } | ||
| 33 | + | ||
| 34 | + public Integer getWeeksNum() { | ||
| 35 | + return weeksNum; | ||
| 36 | + } | ||
| 37 | + | ||
| 38 | + public void setWeeksNum(Integer weeksNum) { | ||
| 39 | + this.weeksNum = weeksNum; | ||
| 40 | + } | ||
| 41 | +} | ||
| 0 | \ No newline at end of file | 42 | \ No newline at end of file |
src/main/java/com/zteits/oa/api/dto/asradaily/param/AsraDailyQueryReq.java
| 1 | package com.zteits.oa.api.dto.asradaily.param; | 1 | package com.zteits.oa.api.dto.asradaily.param; |
| 2 | 2 | ||
| 3 | +import com.sun.istack.internal.NotNull; | ||
| 3 | import com.zteits.oa.api.base.bean.BaseRequest; | 4 | import com.zteits.oa.api.base.bean.BaseRequest; |
| 4 | 5 | ||
| 5 | import java.util.Date; | 6 | import java.util.Date; |
| 6 | 7 | ||
| 7 | public class AsraDailyQueryReq extends BaseRequest{ | 8 | public class AsraDailyQueryReq extends BaseRequest{ |
| 8 | 9 | ||
| 10 | + /**工时填写日期*/ | ||
| 11 | + @NotNull | ||
| 12 | + private String dailyDate; | ||
| 9 | 13 | ||
| 10 | /**所属员工ID*/ | 14 | /**所属员工ID*/ |
| 11 | private Long asarOpId; | 15 | private Long asarOpId; |
| 12 | 16 | ||
| 13 | - /**工时填写日期*/ | ||
| 14 | - private Date dailyDate; | ||
| 15 | 17 | ||
| 16 | /**年:2018*/ | 18 | /**年:2018*/ |
| 17 | private Integer years; | 19 | private Integer years; |
| @@ -27,11 +29,11 @@ public class AsraDailyQueryReq extends BaseRequest{ | @@ -27,11 +29,11 @@ public class AsraDailyQueryReq extends BaseRequest{ | ||
| 27 | this.asarOpId = asarOpId; | 29 | this.asarOpId = asarOpId; |
| 28 | } | 30 | } |
| 29 | 31 | ||
| 30 | - public Date getDailyDate() { | 32 | + public String getDailyDate() { |
| 31 | return dailyDate; | 33 | return dailyDate; |
| 32 | } | 34 | } |
| 33 | 35 | ||
| 34 | - public void setDailyDate(Date dailyDate) { | 36 | + public void setDailyDate(String dailyDate) { |
| 35 | this.dailyDate = dailyDate; | 37 | this.dailyDate = dailyDate; |
| 36 | } | 38 | } |
| 37 | 39 |
src/main/java/com/zteits/oa/report/biz/AsraDailyQueryServiceImpl.java
| @@ -37,7 +37,11 @@ public class AsraDailyQueryServiceImpl implements AsraDailyQueryService { | @@ -37,7 +37,11 @@ public class AsraDailyQueryServiceImpl implements AsraDailyQueryService { | ||
| 37 | List<AsraDailyDTO> asraDailyDTOs = new ArrayList<>(); | 37 | List<AsraDailyDTO> asraDailyDTOs = new ArrayList<>(); |
| 38 | List<AsraDaily> asraDailies = asraDailyDao.queryAsraDailyList(asraDailyQueryReq); | 38 | List<AsraDaily> asraDailies = asraDailyDao.queryAsraDailyList(asraDailyQueryReq); |
| 39 | if(CollectionUtil.isNotEmpty(asraDailies)){ | 39 | if(CollectionUtil.isNotEmpty(asraDailies)){ |
| 40 | - BeanUtils.copyProperties(asraDailies,asraDailyDTOs,AsraDailyDTO.class); | 40 | + for(AsraDaily asraDaily:asraDailies){ |
| 41 | + AsraDailyDTO asraDailyDTO = new AsraDailyDTO(); | ||
| 42 | + BeanUtils.copyProperties(asraDaily,asraDailyDTO); | ||
| 43 | + asraDailyDTOs.add(asraDailyDTO); | ||
| 44 | + } | ||
| 41 | } | 45 | } |
| 42 | return new BizResult<>(asraDailyDTOs); | 46 | return new BizResult<>(asraDailyDTOs); |
| 43 | } | 47 | } |
src/main/java/com/zteits/oa/report/dao/impl/AsraDailyDaoImpl.java
| @@ -35,6 +35,6 @@ public class AsraDailyDaoImpl implements AsraDailyDao{ | @@ -35,6 +35,6 @@ public class AsraDailyDaoImpl implements AsraDailyDao{ | ||
| 35 | example.createCriteria().andAsarOpIdEqualTo(asraDailyQueryReq.getAsarOpId()) | 35 | example.createCriteria().andAsarOpIdEqualTo(asraDailyQueryReq.getAsarOpId()) |
| 36 | .andYearsEqualTo(asraDailyQueryReq.getYears()) | 36 | .andYearsEqualTo(asraDailyQueryReq.getYears()) |
| 37 | .andWeeksEqualTo(asraDailyQueryReq.getWeeks()); | 37 | .andWeeksEqualTo(asraDailyQueryReq.getWeeks()); |
| 38 | - return asraDailyMapper.selectByExample(example); | 38 | + return asraDailyMapper.selectByExampleWithBLOBs(example); |
| 39 | } | 39 | } |
| 40 | } | 40 | } |
src/main/java/com/zteits/oa/report/web/AsraDailyController.java
| @@ -7,6 +7,7 @@ import com.zteits.oa.api.base.bean.BizResult; | @@ -7,6 +7,7 @@ import com.zteits.oa.api.base.bean.BizResult; | ||
| 7 | import com.zteits.oa.api.base.bean.PageBean; | 7 | import com.zteits.oa.api.base.bean.PageBean; |
| 8 | import com.zteits.oa.api.base.constants.SessionEnum; | 8 | import com.zteits.oa.api.base.constants.SessionEnum; |
| 9 | import com.zteits.oa.api.dto.asradaily.AsraDailyDTO; | 9 | import com.zteits.oa.api.dto.asradaily.AsraDailyDTO; |
| 10 | +import com.zteits.oa.api.dto.asradaily.AsraDailyDateChangeDTO; | ||
| 10 | import com.zteits.oa.api.dto.asradaily.param.AsraDailyQueryReq; | 11 | import com.zteits.oa.api.dto.asradaily.param.AsraDailyQueryReq; |
| 11 | import com.zteits.oa.api.dto.asraop.AsraOpDTO; | 12 | import com.zteits.oa.api.dto.asraop.AsraOpDTO; |
| 12 | import com.zteits.oa.api.dto.asraop.param.AsraOpQueryReq; | 13 | import com.zteits.oa.api.dto.asraop.param.AsraOpQueryReq; |
| @@ -16,9 +17,11 @@ import com.zteits.oa.api.service.report.query.AsraDailyQueryService; | @@ -16,9 +17,11 @@ import com.zteits.oa.api.service.report.query.AsraDailyQueryService; | ||
| 16 | import com.zteits.oa.api.service.report.query.AsraOpQueryService; | 17 | import com.zteits.oa.api.service.report.query.AsraOpQueryService; |
| 17 | import com.zteits.oa.api.service.report.query.AsraOpRelationsQueryService; | 18 | import com.zteits.oa.api.service.report.query.AsraOpRelationsQueryService; |
| 18 | import com.zteits.oa.report.domain.AsraDaily; | 19 | import com.zteits.oa.report.domain.AsraDaily; |
| 20 | +import com.zteits.oa.util.pagepaper.DateForObjectUtil; | ||
| 19 | import io.swagger.annotations.Api; | 21 | import io.swagger.annotations.Api; |
| 20 | import org.slf4j.Logger; | 22 | import org.slf4j.Logger; |
| 21 | import org.slf4j.LoggerFactory; | 23 | import org.slf4j.LoggerFactory; |
| 24 | +import org.springframework.beans.BeanUtils; | ||
| 22 | import org.springframework.beans.factory.annotation.Autowired; | 25 | import org.springframework.beans.factory.annotation.Autowired; |
| 23 | import org.springframework.web.bind.annotation.RequestBody; | 26 | import org.springframework.web.bind.annotation.RequestBody; |
| 24 | import org.springframework.web.bind.annotation.RequestMapping; | 27 | import org.springframework.web.bind.annotation.RequestMapping; |
| @@ -39,27 +42,23 @@ public class AsraDailyController { | @@ -39,27 +42,23 @@ public class AsraDailyController { | ||
| 39 | private static final Logger logger = LoggerFactory.getLogger(AsraDailyController.class); | 42 | private static final Logger logger = LoggerFactory.getLogger(AsraDailyController.class); |
| 40 | 43 | ||
| 41 | @Autowired | 44 | @Autowired |
| 42 | - private AsraOpQueryService asraOpQueryService; | ||
| 43 | - | ||
| 44 | - @Autowired | ||
| 45 | private AsraDailyQueryService asraDailyQueryService; | 45 | private AsraDailyQueryService asraDailyQueryService; |
| 46 | 46 | ||
| 47 | 47 | ||
| 48 | @RequestMapping(value="/queryAsraDailyList",method = RequestMethod.POST) | 48 | @RequestMapping(value="/queryAsraDailyList",method = RequestMethod.POST) |
| 49 | public BizResult<List<AsraDailyDTO>> queryAsraDailyList(@RequestBody AsraDailyQueryReq asraDailyQueryReq, HttpServletRequest request){ | 49 | public BizResult<List<AsraDailyDTO>> queryAsraDailyList(@RequestBody AsraDailyQueryReq asraDailyQueryReq, HttpServletRequest request){ |
| 50 | - logger.info("日报系统-日报管理-根据登录人分页查询员工信息入参:{}", JSONObject.toJSON(asraDailyQueryReq)); | 50 | + logger.info("日报系统-日报管理-根据登录人查询日报信息入参:{}", JSONObject.toJSON(asraDailyQueryReq)); |
| 51 | /**1.根据当前登录人查询登录人下面管理的员工-缓存中获取*/ | 51 | /**1.根据当前登录人查询登录人下面管理的员工-缓存中获取*/ |
| 52 | AsraOpDTO asraOpDTO = (AsraOpDTO)request.getSession().getAttribute(SessionEnum.USER_INFO.key()); | 52 | AsraOpDTO asraOpDTO = (AsraOpDTO)request.getSession().getAttribute(SessionEnum.USER_INFO.key()); |
| 53 | 53 | ||
| 54 | /**2.判断登录人和时间查询日报*/ | 54 | /**2.判断登录人和时间查询日报*/ |
| 55 | - Date dailyDate = asraDailyQueryReq.getDailyDate(); | ||
| 56 | - Integer week = DateUtil.weekOfYear(dailyDate);//第N周 | ||
| 57 | - Integer year = DateUtil.year(dailyDate);//第N周 | 55 | + Date dailyDate = DateUtil.parseDate(asraDailyQueryReq.getDailyDate()); |
| 56 | + AsraDailyDateChangeDTO asraDailyDateChangeDTO = DateForObjectUtil.getAsraDailyDTO(dailyDate); | ||
| 58 | asraDailyQueryReq.setAsarOpId(asraOpDTO.getId()); | 57 | asraDailyQueryReq.setAsarOpId(asraOpDTO.getId()); |
| 59 | - asraDailyQueryReq.setWeeks(week); | ||
| 60 | - asraDailyQueryReq.setYears(year); | 58 | + BeanUtils.copyProperties(asraDailyDateChangeDTO,asraDailyQueryReq); |
| 59 | + logger.info("日报系统-日报管理-根据登录人查询日报信息入参:{}", JSONObject.toJSON(asraDailyDateChangeDTO)); | ||
| 61 | BizResult<List<AsraDailyDTO>> result = asraDailyQueryService.queryAsraDailyList(asraDailyQueryReq); | 60 | BizResult<List<AsraDailyDTO>> result = asraDailyQueryService.queryAsraDailyList(asraDailyQueryReq); |
| 62 | - logger.info("日报系统-日报管理-根据登录人分页查询员工信息结束"); | 61 | + logger.info("日报系统-日报管理-根据登录人查询日报信息结束"); |
| 63 | return result; | 62 | return result; |
| 64 | } | 63 | } |
| 65 | 64 |
src/main/java/com/zteits/oa/report/web/AsraOpController.java
| @@ -11,6 +11,7 @@ import com.zteits.oa.api.dto.asraoprelations.AsraOpRelationsDTO; | @@ -11,6 +11,7 @@ import com.zteits.oa.api.dto.asraoprelations.AsraOpRelationsDTO; | ||
| 11 | import com.zteits.oa.api.dto.asraoprelations.param.AsraOpRelationsQueryReq; | 11 | import com.zteits.oa.api.dto.asraoprelations.param.AsraOpRelationsQueryReq; |
| 12 | import com.zteits.oa.api.service.report.query.AsraOpQueryService; | 12 | import com.zteits.oa.api.service.report.query.AsraOpQueryService; |
| 13 | import com.zteits.oa.api.service.report.query.AsraOpRelationsQueryService; | 13 | import com.zteits.oa.api.service.report.query.AsraOpRelationsQueryService; |
| 14 | +import com.zteits.oa.report.web.vo.EasyUIDataGridVO; | ||
| 14 | import io.swagger.annotations.Api; | 15 | import io.swagger.annotations.Api; |
| 15 | import org.slf4j.Logger; | 16 | import org.slf4j.Logger; |
| 16 | import org.slf4j.LoggerFactory; | 17 | import org.slf4j.LoggerFactory; |
| @@ -29,45 +30,26 @@ import java.util.List; | @@ -29,45 +30,26 @@ import java.util.List; | ||
| 29 | @Api(value = "日报系统-员工管理", description = "日报系统-员工管理") | 30 | @Api(value = "日报系统-员工管理", description = "日报系统-员工管理") |
| 30 | @RestController | 31 | @RestController |
| 31 | @RequestMapping("/asraOp") | 32 | @RequestMapping("/asraOp") |
| 32 | -public class AsraOpController { | 33 | +public class AsraOpController extends BizController { |
| 33 | 34 | ||
| 34 | private static final Logger logger = LoggerFactory.getLogger(AsraOpController.class); | 35 | private static final Logger logger = LoggerFactory.getLogger(AsraOpController.class); |
| 35 | 36 | ||
| 36 | @Autowired | 37 | @Autowired |
| 37 | private AsraOpQueryService asraOpQueryService; | 38 | private AsraOpQueryService asraOpQueryService; |
| 38 | 39 | ||
| 39 | - @Autowired | ||
| 40 | - private AsraOpRelationsQueryService asraOpRelationsQueryService; | ||
| 41 | - | ||
| 42 | 40 | ||
| 43 | 41 | ||
| 44 | 42 | ||
| 45 | 43 | ||
| 46 | @RequestMapping(value="/queryAsraOpPage",method = RequestMethod.POST) | 44 | @RequestMapping(value="/queryAsraOpPage",method = RequestMethod.POST) |
| 47 | - public BizResult<PageBean<AsraOpDTO>> queryAsraOpPage(@RequestBody AsraOpQueryReq asraOpQueryReq, HttpServletRequest request){ | 45 | + public BizResult<EasyUIDataGridVO<AsraOpDTO>> queryAsraOpPage(@RequestBody AsraOpQueryReq asraOpQueryReq, HttpServletRequest request) throws IllegalAccessException, InstantiationException { |
| 48 | logger.info("日报系统-员工管理-根据登录人分页查询员工信息入参:{}", JSONObject.toJSON(asraOpQueryReq)); | 46 | logger.info("日报系统-员工管理-根据登录人分页查询员工信息入参:{}", JSONObject.toJSON(asraOpQueryReq)); |
| 49 | /**1.根据当前登录人查询登录人下面管理的员工-缓存中获取*/ | 47 | /**1.根据当前登录人查询登录人下面管理的员工-缓存中获取*/ |
| 50 | AsraOpDTO asraOpDTO = (AsraOpDTO)request.getSession().getAttribute(SessionEnum.USER_INFO.key()); | 48 | AsraOpDTO asraOpDTO = (AsraOpDTO)request.getSession().getAttribute(SessionEnum.USER_INFO.key()); |
| 51 | - | ||
| 52 | -// /**2.判断登录人是领导还是员工 ,2:员工,1:领导*/ | ||
| 53 | -// List<Long> opIdLists = new ArrayList<>(); | ||
| 54 | -// opIdLists.add(asraOpDTO.getId()); | ||
| 55 | -// if(asraOpDTO.getRoleId() == 1){ | ||
| 56 | -// /**如果是领导,获取领导下面的员工信息*/ | ||
| 57 | -// AsraOpRelationsQueryReq asraOpRelationsQueryReq = new AsraOpRelationsQueryReq(); | ||
| 58 | -// asraOpRelationsQueryReq.setParentId(asraOpDTO.getId()); | ||
| 59 | -// BizResult<List<AsraOpRelationsDTO>> listBizResult = asraOpRelationsQueryService.queryAsraOpRelations(asraOpRelationsQueryReq); | ||
| 60 | -// if(listBizResult.isSuccess() && CollectionUtil.isNotEmpty(listBizResult.getData())){ | ||
| 61 | -// for(AsraOpRelationsDTO asraOpRelationsDTO : listBizResult.getData()){ | ||
| 62 | -// opIdLists.add(asraOpRelationsDTO.getOpId()); | ||
| 63 | -// } | ||
| 64 | -// } | ||
| 65 | -// } | ||
| 66 | -// asraOpQueryReq.setOpIdLists(opIdLists); | ||
| 67 | asraOpQueryReq.setId(asraOpDTO.getId()); | 49 | asraOpQueryReq.setId(asraOpDTO.getId()); |
| 68 | BizResult<PageBean<AsraOpDTO>> result = asraOpQueryService.queryAsraOpForPage(asraOpQueryReq); | 50 | BizResult<PageBean<AsraOpDTO>> result = asraOpQueryService.queryAsraOpForPage(asraOpQueryReq); |
| 69 | logger.info("日报系统-员工管理-根据登录人分页查询员工信息结果:{}", JSONObject.toJSON(result)); | 51 | logger.info("日报系统-员工管理-根据登录人分页查询员工信息结果:{}", JSONObject.toJSON(result)); |
| 70 | - return result; | 52 | + return returnJqGridData(result, AsraOpDTO.class); |
| 71 | } | 53 | } |
| 72 | 54 | ||
| 73 | } | 55 | } |
src/main/java/com/zteits/oa/report/web/BizController.java
0 → 100644
| 1 | +package com.zteits.oa.report.web; | ||
| 2 | + | ||
| 3 | +import com.alibaba.fastjson.JSONObject; | ||
| 4 | +import com.zteits.oa.api.base.bean.BizResult; | ||
| 5 | +import com.zteits.oa.api.base.bean.PageBean; | ||
| 6 | +import com.zteits.oa.api.base.constants.ErrorType; | ||
| 7 | +import com.zteits.oa.api.base.exception.BizException; | ||
| 8 | +import com.zteits.oa.report.web.vo.EasyUIDataGridVO; | ||
| 9 | +import org.springframework.beans.BeanUtils; | ||
| 10 | +import org.springframework.util.CollectionUtils; | ||
| 11 | + | ||
| 12 | +import javax.servlet.http.HttpServletResponse; | ||
| 13 | +import java.io.IOException; | ||
| 14 | +import java.io.InputStream; | ||
| 15 | +import java.io.OutputStream; | ||
| 16 | +import java.io.UnsupportedEncodingException; | ||
| 17 | +import java.util.ArrayList; | ||
| 18 | +import java.util.HashMap; | ||
| 19 | +import java.util.List; | ||
| 20 | +import java.util.Map; | ||
| 21 | + | ||
| 22 | +/** | ||
| 23 | + * @描述: | ||
| 24 | + * Copyright: Copyright (c) 2017 Alibb | ||
| 25 | + * | ||
| 26 | + * @ClassName: BizController.java | ||
| 27 | + * @Description: 所有基于Spring MVC的Web控制器类(Action)的统一父类,提供一些便利的请求处理方法,如返回Json、文本数据等 | ||
| 28 | + * @version: v1.0.0 | ||
| 29 | + * @author: wangbiao | ||
| 30 | + * @date: 2017年2月23日 下午1:26:50 | ||
| 31 | + * | ||
| 32 | + * Modification History: | ||
| 33 | + * Date Author Version Description | ||
| 34 | + *---------------------------------------------------------* | ||
| 35 | + * 2017年2月23日 wangbiao v1.0.0 创建 | ||
| 36 | + */ | ||
| 37 | +public class BizController { | ||
| 38 | + private static final String MIME_JSON = "application/json;charset=UTF-8"; | ||
| 39 | + | ||
| 40 | + | ||
| 41 | + /** | ||
| 42 | + * 返回jqgrid格式数据 | ||
| 43 | + * @param bizResult | ||
| 44 | + * @param voClass | ||
| 45 | + * @return | ||
| 46 | + * @throws InstantiationException | ||
| 47 | + * @throws IllegalAccessException | ||
| 48 | + * 2017年5月12日 zhaowg | ||
| 49 | + */ | ||
| 50 | + protected <DTO,VO> BizResult<EasyUIDataGridVO<VO>> returnJqGridData(BizResult<PageBean<DTO>> bizResult, Class<VO> voClass) throws InstantiationException, IllegalAccessException { | ||
| 51 | + PageBean<DTO> pageBean = getBizResultData(bizResult); | ||
| 52 | + //将DTO转换为VO | ||
| 53 | + List<VO> vos = new ArrayList<>(); | ||
| 54 | + if(!CollectionUtils.isEmpty(pageBean.getDataList())){ | ||
| 55 | + for (DTO dto : pageBean.getDataList()) { | ||
| 56 | + VO vo = voClass.newInstance(); | ||
| 57 | + BeanUtils.copyProperties(dto, vo); | ||
| 58 | + vos.add(vo); | ||
| 59 | + } | ||
| 60 | + } | ||
| 61 | + //返回jqGrid数据 | ||
| 62 | + EasyUIDataGridVO<VO> jqGridDatas = new EasyUIDataGridVO<>(); | ||
| 63 | + jqGridDatas.setTotal(pageBean.getPageTotals()==null?0:pageBean.getPageTotals()); | ||
| 64 | + jqGridDatas.setRows(vos); | ||
| 65 | + | ||
| 66 | + BizResult<EasyUIDataGridVO<VO>> bizResultVO = new BizResult<>(); | ||
| 67 | + bizResultVO.setCode(bizResult.getCode()); | ||
| 68 | + bizResultVO.setErrMsg(bizResult.getErrMsg()); | ||
| 69 | + bizResultVO.setData(jqGridDatas); | ||
| 70 | + | ||
| 71 | + return bizResultVO; | ||
| 72 | + } | ||
| 73 | + | ||
| 74 | + /** | ||
| 75 | + * 返回jqgrid格式数据 | ||
| 76 | + * @param bizResult | ||
| 77 | + * @return | ||
| 78 | + * 2017年5月12日 zhaowg | ||
| 79 | + */ | ||
| 80 | + protected <DTO> BizResult<EasyUIDataGridVO<DTO>> returnJqGridData(BizResult<PageBean<DTO>> bizResult) { | ||
| 81 | + PageBean<DTO> pageBean = getBizResultData(bizResult); | ||
| 82 | + //返回jqGrid数据 | ||
| 83 | + EasyUIDataGridVO<DTO> jqGridDatas = new EasyUIDataGridVO<>(); | ||
| 84 | + jqGridDatas.setTotal(pageBean.getPageTotals()==null?0:pageBean.getPageTotals()); | ||
| 85 | + jqGridDatas.setRows(pageBean.getDataList()); | ||
| 86 | + | ||
| 87 | + BizResult<EasyUIDataGridVO<DTO>> bizResultVO = new BizResult<>(); | ||
| 88 | + bizResultVO.setCode(bizResult.getCode()); | ||
| 89 | + bizResultVO.setErrMsg(bizResult.getErrMsg()); | ||
| 90 | + bizResultVO.setData(jqGridDatas); | ||
| 91 | + | ||
| 92 | + return bizResultVO; | ||
| 93 | + } | ||
| 94 | + /** | ||
| 95 | + * 分页结果封装后返回标准格式JSON串.<br/> | ||
| 96 | + * @param response | ||
| 97 | + * @param result | ||
| 98 | + */ | ||
| 99 | + @SuppressWarnings("unused") | ||
| 100 | + public void returnJsonDataGrid(HttpServletResponse response,BizResult<?> result){ | ||
| 101 | + Map<String,Object> resultMap = new HashMap<String,Object>(); | ||
| 102 | + | ||
| 103 | + if(result == null){ | ||
| 104 | + throw new NullPointerException("result 为空,不能进行封装!"); | ||
| 105 | + }else if(result.getData() == null){ | ||
| 106 | + throw new NullPointerException("pageBean 为空,不能进行封装!"); | ||
| 107 | + }else{ | ||
| 108 | + if(result.getData() instanceof PageBean<?>) { | ||
| 109 | + PageBean<?> pageBean = (PageBean<?>)result.getData(); | ||
| 110 | + Map<String,Object> map = new HashMap<String,Object>(); | ||
| 111 | + map.put("total", (null ==pageBean.getPageTotals()? 0 :pageBean.getPageTotals())); | ||
| 112 | + map.put("rows", pageBean.getDataList() != null ? pageBean.getDataList() :new ArrayList<Object>() ); | ||
| 113 | + resultMap.put("code", result.getCode()); | ||
| 114 | + resultMap.put("msg", result.getErrMsg()); | ||
| 115 | + resultMap.put("data", map); | ||
| 116 | + | ||
| 117 | + }else{ | ||
| 118 | + throw new ClassCastException("result.getData() 类型转换异常"); | ||
| 119 | + } | ||
| 120 | + | ||
| 121 | + } | ||
| 122 | + this.returnJson(response, resultMap); | ||
| 123 | + } | ||
| 124 | + | ||
| 125 | + /** | ||
| 126 | + * | ||
| 127 | + * @param data | ||
| 128 | + * @param totalCount | ||
| 129 | + * @return | ||
| 130 | + * 2017年5月12日 zhaowg | ||
| 131 | + */ | ||
| 132 | + public <VO> BizResult<EasyUIDataGridVO<VO>> returnGridData4JqGrid(List<VO> data,Integer totalCount) { | ||
| 133 | + //返回jqGrid数据 | ||
| 134 | + EasyUIDataGridVO<VO> jqGridDatas = new EasyUIDataGridVO<>(); | ||
| 135 | + jqGridDatas.setTotal(totalCount==null?0:totalCount); | ||
| 136 | + jqGridDatas.setRows(data); | ||
| 137 | + | ||
| 138 | + BizResult<EasyUIDataGridVO<VO>> bizResultVO = new BizResult<>(); | ||
| 139 | + bizResultVO.setCode(ErrorType.BIZ_SUCCESS.getCode()); | ||
| 140 | + bizResultVO.setErrMsg(ErrorType.BIZ_SUCCESS.getMsg()); | ||
| 141 | + bizResultVO.setData(jqGridDatas); | ||
| 142 | + return bizResultVO; | ||
| 143 | + } | ||
| 144 | + /** | ||
| 145 | + * 获取返回的数据 | ||
| 146 | + * @param bizResult | ||
| 147 | + * @return | ||
| 148 | + * 2017年5月16日 zhaowg | ||
| 149 | + */ | ||
| 150 | + public <T> T getBizResultData(BizResult<T> bizResult){ | ||
| 151 | + //有异常,抛出 | ||
| 152 | + if(!bizResult.isSuccess() || !bizResult.getCode().equals(ErrorType.BIZ_SUCCESS.getCode())){ | ||
| 153 | + | ||
| 154 | + throw new BizException(ErrorType.BIZ_ERROR,bizResult.getErrMsg()); | ||
| 155 | + } | ||
| 156 | + return bizResult.getData(); | ||
| 157 | + } | ||
| 158 | + /** | ||
| 159 | + * 返回JSon格式的数据 | ||
| 160 | + * | ||
| 161 | + * @param response | ||
| 162 | + * @param data | ||
| 163 | + * @throws Exception | ||
| 164 | + */ | ||
| 165 | + public String returnJson(HttpServletResponse response, Object data) { | ||
| 166 | + | ||
| 167 | + return returnText(response, JSONObject.toJSONString(data), MIME_JSON); | ||
| 168 | + } | ||
| 169 | + | ||
| 170 | + /** | ||
| 171 | + * 返回xml格式的数据 | ||
| 172 | + * | ||
| 173 | + * @param response | ||
| 174 | + * @param text | ||
| 175 | + * @throws Exception | ||
| 176 | + */ | ||
| 177 | + public String returnXml(HttpServletResponse response, CharSequence text) { | ||
| 178 | + return returnText(response, text, "text/xml;charset=UTF-8"); | ||
| 179 | + } | ||
| 180 | + | ||
| 181 | + /** | ||
| 182 | + * 返回文本数据 | ||
| 183 | + * @param response | ||
| 184 | + * @param text | ||
| 185 | + * @param contenttype 内容类型,如:text/plain、text/xml、application/json、text/json、text/javascript、application/javascript(不支持旧浏览器) | ||
| 186 | + * @param encoding 字符集编码,如:GB18030、UTF-8,不建议使用GB2312和GBK | ||
| 187 | + * @throws Exception | ||
| 188 | + */ | ||
| 189 | + public String returnText(HttpServletResponse response, CharSequence text,final String contenttype,final String encoding) { | ||
| 190 | + return returnText(response, text, contenttype+";charset="+encoding); | ||
| 191 | + } | ||
| 192 | + | ||
| 193 | + /** | ||
| 194 | + * 返回文本数据 | ||
| 195 | + * | ||
| 196 | + * @param response | ||
| 197 | + * @param text | ||
| 198 | + * @param contenttype | ||
| 199 | + * @throws IOException | ||
| 200 | + * @author lihl2 2011-3-25 | ||
| 201 | + */ | ||
| 202 | + public String returnText(HttpServletResponse response, CharSequence text,final String contenttype) { | ||
| 203 | + response.setContentType(contenttype); | ||
| 204 | + if (text != null) { | ||
| 205 | + try { | ||
| 206 | + response.getWriter().write(text.toString()); | ||
| 207 | + } catch (IOException e) { | ||
| 208 | + throw new BizException(ErrorType.BIZ_ERROR,e); | ||
| 209 | + } | ||
| 210 | + } | ||
| 211 | + return null; | ||
| 212 | + } | ||
| 213 | + | ||
| 214 | + /** | ||
| 215 | + * 设置文件头格式 | ||
| 216 | + * @param response | ||
| 217 | + * @param mimeType | ||
| 218 | + * @param fileName | ||
| 219 | + * @param size | ||
| 220 | + */ | ||
| 221 | + public void setFileHeader(HttpServletResponse response, CharSequence mimeType, | ||
| 222 | + final CharSequence fileName, int size) { | ||
| 223 | + response.reset(); | ||
| 224 | + // 设置response的Header | ||
| 225 | + if(mimeType != null){ | ||
| 226 | + response.setContentType(mimeType.toString()) ; | ||
| 227 | + } | ||
| 228 | + try { | ||
| 229 | + response.addHeader("Content-Disposition","attachment;filename=" + new String(fileName.toString().getBytes("GB18030"),"ISO-8859-1")) ; | ||
| 230 | + } catch (UnsupportedEncodingException e) { | ||
| 231 | + throw new BizException(ErrorType.BIZ_ERROR,"文件名编码转换失败") ; | ||
| 232 | + } | ||
| 233 | + if(size > 0){ | ||
| 234 | + response.addIntHeader("Content-Length", size) ; | ||
| 235 | + } | ||
| 236 | + } | ||
| 237 | + | ||
| 238 | + /** | ||
| 239 | + * 设置浏览器返回类型为Excel文件 | ||
| 240 | + * @param response | ||
| 241 | + * @param mimeType | ||
| 242 | + * @param fileName | ||
| 243 | + * @param size | ||
| 244 | + */ | ||
| 245 | + public void setExcelFileHeader(HttpServletResponse response, CharSequence mimeType, | ||
| 246 | + final CharSequence fileName, int size) { | ||
| 247 | + setFileHeader(response, "application/vnd.ms-excel", fileName, size); | ||
| 248 | + } | ||
| 249 | + /** | ||
| 250 | + * 文件下载 | ||
| 251 | + * @param response | ||
| 252 | + * @param mimeType | ||
| 253 | + * @param fileName | ||
| 254 | + * @param file | ||
| 255 | + * @param size | ||
| 256 | + */ | ||
| 257 | + public void downloadFile(HttpServletResponse response, CharSequence mimeType, | ||
| 258 | + final CharSequence fileName, InputStream file, int size) { | ||
| 259 | + setFileHeader(response, mimeType, fileName, size) ; | ||
| 260 | + try { | ||
| 261 | + OutputStream out = response.getOutputStream() ; | ||
| 262 | + int l ; | ||
| 263 | + while((l=file.read()) >= 0){ | ||
| 264 | + out.write(l) ; | ||
| 265 | + } | ||
| 266 | + out.flush() ; | ||
| 267 | + } catch (IOException e) { | ||
| 268 | + throw new BizException(ErrorType.BIZ_ERROR,"下载文件失败") ; | ||
| 269 | + }finally { | ||
| 270 | + if (null != file) { | ||
| 271 | + try { | ||
| 272 | + file.close(); | ||
| 273 | + } catch (IOException e) { | ||
| 274 | + e.printStackTrace(); | ||
| 275 | + } | ||
| 276 | + } | ||
| 277 | + | ||
| 278 | + } | ||
| 279 | + } | ||
| 280 | + | ||
| 281 | + | ||
| 282 | + | ||
| 283 | + | ||
| 284 | + | ||
| 285 | + /** | ||
| 286 | + * 返回jqgrid格式数据 | ||
| 287 | + * @param bizResult | ||
| 288 | + * @param voClass | ||
| 289 | + * @return | ||
| 290 | + * @throws InstantiationException | ||
| 291 | + * @throws IllegalAccessException | ||
| 292 | + * 2017年5月12日 zhaowg | ||
| 293 | + */ | ||
| 294 | + protected <DTO,VO> BizResult<EasyUIDataGridVO<VO>> returnJqGridDataByList(BizResult<List<DTO>> bizResult,int total,Class<VO> voClass) throws InstantiationException, IllegalAccessException { | ||
| 295 | + //List<DTO> pageBean = getBizResultData(bizResult); | ||
| 296 | + //将DTO转换为VO | ||
| 297 | + List<VO> vos = new ArrayList<>(); | ||
| 298 | + if(!CollectionUtils.isEmpty(bizResult.getData())){ | ||
| 299 | + for (DTO dto : bizResult.getData()) { | ||
| 300 | + VO vo = voClass.newInstance(); | ||
| 301 | + BeanUtils.copyProperties(dto, vo); | ||
| 302 | + vos.add(vo); | ||
| 303 | + } | ||
| 304 | + } | ||
| 305 | + //返回jqGrid数据 | ||
| 306 | + EasyUIDataGridVO<VO> jqGridDatas = new EasyUIDataGridVO<>(); | ||
| 307 | + | ||
| 308 | + jqGridDatas.setTotal(total); | ||
| 309 | + jqGridDatas.setRows(vos); | ||
| 310 | + | ||
| 311 | + BizResult<EasyUIDataGridVO<VO>> bizResultVO = new BizResult<>(); | ||
| 312 | + bizResultVO.setCode(bizResult.getCode()); | ||
| 313 | + bizResultVO.setErrMsg(bizResult.getErrMsg()); | ||
| 314 | + bizResultVO.setData(jqGridDatas); | ||
| 315 | + | ||
| 316 | + return bizResultVO; | ||
| 317 | + } | ||
| 318 | + | ||
| 319 | + | ||
| 320 | + | ||
| 321 | +} |
src/main/java/com/zteits/oa/util/pagepaper/DateForObjectUtil.java
0 → 100644
| 1 | +package com.zteits.oa.util.pagepaper; | ||
| 2 | + | ||
| 3 | +import com.xiaoleilu.hutool.date.DateUtil; | ||
| 4 | +import com.zteits.oa.api.dto.asradaily.AsraDailyDTO; | ||
| 5 | +import com.zteits.oa.api.dto.asradaily.AsraDailyDateChangeDTO; | ||
| 6 | + | ||
| 7 | +import java.util.Date; | ||
| 8 | + | ||
| 9 | +/** | ||
| 10 | + * Copyright: Copyright (c) 2018 zteits | ||
| 11 | + * | ||
| 12 | + * @Description: | ||
| 13 | + * @version: v1.0.0 | ||
| 14 | + * @author: xiejianpeng | ||
| 15 | + * @date: 2018/8/1 10 | ||
| 16 | + * Modification History: | ||
| 17 | + * Date Author Version Description | ||
| 18 | + * ---------------------------------------------------------* | ||
| 19 | + * 2018/8/1 xiejianpeng v1.0.0 创建 | ||
| 20 | + */ | ||
| 21 | +public class DateForObjectUtil { | ||
| 22 | + | ||
| 23 | + public static AsraDailyDateChangeDTO getAsraDailyDTO(Date dailyDate){ | ||
| 24 | + AsraDailyDateChangeDTO asraDailyDTO = new AsraDailyDateChangeDTO(); | ||
| 25 | + Integer week = DateUtil.weekOfYear(dailyDate);//第N周 | ||
| 26 | + Integer year = DateUtil.year(dailyDate);//年 | ||
| 27 | + Integer weekNum = DateUtil.dayOfWeek(dailyDate);//星期 | ||
| 28 | + | ||
| 29 | + asraDailyDTO.setYears(year); | ||
| 30 | + asraDailyDTO.setWeeks(week); | ||
| 31 | + asraDailyDTO.setWeeksNum(weekNum); | ||
| 32 | + | ||
| 33 | + return asraDailyDTO; | ||
| 34 | + } | ||
| 35 | +} |
src/main/resources/mybatis/smapper/AsraOpSmapper.xml
| @@ -26,7 +26,7 @@ | @@ -26,7 +26,7 @@ | ||
| 26 | modfiy_emp_name, modfiy_date, remark | 26 | modfiy_emp_name, modfiy_date, remark |
| 27 | </sql> | 27 | </sql> |
| 28 | 28 | ||
| 29 | - <select id="queryAsraOpForList" parameterType="com.zteits.oa.api.dto.asraop.param.AsraOpQueryReq" resultMap="BaseResultMap"> | 29 | + <select id="queryAsraOpForList" parameterType="com.zteits.oa.api.dto.asraop.param.AsraOpQueryReq" resultType="com.zteits.oa.api.dto.asraop.AsraOpDTO"> |
| 30 | select | 30 | select |
| 31 | ap.id id, | 31 | ap.id id, |
| 32 | ap.login_code loginCode, | 32 | ap.login_code loginCode, |