Commit 890285e2 authored by nie'hong's avatar nie'hong

完善工时统计

parent 330253f7
package cn.wisenergy.common.config.multipleDatasource;
import com.alibaba.druid.spring.boot.autoconfigure.DruidDataSourceBuilder;
import com.github.pagehelper.PageInterceptor;
import org.apache.ibatis.plugin.Interceptor;
import org.apache.ibatis.session.SqlSessionFactory;
import org.mybatis.spring.SqlSessionFactoryBean;
import org.mybatis.spring.SqlSessionTemplate;
import org.mybatis.spring.annotation.MapperScan;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.core.io.support.PathMatchingResourcePatternResolver;
import org.springframework.jdbc.datasource.DataSourceTransactionManager;
import javax.sql.DataSource;
import java.util.Properties;
/**
* @description:
* @author: nh
* @create: 2021-04-20 10:25
**/
@Configuration
@MapperScan(basePackages = "cn.wisenergy.oaMapper", sqlSessionFactoryRef = "oaSqlSessionFactory")
public class OaDataSourceConfig {
@Bean("oaDataSource")
@ConfigurationProperties("spring.datasource.druid.one")
public DataSource dataSource(){
return DruidDataSourceBuilder.create().build();
}
@Bean("oaSqlSessionFactory")
public SqlSessionFactory sqlSessionFactory(@Qualifier("oaDataSource") DataSource dataSource) throws Exception {
SqlSessionFactoryBean bean = new SqlSessionFactoryBean();
bean.setDataSource(dataSource);
bean.setMapperLocations(
// 设置mybatis的xml所在位置
new PathMatchingResourcePatternResolver().getResources("classpath:/oaMapper/*Mapper.xml"));
//分页插件
Interceptor interceptor = new PageInterceptor();
Properties properties = new Properties();
//数据库
properties.setProperty("helperDialect", "mysql");
//是否将参数offset作为PageNum使用
properties.setProperty("offsetAsPageNum", "true");
//是否进行count查询
properties.setProperty("rowBoundsWithCount", "true");
//是否分页合理化
properties.setProperty("reasonable", "false");
interceptor.setProperties(properties);
bean.setPlugins(new Interceptor[] {interceptor});
return bean.getObject();
}
@Bean("oaSqlSessionTemplate")
public SqlSessionTemplate sqlSessionFactory(@Qualifier("oaSqlSessionFactory")SqlSessionFactory sqlSessionFactory ){
return new SqlSessionTemplate(sqlSessionFactory);
}
@Bean
public DataSourceTransactionManager dataSourceTransactionManager(@Qualifier("oaDataSource") DataSource dataSource) {
return new DataSourceTransactionManager(dataSource);
}
}
package cn.wisenergy.common.config.multipleDatasource;
import com.alibaba.druid.spring.boot.autoconfigure.DruidDataSourceBuilder;
import com.baomidou.mybatisplus.extension.spring.MybatisSqlSessionFactoryBean;
import org.apache.ibatis.session.SqlSessionFactory;
import org.mybatis.spring.SqlSessionTemplate;
import org.mybatis.spring.annotation.MapperScan;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.Primary;
import org.springframework.core.io.support.PathMatchingResourcePatternResolver;
import org.springframework.jdbc.datasource.DataSourceTransactionManager;
import javax.sql.DataSource;
/**
* @description:
* @author: nh
* @create: 2021-04-20 09:47
**/
@Configuration
@MapperScan(basePackages = "cn.wisenergy.mapper", sqlSessionFactoryRef = "primarySqlSessionFactory")
public class PrimaryConfig {
@Primary
@Bean(name = "primaryDataSource")
@ConfigurationProperties(prefix = "spring.datasource.druid.two")
public DataSource primaryDataSource() {
return DruidDataSourceBuilder.create().build();
}
@Primary
@Bean(name = "primarySqlSessionFactory")
public SqlSessionFactory primarySqlSession(@Qualifier("primaryDataSource") DataSource dataSource) throws Exception {
// 扫描的mapper中有使用mybatis-plus这里需要使用MybatisSqlSessionFactoryBean 不然BaseMapper中的方法不会被加载
MybatisSqlSessionFactoryBean bean = new MybatisSqlSessionFactoryBean();
bean.setDataSource(dataSource);
bean.setMapperLocations(
// 设置mybatis的xml所在位置
new PathMatchingResourcePatternResolver().getResources("classpath:mapper/*.xml"));
// bean.setConfigLocation(
// new PathMatchingResourcePatternResolver().getResource("classpath:MybatisConfig.xml"));
return bean.getObject();
}
@Bean("primarySqlSessionTemplate")
@Primary
public SqlSessionTemplate primaryJdbcTemplate(@Qualifier("primarySqlSessionFactory") SqlSessionFactory factory){
return new SqlSessionTemplate(factory);
}
@Bean
@Primary
public DataSourceTransactionManager dataSourceTransactionManager(@Qualifier("primaryDataSource") DataSource dataSource){
return new DataSourceTransactionManager(dataSource);
}
}
......@@ -605,7 +605,7 @@ public class DateUtil {
* @return List
*/
public static List<Date> getDatesBetweenTwoDate(Date startDate, Date endDate) {
List<Date> dates = new ArrayList<Date>();
List<Date> dates = new ArrayList<>();
dates.add(startDate);// 把开始时间加入集合
Calendar cal = Calendar.getInstance();
// 使用给定的 Date 设置此 Calendar 的时间
......@@ -813,7 +813,7 @@ public class DateUtil {
Date date = new Date();
Calendar calendar = new GregorianCalendar();
calendar.setTime(date);
calendar.add(calendar.DATE,1);//把日期往后增加一天.整数往后推,负数往前移动
calendar.add(Calendar.DATE,1);//把日期往后增加一天.整数往后推,负数往前移动
calendar.set(Calendar.HOUR_OF_DAY, 0);
calendar.set(Calendar.MINUTE, 0);
calendar.set(Calendar.SECOND, 0);
......
......@@ -16,7 +16,7 @@ public enum BASE_RESP_CODE_ENUM {
MEDIA_TYPE_NOT_ACCEPT("406", "无法接受请求中的媒体类型"),
REQUEST_TIME_OUT("408", "无法接受请求中的媒体类型"),
MEDIA_TYPE_NOT_SUPPORTED("415", "不支持的媒体类型"),
PLEASE_RE_LOGIN("444", "未登录或已下线,请重新登录"),
PLEASE_RE_LOGIN("444", "已下线,请重新登录"),
SERVER_ERROR("500", "获取数据异常"),
INPUT_PARAM_IS_NULL("600", "入参为空"),
WORK_ORDER_INFO_IS_NULL("601", "工单信息为空"),
......@@ -88,7 +88,13 @@ public enum BASE_RESP_CODE_ENUM {
ATLEASTONEADMINISTRATORISREQUIRED("670", "至少需要一个系统管理员!"),
PLEASESELECTANITEM("671", "请选择一个项目"),
PLEASESELECTADEPARTMENT("672","请选择一个部门"),
WECHAT_NOT_BIND("673","微信未绑定")
WECHAT_NOT_BIND("673","微信未绑定"),
DATE_HANDLE_ERROR("674", "数据处理出错"),
WORK_DAY_IS_REPEAT("675", "所选日期段内已有填报,请重新选择"),
LONG_LEAVE_TYPE_ERROR("676","填报长假/长休类型错误,只能填报请假和调休"),
LONG_LEAVE_DATE_NOT_ONLY_HOLIDAY("677", "长请假/调休不能只包含节假日"),
LONG_LEAVE_DATE_ERROR("678", "长请假/调休所选择时间超出规定填报时间"),
NEW_PROJECT_OA_PROJECT_ID_OR_NAME_ERROR("679","新建项目/商机对应编号在OA中未找到")
;
......
......@@ -43,4 +43,14 @@ public interface WorkCollectMapper extends BaseMapper<WorkCollect> {
int updateStatusOrTotalTime(@Param("id") Integer id,@Param("status") Integer status,@Param("totalTime") Integer totalTime);
List<WorkCollect> getCompletedByUserIdAndMonth(@Param("userId") Integer userId, @Param("month") Date month);
/**
* 批量插入汇总
* @param workCollects
* @return
*/
int addManyLeaveCollect(@Param("workCollects") List<WorkCollect> workCollects);
WorkCollect getWorkCollectByUserIdAndWorkDay(@Param("userId") Integer userId, @Param("workDay") Date workDay);
}
......@@ -30,4 +30,11 @@ public interface WorkDeptMapper extends BaseMapper<WorkDept> {
List<WorkDept> getDeptByManagerId(Integer userId);
List<DeptOfProjectAndOrderType> getDeptOfProjectAndOrderType(@Param("userId") Integer userId, @Param("deptId") Integer deptId);
/**
* 根据用户主键查询所在部门的oa编号
* @param userId
* @return
*/
WorkDept getOaDeptNoByUserId(Integer userId);
}
package cn.wisenergy.mapper;
import cn.wisenergy.model.app.WorkLeave;
import java.util.List;
public interface WorkLeaveMapper {
int insert(WorkLeave workLeave);
List<WorkLeave> getListByUserId(Integer userId);
}
......@@ -68,4 +68,16 @@ public interface WorkProjectMapper extends BaseMapper<WorkProject> {
* 工单变更,获取管理员所管理的项目/商机和参与人员
*/
List<OrderChangeTypeDto> getOrderChangeTypeDtos(Integer userId);
/**
* 获取项目/商机集合
* @param deptId
* @param typeId
* @param projectNameOrNo 项目的oa编号或名称模糊查询
* @return
*/
List<WorkProject> getListByDeptAndType(@Param("deptId") Integer deptId, @Param("typeId") Integer typeId, @Param("projectNameOrNo") String projectNameOrNo);
WorkProject getByProjectNameOrOaId(@Param("projectName") String projectName, @Param("oaId") String oaId);
}
......@@ -13,4 +13,5 @@ import com.baomidou.mybatisplus.core.mapper.BaseMapper;
*/
public interface WorkSubmitAdoptMapper extends BaseMapper<WorkSubmitAdopt> {
}
......@@ -109,4 +109,10 @@ public interface WorkTimeOrderMapper extends BaseMapper<WorkTimeOrder> {
List<DeptUserCollectDto> getDeptNotOrderInfo(@Param("userId") Integer userId,@Param("depts") List<Integer> depts,@Param("startDate") Date startDate, @Param("endDate") Date endDate);
List<OrderChangePageDto> getOrderChangePage(OrderChangeLogMapperDto mapperDto);
List<ProjectWorkTimeStatisticsDto> getProjectStatisticsDetail(Map<String, Object> map);
int countByWorkDay(@Param("userId") Integer userId, @Param("startDate") String startDate, @Param("enbDate") String endDate);
int addManyLeaveOrder(@Param("workTimeOrders") List<WorkTimeOrder> workTimeOrders);
}
......@@ -58,4 +58,6 @@ public interface WorkUserMapper extends BaseMapper<WorkUser> {
WorkUser getUserByOpenId(String openid);
int clearOpenidByUserId(Integer userId);
List<WorkUser> getUserByIds(@Param("userIds") List<String> userIds);
}
package cn.wisenergy.oaMapper;
import cn.wisenergy.oaModel.OaProject;
import org.apache.ibatis.annotations.Param;
import java.util.List;
import java.util.Map;
/**
* @description: 项目和商机的mapper
* @author: nh
* @create: 2021-04-20 11:03
**/
public interface ProjectAndBoMapper {
List<OaProject> getListOaProjectByDept(@Param("oaDeptNo") String oaDeptNo,@Param("projectNameOrNo") String projectNameOrNo, @Param("oaProjectIds") List<String> oaProjectIds);
List<OaProject> getListOaBoByDept(@Param("oaDeptNo") String oaDeptNo ,@Param("projectNameOrNo") String projectNameOrNo, @Param("oaProjectIds") List<String> oaProjectIds);
OaProject getProjectByNameAndNo(Map<String, Object> map);
OaProject getBoByNameAndNo(Map<String, Object> map);
}
......@@ -41,6 +41,19 @@
<include refid="vals"/>
)
</insert>
<insert id="addManyLeaveCollect" keyProperty="id" useGeneratedKeys="true">
insert into
<include refid="table"/>
(<include refid="cols_exclude_id"/>)
values
<foreach collection="workCollects" item="workCollect" separator=",">
(#{workCollect.userId},#{workCollect.workDay},#{workCollect.totalTime},
#{workCollect.status},null,#{workCollect.createTime},#{workCollect.modifyTime}
)
</foreach>
</insert>
<update id="updateStatusOrTotalTime">
UPDATE
<include refid="table"/>
......@@ -94,4 +107,12 @@
</select>
<select id="getWorkCollectByUserIdAndWorkDay" resultType="cn.wisenergy.model.app.WorkCollect">
SELECT
<include refid="Base_Column_List"/>
FROM
<include refid="table"/>
where user_id = #{userId} and work_day = #{workDay}
</select>
</mapper>
......@@ -116,4 +116,10 @@ ORDER BY d.sort,p.id
</select>
<select id="getOaDeptNoByUserId" resultMap="BaseResultMap">
select d.id,<include refid="cols_exclude_id"/>
from work_dept d join work_user_dept ud on d.id = ud.dept_id
where ud.user_id = #{userId}
</select>
</mapper>
......@@ -23,8 +23,11 @@
<select id="getByDate" resultMap="BaseResultMap">
select <include refid="Base_Column_List"/>
from <include refid="table"/>
where (year(day_start) = year(#{startDay}) AND month(day_start) = month(#{startDay})) OR
(year(day_end) = year(#{endDay}) AND month(day_end) = month(#{endDay}))
where (day_start >= #{startDay} and day_end &lt;= #{endDay}) OR
(day_start &lt;= #{startDay} and day_end >= #{endDay}) OR
(day_start >= #{startDay} and day_start &lt;= #{endDay}) OR
(day_end >= #{startDay} and day_end &lt;= #{endDay})
ORDER BY day_start
</select>
<select id="getByTypeAndStartDate" resultType="cn.wisenergy.model.app.WorkHoliday">
......
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="cn.wisenergy.mapper.WorkLeaveMapper">
<!-- 通用查询映射结果 -->
<resultMap id="BaseResultMap" type="cn.wisenergy.model.app.WorkLeave">
<id column="id" property="id"/>
<result column="user_id" property="userId"/>
<result column="type_id" property="typeId"/>
<result column="start_date" property="startDate"/>
<result column="end_date" property="endDate"/>
<result column="des" property="des"/>
<result column="create_time" property="createTime"/>
<result column="modify_time" property="modifyTime"/>
</resultMap>
<sql id="vals">
#{id},#{userId},#{typeId},#{startDate},#{endDate},#{des},#{createTime},#{modifyTime}
</sql>
<sql id="cols_exclude_id">
user_id, type_id, start_date, end_date, des, create_time, modify_time
</sql>
<sql id="cols">
id,<include refid="cols_exclude_id"/>
</sql>
<sql id="table">
work_leave
</sql>
<insert id="insert" useGeneratedKeys="true" keyProperty="id">
insert into <include refid="table"/>(<include refid="cols"/> )
value (<include refid="vals"/> )
</insert>
<select id="getListByUserId" resultMap="BaseResultMap">
select <include refid="cols"/>
from <include refid="table"/>
where user_id = #{userId}
order by start_date DESC
</select>
</mapper>
\ No newline at end of file
......@@ -54,9 +54,9 @@
OR u1.name like concat('%',#{userName},'%'))
</if>
)
</if>
</where>
ORDER BY oc.change_date desc
</if>
</where>
ORDER BY oc.change_date desc
</select>
</mapper>
\ No newline at end of file
......@@ -235,6 +235,7 @@
<if test="managerId != null and deptId == null">
AND manager_id = #{managerId}
</if>
<if test="year != null">
AND YEAR (create_time) &lt;= #{year} AND( year(conclusion_time) >= #{year} or is_conclusion = 1)
</if>
......@@ -306,5 +307,27 @@
ORDER BY t.sort,d1.sort,p.id
</select>
<select id="getListByOaIds" resultType="cn.wisenergy.model.app.WorkProject">
select <include refid="Base_Column_List"/>
from <include refid="table"/>
where oa_project_id in
<foreach collection="oaProjectIds" item="oaProjectId" open="(" close=")" separator=",">
#{oaProjectId}
</foreach>
</select>
<select id="getListByDeptAndType" resultType="cn.wisenergy.model.app.WorkProject">
select <include refid="Base_Column_List"/>
from <include refid="table"/>
where dept_id = #{deptId} AND type = #{typeId} AND (oa_project_id like CONCAT("%" ,#{projectNameOrNo},"%") OR project_name like CONCAT("%" ,#{projectNameOrNo},"%"))
</select>
<select id="getByProjectNameOrOaId" resultType="cn.wisenergy.model.app.WorkProject">
select <include refid="Base_Column_List"/>
from <include refid="table"/>
where project_name = #{projectName} OR oa_project_id = #{oaId}
</select>
</mapper>
......@@ -138,6 +138,7 @@
</if>
</where>
group by <if test="projectId != null and projectIds == null"> project_name,</if> <if test="projectId == null and projectIds != null"> project_name,dept_name,</if>year(statistics_start),MONTH(statistics_start)
order by convert(project_name using gbk)
</select>
<select id="selectListStatistics" resultMap="projectStatisticsByMonth">
......@@ -167,7 +168,7 @@
</if>
</where>
group by ptc.project_id,project_name,year(statistics_start),MONTH(statistics_start) <if test="projectId != null || (projectIds != null and !isAll) "> ,d.dept_name</if> <if test="projectIds != null and isAll">,d.dept_name ,u.name </if>
order by convert(project_name using gbk)
</select>
<select id="selectListByOtherType" resultMap="workTimeAndCostCollect">
......
......@@ -2,17 +2,17 @@
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="cn.wisenergy.mapper.WorkSubmitAdoptMapper">
<!-- 通用查询映射结果 -->
<resultMap id="BaseResultMap" type="cn.wisenergy.model.app.WorkSubmitAdopt">
<id column="id" property="id" />
<result column="submit_time" property="submitTime" />
<result column="auto_adopt" property="autoAdopt" />
<result column="order_change" property="orderChange"></result>
</resultMap>
<!--&lt;!&ndash; 通用查询映射结果 &ndash;&gt;-->
<!--<resultMap id="BaseResultMap" type="cn.wisenergy.model.app.WorkSubmitAdopt">-->
<!--<id column="id" property="id" />-->
<!--<result column="submit_time" property="submitTime" />-->
<!--<result column="auto_adopt" property="autoAdopt" />-->
<!--<result column="order_change" property="orderChange"></result>-->
<!--</resultMap>-->
<!-- 通用查询结果列 -->
<sql id="Base_Column_List">
id, submit_time, auto_adopt,order_change
</sql>
<!--&lt;!&ndash; 通用查询结果列 &ndash;&gt;-->
<!--<sql id="Base_Column_List">-->
<!--id, submit_time, auto_adopt,order_change-->
<!--</sql>-->
</mapper>
......@@ -95,6 +95,14 @@
<result property="approved" column="approved"/>
</resultMap>
<resultMap id="ProjectWorkTimeStatisticsDto" type="cn.wisenergy.model.dto.ProjectWorkTimeStatisticsDto">
<result property="projectName" column="project_name"/>
<result property="username" column="name"/>
<!--<result property="userDept" column="user_dept"/>-->
<result property="normalTime" column="normal_time"/>
<result property="overTime" column="over_time"/>
</resultMap>
<sql id="table">
work_time_order
</sql>
......@@ -108,6 +116,20 @@
)
</insert>
<insert id="addManyLeaveOrder" useGeneratedKeys="true" keyProperty="workId">
insert into
<include refid="table"/>
(<include refid="cols_exclude_id"/>)
values
<foreach collection="workTimeOrders" item="workTimeOrder" separator=",">
(#{workTimeOrder.userId},
null,#{workTimeOrder.deptId},#{workTimeOrder.workTime},#{workTimeOrder.workDay},
#{workTimeOrder.status},null,#{workTimeOrder.des},null,#{workTimeOrder.type},#{workTimeOrder.isOvertime},
null,#{workTimeOrder.createTime},#{workTimeOrder.modifyTime}
)
</foreach>
</insert>
<update id="updateByIds">
UPDATE
......@@ -336,19 +358,17 @@
<where>
status IN (1,4)
AND TIMESTAMPDIFF(HOUR,create_time,now()) > #{autoExamine}
AND TIMESTAMPDIFF(DAY,work_day,now()) > (#{autoExamine}/24)
</where>
</select>
<select id="getUserProjectWorkTimeStatistics" resultMap="userWorkTimeStatisticsByProject">
SELECT <if test="isAll">u.id AS user_id, u.`name` AS user_name, d.dept_name AS dept_name,</if>
<if test="!isAll">'合计' AS user_name ,</if> t.project_id AS project_id, t.type AS work_time_type, p.project_name
AS project_name,
IF(t.is_overtime = 0, <if test="!isAll">0</if>
<if test="isAll">null</if>, sum(t.work_time)) AS over_time, IF(t.is_overtime=1, <if test="!isAll">0</if>
<if test="isAll">null</if>, sum(t.work_time)) AS normal_time
<if test="!isAll">'合计' AS user_name ,</if> t.project_id AS project_id, t.type AS work_time_type, p.project_name AS project_name,
IF(t.is_overtime = 0, <if test="!isAll">0</if> <if test="isAll">null</if>, sum(t.work_time)) AS over_time,
IF(t.is_overtime=1, <if test="!isAll">0</if><if test="isAll">null</if>, sum(t.work_time)) AS normal_time
from work_time_order t left join work_project p on t.project_id = p.id join work_user u on t.user_id = u.id join work_type ty on t.type = ty.id join work_dept d on u.dept_id = d.id
where
t.status in (2,5) AND
......@@ -447,9 +467,47 @@
</where>
ORDER BY CONVERT( u.name USING gbk )
</select>
<select id="getProjectStatisticsDetail" resultMap="ProjectWorkTimeStatisticsDto">
SELECT t1.project_name,t1.name,if(sum(normal_time/8) is null,0,sum(normal_time/8)) AS normal_time,if(sum(over_time/8) is null,0,sum(over_time/8)) AS over_time
FROM (
SELECT project_name,u.name,sum(t.work_time) AS normal_time
FROM work_time_order t join work_user u on t.user_id = u.id
join work_project p on t.project_id = p.id
join work_type ty on t.type = ty.id
WHERE t.status in(2,5) AND is_overtime = 0 AND t.work_day>=#{startDate} AND t.work_day &lt;=#{endDate}
<if test="userId != null and deptId == null">
AND p.manager_id = #{userId}
</if>
<if test="deptId != null and userId == null">
AND p.dept_id = #{deptId}
</if>
<if test="deptId != null and userId != null">
AND (p.manager_id = #{userId} OR p.dept_id = #{deptId})
</if>
GROUP BY project_name,u.`name`
) t1 left join (
SELECT project_name,u.name,sum(t.work_time) AS over_time
FROM work_time_order t join work_user u on t.user_id = u.id
join work_project p on t.project_id = p.id
join work_type ty on t.type = ty.id
WHERE t.status in(2,5) AND is_overtime = 1 AND t.work_day>=#{startDate} AND t.work_day &lt;=#{endDate}
<if test="userId != null and deptId == null">
AND p.manager_id = #{userId}
</if>
<if test="deptId != null and userId == null">
AND p.dept_id = #{deptId}
</if>
<if test="deptId != null and userId != null">
AND (p.manager_id = #{userId} OR p.dept_id = #{deptId})
</if>
GROUP BY project_name,u.`name`
) t2 on t1.project_name = t2.project_name and t1.name = t2.name
GROUP BY t1.project_name,t1.`name`
ORDER BY CONVERT (t1.project_name USING gbk),CONVERT (t1. NAME USING gbk)
</select>
<select id="getOrderChangePage" resultType="cn.wisenergy.model.dto.OrderChangePageDto">
select o.work_id,o.project_id,p.project_name,u.name 'user_name',o.work_day,
o.work_time,t.name 'type_name',o.des,o.status
......@@ -495,6 +553,12 @@
</if>
</where>
ORDER BY o.work_day desc
ORDER BY o.work_day desc, o.create_time desc
</select>
<select id="countByWorkDay" resultType="java.lang.Integer">
SELECT COUNT(1)
FROM work_time_order
WHERE work_day >= #{startDate} AND work_day &lt;= #{enbDate} AND user_id = #{userId}
</select>
</mapper>
......@@ -195,4 +195,15 @@ LEFT JOIN work_role r on ur.role_id = r.id
</where>
</select>
<select id="getUserByIds" resultMap="BaseResultMap">
select <include refid="cols_all"/>
from <include refid="table"/>
<where>
oa_user_id in
<foreach collection="userIds" separator="," open="(" close=")" item="userId">
#{userId}
</foreach>
</where>
</select>
</mapper>
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="cn.wisenergy.oaMapper.ProjectAndBoMapper">
<resultMap id="Project_Map" type="cn.wisenergy.oaModel.OaProject">
<id column="project_no" property="no"/>
<result property="name" column="project_name"/>
<result property="managerNo" column="pm_no"/>
<result property="bo" column="bo_no"/>
<result property="bName" column="bo_name"/>
<result property="managerName" column="manager_name"/>
<result property="deptNo" column="project_depart_no"/>
<result property="deptName" column="project_depart_name"/>
<result property="cost" column="cost"/>
<result property="startDate" column="start_date"/>
<result property="endDate" column="end_date"/>
</resultMap>
<resultMap id="Bo_Map" type="cn.wisenergy.oaModel.OaProject">
<id column="project_no" property="no"/>
<result property="name" column="project_name"/>
<result property="managerNo" column="pm_no"/>
<result property="managerName" column="manager_name"/>
<result property="deptNo" column="project_depart_no"/>
<result property="deptName" column="project_depart_name"/>
<result property="cost" column="cost"/>
<result property="startDate" column="start_date"/>
<result property="endDate" column="end_date"/>
</resultMap>
<sql id="values_project">
project_no, project_name ,pm_no ,bo_no ,bo_name ,manager_name,
project_depart_no ,project_depart_name ,cost,start_date ,end_date
</sql>
<sql id="values_bo">
bo, bo_name,pm_no,manager_name,project_depart_no,project_depart_name
</sql>
<select id="getListOaProjectByDept" resultMap="Project_Map">
select p.project_no, p.project_name, p.pm_no, p.project_depart_no, p.cost, p.start_date, p.end_date, b.bo_no, b.bo_name
from v_project_base p left join v_bo_base b on p.bo_no = b.bo_no
where p.project_depart_no = #{oaDeptNo}
AND (p.project_no like CONCAT("%" ,#{projectNameOrNo},"%") OR p.project_name like CONCAT("%" ,#{projectNameOrNo},"%"))
<if test="oaProjectIds.size != 0">
AND p.project_no not in
<foreach collection="oaProjectIds" item="oaProject" open="(" close=")" separator=",">
#{oaProject}
</foreach>
</if>
</select>
<select id="getListOaBoByDept" resultMap="Bo_Map">
select b.bo_no AS project_no, b.bo_name AS project_name, b.pm_no, b.pm_name, b.project_depart_no, b.project_depart_name
from v_project_base p right join v_bo_base b on p.bo_no = b.bo_no
where (b.project_depart_no = #{oaDeptNo} OR p.project_depart_no = #{oaDeptNo})
AND (b.bo_no like CONCAT("%" ,#{projectNameOrNo},"%") OR b.bo_name like CONCAT("%" ,#{projectNameOrNo},"%"))
<if test="oaProjectIds.size != 0">
AND b.bo_no not in
<foreach collection="oaProjectIds" item="oaProject" open="(" close=")" separator=",">
#{oaProject}
</foreach>
</if>
</select>
<select id="getProjectByNameAndNo" resultMap="Project_Map">
select <include refid="values_project"/>
from v_project_base
where project_no = #{projectNo} AND project_name = #{projectName}
<!--<if test="boNo != null ">-->
<!--AND bo_no = #{boNo} -->
<!--</if>-->
</select>
<select id="getBoByNameAndNo" resultMap="Bo_Map">
select bo_no AS project_no, bo_name AS project_name,pm_no,manager_name,project_depart_no,project_depart_name
from v_bo_base
where bo_no = #{projectNo} AND bo_name = #{projectName}
</select>
</mapper>
\ No newline at end of file
......@@ -23,38 +23,38 @@
</dependency>
<!--mybatis-plus-->
<dependency>
<groupId>com.baomidou</groupId>
<artifactId>mybatis-plus-generator</artifactId>
<version>3.4.0</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>com.baomidou</groupId>
<artifactId>mybatis-plus-annotation</artifactId>
<version>3.4.0</version>
</dependency>
<dependency>
<groupId>com.baomidou</groupId>
<artifactId>mybatis-plus-extension</artifactId>
<version>3.4.0</version>
</dependency>
<dependency>
<groupId>com.baomidou</groupId>
<artifactId>mybatis-plus-boot-starter</artifactId>
<version>3.4.0</version>
</dependency>
<!--<dependency>-->
<!--<groupId>com.baomidou</groupId>-->
<!--<artifactId>mybatis-plus-generator</artifactId>-->
<!--<version>3.4.0</version>-->
<!--<scope>test</scope>-->
<!--</dependency>-->
<!--<dependency>-->
<!--<groupId>com.baomidou</groupId>-->
<!--<artifactId>mybatis-plus-annotation</artifactId>-->
<!--<version>3.4.0</version>-->
<!--</dependency>-->
<!--<dependency>-->
<!--<groupId>com.baomidou</groupId>-->
<!--<artifactId>mybatis-plus-extension</artifactId>-->
<!--<version>3.4.0</version>-->
<!--</dependency>-->
<!--<dependency>-->
<!--<groupId>com.baomidou</groupId>-->
<!--<artifactId>mybatis-plus-boot-starter</artifactId>-->
<!--<version>3.4.0</version>-->
<!--</dependency>-->
<dependency>
<groupId>org.apache.velocity</groupId>
<artifactId>velocity-engine-core</artifactId>
<version>2.0</version>
</dependency>
<dependency>
<groupId>com.baomidou</groupId>
<artifactId>mybatis-plus-generator</artifactId>
<version>3.4.1</version>
<scope>compile</scope>
</dependency>
<!--<dependency>-->
<!--<groupId>com.baomidou</groupId>-->
<!--<artifactId>mybatis-plus-generator</artifactId>-->
<!--<version>3.4.1</version>-->
<!--<scope>compile</scope>-->
<!--</dependency>-->
</dependencies>
<!-- MAVEN构建 -->
......
package cn.wisenergy.model.app;
import lombok.Data;
/**
* @description:
* @author: nh
* @create: 2021-04-14 09:47
**/
@Data
public class WorkLeave {
private Integer id;
private Integer userId;
private Integer typeId;
private String startDate;
private String endDate;
private String des;
private String createTime;
private String modifyTime;
}
package cn.wisenergy.model.dto;
import io.swagger.annotations.ApiModel;
import lombok.Data;
/**
* @description:
* @author: nh
* @create: 2021-04-14 10:22
**/
@Data
@ApiModel(value = "LeaveResult", description = "长假信息返回")
public class LeaveResult {
private String createTime;
private String typeName;
private String startDate;
private String endDate;
private String des;
}
package cn.wisenergy.model.dto;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
/**
* @description: 项目工时统计接口参数
* @author: nh
* @create: 2021-04-13 17:10
**/
@Data
@ApiModel(value = "ProjectTimeStatisticsParam", description = "项目工时统计接口参数")
public class ProjectTimeStatisticsParam {
@ApiModelProperty(name = "userId", value = "用户主键")
private Integer userId;
@ApiModelProperty(name = "deptId", value = "部门主键")
private Integer deptId;
@ApiModelProperty(name = "startDate", value = "开始请假日期")
private String startDate;
@ApiModelProperty(name = "endDate", value = "结束请假日期")
private String endDate;
@ApiModelProperty(name = "currentPage", value = "当前页")
private Integer currentPage;
@ApiModelProperty(name = "pageSize", value = "页面信息数量")
private Integer pageSize;
}
......@@ -25,8 +25,6 @@ public class ProjectWorkTimeAndType{
@ApiModelProperty(name = "workTimeType", value = "项目类型")
private Integer workTimeType;
/**
* 加班工时
*/
......
package cn.wisenergy.model.dto;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import java.math.BigDecimal;
/**
* @description: 项目工时统计
* @author: nh
* @create: 2021-04-13 10:05
**/
@Data
@ApiModel(value = "ProjectWorkTimeStatisticsDto", description = "项目工时统计传输类")
public class ProjectWorkTimeStatisticsDto {
@ApiModelProperty(name = "projectName", value = "项目名称")
private String projectName;
// @ApiModelProperty(name = "userDept", value = "用户填报时部门")
// private String userDept;
@ApiModelProperty(name = "username", value = "用户姓名")
private String username;
@ApiModelProperty(name = "normalTime", value = "正常工时(人/天)")
private BigDecimal normalTime;
@ApiModelProperty(name = "overTime", value = "加班工时(人/天)")
private BigDecimal overTime;
}
package cn.wisenergy.model.dto;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
/**
* @description:
* @author: nh
* @create: 2021-04-13 14:55
**/
@Data
@ApiModel(value = "小程序请长假请求参数")
public class TakeALongLeaveParam {
@ApiModelProperty(name = "userId", value = "用户主键")
private Integer userId;
@ApiModelProperty(name = "typeId", value = "类型")
private Integer typeId;
@ApiModelProperty(name = "startDate", value = "请假开始日期")
private String startDate;
@ApiModelProperty(name = "endDate", value = "请假结束日期")
private String endDate;
@ApiModelProperty(name = "des", value = "说明")
private String des;
}
......@@ -32,7 +32,7 @@ public class UserWorkTimeStatisticsByProject implements Serializable{
private String userName;
/**
* 用户部门名
* 用户部门名
*/
@ApiModelProperty(name = "userDeptName", value = "用户所在部门名称")
private String userDeptName;
......
......@@ -14,6 +14,7 @@ public enum LevelEnum {
ACCOUNTMANAGEMENT("账号管理"),
WORKORDER_CHANGEMANAGEMENT("工单变更管理"),
WORKORDER_CHANGERECORD("工单变更记录"),
PROJECT_STATISTICS_DETAIL("项目工时统计")
;
private String LevelName;
......
......@@ -10,9 +10,7 @@ public enum StatusEnum {
REJECTED(3, "被驳回"),
RE_SUBMIT(4,"重新填报"),
AUTOMATIC_AUDIT(5,"自动审批")
;
;
private Integer status;
private String msg;
......
......@@ -39,7 +39,7 @@ public class CreateProjectVo {
@ApiModelProperty(name = "workTime",value = "工时预算")
private BigDecimal workTime;
@ApiModelProperty(name = "costBudget",value = "成本预算,以为单位")
@ApiModelProperty(name = "costBudget",value = "成本预算,以为单位")
private BigDecimal costBudget;
@ApiModelProperty(name = "managerId",value = "项目经理userId")
......
package cn.wisenergy.oaModel;
import lombok.Data;
/**
* @description:
* @author: nh
* @create: 2021-04-20 10:43
**/
@Data
public class OaProject {
private String no;
private String name;
// 项目对应的商机oa编号
private String bo;
// 项目对应的商机名称,为商机时属性为空
private String bName;
private String managerNo;
private String managerName;
private String deptNo;
private String deptName;
private String startDate;
private String endDate;
private String cost;
}
package cn.wisenergy.oaService;
import cn.wisenergy.model.vo.CreateProjectVo;
import cn.wisenergy.oaModel.OaProject;
import java.util.List;
public interface OaProjectService {
/**
* 根据部门的oa编号和类型查询oa中的项目,typeId为1查询项目,为2查询商机
* @param oaDeptNo
* @param typeId
* @return
*/
List<OaProject> getListOaProject(String oaDeptNo, Integer typeId, String projectNameOrNo, List<String> oaProjectIds);
OaProject getOaProjectByNoAndName(CreateProjectVo createProjectVo);
}
package cn.wisenergy.oaService.impl;
import cn.wisenergy.common.utils.exception.BASE_RESP_CODE_ENUM;
import cn.wisenergy.common.utils.exception.BaseCustomException;
import cn.wisenergy.model.vo.CreateProjectVo;
import cn.wisenergy.oaMapper.ProjectAndBoMapper;
import cn.wisenergy.oaModel.OaProject;
import cn.wisenergy.oaService.OaProjectService;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
/**
* @description:
* @author: nh
* @create: 2021-04-20 11:16
**/
@Service
@Slf4j
public class OaProjectServiceImpl implements OaProjectService {
@Autowired
private ProjectAndBoMapper projectAndBoMapper;
@Override
public List<OaProject> getListOaProject(String oaDeptNo, Integer typeId, String projectNameOrNo,List<String> oaProjectIds) {
log.info("OaProjectServiceImpl[]getListOaProject[]input.param{}oaDeptNo, typeId, projectNameOrNo, oaProjectIds =>" + oaDeptNo +"," + typeId + "," + projectNameOrNo + "," +oaProjectIds);
if (StringUtils.isEmpty(oaDeptNo) || typeId == null) {
throw new BaseCustomException(BASE_RESP_CODE_ENUM.INPUT_PARAM_IS_NULL);
}
List<OaProject> listOaProject = null;
if (typeId.equals(1)) {
listOaProject = projectAndBoMapper.getListOaProjectByDept(oaDeptNo, projectNameOrNo,oaProjectIds);
}
if (typeId.equals(2)) {
listOaProject = projectAndBoMapper.getListOaBoByDept(oaDeptNo, projectNameOrNo,oaProjectIds);
}
return listOaProject;
}
@Override
public OaProject getOaProjectByNoAndName(CreateProjectVo createProjectVo) {
log.info("OaProjectServiceImpl[]getOaProjectByNoAndName[]input.param{}createProjectVo =>" + createProjectVo);
Map<String, Object> map = new HashMap<>();
// 项目/商机编号
map.put("projectNo", createProjectVo.getOaProjectId());
// 项目/商机名称
map.put("projectName", createProjectVo.getProjectName());
// 项目对应的商机不为空
if (createProjectVo.getBusinessId() != null) {
map.put("boNo", createProjectVo.getBusinessId());
map.put("boName", createProjectVo.getBusinessName());
}
OaProject oaProject;
// 项目
if (createProjectVo.getType() == 1) {
oaProject = projectAndBoMapper.getProjectByNameAndNo(map);
}else { // 商机
oaProject = projectAndBoMapper.getBoByNameAndNo(map);
}
return oaProject;
}
}
package cn.wisenergy.service;
import cn.wisenergy.model.dto.GetMonthlyCollectParam;
import cn.wisenergy.model.dto.ProjectStatisticsByMonth;
import cn.wisenergy.model.dto.UserWorkTimeStatisticsByProject;
import cn.wisenergy.model.dto.WorkTimeAndCostCollect;
import cn.wisenergy.model.dto.*;
import com.github.pagehelper.PageInfo;
import org.apache.poi.hssf.usermodel.HSSFWorkbook;
......@@ -78,7 +75,7 @@ public interface StatisticsService {
HSSFWorkbook exportUserStatistics(Integer userId, Integer deptId, String startDate, String endDate);
/**
* 导出项目工时统计
* 导出项目统计
* @param userId
* @param year
* @param projectIds
......@@ -93,4 +90,18 @@ public interface StatisticsService {
* @return
*/
List<Date> currentMonthWorkDays(Date date, boolean toToday);
/**
* 获取项目下所有人在指定时间段内的加班工时和正常工时
* @param projectTimeStatisticsParam
* @return
*/
PageInfo getProjectStatisticsDetail(ProjectTimeStatisticsParam projectTimeStatisticsParam);
/**
* 导出项目工时统计
* @param projectTimeStatisticsParam
* @return
*/
HSSFWorkbook exportProjectTimeStatistics(ProjectTimeStatisticsParam projectTimeStatisticsParam);
}
......@@ -80,4 +80,6 @@ public interface WorkProjectService {
OrderChangeDto getProjectAndOrderTypeAndDept(Integer userId);
List<DeptOfProjectAndOrderType> getProjectOfFind(Integer userId);
PageInfo queryOaProject(Integer userId, Integer typeId, String projectNameOrNo, Integer currentPage, Integer pageSize);
}
......@@ -142,4 +142,26 @@ public interface WorkTimeOrderService {
Boolean deleteOrderChange(Integer workId, Integer operator,String changeReason);
/**
* 请长假
* @param takeALongLeaveParam
* @return
*/
Boolean takeALongLeave(TakeALongLeaveParam takeALongLeaveParam);
/**
* 返回用户长假或长调休信息
* @param userId
* @return
*/
List<LeaveResult> getUserLongLeaveInfo(Integer userId);
/**
* 时间段内的节假日天数
* @param startDate
* @param endDate
* @return
*/
Integer getHolidayCountWithTimePeriod(String startDate, String endDate);
}
......@@ -18,7 +18,6 @@ import com.alibaba.excel.util.StringUtils;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.github.pagehelper.util.StringUtil;
import lombok.SneakyThrows;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.beanutils.BeanUtils;
import org.apache.poi.hssf.usermodel.*;
......@@ -372,6 +371,7 @@ public class StatisticsServiceImpl implements StatisticsService {
WorkTimeAndCostCollect workTimeAndCostCollect1 = new WorkTimeAndCostCollect();
workTimeAndCostCollect1.setType(workType.getId());
workTimeAndCostCollect1.setTypeName(workType.getName());
assert workTimeAndCostCollects != null;
workTimeAndCostCollects.add(i, workTimeAndCostCollect1);
}
}
......@@ -381,7 +381,7 @@ public class StatisticsServiceImpl implements StatisticsService {
WorkType workType = workTypes.get(i);
for (int i1 = 0; i1 < workTimeAndCostCollects.size(); i1++) {
if (workTimeAndCostCollects.get(i1).getType().equals(workType.getId())) {
WorkTimeAndCostCollect workTimeAndCostCollect ;
WorkTimeAndCostCollect workTimeAndCostCollect;
workTimeAndCostCollect = workTimeAndCostCollects.get(i1);
workTimeAndCostCollects.remove(i1);
workTimeAndCostCollects.add(i, workTimeAndCostCollect);
......@@ -428,6 +428,8 @@ public class StatisticsServiceImpl implements StatisticsService {
Date date = DateUtil.convertStrToDate(param.getYear() + "-" + param.getMonth(), "yyyy-MM");
// 传参的时间当月总天数
int dayCount = DateUtil.getMonthDaysArray(date).length;
// 当月截至当天的天数
int dayCount1 = DateUtil.daysBetween(DateUtil.getFirstDayOfMonth(new Date()), new Date()) + 1;
// 需要导出的信息
List<StatisticsTableDto> list = dayWorkTimeOfMonth.getList();
// 创建工作簿
......@@ -468,7 +470,7 @@ public class StatisticsServiceImpl implements StatisticsService {
HSSFCell cell = row1.createCell(2 + i);
cell.setCellValue(i + "日");
// 如果为节假日
if (!days.contains(i)) {
if (!days.contains(i) && i < dayCount1) {
cell.setCellStyle(cellStyle1);
} else {
cell.setCellStyle(cellStyle);
......@@ -509,27 +511,31 @@ public class StatisticsServiceImpl implements StatisticsService {
// 给节假日单元格设置单元格格式
for (int j = 0; j < list.size(); j++) {
HSSFRow row = sheet.getRow(j + 1);
for (int r = 0; r < dayCount; r++) {
for (int r = 0; r < dayCount1; r++) {
HSSFCell cell;
if (row.getCell(r + 3) == null) {
cell = row.createCell(r + 3);
} else {
cell = row.getCell(r + 3);
}
// 获取单元格中的工时,当日总工时小于8,则单元格底色为红色
String cellValue = ExcelUtils.getCellValue(cell, true);
Integer numberOfString = this.getNumberOfString(cellValue);
if (numberOfString < 8) {
cell.setCellStyle(cellStyle2);
}
// 节假日单元格标绿色
if (!days.contains(r + 1)) {
cell.setCellStyle(cellStyle1);
} else {
cell.setCellStyle(cellStyle);
}
// 获取单元格中的工时,当日总工时小于8,则单元格底色为红色
String cellValue = ExcelUtils.getCellValue(cell, true);
if (StringUtil.isNotEmpty(cellValue)) {
Integer numberOfString = this.getNumberOfString(cellValue);
if (numberOfString != null && numberOfString < 8) {
cell.setCellStyle(cellStyle2);
}
}
// else {
// cell.setCellStyle(cellStyle);
// }
}
}
this.closeSheets(sheets);
......@@ -540,9 +546,9 @@ public class StatisticsServiceImpl implements StatisticsService {
private Integer getNumberOfString(String value) {
value = value.trim();
if (StringUtil.isEmpty(value)) {
return null;
return 0;
}
Integer sum = 0;
int sum = 0;
for (int i = 0; i < value.length(); i++) {
if (value.charAt(i) >= 48 && value.charAt(i) <= 57) {
sum += value.charAt(i) - 48;
......@@ -551,7 +557,6 @@ public class StatisticsServiceImpl implements StatisticsService {
return sum;
}
@SneakyThrows
@Override
public List<UserWorkTimeStatisticsByProject> getUserWorkTimeStatisticsReport(Integer userId, Integer deptId, String startDate, String endDate) {
log.info("StatisticsServiceImpl[]getUserWorkTimeStatisticsReport[]" + userId + deptId + startDate + endDate);
......@@ -596,11 +601,7 @@ public class StatisticsServiceImpl implements StatisticsService {
if (CollectionUtil.isEmpty(userProjectWorkTimeStatistics)) {
return null;
}
UserWorkTimeStatisticsByProject userWorkTimeStatisticsByProject = new UserWorkTimeStatisticsByProject();
// 拷贝属性
BeanUtils.copyProperties(userWorkTimeStatisticsByProject, userProjectWorkTimeStatistics.get(0));
// 总计
userWorkTimeStatisticsByProject.setUserName("总计");
UserWorkTimeStatisticsByProject userWorkTimeStatisticsByProject = this.getNewUserTimeStatistics(userProjectWorkTimeStatistics);
// 将合计和总计
userProjectWorkTimeStatistics.add(userWorkTimeStatisticsByProject);
// 所有项目下所有人员的统计
......@@ -828,21 +829,21 @@ public class StatisticsServiceImpl implements StatisticsService {
// 总计行单元格
HSSFCell totalRow2Cell;
// if (!"请假".equals(projectWorkTimeAndType.get(i).getProjectName()) && !"调休".equals(projectWorkTimeAndType.get(i).getProjectName())) {
// 项目名称或类型名称
row_1Cell = row_1.createCell((i + 1) * 2);
totalRow2Cell = totalRow2.createCell((i + 1) * 2);
// 正常工时
HSSFCell row2Cell = row_2.createCell((i + 1) * 2);
row2Cell.setCellValue("正常工时");
// 该项目正常工时合计
HSSFCell cell1 = totalRow1.createCell((i + 1) * 2);
cell1.setCellValue(projectWorkTimeAndType.get(i).getNormalTime());
// 加班工时
HSSFCell row2Cell1 = row_2.createCell((i + 1) * 2 + 1);
row2Cell1.setCellValue("加班工时");
// 该项目加班工时合计
HSSFCell cell2 = totalRow1.createCell((i + 1) * 2 + 1);
cell2.setCellValue(projectWorkTimeAndType.get(i).getOverTime());
// 项目名称或类型名称
row_1Cell = row_1.createCell((i + 1) * 2);
totalRow2Cell = totalRow2.createCell((i + 1) * 2);
// 正常工时
HSSFCell row2Cell = row_2.createCell((i + 1) * 2);
row2Cell.setCellValue("正常工时");
// 该项目正常工时合计
HSSFCell cell1 = totalRow1.createCell((i + 1) * 2);
cell1.setCellValue(projectWorkTimeAndType.get(i).getNormalTime());
// 加班工时
HSSFCell row2Cell1 = row_2.createCell((i + 1) * 2 + 1);
row2Cell1.setCellValue("加班工时");
// 该项目加班工时合计
HSSFCell cell2 = totalRow1.createCell((i + 1) * 2 + 1);
cell2.setCellValue(projectWorkTimeAndType.get(i).getOverTime());
// } else {
// 合计行最后的列
// short lastCellNum = totalRow1.getLastCellNum();
......@@ -865,9 +866,9 @@ public class StatisticsServiceImpl implements StatisticsService {
// totalRow1.createCell(row1_lastCellNum).setCellValue(userWorkTimeStatisticsByProject.getTotalTime());
// totalRow2.createCell(row1_lastCellNum).setCellValue(userWorkTimeStatisticsByProject.getTotalTime());
// } else {
row_1.createCell(row1_lastCellNum + 1).setCellValue("总计");
totalRow1.createCell(row1_lastCellNum + 1).setCellValue(userWorkTimeStatisticsByProject.getTotalTime());
totalRow2.createCell(row1_lastCellNum + 1).setCellValue(userWorkTimeStatisticsByProject.getTotalTime());
row_1.createCell(row1_lastCellNum + 1).setCellValue("总计");
totalRow1.createCell(row1_lastCellNum + 1).setCellValue(userWorkTimeStatisticsByProject.getTotalTime());
totalRow2.createCell(row1_lastCellNum + 1).setCellValue(userWorkTimeStatisticsByProject.getTotalTime());
// }
for (int i = 0; i < userWorkTimeStatisticsReport.size() - 2; i++) {
......@@ -881,16 +882,16 @@ public class StatisticsServiceImpl implements StatisticsService {
HSSFCell cell_1 = row_i.createCell(1);
cell_1.setCellValue(userWorkTimeStatisticsByProject1.getUserName());
// 项目的工时
for (int j = 0; j < projectWorkTimeAndType1.size(); j++) {
for (ProjectWorkTimeAndType projectWorkTimeAndType2 : projectWorkTimeAndType1) {
for (int k = 2; k < row1_lastCellNum; k++) {
if (row_1.getCell(k) != null && projectWorkTimeAndType1.get(j).getProjectName().equals(row_1.getCell(k).getStringCellValue())) {
if (projectWorkTimeAndType1.get(j).getNormalTime() != null) {
if (row_1.getCell(k) != null && projectWorkTimeAndType2.getProjectName().equals(row_1.getCell(k).getStringCellValue())) {
if (projectWorkTimeAndType2.getNormalTime() != null) {
HSSFCell cell_k_1 = row_i.createCell(k);
cell_k_1.setCellValue(projectWorkTimeAndType1.get(j).getNormalTime());
cell_k_1.setCellValue(projectWorkTimeAndType2.getNormalTime());
}
if (projectWorkTimeAndType1.get(j).getOverTime() != null) {
if (projectWorkTimeAndType2.getOverTime() != null) {
HSSFCell cell_k_2 = row_i.createCell(k + 1);
cell_k_2.setCellValue(projectWorkTimeAndType1.get(j).getOverTime());
cell_k_2.setCellValue(projectWorkTimeAndType2.getOverTime());
}
}
// if (row_1.getCell(k) != null && projectWorkTimeAndType1.get(j).getProjectName().equals(row_1.getCell(k).getStringCellValue())) {
......@@ -1003,7 +1004,7 @@ public class StatisticsServiceImpl implements StatisticsService {
for (WorkProject projectsById : projectsByIds) {
String deptName = "";
for (WorkDept dept : depts) {
if (dept.getId() == projectsById.getDeptId()) {
if (dept.getId().equals(projectsById.getDeptId())) {
deptName = dept.getDeptName();
}
}
......@@ -1145,7 +1146,7 @@ public class StatisticsServiceImpl implements StatisticsService {
log.info("StatisticsServiceImpl[]currentMonthWorkDays[]input.method");
// 时间为本月,起始时间为参数时间当月第一天,截至时间为当天。否则,截至时间为当月最后一天
Date startDate = DateUtil.getFirstDayOfMonth(date);
Date endDate = null;
Date endDate;
// 当前时间
Date now = new Date();
if (DateUtil.getYear(date) == DateUtil.getYear(now) && DateUtil.getMonth(date) == DateUtil.getMonth(now) && toToday) {
......@@ -1197,11 +1198,160 @@ public class StatisticsServiceImpl implements StatisticsService {
return workDays;
}
@Override
public PageInfo getProjectStatisticsDetail(ProjectTimeStatisticsParam projectTimeStatisticsParam) {
log.info("StatisticsServiceImpl[]getProjectStatisticsDetail[]input.param{}projectTimeStatisticsParam" + projectTimeStatisticsParam);
// 用户主键
Integer userId = projectTimeStatisticsParam.getUserId();
// 用户部门主键
Integer deptId = projectTimeStatisticsParam.getDeptId();
// 开始请假时间
String startDate = projectTimeStatisticsParam.getStartDate();
// 结束请假时间
String endDate = projectTimeStatisticsParam.getEndDate();
// 当前页
Integer currentPage = projectTimeStatisticsParam.getCurrentPage();
// 每页数量
Integer pageSize = projectTimeStatisticsParam.getPageSize();
// 验证权限
// if (!UserRoleLevelUtils.isManagerLevel(userId, LevelEnum.PROJECT_STATISTICS_DETAIL.getLevelName())) {
// throw new BaseCustomException(BASE_RESP_CODE_ENUM.NO_AUTHORITY);
// }
// 用户信息
WorkUser user = workUserService.getById(userId);
// 获取用户权限对应的级别
List<UserRoleLevelDto> roleUserLevel = UserRoleLevelUtils.getRoleUserLevel(userId);
List<Integer> rank = roleUserLevel.stream().map(UserRoleLevelDto::getRank).collect(Collectors.toList());
// 非中心级别不能选择部门
if (deptId != null && !rank.contains(LevelRankEnum.CENTRAL_LEVEL.getRank())) {
throw new BaseCustomException(BASE_RESP_CODE_ENUM.NO_AUTHORITY);
}
// 存放查询条件
Map<String, Object> map = new HashMap<>();
// 时间段
map.put("startDate", startDate);
map.put("endDate", endDate);
// 中心级别
if (deptId != null) {
map.put("deptId", deptId);
} else if (deptId == null && rank.contains(LevelRankEnum.DEPARTMENT_LEVEL.getRank())) { // 部门级别
map.put("deptId", user.getDeptId());
}
// 项目/商机负责人,其他级别也可能时项目商机负责人
if (rank.contains(LevelRankEnum.PROJECT_LEVEL.getRank())) {
map.put("userId", userId);
}
// 查询合计
// map.put("isDetail", false);
// 用户负责项目在时间段的加班工时和正常工时总计
// List<ProjectWorkTimeStatisticsDto> projectStatisticsCollect = workTimeOrderMapper.getProjectStatisticsDetail(map);
// 总计
// UserWorkTimeStatisticsByProject newUserTimeStatistics = this.getNewUserTimeStatistics(projectStatisticsCollect);
// projectStatisticsCollect.add(newUserTimeStatistics);
// 查询明细
// map.put("isDetail", true);
// 用户负责项目在时间段内所有用户的加班工时和正常工时的统计
if (currentPage != null && pageSize != null) {
PageHelper.startPage(currentPage, pageSize);
}
List<ProjectWorkTimeStatisticsDto> projectStatisticsDetail = workTimeOrderMapper.getProjectStatisticsDetail(map);
PageInfo projectWorkTimeStatisticsDtoPageInfo = new PageInfo(projectStatisticsDetail);
// for (int i = 0; i < projectStatisticsDetail.size() - 1; i++) {
// // 前一条统计数据
// ProjectWorkTimeStatisticsDto projectWorkTimeStatisticsDto = projectStatisticsDetail.get(i);
// BigDecimal normalTime = projectWorkTimeStatisticsDto.getNormalTime();
// BigDecimal overTime = projectWorkTimeStatisticsDto.getOverTime();
// // 后一条统计数据
// ProjectWorkTimeStatisticsDto projectWorkTimeStatisticsDto1 = projectStatisticsDetail.get(i + 1);
// BigDecimal normalTime1 = projectWorkTimeStatisticsDto1.getNormalTime();
// BigDecimal overTime1 = projectWorkTimeStatisticsDto1.getOverTime();
//
// // 将相同项目相同姓名的统计数据合并
// if (projectWorkTimeStatisticsDto.getProjectName().equals(projectWorkTimeStatisticsDto1.getProjectName())
// && projectWorkTimeStatisticsDto.getUsername().equals(projectWorkTimeStatisticsDto1.getUsername())) {
// projectStatisticsDetail.get(i).setNormalTime(normalTime.add(normalTime1));
// projectStatisticsDetail.get(i).setOverTime(overTime.add(overTime1));
// // 移除后一条统计数据
// projectStatisticsDetail.remove(i + 1);
// }
// }
projectWorkTimeStatisticsDtoPageInfo.setList(projectStatisticsDetail);
return projectWorkTimeStatisticsDtoPageInfo;
}
@Override
public HSSFWorkbook exportProjectTimeStatistics(ProjectTimeStatisticsParam projectTimeStatisticsParam) {
log.info("StatisticsServiceImpl[]exportProjectTimeStatistics[]input.param{}projectTimeStatisticsParam" + projectTimeStatisticsParam);
String startDate = projectTimeStatisticsParam.getStartDate();
String endDate = projectTimeStatisticsParam.getEndDate();
HSSFWorkbook sheets = new HSSFWorkbook();
HSSFSheet sheet1 = sheets.createSheet("项目工时统计(正常工时)");
HSSFSheet sheet2 = sheets.createSheet("项目工时统计(加班工时)");
// 转换时间格式
String start = simpleDateToYearMonthDay(startDate);
String end = simpleDateToYearMonthDay(endDate);
// 基本格式
setProjectTimeStatisticsStyle(sheet1, start, end);
setProjectTimeStatisticsStyle(sheet2, start, end);
// 两个表的序号
int i = 1;
int j = 1;
List<ProjectWorkTimeStatisticsDto> projectStatisticsDetail = getProjectStatisticsDetail(projectTimeStatisticsParam).getList();
if (CollectionUtils.isEmpty(projectStatisticsDetail)) {
return creatEmptyHSSFWorkbook();
}
for (ProjectWorkTimeStatisticsDto projectWorkTimeStatisticsDto : projectStatisticsDetail) {
// 正常工时
if (!"0".equals(projectWorkTimeStatisticsDto.getNormalTime().toString())) {
HSSFRow sheet1Row = sheet1.createRow(i + 1);
sheet1Row.createCell(0).setCellValue(i);
sheet1Row.createCell(1).setCellValue(projectWorkTimeStatisticsDto.getProjectName());
sheet1Row.createCell(2).setCellValue(projectWorkTimeStatisticsDto.getUsername());
sheet1Row.createCell(3).setCellValue(projectWorkTimeStatisticsDto.getNormalTime().stripTrailingZeros().toPlainString());
i++;
}
// 加班工时
if (!"0".equals(projectWorkTimeStatisticsDto.getOverTime().toString())) {
HSSFRow sheet2Row = sheet2.createRow(j + 1);
sheet2Row.createCell(0).setCellValue(j);
sheet2Row.createCell(1).setCellValue(projectWorkTimeStatisticsDto.getProjectName());
sheet2Row.createCell(2).setCellValue(projectWorkTimeStatisticsDto.getUsername());
sheet2Row.createCell(3).setCellValue(projectWorkTimeStatisticsDto.getOverTime().stripTrailingZeros().toPlainString());
j++;
}
}
// 合并两个表的第一行
CellRangeAddress cellRangeAddress = new CellRangeAddress(0, 0, 0, 4);
sheet1.addMergedRegion(cellRangeAddress);
sheet2.addMergedRegion(cellRangeAddress);
// 设置项目商机名称这一列的宽度
sheet1.setColumnWidth(1, EXCEL_WIDTH);
sheet2.setColumnWidth(1, EXCEL_WIDTH);
// 按5:3的比例放大表的视图
sheet1.setZoom(5, 3);
sheet2.setZoom(5, 3);
return sheets;
}
//获取用户某月已填报的日期,如果一天中只有被驳回则不为已填报
private List<Date> currentMonthFilledDays(Integer userId, Date date) {
log.info("StatisticsServiceImpl[]currentMonthFilledDays[]input.method");
List<Date> currentMonthFilledDays = workTimeOrderMapper.getDaysByDateAndStatus(userId, date);
return currentMonthFilledDays;
return workTimeOrderMapper.getDaysByDateAndStatus(userId, date);
}
// 设置单元格基本样式
......@@ -1254,7 +1404,7 @@ public class StatisticsServiceImpl implements StatisticsService {
statisticsDateAndWorkTimes.add(i, statisticsDateAndWorkTime);
}
SimpleDateFormat format = new SimpleDateFormat("yyyy年M月");
Date parse = null;
Date parse;
try {
parse = format.parse(s);
// 在查询部门所有项目统计时,将除开统计首月和月份为一月的时间格式中的年分删除
......@@ -1386,7 +1536,7 @@ public class StatisticsServiceImpl implements StatisticsService {
return sheets;
}
// 画斜线
// excel画斜线
private void setDrawingPatriarch(HSSFSheet sheet1, int dx1, int dy1, int dx2, int dy2, short col1, int row1, short col2, int row2) {
HSSFPatriarch drawingPatriarch = sheet1.createDrawingPatriarch();
HSSFClientAnchor hssfClientAnchor = new HSSFClientAnchor(dx1, dy1, dx2, dy2, col1, row1, col2, row2);
......@@ -1394,4 +1544,29 @@ public class StatisticsServiceImpl implements StatisticsService {
simpleShape.setShapeType(HSSFSimpleShape.OBJECT_TYPE_LINE);
simpleShape.setLineStyle(HSSFSimpleShape.LINESTYLE_SOLID);
}
// 人员工时总计
private UserWorkTimeStatisticsByProject getNewUserTimeStatistics(List<UserWorkTimeStatisticsByProject> userProjectWorkTimeStatistics) {
UserWorkTimeStatisticsByProject userWorkTimeStatisticsByProject = new UserWorkTimeStatisticsByProject();
// 拷贝属性
try {
BeanUtils.copyProperties(userWorkTimeStatisticsByProject, userProjectWorkTimeStatistics.get(0));
} catch (Exception e) {
e.printStackTrace();
throw new BaseCustomException(BASE_RESP_CODE_ENUM.DATE_HANDLE_ERROR);
}
// 总计
userWorkTimeStatisticsByProject.setUserName("总计");
return userWorkTimeStatisticsByProject;
}
// 项目工时统计基本格式
private void setProjectTimeStatisticsStyle(HSSFSheet sheet, String start, String end) {
sheet.createRow(0).createCell(0).setCellValue(start + "-" + end + "项目工时统计");
HSSFRow sheet2Row1 = sheet.createRow(1);
sheet2Row1.createCell(0).setCellValue("序号");
sheet2Row1.createCell(1).setCellValue("项目名称");
sheet2Row1.createCell(2).setCellValue("姓名");
sheet2Row1.createCell(3).setCellValue("工时(人*天)");
}
}
......@@ -158,6 +158,10 @@ public class WorkCollectServiceImpl implements WorkCollectService {
if (null == workCollect) {
throw new BaseCustomException(BASE_RESP_CODE_ENUM.INPUT_PARAM_IS_NULL);
}
WorkCollect workCollectByUserIdAndWorkDay = workCollectMapper.getWorkCollectByUserIdAndWorkDay(workCollect.getUserId(), workCollect.getWorkDay());
if (workCollectByUserIdAndWorkDay != null) {
workCollectMapper.deleteById(workCollectByUserIdAndWorkDay.getId());
}
int insertRow = workCollectMapper.insertWorkCollect(workCollect);
if (insertRow == 0) {
throw new BaseCustomException(BASE_RESP_CODE_ENUM.INSERT_DATA_IS_FAIL);
......
......@@ -3,10 +3,7 @@ package cn.wisenergy.service.impl;
import cn.wisenergy.common.utils.DateUtil;
import cn.wisenergy.common.utils.exception.BASE_RESP_CODE_ENUM;
import cn.wisenergy.common.utils.exception.BaseCustomException;
import cn.wisenergy.mapper.WorkCentreMapper;
import cn.wisenergy.mapper.WorkDeptMapper;
import cn.wisenergy.mapper.WorkProjectChangeMapper;
import cn.wisenergy.mapper.WorkProjectMapper;
import cn.wisenergy.mapper.*;
import cn.wisenergy.model.app.*;
import cn.wisenergy.model.dto.*;
import cn.wisenergy.model.enums.LevelEnum;
......@@ -15,6 +12,8 @@ import cn.wisenergy.model.enums.ManagerEnum;
import cn.wisenergy.model.vo.CreateProjectVo;
import cn.wisenergy.model.vo.GetManagerProjectsVo;
import cn.wisenergy.model.vo.ModifyProjectVo;
import cn.wisenergy.oaModel.OaProject;
import cn.wisenergy.oaService.OaProjectService;
import cn.wisenergy.service.*;
import cn.wisenergy.service.utils.UserRoleLevelUtils;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
......@@ -29,7 +28,10 @@ import org.springframework.transaction.annotation.Transactional;
import org.springframework.util.CollectionUtils;
import java.math.BigDecimal;
import java.util.*;
import java.util.ArrayList;
import java.util.Date;
import java.util.HashMap;
import java.util.List;
import java.util.stream.Collectors;
/**
......@@ -71,6 +73,12 @@ public class WorkProjectServiceImpl implements WorkProjectService {
@Autowired
private WorkProjectChangeMapper workProjectChangeMapper;
@Autowired
private OaProjectService oaProjectService;
@Autowired
private WorkUserMapper workUserMapper;
/**
* 功能:根据项目id获取项目
*
......@@ -565,18 +573,33 @@ public class WorkProjectServiceImpl implements WorkProjectService {
throw new BaseCustomException(BASE_RESP_CODE_ENUM.BUDGET_CANNOT_BELESSTHAN_ZERO);
}
// 判断oa编号、项目名称是否重复
List<WorkProject> workProjects = workProjectMapper.selectList(new QueryWrapper<>());
if (CollectionUtils.isEmpty(workProjects)) {
throw new BaseCustomException(BASE_RESP_CODE_ENUM.WORK_PROJECT_IS_NULL);
}
for (WorkProject workProject : workProjects) {
if (createProjectVo.getProjectName().equals(workProject.getProjectName())) {
WorkProject byProjectNameOrOaId = workProjectMapper.getByProjectNameOrOaId(createProjectVo.getProjectName(), createProjectVo.getOaProjectId());
if (byProjectNameOrOaId != null) {
if (createProjectVo.getProjectName().equals(byProjectNameOrOaId.getProjectName())) {
throw new BaseCustomException(BASE_RESP_CODE_ENUM.DUPLICATEPROJECTNAME);
}
if (createProjectVo.getOaProjectId().equals(workProject.getOaProjectId())) {
if (createProjectVo.getOaProjectId().equals(byProjectNameOrOaId.getOaProjectId())) {
throw new BaseCustomException(BASE_RESP_CODE_ENUM.ITEMOADUPLICATE);
}
}
// List<WorkProject> workProjects = workProjectMapper.selectList(new QueryWrapper<>());
// if (CollectionUtils.isEmpty(workProjects)) {
// throw new BaseCustomException(BASE_RESP_CODE_ENUM.WORK_PROJECT_IS_NULL);
// }
// for (WorkProject workProject : workProjects) {
// if (createProjectVo.getProjectName().equals(workProject.getProjectName())) {
// throw new BaseCustomException(BASE_RESP_CODE_ENUM.DUPLICATEPROJECTNAME);
// }
// if (createProjectVo.getOaProjectId().equals(workProject.getOaProjectId())) {
// throw new BaseCustomException(BASE_RESP_CODE_ENUM.ITEMOADUPLICATE);
// }
// }
// 在oa数据库中查找对应信息
// OaProject oaProject = oaProjectService.getOaProjectByNoAndName(createProjectVo);
// if (oaProject == null) {
// throw new BaseCustomException(BASE_RESP_CODE_ENUM.NEW_PROJECT_OA_PROJECT_ID_OR_NAME_ERROR);
// }
// 插入项目信息
Date date = new Date();
......@@ -758,6 +781,67 @@ public class WorkProjectServiceImpl implements WorkProjectService {
return orderChangeDto.getProjectAndOrderTypes();
}
@Override
public PageInfo queryOaProject(Integer userId, Integer typeId, String projectNameOrNo, Integer currentPage, Integer pageSize) {
log.info("WorkProjectServiceImpl[]queryOaProject[]input.param{}userId,typeId,projectNameOrNo" + userId + "," + typeId + "," + projectNameOrNo + "," + currentPage + "," + pageSize);
if (userId == null || typeId == null || StringUtils.isEmpty(projectNameOrNo)) {
throw new BaseCustomException(BASE_RESP_CODE_ENUM.INPUT_PARAM_IS_NULL);
}
// 项目/商机管理部门级权限能够新建项目/商机
// List<Integer> rankByUserAndLevelName = UserRoleLevelUtils.getRankByUserAndLevelName(userId, LevelEnum.PROJECT_MANAGER.getLevelName());
// if (!rankByUserAndLevelName.contains(LevelRankEnum.DEPARTMENT_LEVEL.getRank())) {
// throw new BaseCustomException(BASE_RESP_CODE_ENUM.NO_AUTHORITY);
// }
// 根据用户id查询所对应oa部门编号
WorkDept oaDept = workDeptMapper.getOaDeptNoByUserId(userId);
// 查询工时系统中的该部门下的项目/商机
List<WorkProject> projectList = workProjectMapper.getListByDeptAndType(oaDept.getId(),typeId, projectNameOrNo);
List<String> oaProjectIds = projectList.stream().map(WorkProject::getOaProjectId).collect(Collectors.toList());
// 从oa中根据部门的oa编号查询项目/商机,
// typeId 为1 查询项目,为2查询商机
if (currentPage != null && pageSize != null) {
PageHelper.startPage(currentPage, pageSize);
}
List<OaProject> listOaProject = oaProjectService.getListOaProject(oaDept.getOaDeptId(), typeId, projectNameOrNo,oaProjectIds);
PageInfo<OaProject> pageInfo = new PageInfo<>(listOaProject);
if (CollectionUtils.isEmpty(listOaProject)) {
return null;
}
// 查询项目经理在工时系统中对应的id
List<String> managerIds = listOaProject.stream().map(OaProject::getManagerNo).collect(Collectors.toList());
List<WorkUser> workUsers = null;
if (!CollectionUtils.isEmpty(managerIds)) {
workUsers = workUserMapper.getUserByIds(managerIds);
}
// 将查询结果中的oa编号更换为工时系统中的编号
for (int i = 0; i < listOaProject.size(); i++) {
OaProject oaProject = listOaProject.get(i);
// 将部门oa编号替换为工时系统中的部门id
oaProject.setDeptNo(oaDept.getId().toString());
oaProject.setDeptName(oaDept.getDeptName());
// 将项目/商机负责人oa编号替换为工时系统中的用户id
if (StringUtils.isNotBlank(oaProject.getManagerNo())) {
assert workUsers != null;
for (WorkUser workUser : workUsers) {
if (workUser.getOaUserId().equals(oaProject.getManagerNo())) {
oaProject.setManagerNo(workUser.getId().toString());
oaProject.setManagerName(workUser.getName());
}
}
}
}
return pageInfo;
}
private PageInfo<ManagerProjectsDto> returnPageInfo(List<ManagerProjectsDto> managerProjectsDto) {
if (CollectionUtils.isEmpty(managerProjectsDto)) {
......
......@@ -4,10 +4,7 @@ import cn.wisenergy.common.utils.DateUtil;
import cn.wisenergy.common.utils.DateUtils;
import cn.wisenergy.common.utils.exception.BASE_RESP_CODE_ENUM;
import cn.wisenergy.common.utils.exception.BaseCustomException;
import cn.wisenergy.mapper.WorkOrderChangeMapper;
import cn.wisenergy.mapper.WorkProjectMapper;
import cn.wisenergy.mapper.WorkTimeOrderMapper;
import cn.wisenergy.mapper.WorkUserMapper;
import cn.wisenergy.mapper.*;
import cn.wisenergy.model.app.*;
import cn.wisenergy.model.dto.*;
import cn.wisenergy.model.enums.LevelEnum;
......@@ -92,6 +89,18 @@ public class WorkTimeOrderServiceImpl implements WorkTimeOrderService {
@Autowired
private WorkOrderChangeMapper workOrderChangeMapper;
@Autowired
private WorkCollectMapper workCollectMapper;
@Autowired
private WorkLeaveMapper workLeaveMapper;
@Autowired
private WorkHolidayMapper workHolidayMapper;
// 长请假最大天数
private final Integer LONG_LEAVE_DAYS = 142;
// 工单状态
......@@ -283,7 +292,6 @@ public class WorkTimeOrderServiceImpl implements WorkTimeOrderService {
throw new BaseCustomException("627", "超过" + submitTime + "天的不能填报");
}
}
}
// 9.删除数据库还没有审批的工单,添加填报没有审批的工单
......@@ -314,6 +322,7 @@ public class WorkTimeOrderServiceImpl implements WorkTimeOrderService {
workCollect.setStatus(status);
workCollectService.update(workCollect);
}
return workTimeOrders;
}
......@@ -1275,6 +1284,205 @@ public class WorkTimeOrderServiceImpl implements WorkTimeOrderService {
return true;
}
@Transactional
@Override
public Boolean takeALongLeave(TakeALongLeaveParam takeALongLeaveParam) {
log.info("WorkTimeOrderServiceImpl[]takeALongLeave[]input.param{}takeALongLeaveParam" + takeALongLeaveParam.toString());
Integer userId = takeALongLeaveParam.getUserId();
Integer type = takeALongLeaveParam.getTypeId();
String startDate = takeALongLeaveParam.getStartDate();
String endDate = takeALongLeaveParam.getEndDate();
String des = takeALongLeaveParam.getDes();
if (userId == null || type == null || StringUtils.isEmpty(startDate) || StringUtils.isEmpty(endDate)|| StringUtils.isEmpty(des)) {
throw new BaseCustomException(BASE_RESP_CODE_ENUM.INPUT_PARAM_IS_NULL);
}
// 开始日期和结束日期是否在可填报时间段
WorkSubmitAdopt submitAdopt = workSubmitAdoptService.getById(1);
// 限制填报天数
Integer submitTime = submitAdopt.getSubmitTime();
// 开始结束日期转为date
Date start = DateUtil.convertStrToDate(startDate, "yyyy-MM-dd");
Date end = DateUtil.convertStrToDate(endDate, "yyyy-MM-dd");
// 当前日期
Date today = DateUtil.getStartOfDay(new Date());
Date add = DateUtil.add(start, Calendar.DAY_OF_MONTH, submitTime);
Date lastDayByMonth = DateUtil.add(start, Calendar.DAY_OF_YEAR, LONG_LEAVE_DAYS);
if (add.compareTo(today) < 1 || lastDayByMonth.compareTo(end) == -1) {
throw new BaseCustomException(BASE_RESP_CODE_ENUM.LONG_LEAVE_DATE_ERROR);
}
// 所有类型名称
List<WorkType> workTypes = workTypeService.getAll(0);
// 用户填报的类型
String typeName = getTypeName(type, workTypes);
if (!"请假".equals(typeName) && !"调休".equals(typeName)) {
throw new BaseCustomException(BASE_RESP_CODE_ENUM.LONG_LEAVE_TYPE_ERROR);
}
// 用户信息
WorkUser user = workUserService.getById(userId);
// 请假时间段内不能够存在已填报工单
int i = workTimeOrderMapper.countByWorkDay(userId, startDate, endDate);
if (i != 0) {
throw new BaseCustomException(BASE_RESP_CODE_ENUM.WORK_DAY_IS_REPEAT);
}
// 去除掉日期段内的节假日
// 选择日期段内的所有日期集合
List<Date> datesBetweenTwoDate = DateUtil.getDatesBetweenTwoDate(start, end);
// 从日期集合中除去周末
for (int j = 0; j < datesBetweenTwoDate.size(); j++) {
int week = DateUtil.getWeek(datesBetweenTwoDate.get(j));
if (week == 7 || week == 1) {
datesBetweenTwoDate.remove(j);
}
}
// 在填报日期内的节假日和补班日
List<WorkHoliday> holidays = workHolidayMapper.getByDate(start, end);
if (!CollectionUtils.isEmpty(holidays)) {
for (WorkHoliday holiday : holidays) {
List<Date> holidayList = DateUtil.getDatesBetweenTwoDate(holiday.getDayStart(), holiday.getDayEnd());
// 为1就是节假日,否则补班
if (holiday.getDayType().equals(1)) {
datesBetweenTwoDate.removeAll(holidayList);
}else {
datesBetweenTwoDate.addAll(holidayList);
}
}
}
// 所填报日期中没有工作日
if (datesBetweenTwoDate.size() == 0) {
throw new BaseCustomException(BASE_RESP_CODE_ENUM.LONG_LEAVE_DATE_NOT_ONLY_HOLIDAY);
}
// for (int i1 = 0; i1 < datesBetweenTwoDate.size(); i1++) {
// // 为节假日,从日期集合中删除
// if (workHolidayService.isHoliday(datesBetweenTwoDate.get(i1))) {
// datesBetweenTwoDate.remove(i1);
// i1--;
// }
// if (datesBetweenTwoDate.size() == 0) {
// throw new BaseCustomException(BASE_RESP_CODE_ENUM.LONG_LEAVE_DATE_NOT_ONLY_HOLIDAY);
// }
// }
// 需要插入的工单集合
List<WorkTimeOrder> workTimeOrders = new ArrayList<>();
// 插入工单汇总
List<WorkCollect> workCollects = new ArrayList<>();
for (Date date : datesBetweenTwoDate) {
// 工单信息
WorkTimeOrder workTimeOrder = new WorkTimeOrder();
workTimeOrder.setUserId(userId);
workTimeOrder.setType(type);
workTimeOrder.setDeptId(user.getDeptId());
workTimeOrder.setWorkDay(date);
workTimeOrder.setIsOvertime(0);
workTimeOrder.setStatus(StatusEnum.COMPLETED.getCode());
workTimeOrder.setDes(des);
workTimeOrder.setWorkTime(8);
workTimeOrder.setCreateTime(new Date());
workTimeOrder.setModifyTime(new Date());
workTimeOrders.add(workTimeOrder);
// 汇总信息
WorkCollect workCollect = new WorkCollect();
workCollect.setUserId(userId);
workCollect.setStatus(StatusEnum.COMPLETED.getCode());
workCollect.setTotalTime(8);
workCollect.setWorkDay(date);
workCollect.setCreateTime(new Date());
workCollect.setModifyTime(new Date());
workCollects.add(workCollect);
}
// 添加work_time_order记录
int workOrderCount = workTimeOrderMapper.addManyLeaveOrder(workTimeOrders);
// 添加work_collect记录
int workCollectCount = workCollectMapper.addManyLeaveCollect(workCollects);
// 添加work_leave记录
WorkLeave workLeave = new WorkLeave();
BeanUtils.copyProperties(takeALongLeaveParam, workLeave);
workLeave.setCreateTime(DateUtil.getTime(new Date(),"yyyy-MM-dd-HH-mm-ss"));
workLeave.setModifyTime(DateUtil.getTime(new Date(),"yyyy-MM-dd-HH-mm-ss"));
int workLeaveCount = workLeaveMapper.insert(workLeave);
if (workOrderCount == 0 || workCollectCount == 0 || workLeaveCount == 0) {
throw new BaseCustomException(BASE_RESP_CODE_ENUM.UPDATE_DATA_FAIL);
}
return true;
}
@Override
public List<LeaveResult> getUserLongLeaveInfo(Integer userId) {
log.info("WorkTimeOrderServiceImpl[]getUserLongLeaveInfo[]input.param{}userId" + userId);
if (userId == null) {
throw new BaseCustomException(BASE_RESP_CODE_ENUM.INPUT_PARAM_IS_NULL);
}
// 所有填报类型信息
List<WorkType> workTypes = workTypeService.getAll(null);
// 数据库中存储的信息
List<WorkLeave> listByUserId = workLeaveMapper.getListByUserId(userId);
// 返回信息
List<LeaveResult> leaveResultList = new ArrayList<>();
for (WorkLeave workLeave : listByUserId) {
// 复制属性
LeaveResult leaveResult = new LeaveResult();
BeanUtils.copyProperties(workLeave, leaveResult);
// 赋值类型名称
leaveResult.setTypeName(getTypeName(workLeave.getTypeId(),workTypes));
// 添加到集合
leaveResultList.add(leaveResult);
}
return leaveResultList;
}
@Override
public Integer getHolidayCountWithTimePeriod(String startDate, String endDate) {
log.info("WorkTimeOrderServiceImpl[]getHolidayCountWithTimePeriod[]input.param{}startDate, endDate" + startDate + "," + endDate);
// 将两个时间字符串转为Date类型
Date start = DateUtil.convertStrToDate(startDate, "yyyy-MM-dd");
Date end = DateUtil.convertStrToDate(endDate, "yyyy-MM-dd");
// 获取两个时间段内日期的集合
List<Date> datesBetweenTwoDate = DateUtil.getDatesBetweenTwoDate(start, end);
// 获取两个时间段内的节假日或补班日
List<WorkHoliday> holidays = workHolidayMapper.getByDate(start, end);
Integer count = 0;
List<Date> weekendList = new ArrayList<>();
for (Date date : datesBetweenTwoDate) {
int week = DateUtil.getWeek(date);
if (week == 1 || week == 7) {
count ++;
weekendList.add(date);
}
}
for (WorkHoliday holiday : holidays) {
List<Date> datesBetweenTwoDate1 = DateUtil.getDatesBetweenTwoDate(holiday.getDayStart(), holiday.getDayEnd());
// 取交集
datesBetweenTwoDate1.retainAll(datesBetweenTwoDate);
// 工作日,count减
if (holiday.getDayType() == 0) {
count -= datesBetweenTwoDate1.size();
}else {
// 与周末取差集
datesBetweenTwoDate1.removeAll(weekendList);
count += datesBetweenTwoDate1.size();
}
}
return count;
}
private void addWorkOrderChange(Integer content, OrderChangeVo vo) {
WorkOrderChange workOrderChange = new WorkOrderChange();
workOrderChange.setChangeDate(new Date()).setContent(content).setOperatorId(vo.getOperatorId()).setWorkDay(vo.getWorkDay()).setUserId(vo.getUserId()).setWorkTime(vo.getWorkTime()).setDes(vo.getDes()).setChangeReason(vo.getChangeReason());
......
......@@ -33,6 +33,7 @@ import org.apache.shiro.authc.UnknownAccountException;
import org.apache.shiro.authc.UsernamePasswordToken;
import org.apache.shiro.subject.Subject;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.util.CollectionUtils;
......@@ -69,6 +70,9 @@ public class WorkUserServiceImpl implements WorkUserService {
@Autowired
private WorkUserRoleMapper workUserRoleMapper;
@Autowired
private RedisTemplate redisTemplate;
private static final String LOGIN_SOURCE = "PC";
// 用户在职状态码
......@@ -240,6 +244,9 @@ public class WorkUserServiceImpl implements WorkUserService {
if (null == workUser) {
throw new BaseCustomException(BASE_RESP_CODE_ENUM.QUERY_DATA_IS_NULL);
}
// 清空该用在redis中的认证信息
WorkUser user = workUserMapper.getUserById(userId);
redisTemplate.delete("AuthenticationRedisCache" + user.getName());
WorkDept workDept = workDeptService.getById(workUser.getDeptId());
WorkCentre centre = workCentreService.getCentreById(workDept.getCentreId());
......@@ -313,6 +320,7 @@ public class WorkUserServiceImpl implements WorkUserService {
if (null == userId) {
throw new BaseCustomException(BASE_RESP_CODE_ENUM.INPUT_PARAM_IS_NULL);
}
// 验证用户是否存在
WorkUser user = workUserMapper.getUserById(userId);
WorkUser workUser = new WorkUser();
......@@ -320,6 +328,11 @@ public class WorkUserServiceImpl implements WorkUserService {
if (null == user) {
throw new BaseCustomException(BASE_RESP_CODE_ENUM.QUERY_USER_INFO_FAIL);
}
// 清空该用在redis中的认证信息
redisTemplate.delete("AuthenticationRedisCache" + user.getName());
// 重置密码
workUser.setPassword(Md5Util.digestMD5(user.getPhone()));
int i = workUserMapper.updateById(workUser);
return i > 0;
......
......@@ -74,7 +74,7 @@ public class ShiroConfig {
map.put("/swagger-resources/**","anon");
map.put("/v2/**","anon");
map.put("/static/**", "anon");
map.put("/**", "kickout");
// map.put("/**", "kickout");
map.put("/wxLogout", "wxLogout");
shiroFilterFactoryBean.setFilterChainDefinitionMap(map);
......@@ -92,7 +92,7 @@ public class ShiroConfig {
}
@Bean(name = "realm")
public Realm getRealm(){
public CustomerRealm getRealm(){
CustomerRealm customerRealm = new CustomerRealm();
// 凭证校验匹配器
HashedCredentialsMatcher hashedCredentialsMatcher = new HashedCredentialsMatcher();
......@@ -142,6 +142,7 @@ public class ShiroConfig {
public KickoutSessionControlFilter kickoutSessionControlFilter(){
KickoutSessionControlFilter kickoutSessionControlFilter = new KickoutSessionControlFilter();
kickoutSessionControlFilter.setSessionManager(sessionManager());
kickoutSessionControlFilter.setCustomerRealm(getRealm());
return kickoutSessionControlFilter;
}
......
......@@ -3,9 +3,14 @@ package cn.wisenergy.shiro.filter;
import cn.wisenergy.common.utils.exception.BASE_RESP_CODE_ENUM;
import cn.wisenergy.common.utils.exception.Result;
import cn.wisenergy.model.app.WorkUser;
import cn.wisenergy.shiro.util.CustomerRealm;
import net.sf.json.JSONObject;
import org.apache.commons.io.IOUtils;
import org.apache.commons.lang.exception.ExceptionUtils;
import org.apache.shiro.authc.AuthenticationInfo;
import org.apache.shiro.authc.SimpleAuthenticationInfo;
import org.apache.shiro.cache.Cache;
import org.apache.shiro.cache.CacheManager;
import org.apache.shiro.session.Session;
import org.apache.shiro.session.mgt.DefaultSessionKey;
import org.apache.shiro.session.mgt.SessionManager;
......@@ -34,8 +39,13 @@ import java.util.concurrent.TimeUnit;
public class KickoutSessionControlFilter extends AccessControlFilter {
protected Logger log = LoggerFactory.getLogger(this.getClass());
@Autowired
private RedisTemplate redisTemplate;
private SessionManager sessionManager;
private CustomerRealm customerRealm;
// false为提出之前登录的用户
private boolean kickoutAfter = false;
......@@ -48,8 +58,9 @@ public class KickoutSessionControlFilter extends AccessControlFilter {
private static final long EXPIRE_TIME = 30 * 60;
@Autowired
private RedisTemplate redisTemplate;
public void setCustomerRealm(CustomerRealm customerRealm) {
this.customerRealm = customerRealm;
}
String getRedisKickoutKey(Integer userId) {
return keyprefix + userId;
......@@ -70,13 +81,26 @@ public class KickoutSessionControlFilter extends AccessControlFilter {
Subject subject = getSubject(request, response);
HttpServletResponse httpServletResponse = null;
// 没有登陆或没有设置“记住我”
// 没有登陆或没有设置“记住我”抛出未登录异常
if (!subject.isAuthenticated() && !subject.isRemembered()) {
// 没有登陆,抛出异常
httpServletResponse = (HttpServletResponse) response;
thrLogoutException(httpServletResponse, Result.RESULT_FLG.FAIL,BASE_RESP_CODE_ENUM.PLEASE_RE_LOGIN);
return false;
}
/** 刷新redis缓存认证信息,存在redis中的认证信息k为登录时写入usernamePasswordToken的username,
v为写入SimpleAuthenticationInfo中的principal **/
WorkUser principal = (WorkUser) subject.getPrincipal();
// 缓存管理
CacheManager cacheManager = customerRealm.getCacheManager();
// 缓存
Cache<Object, Object> cache = cacheManager.getCache(customerRealm.getAuthenticationCacheName());
// 覆盖,重新写入过期时间
AuthenticationInfo authenticationInfo = new SimpleAuthenticationInfo(principal,principal.getPassword(),customerRealm.getName());
cache.put(principal.getLoginName(), authenticationInfo);
// 账号PC端只允许一位同时在线登录,做踢出用户操作
// 获取当前用户请求所携带的session
Session session = subject.getSession();
// 当前用户
......
......@@ -45,4 +45,7 @@ public class CustomerRealm extends AuthorizingRealm {
SimplePrincipalCollection newPrincipals = new SimplePrincipalCollection(user.getLoginName(), this.getName());
super.clearCachedAuthenticationInfo(newPrincipals);
}
}
package cn.wisenergy.shiro.util;
/**
* @description:
* @author: nh
* @create: 2021-04-11 23:45
**/
public class ExceptionUtil {
}
......@@ -38,10 +38,8 @@ public class ShiroSessionManager extends DefaultWebSessionManager {
}
}
@Override
public Session getSession(SessionKey key) throws SessionException {
return super.getSession(key);
}
}
package cn.wisenergy;
import com.baomidou.mybatisplus.autoconfigure.MybatisPlusAutoConfiguration;
import org.apache.shiro.spring.boot.autoconfigure.ShiroAnnotationProcessorAutoConfiguration;
import org.apache.shiro.spring.boot.autoconfigure.ShiroAutoConfiguration;
import org.apache.shiro.spring.boot.autoconfigure.ShiroBeanAutoConfiguration;
import org.mybatis.spring.annotation.MapperScan;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.autoconfigure.jdbc.DataSourceAutoConfiguration;
import org.springframework.boot.autoconfigure.web.servlet.MultipartAutoConfiguration;
import org.springframework.cache.annotation.EnableCaching;
import org.springframework.scheduling.annotation.EnableScheduling;
......@@ -15,9 +16,11 @@ import springfox.documentation.swagger2.annotations.EnableSwagger2;
* 配置netty启动
*/
@EnableCaching
//排除原有的Multipart配置 spingboot接受不了multipartfile参数
@SpringBootApplication(exclude = {MultipartAutoConfiguration.class, ShiroAnnotationProcessorAutoConfiguration.class, ShiroAutoConfiguration.class, ShiroBeanAutoConfiguration.class})
@MapperScan(basePackages = "cn.wisenergy.mapper")
//排除原有的Multipart配置 spingboot接受不了multipartfile参数;取消加载数据源自动配置
// MybatisPlusAutoConfiguration.class, DataSourceAutoConfiguration.class,
@SpringBootApplication(exclude = {MultipartAutoConfiguration.class, MybatisPlusAutoConfiguration.class, DataSourceAutoConfiguration.class, ShiroAnnotationProcessorAutoConfiguration.class, ShiroAutoConfiguration.class, ShiroBeanAutoConfiguration.class})
//@MapperScan(basePackages = "cn.wisenergy.mapper")
//@ImportResource("classpath:mapper.*.xml")
@EnableSwagger2
@EnableScheduling
public class Application {
......
......@@ -4,10 +4,7 @@ import cn.wisenergy.common.utils.exception.BASE_RESP_CODE_ENUM;
import cn.wisenergy.common.utils.exception.BaseCustomException;
import cn.wisenergy.common.utils.exception.Result;
import cn.wisenergy.model.app.WorkDept;
import cn.wisenergy.model.dto.GetMonthlyCollectParam;
import cn.wisenergy.model.dto.ProjectStatisticsByMonth;
import cn.wisenergy.model.dto.UserWorkTimeStatisticsByProject;
import cn.wisenergy.model.dto.WorkTimeAndCostCollect;
import cn.wisenergy.model.dto.*;
import cn.wisenergy.service.StatisticsService;
import cn.wisenergy.service.WorkDeptService;
import cn.wisenergy.web.admin.controller.common.BaseController;
......@@ -20,7 +17,9 @@ import lombok.extern.slf4j.Slf4j;
import org.apache.poi.hssf.usermodel.HSSFWorkbook;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.MediaType;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import javax.servlet.ServletOutputStream;
import javax.servlet.http.HttpServletResponse;
......@@ -168,7 +167,7 @@ public class StatisticsController extends BaseController {
}
@ApiOperation(value = "导出项目统计明细", notes = "导出项目明细表")
@ApiOperation(value = "导出项目统计报表", notes = "导出项目明细表")
@ApiImplicitParams({
@ApiImplicitParam(name = "userId",value = "用户主键"),
@ApiImplicitParam(name = "year", value = "统计年"),
......@@ -192,6 +191,45 @@ public class StatisticsController extends BaseController {
}
}
@ApiOperation(value = "项目工时统计", notes = "项目统计明细报表")
@ApiImplicitParams({
@ApiImplicitParam(name = "userId",value = "用户主键"),
@ApiImplicitParam(name = "startDate", value = "起始统计日期"),
@ApiImplicitParam(name = "endDate", value = "结束统计日期"),
@ApiImplicitParam(name = "deptId", value = "部门主键,非中心不能选择")
})
@GetMapping("/getProjectStatisticsDetail")
public Result getProjectStatisticsDetail(ProjectTimeStatisticsParam projectTimeStatisticsParam){
log.info("StatisticsController[]getProjectStatisticsDetail[]input.param{}projectTimeStatisticsParam" + projectTimeStatisticsParam);
PageInfo projectStatisticsDetail = statisticsService.getProjectStatisticsDetail(projectTimeStatisticsParam);
return getResult(projectStatisticsDetail);
}
@ApiOperation(value = "导出项目工时统计", notes = "导出项目工时统计")
@ApiImplicitParams({
@ApiImplicitParam(name = "userId",value = "用户主键"),
@ApiImplicitParam(name = "startDate", value = "起始统计日期"),
@ApiImplicitParam(name = "endDate", value = "结束统计日期"),
@ApiImplicitParam(name = "deptId", value = "部门主键,非中心不能选择")
})
@GetMapping("/exportProjectTimeStatistics")
public void exportProjectTimeStatistics(ProjectTimeStatisticsParam projectTimeStatisticsParam,HttpServletResponse response){
log.info("StatisticsController[]exportProjectTimeStatistics[]input.param{}projectTimeStatisticsParam" +projectTimeStatisticsParam);
HSSFWorkbook sheets = new HSSFWorkbook();
try {
sheets = statisticsService.exportProjectTimeStatistics(projectTimeStatisticsParam);
String fileName = "工时统计";
downExcel(response, sheets, fileName);
}finally {
try {
sheets.close();
} catch (IOException e) {
e.printStackTrace();
throw new BaseCustomException(BASE_RESP_CODE_ENUM.SERVER_ERROR);
}
}
}
// 导出Excel
public void downExcel(HttpServletResponse response, HSSFWorkbook sheets, String fileName) {
//响应类型为application/octet- stream情况下使用了这个头信息的话,那就意味着不想直接显示内容
......
......@@ -119,5 +119,17 @@ public class WorkProjectController extends BaseController {
return getResult(projectOfFind);
}
@ApiOperation(value = "查询oa中项目", notes = "查询oa中项目")
@ApiImplicitParams({
@ApiImplicitParam(name = "userId", value = "用户主键"),
@ApiImplicitParam(name = "typeId", value = "类型主键"),
@ApiImplicitParam(name = "projectNameOrNo", value = "项目名称或oa编号")
})
@GetMapping("/queryOaProject")
public Result queryOaProject(Integer userId, Integer typeId, String projectNameOrNo, Integer currentPage, Integer pageSize){
log.info("WorkProjectController[]queryOaProject[]input.param{}userId,typeId,projectNameOrNo,currentPage,pageSize" + userId +"," + typeId + "," + projectNameOrNo + "," + currentPage + "," + pageSize);
PageInfo pageInfo = workProjectService.queryOaProject(userId, typeId, projectNameOrNo, currentPage, pageSize);
return getResult(pageInfo);
}
}
......@@ -221,4 +221,28 @@ public class WorkTimeOrderController extends BaseController {
return getResult(orderChangeLogPage);
}
@ApiOperation(value = "小程序长假/长调休填报", notes = "小程序长假/长调休填报")
@PostMapping("/takeALongLeave")
public Result takeALongLeave(TakeALongLeaveParam takeALongLeaveParam) {
log.info("WorkTimeOrderController[]takeALongLeave[]input.param" + takeALongLeaveParam);
Boolean isSuccess = workTimeOrderService.takeALongLeave(takeALongLeaveParam);
return getResult(isSuccess);
}
@ApiOperation(value = "获取用户长假/长调休信息", notes = "获取用户长假或长调休信息")
@GetMapping("/getUserLongLeaveInfo")
public Result getUserLongLeaveInfo(Integer userId) {
log.info("WorkTimeOrderController[]getLongLeaveInfo[]input.param{}userId" + userId);
List<LeaveResult> leaveResultList = workTimeOrderService.getUserLongLeaveInfo(userId);
return getResult(leaveResultList);
}
@ApiOperation(value = "获取时间段内节假日的天数", notes = "获取时间段内节假日的天数")
@GetMapping("getHolidayCountWithTimePeriod")
public Result getHolidayCountWithTimePeriod(String startDate, String endDate){
log.info("WorkTimeOrderController[]getHolidayCountWithTimePeriod[]input.param{}" + startDate + "," + endDate);
Integer daysCount = workTimeOrderService.getHolidayCountWithTimePeriod(startDate, endDate);
return getResult(daysCount);
}
}
......@@ -7,6 +7,7 @@ import cn.wisenergy.model.app.WorkSubmitAdopt;
import cn.wisenergy.model.app.WorkTimeOrder;
import cn.wisenergy.service.WorkCollectService;
import cn.wisenergy.service.WorkSubmitAdoptService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Configuration;
import org.springframework.scheduling.annotation.EnableScheduling;
......@@ -24,6 +25,7 @@ import java.util.List;
@Component
@Configuration
@EnableScheduling
@Slf4j
public class Trigger implements SchedulingConfigurer {
@Autowired
......@@ -40,6 +42,7 @@ public class Trigger implements SchedulingConfigurer {
public void configureTasks(ScheduledTaskRegistrar scheduledTaskRegistrar) {
TriggerTask trigerTask = new TriggerTask(
() -> {
log.info("*******自动审批***********");
//这里写业务方法
WorkSubmitAdopt workSubmitAdopt = workSubmitAdoptService.getById(1);
Integer autoExamine = workSubmitAdopt.getAutoExamine();
......@@ -59,7 +62,8 @@ public class Trigger implements SchedulingConfigurer {
}
, triggerContext -> {
Integer autoAdopt = workSubmitAdoptService.getById(1).getAutoAdopt();
// Integer autoAdopt = workSubmitAdoptService.getById(1).getAutoAdopt();
Integer autoAdopt =1;
String time = "0 0 0 */" + autoAdopt + " * ?";
//返回执行的周期
return new CronTrigger(time).nextExecutionTime(triggerContext);
......
spring:
datasource:
type: com.alibaba.druid.pool.DruidDataSource
druid:
driver-class-name: com.mysql.cj.jdbc.Driver
url: jdbc:mysql://192.168.110.84:3306/work_test?useUnicode=true&characterEncoding=UTF-8&allowMultiQueries=true&serverTimezone=GMT%2B8
username: root
password: admin!@#123
initial-size: 10
max-active: 100
min-idle: 10
max-wait: 60000
# 打开PSCache,并且指定每个连接上PSCache的大小
pool-prepared-statements: true
max-pool-prepared-statement-per-connection-size: 20
time-between-eviction-runs-millis: 60000
min-evictable-idle-time-millis: 300000
#Oracle需要打开注释
#validation-query: SELECT 1 FROM DUAL
test-while-idle: true
test-on-borrow: false
test-on-return: false
stat-view-servlet:
enabled: true
url-pattern: /druid/*
#login-username: admin
#login-password: admin
# 配置监控统计拦截的filters,去掉后监控界面sql无法统计,'wall'用于防火墙
filter:
stat:
log-slow-sql: true
slow-sql-millis: 1000
merge-sql: false
wall:
config:
multi-statement-allow: true
#文件上传配置
## 连接池配置
filters: stat
maxActive: 20
initialSize: 1
maxWait: 60000
minIdle: 1
timeBetweenEvictionRunsMillis: 60000
minEvictableIdleTimeMillis: 300000
validationQuery: select 'x'
testWhileIdle: true
testOnBorrow: false
testOnReturn: false
poolPreparedStatements: true
maxOpenPreparedStatements: 20
one:
## 数据源one配置
name: DBconfig1
url: jdbc:mysql://172.18.1.12:3306/view_wh?useUnicode=true&characterEncoding=UTF-8&allowMultiQueries=true&serverTimezone=GMT%2B8
username: wh_read
password: 8ik,*IK<
driver-class-name: com.mysql.cj.jdbc.Driver
type: com.alibaba.druid.pool.DruidDataSource
two:
## 数据源two配置
name: DBconfig2
url: jdbc:mysql://192.168.110.84:3306/work_test?useUnicode=true&characterEncoding=UTF-8&allowMultiQueries=true&serverTimezone=GMT%2B8
username: root
password: admin!@#123
driver-class-name: com.mysql.cj.jdbc.Driver
type: com.alibaba.druid.pool.DruidDataSource
# oa-datasource:
# type: com.alibaba.druid.pool.DruidDataSource
# druid:
# driver-class-name: com.mysql.cj.jdbc.Driver
# jdbc-url: jdbc:mysql://172.18.1.12:3306/view_wh?useUnicode=true&characterEncoding=UTF-8&allowMultiQueries=true&serverTimezone=GMT%2B8
# username: wh_read
# password: 8ik,*IK<
# initial-size: 10
# max-active: 100
# min-idle: 10
# max-wait: 60000
# datasource:
# type: com.alibaba.druid.pool.DruidDataSource
# druid:
# driver-class-name: com.mysql.cj.jdbc.Driver
# jdbc-url: jdbc:mysql://192.168.110.84:3306/work_test?useUnicode=true&characterEncoding=UTF-8&allowMultiQueries=true&serverTimezone=GMT%2B8
# username: root
# password: admin!@#123
# initial-size: 10
# max-active: 100
# min-idle: 10
# max-wait: 60000
# # 打开PSCache,并且指定每个连接上PSCache的大小
# pool-prepared-statements: true
# max-pool-prepared-statement-per-connection-size: 20
# time-between-eviction-runs-millis: 60000
# min-evictable-idle-time-millis: 300000
# #Oracle需要打开注释
# #validation-query: SELECT 1 FROM DUAL
# test-while-idle: true
# test-on-borrow: false
# test-on-return: false
# stat-view-servlet:
# enabled: true
# url-pattern: /druid/*
# #login-username: admin
# #login-password: admin
# # 配置监控统计拦截的filters,去掉后监控界面sql无法统计,'wall'用于防火墙
# filter:
# stat:
# log-slow-sql: true
# slow-sql-millis: 1000
# merge-sql: false
# wall:
# config:
# multi-statement-allow: true
# #文件上传配置
servlet:
multipart:
# 启用
......@@ -44,19 +87,20 @@ spring:
# 总限制
max-request-size: 10MB
# redis:
# database: 0
# host: localhost
# port: 6379
# password: root # 密码(默认为空)
# timeout: 6000ms # 连接超时时长(毫秒)
# jedis:
# pool:
# max-active: 1000 # 连接池最大连接数(使用负值表示没有限制)
# max-wait: -1ms # 连接池最大阻塞等待时间(使用负值表示没有限制)
# max-idle: 10 # 连接池中的最大空闲连接
# min-idle: 5 # 连接池中的最小空闲连
###上传文件配置 :该配置可根据部署的系统或开发人员自定义路径,每次部署之前需要修改location
redis:
database: 0
host: 192.168.110.84
port: 6379
password: # 密码(默认为空)
timeout: 6000ms # 连接超时时长(毫秒)
jedis:
pool:
max-active: 1000 # 连接池最大连接数(使用负值表示没有限制)
max-wait: -1ms # 连接池最大阻塞等待时间(使用负值表示没有限制)
max-idle: 10 # 连接池中的最大空闲连接
min-idle: 5 # 连接池中的最小空闲连
##上传文件配置 :该配置可根据部署的系统或开发人员自定义路径,每次部署之前需要修改location
uploadFile:
resourceHandler: /upload_flowChart/** #请求 url 中的资源映射也是保存到数据库中的父级路径
#location: D:/java/test/upload_flowChart/ #自定义上传文件服务器硬盘保存路径 ,linux服务器保存路径 /home/changfa/app/wxbjgkpt/upload_flowChart
......@@ -67,4 +111,10 @@ jwt:
# token有效时长,单位秒
expire: 14400
logging:
config: classpath:logback-spring.xml
\ No newline at end of file
config: classpath:logback-spring.xml
mybatis-plus:
mapper-locations: classpath*:mapper/*.xml
mybatis:
mapper-locations: classpath*:mapper/*.xml
#redis
\ No newline at end of file
......@@ -3,9 +3,10 @@ server:
uri-encoding: UTF-8
max-threads: 1000
min-spare-threads: 30
port: 8080
port: 8086
connection-timeout: 5000ms
spring:
main:
allow-bean-definition-overriding: true
......@@ -26,27 +27,27 @@ spring:
# resources:
# add-mappings: false
#mybatis
mybatis-plus:
mapper-locations: classpath*:/mapper/**/*.xml
#实体扫描,多个package用逗号或者分号分隔
#typeAliasesPackage: cn.wisenergy.service.*
global-config:
#数据库相关配置
db-config:
#主键类型 AUTO:"数据库ID自增", INPUT:"用户输入ID", ID_WORKER:"全局唯一ID (数字类型唯一ID)", UUID:"全局唯一ID UUID";
id-type: AUTO
#驼峰下划线转换
column-underline: true
logic-delete-value: -1
logic-not-delete-value: 0
banner: false
#原生配置
configuration:
map-underscore-to-camel-case: true
cache-enabled: false
call-setters-on-nulls: true
jdbc-type-for-null: 'null'
##mybatis
#mybatis-plus:
# mapper-locations: classpath*:mapper/*.xml
# #实体扫描,多个package用逗号或者分号分隔
# #typeAliasesPackage: cn.wisenergy.service.*
# global-config:
# #数据库相关配置
# db-config:
# #主键类型 AUTO:"数据库ID自增", INPUT:"用户输入ID", ID_WORKER:"全局唯一ID (数字类型唯一ID)", UUID:"全局唯一ID UUID";
# id-type: AUTO
# #驼峰下划线转换
# column-underline: true
# logic-delete-value: -1
# logic-not-delete-value: 0
# banner: false
# #原生配置
# configuration:
# map-underscore-to-camel-case: true
# cache-enabled: false
# call-setters-on-nulls: true
# jdbc-type-for-null: 'null'
camera:
......@@ -63,8 +64,8 @@ camera:
appSecret: TDrCbqQXe9XSt7SimYDO
path: /artemis
mybatis:
mapper-locations: classpath:/mapper/*Mapper.xml
#mybatis:
# mapper-locations: classpath*:/mapper/*Mapper.xml
logging:
level:
cn.wisenergy.mapper : debug
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment