兴安优化提交
This commit is contained in:
@@ -5,6 +5,7 @@ import cn.hutool.core.util.StrUtil;
|
||||
import com.alibaba.fastjson.JSON;
|
||||
import com.dcsoft.common.core.constant.CacheConstants;
|
||||
import com.dcsoft.common.core.constant.Constants;
|
||||
import com.dcsoft.common.core.enums.ExamineEnum;
|
||||
import com.dcsoft.common.core.exception.ServiceException;
|
||||
import com.dcsoft.common.core.utils.CollUtil;
|
||||
import com.dcsoft.common.core.utils.SmsUtils;
|
||||
@@ -17,10 +18,12 @@ import com.dcsoft.common.log.enums.BusinessType;
|
||||
import com.dcsoft.common.redis.service.RedisService;
|
||||
import com.dcsoft.common.security.annotation.RequiresPermissions;
|
||||
import com.dcsoft.common.sms.config.properties.SmsProperties;
|
||||
import com.dcsoft.system.api.domain.SysUser;
|
||||
import com.dcsoft.system.domain.SysPeople;
|
||||
import com.dcsoft.system.domain.vo.IdNamelVo;
|
||||
import com.dcsoft.system.service.ISysDictDataService;
|
||||
import com.dcsoft.system.service.ISysPeopleService;
|
||||
import com.dcsoft.system.service.impl.SysUserServiceImpl;
|
||||
import com.dcsoft.system.utils.UuidUtil;
|
||||
import com.dcsoft.system.visitor.domain.*;
|
||||
import com.dcsoft.system.visitor.service.IVisCarryStuffService;
|
||||
@@ -30,6 +33,7 @@ import lombok.extern.slf4j.Slf4j;
|
||||
import org.apache.commons.collections4.MapUtils;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
@@ -73,6 +77,12 @@ public class VisCarryStuffController extends BaseController {
|
||||
|
||||
private static final String APPROVE_KEY = "APPROVE_KEY:STUFF_APPROVE";
|
||||
|
||||
@Autowired
|
||||
private SysUserServiceImpl sysUserServiceImpl;
|
||||
|
||||
@Value("${sms.parkName:'兴安智慧园区'}")
|
||||
private String parkName;
|
||||
|
||||
|
||||
@GetMapping("/list")
|
||||
public TableDataInfo list(VisExitOutVo vo) {
|
||||
@@ -189,6 +199,30 @@ public class VisCarryStuffController extends BaseController {
|
||||
//新增物资信息
|
||||
visStuffInfoList.forEach(stuff -> stuff.setExitId(vo.getId()));
|
||||
visCarryStuffService.insertVisStuffInfo(visStuffInfoList);
|
||||
|
||||
//新增审核环节信息
|
||||
List<VisExitOutVo> list = new ArrayList<>();
|
||||
VisExitOutVo visExitOutVo = new VisExitOutVo();
|
||||
visExitOutVo.setId(vo.getId());
|
||||
visExitOutVo.setReviewer(vo.getReviewer1());
|
||||
visExitOutVo.setState(ExamineEnum.IN_REVIEW.getCode());
|
||||
list.add(visExitOutVo);
|
||||
|
||||
VisExitOutVo visExitOutVo2 = new VisExitOutVo();
|
||||
visExitOutVo2.setId(vo.getId());
|
||||
visExitOutVo2.setReviewer(vo.getReviewer2());
|
||||
visExitOutVo2.setState(ExamineEnum.IN_REVIEW.getCode());
|
||||
list.add(visExitOutVo2);
|
||||
|
||||
VisExitOutVo visExitOutVo3 = new VisExitOutVo();
|
||||
visExitOutVo3.setId(vo.getId());
|
||||
visExitOutVo3.setReviewer(vo.getReviewer3());
|
||||
visExitOutVo3.setState(ExamineEnum.IN_REVIEW.getCode());
|
||||
list.add(visExitOutVo3);
|
||||
//保存审核环节表
|
||||
visCarryStuffService.saveVisitorReviewProcessList(list);
|
||||
|
||||
|
||||
} catch (Exception e) {
|
||||
log.error("出门证申请add异常:", e);
|
||||
throw new ServiceException("系统异常,请重新提交或联系管理员!");
|
||||
@@ -262,9 +296,13 @@ public class VisCarryStuffController extends BaseController {
|
||||
VisExitOutVo stuffVo = visCarryStuffService.selectVisExitOutById(vo.getId());
|
||||
|
||||
//保存审核环节表
|
||||
vo.setReviewer(sysPeople.getId());
|
||||
vo.setState(vo.getExamineState());
|
||||
visCarryStuffService.saveVisitorReviewProcess(vo);
|
||||
VisitorReviewProcessVo reviewProcessVo = new VisitorReviewProcessVo();
|
||||
reviewProcessVo.setReviewer(String.valueOf(sysPeople.getId()));
|
||||
reviewProcessVo.setExitId(String.valueOf(vo.getId()));
|
||||
//查询审核环节表未审核状态的第一条数据,处理同一个人会审核两个环节情况
|
||||
VisitorReviewProcessVo reviewProcess = visCarryStuffService.selectVisitorReviewProcessOne(reviewProcessVo);
|
||||
reviewProcess.setState(vo.getExamineState());
|
||||
visCarryStuffService.updateVisitorReviewProcessById(reviewProcess);
|
||||
|
||||
//保存审核历史表
|
||||
VisVisitorExamine examine = new VisVisitorExamine();
|
||||
@@ -299,6 +337,10 @@ public class VisCarryStuffController extends BaseController {
|
||||
codeVo.setExitId(String.valueOf(vo.getId()));
|
||||
codeVo.setId(UUID.randomUUID().toString().replace("-", ""));
|
||||
visitorService.saveVisCheckCode(codeVo);
|
||||
|
||||
// 申请人发送短信(审核通过)
|
||||
SysUser sysUser = sysUserServiceImpl.selectUserById(stuffVo.getUserId());
|
||||
visitorController.sendMessage(sysUser.getPhonenumber(), "1", parkName, smsProperties.getTemplate2());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -325,9 +367,10 @@ public class VisCarryStuffController extends BaseController {
|
||||
log.error("访客approve-sendWeCom驳回异常", e);
|
||||
throw new ServiceException("系统异常,请重新审核或联系管理员!");
|
||||
}
|
||||
|
||||
// 申请人发送短信(审核不通过)
|
||||
SysPeople sysPeople1 = sysPeopleService.selectSysPeopleById(stuffVo.getUserId());
|
||||
visitorController.sendMessage(sysPeople1.getPhone(), "1", smsProperties.getTemplate3());
|
||||
SysUser sysUser = sysUserServiceImpl.selectUserById(stuffVo.getUserId());
|
||||
visitorController.sendMessage(sysUser.getPhonenumber(), "1", parkName, smsProperties.getTemplate3());
|
||||
}
|
||||
|
||||
visCarryStuffService.updateStaff(vo);
|
||||
|
||||
@@ -180,6 +180,9 @@ public class VisitorController extends BaseController {
|
||||
@Value("${weCom.agentid}")
|
||||
public String weComAgentid;
|
||||
|
||||
@Value("${sms.parkName:'兴安智慧园区'}")
|
||||
private String parkName;
|
||||
|
||||
// 正则表达式匹配大部分国家的手机号码格式
|
||||
private static final Pattern PHONE_NUMBER_PATTERN = Pattern.compile("^1[3-9]\\d{9}$");
|
||||
|
||||
@@ -1094,7 +1097,7 @@ public class VisitorController extends BaseController {
|
||||
}
|
||||
log.info("approve-发同意短信:{}", JSON.toJSONString(phoneList));
|
||||
for (String phone : phoneList) {
|
||||
sendMessage(phone, "1", smsProperties.getTemplate2());
|
||||
sendMessage(phone, "1", parkName, smsProperties.getTemplate2());
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1116,7 +1119,7 @@ public class VisitorController extends BaseController {
|
||||
// 申请人发送短信(审核不通过)
|
||||
|
||||
log.info("approve-发拒绝短信:{}", visitor.getPhone());
|
||||
sendMessage(visitor.getPhone(), "1", smsProperties.getTemplate3());
|
||||
sendMessage(visitor.getPhone(), "1", parkName, smsProperties.getTemplate3());
|
||||
}
|
||||
|
||||
visitorService.approve(visitor);
|
||||
@@ -1235,7 +1238,7 @@ public class VisitorController extends BaseController {
|
||||
visitor2.setReviewer3(visitor.getReviewer3());
|
||||
visitorService.updateVisitor(visitor2);
|
||||
if(Constants.ONE.equals(examine.getExamine())) {
|
||||
sendMessage(visitor.getPhone(), "1", smsProperties.getTemplate8());
|
||||
sendMessage(visitor.getPhone(), "1", null, smsProperties.getTemplate8());
|
||||
visitor.setState(examine.getExamine());
|
||||
visitorService.updateVisitorReviewProcess(visitor);
|
||||
|
||||
@@ -1306,7 +1309,7 @@ public class VisitorController extends BaseController {
|
||||
visitorService.updateVisitorReviewProcess(visitor2);
|
||||
// 审核通知企微发送消息(小程序来源)
|
||||
sendWeCom(officialAccountVo.getPhone(), visitor.getName() + "的访客审核被拒绝");
|
||||
sendMessage(visitor.getPhone(), "1", smsProperties.getTemplate8());
|
||||
sendMessage(visitor.getPhone(), "1", null, smsProperties.getTemplate8());
|
||||
Visitor visitor3 = new Visitor();
|
||||
if("1".equals(examine.getExamine())) {
|
||||
visitor3.setOutTime(new Date());
|
||||
@@ -1365,21 +1368,21 @@ public class VisitorController extends BaseController {
|
||||
// 申请人发送短信(审核通过)
|
||||
String appletLink = getAppletLink(String.valueOf(visitor.getId()), "pagesC/visExamineEwm/index");
|
||||
String[] split = appletLink.split("wxaurl.cn/");
|
||||
sendMessage(visitor.getPhone(), split[1], smsProperties.getTemplate5());
|
||||
sendMessage(visitor.getPhone(), split[1], null, smsProperties.getTemplate5());
|
||||
redisService.setCacheObject(CacheConstants.WEIXIN_URL_LINK + visitor.getPhone(), appletLink, 24L, TimeUnit.HOURS);
|
||||
|
||||
// 被访人发送短信(审核通过)
|
||||
sendMessage(officialAccountVo.getPhone(), visitor.getName() + "访问" + officialAccountVo.getName(), smsProperties.getTemplate9());
|
||||
sendMessage(officialAccountVo.getPhone(), visitor.getName() + "访问" + officialAccountVo.getName(), null, smsProperties.getTemplate9());
|
||||
}
|
||||
|
||||
if("1".equals(examine.getExamine())) {
|
||||
// 申请人发送短信(审核不通过)
|
||||
SysPeople people1 = sysPeopleService.selectSysPeopleById(visitor.getUserId());
|
||||
sendWeCom(people1.getPhone(), visitor.getName() + "的访客审核被拒绝");
|
||||
sendMessage(visitor.getPhone(), "1", smsProperties.getTemplate8());
|
||||
sendMessage(visitor.getPhone(), "1", null, smsProperties.getTemplate8());
|
||||
|
||||
// 被访人发送短信(审核不通过)
|
||||
sendMessage(officialAccountVo.getPhone(), visitor.getName() + "访问" + officialAccountVo.getName(), smsProperties.getTemplate10());
|
||||
sendMessage(officialAccountVo.getPhone(), visitor.getName() + "访问" + officialAccountVo.getName(), null, smsProperties.getTemplate10());
|
||||
}
|
||||
|
||||
visitor.setState(examine.getExamine());
|
||||
@@ -1562,7 +1565,7 @@ public class VisitorController extends BaseController {
|
||||
return toAjax(visVisitorExamineService.deleteVisVisitorExamineByVisitorId(id));
|
||||
}
|
||||
|
||||
public AjaxResult sendMessage(String phone, String code, String templateId) {
|
||||
public AjaxResult sendMessage(String phone, String code, String parkName, String templateId) {
|
||||
if (org.apache.commons.lang3.StringUtils.isEmpty(phone)) {
|
||||
return error("手机号不能为空!");
|
||||
}
|
||||
@@ -1571,13 +1574,17 @@ public class VisitorController extends BaseController {
|
||||
}
|
||||
Map<String, String> map = new HashMap<>(1);
|
||||
map.put("code", code);
|
||||
if (StringUtils.isNotBlank(parkName)) {
|
||||
map.put("park_name", parkName);
|
||||
}
|
||||
SmsTemplate smsTemplate = SpringUtils.getBean(SmsTemplate.class);
|
||||
log.info("访客短信发送{}模板:{}参数:{}", phone, templateId, JSON.toJSONString(map));
|
||||
SmsResult result = smsTemplate.send(phone, templateId, map);
|
||||
log.info("sendMessage-phone:{},result:{}", phone, result);
|
||||
log.info("短信发送{}结果:{}", phone, JSON.toJSONString(result));
|
||||
if (!result.getIsSuccess()) {
|
||||
return error(result.getMessage());
|
||||
}
|
||||
return AjaxResult.success();
|
||||
return AjaxResult.success("成功", result.getResponse());
|
||||
}
|
||||
|
||||
|
||||
@@ -1585,7 +1592,8 @@ public class VisitorController extends BaseController {
|
||||
public AjaxResult test(@RequestBody JSONObject js) throws Exception {
|
||||
String code = js.getString("code");
|
||||
String template = js.getString("template");
|
||||
return sendMessage("15155304840", code, template);
|
||||
String parkName = js.getString("parkName");
|
||||
return sendMessage("15155304840", code, parkName, template);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -22,6 +22,11 @@ public class VisExitOutVo extends BaseEntity {
|
||||
*/
|
||||
private Long userId;
|
||||
|
||||
/**
|
||||
* 事由
|
||||
*/
|
||||
private String reason;
|
||||
|
||||
/**
|
||||
* 当前审核人id
|
||||
*/
|
||||
|
||||
@@ -18,6 +18,11 @@ public class VisStuffInfoExportVo extends BaseEntity {
|
||||
*/
|
||||
private Long exitId;
|
||||
|
||||
/**
|
||||
* 事由
|
||||
*/
|
||||
private String reason;
|
||||
|
||||
|
||||
private List<Long> exitIds;
|
||||
|
||||
|
||||
@@ -1,14 +1,23 @@
|
||||
package com.dcsoft.system.visitor.domain;
|
||||
|
||||
import com.dcsoft.common.core.web.domain.BaseEntity;
|
||||
import lombok.Data;
|
||||
|
||||
@Data
|
||||
public class VisitorReviewProcessVo {
|
||||
|
||||
private String id;
|
||||
|
||||
/**
|
||||
* 审核人
|
||||
*/
|
||||
private String reviewer;
|
||||
|
||||
/**
|
||||
* 访客id
|
||||
*/
|
||||
private String visitorId;
|
||||
|
||||
/**
|
||||
* 审核状态 0 同意;1 不同意
|
||||
*/
|
||||
@@ -28,4 +37,14 @@ public class VisitorReviewProcessVo {
|
||||
* 审核时间
|
||||
*/
|
||||
private String createdTime;
|
||||
|
||||
/**
|
||||
* 出门申请表id
|
||||
*/
|
||||
private String exitId;
|
||||
|
||||
/**
|
||||
* 理由
|
||||
*/
|
||||
private String rejectReason;
|
||||
}
|
||||
|
||||
@@ -28,4 +28,10 @@ public interface VisCarryStuffMapper {
|
||||
List<VisStuffInfoVo> selectStuffList(VisStuffInfoVo visStuffInfoVo);
|
||||
|
||||
List<VisStuffInfoExportVo> selectVisitorList(VisExitOutVo vo);
|
||||
|
||||
void saveVisitorReviewProcessList(List<VisExitOutVo> list);
|
||||
|
||||
VisitorReviewProcessVo selectVisitorReviewProcessOne(VisitorReviewProcessVo reviewProcessVo);
|
||||
|
||||
void updateVisitorReviewProcessById(VisitorReviewProcessVo reviewProcess);
|
||||
}
|
||||
|
||||
@@ -27,4 +27,10 @@ public interface IVisCarryStuffService {
|
||||
List<VisStuffInfoVo> selectStuffList(VisStuffInfoVo vo);
|
||||
|
||||
List<VisStuffInfoExportVo> selectVisitorList(VisExitOutVo vo);
|
||||
|
||||
void saveVisitorReviewProcessList(List<VisExitOutVo> list);
|
||||
|
||||
VisitorReviewProcessVo selectVisitorReviewProcessOne(VisitorReviewProcessVo reviewProcessVo);
|
||||
|
||||
void updateVisitorReviewProcessById(VisitorReviewProcessVo reviewProcess);
|
||||
}
|
||||
|
||||
@@ -23,9 +23,6 @@ public class VisCarryStuffImpl implements IVisCarryStuffService {
|
||||
@Resource
|
||||
private VisCarryStuffMapper visCarryStuffMapper;
|
||||
|
||||
@Resource
|
||||
private VisitorMapper visitorMapper;
|
||||
|
||||
@Override
|
||||
public List<VisExitOutVo> selectList(VisExitOutVo vo) {
|
||||
return visCarryStuffMapper.selectList(vo);
|
||||
@@ -57,6 +54,21 @@ public class VisCarryStuffImpl implements IVisCarryStuffService {
|
||||
return visCarryStuffMapper.selectVisitorList(vo);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void saveVisitorReviewProcessList(List<VisExitOutVo> list) {
|
||||
visCarryStuffMapper.saveVisitorReviewProcessList(list);
|
||||
}
|
||||
|
||||
@Override
|
||||
public VisitorReviewProcessVo selectVisitorReviewProcessOne(VisitorReviewProcessVo reviewProcessVo) {
|
||||
return visCarryStuffMapper.selectVisitorReviewProcessOne(reviewProcessVo);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updateVisitorReviewProcessById(VisitorReviewProcessVo reviewProcess) {
|
||||
visCarryStuffMapper.updateVisitorReviewProcessById(reviewProcess);
|
||||
}
|
||||
|
||||
@Override
|
||||
public VisExitOutVo selectVisExitOutById(Long id) {
|
||||
return visCarryStuffMapper.selectVisExitOutById(id);
|
||||
|
||||
@@ -7,6 +7,7 @@
|
||||
<resultMap type="VisExitOutVo" id="VisitorResult">
|
||||
<result property="id" column="id"/>
|
||||
<result property="userId" column="user_id"/>
|
||||
<result property="reason" column="reason"/>
|
||||
<result property="name" column="name"/>
|
||||
<result property="phone" column="phone"/>
|
||||
<result property="exitPermitNo" column="exit_permit_no"/>
|
||||
@@ -57,6 +58,7 @@
|
||||
<result property="id" column="id"/>
|
||||
<result property="userId" column="user_id"/>
|
||||
<result property="userName" column="userName"/>
|
||||
<result property="reason" column="reason"/>
|
||||
<result property="phone" column="phone"/>
|
||||
<result property="exitPermitNo" column="exit_permit_no"/>
|
||||
<result property="visitingUnit" column="visiting_unit"/>
|
||||
@@ -89,6 +91,7 @@
|
||||
select distinct
|
||||
e.id,
|
||||
e.user_id,
|
||||
e.reason,
|
||||
e.name,
|
||||
e.phone,
|
||||
e.`exit_permit_no`,
|
||||
@@ -118,6 +121,7 @@
|
||||
<trim prefix="SET" suffixOverrides=",">
|
||||
<if test="userId != null">user_id = #{userId},</if>
|
||||
<if test="name != null and name != ''"> `name` = #{name},</if>
|
||||
<if test="reason != null and reason != ''"> `reason` = #{reason},</if>
|
||||
<if test="phone != null and phone != ''"> `phone` = #{phone},</if>
|
||||
<if test="exitPermitNo != null and exitPermitNo != ''"> `exit_permit_no` = #{exitPermitNo},</if>
|
||||
<if test="peopleId != null and peopleId != ''"> `people_id` = #{peopleId},</if>
|
||||
@@ -136,6 +140,15 @@
|
||||
where id = #{id}
|
||||
</update>
|
||||
|
||||
<update id="updateVisitorReviewProcessById">
|
||||
update vis_visitor_review_process
|
||||
set state = #{state}
|
||||
<if test="rejectReason != null and rejectReason != ''">
|
||||
,reject_reason = #{rejectReason}
|
||||
</if>
|
||||
where id = #{id}
|
||||
</update>
|
||||
|
||||
<select id="selectList" resultType="com.dcsoft.system.visitor.domain.VisExitOutVo">
|
||||
<include refid="selectVisExitOutVo"/>
|
||||
<where>
|
||||
@@ -148,6 +161,7 @@
|
||||
<if test="examineState != null and examineState != '' and examineState != 3">and e.examine_state = #{examineState}</if>
|
||||
<if test="isExistBack != null">and e.is_exist_back = #{isExistBack}</if>
|
||||
</where>
|
||||
order by create_time desc
|
||||
</select>
|
||||
|
||||
<select id="selectVisExitOutById" resultType="com.dcsoft.system.visitor.domain.VisExitOutVo">
|
||||
@@ -270,12 +284,30 @@
|
||||
</if>
|
||||
</where>
|
||||
</select>
|
||||
<select id="selectVisitorReviewProcessOne"
|
||||
resultType="com.dcsoft.system.visitor.domain.VisitorReviewProcessVo">
|
||||
select
|
||||
id,
|
||||
visitor_id visitorId,
|
||||
reviewer,
|
||||
state,
|
||||
type,
|
||||
created_time createdTime,
|
||||
exit_id exitId
|
||||
from vis_visitor_review_process
|
||||
where exit_id = #{exitId}
|
||||
and reviewer = #{reviewer}
|
||||
and state = '2'
|
||||
order by created_time asc
|
||||
limit 1
|
||||
</select>
|
||||
|
||||
<insert id="insertVisExitOut" useGeneratedKeys="true" keyProperty="id">
|
||||
insert into vis_exit_out
|
||||
<trim prefix="(" suffix=")" suffixOverrides=",">
|
||||
<if test="id != null and id != ''">id,</if>
|
||||
<if test="userId != null">user_id,</if>
|
||||
<if test="reason != null and reason != ''">reason,</if>
|
||||
<if test="name != null and name != ''">`name`,</if>
|
||||
<if test="phone != null and phone != ''">`phone`,</if>
|
||||
<if test="exitPermitNo != null and exitPermitNo != ''">`exit_permit_no`,</if>
|
||||
@@ -295,6 +327,7 @@
|
||||
<trim prefix="values (" suffix=")" suffixOverrides=",">
|
||||
<if test="id != null and id != ''">#{id},</if>
|
||||
<if test="userId != null">#{userId},</if>
|
||||
<if test="reason != null and reason != ''">#{reason},</if>
|
||||
<if test="name != null and name != ''">#{name},</if>
|
||||
<if test="phone != null and phone != ''">#{phone},</if>
|
||||
<if test="exitPermitNo != null and exitPermitNo != ''">#{exitPermitNo},</if>
|
||||
@@ -373,4 +406,12 @@
|
||||
</foreach>
|
||||
</insert>
|
||||
|
||||
<insert id="saveVisitorReviewProcessList">
|
||||
insert into vis_visitor_review_process (id, exit_id, reviewer, state)
|
||||
VALUES
|
||||
<foreach collection="list" item="i" index="index" separator=",">
|
||||
(REPLACE(uuid(), '-', ''), #{i.id}, #{i.reviewer}, #{i.state})
|
||||
</foreach>
|
||||
</insert>
|
||||
|
||||
</mapper>
|
||||
|
||||
Reference in New Issue
Block a user