提交 88bba9df authored 作者: 133's avatar 133

[用户] [清退] [专管员统计] 代码提交

上级 25e4880c
......@@ -4,6 +4,7 @@ import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import com.alibaba.fastjson.TypeReference;
import com.github.wenhao.jpa.Specifications;
import com.sun.tools.internal.xjc.reader.xmlschema.bindinfo.BIConversion;
import com.tykj.dev.device.library.repository.DeviceLibraryDao;
import com.tykj.dev.device.library.service.DeviceLibraryService;
import com.tykj.dev.device.library.service.DeviceLogService;
......@@ -19,6 +20,8 @@ import com.tykj.dev.device.task.repository.TaskDao;
import com.tykj.dev.device.task.service.TaskService;
import com.tykj.dev.device.task.subject.bto.TaskBto;
import com.tykj.dev.device.task.subject.domin.Task;
import com.tykj.dev.device.user.read.service.MessageService;
import com.tykj.dev.device.user.read.subject.bto.MessageBto;
import com.tykj.dev.device.user.subject.dao.AreaDao;
import com.tykj.dev.device.user.subject.dao.UnitsDao;
import com.tykj.dev.device.user.subject.dao.UserDao;
......@@ -77,6 +80,8 @@ public class SendBackServiceImpl implements SendBackService {
@Autowired
Snowflake snowflake;
@Autowired
MessageService messageService;
/**
* 添加设备
* @param deviceIdList 待清退装备的id集合
......@@ -123,6 +128,7 @@ public class SendBackServiceImpl implements SendBackService {
boolean flag=false;
User user= userDao.findById(startUserId).get();
Units units= unitsDao.findById(user.getUnitsId()).get();
for (DeviceLibrary deviceLibrary:deviceLibraryDao.getDeviceLibraryEntitiesByIdIn(deviceIdList)){
if (!deviceLibrary.getLocationUnit().equals(units.getName())){
flag=true;
......@@ -141,7 +147,9 @@ public class SendBackServiceImpl implements SendBackService {
添加各单位的Task
*/
addTaskById(deviceIdList,taskBto.getId(),startUserId,sendBackVo.getTime(),sendBackVo.getName());
List<Integer> ids= userDao.findAllByUnitsId(units.getUnitId()).stream().map(User::getUserId).collect(Collectors.toList());
ids.remove(startUserId);
messageService.add(new MessageBto(taskBto.getId(),BusinessEnum.SEND_BACK.id,user.getName()+"发起清退任务",ids));
return ResponseEntity.ok(taskBto.getId());
}
......@@ -472,7 +480,8 @@ public class SendBackServiceImpl implements SendBackService {
保存出库清单
*/
TaskBto taskEntity = taskService.get(taskId);
Units unit = unitsDao.findById(taskEntity.getOwnUnit()).get();
User user =userDao.findById(userId).get();
Units unit = unitsDao.findById(user.getUnitsId()).get();
Area area = areaDao.findById(unit.getAreaId()).get();
......@@ -481,7 +490,7 @@ public class SendBackServiceImpl implements SendBackService {
SendBackBill bill = sendBackBillEntityDao.findById(taskEntity.getBillId()).get();
bill.setSendBackOut(JSON.toJSONString(sendBackOut));
taskService.moveToSpecial(taskEntity,StatusEnum.SEND_BACK_1202,sendBackOut.getReviewerNameId());
// taskService.moveToSpecial(taskEntity,StatusEnum.SEND_BACK_1202,sendBackOut.getReviewerNameId());
/*
......@@ -515,7 +524,20 @@ public class SendBackServiceImpl implements SendBackService {
bill.setFormId(backBillDetailEntity.getId());
sendBackBillEntityDao.save(bill);
return ResponseEntity.ok("装备出库发起成功等待审核");
Units father=fatherUnit.get(0);
taskEntity.setOwnUnit(father.getUnitId());
SendBackBill sendBackBill= sendBackBillEntityDao.findById(taskEntity.getBillId()).get();
List<Integer> idList=stringToList(sendBackBill.getInvoleDevice());
deviceLibraryDao.getDeviceLibraryEntitiesByIdIn(idList).forEach(
deviceLibrary -> {
DeviceLogDto deviceLogDto = new DeviceLogDto(deviceLibrary.getId(),"清退装备出库等待"+father.getName()+"签收",null);
deviceLogService.addLog(deviceLogDto);
}
);
TaskBto taskBto= taskService.moveToSpecial(taskEntity,StatusEnum.SEND_BACK_1206,0);
return ResponseEntity.ok(taskBto);
}
/**
......@@ -528,24 +550,24 @@ public class SendBackServiceImpl implements SendBackService {
@Transactional
@Override
public ResponseEntity sendBackOutExamine(Integer taskId,Integer userId,Integer type) {
TaskBto taskEntity = taskService.get(taskId);
Units unit = unitsDao.findById(taskEntity.getOwnUnit()).get();
Area area = areaDao.findById(unit.getAreaId()).get();
List<Units> fatherUnit = unitsDao.findByAreaId(area.getFatherId());
Units father=fatherUnit.get(0);
taskEntity.setOwnUnit(father.getUnitId());
SendBackBill sendBackBill= sendBackBillEntityDao.findById(taskEntity.getBillId()).get();
List<Integer> idList=stringToList(sendBackBill.getInvoleDevice());
deviceLibraryDao.getDeviceLibraryEntitiesByIdIn(idList).forEach(
deviceLibrary -> {
DeviceLogDto deviceLogDto = new DeviceLogDto(deviceLibrary.getId(),"清退装备出库等待"+father.getName()+"签收",null);
deviceLogService.addLog(deviceLogDto);
}
);
taskService.moveToSpecial(taskEntity,StatusEnum.SEND_BACK_1206,0);
// TaskBto taskEntity = taskService.get(taskId);
//
// Units unit = unitsDao.findById(taskEntity.getOwnUnit()).get();
//
// Area area = areaDao.findById(unit.getAreaId()).get();
//
// List<Units> fatherUnit = unitsDao.findByAreaId(area.getFatherId());
// Units father=fatherUnit.get(0);
// taskEntity.setOwnUnit(father.getUnitId());
// SendBackBill sendBackBill= sendBackBillEntityDao.findById(taskEntity.getBillId()).get();
// List<Integer> idList=stringToList(sendBackBill.getInvoleDevice());
// deviceLibraryDao.getDeviceLibraryEntitiesByIdIn(idList).forEach(
// deviceLibrary -> {
// DeviceLogDto deviceLogDto = new DeviceLogDto(deviceLibrary.getId(),"清退装备出库等待"+father.getName()+"签收",null);
// deviceLogService.addLog(deviceLogDto);
// }
// );
// taskService.moveToSpecial(taskEntity,StatusEnum.SEND_BACK_1206,0);
return ResponseEntity.ok("装配入库申请发送成功");
}
......@@ -797,10 +819,37 @@ public class SendBackServiceImpl implements SendBackService {
form.setReceiveUserBId(sendBackOut.getReviewerNameId());
form.setReceiveUserBName(sendBackOut.getReviewerName());
sendBackBillDetailEntityDao.save(form);
Units unit = unitsDao.findById(taskEntity.getOwnUnit()).get();
/*
已完结
*/
taskService.moveToEnd(taskEntity);
/*
修改装备是所属单位
*/
bill.setIsComplete(1);
sendBackBillEntityDao.save(bill);
List<Integer> idList = stringToList(bill.getInvoleDevice());
List<DeviceLibrary> deviceList = deviceLibraryDao.getDeviceLibraryEntitiesByIdIn(idList);
for (DeviceLibrary d:deviceList) {
DeviceLogDto deviceLogDto = new DeviceLogDto(d.getId(),"清退装备签收入库完成",null);
deviceLogService.addLog(deviceLogDto);
d.setLocationUnit(unit.getName());
d.setOwnUnit(unit.getName());
d.setManageStatus(1);
}
deviceLibraryDao.saveAll(deviceList);
s(taskEntity,bill,idList);
/*
task 推入 19
*/
taskService.moveToSpecial(taskEntity,StatusEnum.SEND_BACK_1204,sendBackOut.getReviewerNameId());
// taskService.moveToSpecial(taskEntity,StatusEnum.SEND_BACK_1204,sendBackOut.getReviewerNameId());
// JobEntity job = jobDao.findByTaskIdAndIsDone(taskEntity.getId(), 0);
// job.setIsDone(1);
// addJob(taskEntity.getId(),taskEntity.getBillStatus(),userId,job,sendBackOut.getReviewerNameId(),0);
......@@ -1584,7 +1633,7 @@ public class SendBackServiceImpl implements SendBackService {
/*
市级的业务详情
*/
kidTask = taskDao.findTaskEntitiesByParentTaskId(taskBto.getParentTaskId()).stream().map(Task::parse2Bto).collect(Collectors.toList());
kidTask = taskDao.findTaskEntitiesByParentTaskId(taskBto.getId()).stream().map(Task::parse2Bto).collect(Collectors.toList());
}
/*
区域名和任务id的映射,方便进入下一级
......
......@@ -23,7 +23,6 @@ import java.util.concurrent.ConcurrentHashMap;
@ServerEndpoint(value = "/websocket/{userId}") //接受websocket请求路径
@Component //注册到spring容器中
public class MyWebSocket {
private static int onlineCount = 0;
/**
* concurrent包的线程安全Set,用来存放每个客户端对应的MyWebSocket对象。
*/
......@@ -49,17 +48,7 @@ public class MyWebSocket {
}
}
public static synchronized int getOnlineCount() {
return onlineCount;
}
public static synchronized void addOnlineCount() {
MyWebSocket.onlineCount++;
}
public static synchronized void subOnlineCount() {
MyWebSocket.onlineCount--;
}
/**
* 连接建立成功调用的方法
......@@ -75,11 +64,10 @@ public class MyWebSocket {
} else {
webSocketMap.put(userId, this);
//加入set中
addOnlineCount();
//在线数加1
}
log.info("用户连接:" + userId + ",当前在线人数为:" + getOnlineCount());
log.info("用户连接:" + userId + ",当前在线人数为:" + webSocketMap.size());
sendMessage("连接成功");
}
......@@ -89,12 +77,16 @@ public class MyWebSocket {
*/
@OnClose
public void onClose() {
if (webSocketMap.containsKey(userId)) {
webSocketMap.remove(userId);
//从set中删除
subOnlineCount();
webSocketMap.remove(userId);
log.info("用户退出:" + userId + ",当前在线人数为:" + webSocketMap.size());
}
log.info("用户退出:" + userId + ",当前在线人数为:" + getOnlineCount());
public void Close(String userId) {
//从set中删除
webSocketMap.remove(userId);
log.info("用户退出:" + userId + ",当前在线人数为:" + webSocketMap.size());
}
/**
......
package com.tykj.dev.device.train.dao;
import com.tykj.dev.device.train.entity.TrainTheme;
import com.tykj.dev.device.train.entity.TrainUser;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import java.util.List;
/**
* @author zjm
* @version 1.0.0
* @ClassName TrainUserDao.java
* @Description TODO
* @createTime 2020年12月01日 13:55:00
*/
public interface TrainUserDao extends JpaRepository<TrainUser, Integer>, JpaSpecificationExecutor<TrainUser> {
TrainUser findByUserIdAndTrainId(Integer userId,Integer trainId);
List<TrainUser> findAllByIsSignUpAndTrainId(Integer IsSignUp,Integer trainId);
}
......@@ -117,23 +117,23 @@ public class TrainTheme {
@ApiModelProperty(value = "trainSynopsis")
private String trainSynopsis;
/**
* 参会人员(必须参会)
*/
@ApiModelProperty(value = "参会人员id 多个使用人员id+x+id+x")
private String joinUserId;
/**
* 不必须参会人员
*/
@ApiModelProperty(value = "参会人员id 多个使用人员id+x+id+x")
private String noJoinUserId;
/**
* 报名人员
*/
@ApiModelProperty(value = "参会人员id 多个使用人员id+x+id+x")
private String signUp;
// /**
// * 参会人员(必须参会)
// */
// @ApiModelProperty(value = "参会人员id 多个使用人员id+x+id+x")
// private String joinUserId;
//
// /**
// * 不必须参会人员
// */
// @ApiModelProperty(value = "参会人员id 多个使用人员id+x+id+x")
// private String noJoinUserId;
//
// /**
// * 报名人员
// */
// @ApiModelProperty(value = "参会人员id 多个使用人员id+x+id+x")
// private String signUp;
/**
* 培训结果
......
package com.tykj.dev.device.user.base.ret;
package com.tykj.dev.device.train.entity;
import com.tykj.dev.device.user.subject.entity.Mgrcert;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import javax.persistence.*;
/**
* @author zjm
* @version 1.0.0
......@@ -16,15 +19,27 @@ import lombok.NoArgsConstructor;
@AllArgsConstructor
@NoArgsConstructor
@Data
@ApiModel(value = "培训选人列表实体")
public class UserTrainVo {
@Entity
@ApiModel(value = "培训人员信息")
public class TrainUser {
/**
* 用户
* 数据id
*/
@Id
@ApiModelProperty(value = "数据ID", name = "id", example = "12321L")
@GeneratedValue(strategy = GenerationType.IDENTITY)
private Integer id;
/**
* 培训id
*/
@ApiModelProperty(value = "培训id", name = "userId", example = "12321L")
private Integer trainId;
/**
* 用户
*/
@ApiModelProperty(value = "用户数据ID", name = "userId", example = "12321L")
// @GeneratedValue(generator="UserIdentityGenerator",strategy = GenerationType.AUTO)
// @GenericGenerator(name = "UserIdentityGenerator", strategy = "UserIdentityGenerator")
private Integer userId;
/**
......@@ -72,13 +87,48 @@ public class UserTrainVo {
private Integer unitsId;
/**
* 培训状态 0.已培训 1.已过期 2.未培训 3.快过期
* 考勤
*/
@ApiModelProperty(value = "考勤", name = "attendance")
private String attendance;
/**
* 分数
*/
@ApiModelProperty(value = "分数", name = "score")
private String score;
/**
* 评价
*/
@ApiModelProperty(value = "评价", name = "evaluation")
private String evaluation;
/**
* 是否报名 1.报名 2.不报名
*/
@ApiModelProperty(value = "是否报名 1.报名 2.不报名", name = "certificate")
private Integer isSignUp;
/**
* 不报名的备注
*/
private Integer trainStatus;
@ApiModelProperty(value = "不报名的备足", name = "certificate")
private String note;
/**
* 是否发证
*/
@ApiModelProperty(value = "是否发证", name = "certificate")
private Integer certificate;
/**
* 0 是 1 否
* 是否必须报名 1.必须 2.不必须
*/
private Integer isMustJoin;
@ApiModelProperty(value = "是否必须报名 1.必须 2.不必须", name = "certificate")
private Integer isNotJoinUserId;
@Transient
private Mgrcert mgrcert;
}
package com.tykj.dev.device.train.entity.vo;
import com.fasterxml.jackson.annotation.JsonFormat;
import com.tykj.dev.device.train.entity.TrainUser;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.AllArgsConstructor;
......@@ -131,6 +132,6 @@ public class TrainAuditVo {
* 成绩
*/
@ApiModelProperty(value = "gradeEntry")
private List<GradeEntry> gradeEntry;
private List<TrainUser> TrainUser;
}
package com.tykj.dev.device.train.entity.vo;
import com.fasterxml.jackson.annotation.JsonFormat;
import com.tykj.dev.device.train.entity.TrainUser;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.AllArgsConstructor;
......@@ -130,7 +131,7 @@ public class TrainDetailsVo {
/**
* 成绩
*/
@ApiModelProperty(value = "gradeEntry")
private List<GradeEntry> gradeEntry;
@ApiModelProperty(value = "trainUsers")
private List<TrainUser> trainUsers;
}
package com.tykj.dev.device.train.entity.vo;
import com.fasterxml.jackson.annotation.JsonFormat;
import com.tykj.dev.device.user.base.ret.UserTrainVo;
import com.tykj.dev.device.train.entity.TrainUser;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.AllArgsConstructor;
......@@ -118,11 +118,11 @@ public class TrainRegistrationVo {
* 以报名人员
*/
@ApiModelProperty(value = "trainSynopsis")
private List<UserTrainVo> signUpUser;
private List<TrainUser> signUpUser;
/**
* 没报名人员
*/
@ApiModelProperty(value = "trainSynopsis")
private List<UserTrainVo> noSignUpUser;
private List<TrainUser> noSignUpUser;
}
......@@ -102,17 +102,24 @@ public class TrainThemeAddVo {
@ApiModelProperty(value = "trainSynopsis")
private String trainSynopsis;
/**
* 必须参加
*/
@ApiModelProperty(value = "参会人员id 集合")
private List<Integer> joinUserIds=new ArrayList<>();
// /**
// * 必须参加
// */
// @ApiModelProperty(value = "参会人员id 集合")
// private List<Integer> joinUserIds=new ArrayList<>();
//
// /**
// * 不必须参会人员
// */
// @ApiModelProperty(value = "参会人员id 集合")
// private List<Integer> noJoinUserIds=new ArrayList<>();
/**
* 不必须参会人员
* 需要参加的单位
*/
@ApiModelProperty(value = "参会人员id 集合")
private List<Integer> noJoinUserIds=new ArrayList<>();
@ApiModelProperty(value = "参会人员id 集合",name = "unitsIds")
private List<Integer> unitsIds;
/**
* 培训状态 1报名中 2待培训 3培训中
......
package com.tykj.dev.device.train.entity.vo;
import com.fasterxml.jackson.annotation.JsonFormat;
import com.tykj.dev.device.user.base.ret.UserTrainVo;
import com.tykj.dev.device.train.entity.TrainUser;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.AllArgsConstructor;
......@@ -118,7 +118,7 @@ public class TrainTrainingVo {
/**
* 以报名人员
*/
@ApiModelProperty(value = "trainSynopsis")
private List<UserTrainVo> signUpUser;
@ApiModelProperty(value = "trainUsers")
private List<TrainUser> trainUsers;
}
......@@ -5,6 +5,7 @@ import io.swagger.annotations.ApiModelProperty;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import org.checkerframework.checker.units.qual.A;
/**
* @author zjm
......@@ -23,6 +24,9 @@ public class signUpReturn {
@ApiModelProperty(value = "是否报名 0 报名 1否", name = "returns")
private Integer returns;
@ApiModelProperty(value = "必须报名 不报名填写的备注",name = "node")
private String node;
@ApiModelProperty(value = "job——id", name = "taskId")
private Integer taskId;
......
......@@ -5,7 +5,9 @@ import com.github.wenhao.jpa.PredicateBuilder;
import com.github.wenhao.jpa.Specifications;
import com.tykj.dev.device.task.subject.bto.TaskBto;
import com.tykj.dev.device.train.dao.TrainThemeDao;
import com.tykj.dev.device.train.dao.TrainUserDao;
import com.tykj.dev.device.train.entity.TrainTheme;
import com.tykj.dev.device.train.entity.TrainUser;
import com.tykj.dev.device.train.entity.vo.*;
import com.tykj.dev.device.train.service.TrainTaskService;
import com.tykj.dev.device.train.service.TrainThemeService;
......@@ -51,6 +53,9 @@ public class TrainThemeServiceImpl implements TrainThemeService {
@Autowired
TrainTaskService trainTaskService;
@Autowired
TrainUserDao trainUserDao;
@Override
public TrainTheme save(TrainTheme trainTheme) {
return trainThemeDao.save(trainTheme);
......@@ -92,20 +97,8 @@ public class TrainThemeServiceImpl implements TrainThemeService {
public TrainRegistrationVo findRegistrationVo(Integer trainThemeId) {
TrainTheme trainTheme = trainThemeDao.findById(trainThemeId).get();
TrainRegistrationVo trainRegistrationVo = trainTheme.toTrainRegistrationVo();
List<Integer> signUp = StringSplitUtil.userIdSplit(trainTheme.getSignUp());
trainRegistrationVo.setSignUpUser(userService.findByIdListUserTarinVo(signUp));
List<Integer> integerList1 = JacksonUtil.readValue(trainTheme.getNoJoinUserId(), new TypeReference<List<Integer>>() {
});
List<Integer> integerList2 = JacksonUtil.readValue(trainTheme.getJoinUserId(), new TypeReference<List<Integer>>() {
});
if (integerList2!=null) {
integerList1.addAll(integerList2);
}
if (integerList1!=null) {
integerList1.removeAll(signUp);
}
trainRegistrationVo.setNoSignUpUser(userService.findByIdListUserTarinVo(integerList1));
trainRegistrationVo.setSignUpUser(trainUserDao.findAllByIsSignUpAndTrainId(1,trainThemeId));
trainRegistrationVo.setNoSignUpUser(trainUserDao.findAllByIsSignUpAndTrainId(2,trainThemeId));
return trainRegistrationVo;
}
......@@ -113,8 +106,7 @@ public class TrainThemeServiceImpl implements TrainThemeService {
public TrainTrainingVo findTrainTrainingVo(Integer trainThemeId) {
TrainTheme trainTheme = trainThemeDao.findById(trainThemeId).get();
TrainTrainingVo trainTrainingVo = trainTheme.toTrainTrainingVo();
List<Integer> signUp = StringSplitUtil.userIdSplit(trainTheme.getSignUp());
trainTrainingVo.setSignUpUser(userService.findByIdListUserTarinVo(signUp));
trainTrainingVo.setTrainUsers(trainUserDao.findAllByIsSignUpAndTrainId(1,trainThemeId));
return trainTrainingVo;
}
......@@ -122,8 +114,11 @@ public class TrainThemeServiceImpl implements TrainThemeService {
public TrainAuditVo findTrainAuditVo(Integer trainThemeId) {
TrainTheme trainTheme = trainThemeDao.findById(trainThemeId).get();
TrainAuditVo trainAuditVo = trainTheme.toTrainAuditVo();
trainAuditVo.setGradeEntry(JacksonUtil.readValue(trainTheme.getTrainingResults(), new TypeReference<List<GradeEntry>>() {
}));
List<TrainUser> trainUsers= trainUserDao.findAllByIsSignUpAndTrainId(1,trainThemeId);
trainUsers.forEach(trainUser -> {
trainUser.setMgrcert(mgrcertService.findByUserId(trainUser.getUserId()));
});
trainAuditVo.setTrainUser(trainUsers);
return trainAuditVo;
}
......@@ -184,16 +179,11 @@ public class TrainThemeServiceImpl implements TrainThemeService {
if (trainThemeOptional.isPresent()){
TrainTheme trainTheme=trainThemeOptional.get();
TrainDetailsVo trainDetailsVo=trainTheme.toTrainDetailsVo();
String gradeEntity= trainTheme.getTrainingResults();
if (gradeEntity!=null) {
List<GradeEntry> list = JacksonUtil.readValue(gradeEntity, new TypeReference<List<GradeEntry>>() {
List<TrainUser> trainUsers= trainUserDao.findAllByIsSignUpAndTrainId(1,trainId);
trainUsers.forEach(trainUser -> {
trainUser.setMgrcert(mgrcertService.findByUserId(trainUser.getUserId()));
});
list.forEach(
gradeEntry -> gradeEntry.setMgrcert(mgrcertService.findByUserId(gradeEntry.getUserId()))
);
trainDetailsVo.setGradeEntry(list);
}
trainDetailsVo.setTrainUsers(trainUsers);
return trainDetailsVo;
}else {
throw new ApiException(ResponseEntity.ok("培训id没有查询到,请检查"));
......
......@@ -29,5 +29,12 @@
<groupId>com.tykj.dev</groupId>
<artifactId>config</artifactId>
</dependency>
<dependency>
<groupId>com.tykj.dev</groupId>
<artifactId>socket</artifactId>
</dependency>
</dependencies>
</project>
\ No newline at end of file
......@@ -13,7 +13,8 @@ import org.springframework.boot.autoconfigure.SpringBootApplication;
@SpringBootApplication(scanBasePackages = {
"com.tykj.dev.misc",
"com.tykj.dev.config",
"com.tykj.dev.device.user"
"com.tykj.dev.device.user",
"com.tykj.dev.socket"
}
)
public class UserApp {
......
package com.tykj.dev.device.user.base.ret;
import com.tykj.dev.device.user.subject.entity.Units;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import javax.validation.constraints.Null;
import java.util.List;
/**
* @author zjm
* @version 1.0.0
* @ClassName UnitsTrainListVo.java
* @Description TODO
* @createTime 2020年12月01日 10:33:00
*/
@AllArgsConstructor
@NoArgsConstructor
@Data
@ApiModel(value = "单位集合", description = "给培训单位列表做筛选")
public class UnitsTrainListVo {
@ApiModelProperty(value = "省级单位id", name = "province", example = "12321L")
private List<Units> province;
@ApiModelProperty(value = "市级单位", name = "city", example = "12321L")
private List<Units> city;
@ApiModelProperty(value = "区县单位", name = "county", example = "12321L")
private List<Units> county;
}
package com.tykj.dev.device.user.read.controller;
/**
* @author dengdiyi
*/
import com.tykj.dev.config.swagger.AutoDocument;
import com.tykj.dev.device.read.service.MessageService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.*;
/**
* @author dengdiyi
*/
@RestController
@Api(tags = "阅知模块", description = "阅知模块")
@AutoDocument
@RequestMapping("/read")
public class MessageController {
@Autowired
private MessageService messageService;
@ApiOperation(value = "阅知信息查询")
@GetMapping("/get")
public ResponseEntity getMessage(){
return ResponseEntity.ok(messageService.getList());
}
@ApiOperation(value = "提交已读阅知信息")
@PostMapping("/read/{id}")
public ResponseEntity readMessage(@PathVariable("id") int id){
return ResponseEntity.ok(messageService.read(id).parse2Bto().toVo());
}
@ApiOperation(value = "完成阅知信息")
@PostMapping("/complete/{id}")
public ResponseEntity completeMessage(@PathVariable("id") int id){
return ResponseEntity.ok(messageService.complete(id).parse2Bto().toVo());
}
}
package com.tykj.dev.device.user.read.repository;
import com.tykj.dev.device.user.read.subject.domin.Message;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.stereotype.Repository;
/**
* @author dengdiyi
*/
@Repository
public interface MessageDao extends JpaRepository<Message,Integer>, JpaSpecificationExecutor<Message> {
}
package com.tykj.dev.device.user.read.service;
import com.tykj.dev.device.user.read.subject.bto.MessageBto;
import com.tykj.dev.device.user.read.subject.domin.Message;
import com.tykj.dev.device.user.read.subject.vo.MessageUserVo;
import java.util.List;
/**
* @author dengdiyi
*/
public interface MessageService {
MessageBto add(MessageBto messageBto);
Message update(Message message);
Message get(Integer id);
void delete(Integer id);
List<MessageUserVo> getList();
/**
* @param messageId 阅知信息id
* 阅读该信息
*/
Message read(Integer messageId);
/**
* @param messageId 阅知信息id
* 完成该阅知信息
*/
Message complete(Integer messageId);
}
package com.tykj.dev.device.user.read.service.impl;
import com.tykj.dev.device.user.read.repository.MessageDao;
import com.tykj.dev.device.user.read.service.MessageService;
import com.tykj.dev.device.user.read.subject.bto.MessageBto;
import com.tykj.dev.device.user.read.subject.domin.Message;
import com.tykj.dev.device.user.read.subject.vo.MessageUserVo;
import com.tykj.dev.device.user.util.UserUtils;
import com.tykj.dev.misc.exception.ApiException;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.Comparator;
import java.util.List;
import java.util.Optional;
import java.util.stream.Collectors;
/**
* @author dengdiyi
*/
@Service
public class MessageServiceImpl implements MessageService {
@Autowired
private MessageDao messageDao;
@Autowired
private UserUtils userUtils;
@Override
public MessageBto add(MessageBto messageBto) {
return messageDao.save(messageBto.toDo()).parse2Bto();
}
@Override
public Message update(Message message) {
return messageDao.save(message);
}
@Override
public Message get(Integer id) {
Optional<Message> message = messageDao.findById(id);
if (message.isPresent()){
return message.get();
}
else {
throw new ApiException("Id不存在");
}
}
@Override
public void delete(Integer id) {
messageDao.deleteById(id);
}
@Override
public List<MessageUserVo> getList() {
Integer userId = userUtils.getCurrentUserId();
return messageDao.findAll().stream()
.map(Message::parse2Bto)
.filter(messageBto -> messageBto.getInvolveUserIdList().contains(userId)&&!messageBto.getCompleteUserIdList().contains(userId))
.map(MessageBto::toVo)
.sorted(Comparator.comparing(MessageUserVo::getCreateTime).reversed())
.collect(Collectors.toList());
}
/**
* @param messageId 阅知信息id
*/
@Override
public Message read(Integer messageId) {
Integer userId = userUtils.getCurrentUserId();
MessageBto messageBto = get(messageId).parse2Bto();
List<Integer> userIds = messageBto.getUserReadDetailList();
userIds.add(userId);
messageBto.setUserReadDetailList(userIds);
List<Integer> userIds2 = messageBto.getCompleteUserIdList();
userIds2.add(userId);
messageBto.setCompleteUserIdList(userIds2);
return messageDao.save(messageBto.toDo());
}
/**
* @param messageId 阅知信息id
* 完成该阅知信息
*/
@Override
public Message complete(Integer messageId) {
Integer userId = userUtils.getCurrentUserId();
MessageBto messageBto = get(messageId).parse2Bto();
List<Integer> userIds = messageBto.getCompleteUserIdList();
userIds.add(userId);
messageBto.setCompleteUserIdList(userIds);
return messageDao.save(messageBto.toDo());
}
}
package com.tykj.dev.device.user.read.subject.bto;
import com.tykj.dev.device.user.read.subject.domin.Message;
import com.tykj.dev.device.user.read.subject.vo.MessageUserVo;
import com.tykj.dev.device.user.util.UserUtils;
import com.tykj.dev.misc.base.BeanHelper;
import com.tykj.dev.misc.utils.SpringUtils;
import com.tykj.dev.misc.utils.StringSplitUtil;
import io.swagger.annotations.ApiModelProperty;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import org.modelmapper.ModelMapper;
import org.springframework.data.annotation.CreatedDate;
import org.springframework.data.annotation.LastModifiedBy;
import org.springframework.data.annotation.LastModifiedDate;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
/**
* @author dengdiyi
*/
@Data
@NoArgsConstructor
@AllArgsConstructor
public class MessageBto {
@ApiModelProperty(name = "主键id")
private Integer id;
@ApiModelProperty(name = "阅知信息对应业务Id")
private Integer taskId;
@ApiModelProperty(value = "业务类型主键id")
private Integer businessType;
@ApiModelProperty(value = "信息内容")
private String content;
@ApiModelProperty(value = "阅知人员id类别")
private List<Integer> involveUserIdList;
@ApiModelProperty(value = "已完成人员id列表")
private List<Integer> completeUserIdList = new ArrayList<>();
@ApiModelProperty(value = "用户已读列表")
private List<Integer> userReadDetailList = new ArrayList<>();
@ApiModelProperty(value = "创建用户id")
private Integer createUserId;
@ApiModelProperty(value = "创建时间")
@CreatedDate
private Date createTime;
@ApiModelProperty(value = "更新用户id")
@LastModifiedBy
private Integer updateUserId;
@ApiModelProperty(value = "更新时间")
@LastModifiedDate
private Date updateTime;
@ApiModelProperty(value = "删除标记(0:未删除,1:已删除)")
private Integer deleteTag = 0;
/**
* bto类转化为do类
*/
public Message toDo() {
//复制相同属性
ModelMapper modelMapper = BeanHelper.getUserMapper();
Message message = modelMapper.map(this, Message.class);
//set组合字段
message.setInvolveUsers(StringSplitUtil.idListToString(this.involveUserIdList));
message.setUserReadDetail(StringSplitUtil.idListToString(this.userReadDetailList));
message.setCompleteUsers(StringSplitUtil.idListToString(this.completeUserIdList));
return message;
}
/**
* bto类转化为vo类
*/
public MessageUserVo toVo() {
UserUtils userUtils = SpringUtils.getBean("userUtils");
//复制相同属性
ModelMapper modelMapper = BeanHelper.getUserMapper();
MessageUserVo messageUserVo = modelMapper.map(this, MessageUserVo.class);
//set vo字段
if (userUtils!=null&&userReadDetailList.contains(userUtils.getCurrentUserId())){
messageUserVo.setIsRead(1);
}
return messageUserVo;
}
public MessageBto(Integer taskId, Integer businessType, String content, List<Integer> involveUserIdList) {
this.taskId = taskId;
this.businessType = businessType;
this.content = content;
this.involveUserIdList = involveUserIdList;
}
}
package com.tykj.dev.device.user.read.subject.domin;
import com.tykj.dev.device.user.read.subject.bto.MessageBto;
import com.tykj.dev.misc.base.BeanHelper;
import com.tykj.dev.misc.utils.StringSplitUtil;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import org.hibernate.annotations.SQLDelete;
import org.hibernate.annotations.Where;
import org.modelmapper.ModelMapper;
import org.springframework.data.annotation.CreatedBy;
import org.springframework.data.annotation.CreatedDate;
import org.springframework.data.annotation.LastModifiedBy;
import org.springframework.data.annotation.LastModifiedDate;
import org.springframework.data.jpa.domain.support.AuditingEntityListener;
import javax.persistence.*;
import java.util.Date;
/**
* 阅知信息表
* @author dengdiyi
*/
@Data
@Entity
@EntityListeners(AuditingEntityListener.class)
@SQLDelete(sql = "update message set delete_tag = 1 where id = ?")
@Where(clause = "delete_tag = 0")
@ApiModel("阅知信息表")
public class Message {
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
@ApiModelProperty(name = "主键id")
private Integer id;
@ApiModelProperty(name = "阅知信息对应业务Id")
private Integer taskId;
@ApiModelProperty(value = "业务类型主键id")
private Integer businessType;
@ApiModelProperty(value = "信息内容")
private String content;
@ApiModelProperty(value = "阅知人员id(x作为分隔符),例如x1x2x,意为id为1,2的用户待阅知该信息")
private String involveUsers;
@ApiModelProperty(value = "已完成人员id(x作为分隔符),例如x1x2x,意为id为1,2的用户已完成阅知该信息")
private String completeUsers;
@ApiModelProperty(value = "用户阅读信息")
private String userReadDetail;
@ApiModelProperty(value = "创建用户id")
@CreatedBy
private Integer createUserId;
@ApiModelProperty(value = "创建时间")
@CreatedDate
private Date createTime;
@ApiModelProperty(value = "更新用户id")
@LastModifiedBy
private Integer updateUserId;
@ApiModelProperty(value = "更新时间")
@LastModifiedDate
private Date updateTime;
@ApiModelProperty(value = "删除标记(0:未删除,1:已删除)")
private Integer deleteTag = 0;
/**
* do类转化为bto类
*/
public MessageBto parse2Bto() {
//modelMap复制
ModelMapper mapper = BeanHelper.getUserMapper();
MessageBto messageBto = mapper.map(this, MessageBto.class);
//解析组合字段并添加
messageBto.setInvolveUserIdList(StringSplitUtil.userIdSplit(this.involveUsers));
messageBto.setUserReadDetailList(StringSplitUtil.userIdSplit(this.userReadDetail));
messageBto.setCompleteUserIdList(StringSplitUtil.userIdSplit(this.completeUsers));
return messageBto;
}
}
package com.tykj.dev.device.user.read.subject.vo;
import io.swagger.annotations.ApiModelProperty;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import org.springframework.data.annotation.CreatedDate;
import org.springframework.data.annotation.LastModifiedBy;
import org.springframework.data.annotation.LastModifiedDate;
import java.util.Date;
/**
* @author dengdiyi
*/
@Data
@NoArgsConstructor
@AllArgsConstructor
public class MessageUserVo {
@ApiModelProperty(name = "主键id")
private Integer id;
@ApiModelProperty(name = "阅知信息对应业务Id")
private Integer taskId;
@ApiModelProperty(value = "业务类型主键id")
private Integer businessType;
@ApiModelProperty(value = "信息内容")
private String content;
@ApiModelProperty(name = "当前用户是否已阅读(0:未读,1:已读)")
private Integer isRead = 0;
@ApiModelProperty(value = "创建用户id")
private Integer createUserId;
@ApiModelProperty(value = "创建时间")
@CreatedDate
private Date createTime;
@ApiModelProperty(value = "更新用户id")
@LastModifiedBy
private Integer updateUserId;
@ApiModelProperty(value = "更新时间")
@LastModifiedDate
private Date updateTime;
}
......@@ -79,4 +79,12 @@ public class UnitsController {
return ResponseEntity.ok(unitsService.selectPage(page,size));
}
@GetMapping("/train/list/{unitsId}")
@ApiOperation(value = "清退时选择培训单位的接口", notes = "成功返回单位对象")
public ResponseEntity selectPage( @PathVariable Integer unitsId){
return ResponseEntity.ok(unitsService.findByUserIdUnitsTrainListVo(unitsId));
}
}
......@@ -10,6 +10,7 @@ import com.tykj.dev.device.user.subject.entity.SecurityUser;
import com.tykj.dev.device.user.subject.entity.User;
import com.tykj.dev.device.user.subject.service.*;
import com.tykj.dev.device.user.util.LogoutUtil;
import com.tykj.dev.socket.MyWebSocket;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
......@@ -62,6 +63,9 @@ public class UserController {
MyUserDetailsServiceImpl myUserDetailsService;
@Autowired
LogoutUtil logout;
@Autowired
MyWebSocket myWebSocket;
// @PostMapping(value = "/login")
// @ApiOperation(value = "用户新增接口", notes = "添加成功返回用户对象")
// public ResponseEntity loginUser(@RequestBody LoginUser loginUser){
......@@ -80,8 +84,9 @@ public class UserController {
@ApiOperation(value = "用户登出")
@GetMapping("/userLogout")
public void logout() {
public void logout(@ApiIgnore @AuthenticationPrincipal SecurityUser securityUser) {
log.info("调用登出接口");
myWebSocket.Close(String.valueOf(securityUser.getCurrentUserInfo().getUserId()));
logout.logout();
}
......@@ -99,8 +104,8 @@ public class UserController {
@PostMapping(value = "/save")
@ApiOperation(value = "用户新增接口", notes = "添加成功返回用户对象")
public ResponseEntity saveUser(@RequestBody User user) {
return ResponseEntity.ok(userService.save(user));
public ResponseEntity saveUser(@ApiIgnore @AuthenticationPrincipal SecurityUser securityUser,@RequestBody User user) {
return ResponseEntity.ok(userService.save(user,securityUser));
}
@GetMapping(value = "/delete/{userId}")
......@@ -165,12 +170,12 @@ public class UserController {
return ResponseEntity.ok("修改密码成功");
}
@GetMapping(value = "/get/train/{userId}")
@ApiOperation(value = "根据用户id查询下级用户列表", notes = "成功返回UserTrainVo对象集合")
public ResponseEntity getFind(@ApiIgnore @AuthenticationPrincipal SecurityUser securityUser, @PathVariable Integer userId) {
return ResponseEntity.ok(userService.findByIdUserTarinVo(userId));
}
// @GetMapping(value = "/get/train/{userId}")
// @ApiOperation(value = "根据用户id查询下级用户列表", notes = "成功返回UserTrainVo对象集合")
// public ResponseEntity getFind(@ApiIgnore @AuthenticationPrincipal SecurityUser securityUser, @PathVariable Integer userId) {
//
// return ResponseEntity.ok(userService.findByIdUserTarinVo(userId));
// }
@GetMapping(value = "/get/trainUnits/{userId}")
@ApiOperation(value = "根据用户id查询下级单位列表", notes = "成功返回UnitsTrainVo对象集合")
......@@ -214,4 +219,11 @@ public class UserController {
return ResponseEntity.ok(venitalisService.registeredRet(venitalisVo));
}
@GetMapping("/test")
@ApiOperation(value = "1111111111111", notes = "uuid")
public ResponseEntity getUuid1(@ApiIgnore @AuthenticationPrincipal SecurityUser securityUser) {
return ResponseEntity.ok(userService.findAllLastUserids(securityUser.getCurrentUserInfo().getUserId()));
}
}
package com.tykj.dev.device.user.subject.controller;
/**
* @author zjm
* @version 1.0.0
* @ClassName AreaController.java
* @Description TODO
* @createTime 2020年09月04日 13:34:00
*/
import com.tykj.dev.config.swagger.AutoDocument;
import com.tykj.dev.device.user.subject.dao.AreaDao;
import com.tykj.dev.device.user.subject.entity.Area;
import com.tykj.dev.device.user.subject.entity.SecurityUser;
import com.tykj.dev.device.user.subject.service.AreaService;
import com.tykj.dev.device.user.subject.service.UserLogService;
import com.tykj.dev.misc.exception.ApiException;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.checkerframework.checker.units.qual.A;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.ResponseEntity;
import org.springframework.security.core.annotation.AuthenticationPrincipal;
import org.springframework.web.bind.annotation.*;
import springfox.documentation.annotations.ApiIgnore;
import java.util.Optional;
/**
* 区域视图层
*/
@RestController
@AutoDocument
@Api(tags = "用户档案模块", description = "提供用户档案的接口")
@RequestMapping("/userLog")
public class UserLogController {
@Autowired
UserLogService userLogService;
@GetMapping("/find/select/{userId}")
@ApiOperation(value = "分页查询area对象", notes = "成功返回区域对象")
public ResponseEntity selectPage(@PathVariable Integer userId){
return ResponseEntity.ok(userLogService.findAllByuserID(userId));
}
}
......@@ -16,4 +16,5 @@ public interface UserDao extends JpaRepository<User, Integer>, JpaSpecificationE
List<User> findAllByUnitsIdIn(List<Integer> ids);
List<User> findAllByUserIdIn(List<Integer> userIds);
}
package com.tykj.dev.device.user.subject.dao;
import com.tykj.dev.device.user.subject.entity.UserLog;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import java.util.List;
public interface UserLogDao extends JpaRepository<UserLog, Integer>, JpaSpecificationExecutor<UserLog> {
List<UserLog> findAllByUserIdOrderByTimeAsc(Integer userId);
}
......@@ -158,10 +158,6 @@ public class User {
return mapper.map(this, HandoverUser.class);
}
public UserTrainVo toUserTrainVo() {
ModelMapper mapper = BeanHelper.getUserMapper();
return mapper.map(this, UserTrainVo.class);
}
public UserSuperiorVo toUserSuperiorVo() {
ModelMapper mapper = BeanHelper.getUserMapper();
......
package com.tykj.dev.device.user.subject.entity;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import java.util.Date;
/**
* @author zjm
* @version 1.0.0
* @ClassName UserLog.java
* @Description 用户日志对象
* @createTime 2020年12月01日 14:37:00
*/
@AllArgsConstructor
@NoArgsConstructor
@Data
@Entity
@ApiModel(value = "用户日志对象", description = "用户log")
public class UserLog {
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
@ApiModelProperty(value = "id", name = "id")
private Integer id;
@ApiModelProperty(value = "用户id", name = "userId")
private Integer userId;
@ApiModelProperty(value = "时间", name = "time")
private Date time;
@ApiModelProperty(value = "内容", name = "content")
private String content;
public UserLog(Integer userId, Date time, String content) {
this.userId = userId;
this.time = time;
this.content = content;
}
}
......@@ -30,4 +30,6 @@ public interface AreaService extends PublicService<Area> {
AreaPage selectPage(Integer page,Integer size);
Area findByid(Integer areaId);
}
package com.tykj.dev.device.user.subject.service;
import com.tykj.dev.device.user.base.ret.AreaVo;
import com.tykj.dev.device.user.base.ret.UnitsPage;
import com.tykj.dev.device.user.base.ret.UnitsTrainVo;
import com.tykj.dev.device.user.base.ret.UnitsVo;
import com.tykj.dev.device.user.base.ret.*;
import com.tykj.dev.device.user.subject.entity.SecurityUser;
import com.tykj.dev.device.user.subject.entity.Units;
......@@ -22,6 +19,11 @@ public interface UnitsService extends PublicService<Units> {
List<Units> findListById(Integer leven);
/**
* 装备管理 人员管理 组织结构列表
* @param securityUser
* @return
*/
List<AreaVo> findListAreaUnitsVo(SecurityUser securityUser);
List<Units> findListlevenGreaterThanEqual(Integer leven);
......@@ -72,4 +74,12 @@ public interface UnitsService extends PublicService<Units> {
UnitsPage selectPage(Integer page, Integer size);
}
/**
* 根据用户查询 可当前单位的下级单位
* @param userId 当前用户id
* @return 单位集合
*/
List<Units> findByUserIdUnitsTrainListVo(Integer unitsId);
}
package com.tykj.dev.device.user.subject.service;
import com.tykj.dev.device.user.subject.entity.UserLog;
import java.util.List;
public interface UserLogService extends PublicService<UserLog>{
List<UserLog> findAllByuserID(Integer userId);
}
......@@ -2,6 +2,8 @@ package com.tykj.dev.device.user.subject.service;
import com.tykj.dev.device.user.base.ret.*;
import com.tykj.dev.device.user.subject.entity.SecurityUser;
import com.tykj.dev.device.user.subject.entity.Units;
import com.tykj.dev.device.user.subject.entity.User;
import java.util.List;
......@@ -22,6 +24,8 @@ public interface UserService extends PublicService<User> {
*/
User findByUserName(String userName);
User save(User user, SecurityUser securityUser);
/**
* 查询同级人员
*
......@@ -74,7 +78,7 @@ public interface UserService extends PublicService<User> {
* @param userId 用户ID
* @return 用户集合
*/
List<UserTrainVo> findByIdUserTarinVo(Integer userId);
// List<UserTrainVo> findByIdUserTarinVo(Integer userId);
/**
......@@ -91,7 +95,7 @@ public interface UserService extends PublicService<User> {
* @param userId
* @return
*/
List<UserTrainVo> findByIdListUserTarinVo(List<Integer> userId);
// List<UserTrainVo> findByIdListUserTarinVo(List<Integer> userId);
/**
......@@ -107,4 +111,21 @@ public interface UserService extends PublicService<User> {
* 根据用户ID查询上级单位所有用户
*/
List<UserSuperiorVo> findUserSuperiorVo(Integer userId);
/**
* 根据单位id集合查询用户
*/
List<User> findUnitsIdInUsers(List<Integer> units);
/**
* 根据用户id集合查询用户
*/
List<User> findAllUserIdInUser(List<Integer> userIds);
/**
* 根据单位id查询 上级的用户id
*/
List<Integer> findAllLastUserids(Integer userId);
}
......@@ -111,6 +111,11 @@ public class AreaServiceImpl implements AreaService {
.build();
}
@Override
public Area findByid(Integer areaId) {
return areaDao.findById(areaId).get();
}
private List<UnitsVo> subordinateAllUnits(List<UnitsVo> units, Area area) {
List<Area> list = areaDao.findAllByFatherId(area.getId());
if (list.size() == 0) {
......
......@@ -68,6 +68,34 @@ public class UnitsServiceImpl implements UnitsService {
}
List<Area> areas= areaDao.findAllByFatherId(areaId);
if (areas.size()!=0) {
areaVos=provinceAndCity(belongsArea,areas,areaVos);
}else {
int i=0;
AreaVo areaVo = belongsArea.toVo();
areaVo.setFrontEnd(i++);
List<UnitsVo> unitsList = unitsDao.findAllByAreaId(belongsArea.getId()).stream().map(Units::toVo).collect(Collectors.toList());
for (UnitsVo unitsVo : unitsList) {
unitsVo.setFrontEnd(i++);
}
areaVo.setUnits(unitsList);
areaVos.add(areaVo);
}
//查询区域下所有的区域
//根据区域查看
return areaVos;
}
/**
* 根据所在区域是省还是市
* 省 则把下属市以及市下属都区都单位统一放入市AreaVo 在放入List<AreaVo> 集合中。
* 市 则把下属区都单位放入市都AreaVo对象中
* @param thisArea 本单位区域
* @param areas 下级区域列表
*/
private List<AreaVo> provinceAndCity(Area thisArea,List<Area> areas,List<AreaVo> areaVos){
AreaVo thisAreaVo=thisArea.toVo();
if (thisArea.getType()==1) {
areas.forEach(area -> {
int i = 1;
AreaVo areaVo = area.toVo();
......@@ -84,23 +112,29 @@ public class UnitsServiceImpl implements UnitsService {
areaVo.setUnits(unitsList);
areaVos.add(areaVo);
});
}else {
int i=0;
AreaVo areaVo = belongsArea.toVo();
areaVo.setFrontEnd(i++);
List<UnitsVo> unitsList = unitsDao.findAllByAreaId(belongsArea.getId()).stream().map(Units::toVo).collect(Collectors.toList());
}else if (thisArea.getType()==2){
List<UnitsVo> unitsLists = unitsDao.findAllByAreaId(thisArea.getId()).stream().map(Units::toVo).collect(Collectors.toList());
for (UnitsVo unitsVo : unitsLists) {
unitsVo.setFrontEnd(5000);
}
thisAreaVo.setUnits(unitsLists);
areas.forEach(area -> {
int i = 1;
thisAreaVo.setFrontEnd(i++);
List<UnitsVo> unitsList = unitsDao.findAllByAreaId(area.getId()).stream().map(Units::toVo).collect(Collectors.toList());
for (UnitsVo unitsVo : unitsList) {
unitsVo.setFrontEnd(i++);
}
areaVo.setUnits(unitsList);
areaVos.add(areaVo);
thisAreaVo.getUnits().addAll(unitsList);
});
areaVos.add(thisAreaVo);
}else {
return areaVos;
}
//查询区域下所有的区域
//根据区域查看
return areaVos;
}
@Override
public List<Units> findListlevenGreaterThanEqual(Integer leven) {
return unitsDao.findAllByLevelGreaterThanEqual(leven);
......@@ -167,6 +201,37 @@ public class UnitsServiceImpl implements UnitsService {
.build();
}
@Override
public List<Units> findByUserIdUnitsTrainListVo(Integer unitsId) {
// List<Units> province=new ArrayList<>();
// List<Units> city=new ArrayList<>();
// List<Units> county=new ArrayList<>();
Optional<Units> unitsOptional = unitsDao.findById(unitsId);
if (unitsOptional.isPresent()) {
Units units=unitsOptional.get();
List<Integer> areaIds = areaDao.findAllByFatherId(units.getAreaId()).stream().map(Area::getId).collect(Collectors.toList());
// if (areaIds.size() != 0) {
// unitsDao.findAllByAreaIdIn(areaIds).forEach(
// units1 -> {
// if (units1.getLevel()==1){
// province.add(units1);
// }else if (units1.getLevel()==2){
// city.add(units1);
// }else if (units1.getLevel()==3){
// county.add(units1);
// }else {
// log.info("[清退] 没有找到对应的单位id");
// }
// }
// );
// }
return unitsDao.findAllByAreaIdIn(areaIds);
}else {
throw new ApiException(ResponseEntity.status(500).body("单位没有查到"));
}
}
@Override
public Units save(Units units) {
Optional<Area> optionalArea = areaDao.findById(units.getAreaId());
......
package com.tykj.dev.device.user.subject.service.impl;
import com.tykj.dev.device.user.subject.dao.UserLogDao;
import com.tykj.dev.device.user.subject.entity.UserLog;
import com.tykj.dev.device.user.subject.service.UserLogService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.List;
/**
* @author zjm
* @version 1.0.0
* @ClassName UserLogServiceImpl.java
* @Description TODO
* @createTime 2020年12月01日 15:46:00
*/
@Service
public class UserLogServiceImpl implements UserLogService {
@Autowired
UserLogDao userLogDao;
@Override
public UserLog save(UserLog userLog) {
return userLogDao.save(userLog);
}
@Override
public boolean delete(Integer id) {
return false;
}
@Override
public List<UserLog> findAll() {
return userLogDao.findAll();
}
@Override
public UserLog update(UserLog userLog) {
return userLogDao.save(userLog);
}
@Override
public List<UserLog> findAllByuserID(Integer userId) {
return userLogDao.findAllByUserIdOrderByTimeAsc(userId);
}
}
package com.tykj.dev.device.user.subject.service.impl;
import com.tykj.dev.device.user.base.ret.*;
import com.tykj.dev.device.user.subject.dao.MgrcertDao;
import com.tykj.dev.device.user.subject.dao.UserDao;
import com.tykj.dev.device.user.subject.dao.UserRoleDao;
import com.tykj.dev.device.user.subject.entity.Mgrcert;
import com.tykj.dev.device.user.subject.entity.Units;
import com.tykj.dev.device.user.subject.entity.User;
import com.tykj.dev.device.user.subject.entity.UserRole;
import com.tykj.dev.device.user.read.service.MessageService;
import com.tykj.dev.device.user.read.subject.bto.MessageBto;
import com.tykj.dev.device.user.subject.dao.*;
import com.tykj.dev.device.user.subject.entity.*;
import com.tykj.dev.device.user.subject.service.AreaService;
import com.tykj.dev.device.user.subject.service.UnitsService;
import com.tykj.dev.device.user.subject.service.UserLogService;
import com.tykj.dev.device.user.subject.service.UserService;
import com.tykj.dev.misc.utils.JacksonUtil;
import lombok.extern.slf4j.Slf4j;
import org.checkerframework.checker.units.qual.A;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.crypto.bcrypt.BCryptPasswordEncoder;
import org.springframework.stereotype.Service;
......@@ -40,6 +38,42 @@ public class UserServiceImpl implements UserService {
UnitsService unitsService;
@Autowired
UserRoleDao userRoleDao;
@Autowired
UserLogService userLogService;
@Autowired
AreaService areaService;
@Autowired
UnitsDao unitsDao;
@Autowired
MessageService messageService;
@Override
public User save(User user, SecurityUser securityUser) {
String encode = bCryptPasswordEncoder.encode("qwer1234");
user.setPassword(encode);
Units units = unitsService.findById(user.getUnitsId());
User user1 = userDao.save(user);
switch (units.getLevel()){
case 1:
userRoleDao.save(new UserRole(user1.getUserId(),1));
break;
case 2:
userRoleDao.save(new UserRole(user1.getUserId(),2));
break;
case 3:
userRoleDao.save(new UserRole(user1.getUserId(),3));
break;
default:
log.info("[user] 添加转管员单位等级不存在:{}",units.getLevel());
}
messageService.add(new MessageBto(0,0,securityUser.getUsername()+"添加专管员"+user1.getUsername(),this.findAllLastUserids(securityUser.getCurrentUserInfo().getUserId())));
userLogService.save(new UserLog(user1.getUserId(),new Date(),"专管员任命成功"));
return user1;
}
/**
* 给密码加密bCryptPasswordEncoder
......@@ -67,6 +101,7 @@ public class UserServiceImpl implements UserService {
log.info("[user] 添加转管员单位等级不存在:{}",units.getLevel());
}
userLogService.save(new UserLog(user1.getUserId(),new Date(),"专管员任命成功"));
return user1;
}
......@@ -91,6 +126,7 @@ public class UserServiceImpl implements UserService {
return userDao.findByUsername(userName);
}
@Override
public List<UserShenRe> findByUserId(Integer userId) {
......@@ -242,26 +278,26 @@ public class UserServiceImpl implements UserService {
}
@Override
public List<UserTrainVo> findByIdUserTarinVo(Integer userId) {
List<UserTrainVo> list = new ArrayList<>();
Integer unitsId = userDao.findById(userId).get().getUnitsId();
Units units = unitsService.findById(unitsId);
userDao.findAllByUnitsIdIn(unitsService.findListSubordinateId(unitsId)).forEach(
user -> {
UserTrainVo userTrainVo = user.toUserTrainVo();
if (user.getTrainStatus() == 1 || user.getTrainStatus() == 2) {
userTrainVo.setIsMustJoin(0);
} else {
userTrainVo.setIsMustJoin(1);
}
userTrainVo.setUnitsName(unitsService.findById(user.getUnitsId()).getName());
list.add(userTrainVo);
}
);
list.sort(Comparator.comparing(UserTrainVo::getIsMustJoin).reversed());
return list;
}
// @Override
// public List<UserTrainVo> findByIdUserTarinVo(Integer userId) {
// List<UserTrainVo> list = new ArrayList<>();
// Integer unitsId = userDao.findById(userId).get().getUnitsId();
// Units units = unitsService.findById(unitsId);
// userDao.findAllByUnitsIdIn(unitsService.findListSubordinateId(unitsId)).forEach(
// user -> {
// UserTrainVo userTrainVo = user.toUserTrainVo();
// if (user.getTrainStatus() == 1 || user.getTrainStatus() == 2) {
// userTrainVo.setIsMustJoin(0);
// } else {
// userTrainVo.setIsMustJoin(1);
// }
// userTrainVo.setUnitsName(unitsService.findById(user.getUnitsId()).getName());
// list.add(userTrainVo);
// }
// );
// list.sort(Comparator.comparing(UserTrainVo::getIsMustJoin).reversed());
// return list;
// }
@Override
public List<UnitsTrainVo> findByIdUnitsTrainVo(Integer userId) {
......@@ -269,23 +305,23 @@ public class UserServiceImpl implements UserService {
}
@Override
public List<UserTrainVo> findByIdListUserTarinVo(List<Integer> userId) {
List<UserTrainVo> list = new ArrayList<>();
userDao.findAllByUserIdIn(userId).forEach(
user -> {
UserTrainVo userTrainVo = user.toUserTrainVo();
if (user.getTrainStatus() == 1 || user.getTrainStatus() == 2) {
userTrainVo.setIsMustJoin(0);
} else {
userTrainVo.setIsMustJoin(1);
}
userTrainVo.setUnitsName(unitsService.findById(user.getUnitsId()).getName());
list.add(userTrainVo);
}
);
return list;
}
// @Override
// public List<UserTrainVo> findByIdListUserTarinVo(List<Integer> userId) {
// List<UserTrainVo> list = new ArrayList<>();
// userDao.findAllByUserIdIn(userId).forEach(
// user -> {
// UserTrainVo userTrainVo = user.toUserTrainVo();
// if (user.getTrainStatus() == 1 || user.getTrainStatus() == 2) {
// userTrainVo.setIsMustJoin(0);
// } else {
// userTrainVo.setIsMustJoin(1);
// }
// userTrainVo.setUnitsName(unitsService.findById(user.getUnitsId()).getName());
// list.add(userTrainVo);
// }
// );
// return list;
// }
@Override
public HandoverUser findByIdHandoverUser(Integer userId) {
......@@ -320,5 +356,35 @@ public class UserServiceImpl implements UserService {
return list;
}
@Override
public List<User> findUnitsIdInUsers(List<Integer> units) {
return userDao.findAllByUnitsIdIn(units);
}
@Override
public List<User> findAllUserIdInUser(List<Integer> userIds) {
return userDao.findAllByUserIdIn(userIds);
}
@Override
public List<Integer> findAllLastUserids(Integer userId) {
User user=userDao.findById(userId).get();
Units units= unitsDao.findById(user.getUnitsId()).get();
Area area= areaService.findByid(units.getAreaId());
return to(new ArrayList<>(),area);
}
private List<Integer> to(List<Integer> ids,Area area){
if (area.getFatherId()==null){
return ids;
}
Area area1= areaService.findByid(area.getFatherId());
List<Units> units= unitsDao.findAllByAreaId(area1.getId());
ids.addAll(userDao.findAllByUnitsId(units.get(0).getUnitId()).stream().map(User::getUserId).collect(Collectors.toList()));
return to(ids,area1);
}
}
......@@ -3,7 +3,9 @@ package com.tykj.dev.device.user.subject.service.impl;
import com.tykj.dev.device.user.base.req.VenitalisVo;
import com.tykj.dev.device.user.base.ret.RegistereRetVo;
import com.tykj.dev.device.user.subject.dao.UserDao;
import com.tykj.dev.device.user.subject.dao.UserLogDao;
import com.tykj.dev.device.user.subject.entity.User;
import com.tykj.dev.device.user.subject.entity.UserLog;
import com.tykj.dev.device.user.subject.entity.venaDigitalis.ContrastRet;
import com.tykj.dev.device.user.subject.entity.venaDigitalis.RegisteredRet;
import com.tykj.dev.device.user.subject.service.VenitalisService;
......@@ -12,10 +14,12 @@ import com.tykj.dev.misc.utils.JacksonUtil;
import com.tykj.dev.misc.utils.httpclientutil.HttpClientUtil;
import lombok.extern.slf4j.Slf4j;
import org.checkerframework.checker.i18nformatter.qual.I18nFormat;
import org.checkerframework.checker.units.qual.A;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.ResponseEntity;
import org.springframework.stereotype.Service;
import java.util.Date;
import java.util.HashMap;
import java.util.Map;
......@@ -31,6 +35,8 @@ import java.util.Map;
public class VenitalisServiceImpl implements VenitalisService {
@Autowired
private UserDao userDao;
@Autowired
private UserLogDao userLogDao;
private final static String http="http://192.168.0.80:8081";
......@@ -59,6 +65,7 @@ public class VenitalisServiceImpl implements VenitalisService {
RegistereRetVo registereRetVo=new RegistereRetVo();
if (registeredRet.getReg_result().equals("ok") && registeredRet.getResult_code().equals("ok")){
registereRetVo.setRet(true);
userLogDao.save(new UserLog(venitalisVo.getUserId(),new Date(),user.getName()+"注册了指静脉"));
return registereRetVo;
}else {
registereRetVo.setRet(false);
......
......@@ -14,6 +14,7 @@
<artifactId>spring-boot-starter-parent</artifactId>
<version>2.1.4.RELEASE</version>
</parent>
<modules>
<module>dev-socket</module>
<module>dev-blockcha</module>
......@@ -117,6 +118,7 @@
<version>1.0-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>com.tykj</groupId>
<artifactId>dev-allot</artifactId>
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论