Commit 8060cfe6 authored by mengbali153's avatar mengbali153

培训计划

parent 0366eb59
......@@ -2,16 +2,15 @@ package cn.wise.sc.cement.business.controller;
import cn.wise.sc.cement.business.model.BaseResponse;
import cn.wise.sc.cement.business.model.PageQuery;
import cn.wise.sc.cement.business.model.query.PlanPeopleQuery;
import cn.wise.sc.cement.business.model.query.SampleDistributionEnclosureQuery;
import cn.wise.sc.cement.business.service.IPlanPeopleService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.bind.annotation.*;
/**
* <p>
......@@ -62,4 +61,26 @@ public class PlanPeopleController {
}
return BaseResponse.errorMsg("失败!");
}
@ApiOperation(value = "培训计划上传附件")
@PostMapping("/uploadPlanPF")
public BaseResponse uploadPlanPF(PlanPeopleQuery query) {
try {
return iPlanPeopleService.uploadPlanPF(query);
} catch (Exception e) {
log.debug("培训计划上传附件{}", e);
}
return BaseResponse.errorMsg("失败!");
}
@ApiOperation(value = "同步历史档案")
@PostMapping("/synchronization/{id}")
public BaseResponse synchronization(@PathVariable Integer id){
try {
return iPlanPeopleService.synchronization(id);
}catch (Exception e){
log.debug("同步历史档案{}",e);
}
return BaseResponse.errorMsg("失败!");
}
}
......@@ -4,9 +4,7 @@ import cn.hutool.core.date.DateUtil;
import cn.hutool.core.util.StrUtil;
import cn.wise.sc.cement.business.model.BaseResponse;
import cn.wise.sc.cement.business.model.PageQuery;
import cn.wise.sc.cement.business.model.query.PlanTrainingFJ;
import cn.wise.sc.cement.business.model.query.PlanTrainingQuery;
import cn.wise.sc.cement.business.model.query.SampleDistributionEnclosureQuery;
import cn.wise.sc.cement.business.model.vo.PlanTrainingVo;
import cn.wise.sc.cement.business.service.IPlanTrainingService;
import io.swagger.annotations.Api;
......
......@@ -3,12 +3,14 @@ package cn.wise.sc.cement.business.entity;
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.experimental.Accessors;
import org.springframework.data.annotation.Id;
import java.io.Serializable;
import java.time.LocalDateTime;
@Data
@EqualsAndHashCode(callSuper = false)
......@@ -32,4 +34,16 @@ public class PlanPeople implements Serializable {
private String account;
@ApiModelProperty("附件地址")
private String enclosureUrl;
@ApiModelProperty("状态(0未上传,1成功,2上传失败)")
private Integer FlStatus;
@ApiModelProperty("文件名")
private String alias;
@ApiModelProperty("扩展名")
private String extName;
}
......@@ -11,9 +11,9 @@ import lombok.RequiredArgsConstructor;
* @create: 2020-10-19
**/
@Data
@RequiredArgsConstructor
@ApiModel("培训计划附件")
public class PlanTrainingFJ {
public class PlanPeopleQuery {
@ApiModelProperty("培训计划审批id")
private Integer id;
@ApiModelProperty("文件名")
......
......@@ -27,8 +27,8 @@ public class PlanTrainingQuery {
@ApiModelProperty("培训方式")
private String mode;
// @ApiModelProperty("培训对象")
// private String planObject;
@ApiModelProperty("培训对象")
private String planObject;
@ApiModelProperty("培训人")
private String people;
......
package cn.wise.sc.cement.business.model.vo;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import java.io.Serializable;
......@@ -20,4 +21,7 @@ public class PlanPeopleVo implements Serializable {
private String account;
private Integer status;
@ApiModelProperty("文件名")
private String alias;
}
......@@ -2,12 +2,16 @@ package cn.wise.sc.cement.business.service;
import cn.wise.sc.cement.business.entity.PlanPeople;
import cn.wise.sc.cement.business.entity.PlanTraining;
import cn.wise.sc.cement.business.entity.SampleDistribution;
import cn.wise.sc.cement.business.model.BaseResponse;
import cn.wise.sc.cement.business.model.PageQuery;
import cn.wise.sc.cement.business.model.query.PlanPeopleQuery;
import cn.wise.sc.cement.business.model.query.SampleDistributionEnclosureQuery;
import cn.wise.sc.cement.business.model.vo.PlanPeopleVo;
import cn.wise.sc.cement.business.model.vo.PlanTrainingVo;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.service.IService;
import org.springframework.transaction.annotation.Transactional;
import java.util.Date;
import java.util.List;
......@@ -35,4 +39,20 @@ public interface IPlanPeopleService extends IService<PlanPeople> {
* @return Boolean
*/
BaseResponse<String> status(Integer status, Integer id);
/**
* 培训计划上传附件
*
* @param query
* @return
*/
BaseResponse<PlanPeople> uploadPlanPF(PlanPeopleQuery query);
/**
* 同步历史档案
*
* @param id
* @return
*/
BaseResponse synchronization(Integer id);
}
package cn.wise.sc.cement.business.service;
import cn.wise.sc.cement.business.entity.NonStandardApply;
import cn.wise.sc.cement.business.entity.PlanTraining;
import cn.wise.sc.cement.business.model.BaseResponse;
import cn.wise.sc.cement.business.model.PageQuery;
import cn.wise.sc.cement.business.model.query.PlanTrainingFJ;
import cn.wise.sc.cement.business.model.query.PlanTrainingQuery;
import cn.wise.sc.cement.business.model.vo.PlanTrainingVo;
import com.baomidou.mybatisplus.core.metadata.IPage;
......@@ -86,10 +84,4 @@ public interface IPlanTrainingService extends IService<PlanTraining> {
*/
void exportList(String filename, String objective, HttpServletResponse response);
// /**
// * 上传附件
// *
// * @param query
// */
// BaseResponse<PlanTraining> uploadPlanTrainListPT(PlanTrainingFJ query);
}
......@@ -3,20 +3,31 @@ package cn.wise.sc.cement.business.service.impl;
import cn.wise.sc.cement.business.entity.HistoryArchives;
import cn.wise.sc.cement.business.entity.PlanPeople;
import cn.wise.sc.cement.business.entity.PlanTraining;
import cn.wise.sc.cement.business.entity.SampleDistribution;
import cn.wise.sc.cement.business.mapper.HistoryArchivesMapper;
import cn.wise.sc.cement.business.mapper.PlanPeopleMapper;
import cn.wise.sc.cement.business.mapper.PlanTrainingMapper;
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.PlanPeopleQuery;
import cn.wise.sc.cement.business.model.vo.HistoryArchivesVo;
import cn.wise.sc.cement.business.model.vo.PlanPeopleVo;
import cn.wise.sc.cement.business.model.vo.PlanTrainingVo;
import cn.wise.sc.cement.business.service.IHistoryArchivesService;
import cn.wise.sc.cement.business.service.IPlanPeopleService;
import cn.wise.sc.cement.business.service.ISysUserService;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
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.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import javax.annotation.Resource;
import java.time.LocalDateTime;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
......@@ -34,6 +45,19 @@ public class PlanPeopleServiceImpl extends ServiceImpl<PlanPeopleMapper, PlanPeo
@Resource
private PlanPeopleMapper planPeopleMapper;
@Resource
private PlanTrainingMapper planTrainingMapper;
@Resource
private HistoryArchivesMapper historyArchivesMapper;
@Autowired
private ISysUserService userService;
@Autowired
private IHistoryArchivesService iHistoryArchivesService;
@Override
public BaseResponse<IPage<PlanPeople>> getPage(PageQuery pageQuery) {
// Page<PlanPeopleVo> page = new Page<>(pageQuery.getPageNo(), pageQuery.getPageSize());
......@@ -69,4 +93,46 @@ public class PlanPeopleServiceImpl extends ServiceImpl<PlanPeopleMapper, PlanPeo
}
return BaseResponse.okData(result);
}
@Override
@Transactional
public BaseResponse<PlanPeople> uploadPlanPF(PlanPeopleQuery query) {
LoginUser loginUser = userService.getLoginUser();
if (loginUser == null) {
return BaseResponse.errorMsg("请登录账号");
}
if (query == null || query.getId() == null) {
return BaseResponse.errorMsg("参数错误");
}
PlanPeople planPeople = planPeopleMapper.selectById(query.getId());
if (planPeople == null) {
return BaseResponse.errorMsg("数据错误");
}
planPeople.setEnclosureUrl(query.getEnclosureUrl())
.setExtName(query.getExtName())
.setAlias(query.getAlias())
.setStatus(1);
if (StringUtils.isEmpty(query.getEnclosureUrl())) {
planPeople.setStatus(2);
}
planPeopleMapper.updateById(planPeople);
return BaseResponse.okData(planPeople);
}
@Override
public BaseResponse synchronization(Integer id) {
PlanPeople planPeople = planPeopleMapper.selectById(id);
Integer planId = planPeople.getPlanId();
PlanTraining planTraining = planTrainingMapper.selectById(planId);
HistoryArchives historyArchives=new HistoryArchives();
historyArchives.setCreateTime(LocalDateTime.now())
.setTime(planTraining.getStartTime())
.setType(planTraining.getContent())
.setContent(planTraining.getObjective())
.setUserId(planPeople.getUserId());
historyArchivesMapper.insert(historyArchives);
return BaseResponse.okData("同步成功");
}
}
......@@ -53,6 +53,9 @@ public class PlanTrainingServiceImpl extends ServiceImpl<PlanTrainingMapper, Pla
@Autowired
private IPlanPeopleService iPlantPeopleService;
@Autowired
private IPlanTrainingService iPlanTrainingService;
@Resource
private PlanPeopleMapper plantPeopleMapper;
......@@ -86,6 +89,7 @@ public class PlanTrainingServiceImpl extends ServiceImpl<PlanTrainingMapper, Pla
public BaseResponse<PlanTraining> create(PlanTrainingQuery query) {
PlanTraining cama = new PlanTraining();
BeanUtils.copyProperties(query, cama);
cama.setPlanObject("");
boolean save = this.save(cama);
if (save){
Integer planId = cama.getId();
......@@ -106,8 +110,10 @@ public class PlanTrainingServiceImpl extends ServiceImpl<PlanTrainingMapper, Pla
planPeople.setGroupId(user.getGroupId());
batchAdd.add(planPeople);
cama.setPlanObject(cama.getPlanObject()+user.getName()+"、");
}
//传的GroupIds
String groupIds = query.getGroupIds();
String[] split1 = groupIds.split("、");
......@@ -129,6 +135,9 @@ public class PlanTrainingServiceImpl extends ServiceImpl<PlanTrainingMapper, Pla
}
}
iPlantPeopleService.saveBatch(batchAdd);
String substring = cama.getPlanObject().substring(0, cama.getPlanObject().length() - 1);
cama.setPlanObject(substring);
iPlanTrainingService.updateById(cama);
}
return BaseResponse.okData(cama);
}
......@@ -138,7 +147,61 @@ public class PlanTrainingServiceImpl extends ServiceImpl<PlanTrainingMapper, Pla
PlanTraining update = new PlanTraining();
BeanUtils.copyProperties(planTrainingQuery, update);
update.setId(planTrainingQuery.getId());
planTrainingMapper.updateById(update);
QueryWrapper<PlanPeople> qw = new QueryWrapper<>();
qw.eq("plan_id",update.getId());
update.setPlanObject("");
boolean remove = iPlantPeopleService.remove(qw);
if (remove){
Integer planId = update.getId();
//todo 培训关联表对象 ==>plant + 基本用户信息
//拆分用户id
String userIds = planTrainingQuery.getUserIds();
String[] split = userIds.split("、");
List<PlanPeople> batchAdd = new ArrayList<>();
//为每个用户id创建关联表信息s
for (String userId:split) {
Integer id = Integer.parseInt(userId);
UserVo user = sysUserMapper.getById(id);
PlanPeople planPeople = new PlanPeople();
planPeople.setPlanId(planId);
planPeople.setUserId(user.getId());
planPeople.setName(user.getName());
planPeople.setAccount(user.getUsername());
planPeople.setGroupId(user.getGroupId());
batchAdd.add(planPeople);
update.setPlanObject(update.getPlanObject()+user.getName()+"、");
}
//传的GroupIds
String groupIds = planTrainingQuery.getGroupIds();
String[] split1 = groupIds.split("、");
List<PlanPeople> batchAdd1=new ArrayList<>();
for (String groupId:split1){
int gpId=Integer.parseInt(groupId);
QueryWrapper<SysUser> qw1=new QueryWrapper<>();
qw1.eq("group_id",gpId);
List<SysUser> sysUsers=sysUserMapper.selectList(qw1);
for (SysUser user : sysUsers){
PlanPeople planPeople = new PlanPeople();
planPeople.setPlanId(planId);
planPeople.setUserId(user.getId());
planPeople.setName(user.getName());
planPeople.setAccount(user.getUsername());
planPeople.setGroupId(user.getGroupId());
batchAdd.add(planPeople);
}
}
iPlantPeopleService.saveBatch(batchAdd);
String substring = update.getPlanObject().substring(0, update.getPlanObject().length() - 1);
update.setPlanObject(substring);
iPlanTrainingService.updateById(update);
}
return BaseResponse.okData(update);
}
......
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