企业端设备模块->和前端调试接口

This commit is contained in:
79493 2022-11-07 17:47:41 +08:00
parent 0db404563a
commit a279ce4315
28 changed files with 650 additions and 153 deletions

View File

@ -23,10 +23,8 @@ public interface EntPostDutyMapper extends BaseMapper<EntPostDuty> {
* 企业用户岗位职责
* @param enterpriseId 企业id
* @param postId 岗位id
* @param page 页码
* @param pageSize 条数
* @return EntPostTask 企业用户岗位职责
* */
List<EntPostDuty>selectEntUserPostDuty(@Param("enterpriseId") String enterpriseId, @Param("postId")String postId,@Param("page") Integer page,@Param("pageSize")Integer pageSize);
List<EntPostDuty>selectEntUserPostDuty(@Param("enterpriseId") String enterpriseId, @Param("postId")String postId);
}

View File

@ -24,27 +24,41 @@ public interface EntPostListMapper extends BaseMapper<EntPostList> {
*
* @param enterpriseId 企业id
* @param entUserId 企业用户id
* @param finishedState 完成状态
* @param postId 岗位id
* @param page 页码
* @param pageSize 条数
* @return EntPostList 企业用户工作要务
*/
List<EntPostList> selectEntPostList(@Param("enterpriseId") String enterpriseId, @Param("entUserId") String entUserId, @Param("postId") String postId, Integer page, Integer pageSize);
List<EntPostList> selectEntPostList(@Param("enterpriseId") String enterpriseId, @Param("entUserId") String entUserId,@Param("finishedState") Integer finishedState ,@Param("postId") String postId, Integer page, Integer pageSize);
/**
* 企业清单条数
* @param enterpriseId 企业id
* @param listId 企业用户id
* @param year 年份
* @return int 企业岗位条数
*/
Integer selectEntPostListCount(@Param("enterpriseId") String enterpriseId,@Param("listId")String listId);
Integer selectEntPostListCount(@Param("enterpriseId") String enterpriseId,@Param("listId")String listId,@Param("year") Integer year);
/**
* 企业清单完成条数
* @param enterpriseId 企业id
* @param listId 企业用户id
* @param state 状态
* @param year 年份
* @return int 企业清单完成条数
*/
Integer selectEntPostListFinishedCount(@Param("enterpriseId") String enterpriseId,@Param("listId")String listId,@Param("state")Integer state);
Integer selectEntPostListFinishedCount(@Param("enterpriseId") String enterpriseId,@Param("listId")String listId,@Param("state")Integer state,@Param("year") Integer year);
/**
* 企业清单(类型)分组查询
* @param enterpriseId 企业id
* @param listId 清单id
* @param userId 用户id
* @return int 企业清单(类型)
*/
List<EntPostList>selectEntListGroupByListId(@Param("enterpriseId") String enterpriseId,@Param("listId")String listId,@Param("userId")String userId);
}

View File

@ -2,6 +2,7 @@ package com.rzyc.mapper;
import com.rzyc.model.EntPostTask;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.rzyc.model.EntPostTaskStatistic;
import org.apache.ibatis.annotations.Param;
import org.springframework.stereotype.Repository;
@ -27,14 +28,11 @@ public interface EntPostTaskMapper extends BaseMapper<EntPostTask> {
* @param listId 清单id
* @param content 内容模糊搜索
* @param taskState 任务状态
* @param page 页码
* @param pageSize 条数
* @return EntPostTask 企业用户清单任务
* */
List<EntPostTask>selectEntUserPostTask(@Param("enterpriseId") String enterpriseId, @Param("entUserId")String entUserId,
@Param("postId")String postId, @Param("listId")String listId,
@Param("content")String content,@Param("taskState") Integer taskState,
@Param("page") Integer page,@Param("pageSize") Integer pageSize);
@Param("content")String content,@Param("taskState") Integer taskState);
/**
@ -50,7 +48,22 @@ public interface EntPostTaskMapper extends BaseMapper<EntPostTask> {
@Param("page") Integer page,@Param("pageSize") Integer pageSize);
/**
* 查询企业岗位履职数
* @param enterpriseId 企业id
* @param listId 清单id
* @param year 年份
* @return EntPostTaskStatistic 统计对象
* */
EntPostTaskStatistic selectEntPostTaskByState(@Param("enterpriseId") String enterpriseId,@Param("listId") String listId,@Param("year") Integer year);
/**
* 查询企业岗位履职总数
* @param enterpriseId 企业id
* @param listId 清单id
* @param year 年份
* @return long 统计总条数
* */
long selectEntPostTaskTotal(@Param("enterpriseId") String enterpriseId,@Param("listId")String listId,@Param("year") Integer year);
}

View File

@ -31,9 +31,10 @@ public interface EntUserMapper extends BaseMapper<EntUser> {
* @param keyContent 关键字
* @param page 页码
* @param pageSize 条数
* @param postId 岗位id
* @return EntUser 企业用户实体
* */
List<EntUser>selectEntUserList(@Param("keyContent") String keyContent,@Param("page")Integer page,@Param("pageSize")Integer pageSize);
List<EntUser>selectEntUserList(@Param("keyContent") String keyContent,@Param("page")Integer page,@Param("pageSize")Integer pageSize,@Param("postId")String postId);
/**

View File

@ -2,6 +2,7 @@ package com.rzyc.mapper.ent;
import com.rzyc.model.ent.InEntList;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import org.apache.ibatis.annotations.Param;
import org.springframework.stereotype.Repository;
import java.util.List;
@ -17,5 +18,11 @@ import java.util.List;
@Repository
public interface InEntListMapper extends BaseMapper<InEntList> {
/**
* 查询企业清单类型
* @param enterpriseId 企业id
* @return list
* */
List<InEntList> selectByEnterpriseId(@Param("enterpriseId") String enterpriseId);
}

View File

@ -103,8 +103,33 @@ public class EntPostList implements Serializable {
private String modifyBy;
@TableField(exist = false)
@ApiModelProperty(value = "已完成数")
private Integer finishCount;
@TableField(exist = false)
@ApiModelProperty(value = "进行中数")
private Integer haveInHand;
@TableField(exist = false)
@ApiModelProperty(value = "任务总数")
private Integer totalTaskNumber;
public Integer getHaveInHand() {
return haveInHand;
}
public void setHaveInHand(Integer haveInHand) {
this.haveInHand = haveInHand;
}
public Integer getTotalTaskNumber() {
return totalTaskNumber;
}
public void setTotalTaskNumber(Integer totalTaskNumber) {
this.totalTaskNumber = totalTaskNumber;
}
public Integer getFinishCount() {
return finishCount;
}

View File

@ -0,0 +1,47 @@
package com.rzyc.model;
/**
* 企业岗位任务履职统计
* @author Xuwanxin
* @date 2022/11/1
* */
public class EntPostTaskStatistic {
/**
* 进行中
* */
private long haveInHand = 0;
/**
* 已完成
* */
private long finished = 0 ;
/**
* 超时
* */
private long overtime = 0;
public long getHaveInHand() {
return haveInHand;
}
public void setHaveInHand(long haveInHand) {
this.haveInHand = haveInHand;
}
public long getFinished() {
return finished;
}
public void setFinished(long finished) {
this.finished = finished;
}
public long getOvertime() {
return overtime;
}
public void setOvertime(long overtime) {
this.overtime = overtime;
}
}

View File

@ -14,6 +14,7 @@ import javax.validation.constraints.NotNull;
* */
public class AddOrUpdateEntPostDto {
@NotNull
@ApiModelProperty(value = "企业岗位id")
private String postId;
@ -37,6 +38,16 @@ public class AddOrUpdateEntPostDto {
@ApiModelProperty(value = "岗位层级")
private Integer postLevel;
@ApiModelProperty(value = "排序字段")
private Integer sort;
public Integer getSort() {
return sort;
}
public void setSort(Integer sort) {
this.sort = sort;
}
public String getPostId() {
return postId;

View File

@ -15,18 +15,17 @@ import javax.validation.constraints.NotNull;
public class EntUserPostDutyDto {
@NotNull
@ApiModelProperty(value = "企业id")
@ApiModelProperty(value = "企业id",required = true)
private String enterpriseId;
@NotNull
@ApiModelProperty(value = "岗位id")
private String postId;
@NotNull
@ApiModelProperty(value = "页码")
private Integer page;
@NotNull
@ApiModelProperty(value = "条数")
private Integer pageSize;

View File

@ -14,25 +14,36 @@ import javax.validation.constraints.NotNull;
@ApiModel(value = "企业用户岗位要务Dto",description = "企业用户岗位要务Dto")
public class EntUserPostListDto {
@NotNull
@ApiModelProperty(value = "企业id")
@ApiModelProperty(value = "企业id",required = true)
String enterpriseId;
@NotNull
@ApiModelProperty(value = "企业用户id")
@ApiModelProperty(value = "企业用户id",required = true)
String entUserId;
@ApiModelProperty(value = "岗位id")
String postId;
@NotNull
@ApiModelProperty(value = "页码")
Integer page;
@NotNull
@ApiModelProperty(value = "条数")
Integer pageSize;
@ApiModelProperty(value = "完成状态")
Integer finishedState;
public Integer getFinishedState() {
return finishedState;
}
public void setFinishedState(Integer finishedState) {
this.finishedState = finishedState;
}
public String getEnterpriseId() {
return enterpriseId;
}

View File

@ -15,11 +15,11 @@ import javax.validation.constraints.NotNull;
public class EntUserPostTaskDto {
@NotNull
@ApiModelProperty(value = "企业id")
@ApiModelProperty(value = "企业id",required = true)
String enterpriseId;
@NotNull
@ApiModelProperty(value = "企业用户id")
@ApiModelProperty(value = "企业用户id",required = true)
String entUserId;
@ -34,15 +34,15 @@ public class EntUserPostTaskDto {
@ApiModelProperty(value = "模糊内容")
String content;
@NotNull
@ApiModelProperty(value = "任务状态")
Integer taskState;
@NotNull
@ApiModelProperty(value = "页码")
Integer page;
@NotNull
@ApiModelProperty(value = "条数")
Integer pageSize;

View File

@ -112,17 +112,31 @@ public class EntUser implements Serializable {
@ApiModelProperty(value = "工号")
private String jobNumber;
@TableField(exist = false)
private LocalTime localTime;
private String token;
public LocalTime getLocalTime() {
return localTime;
@ApiModelProperty(value = "岗位名字")
@TableField(exist = false)
private String entPostName;
public String getEntPostName() {
return entPostName;
}
public void setLocalTime(LocalTime localTime) {
this.localTime = localTime;
public void setEntPostName(String entPostName) {
this.entPostName = entPostName;
}
public String getToken() {
return token;
}
public void setToken(String token) {
this.token = token;
}
public String getJobNumber() {
return jobNumber;
}

View File

@ -21,7 +21,7 @@
</sql>
<select id="selectEntUserPostDuty" resultMap="BaseResultMap">
select * from ent_post_duty where enterprise_id = #{enterpriseId} and post_id = #{postId} limit #{page},#{pageSize}
select * from ent_post_duty where enterprise_id = #{enterpriseId} and post_id = #{postId}
</select>
</mapper>

View File

@ -35,6 +35,9 @@
<select id="selectEntPostList" resultMap="BaseResultMap">
select epl.*,sum(case when task_state = 2 then 1 else 0 end)as finishCount from ent_post_list epl left join ent_post_task ept on epl.post_list_id = ept.post_list_id
where epl.enterprise_id = #{enterpriseId} and epl.ent_user_id = #{entUserId}
<if test="null != finishedState and '' != finishedState">
and epl.finish_state = #{finishedState}
</if>
<if test="null !=postId and '' != postId">
and epl.post_id = #{postId}
</if>
@ -42,11 +45,45 @@
</select>
<select id="selectEntPostListCount" resultType="java.lang.Integer">
select * from ent_post_list where enterprise_id = #{enterpriseId} and list_id = #{listId}
select count(post_list_id) from ent_post_list where enterprise_id = #{enterpriseId}
<if test="null != listId and '' != listId">
and list_id = #{listId}
</if>
<if test="null != year">
and `year_num` = #{year}
</if>
</select>
<select id="selectEntPostListFinishedCount" resultType="java.lang.Integer">
select * from ent_post_list where enterprise_id = #{enterpriseId} and list_id = #{listId} and finish_satte = #{state}
select count(post_list_id) from ent_post_list where enterprise_id = #{enterpriseId}
<if test="null != listId and '' != listId">
and list_id = #{listId}
</if>
<if test="null != state and '' != state">
and finish_state = #{state}
</if>
<if test="null != year">
and `year` = #{year}
</if>
</select>
<resultMap id="EntListGroupMap" type="com.rzyc.model.EntPostList">
<result column="list_id" property="listId" />
<result column="item_title" property="itemTitle" />
<result column="totalTaskNumber" property="totalTaskNumber"/>
<result column="haveInHand" property="haveInHand"/>
</resultMap>
<select id="selectEntListGroupByListId" resultMap="EntListGroupMap">
select epl.list_id,epl.item_title,count(ept.task_id)as totalTaskNumber,sum(case when task_state = 1 then 1 else 0 end)as haveInHand
from ent_post_list epl
left join ent_post_task ept on epl.post_list_id = ept.ent_list_id
where epl.enterprise_id = #{enterpriseId} and epl.ent_user_id = #{userId}
<if test="null != listId and '' != listId">
and epl.list_id = #{listId}
</if>
group by epl.list_id,epl.item_title
</select>

View File

@ -30,7 +30,10 @@
</sql>
<select id="selectEntUserPostTask" resultMap="BaseResultMap">
select * from ent_post_task where ent_user_id = #{entUserId} and enterprise_id = #{enterpriseId} and list_id = #{listId}
select * from ent_post_task where ent_user_id = #{entUserId} and enterprise_id = #{enterpriseId}
<if test="listId != null and '' != listId">
and list_id = #{listId}
</if>
<if test="null != postId and '' != postId">
and post_id = #{postId}
</if>
@ -53,6 +56,48 @@
limit #{page},#{pageSize}
</select>
<select id="selectEntPostTaskTotal" resultType="java.lang.Long">
select count(ept.task_id) from ent_post_task ept
left join ent_post_list epl on ept.ent_list_id = epl.post_list_id
where epl.enterprise_id = #{enterpriseId}
<if test="null != year">
and epl.year_num = #{year}
</if>
</select>
<select id="selectEntPostTaskTotal" resultType="java.lang.Long">
select count(ept.task_id) from ent_post_task ept
left join ent_post_list epl on ept.ent_list_id = epl.post_list_id
where epl.enterprise_id = #{enterpriseId}
<if test="null != year">
and epl.year_num = #{year}
</if>
<if test="null != listId and '' != listId">
and epl.post_list_id = #{listId}
</if>
</select>
<resultMap id="entPostTaskByStateMap" type="com.rzyc.model.EntPostTaskStatistic">
<result column="haveInHand" property="haveInHand" />
<result column="finished" property="finished" />
<result column="overtime" property="overtime" />
</resultMap>
<select id="selectEntPostTaskByState" resultMap="entPostTaskByStateMap">
select sum(case when task_state = 1 then 1 else 0 end)as haveInHand,
sum(case when task_state = 2 then 1 else 0 end)as finished,
sum(case when task_state = 3 then 1 else 0 end)as overtime
from ent_post_task ept
left join ent_post_list epl on ept.ent_list_id = epl.post_list_id
where epl.enterprise_id = #{enterpriseId}
<if test="null != year">
and epl.year_num = #{year}
</if>
<if test="null != listId and '' != listId">
and epl.post_list_id = #{listId}
</if>
</select>
</mapper>

View File

@ -30,19 +30,19 @@
<if test="null != postId and '' != postId">
and post_path like concat('%',#{postId},'%')
</if>
order by post_level asc
order by post_level,sort asc
</select>
<update id="updateEntPost">
update set name = #{data.name},parent_id = #{data.parentId},post_path = #{data.postPath},parent_name = #{data.parentName},post_level = #{postLevel},
modify_time = #{modifyTime} , modify_by = #{modifyBy}
where post_id = #{postId},enterprise_id = #{enterpriseId}
update ent_post set name = #{data.name},parent_id = #{data.parentId},post_path = #{data.postPath},parent_name = #{data.parentName},post_level = #{data.postLevel},
modify_time = #{data.modifyTime} , modify_by = #{data.modifyBy}
where post_id = #{data.postId} and enterprise_id = #{data.enterpriseId}
</update>
<insert id="insertEntPost">
insert into ent_post (post_id,enterprise_id,name,parent_id,post_path,parent_name,post_level,completion_rate,subordinates,create_time,create_by)
values(#{data.postId},#{data.enterpriseId},#{data.name},#{data.parentId},#{data.postPath},#{data.parentName},#{data.postLevel},#{data.completionRate},#{data.subordinates},
,#{data.createTime},#{data.createBy})
#{data.createTime},#{data.createBy})
</insert>
</mapper>

View File

@ -54,8 +54,12 @@
</resultMap>
<select id="selectEntUserList" resultMap="entUserListStatistic">
select eu.*,ep.name postName,sum(case when credential_state = 1 then 1 else 0 end)as noTimeout,sum(case when credential_state = 2 then 1 else 0 end)as overtime ,
sum(case when task_state = 1 then 1 else 0 end) as ongoingTask,sum(case when task_state = 2 then 1 else 0 end) as finishTask,sum(case when task_state = 3 then 1 else 0 end) as overTimeTask
select eu.*,ep.name postName,
sum(case when credential_state = 1 then 1 else 0 end)as noTimeout,
sum(case when credential_state = 2 then 1 else 0 end)as overtime ,
sum(case when task_state = 1 then 1 else 0 end) as ongoingTask,
sum(case when task_state = 2 then 1 else 0 end) as finishTask,
sum(case when task_state = 3 then 1 else 0 end) as overTimeTask
from ent_user eu
left join ent_post ep on eu.post_id = ep.post_id
left join ent_user_credential euc on eu.ent_user_id = euc.ent_user_id
@ -65,6 +69,9 @@
or eu.job_number like concat('%',#{keyContent},'%')
or ep.name like concat('%',#{keyContent},'%')
</if>
<if test="null != postId and '' != postId">
and eu.post_path like concat('%',#{postId},'%')
</if>
limit #{page},#{pageSize}
</select>

View File

@ -30,4 +30,8 @@
item_basis, item_proof, item_law, sort_id,del_state, create_time, create_by, modify_time, modify_by
</sql>
<select id="selectByEnterpriseId" resultMap="BaseResultMap">
select * from in_ent_list where enterprise_id = #{enterpriseId}
</select>
</mapper>

View File

@ -92,7 +92,63 @@
where SysEnterpriseId = #{sysenterpriseid,jdbcType=VARCHAR}
</delete>
<insert id="insert" parameterType="com.rzyc.model.ent.SysEnterprise">
insert into SysEnterprise (SysEnterpriseId,
OrgCode,
street_code,
community_code,
net_code,
SuperiorEnterpriseId,
LowOrgCode, EntName,isHide, State,complite,sysUnitId,ManagerDept,dynamicRiskLevel,inherentRisk,manageType,EntType,
EntSection, BaseSafeClassId, BaseInClassId,work_class_id,
PinYin, Principal,
SysAddress,
safeTelephone,
safeManager,
PostCode, EcoType, PersonCount,
EntLogoPic, MaleCode, OrgPassNo,
LegalRepre, LRIDCard, LRLinkTel,
EstablishDate, RiskLevel, Latitude,
Longitude, IsBlackList, Comments,
ISMaleCode, EntScore, EntHouseNum,
CreatedOn, CreatedBy, ModifiedOn,
ModifiedBy,qr_code)
values (
#{sysenterpriseid,jdbcType=VARCHAR},
#{orgcode,jdbcType=VARCHAR},
#{streetCode,jdbcType=VARCHAR},
#{communityCode,jdbcType=VARCHAR},
#{netCode,jdbcType=VARCHAR},
#{superiorenterpriseid,jdbcType=VARCHAR},
#{loworgcode,jdbcType=VARCHAR},
#{entname,jdbcType=VARCHAR},
#{isHide,jdbcType=VARCHAR},
#{state,jdbcType=VARCHAR},
#{complite,jdbcType=VARCHAR},
#{sysUnitId,jdbcType=VARCHAR},
#{managerDept,jdbcType=VARCHAR},
#{dynamicRiskLevel,jdbcType=VARCHAR},
#{inherentRisk,jdbcType=VARCHAR},
#{manageType,jdbcType=VARCHAR},
#{enttype,jdbcType=VARCHAR},
#{entsection,jdbcType=VARCHAR}, #{basesafeclassid,jdbcType=VARCHAR},
#{baseinclassid,jdbcType=VARCHAR},
#{workClassId,jdbcType=VARCHAR},
#{pinyin,jdbcType=VARCHAR}, #{principal,jdbcType=VARCHAR},
#{sysaddress,jdbcType=VARCHAR},
#{safeTelephone,jdbcType=VARCHAR},
#{safeManager,jdbcType=VARCHAR},
#{postcode,jdbcType=VARCHAR}, #{ecotype,jdbcType=VARCHAR}, #{personcount,jdbcType=INTEGER},
#{entlogopic,jdbcType=VARCHAR}, #{malecode,jdbcType=VARCHAR}, #{orgpassno,jdbcType=VARCHAR},
#{legalrepre,jdbcType=VARCHAR}, #{lridcard,jdbcType=VARCHAR}, #{lrlinktel,jdbcType=VARCHAR},
#{establishdate,jdbcType=TIMESTAMP}, #{risklevel,jdbcType=VARCHAR}, #{latitude,jdbcType=VARCHAR},
#{longitude,jdbcType=VARCHAR}, #{isblacklist,jdbcType=VARCHAR}, #{comments,jdbcType=VARCHAR},
#{ismalecode,jdbcType=VARCHAR}, #{entscore,jdbcType=VARCHAR}, #{enthousenum,jdbcType=VARCHAR},
#{createdon,jdbcType=TIMESTAMP}, #{createdby,jdbcType=VARCHAR}, #{modifiedon,jdbcType=TIMESTAMP},
#{modifiedby,jdbcType=VARCHAR},#{qrCode})
</insert>
<insert id="insertSelective" parameterType="com.rzyc.model.ent.SysEnterprise">
insert into SysEnterprise
<trim prefix="(" suffix=")" suffixOverrides=",">
@ -2500,7 +2556,7 @@
</select>
<select id="findEnterpriseByName" resultMap="BaseResultMap">
select sysent.EntName,sysent.state from ent_user eu left join sysenterprise sysent on eu.enterprise_id = sysent.SysEnterpriseId where eu.name = #{entUserName}
select sysent.EntName,sysent.state,sysent.SysEnterpriseId from ent_user eu left join sysenterprise sysent on eu.enterprise_id = sysent.SysEnterpriseId where eu.name = #{entUserName}
</select>

View File

@ -40,16 +40,11 @@ public class PageAspect {
Pager pager = new Pager();
pager.setRows(page.getResult());
pager.setTotal(page.getTotal());
return packageData(pager);
return pager;
}
return proceed;
}
private SingleResult packageData( Pager pager){
SingleResult singleResult = new SingleResult();
singleResult.setData(pager);
return singleResult;
}
/**
* 设置参数,返回是否分页

View File

@ -14,9 +14,23 @@ import java.util.Collection;
public class UserDetailsAndId extends User {
/**
* 用户id
* */
private String id;
/**
* 企业岗位id
* */
private String postId;
public String getPostId() {
return postId;
}
public void setPostId(String postId) {
this.postId = postId;
}
public String getId() {
return id;
@ -28,9 +42,10 @@ public class UserDetailsAndId extends User {
public UserDetailsAndId(String username, String password, Collection<? extends GrantedAuthority> authorities, String id) {
public UserDetailsAndId(String username, String password, Collection<? extends GrantedAuthority> authorities, String id,String postId) {
super(username, password, authorities);
setId(id);
setPostId(postId);
}
}

View File

@ -20,13 +20,16 @@ import com.rzyc.bean.check.dto.LawAddDto;
import com.rzyc.bean.check.dto.TalkAddDto;
import com.rzyc.bean.ent.*;
import com.rzyc.bean.user.dto.LoginDto;
import com.rzyc.config.MethodAnnotation;
import com.rzyc.model.Accident;
import com.rzyc.model.EntCertificates;
import com.rzyc.model.check.*;
import com.rzyc.model.ent.EntBillCon;
import com.rzyc.model.ent.InEntList;
import com.rzyc.model.ent.SysEnterprise;
import com.rzyc.model.user.SysUnit;
import com.rzyc.model.user.SysUser;
import com.rzyc.service.PcBusinessService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
@ -37,6 +40,7 @@ import org.apache.commons.beanutils.ConvertUtils;
import org.apache.commons.beanutils.converters.DateConverter;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.stereotype.Controller;
import org.springframework.transaction.annotation.Transactional;
@ -64,7 +68,8 @@ import java.util.List;
@Controller
@Validated
public class PcCompanyController extends BaseController{
@Autowired
PcBusinessService pcBusinessService;
/**
* PC企业详细
@ -185,8 +190,8 @@ public class PcCompanyController extends BaseController{
result.setMessage(Message.PASSWORD_ERROR);
}
}else{
result.setCode(Code.PASSWORD_ERROR.getCode());
result.setMessage(Message.PASSWORD_ERROR);
result.setCode(Code.ERROR.getCode());
result.setMessage(Message.ERROR);
}
}else{
result.setCode(Code.CODE_ERROT.getCode());
@ -764,7 +769,7 @@ public class PcCompanyController extends BaseController{
@ApiOperation(value = "证照分页新增或者修改", notes = "证照分页新增或者修改")
@PostMapping("/certificatesAdd")
@ResponseBody
public SingleResult<String> certificatesAdd(@Valid CertificatesAddDto certificatesAddDto)throws Exception{
public SingleResult<String> certificatesAdd(@RequestBody @Valid CertificatesAddDto certificatesAddDto)throws Exception{
SingleResult<String> result = new SingleResult<>();
String userId = getUserId();
@ -827,4 +832,85 @@ public class PcCompanyController extends BaseController{
return "SysEnterpriseId";
}
/**
* @author Xuwanxin
* 企业清单统计
* @param listId
* @throws Exception
*/
@ApiOperation(value = "企业清单统计", notes = "企业清单统计")
@ApiImplicitParams({
@ApiImplicitParam(name = "listId", value = "清单Id",required = true, dataType = "string"),
@ApiImplicitParam(name = "keyWord", value = "关键字",required = true, dataType = "string"),
@ApiImplicitParam(name = "page", value = "page",required = true, dataType = "int"),
@ApiImplicitParam(name = "pageSize", value = "pageSize",required = true, dataType = "int"),
})
@GetMapping(value = "/inListStatistic")
@PreAuthorize("hasAnyAuthority('inListStatistic')")
@MethodAnnotation(authorizations = {"inListStatistic"},name = "企业清单统计")
@ResponseBody
public SingleResult entUserList(String listId,
@RequestParam(required = true) String enterpriseId,
String keyWord,
@RequestParam(required = true) Integer page,
@RequestParam(required = true) Integer pageSize)throws Exception{
return pcBusinessService.inListStatistic(enterpriseId,listId,keyWord,page,pageSize);
}
/**
* 企业清单类型
* @return list
* @throws Exception
*/
@ApiOperation(value = "企业清单类型", notes = "企业清单类型")
@GetMapping(value = "/inListTypes")
@PreAuthorize("hasAnyAuthority('inListTypes')")
@MethodAnnotation(authorizations = {"inListTypes"},name = "企业清单类型")
@ResponseBody
public SingleResult<List<InEntList>> entUserList(@RequestParam(required = true) String enterpriseId)throws Exception{
return pcBusinessService.inListTypes(enterpriseId);
}
/**
* 企业工作要务总进度
* @return list
* @throws Exception
*/
@ApiOperation(value = "企业工作要务总进度", notes = "企业工作要务总进度")
@GetMapping(value = "/entPostListFinishedPercent")
@ApiImplicitParams({
@ApiImplicitParam(name = "enterpriseId", value = "企业id",required = true, dataType = "string"),
@ApiImplicitParam(name = "year", value = "年份",required = false, dataType = "string"),
@ApiImplicitParam(name = "listId", value = "清单id",required = false, dataType = "string"),
})
@PreAuthorize("hasAnyAuthority('entPostListFinishedPercent')")
@MethodAnnotation(authorizations = {"entPostListFinishedPercent"},name = "企业工作要务总进度")
@ResponseBody
public SingleResult entPostListFinishedPercent(@RequestParam(required = true) String enterpriseId,Integer year,String listId)throws Exception{
return pcBusinessService.entPostProcessStatistic(enterpriseId,listId,year);
}
/**
* 企业清单履职总统计
* @return list
* @throws Exception
*/
@ApiOperation(value = "企业清单履职总统计", notes = "企业清单履职总统计")
@GetMapping(value = "/entPostListPercentStatistic")
@ApiImplicitParams({
@ApiImplicitParam(name = "enterpriseId", value = "企业id",required = true, dataType = "string"),
@ApiImplicitParam(name = "year", value = "年份",required = false, dataType = "string"),
@ApiImplicitParam(name = "listId", value = "清单id",required = false, dataType = "string"),
})
@PreAuthorize("hasAnyAuthority('entPostListPercentStatistic')")
@MethodAnnotation(authorizations = {"entPostListPercentStatistic"},name = "企业清单履职总统计")
@ResponseBody
public SingleResult entPostListPercentStatistic(@RequestParam(required = true)String enterpriseId,Integer year,String listId)throws Exception{
return pcBusinessService.entPostListPercentStatistic(enterpriseId,listId,year);
}
}

View File

@ -10,7 +10,12 @@ import com.common.utils.model.SingleResult;
import com.rzyc.bean.user.dto.LoginDto;
import com.rzyc.config.MethodAnnotation;
import com.rzyc.config.RedisUtil;
import com.rzyc.model.EntPostDuty;
import com.rzyc.model.EntPostList;
import com.rzyc.model.EntPostTask;
import com.rzyc.model.EntUserCredential;
import com.rzyc.model.dto.*;
import com.rzyc.model.ent.EntPost;
import com.rzyc.model.ent.EntUser;
import com.rzyc.service.PcBusinessService;
import com.rzyc.service.UserLoginService;
@ -21,13 +26,14 @@ import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import org.apache.poi.ss.formula.functions.T;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Bean;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;
import javax.validation.Valid;
import javax.validation.constraints.NotNull;
import java.util.ArrayList;
import java.util.List;
import java.util.Objects;
@ -53,6 +59,11 @@ public class PersonalController extends BaseController{
RedisUtil redisUtil;
/**
*只允许使用page注解的使用此静态包装
*/
final static SingleResult singleResult = new SingleResult();
@Autowired
public PersonalController(UserLoginService userLoginService, PcBusinessService pcBusinessService, RedisUtil redisUtil) {
this.userLoginService = userLoginService;
@ -66,15 +77,15 @@ public class PersonalController extends BaseController{
*/
@ApiOperation(value = "用户登录", notes = "用户登录")
@PostMapping(value = "/login")
public SingleResult<String> login(@Valid LoginDto loginDto)throws Exception{
SingleResult<String> result = new SingleResult<>();
public SingleResult<EntUser> login(@Valid LoginDto loginDto)throws Exception{
SingleResult<EntUser> result = new SingleResult<>();
String generateCode = request.getSession().getAttribute(constantsConfigure.getGenerateCodeKey())+"";
//验证码只能使用一次
request.getSession().removeAttribute(constantsConfigure.getGenerateCodeKey());
if(loginDto.getGenerateCode().equals(generateCode)) {
String loginResult = userLoginService.login(loginDto.sysusername, loginDto.getSyspassword());
EntUser loginResult = userLoginService.login(loginDto.sysusername, loginDto.getSyspassword());
if (Objects.isNull(loginResult)) {
result.setCode(Code.PASSWORD_OR_ACCOUNT_ERROR.getCode());
result.setMessage(Message.PASSWORD_OR_ACCOUNT_ERROR);
@ -89,6 +100,10 @@ public class PersonalController extends BaseController{
return result;
}
/**
* 企业登录
* @param loginDto
@ -170,7 +185,7 @@ public class PersonalController extends BaseController{
@PreAuthorize("hasAnyAuthority('entUserTree','entUserTree:update')")
@MethodAnnotation(authorizations = {"entUserTree","entUserTree:update"},name = "企业用户组织树")
@ResponseBody
public SingleResult<List<EntUser>> entUserTree(@NotNull(message = "公司id不能为null") String enterpriseId, String postId)throws Exception{
public SingleResult<List<EntPost>> entUserTree(@RequestParam(required = true) String enterpriseId, String postId)throws Exception{
return pcBusinessService.entUserTree(enterpriseId,postId);
}
@ -182,12 +197,13 @@ public class PersonalController extends BaseController{
* @throws Exception
*/
@ApiOperation(value = "企业用户工作要务", notes = "企业用户工作要务")
@GetMapping(value = "/entUserPostList")
@PostMapping(value = "/entUserPostList")
@PreAuthorize("hasAnyAuthority('entUserPostList','entUserPostList:update')")
@MethodAnnotation(authorizations = {"entUserPostList","entUserPostList:update"},name = "企业用户工作要务")
@ResponseBody
public SingleResult entUserPostList(@RequestBody EntUserPostListDto entUserPostListDto)throws Exception{
return pcBusinessService.entUserPostList(entUserPostListDto);
public SingleResult<List<EntPostList>> entUserPostList(@RequestBody EntUserPostListDto entUserPostListDto)throws Exception{
singleResult.setData(pcBusinessService.entUserPostList(entUserPostListDto));
return singleResult;
}
@ -196,13 +212,14 @@ public class PersonalController extends BaseController{
* @return 企业用户工作清单
* @throws Exception
*/
@ApiOperation(value = "企业用户工作清单", notes = "企业用户工作清单")
@GetMapping(value = "/entUserPostTask")
@ApiOperation(value = "企业用户日常工作清单", notes = "企业用户日常工作清单")
@PostMapping(value = "/entUserPostTask")
@PreAuthorize("hasAnyAuthority('entUserPostTask','entUserPostTask:update')")
@MethodAnnotation(authorizations = {"entUserPostTask","entUserPostTask:update"},name = "企业用户工作清单")
@MethodAnnotation(authorizations = {"entUserPostTask","entUserPostTask:update"},name = "企业用户日常工作清单")
@ResponseBody
public SingleResult entUserPostTask(@RequestBody EntUserPostTaskDto entUserPostTaskDto)throws Exception{
return pcBusinessService.entUserPostTask(entUserPostTaskDto);
public SingleResult<List<EntPostTask>> entUserPostTask(@RequestBody EntUserPostTaskDto entUserPostTaskDto)throws Exception{
singleResult.setData(pcBusinessService.entUserPostTask(entUserPostTaskDto));
return singleResult;
}
@ -213,12 +230,13 @@ public class PersonalController extends BaseController{
* @throws Exception
*/
@ApiOperation(value = "企业用户岗位职责", notes = "企业用户岗位职责")
@GetMapping(value = "/entUserPostDuty")
@PostMapping(value = "/entUserPostDuty")
@PreAuthorize("hasAnyAuthority('entUserPostDuty','entUserPostDuty:update')")
@MethodAnnotation(authorizations = {"entUserPostDuty","entUserPostDuty:update"},name = "企业用户岗位职责")
@ResponseBody
public SingleResult entUserPostDuty(@RequestBody EntUserPostDutyDto entUserPostDutyDto)throws Exception{
return pcBusinessService.entUserPostDuty(entUserPostDutyDto);
public SingleResult<List<EntPostDuty>> entUserPostDuty(@RequestBody EntUserPostDutyDto entUserPostDutyDto)throws Exception{
singleResult.setData(pcBusinessService.entUserPostDuty(entUserPostDutyDto));
return singleResult;
}
/**
@ -237,7 +255,7 @@ public class PersonalController extends BaseController{
@PreAuthorize("hasAnyAuthority('entUserCredential','entUserCredential:update')")
@MethodAnnotation(authorizations = {"entUserCredential","entUserCredential:update"},name = "企业用户证照表")
@ResponseBody
public SingleResult entUserCredential(@NotNull(message = "企业用户id不能为null") String entUserId, @NotNull(message = "页码不能为null") Integer page, @NotNull(message = "条数不能为null")Integer pageSize)throws Exception{
public SingleResult<List<EntUserCredential>> entUserCredential(@RequestParam(required = true) String entUserId, @RequestParam(required = true) Integer page, @RequestParam(required = true)Integer pageSize)throws Exception{
return pcBusinessService.entUserCredential(null,entUserId,page,pageSize);
}
@ -256,9 +274,9 @@ public class PersonalController extends BaseController{
@MethodAnnotation(authorizations = {"entUserCredentialUpdate:update"},name = "企业用户证照表-新增,修改")
@ResponseBody
public SingleResult entUserCredentialUpdate(@RequestBody EntUserCredentialUpdateDto entUserCredentialUpdateDto)throws Exception{
List<EntUserCredentialUpdateDto>entUserCredentialUpdateDtos = new ArrayList<>();
entUserCredentialUpdateDtos.add(entUserCredentialUpdateDto);
return pcBusinessService.entUserCredentialUpdate(entUserCredentialUpdateDtos);
List<EntUserCredentialUpdateDto>entUserCredentialUpdateDtoList= new ArrayList<>();
entUserCredentialUpdateDtoList.add(entUserCredentialUpdateDto);
return pcBusinessService.entUserCredentialUpdate(entUserCredentialUpdateDtoList);
}
@ -276,31 +294,33 @@ public class PersonalController extends BaseController{
@PreAuthorize("hasAnyAuthority('entUserCredentialDelete')")
@MethodAnnotation(authorizations = {"entUserCredentialDelete"},name = "企业用户证照表-删除")
@ResponseBody
public SingleResult entUserCredentialDelete(@NotNull(message = "证件照id不能为null") String credentialId)throws Exception{
public SingleResult entUserCredentialDelete(@RequestParam(required = true) String credentialId)throws Exception{
return pcBusinessService.entUserCredentialDelete(credentialId);
}
/**
* 企业岗位总体信息列表
* 企业岗位人员总体信息列表
* @param keyContent
* @return list
* @throws Exception
*/
@ApiOperation(value = "企业岗位总体信息列表", notes = "企业岗位总体信息列表")
@ApiOperation(value = "企业岗位人员总体信息列表", notes = "企业岗位人员总体信息列表")
@ApiImplicitParams({
@ApiImplicitParam(name = "keyContent", value = "搜索关键字",required = true, dataType = "string"),
@ApiImplicitParam(name = "page", value = "page",required = true, dataType = "int"),
@ApiImplicitParam(name = "pageSize", value = "pageSize",required = true, dataType = "int"),
@ApiImplicitParam(name = "postId", value = "postId",required = false, dataType = "string"),
})
@GetMapping(value = "/entUserList")
@PreAuthorize("hasAnyAuthority('entUserList','entUserList:update')")
@MethodAnnotation(authorizations = {"entUserList","entUserList:update"},name = "企业岗位总体信息列表")
@MethodAnnotation(authorizations = {"entUserList","entUserList:update"},name = "企业岗位人员总体信息列表")
@ResponseBody
public SingleResult entUserList(@NotNull(message = "搜索关键字不能为null") String keyContent,
@NotNull(message = "页码不能为null") Integer page,
@NotNull(message = "条数不能为null") Integer pageSize)throws Exception{
return pcBusinessService.entUserList(keyContent,page,pageSize);
public SingleResult<List<EntUser>> entUserList(@RequestParam(required = true) String keyContent,
@RequestParam(required = false) String postId,
@RequestParam(required = true) Integer page,
@RequestParam(required = true) Integer pageSize)throws Exception{
return pcBusinessService.entUserList(keyContent,page,pageSize,postId);
}
@ -356,29 +376,28 @@ public class PersonalController extends BaseController{
}
/**
* 企业清单统计
* @param listId
* 企业清单(类型)分组查询
* @param enterpriseId
* @return list
* @throws Exception
*/
@ApiOperation(value = "企业清单统计", notes = "企业清单统计")
@ApiOperation(value = "企业清单(类型)分组查询", notes = "企业清单(类型)分组查询")
@ApiImplicitParams({
@ApiImplicitParam(name = "listId", value = "清单Id",required = true, dataType = "string"),
@ApiImplicitParam(name = "keyWord", value = "关键字",required = true, dataType = "string"),
@ApiImplicitParam(name = "page", value = "page",required = true, dataType = "int"),
@ApiImplicitParam(name = "pageSize", value = "pageSize",required = true, dataType = "int"),
@ApiImplicitParam(name = "enterpriseId", value = "企业id",required = true, dataType = "string"),
@ApiImplicitParam(name = "listId", value = "清单id",required = false, dataType = "string"),
@ApiImplicitParam(name = "userId", value = "用户id",required = true, dataType = "string"),
})
@GetMapping(value = "/inListStatistic")
@PreAuthorize("hasAnyAuthority('inListStatistic')")
@MethodAnnotation(authorizations = {"inListStatistic"},name = "企业清单统计")
@GetMapping(value = "/entListGroupByListId")
@PreAuthorize("hasAnyAuthority('entListGroupByListId')")
@MethodAnnotation(authorizations = {"entListGroupByListId"},name = "企业清单(类型)分组查询")
@ResponseBody
public SingleResult entUserList(String listId,
@NotNull(message = "企业Id") String enterpriseId,
String keyWord,
@NotNull(message = "页码不能为null") Integer page,
@NotNull(message = "条数不能为null") Integer pageSize)throws Exception{
return pcBusinessService.inListStatistic(enterpriseId,listId,keyWord,page,pageSize);
public SingleResult<List<EntPostList>> entListGroupByListId(@RequestParam(required = true) String enterpriseId,
String listId,
@RequestParam(required = true) String userId
)throws Exception{
return pcBusinessService.entListGroupByListId(enterpriseId,listId,userId);
}
@ -391,4 +410,5 @@ public class PersonalController extends BaseController{
}

View File

@ -2,6 +2,7 @@ package com.rzyc.filter;
import com.common.utils.jwt.JwtUtil;
import com.rzyc.advice.CustomException;
import com.rzyc.config.RedisUtil;
import com.rzyc.mapper.AuthorityKeyMapper;
import com.rzyc.model.AuthorityKey;
import lombok.extern.slf4j.Slf4j;
@ -31,11 +32,18 @@ import java.util.List;
* */
@Component
@Slf4j
public class JwtAuthenticationTokenFiler extends OncePerRequestFilter {
@Autowired
AuthorityKeyMapper authorityKeyMapper;
RedisUtil redisUtil;
@Autowired
public JwtAuthenticationTokenFiler(AuthorityKeyMapper authorityKeyMapper, RedisUtil redisUtil) {
this.authorityKeyMapper = authorityKeyMapper;
this.redisUtil = redisUtil;
}
@Override
protected void doFilterInternal(HttpServletRequest request, HttpServletResponse response, FilterChain filterChain) throws ServletException, IOException {
//获取token
@ -56,9 +64,11 @@ public class JwtAuthenticationTokenFiler extends OncePerRequestFilter {
throw new RuntimeException("token非法");
}
try {
List<AuthorityKey>authorizations = authorityKeyMapper.allAuthorizations();
//这里是要去拿角色权限的
List<AuthorityKey>authorizations = (List<AuthorityKey>) redisUtil.get("allKeys");
List<GrantedAuthority> authority= new ArrayList<GrantedAuthority>();
if (null != authorizations && authorizations.size() > 0 ){
StringBuilder stringBuilder = new StringBuilder();
for (AuthorityKey s:authorizations) {
stringBuilder.append(s.getAuthKey());
@ -66,13 +76,12 @@ public class JwtAuthenticationTokenFiler extends OncePerRequestFilter {
stringBuilder.setLength(0);
}
}
// 获取权限信息封装到Authentication中
UsernamePasswordAuthenticationToken authenticationToken =
new UsernamePasswordAuthenticationToken(null,null,authority);
SecurityContextHolder.getContext().setAuthentication(authenticationToken);
filterChain.doFilter(request, response);
}catch (AccessDeniedException e){
System.out.println("权限失败");

View File

@ -17,6 +17,7 @@ import com.rzyc.model.dto.*;
import com.rzyc.model.ent.EntPost;
import com.rzyc.model.ent.EntUser;
import com.rzyc.model.dto.SparePartDto;
import com.rzyc.model.ent.InEntList;
import com.rzyc.model.ent.SysEnterprise;
import org.springframework.beans.BeanUtils;
@ -68,15 +69,17 @@ public class PcBusinessService extends BaseController {
* sql里进行了order by如果传入postId就是查询非全部的数结构需要加入一个公司所以把第一个最大权限设置为company这样公司才会在树的最上面
* 相反不穿postId就是查询全部默认会有company打头就不用再修改list的0对象
*/
if (null != postId){
list.get(0).setParentId("company");
}
//加入公司为第一个树结构
EntPost entPost = new EntPost();
entPost.setName(sysEnterprise.getEntname());
entPost.setPostId("company");
list.add(entPost);
if (null != postId){
list.get(0).setParentId("company");
}
JSONArray jsonArray = handleEntUserTree(list);
List<EntPost>posts = JSONArray.parseArray(JSONArray.toJSONString(jsonArray),EntPost.class);
singleResult.setData(posts);
@ -113,35 +116,34 @@ public class PcBusinessService extends BaseController {
return result;
}
public List<EntPostList> entUserPostList(EntUserPostListDto entUserPostListDto) throws Exception {
entUserPostListDto.setPostId(getUserPostId());
public SingleResult entUserPostList(EntUserPostListDto entUserPostListDto){
SingleResult singleResult = new SingleResult();
entUserPostListDto.setPage(entUserPostListDto.getPageSize() * (entUserPostListDto.getPage() - 1));
List<EntPostList>list = entPostListMapper.selectEntPostList(entUserPostListDto.getEnterpriseId(),entUserPostListDto.getEntUserId(),
List<EntPostList>list = entPostListMapper.selectEntPostList(entUserPostListDto.getEnterpriseId(),entUserPostListDto.getEntUserId(),entUserPostListDto.getFinishedState(),
entUserPostListDto.getPostId(),entUserPostListDto.getPage(),entUserPostListDto.getPageSize());
singleResult.setData(list);
return singleResult;
return list;
}
public SingleResult entUserPostTask(EntUserPostTaskDto entUserPostTaskDto){
SingleResult singleResult = new SingleResult();
entUserPostTaskDto.setPage(entUserPostTaskDto.getPageSize() * (entUserPostTaskDto.getPage() - 1));
public List<EntPostTask> entUserPostTask(EntUserPostTaskDto entUserPostTaskDto) throws Exception {
entUserPostTaskDto.setPostId(getUserPostId());
//当listId为null时默认第一个日常清单查询所有正在进行中的任务
if (null == entUserPostTaskDto.getListId()){
//2为正在进行中
entUserPostTaskDto.setTaskState(1);
}
//EntPostTask
List<EntPostTask>list = entPostTaskMapper.selectEntUserPostTask(entUserPostTaskDto.getEnterpriseId(),entUserPostTaskDto.getEntUserId(),entUserPostTaskDto.getPostId()
,entUserPostTaskDto.getListId(),entUserPostTaskDto.getContent(),entUserPostTaskDto.getTaskState(),
entUserPostTaskDto.getPage(),entUserPostTaskDto.getPageSize());
singleResult.setData(list);
return singleResult;
,entUserPostTaskDto.getListId(),entUserPostTaskDto.getContent(),entUserPostTaskDto.getTaskState());
return list;
}
public SingleResult entUserPostDuty(EntUserPostDutyDto entUserPostDutyDto){
SingleResult singleResult = new SingleResult();
entUserPostDutyDto.setPage( entUserPostDutyDto.getPageSize() * (entUserPostDutyDto.getPage() - 1));
public List entUserPostDuty(EntUserPostDutyDto entUserPostDutyDto) throws Exception {
entUserPostDutyDto.setPostId(getUserPostId());
//EntPostDuty
List<EntPostDuty>list = entPostDutyMapper.selectEntUserPostDuty(entUserPostDutyDto.getEnterpriseId(),entUserPostDutyDto.getPostId(),entUserPostDutyDto.getPage(),entUserPostDutyDto.getPageSize());
singleResult.setData(list);
return singleResult;
List<EntPostDuty>list = entPostDutyMapper.selectEntUserPostDuty(entUserPostDutyDto.getEnterpriseId(),entUserPostDutyDto.getPostId());
return list;
}
@ -188,10 +190,10 @@ public class PcBusinessService extends BaseController {
}
public SingleResult entUserList(String keyContent,Integer page,Integer pageSize){
public SingleResult entUserList(String keyContent,Integer page,Integer pageSize,String postId){
SingleResult singleResult = new SingleResult();
page = pageSize * (page - 1);
List<EntUser>users = entUserMapper.selectEntUserList(keyContent,page,pageSize);
List<EntUser>users = entUserMapper.selectEntUserList(keyContent,page,pageSize,postId);
//计算履职百分比,后期这里使用redis来读取履职进度
for (EntUser e:users) {
Integer total = e.getFinishTask() + e.getOngoingTask() + e.getOverTimeTask();
@ -232,7 +234,10 @@ public class PcBusinessService extends BaseController {
singleResult.setMessage(Message.ERROR);
}
//插入证件图
if (null != addOrUpdateEntUserDto.getEntUserCredentialUpdateDtos() && addOrUpdateEntUserDto.getEntUserCredentialUpdateDtos().size() > 0 ){
singleResult = this.entUserCredentialUpdate(addOrUpdateEntUserDto.getEntUserCredentialUpdateDtos());
}
return singleResult;
}
@ -325,8 +330,9 @@ public class PcBusinessService extends BaseController {
entPost.setModifyTime(new Date());
result = entPostMapper.updateEntPost(entPost);
}else {
entPost.setCreateBy(getUserId());
entPost.setPostId(RandomNumber.getUUid());
entPost.setCreateTime(new Date());
entPost.setCreateBy(getUserId());
result = entPostMapper.insertEntPost(entPost);
}
if (result != 1 ){
@ -620,9 +626,9 @@ public class PcBusinessService extends BaseController {
public SingleResult inListStatistic(String enterpriseId,String listId,String keyWord,Integer page,Integer pageSize){
SingleResult singleResult = new SingleResult();
HashMap map = new HashMap();
Integer total = entPostListMapper.selectEntPostListCount(enterpriseId,listId);
Integer total = entPostListMapper.selectEntPostListCount(enterpriseId,listId,null);
//2代表已完成状态
Integer finishCount = entPostListMapper.selectEntPostListFinishedCount(enterpriseId,listId,2);
Integer finishCount = entPostListMapper.selectEntPostListFinishedCount(enterpriseId,listId,2,null);
double finishPercent = Arith.div(total,finishCount) * 100;
map.put("finishPercent",finishPercent);
List<EntPostTask>tasks = entPostTaskMapper.selectEntUserPostTaskByListId(enterpriseId,listId,keyWord,page,pageSize);
@ -631,6 +637,67 @@ public class PcBusinessService extends BaseController {
return singleResult;
}
public SingleResult inListTypes(String enterpriseId){
SingleResult singleResult = new SingleResult();
List<InEntList>list = inEntListMapper.selectByEnterpriseId(enterpriseId);
singleResult.setData(list);
return singleResult;
}
public SingleResult entPostProcessStatistic(String enterpriseId,String listId,Integer year){
SingleResult singleResult = new SingleResult();
Integer total = entPostListMapper.selectEntPostListCount(enterpriseId,listId,year);
//2代表已完成状态
Integer finishCount = entPostListMapper.selectEntPostListFinishedCount(enterpriseId,listId,2,year);
double finishPercent = Arith.div(finishCount,total) * 100;
singleResult.setData(finishPercent);
return singleResult;
}
public SingleResult entPostListPercentStatistic(String enterpriseId,String listId,Integer year){
SingleResult singleResult = new SingleResult();
HashMap map = new HashMap();
long total = entPostTaskMapper.selectEntPostTaskTotal(enterpriseId,listId,year);
//2代表已完成状态
EntPostTaskStatistic entPostTaskStatistic = entPostTaskMapper.selectEntPostTaskByState(enterpriseId,listId,year);
double finishPercent = Arith.div(entPostTaskStatistic.getFinished(),total) * 100;
map.put("finished",finishPercent);
double unfinishedPercent = Arith.div(entPostTaskStatistic.getOvertime(),total) * 100;
map.put("unfinished",unfinishedPercent);
double haveInHand = Arith.div(entPostTaskStatistic.getHaveInHand(),total) * 100;
map.put("haveInHand",haveInHand);
singleResult.setData(map);
return singleResult;
}
/**
* 获取用户岗位id
* 如果redis不存在就查询再存放到redis
* */
private String getUserPostId() throws Exception {
String userId = getUserId();
Object object = redisUtil.get("postId:userId"+userId);
if (null == object){
EntUser entUser = entUserMapper.selectById(userId);
redisUtil.set("postId:userId"+userId,entUser.getPostId());
return entUser.getPostId();
}else {
return (String)object;
}
}
public SingleResult entListGroupByListId(String enterpriseId,String listId,String userId){
SingleResult singleResult = new SingleResult();
List<EntPostList> list = entPostListMapper.selectEntListGroupByListId(enterpriseId,listId,userId);
singleResult.setData(list);
return singleResult;
}
}

View File

@ -1,6 +1,7 @@
package com.rzyc.service;
import com.rzyc.advice.CustomException;
import com.rzyc.config.RedisUtil;
import com.rzyc.config.UserDetailsAndId;
import com.rzyc.enums.SysEnterpriseState;
@ -74,17 +75,18 @@ public class UserDetailsServiceImpl implements UserDetailsService {
EntUser entUser = entUserMapper.selectByName(name);
if (Objects.isNull(entUser)){
throw new UsernameNotFoundException("用户名不存在");
throw new CustomException("用户名不存在");
}
List<GrantedAuthority> authority= new ArrayList<GrantedAuthority>();
List<AuthorityKey>authorizations = authorityKeyMapper.allAuthorizations();
redisUtil.set("allKeys",authorizations);
StringBuilder stringBuilder = new StringBuilder();
for (AuthorityKey s:authorizations) {
stringBuilder.append(s.getAuthKey());
authority.add(new SimpleGrantedAuthority(stringBuilder.toString()));
stringBuilder.setLength(0);
}
return new UserDetailsAndId(entUser.getName(), passwordEncoder.encode(entUser.getPasswd()), authority,entUser.getEntUserId());
return new UserDetailsAndId(entUser.getName(), passwordEncoder.encode(entUser.getPasswd()), authority,entUser.getEntUserId(),entUser.getPostId());
}
}

View File

@ -7,7 +7,10 @@ import com.common.utils.jwt.JwtUtil;
import com.rzyc.advice.CustomException;
import com.rzyc.config.UserDetailsAndId;
import com.rzyc.enums.SysEnterpriseState;
import com.rzyc.mapper.ent.EntPostMapper;
import com.rzyc.mapper.ent.SysEnterpriseMapper;
import com.rzyc.model.ent.EntPost;
import com.rzyc.model.ent.EntUser;
import com.rzyc.model.ent.SysEnterprise;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.authentication.BadCredentialsException;
@ -46,20 +49,26 @@ public class UserLoginService {
* */
private SysEnterpriseMapper sysEnterpriseMapper;
/**
* 企业端岗位
* */
private EntPostMapper entPostMapper;
@Autowired
public void UserLoginServiceFinder(UserDetailsService userDetailsService,PasswordEncoder passwordEncoder,SysEnterpriseMapper sysEnterpriseMapper){
public void UserLoginServiceFinder(UserDetailsService userDetailsService,PasswordEncoder passwordEncoder,SysEnterpriseMapper sysEnterpriseMapper,EntPostMapper entPostMapper){
this.userDetailsService = userDetailsService;
this.passwordEncoder = passwordEncoder;
this.sysEnterpriseMapper= sysEnterpriseMapper;
this.entPostMapper = entPostMapper;
}
public String login(String username, String password)throws Exception {
public EntUser login(String username, String password)throws Exception {
EntUser entUser = new EntUser();
String token = null;
try {
UserDetails userDetails = userDetailsService.loadUserByUsername(username);
if (Objects.isNull(userDetails)) {
throw new UsernameNotFoundException("账号不存在");
throw new CustomException("账号不存在");
}
SysEnterprise sysEnterprise = sysEnterpriseMapper.findEnterpriseByName(username);
if (Objects.isNull(sysEnterprise) || sysEnterprise.getState().equals(SysEnterpriseState.DISABLE)){
@ -67,7 +76,7 @@ public class UserLoginService {
}
//这里可能会不对因为我们是MD5这个是spring security 中的 encoder加密
if (!passwordEncoder.matches(MD5.md5(password), userDetails.getPassword())) {
throw new BadCredentialsException("密码不正确");
throw new CustomException("密码不正确");
}
//spring security context insert
UsernamePasswordAuthenticationToken authentication = new UsernamePasswordAuthenticationToken(userDetails, null, userDetails.getAuthorities());
@ -75,9 +84,14 @@ public class UserLoginService {
//企业用户id
String id = ((UserDetailsAndId)SecurityContextHolder.getContext().getAuthentication().getPrincipal()).getId();
token = JwtUtil.createToken(id);
} catch (AuthenticationException e) {
e.printStackTrace();
}
return token;
String postId = ((UserDetailsAndId)SecurityContextHolder.getContext().getAuthentication().getPrincipal()).getPostId();
EntPost entPost = entPostMapper.selectById(postId);
//封装返回数据
entUser.setName(userDetails.getUsername());
entUser.setEntUserId(id);
entUser.setEnterpriseId(sysEnterprise.getSysenterpriseid());
entUser.setToken(token);
entUser.setEntPostName(entPost.getName());
return entUser;
}
}

View File

@ -17,8 +17,8 @@ public class StringEncryptorTest {
@Test
public void test(){
String text = "你的盐";
String password = "你的密码";
String text = "rzyc2022";
String password = "123qqq...A";
StandardPBEStringEncryptor encryptor = new StandardPBEStringEncryptor();
//加密配置
EnvironmentStringPBEConfig config = new EnvironmentStringPBEConfig();