Commit 82d7adf9 authored by 竹天卫's avatar 竹天卫
parents 24137af2 1c704a11
......@@ -84,7 +84,7 @@ public class PlanTrainingController {
@PostMapping("/create")
public BaseResponse create(@RequestBody PlanTrainingQuery query) {
if (query.getRemind() == 0 && query.getRemindTime() != null) {
return BaseResponse.errorMsg("没有确认提醒");
return BaseResponse.errorMsg("没有确认");
}
if (query.getRemind() == 1 && query.getRemindTime() == null) {
return BaseResponse.errorMsg("请选择提醒时间");
......@@ -114,6 +114,17 @@ public class PlanTrainingController {
return BaseResponse.errorMsg("失败!");
}
@ApiOperation(value = "培训计划是否开始")
@PostMapping("/checkplanDate")
public BaseResponse checkplanDate(){
try{
return iplanTrainingService.checkplanDate();
}catch (Exception e){
log.debug("培训计划是否开始{}",e);
}
return BaseResponse.errorMsg("失败!");
}
// @ApiOperation(value = "考核结果")
// @PostMapping("/status")
// public BaseResponse status(Integer status, Integer id){
......@@ -138,9 +149,9 @@ public class PlanTrainingController {
@ApiOperation("培训计划导出")
@PostMapping("/exportList")
public void exportList(String filename, String objective, HttpServletResponse response) {
public void exportList(String filename,HttpServletResponse response) {
try {
iplanTrainingService.exportList(filename, objective, response);
iplanTrainingService.exportList(filename,response);
} catch (Exception e) {
log.debug("培训计划导出{}", e);
}
......
......@@ -78,4 +78,7 @@ public class PlanTraining implements Serializable {
@ApiModelProperty("用户id")
private String userIds;
@ApiModelProperty("实施情况")
private String implementation;
}
......@@ -7,6 +7,7 @@ import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import java.util.List;
import java.util.Map;
......@@ -21,4 +22,7 @@ import java.util.Map;
*/
public interface PlanPeopleMapper extends BaseMapper<PlanPeople> {
IPage<PlanPeopleVo> getPage(@Param("page") Page page, @Param("params") Map<String, Object> params);
@Select("select user_id from plan_people where plan_id=#{id}")
List<Integer> getPlanPeopleId(Integer id);
}
......@@ -46,13 +46,14 @@
<select id="exportList" resultType="java.util.HashMap">
SELECT
pt.id as 序号,
pt.plan_object as 培训对象,
pt.objective as 培训目的,
pt.content as 培训内容,
pt.mode as 培训方式,
pt.start_time as 培训时间,
pt.plan_object as 培训对象,
pt.mode as 培训方式,
pt.people as 培训人,
pt.assessment as 考核人
pt.assessment as 考核人,
pt.implementation as 实施情况
from plan_training pt
<include refid="where"/>
ORDER BY pt.id ASC
......
......@@ -59,6 +59,13 @@ public interface IPlanTrainingService extends IService<PlanTraining> {
*/
BaseResponse<PlanTraining> update(PlanTrainingQuery planTrainingQuery);
/**
* 检测培训计划是否开始
*
* @return String
*/
BaseResponse<String> checkplanDate();
/**
* 更改状态信息,达到改变显示的效果
* 1:未通过
......@@ -84,6 +91,6 @@ public interface IPlanTrainingService extends IService<PlanTraining> {
* @param filename 文件名
* @param response
*/
void exportList(String filename, String objective, HttpServletResponse response);
void exportList(String filename,HttpServletResponse response);
}
......@@ -6,12 +6,14 @@ import cn.wise.sc.cement.business.mapper.PlanPeopleMapper;
import cn.wise.sc.cement.business.mapper.SysGroupMapper;
import cn.wise.sc.cement.business.mapper.SysUserMapper;
import cn.wise.sc.cement.business.model.BaseResponse;
import cn.wise.sc.cement.business.model.LoginUser;
import cn.wise.sc.cement.business.model.PageQuery;
import cn.wise.sc.cement.business.model.query.PlanTrainingQuery;
import cn.wise.sc.cement.business.model.vo.PlanTrainingVo;
import cn.wise.sc.cement.business.model.vo.UserVo;
import cn.wise.sc.cement.business.service.IPlanTrainingService;
import cn.wise.sc.cement.business.service.IPlanPeopleService;
import cn.wise.sc.cement.business.service.ISysUserMessageService;
import cn.wise.sc.cement.business.service.ISysUserService;
import cn.wise.sc.cement.business.util.ExcelUtil;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
......@@ -19,13 +21,16 @@ import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.core.toolkit.CollectionUtils;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import javax.annotation.Resource;
import javax.servlet.http.HttpServletResponse;
import java.time.LocalDate;
import java.util.*;
/**
......@@ -59,6 +64,12 @@ public class PlanTrainingServiceImpl extends ServiceImpl<PlanTrainingMapper, Pla
@Resource
private PlanPeopleMapper plantPeopleMapper;
@Autowired
private ISysUserMessageService userMessageService;
@Autowired
private WeiXinService weiXinService;
@Override
public BaseResponse<IPage<PlanTrainingVo>> getPage(PageQuery pageQuery) {
Map<String, Object> params = new HashMap<>();
......@@ -87,6 +98,10 @@ public class PlanTrainingServiceImpl extends ServiceImpl<PlanTrainingMapper, Pla
@Override
@Transactional
public BaseResponse<PlanTraining> create(PlanTrainingQuery query) {
LoginUser loginUser = userService.getLoginUser();
if (loginUser == null){
return BaseResponse.errorMsg("请登录账号");
}
PlanTraining cama = new PlanTraining();
BeanUtils.copyProperties(query, cama);
cama.setPlanObject("");
......@@ -134,8 +149,9 @@ public class PlanTrainingServiceImpl extends ServiceImpl<PlanTrainingMapper, Pla
planPeople.setGroupId(user.getGroupId());
batchAdd.add(planPeople);
cama.setPlanObject(cama.getPlanObject() + user.getName() + "、");
// cama.setPlanObject(cama.getPlanObject() + user.getName() + "、");
}
cama.setPlanObject(cama.getPlanObject() + sysGroupMapper.selectById(groupId).getName() + "、");
}
}
iPlantPeopleService.saveBatch(batchAdd);
......@@ -143,6 +159,28 @@ public class PlanTrainingServiceImpl extends ServiceImpl<PlanTrainingMapper, Pla
cama.setPlanObject(substring);
iPlanTrainingService.updateById(cama);
}
List<Integer> planPeopleIdList = plantPeopleMapper.getPlanPeopleId(cama.getId());
if (planPeopleIdList == null){
return BaseResponse.errorMsg("培训计划信息错误");
}
String userIds="";
for (Integer planId : planPeopleIdList){
SysUser byId = userService.getById(planId);
if (byId == null){
return BaseResponse.errorMsg("培训计划信息错误");
}
BaseResponse wrapper = userMessageService.sendMessage(planId, "您有一条新的的培训信息", cama.getId(), SysUserMessage.MessageType.ENTRUST);
if (wrapper.getCode() != 200){
return wrapper;
}
if (StringUtils.isNotBlank(byId.getWxId())){
userIds = userIds.equals("")?byId.getWxId():userIds+"|"+byId.getWxId();
}
}
String content="您好!您有一项新的培训计划,请按时前往指定地点进行培训";
weiXinService.sendTextMessage(userIds,content);
return BaseResponse.okData(cama);
}
......@@ -200,8 +238,9 @@ public class PlanTrainingServiceImpl extends ServiceImpl<PlanTrainingMapper, Pla
planPeople.setGroupId(user.getGroupId());
batchAdd.add(planPeople);
update.setPlanObject(update.getPlanObject() + user.getName() + "、");
// update.setPlanObject(update.getPlanObject() + user.getName() + "、");
}
update.setPlanObject(update.getPlanObject() + sysGroupMapper.selectById(split1).getName() + "、");
}
}
iPlantPeopleService.saveBatch(batchAdd);
......@@ -213,6 +252,47 @@ public class PlanTrainingServiceImpl extends ServiceImpl<PlanTrainingMapper, Pla
return BaseResponse.okData(update);
}
/**
* 判断培训计划是否开始,如果开始,提醒培训人员 每天早上6点
* @return
*/
@Override
@Scheduled(cron = "0 0 6 * * *")
// @Scheduled(cron = "0 * * * * ?")
public BaseResponse<String> checkplanDate() {
QueryWrapper<PlanTraining> qw = new QueryWrapper<>();
qw.eq("remind",1);
List<PlanTraining> planTrainings = planTrainingMapper.selectList(qw);
if (planTrainings == null){
return BaseResponse.errorMsg("目前暂无需要提醒的培训计划");
}
String userIds="";
for (PlanTraining planTraining2 : planTrainings){
LocalDate remindTime = planTraining2.getRemindTime();
LocalDate nowDate = LocalDate.now();
if (remindTime != null && nowDate.equals(remindTime)){
List<Integer> planPeopleId = plantPeopleMapper.getPlanPeopleId(planTraining2.getId());
for (Integer checkId : planPeopleId){
SysUser byId = userService.getById(checkId);
if (byId == null ){
return BaseResponse.errorMsg("用户没有该培训计划,信息错误");
}
if (StringUtils.isNoneBlank(byId.getWxId())){
userIds=userIds.equals("")?byId.getWxId():userIds+"|"+byId.getWxId();
}
}
String content="您好!您有一项新的培训计划,记得按时前往"+planTraining2.getPlace()+"参加";
// System.out.println("**************************content**********************");
// System.out.println(content);
// System.out.println(userIds);
weiXinService.sendTextMessage(userIds,content);
}
}
return BaseResponse.okMsg("成功");
}
// @Override
// @Transactional
// public BaseResponse<String> status(Integer status, Integer id) {
......@@ -245,22 +325,23 @@ public class PlanTrainingServiceImpl extends ServiceImpl<PlanTrainingMapper, Pla
}
@Override
public void exportList(String filename, String objective, HttpServletResponse response) {
public void exportList(String filename,HttpServletResponse response) {
Map<String, Object> params = new HashMap<>();
params.put("objective", objective);
// params.put("objective", objective);
List<Map<String, Object>> list = planTrainingMapper.exportList(params);
if (!CollectionUtils.isEmpty(list)) {
Map<String, Object> map = list.get(0);
String[] headers = new String[map.size()];
String[] headers = new String[9];
headers[0] = "序号";
headers[1] = "培训目的";
headers[2] = "培训内容";
headers[3] = "培训方式";
headers[1] = "培训对象";
headers[2] = "培训目的";
headers[3] = "培训内容";
headers[4] = "培训时间";
headers[5] = "培训对象";
headers[5] = "培训方式";
headers[6] = "培训人";
headers[7] = "考核人";
headers[8] = "实施情况";
List<Object[]> datas = new ArrayList<>(list.size());
for (Map<String, Object> m : list) {
......@@ -270,7 +351,11 @@ public class PlanTrainingServiceImpl extends ServiceImpl<PlanTrainingMapper, Pla
if (j == 0 && obj != null) {
obj = obj.split("\\.")[0];
}
objects[j] = obj;
if (StringUtils.isEmpty(obj)){
objects[j]= "———";
}
}
datas.add(objects);
......
......@@ -7,8 +7,8 @@ spring:
active: dev
datasource:
# 192.168.110.85 admin!@#123
url: jdbc:mysql://192.168.110.85:3306/sinoma_tcdri?serverTimezone=Asia/Shanghai&useUnicode=true&characterEncoding=UTF-8&useSSL=false
# url: jdbc:mysql://81.68.92.175:3306/sinoma_tcdri?serverTimezone=Asia/Shanghai&useUnicode=true&characterEncoding=UTF-8&useSSL=false
# url: jdbc:mysql://192.168.110.85:3306/sinoma_tcdri?serverTimezone=Asia/Shanghai&useUnicode=true&characterEncoding=UTF-8&useSSL=false
url: jdbc:mysql://81.68.92.175:3306/sinoma_tcdri?serverTimezone=Asia/Shanghai&useUnicode=true&characterEncoding=UTF-8&useSSL=false
username: root
password: admin!@#123
driverClassName: com.mysql.cj.jdbc.Driver
......
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