Commit e88a6587 authored by wujiang's avatar wujiang

添加安全域控工程

parent 8ec76077
<?xml version="1.0"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>com.amosframework.boot</groupId>
<artifactId>amos-boot-module-biz</artifactId>
<version>1.0.0</version>
</parent>
<artifactId>amos-boot-module-precontrol-biz</artifactId>
<name>amos-boot-module-precontrol-biz</name>
<url>http://maven.apache.org</url>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>
<dependencies>
<dependency>
<groupId>com.amosframework.boot</groupId>
<artifactId>amos-boot-module-precontrol-api</artifactId>
<version>${amos-biz-boot.version}</version>
</dependency>
</dependencies>
</project>
package com.yeejoin.precontrol.config;
import org.springframework.context.annotation.Configuration;
import org.springframework.core.Ordered;
import org.springframework.core.annotation.Order;
import javax.servlet.*;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
/**
* @program: api
* @description:
* @author: duanwei
* @create: 2019-12-13 11:16
**/
@Order(Ordered.HIGHEST_PRECEDENCE)
@Configuration
public class CORSFilter implements Filter {
@Override
public void init(FilterConfig filterConfig) throws ServletException {
}
@Override
public void doFilter(ServletRequest servletRequest, ServletResponse servletResponse, FilterChain filterChain) throws IOException, ServletException {
HttpServletRequest request = (HttpServletRequest) servletRequest;
HttpServletResponse response = (HttpServletResponse) servletResponse;
response.setHeader("Access-Control-Allow-Origin", "*");
response.setHeader("Access-Control-Allow-Methods", "POST,GET,OPTIONS,PUT,DELETE,PATCH,HEAD");
response.setHeader("Access-Control-Allow-Credentials", "true");
response.setHeader("Access-Control-Allow-Max-Age", "3600");
response.setHeader("Access-Control-Allow-Headers",
"Origin, X-Requested-With, X-Access-Token, X-Api-Key, Content-Type, Accept, Cache-Control,appkey,token,product");
//response.setHeader("Access-Control-Allow-Headers","*");
if ("OPTIONS".equalsIgnoreCase(request.getMethod())) {
response.setStatus(HttpServletResponse.SC_OK);
} else {
filterChain.doFilter(servletRequest, servletResponse);
}
}
@Override
public void destroy() {
}
}
package com.yeejoin.precontrol.config;
import com.fasterxml.jackson.core.JsonGenerator;
import com.fasterxml.jackson.core.JsonParser;
import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.databind.DeserializationContext;
import com.fasterxml.jackson.databind.JsonDeserializer;
import com.fasterxml.jackson.databind.JsonSerializer;
import com.fasterxml.jackson.databind.SerializerProvider;
import org.springframework.boot.jackson.JsonComponent;
import java.io.IOException;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Date;
/**
* @description:
* @author: duanwei
* @date: 2020-07-09 14:11
**/
@JsonComponent
public class DateFormatConfig {
private static SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
// /**
// * 日期格式化
// */
// public static class DateJsonSerializer extends JsonSerializer<Date> {
// @Override
// public void serialize(Date date, JsonGenerator jsonGenerator, SerializerProvider serializerProvider) throws IOException {
// jsonGenerator.writeString(dateFormat.format(date));
// }
// }
//
// /**
// * 解析日期字符串
// */
// public static class DateJsonDeserializer extends JsonDeserializer<Date> {
// @Override
// public Date deserialize(JsonParser jsonParser, DeserializationContext deserializationContext) throws IOException, JsonProcessingException {
// try {
// return dateFormat.parse(jsonParser.getText());
// } catch (ParseException e) {
// throw new RuntimeException(e);
// }
// }
// }
/**
* id主键
*/
public static class LongJsonSerializer extends JsonSerializer<Long> {
@Override
public void serialize(Long id, JsonGenerator jsonGenerator, SerializerProvider serializerProvider) throws IOException {
jsonGenerator.writeString(String.valueOf(id));
}
}
}
package com.yeejoin.precontrol.config;
import com.baomidou.mybatisplus.core.handlers.MetaObjectHandler;
import com.yeejoin.precontrol.common.utils.RedisUtil;
import org.apache.ibatis.reflection.MetaObject;
import org.springframework.beans.factory.InitializingBean;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Primary;
import org.springframework.stereotype.Component;
import java.util.Date;
/**
* @description: 处理mybatis业务处理, 新增和更新的基础数据填充,配合BaseEntity和MyBatisPlusConfig使用
* @author: duanwei
* @create: 2020-05-28 13:57
**/
@Primary
@Component("metaHandlerPrecontrol")
public class MetaHandler implements MetaObjectHandler, InitializingBean {
@Autowired
RedisUtil redisUtil;
/**
* 新增数据拦截
*
* @param metaObject
*/
@Override
public void insertFill(MetaObject metaObject) {
Date currentDate = new Date();
this.setFieldValByName("createDate", currentDate, metaObject);
this.setFieldValByName("updateTime", currentDate, metaObject);
}
/**
* 更新拦截
*
* @param metaObject
*/
@Override
public void updateFill(MetaObject metaObject) {
Date currentDate = new Date();
this.setFieldValByName("updateTime", currentDate, metaObject);
}
@Override
public void afterPropertiesSet() throws Exception {
}
}
\ No newline at end of file
package com.yeejoin.precontrol.config;
import com.baomidou.mybatisplus.autoconfigure.ConfigurationCustomizer;
import com.baomidou.mybatisplus.core.MybatisConfiguration;
import com.baomidou.mybatisplus.core.config.GlobalConfig;
import com.baomidou.mybatisplus.extension.plugins.PaginationInterceptor;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.Primary;
import org.springframework.transaction.annotation.EnableTransactionManagement;
/**
* @description: 分页插件
* @author: duanwei
* @create: 2020-06-30 13:57
**/
@EnableTransactionManagement
@Configuration("MybatisPlusConfigPrecontrol")
@Primary
public class MybatisPlusConfig {
/**
* plus分页插件支持
*/
@Bean
public PaginationInterceptor paginationInterceptor() {
PaginationInterceptor page = new PaginationInterceptor();
//设置方言类型
page.setDialectType("mysql");
//不限制
page.setLimit(-1);
return page;
}
/**
* pageHelper插件支持
*
* @return
*/
@Bean
ConfigurationCustomizer mybatisConfigurationCustomizer() {
return new ConfigurationCustomizer() {
@Override
public void customize(MybatisConfiguration configuration) {
configuration.addInterceptor(new com.github.pagehelper.PageInterceptor());
}
};
}
/**
* mp参数切面
*
* @return
*/
@Bean
public GlobalConfig globalConfig() {
GlobalConfig globalConfig = new GlobalConfig();
globalConfig.setMetaObjectHandler(new MetaHandler());
return globalConfig;
}
}
//package com.yeejoin.precontrol.config;
//
//import com.fasterxml.jackson.annotation.JsonAutoDetect;
//import com.fasterxml.jackson.annotation.JsonTypeInfo;
//import com.fasterxml.jackson.annotation.PropertyAccessor;
//import com.fasterxml.jackson.databind.ObjectMapper;
//import com.fasterxml.jackson.databind.SerializationFeature;
//import com.fasterxml.jackson.datatype.jsr310.JavaTimeModule;
//import org.springframework.context.annotation.Bean;
//import org.springframework.context.annotation.Configuration;
//import org.springframework.context.annotation.Primary;
//import org.springframework.data.redis.cache.RedisCacheConfiguration;
//import org.springframework.data.redis.cache.RedisCacheManager;
//import org.springframework.data.redis.cache.RedisCacheWriter;
//import org.springframework.data.redis.connection.RedisConnectionFactory;
//import org.springframework.data.redis.connection.lettuce.LettuceConnectionFactory;
//import org.springframework.data.redis.core.RedisTemplate;
//import org.springframework.data.redis.serializer.Jackson2JsonRedisSerializer;
//import org.springframework.data.redis.serializer.RedisSerializationContext;
//import org.springframework.data.redis.serializer.StringRedisSerializer;
//
//import java.time.Duration;
//
///**
// * @description:
// * @author: duanwei
// **/
//@Configuration("redisConfigPrecontrol")
//@Primary
//public class RedisConfig {
// @Bean
// public RedisTemplate<String, Object> redisTemplate(LettuceConnectionFactory factory) {
// RedisTemplate<String, Object> template = new RedisTemplate<>();
// template.setConnectionFactory(factory);
// Jackson2JsonRedisSerializer<Object> j2jrs = new Jackson2JsonRedisSerializer<>(Object.class);
// ObjectMapper om = new ObjectMapper();
// om.setVisibility(PropertyAccessor.ALL, JsonAutoDetect.Visibility.ANY);
// // 解决jackson2无法反序列化LocalDateTime的问题
// om.disable(SerializationFeature.WRITE_DATES_AS_TIMESTAMPS);
// om.registerModule(new JavaTimeModule());
// om.enableDefaultTyping(ObjectMapper.DefaultTyping.NON_FINAL, JsonTypeInfo.As.PROPERTY);
// j2jrs.setObjectMapper(om);
// // 序列化 value 时使用此序列化方法
// template.setValueSerializer(j2jrs);
// template.setHashValueSerializer(j2jrs);
// // 序列化 key 时
// StringRedisSerializer srs = new StringRedisSerializer();
// template.setKeySerializer(srs);
// template.setHashKeySerializer(srs);
// template.afterPropertiesSet();
// return template;
// }
//
// /**
// * 配置redis缓存管理器,将序列化机制设置为json格式 设置为默认缓存管理器
// *
// * @param redisConnectionFactory
// * @return
// */
// @Primary
// @Bean
// public RedisCacheManager redisCacheManager(RedisConnectionFactory redisConnectionFactory) {
// RedisCacheConfiguration redisCacheConfiguration = RedisCacheConfiguration.defaultCacheConfig()
// // 设置缓存有效期一小时
// .entryTtl(Duration.ofHours(1));
// Jackson2JsonRedisSerializer ser = new Jackson2JsonRedisSerializer(Object.class);
// redisCacheConfiguration = redisCacheConfiguration.serializeValuesWith(RedisSerializationContext.SerializationPair
// .fromSerializer(ser));
// return RedisCacheManager
// .builder(RedisCacheWriter.nonLockingRedisCacheWriter(redisConnectionFactory))
// .cacheDefaults(redisCacheConfiguration).build();
// }
//}
package com.yeejoin.precontrol.config;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.SwaggerDefinition;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import springfox.documentation.builders.ApiInfoBuilder;
import springfox.documentation.builders.ParameterBuilder;
import springfox.documentation.builders.PathSelectors;
import springfox.documentation.builders.RequestHandlerSelectors;
import springfox.documentation.schema.ModelRef;
import springfox.documentation.service.ApiInfo;
import springfox.documentation.service.Contact;
import springfox.documentation.service.Parameter;
import springfox.documentation.spi.DocumentationType;
import springfox.documentation.spring.web.plugins.Docket;
import java.util.ArrayList;
import java.util.List;
/**
* swagger配置类 模块如果需要引入则引入
*
* @author duanwei
*/
@Configuration
//@SwaggerDefinition
public class SwaggerConfig {
@Bean
public Docket api() {
ParameterBuilder tokenPar1 = new ParameterBuilder();
ParameterBuilder tokenPar2 = new ParameterBuilder();
ParameterBuilder tokenPar3 = new ParameterBuilder();
//header中的ticket参数非必填,传空也可以
//根据每个方法名也知道当前方法在设置什么参数
List<Parameter> pars = new ArrayList<Parameter>();
tokenPar1.name("token").description("用户token")
.modelRef(new ModelRef("string")).parameterType("header")
.required(false).build();
tokenPar2.name("appKey").description("appkey").modelRef(new ModelRef("string")).parameterType("header").defaultValue("studio_normalapp_2075166")
.required(false).build();
tokenPar3.name("product").description("product").modelRef(new ModelRef("string")).parameterType("header").defaultValue("STUDIO_APP_WEB")
.required(false).build();
pars.add(tokenPar1.build());
pars.add(tokenPar2.build());
pars.add(tokenPar3.build());
return new Docket(DocumentationType.SWAGGER_2)
.enable(true)
.apiInfo(apiInfo())
.select()
.apis(RequestHandlerSelectors.withMethodAnnotation(ApiOperation.class))
.paths(PathSelectors.any())
.build().globalOperationParameters(pars);
}
/**
* 构建api文档
*
* @return
*/
private ApiInfo apiInfo() {
return new ApiInfoBuilder()
//页面标题
.title("RestFul API")
//创建人
.contact(new Contact("duanwei", "", ""))
//版本号
.version("1.0")
//描述
.description("API 描述")
.build();
}
}
\ No newline at end of file
//package com.yeejoin.precontrol.config;
//
//
//import lombok.extern.slf4j.Slf4j;
//import org.springframework.stereotype.Component;
//
//import javax.annotation.PostConstruct;
//import javax.websocket.*;
//import javax.websocket.server.ServerEndpoint;
//import java.io.IOException;
//import java.util.concurrent.CopyOnWriteArraySet;
//import java.util.concurrent.atomic.AtomicInteger;
//
//
///**
// * @author zhengkai.blog.csdn.net
// */
//@ServerEndpoint(value = "/ws/asset")
//@Component
//@Slf4j
//public class WebSocketServer {
//
// @PostConstruct
// public void init() {
// log.info("websocket 加载");
// }
//
// private static final AtomicInteger ONLINECOUNT = new AtomicInteger(0);
//
// /**
// * concurrent包的线程安全Set,用来存放每个客户端对应的Session对象。
// */
// private static CopyOnWriteArraySet<Session> SessionSet = new CopyOnWriteArraySet<Session>();
//
//
// /**
// * 连接建立成功调用的方法
// */
// @OnOpen
// public void onOpen(Session session) {
// SessionSet.add(session);
// // 在线数加1
// int cnt = ONLINECOUNT.incrementAndGet();
// log.info("有连接加入,当前连接数为:{}", cnt);
// sendMessage(session, "连接成功");
// }
//
// /**
// * 连接关闭调用的方法
// */
// @OnClose
// public void onClose(Session session) {
// SessionSet.remove(session);
// int cnt = ONLINECOUNT.decrementAndGet();
// log.info("有连接关闭,当前连接数为:{}", cnt);
// }
//
// /**
// * 收到客户端消息后调用的方法
// *
// * @param message 客户端发送过来的消息
// */
// @OnMessage
// public void onMessage(String message, Session session) {
// log.info("来自客户端的消息:{}", message);
// sendMessage(session, "收到消息,消息内容:" + message);
//
// }
//
// /**
// * 出现错误
// *
// * @param session
// * @param error
// */
// @OnError
// public void onError(Session session, Throwable error) {
// log.error("发生错误:{},Session ID: {}", error.getMessage(), session.getId());
// error.printStackTrace();
// }
//
// /**
// * 发送消息,实践表明,每次浏览器刷新,session会发生变化。
// *
// * @param session
// * @param message
// */
// public static void sendMessage(Session session, String message) {
// try {
// session.getBasicRemote().sendText(String.format("%s (From Server,Session ID=%s)", message, session.getId()));
// } catch (IOException e) {
// log.error("发送消息出错:{}", e.getMessage());
// e.printStackTrace();
// }
// }
//
// /**
// * 群发消息
// *
// * @param message
// * @throws IOException
// */
// public static void broadCastInfo(String message) throws IOException {
// for (Session session : SessionSet) {
// if (session.isOpen()) {
// sendMessage(session, message);
// }
// }
// }
//
// /**
// * 指定Session发送消息
// *
// * @param sessionId
// * @param message
// * @throws IOException
// */
// public static void sendMessage(String message, String sessionId) throws IOException {
// Session session = null;
// for (Session s : SessionSet) {
// if (s.getId().equals(sessionId)) {
// session = s;
// break;
// }
// }
// if (session != null) {
// sendMessage(session, message);
// } else {
// log.warn("没有找到你指定ID的会话:{}", sessionId);
// }
// }
//
//}
\ No newline at end of file
package com.yeejoin.precontrol.controller;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.List;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.MediaType;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;
import com.alibaba.fastjson.JSONObject;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.yeejoin.precontrol.common.entity.Person;
import com.yeejoin.precontrol.common.entity.PersonAscription;
import com.yeejoin.precontrol.common.entity.PersonClock;
import com.yeejoin.precontrol.common.entity.Project;
import com.yeejoin.precontrol.common.entity.ProjectDevice;
import com.yeejoin.precontrol.common.entity.access.AccessInfo;
import com.yeejoin.precontrol.common.entity.access.CommInfo;
import com.yeejoin.precontrol.common.entity.access.DoorOpenAndShowTips;
import com.yeejoin.precontrol.common.entity.access.Event;
import com.yeejoin.precontrol.common.entity.access.HttpAccessVerifyParam;
import com.yeejoin.precontrol.common.entity.access.HttpAccessVerifyResult;
import com.yeejoin.precontrol.common.entity.access.PersonInfo;
import com.yeejoin.precontrol.common.entity.access.PictureAck;
import com.yeejoin.precontrol.common.entity.access.RecognizeResult;
import com.yeejoin.precontrol.common.exception.BaseException;
import com.yeejoin.precontrol.common.service.IPersonAccessService;
import com.yeejoin.precontrol.common.service.IPersonAscriptionService;
import com.yeejoin.precontrol.common.service.IPersonClockService;
import com.yeejoin.precontrol.common.service.IPersonService;
import com.yeejoin.precontrol.common.service.IProjectDeviceService;
import com.yeejoin.precontrol.common.service.IProjectService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import springfox.documentation.annotations.ApiIgnore;
/**
* 门禁
*
* @author duanwei
* @date 2020-07-06
*/
@RestController
@ApiIgnore
@Api(tags = " 门禁")
@RequestMapping(value = "/access", produces = MediaType.APPLICATION_JSON_UTF8_VALUE)
public class AccessController {
@Autowired
IPersonAccessService iPersonAccessService;
@Autowired
IPersonService iPersonService;
@Autowired
IProjectDeviceService iProjectDeviceService;
@Autowired
IPersonAscriptionService iPersonAscriptionService;
@Autowired
IProjectService iProjectService;
@Autowired
IPersonClockService iPersonClockService;
/**
* 门禁信令连接
*
* @return
*/
@RequestMapping(value = "/connect", method = RequestMethod.GET)
@ApiOperation(httpMethod = "GET", value = " 门禁信令连接", notes = "门禁信令连接")
public Object connect() {
System.out.println("门禁心跳运行中...");
return null;
}
/**
* 人脸认证推送
*
* @return
*/
@RequestMapping(value = "/faceVerify", method = RequestMethod.POST)
@ApiOperation(httpMethod = "POST", value = "人脸认证推送", notes = "人脸认证推送")
public Object faceVerify(String json) {
System.out.println(json);
HttpAccessVerifyParam param = JSONObject.parseObject(json, HttpAccessVerifyParam.class);
int PicID = param.getPicID();
List<Event> Events = param.getEvents();
List<RecognizeResult> RecognizeResults = Events.get(0).getRecognizeResults();
AccessInfo AccessInfo = Events.get(0).getAccessInfo();
CommInfo CommInfo = Events.get(0).getCommInfo();
HttpAccessVerifyResult result = new HttpAccessVerifyResult();
if (AccessInfo.getPassResult() == 1) {
ProjectDevice projectDevice = iProjectDeviceService.getOne(
new LambdaQueryWrapper<ProjectDevice>().eq(ProjectDevice::getNumber, CommInfo.getSerialNo()));
PersonInfo personInfo = RecognizeResults.get(0).getPersonInfo();
PictureAck pictureAck = new PictureAck();
pictureAck.setPicID(PicID);
pictureAck.setResult(true);
DoorOpenAndShowTips doorOpenAndShowTips = new DoorOpenAndShowTips();
doorOpenAndShowTips.setType("both");
if (projectDevice == null) {
doorOpenAndShowTips.setCustomtip("设备未绑定项目");
} else {
Person person = iPersonService
.getOne(new LambdaQueryWrapper<Person>().eq(Person::getUserId, personInfo.getID()));
try {
if ("入向".equals(projectDevice.getDirect())) {
iPersonAccessService.enterJudge(person);
doorOpenAndShowTips.setCustomtip("入场成功");
saveClock(person, 0);
} else if ("出向".equals(projectDevice.getDirect())) {
doorOpenAndShowTips.setCustomtip("出场成功");
saveClock(person, 1);
} else {
doorOpenAndShowTips.setCustomtip("设备未选择方向");
}
} catch (BaseException e) {
doorOpenAndShowTips.setCustomtip(e.getMessage());
}
}
result.setPictureAck(pictureAck);
result.setDoorOpenAndShowTips(doorOpenAndShowTips);
} else if (AccessInfo.getPassResult() == 16) {
PictureAck pictureAck = new PictureAck();
pictureAck.setPicID(PicID);
pictureAck.setResult(true);
DoorOpenAndShowTips doorOpenAndShowTips = new DoorOpenAndShowTips();
doorOpenAndShowTips.setType("both");
doorOpenAndShowTips.setCustomtip("未识别的人员");
result.setPictureAck(pictureAck);
result.setDoorOpenAndShowTips(doorOpenAndShowTips);
}
return JSONObject.toJSON(result);
}
private void saveClock(Person person,int direct) {
PersonAscription personAscription = iPersonAscriptionService
.getOne(new LambdaQueryWrapper<PersonAscription>().eq(PersonAscription::getPersonId, person.getId()));
Project project = iProjectService
.getOne(new LambdaQueryWrapper<Project>().eq(Project::getId, personAscription.getProjectId()));
PersonClock personClock = new PersonClock();
personClock.setPersonId(Long.valueOf(person.getId()));
personClock.setInOrOut(direct);
try {
SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd");
personClock.setClockDate(dateFormat.parse(dateFormat.format(new Date())));
} catch (ParseException e) {
throw new BaseException("日期转换错误");
}
personClock.setClockCompanyId(personAscription != null ? personAscription.getCompanyId() : null);
personClock.setClockTime(new Date());
personClock
.setClockProjectId(personAscription != null ? String.valueOf(personAscription.getProjectId()) : null);
personClock.setClockProject(project.getName());
personClock.setClockAddress(project.getAddress());
personClock.setOrgCode(person.getOrgCode());
iPersonClockService.save(personClock);
}
}
package com.yeejoin.precontrol.controller;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.yeejoin.precontrol.common.service.IBadManagementService;
import com.yeejoin.precontrol.common.vo.BadManagementVo;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.MediaType;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;
import springfox.documentation.annotations.ApiIgnore;
@RestController
@ApiIgnore
@Api(tags = " 分包商违章Api")
@RequestMapping(value = "/badManagement", produces = MediaType.APPLICATION_JSON_UTF8_VALUE)
public class BadManagementController {
@Autowired
IBadManagementService IBadManagementService;
@ApiOperation(httpMethod = "GET", value = "根据公司ID分页查询违章信息")
@RequestMapping(value = "/list", method = RequestMethod.GET)
public Page<BadManagementVo> pageList(Long pageNum, Long pageSize, String companyId) {
return IBadManagementService.pageList(pageNum, pageSize, companyId);
}
}
package com.yeejoin.precontrol.controller;
import com.yeejoin.precontrol.common.enums.TaskStatusEnum;
import com.yeejoin.precontrol.common.enums.TaskTypeEnum;
import com.yeejoin.precontrol.common.service.IBaseService;
import com.yeejoin.precontrol.common.service.SmallProService;
import com.yeejoin.precontrol.common.utils.CommonResponseUtil;
import com.yeejoin.precontrol.common.utils.RedisUtil;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.http.MediaType;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
/**
* 项目信息
*
* @author duanwei
* @date 2020-06-30
*/
@RestController
@Api(tags = "公共API")
@RequestMapping(value = "/common", produces = MediaType.APPLICATION_JSON_UTF8_VALUE)
public class CommonController {
/**
* 小程序应用id
*/
@Value("${smallProgram.appid}")
private String appId;
/**
* 小程序应用secret
*/
@Value("${smallProgram.secret}")
private String secret;
/**
* 缓存工具类
*/
@Autowired
RedisUtil redisUtil;
/**
* 通用查询服务
*/
@Autowired
IBaseService iBaseService;
/**
* 小程序服务
*/
@Autowired
SmallProService smallProService;
/**
* 获取token
*
* @return
*/
@RequestMapping(value = "/getToken", method = RequestMethod.GET)
@ApiOperation(httpMethod = "GET", value = "获取token", notes = "获取token")
public Object getToken() {
String token = smallProService.getSmallProToken();
return token;
}
/**
* 通过code换 请求openId链接
*
* @return
*/
@RequestMapping(value = "/exchangeSmallProMesssage", method = RequestMethod.GET)
@ApiOperation(httpMethod = "GET", value = "通过code换 请求openId链接", notes = "通过code换 请求openId链接")
public Object exchangeSmallProMesssage(String json_code) {
String url = "https://api.weixin.qq.com/sns/jscode2session?appid=" + appId + "&secret=" + secret + "&js_code=" + json_code
+ "&grant_type=authorization_code";
return url;
}
/**
* 获取作业活动类型
* @return
*/
@GetMapping(value = "get/activity/type")
@ApiOperation(value = "获取作业活动类型", notes = "获取作业活动类型")
public Object getActivityType() {
TaskTypeEnum[] values = TaskTypeEnum.values();
List<Map<String, Object>> list = new ArrayList<>();
for (TaskTypeEnum value : values) {
if(value.getValue().equals(4L)){
continue;
}
Map<String, Object> map = new HashMap();
map.put("key",value.getValue());
map.put("value", value.getLabel());
list.add(map);
}
return CommonResponseUtil.success(list);
}
/**
* 获取作业活动状态
* @return
*/
@GetMapping(value = "get/activity/status")
@ApiOperation(value = "获取作业活动状态", notes = "获取作业活动状态")
public Object getActivityStatus() {
TaskStatusEnum[] values = TaskStatusEnum.values();
List<Map<String, Object>> list = new ArrayList<>();
for (TaskStatusEnum value : values) {
Map<String, Object> map = new HashMap();
map.put("key",value.getType());
map.put("value", value.getName());
list.add(map);
}
return CommonResponseUtil.success(list);
}
}
package com.yeejoin.precontrol.controller;
import java.util.Arrays;
import java.util.List;
import javax.servlet.http.HttpServletRequest;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.MediaType;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;
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.yeejoin.precontrol.common.dto.CompanyDepartmentDto;
import com.yeejoin.precontrol.common.entity.CompanyDepartment;
import com.yeejoin.precontrol.common.service.ICompanyDepartmentService;
import com.yeejoin.precontrol.common.utils.NameUtils;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
/**
* 部门信息
*
* @author duanwei
* @date 2021-09-07
*/
@RestController
@Api(tags = "部门信息Api")
@RequestMapping(value = "/company-department", produces = MediaType.APPLICATION_JSON_UTF8_VALUE)
public class CompanyDepartmentController {
@Autowired
ICompanyDepartmentService iCompanyDepartmentService;
/**
* 新增部门信息
*
* @return
*/
@RequestMapping(value = "/save", method = RequestMethod.POST)
@ApiOperation(httpMethod = "POST", value = "新增部门信息", notes = "新增部门信息")
public boolean saveCompanyDepartment(HttpServletRequest request, @RequestBody CompanyDepartment companyDepartment) {
return iCompanyDepartmentService.saveOne(companyDepartment);
}
/**
* 根据id删除
*
* @param id
* @return
*/
@RequestMapping(value = "/{id}", method = RequestMethod.DELETE)
@ApiOperation(httpMethod = "DELETE", value = "根据id删除", notes = "根据id删除")
public boolean deleteById(HttpServletRequest request, @PathVariable Long id) {
return iCompanyDepartmentService.removeTreeById(id);
}
/**
* 修改部门信息
*
* @return
*/
@RequestMapping(value = "/updateById", method = RequestMethod.PUT)
@ApiOperation(httpMethod = "PUT", value = "修改部门信息", notes = "修改部门信息")
public boolean updateByIdCompanyDepartment(HttpServletRequest request,
@RequestBody CompanyDepartment companyDepartment) {
return iCompanyDepartmentService.updateOneById(companyDepartment);
}
/**
* 根据id查询
*
* @param id
* @return
*/
@RequestMapping(value = "/{id}", method = RequestMethod.GET)
@ApiOperation(httpMethod = "GET", value = "根据id查询", notes = "根据id查询")
public CompanyDepartment selectById(HttpServletRequest request, @PathVariable Long id) {
return iCompanyDepartmentService.getById(id);
}
/**
* 列表分页查询
*
* @return
*/
@RequestMapping(value = "/list", method = RequestMethod.GET)
@ApiOperation(httpMethod = "GET", value = "列表分页查询", notes = "列表分页查询")
public IPage<CompanyDepartment> listPage(String pageNum, String pageSize, CompanyDepartment companyDepartment) {
Page<CompanyDepartment> pageBean;
QueryWrapper<CompanyDepartment> companyDepartmentQueryWrapper = new QueryWrapper<>();
Class<? extends CompanyDepartment> aClass = companyDepartment.getClass();
Arrays.stream(aClass.getDeclaredFields()).forEach(field -> {
try {
field.setAccessible(true);
Object o = field.get(companyDepartment);
if (o != null) {
Class<?> type = field.getType();
String name = NameUtils.camel2Underline(field.getName());
if (type.equals(Integer.class)) {
Integer fileValue = (Integer) field.get(companyDepartment);
companyDepartmentQueryWrapper.eq(name, fileValue);
} else if (type.equals(Long.class)) {
Long fileValue = (Long) field.get(companyDepartment);
companyDepartmentQueryWrapper.eq(name, fileValue);
} else if (type.equals(String.class)) {
String fileValue = (String) field.get(companyDepartment);
companyDepartmentQueryWrapper.eq(name, fileValue);
} else {
String fileValue = (String) field.get(companyDepartment);
companyDepartmentQueryWrapper.eq(name, fileValue);
}
}
} catch (Exception e) {
}
});
IPage<CompanyDepartment> page;
if (StringUtils.isBlank(pageNum) || StringUtils.isBlank(pageSize)) {
pageBean = new Page<>(0, Long.MAX_VALUE);
} else {
pageBean = new Page<>(Integer.parseInt(pageNum), Integer.parseInt(pageSize));
}
page = iCompanyDepartmentService.page(pageBean, companyDepartmentQueryWrapper);
return page;
}
/**
* 查询部门树
*
* @param id
* @return
*/
@RequestMapping(value = "/tree/{companyId}", method = RequestMethod.GET)
@ApiOperation(httpMethod = "GET", value = "根据id查询", notes = "根据id查询")
public List<CompanyDepartmentDto> treeById(HttpServletRequest request, @PathVariable Long companyId, String name) {
return iCompanyDepartmentService.treeByCompanyId(companyId, name);
}
}
package com.yeejoin.precontrol.controller;
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.yeejoin.precontrol.common.entity.CompanyEvaluationLog;
import com.yeejoin.precontrol.common.entity.UserEvaluationLog;
import com.yeejoin.precontrol.common.service.ICompanyEvaluationLogService;
import com.yeejoin.precontrol.common.utils.NameUtils;
import com.yeejoin.precontrol.common.vo.CompanyEvaluationLogVo;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.MediaType;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;
import org.typroject.tyboot.core.restful.exception.instance.BadRequest;
import javax.servlet.http.HttpServletRequest;
import java.util.Arrays;
import java.util.List;
import java.util.Optional;
/**
* 分包商评价记录表
*
* @author tb
* @date 2021-01-28
*/
@RestController
@Api(tags = "分包商评价记录表Api")
@RequestMapping(value = "/company-evaluation-log", produces = MediaType.APPLICATION_JSON_UTF8_VALUE)
public class CompanyEvaluationLogController {
@Autowired
ICompanyEvaluationLogService iCompanyEvaluationLogService;
/**
* 新增分包商评价记录表
*
* @return
*/
@RequestMapping(value = "/save", method = RequestMethod.POST)
@ApiOperation(httpMethod = "POST", value = "新增分包商评价记录表", notes = "新增分包商评价记录表")
public boolean saveCompanyEvaluationLog(HttpServletRequest request, @RequestBody CompanyEvaluationLog companyEvaluationLog) {
Optional.ofNullable(companyEvaluationLog.getEvaluationUserId()).orElseThrow(() -> new BadRequest("评价人不能为空"));
Optional.ofNullable(companyEvaluationLog.getCompanyId()).orElseThrow(() -> new BadRequest("分包商不能为空"));
Optional.ofNullable(companyEvaluationLog.getRate()).orElseThrow(() -> new BadRequest("评分不能为空"));
return iCompanyEvaluationLogService.save(companyEvaluationLog);
}
/**
* 根据id删除
*
* @param id
* @return
*/
@RequestMapping(value = "/{id}", method = RequestMethod.DELETE)
@ApiOperation(httpMethod = "DELETE", value = "根据id删除", notes = "根据id删除")
public boolean deleteById(HttpServletRequest request, @PathVariable Long id) {
return iCompanyEvaluationLogService.removeById(id);
}
/**
* 根据分包商id查询列表分页
*
* @return
*/
@RequestMapping(value = "/{companyId}/page/list", method = RequestMethod.GET)
@ApiOperation(httpMethod = "GET", value = "根据分包商id查询列表分页", notes = "根据分包商id查询列表分页")
public IPage<CompanyEvaluationLog> listByCompanyId(String pageNum, String pageSize, @PathVariable String companyId) {
return iCompanyEvaluationLogService.listByCompanyId(pageNum, pageSize, companyId);
}
/**
* 根据分包商id查询列表分页
*
* @return
*/
@RequestMapping(value = "/{companyId}/page/list/vo", method = RequestMethod.GET)
@ApiOperation(httpMethod = "GET", value = "根据分包商id查询列表分页", notes = "根据分包商id查询列表分页")
public IPage<CompanyEvaluationLogVo> listVoByCompanyId(String pageNum, String pageSize, @PathVariable String companyId) {
return iCompanyEvaluationLogService.listVoByCompanyId(pageNum, pageSize, companyId);
}
/**
* 根据被评价人id查询列表分页
*
* @return
*/
@RequestMapping(value = "/{taskId}/list", method = RequestMethod.GET)
@ApiOperation(httpMethod = "GET", value = "根据被任务id查询列表分页", notes = "根据被任务id查询列表分页")
public List<CompanyEvaluationLog> listByTaskId(@PathVariable String taskId) {
return iCompanyEvaluationLogService.listByTaskId(taskId);
}
/**
* 列表分页查询
*
* @return
*/
@RequestMapping(value = "/list", method = RequestMethod.GET)
@ApiOperation(httpMethod = "GET", value = "列表分页查询", notes = "列表分页查询")
public IPage<CompanyEvaluationLog> listPage(String pageNum, String pageSize,
CompanyEvaluationLog companyEvaluationLog) {
Page<CompanyEvaluationLog> pageBean;
QueryWrapper<CompanyEvaluationLog> companyEvaluationLogQueryWrapper = new QueryWrapper<>();
Class<? extends CompanyEvaluationLog> aClass = companyEvaluationLog.getClass();
Arrays.stream(aClass.getDeclaredFields()).forEach(field -> {
try {
field.setAccessible(true);
Object o = field.get(companyEvaluationLog);
if (o != null) {
Class<?> type = field.getType();
String name = NameUtils.camel2Underline(field.getName());
if (type.equals(Integer.class)) {
Integer fileValue = (Integer) field.get(companyEvaluationLog);
companyEvaluationLogQueryWrapper.eq(name, fileValue);
} else if (type.equals(Long.class)) {
Long fileValue = (Long) field.get(companyEvaluationLog);
companyEvaluationLogQueryWrapper.eq(name, fileValue);
} else if (type.equals(String.class)) {
String fileValue = (String) field.get(companyEvaluationLog);
companyEvaluationLogQueryWrapper.eq(name, fileValue);
} else {
String fileValue = (String) field.get(companyEvaluationLog);
companyEvaluationLogQueryWrapper.eq(name, fileValue);
}
}
} catch (Exception e) {
}
});
IPage<CompanyEvaluationLog> page;
if (StringUtils.isBlank(pageNum) || StringUtils.isBlank(pageSize)) {
pageBean = new Page<>(0, Long.MAX_VALUE);
} else {
pageBean = new Page<>(Integer.parseInt(pageNum), Integer.parseInt(pageSize));
}
page = iCompanyEvaluationLogService.page(pageBean, companyEvaluationLogQueryWrapper);
return page;
}
}
\ No newline at end of file
package com.yeejoin.precontrol.controller;
import com.yeejoin.amos.feign.systemctl.Systemctl;
import com.yeejoin.amos.feign.systemctl.model.DictionarieValueModel;
import com.yeejoin.precontrol.common.utils.CommonResponseUtil;
import io.swagger.annotations.ApiOperation;
import org.springframework.http.MediaType;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;
import springfox.documentation.annotations.ApiIgnore;
import java.util.List;
/**
* 字典controller
*
* @author sqy
*/
@ApiIgnore
@RestController
@RequestMapping(value = "/dictionarie", produces = MediaType.APPLICATION_JSON_UTF8_VALUE)
public class DictionarieController {
@RequestMapping(value = "/{dictCode}", method = RequestMethod.GET)
@ApiOperation(httpMethod = "GET", value = "根据code查询字典", notes = "根据code查询字典")
public Object getDictValues(@PathVariable String dictCode) {
try {
List<DictionarieValueModel> result = Systemctl.dictionarieClient.dictValues(dictCode).getResult();
return result;
} catch (Exception e) {
return CommonResponseUtil.failure("查询失败");
}
}
}
package com.yeejoin.precontrol.controller;
import com.yeejoin.precontrol.common.entity.Districts;
import com.yeejoin.precontrol.common.service.IDistrictsService;
import com.yeejoin.precontrol.common.utils.RedisUtil;
import com.yeejoin.precontrol.common.vo.DistrictVo;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.MediaType;
import org.springframework.web.bind.annotation.*;
import springfox.documentation.annotations.ApiIgnore;
import javax.servlet.http.HttpServletRequest;
import java.util.ArrayList;
import java.util.List;
/**
* 地区
*
* @author duanwei
* @date 2020-07-06
*/
@RestController
@ApiIgnore
@Api(tags = "地区Api")
@RequestMapping(value = "/districts", produces = MediaType.APPLICATION_JSON_UTF8_VALUE)
public class DistrictsController {
/**
* 省市区服务
*/
@Autowired
IDistrictsService iDistrictsService;
/**
* 缓存服务
*/
@Autowired
RedisUtil redisUtil;
/**
* 新增地区
*
* @return
*/
@RequestMapping(value = "/save", method = RequestMethod.POST)
@ApiOperation(httpMethod = "POST", value = "新增地区", notes = "新增地区")
public Object saveDistricts(HttpServletRequest request, @RequestBody Districts districts) {
return iDistrictsService.save(districts);
}
/**
* 根据id删除
*
* @param id
* @return
*/
@RequestMapping(value = "/{id}", method = RequestMethod.DELETE)
@ApiOperation(httpMethod = "DELETE", value = "根据id删除", notes = "根据id删除")
public boolean deleteById(HttpServletRequest request, @PathVariable Long id) {
return iDistrictsService.removeById(id);
}
/**
* 根据ids删除
*
* @param ids
* @return
*/
@RequestMapping(value = "/ids/{ids}", method = RequestMethod.DELETE)
@ApiOperation(httpMethod = "DELETE", value = "根据ids删除", notes = "根据ids删除")
public boolean deleteById(HttpServletRequest request, @PathVariable List<String> ids) {
return iDistrictsService.removeByIds(ids);
}
/**
* 修改地区
*
* @return
*/
@RequestMapping(value = "/updateById", method = RequestMethod.PUT)
@ApiOperation(httpMethod = "PUT", value = "修改地区", notes = "修改地区")
public boolean updateByIdDistricts(HttpServletRequest request, @RequestBody Districts districts) {
return iDistrictsService.updateById(districts);
}
/**
* 根据id查询
*
* @param id
* @return
*/
@RequestMapping(value = "/{id}", method = RequestMethod.GET)
@ApiOperation(httpMethod = "GET", value = "根据id查询", notes = "根据id查询")
public Districts selectById(HttpServletRequest request, @PathVariable Long id) {
return iDistrictsService.getById(id);
}
/**
* 列表分页查询
*
* @return
*/
@RequestMapping(value = "/tree", method = RequestMethod.GET)
@ApiOperation(httpMethod = "GET", value = "列表tree查询", notes = "列表tree查询")
public Object tree() {
if (redisUtil.hasKey("city")) {
return redisUtil.get("city");
}
List<Districts> list = iDistrictsService.list();
List<DistrictVo> districtVos = new ArrayList<>();
list.forEach(d -> {
DistrictVo districtVo = new DistrictVo();
districtVo.setLabel(d.getExtName());
districtVo.setValue(String.valueOf(d.getId()));
districtVo.setId(d.getId());
districtVo.setPid(d.getPid());
districtVos.add(districtVo);
});
List<DistrictVo> menuTreeList = getMenuTreeList(0L, districtVos);
redisUtil.set("city", menuTreeList, 3600);
return menuTreeList;
}
/**
* 递归循环
*
* @param pid
* @param list
* @return
*/
private List<DistrictVo> getMenuTreeList(Long pid, List<DistrictVo> list) {
List<DistrictVo> childrenList = new ArrayList<>();
for (int i = 0; i < list.size(); i++) {
DistrictVo districtVo = list.get(i);
if (districtVo.getPid().equals(pid)) {
districtVo.setChildren(getMenuTreeList(districtVo.getId(), list));
childrenList.add(districtVo);
}
}
return childrenList;
}
}
package com.yeejoin.precontrol.controller;
import java.util.List;
import java.util.UUID;
import java.util.stream.Collectors;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.MediaType;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.yeejoin.precontrol.common.annotations.OpsLog;
import com.yeejoin.precontrol.common.dto.CommonPageableDto;
import com.yeejoin.precontrol.common.dto.HazardousWorkDto;
import com.yeejoin.precontrol.common.dto.HazardousWorkPageDto;
import com.yeejoin.precontrol.common.dto.InputItemDto;
import com.yeejoin.precontrol.common.entity.HazardousWork;
import com.yeejoin.precontrol.common.entity.HazardousWorkRefInputItem;
import com.yeejoin.precontrol.common.entity.InputItem;
import com.yeejoin.precontrol.common.entity.Person;
import com.yeejoin.precontrol.common.entity.RiskWorkHazadousWork;
import com.yeejoin.precontrol.common.enums.OpsLogEnum;
import com.yeejoin.precontrol.common.exception.BaseException;
import com.yeejoin.precontrol.common.service.IHazardousWorkRefInputItemService;
import com.yeejoin.precontrol.common.service.IHazardousWorkService;
import com.yeejoin.precontrol.common.service.IInputItemService;
import com.yeejoin.precontrol.common.service.IPersonService;
import com.yeejoin.precontrol.common.service.IRiskWorkHazadousWorkService;
import com.yeejoin.precontrol.common.utils.FileHelper;
import com.yeejoin.precontrol.common.utils.StringUtil;
import com.yeejoin.precontrol.common.vo.HazardousWorkPageVo;
import com.yeejoin.precontrol.common.vo.HazardousWorkVo;
import com.yeejoin.precontrol.controller.publics.BaseController;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
/**
* 危险作业表
*
* @author duanwei
* @date 2020-08-24
*/
@RestController
@Api(tags = "危险作业表Api")
@RequestMapping(value = "/hazardous-work", produces = MediaType.APPLICATION_JSON_UTF8_VALUE)
public class HazardousWorkController extends BaseController {
/**
* 危险作业服务
*/
@Autowired
IHazardousWorkService iHazardousWorkService;
/**
* 检查项服务
*/
@Autowired
IInputItemService iInputItemService;
/**
* 用户服务
*/
@Autowired
IPersonService iPersonService;
/**
* 检查项关联危险作业服务
*/
@Autowired
IHazardousWorkRefInputItemService iHazardousWorkRefInputItemService;
@Autowired
IRiskWorkHazadousWorkService iRiskWorkHazadousWorkService;
/**
* 新增危险作业表
*
* @return
*/
@RequestMapping(value = "/saveOrUpdate", method = RequestMethod.POST)
@ApiOperation(httpMethod = "POST", value = "新增危险作业表", notes = "新增危险作业表")
@OpsLog(value = OpsLogEnum.EDIT_HAZARDOUSWORK)
public boolean saveOrUpdate(HttpServletRequest request, @RequestBody HazardousWorkDto hazardousWorkDto) {
Person person = getPerson();
HazardousWork hazardousWork = new HazardousWork();
BeanUtils.copyProperties(hazardousWorkDto, hazardousWork);
hazardousWork.setCPersonId(person.getId());
if (hazardousWorkDto.getId() == null) {
// 存储
List<HazardousWork> list = iHazardousWorkService.list(
new LambdaQueryWrapper<HazardousWork>().eq(HazardousWork::getName, hazardousWorkDto.getName()));
if (StringUtil.isNotEmpty(list)) {
throw new BaseException("作业名称重复,已经存在");
}
iHazardousWorkService.save(hazardousWork);
} else {
iHazardousWorkService.updateById(hazardousWork);
deleteHazarDousWork(hazardousWork.getId());
}
saveHazarDousWork(hazardousWorkDto, hazardousWork);
return true;
}
/**
* 根据id删除
*
* @param id
* @return
*/
@RequestMapping(value = "/{id}", method = RequestMethod.DELETE)
@ApiOperation(httpMethod = "DELETE", value = "根据id删除", notes = "根据id删除")
public boolean deleteById(HttpServletRequest request, @PathVariable Long id) {
// 删除风险作业
iHazardousWorkService.removeById(id);
// 根据风险作业id删除 检查项和关联关系
deleteHazarDousWork(id);
return true;
}
/**
* 根据ids删除 多个
*
* @return
*/
@RequestMapping(value = "/ids/{ids}", method = RequestMethod.DELETE)
@ApiOperation(httpMethod = "DELETE", value = "根据ids删除", notes = "根据ids删除")
@OpsLog(value = OpsLogEnum.DELETE_HAZARDOUSWORK)
public boolean deleteById(HttpServletRequest request, @PathVariable List<Long> ids) {
int count = iRiskWorkHazadousWorkService.count(
new LambdaQueryWrapper<RiskWorkHazadousWork>().in(RiskWorkHazadousWork::getHarzadousWorkId, ids));
if (count > 0) {
throw new BaseException("被风险作业引用,无法删除");
}
for (Long id : ids) {
// 删除风险作业
iHazardousWorkService.removeById(id);
// 根据风险作业id删除 检查项和关联关系
deleteHazarDousWork(id);
}
return true;
}
/**
* 根据id查询
*
* @param id
* @return
*/
@RequestMapping(value = "/{id}", method = RequestMethod.GET)
@ApiOperation(httpMethod = "GET", value = "根据id查询", notes = "根据id查询")
public Object selectById(HttpServletRequest request, @PathVariable Long id) {
HazardousWorkVo hazardousWorkVo = iHazardousWorkService.getHazardousWorkVo(id);
return hazardousWorkVo;
}
/**
* 列表分页查询
*
* @return
*/
@RequestMapping(value = "/list", method = RequestMethod.GET)
@ApiOperation(httpMethod = "GET", value = "列表分页查询", notes = "列表分页查询")
public Object listPage(@ApiParam(value = "分页条件 isAll=0 具体分页必传") CommonPageableDto pageable,
@ApiParam(value = "查询参数") HazardousWorkPageDto hazardousWorkPageDto,
@ApiParam(value = "类型 0查询列表 1 导出列表") @RequestParam Long operType,
@ApiParam(value = "查询Ids") @RequestParam(required = false) List<Long> ids, HttpServletResponse response) {
String fileName = UUID.randomUUID().toString() + ".xls";
if (StringUtil.isNotEmpty(ids)) {
hazardousWorkPageDto.setIds(ids);
}
IPage<HazardousWorkPageVo> page = iHazardousWorkService.listByPage(pageable, hazardousWorkPageDto);
if (operType == 1) {
List<HazardousWorkPageVo> excelList = page.getRecords();
for (HazardousWorkPageVo hazardousWorkPageVo : excelList) {
Long cPersonId = hazardousWorkPageVo.getCreatePersonId();
Person person = iPersonService.getById(cPersonId);
if (person != null) {
hazardousWorkPageVo.setCreatePersonName(person.getName());
}
}
FileHelper.exportExcel(excelList, "危险作业管理", "危险作业管理信息", HazardousWorkPageVo.class, fileName, response);
return null;
} else {
return page;
}
}
@RequestMapping(value = "/list-all", method = RequestMethod.GET)
@ApiOperation(httpMethod = "GET", value = "下拉列表查询", notes = "下拉列表查询")
public List<HazardousWork> listAll() {
return iHazardousWorkService.list();
}
/**
* 保存风险作业和检查项
*
* @param hazardousWorkDto
*/
public void saveHazarDousWork(HazardousWorkDto hazardousWorkDto, HazardousWork hazardousWork) {
List<InputItemDto> inputItemDtos = hazardousWorkDto.getInputItemDtos();
if (StringUtil.isNotEmpty(inputItemDtos)) {
inputItemDtos.forEach(inputItemDto -> {
InputItem inputItem = new InputItem();
BeanUtils.copyProperties(inputItemDto, inputItem);
iInputItemService.save(inputItem);
HazardousWorkRefInputItem hazardousWorkRefInputItem = new HazardousWorkRefInputItem();
hazardousWorkRefInputItem.setHazardousWorkId(hazardousWork.getId());
hazardousWorkRefInputItem.setInputItemId(inputItem.getId());
hazardousWorkRefInputItem.setOrders(0L);
iHazardousWorkRefInputItemService.save(hazardousWorkRefInputItem);
});
}
}
/**
* 根据风险作业id删除 检查项和关联关系
*
* @param id
*/
public void deleteHazarDousWork(Long id) {
// 删除检查项
List<HazardousWorkRefInputItem> list = iHazardousWorkRefInputItemService.list(
new LambdaQueryWrapper<HazardousWorkRefInputItem>().select(HazardousWorkRefInputItem::getInputItemId)
.eq(HazardousWorkRefInputItem::getHazardousWorkId, id));
if (StringUtil.isNotEmpty(list)) {
List<Long> collect = list.stream().map(l -> l.getInputItemId()).collect(Collectors.toList());
iInputItemService.removeByIds(collect);
}
// 删除关联关系
List<HazardousWorkRefInputItem> hazardousWorkRefInputItemServices = iHazardousWorkRefInputItemService
.list(new LambdaQueryWrapper<HazardousWorkRefInputItem>().select(HazardousWorkRefInputItem::getId)
.eq(HazardousWorkRefInputItem::getHazardousWorkId, id));
if (StringUtil.isNotEmpty(hazardousWorkRefInputItemServices)) {
List<Long> collect = hazardousWorkRefInputItemServices.stream().map(l -> l.getId())
.collect(Collectors.toList());
iHazardousWorkRefInputItemService.removeByIds(collect);
}
}
}
package com.yeejoin.precontrol.controller;
import com.yeejoin.precontrol.common.dto.StudioPageableDto;
import com.yeejoin.precontrol.common.entity.PersonClock;
import com.yeejoin.precontrol.common.entity.publics.CommonPageable;
import com.yeejoin.precontrol.common.fileparser.utils.DateUtil;
import com.yeejoin.precontrol.common.service.IPersonClockService;
import com.yeejoin.precontrol.common.vo.PersonClockVo;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.MediaType;
import org.springframework.web.bind.annotation.*;
import org.typroject.tyboot.core.restful.utils.ResponseModel;
import javax.servlet.http.HttpServletRequest;
import java.util.Date;
import java.util.HashMap;
/**
* 人员履历信息(打卡)
*
* @author duanwei
* @date 2020-06-30
*/
@RestController
@Api(tags = "人员履历信息(打卡)Api")
@RequestMapping(value = "/person-clock", produces = MediaType.APPLICATION_JSON_UTF8_VALUE)
public class PersonClockController {
/**
* 用户打卡服务
*/
@Autowired
IPersonClockService iPersonClockService;
/**
* 新增人员履历信息(打卡)
*
* @return
*/
@RequestMapping(value = "/save", method = RequestMethod.POST)
@ApiOperation(httpMethod = "POST", value = "新增人员履历信息(打卡)", notes = "新增人员履历信息(打卡)")
public boolean savePersonClock(HttpServletRequest request, @RequestBody PersonClock personClock) {
return iPersonClockService.save(personClock);
}
/**
* 根据id删除
*
* @param id
* @return
*/
@RequestMapping(value = "/{id}", method = RequestMethod.DELETE)
@ApiOperation(httpMethod = "DELETE", value = "根据id删除", notes = "根据id删除")
public boolean deleteById(HttpServletRequest request, @PathVariable Long id) {
return iPersonClockService.removeById(id);
}
/**
* 修改人员履历信息(打卡)
*
* @return
*/
@RequestMapping(value = "/updateById", method = RequestMethod.PUT)
@ApiOperation(httpMethod = "PUT", value = "修改人员履历信息(打卡)", notes = "修改人员履历信息(打卡)")
public boolean updateByIdPersonClock(HttpServletRequest request, @RequestBody PersonClock personClock) {
return iPersonClockService.updateById(personClock);
}
/**
* 根据id查询
*
* @param id
* @return
*/
@RequestMapping(value = "/{id}", method = RequestMethod.GET)
@ApiOperation(httpMethod = "GET", value = "根据id查询", notes = "根据id查询")
public Object selectById(HttpServletRequest request, @PathVariable Long id) {
return iPersonClockService.getById(id);
}
/**
* 列表分页查询
*
* @return
*/
@RequestMapping(value = "/list", method = RequestMethod.GET)
@ApiOperation(httpMethod = "GET", value = "考勤列表分页查询", notes = "考勤列表分页查询")
public Object listPage(CommonPageable pageable,
@ApiParam("查询时间开始") @RequestParam(value = "clockTimeStart", required = false) String clockTimeStart,
@ApiParam("查询时间结束") @RequestParam(value = "clockTimeEnd", required = false) String clockTimeEnd,
@ApiParam("用户id") @RequestParam(value = "personId", required = true) Long personId) {
HashMap<String, Object> param = new HashMap<>(2);
param.put("clockTimeStart", clockTimeStart);
param.put("clockTimeEnd", clockTimeEnd);
param.put("personId", personId);
return iPersonClockService.pageInfo(pageable, param);
}
/**
* 对接闸机生成数字签名
*
* @param deviceNo
* @return ResponseModel
*/
@GetMapping("/signature")
@ApiOperation(httpMethod = "GET", value = "对接闸机生成数字签名", notes = "对接闸机生成数字签名")
public ResponseModel getSignature(@RequestParam("deviceNo") String deviceNo) {
return iPersonClockService.getSignature(deviceNo);
}
/**
* 对接三合闸机人员出入场打卡
*
* @param PersonClockVo
* @return ResponseModel
*/
@PostMapping("/clock")
@ApiOperation(httpMethod = "POST", value = "三合闸机出入场回调接口", notes = "三合闸机出入场回调接口")
public ResponseModel personClock(@RequestBody PersonClockVo PersonClockVo) {
return iPersonClockService.personClock(PersonClockVo);
}
/**
* 开发接口
* 列表分页查询
*
* @return
*/
@RequestMapping(value = "/listByDevice", method = RequestMethod.GET)
@ApiOperation(httpMethod = "GET", value = "考勤列表分页查询", notes = "考勤列表分页查询")
public Object listPage(StudioPageableDto pageable,PersonClockVo personClockVo ) {
return iPersonClockService.listByDevice(pageable, personClockVo);
}
}
package com.yeejoin.precontrol.controller;
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.yeejoin.precontrol.common.dto.CommonPageableDto;
import com.yeejoin.precontrol.common.dto.EnterpriseLocusDto;
import com.yeejoin.precontrol.common.entity.PersonContract;
import com.yeejoin.precontrol.common.service.IPersonContractService;
import com.yeejoin.precontrol.common.utils.NameUtils;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.MediaType;
import org.springframework.web.bind.annotation.*;
import javax.servlet.http.HttpServletRequest;
import java.util.Arrays;
/**
* 人员合同信息
*
* @author duanwei
* @date 2020-06-30
*/
@RestController
@Api(tags = "人员合同信息Api")
@RequestMapping(value = "/person-contract", produces = MediaType.APPLICATION_JSON_UTF8_VALUE)
public class PersonContractController {
/**
* 人员合同服务
*/
@Autowired
IPersonContractService iPersonContractService;
/**
* 新增人员合同信息
*
* @return
*/
@RequestMapping(value = "/save", method = RequestMethod.POST)
@ApiOperation(httpMethod = "POST", value = "新增人员合同信息", notes = "新增人员合同信息")
public boolean savePersonContract(HttpServletRequest request, @RequestBody PersonContract personContract) {
return iPersonContractService.save(personContract);
}
/**
* 根据id删除
*
* @param id
* @return
*/
@RequestMapping(value = "/{id}", method = RequestMethod.DELETE)
@ApiOperation(httpMethod = "DELETE", value = "根据id删除", notes = "根据id删除")
public boolean deleteById(HttpServletRequest request, @PathVariable Long id) {
return iPersonContractService.removeById(id);
}
/**
* 修改人员合同信息
*
* @return
*/
@RequestMapping(value = "/updateById", method = RequestMethod.PUT)
@ApiOperation(httpMethod = "PUT", value = "修改人员合同信息", notes = "修改人员合同信息")
public boolean updateByIdPersonContract(HttpServletRequest request, @RequestBody PersonContract personContract) {
return iPersonContractService.updateById(personContract);
}
/**
* 根据id查询
*
* @param id
* @return
*/
@RequestMapping(value = "/{id}", method = RequestMethod.GET)
@ApiOperation(httpMethod = "GET", value = "根据id查询", notes = "根据id查询")
public Object selectById(HttpServletRequest request, @PathVariable Long id) {
return iPersonContractService.getById(id);
}
/**
* 列表分页查询
*
* @return
*/
@RequestMapping(value = "/list", method = RequestMethod.GET)
@ApiOperation(httpMethod = "GET", value = "列表分页查询", notes = "列表分页查询")
public Object listPage(String pageNum, String pageSize, PersonContract personContract) {
Page<PersonContract> pageBean;
QueryWrapper<PersonContract> personContractQueryWrapper = new QueryWrapper<>();
Class<? extends PersonContract> aClass = personContract.getClass();
Arrays.stream(aClass.getDeclaredFields()).forEach(field -> {
try {
field.setAccessible(true);
Object o = field.get(personContract);
if (o != null) {
Class<?> type = field.getType();
String name = NameUtils.camel2Underline(field.getName());
if (type.equals(Integer.class)) {
Integer fileValue = (Integer) field.get(personContract);
personContractQueryWrapper.eq(name, fileValue);
} else if (type.equals(Long.class)) {
Long fileValue = (Long) field.get(personContract);
personContractQueryWrapper.eq(name, fileValue);
} else if (type.equals(String.class)) {
String fileValue = (String) field.get(personContract);
personContractQueryWrapper.eq(name, fileValue);
} else {
String fileValue = (String) field.get(personContract);
personContractQueryWrapper.eq(name, fileValue);
}
}
} catch (Exception e) {
}
});
IPage<PersonContract> page;
if (StringUtils.isBlank(pageNum) || StringUtils.isBlank(pageSize)) {
pageBean = new Page<>(0, Long.MAX_VALUE);
} else {
pageBean = new Page<>(Integer.parseInt(pageNum), Integer.parseInt(pageSize));
}
page = iPersonContractService.page(pageBean, personContractQueryWrapper);
return page;
}
@GetMapping("/EnterpriseLocus")
@ApiOperation(httpMethod = "GET", value = "人员企业轨迹", notes = "人员企业轨迹")
public Object enterpriseLocusByPersonId(@ApiParam(value = "分页参数")CommonPageableDto pageableDto, EnterpriseLocusDto enterpriseLocusDto) {
return iPersonContractService.enterpriseLocusByPersonId(enterpriseLocusDto,pageableDto);
}
}
package com.yeejoin.precontrol.controller;
import javax.servlet.http.HttpServletRequest;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.MediaType;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.yeejoin.precontrol.common.dto.CommonPageableDto;
import com.yeejoin.precontrol.common.entity.PersonExamRecord;
import com.yeejoin.precontrol.common.service.IPersonExamRecordService;
import com.yeejoin.precontrol.common.vo.PersonExamRecordVo;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
/**
* 考试记录表
*
* @author duanwei
* @date 2021-02-23
*/
@RestController
@Api(tags = "考试记录表Api")
@RequestMapping(value = "/person-exam-record", produces = MediaType.APPLICATION_JSON_UTF8_VALUE)
public class PersonExamRecordController {
@Autowired
IPersonExamRecordService iPersonExamRecordService;
/**
* 新增考试记录表
*
* @return
*/
@RequestMapping(value = "/save", method = RequestMethod.POST)
@ApiOperation(httpMethod = "POST", value = "新增考试记录表", notes = "新增考试记录表")
public boolean savePersonExamRecord(HttpServletRequest request, @RequestBody PersonExamRecord personExamRecord) {
return iPersonExamRecordService.save(personExamRecord);
}
/**
* 根据id删除
*
* @param id
* @return
*/
@RequestMapping(value = "/{id}", method = RequestMethod.DELETE)
@ApiOperation(httpMethod = "DELETE", value = "根据id删除", notes = "根据id删除")
public boolean deleteById(HttpServletRequest request, @PathVariable Long id) {
return iPersonExamRecordService.removeById(id);
}
/**
* 修改考试记录表
*
* @return
*/
@RequestMapping(value = "/updateById", method = RequestMethod.PUT)
@ApiOperation(httpMethod = "PUT", value = "修改考试记录表", notes = "修改考试记录表")
public boolean updateByIdPersonExamRecord(HttpServletRequest request,
@RequestBody PersonExamRecord personExamRecord) {
return iPersonExamRecordService.updateById(personExamRecord);
}
/**
* 根据id查询
*
* @param id
* @return
*/
@RequestMapping(value = "/{id}", method = RequestMethod.GET)
@ApiOperation(httpMethod = "GET", value = "根据id查询", notes = "根据id查询")
public PersonExamRecord selectById(HttpServletRequest request, @PathVariable Long id) {
return iPersonExamRecordService.getById(id);
}
/**
* 列表分页查询
*
* @return
*/
@RequestMapping(value = "/list", method = RequestMethod.GET)
@ApiOperation(httpMethod = "GET", value = "列表分页查询", notes = "列表分页查询")
public IPage<PersonExamRecordVo> listPage(CommonPageableDto pageable, PersonExamRecordVo personExamRecordVo) {
Page<PersonExamRecordVo> page = iPersonExamRecordService.pageInfo(pageable, personExamRecordVo);
return page;
}
}
package com.yeejoin.precontrol.controller;
import com.yeejoin.precontrol.common.service.IPersonWorkingHoursService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.MediaType;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
/**
* 工时信息
*
* @author duanwei
* @date 2020-06-30
*/
@RestController
@Api(tags = "工时信息Api")
@RequestMapping(value = "/person-working-hours", produces = MediaType.APPLICATION_JSON_UTF8_VALUE)
public class PersonWorkingHoursController {
/**
* 工时服务
*/
@Autowired
IPersonWorkingHoursService iPersonWorkingHoursService;
@RequestMapping(value = "/workHourStatistical", method = RequestMethod.GET)
@ApiOperation(httpMethod = "GET", value = "人员工时统计", notes = "人员工时统计")
public Object workHourStatisticalByPersonId(
@RequestParam(value = "personId", required = true) Long personId,
@RequestParam(value = "curTime", required = false) String curTime) {
return iPersonWorkingHoursService.workHourStatisticalByPersonId(personId, curTime);
}
}
package com.yeejoin.precontrol.controller;
import org.springframework.http.MediaType;
import org.springframework.web.bind.annotation.RequestMapping;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.Api;
import com.yeejoin.precontrol.common.entity.publics.CommonResponse;
import org.apache.commons.lang3.StringUtils;
import org.springframework.web.bind.annotation.RestController;
import com.yeejoin.precontrol.common.service.IProjectDeviceService;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import org.springframework.beans.factory.annotation.Autowired;
import javax.servlet.http.HttpServletRequest;
import com.baomidou.mybatisplus.core.metadata.IPage;
import org.springframework.web.bind.annotation.*;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.yeejoin.precontrol.common.entity.ProjectDevice;
import com.yeejoin.precontrol.common.utils.NameUtils;
import java.lang.reflect.Field;
import java.util.Arrays;
/**
* 项目设备表
*
* @author duanwei
* @date 2021-03-22
*/
@RestController
@Api(tags = "项目设备表Api")
@RequestMapping(value = "/project-device", produces = MediaType.APPLICATION_JSON_UTF8_VALUE)
public class ProjectDeviceController {
@Autowired
IProjectDeviceService iProjectDeviceService;
/**
* 新增项目设备表
* @return
*/
@RequestMapping(value = "/save", method = RequestMethod.POST)
@ApiOperation(httpMethod = "POST", value = "新增项目设备表", notes = "新增项目设备表")
public boolean saveProjectDevice(HttpServletRequest request, @RequestBody ProjectDevice projectDevice){
return iProjectDeviceService.save(projectDevice);
}
/**
* 根据id删除
* @param id
* @return
*/
@RequestMapping(value = "/{id}", method = RequestMethod.DELETE)
@ApiOperation(httpMethod = "DELETE", value = "根据id删除", notes = "根据id删除")
public boolean deleteById(HttpServletRequest request, @PathVariable Long id){
return iProjectDeviceService.removeById(id);
}
/**
* 修改项目设备表
* @return
*/
@RequestMapping(value = "/updateById", method = RequestMethod.PUT)
@ApiOperation(httpMethod = "PUT", value = "修改项目设备表", notes = "修改项目设备表")
public boolean updateByIdProjectDevice(HttpServletRequest request, @RequestBody ProjectDevice projectDevice){
return iProjectDeviceService.updateById(projectDevice);
}
/**
* 根据id查询
* @param id
* @return
*/
@RequestMapping(value = "/{id}", method = RequestMethod.GET)
@ApiOperation(httpMethod = "GET", value = "根据id查询", notes = "根据id查询")
public ProjectDevice selectById(HttpServletRequest request, @PathVariable Long id){
return iProjectDeviceService.getById(id);
}
/**
* 列表分页查询
* @return
*/
@RequestMapping(value = "/list", method = RequestMethod.GET)
@ApiOperation(httpMethod = "GET", value = "列表分页查询", notes = "列表分页查询")
public IPage<ProjectDevice> listPage(String pageNum,String pageSize,
ProjectDevice projectDevice){
Page<ProjectDevice> pageBean;
QueryWrapper<ProjectDevice> projectDeviceQueryWrapper = new QueryWrapper<>();
Class<? extends ProjectDevice> aClass = projectDevice.getClass();
Arrays.stream(aClass.getDeclaredFields()).forEach(field -> {
try {
field.setAccessible(true);
Object o = field.get(projectDevice);
if (o != null) {
Class<?> type = field.getType();
String name = NameUtils.camel2Underline(field.getName());
if (type.equals(Integer.class)) {
Integer fileValue = (Integer) field.get(projectDevice);
projectDeviceQueryWrapper.eq(name, fileValue);
} else if (type.equals(Long.class)) {
Long fileValue = (Long) field.get(projectDevice);
projectDeviceQueryWrapper.eq(name, fileValue);
} else if (type.equals(String.class)) {
String fileValue = (String) field.get(projectDevice);
projectDeviceQueryWrapper.eq(name, fileValue);
} else {
String fileValue = (String) field.get(projectDevice);
projectDeviceQueryWrapper.eq(name, fileValue);
}
}
}catch (Exception e) {
}
});
IPage<ProjectDevice> page;
if (StringUtils.isBlank(pageNum) ||StringUtils.isBlank(pageSize)) {
pageBean = new Page<>(0, Long.MAX_VALUE);
}else{
pageBean = new Page<>(Integer.parseInt(pageNum), Integer.parseInt(pageSize));
}
page = iProjectDeviceService.page(pageBean, projectDeviceQueryWrapper);
return page;
}
}
package com.yeejoin.precontrol.controller;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.yeejoin.precontrol.common.dto.CommonPageableDto;
import com.yeejoin.precontrol.common.dto.ProjectHistroyDto;
import com.yeejoin.precontrol.common.entity.ProjectHistory;
import com.yeejoin.precontrol.common.service.IProjectHistoryService;
import com.yeejoin.precontrol.common.utils.FileHelper;
import com.yeejoin.precontrol.common.vo.ProjectHistoryVo;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.MediaType;
import org.springframework.web.bind.annotation.*;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.util.List;
import java.util.UUID;
/**
* 项目历史轨迹
*
* @author duanwei
* @date 2020-07-16
*/
@RestController
@Api(tags = "项目历史轨迹Api")
@RequestMapping(value = "/project-history", produces = MediaType.APPLICATION_JSON_UTF8_VALUE)
public class ProjectHistoryController {
/**
* 项目历史服务
*/
@Autowired
IProjectHistoryService iProjectHistoryService;
/**
* 新增项目历史轨迹
*
* @return
*/
@RequestMapping(value = "/save", method = RequestMethod.POST)
@ApiOperation(httpMethod = "POST", value = "新增项目历史轨迹", notes = "新增项目历史轨迹")
public boolean saveProjectHistory(HttpServletRequest request, @RequestBody ProjectHistory projectHistory) {
return iProjectHistoryService.save(projectHistory);
}
/**
* 根据id删除
*
* @param id
* @return
*/
@RequestMapping(value = "/{id}", method = RequestMethod.DELETE)
@ApiOperation(httpMethod = "DELETE", value = "根据id删除", notes = "根据id删除")
public boolean deleteById(HttpServletRequest request, @PathVariable Long id) {
return iProjectHistoryService.removeById(id);
}
/**
* 修改项目历史轨迹
*
* @return
*/
@RequestMapping(value = "/updateById", method = RequestMethod.PUT)
@ApiOperation(httpMethod = "PUT", value = "修改项目历史轨迹", notes = "修改项目历史轨迹")
public boolean updateByIdProjectHistory(HttpServletRequest request, @RequestBody ProjectHistory projectHistory) {
return iProjectHistoryService.updateById(projectHistory);
}
/**
* 根据id查询
*
* @param id
* @return
*/
@RequestMapping(value = "/{id}", method = RequestMethod.GET)
@ApiOperation(httpMethod = "GET", value = "根据id查询", notes = "根据id查询")
public ProjectHistory selectById(HttpServletRequest request, @PathVariable Long id) {
return iProjectHistoryService.getById(id);
}
/**
* 列表分页查询
*
* @return
*/
@RequestMapping(value = "/list", method = RequestMethod.GET)
@ApiOperation(httpMethod = "GET", value = "列表分页查询", notes = "列表分页查询")
public Object listPage(@ApiParam(value = "分页条件 isAll=0 具体分页必传") CommonPageableDto pageable,
@ApiParam(value = "查询参数") ProjectHistroyDto projectHistroyDto,
@ApiParam(value = "类型 0查询列表 1 导出列表") @RequestParam Long operType,
@ApiParam(value = "查询Ids") @RequestParam(required = false) List<Long> ids,
HttpServletResponse response) {
String fileName = UUID.randomUUID().toString() + ".xls";
if (null != ids && ids.size() > 0) {
projectHistroyDto.setIds(ids);
}
IPage<ProjectHistoryVo> page = iProjectHistoryService.listByPage(pageable, projectHistroyDto);
if (operType == 1) {
List<ProjectHistoryVo> excelList = page.getRecords();
FileHelper.exportExcel(excelList, "项目历史轨迹", "项目历史轨迹信息", ProjectHistoryVo.class, fileName, response);
return null;
} else {
return page;
}
}
}
package com.yeejoin.precontrol.controller;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.yeejoin.precontrol.common.entity.Project;
import com.yeejoin.precontrol.common.entity.ProjectVideo;
import com.yeejoin.precontrol.common.service.IProjectService;
import com.yeejoin.precontrol.common.service.IProjectVideoService;
import com.yeejoin.precontrol.common.utils.StringUtil;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.http.MediaType;
import org.springframework.web.bind.annotation.*;
import org.typroject.tyboot.core.foundation.utils.ValidationUtil;
import org.typroject.tyboot.core.restful.exception.instance.BadRequest;
import javax.servlet.http.HttpServletRequest;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.UUID;
/**
* 项目视频表
*
* @author duanwei
* @date 2020-08-06
*/
@RestController
@Api(tags = "项目视频表Api")
@RequestMapping(value = "/project-video", produces = MediaType.APPLICATION_JSON_UTF8_VALUE)
public class ProjectVideoController {
/**
* 工程视频服务
*/
@Autowired
IProjectVideoService iProjectVideoService;
/**
* 工程服务
*/
@Autowired
IProjectService iProjectService;
/**
* 文件服务器
*/
@Value("${fileserver.domain}")
private String fileserver;
@Value("${camera-conf.protocol}")
private String protocol;
@Value("${camera-conf.socket}")
private String socket;
/**
* 新增项目视频表
*
* @return
*/
@RequestMapping(value = "", method = RequestMethod.POST)
@ApiOperation(httpMethod = "POST", value = "新增项目视频表", notes = "新增项目视频表")
public boolean saveProjectVideo(@RequestBody ProjectVideo projectVideo) {
if (ValidationUtil.isEmpty(projectVideo.getIp()) || ValidationUtil.isEmpty(projectVideo.getPort())
|| ValidationUtil.isEmpty(projectVideo.getUsername()) || ValidationUtil.isEmpty(projectVideo.getPassword())
|| ValidationUtil.isEmpty(projectVideo.getProjectId())) {
throw new BadRequest("参数不正确");
}
projectVideo.setProtocol(protocol);
projectVideo.setSocket(socket);
updateToken(projectVideo);
return iProjectVideoService.save(projectVideo);
}
private void updateToken(ProjectVideo projectVideo) {
String token = UUID.randomUUID().toString();
projectVideo.setToken(token);
// TODO-调用第三方注册摄像头
}
/**
* 根据id删除
*
* @param id
* @return
*/
@RequestMapping(value = "/{id}", method = RequestMethod.DELETE)
@ApiOperation(httpMethod = "DELETE", value = "根据id删除", notes = "根据id删除")
public boolean deleteById(HttpServletRequest request, @PathVariable Long id) {
return iProjectVideoService.removeById(id);
}
/**
* 修改项目视频表
*
* @return
*/
@RequestMapping(value = "/{id}", method = RequestMethod.PUT)
@ApiOperation(httpMethod = "PUT", value = "修改项目视频表", notes = "修改项目视频表")
public boolean updateByIdProjectVideo(@PathVariable("id") Long id, @RequestBody ProjectVideo projectVideo) {
if (null == id) {
throw new BadRequest("缺少目标");
}
ProjectVideo old = iProjectVideoService.getById(id);
if (null == old) {
throw new BadRequest("目标不存在");
}
if (ValidationUtil.isEmpty(projectVideo) || ValidationUtil.isEmpty(projectVideo.getIp())
|| ValidationUtil.isEmpty(projectVideo.getPort()) || ValidationUtil.isEmpty(projectVideo.getUsername())
|| ValidationUtil.isEmpty(projectVideo.getPassword()) || ValidationUtil.isEmpty(projectVideo.getProjectId())
) {
throw new BadRequest("参数不正确");
}
projectVideo.setProtocol(protocol);
projectVideo.setSocket(socket);
if (StringUtils.equals(old.getUsername(), projectVideo.getUsername()) && StringUtils.equals(old.getPassword(), projectVideo.getPassword())
&& StringUtils.equals(old.getIp(), projectVideo.getIp()) && projectVideo.getPort().equals(old.getPort())) {
}else {
updateToken(projectVideo);
}
return iProjectVideoService.updateById(projectVideo);
}
/**
* 根据id查询
*
* @param id
* @return
*/
@RequestMapping(value = "/{id}", method = RequestMethod.GET)
@ApiOperation(httpMethod = "GET", value = "根据id查询", notes = "根据id查询")
public Object selectById(@PathVariable Long id) {
ProjectVideo res = iProjectVideoService.getById(id);
return res;
}
/**
* 列表分页查询
*
* @return
*/
@RequestMapping(value = "/list", method = RequestMethod.GET)
@ApiOperation(httpMethod = "GET", value = "列表分页查询", notes = "列表分页查询")
public Object listPage(String projectId) {
List<ProjectVideo> projectVideoList;
Map<String, Object> map = new HashMap<>(2);
map.put("title", "");
if (StringUtils.isEmpty(projectId)) {
projectVideoList = iProjectVideoService.list();
} else {
Project project = iProjectService.getById(projectId);
if (project != null) {
map.put("title", project.getName());
}
projectVideoList = iProjectVideoService.list(new LambdaQueryWrapper<ProjectVideo>().eq(ProjectVideo::getProjectId, projectId));
}
if (StringUtil.isNotEmpty(projectVideoList)) {
projectVideoList.forEach(projectVideo -> projectVideo.setUsername(null).setPassword(null));
}
map.put("videoList", projectVideoList);
return map;
}
}
package com.yeejoin.precontrol.controller;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.yeejoin.precontrol.common.dto.CommonPageableDto;
import com.yeejoin.precontrol.common.dto.StudioPageableDto;
import com.yeejoin.precontrol.common.entity.Person;
import com.yeejoin.precontrol.common.entity.Retribution;
import com.yeejoin.precontrol.common.service.IRetributionService;
import com.yeejoin.precontrol.common.utils.Response;
import com.yeejoin.precontrol.common.utils.StringUtil;
import com.yeejoin.precontrol.common.vo.RetributionVo;
import com.yeejoin.precontrol.common.vo.RewardListVo;
import com.yeejoin.precontrol.common.vo.RewardOrgCodeVo;
import com.yeejoin.precontrol.controller.publics.BaseController;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.MediaType;
import org.springframework.util.StringUtils;
import org.springframework.web.bind.annotation.*;
import javax.servlet.http.HttpServletRequest;
import java.math.BigDecimal;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
/**
* 惩罚表
*
* @author duanwei
* @date 2021-04-06
*/
@RestController
@Api(tags = "惩罚表Api")
@RequestMapping(value = "/retribution", produces = MediaType.APPLICATION_JSON_UTF8_VALUE)
public class RetributionController extends BaseController {
@Autowired
IRetributionService iRetributionService;
/**
* 新增惩罚表
*
* @return
*/
@RequestMapping(value = "/save", method = RequestMethod.POST)
@ApiOperation(httpMethod = "POST", value = "新增惩罚表", notes = "新增惩罚表")
public boolean saveRetribution(HttpServletRequest request, @RequestBody Retribution retribution) {
return iRetributionService.save(retribution);
}
/**
* 根据id删除
*
* @param id
* @return
*/
@RequestMapping(value = "/{id}", method = RequestMethod.DELETE)
@ApiOperation(httpMethod = "DELETE", value = "根据id删除", notes = "根据id删除")
public boolean deleteById(HttpServletRequest request, @PathVariable Long id) {
return iRetributionService.removeById(id);
}
/**
* 修改惩罚表
*
* @return
*/
@RequestMapping(value = "/updateById", method = RequestMethod.PUT)
@ApiOperation(httpMethod = "PUT", value = "修改惩罚表", notes = "修改惩罚表")
public boolean updateByIdRetribution(HttpServletRequest request, @RequestBody Retribution retribution) {
return iRetributionService.updateById(retribution);
}
/**
* 根据id查询
*
* @param id
* @return
*/
@RequestMapping(value = "/{id}", method = RequestMethod.GET)
@ApiOperation(httpMethod = "GET", value = "根据id查询", notes = "根据id查询")
public Retribution selectById(HttpServletRequest request, @PathVariable Long id) {
return iRetributionService.getById(id);
}
/**
* 列表分页查询
*
* @return
*/
@RequestMapping(value = "/list", method = RequestMethod.GET)
@ApiOperation(httpMethod = "GET", value = "列表分页查询", notes = "列表分页查询")
public IPage<RetributionVo> listPage(CommonPageableDto pageable, RetributionVo retributionVo) {
Person person = getPerson();
if (person != null) {
retributionVo.setPersonId(person.getId());
}
if (StringUtil.isNotEmpty(retributionVo.getTaskName())) {
retributionVo.setTaskName("%" + retributionVo.getTaskName() + "%");
}
if (StringUtil.isNotEmpty(retributionVo.getTaskNo())) {
retributionVo.setTaskNo("%" + retributionVo.getTaskNo() + "%");
}
return iRetributionService.pageInfo(pageable, retributionVo);
}
/**
* 查处违章总数查询
*
* @return
*/
@RequestMapping(value = "/total", method = RequestMethod.GET)
@ApiOperation(httpMethod = "GET", value = "查处违章总数查询", notes = "查处违章总数查询")
public Object listTotal() {
Response response = new Response();
Map ret = new HashMap();
Person person = getPerson();
if (person != null) {
Map map = new HashMap();
map.put("person_id", person.getId());
List<Retribution> list = (List<Retribution>) iRetributionService.listByMap(map);
BigDecimal sumMoney = BigDecimal.ZERO;
if (list != null && list.size() > 0) {
sumMoney = list.stream().map(Retribution::getMoney).reduce(BigDecimal.ZERO, BigDecimal::add);
}
ret.put("total", list.size());
ret.put("sumMoney", sumMoney.toPlainString());
} else {
ret.put("sumMoney", Integer.MIN_VALUE);
ret.put("total", Integer.MIN_VALUE);
}
response.setData(ret);
return response;
}
/**
* 所有分包商违章统计排名 以人员违章表为主,该表有该分包商下的人员则该分包商出现
*/
@GetMapping("/list/company")
@ApiOperation(httpMethod = "GET", value = "所有分包商违章统计排名 以人员违章表为主,该表有该分包商下的人员则该分包商出现", notes = "所有分包商违章统计排名 以人员违章表为主,该表有该分包商下的人员则该分包商出现")
public IPage<RewardOrgCodeVo> listPageByOrgCode(StudioPageableDto pageable,
@RequestParam(value = "companyName", required = false) String companyName) {
return iRetributionService.listPageComcany(pageable, companyName, null);
}
/**
* 根据人员id查询该人员的违章列表
*/
@GetMapping("/list/user/detail")
@ApiOperation(httpMethod = "GET", value = "根据人员id查询该人员的奖励详情列表", notes = "根据人员id查询该人员的奖励详情列表")
public IPage<RewardListVo> rewardUserListDetail(StudioPageableDto pageable, RewardListVo rewardVo) {
return iRetributionService.rewardUserListDetail(pageable, rewardVo);
}
/**
* 根据分包商companyId 查询该分包商下的所有 人员违章列表
*
* @return
*/
@RequestMapping(value = "/person/list", method = RequestMethod.GET)
@ApiOperation(httpMethod = "GET", value = "某个用户惩罚 列表分页查询", notes = "某个用户惩罚 列表分页查询")
public IPage<RetributionVo> listPageByPersonId(CommonPageableDto pageable, RetributionVo retributionVo) {
if (StringUtils.isEmpty(retributionVo.getCompanyId())) {
return new Page<>(pageable.getPageNumber(), pageable.getPageSize());
}
if (StringUtil.isNotEmpty(retributionVo.getProjectName())) {
retributionVo.setProjectName("%" + retributionVo.getProjectName() + "%");
}
return iRetributionService.pageCompanyInfo(pageable, retributionVo);
}
/**
* 分包商违章排名列表
*/
@GetMapping("/list/company/bad")
@ApiOperation(httpMethod = "GET", value = "所有分包商违章统计排名 以人员违章表为主,该表有该分包商下的人员则该分包商出现", notes = "所有分包商违章统计排名 以人员违章表为主,该表有该分包商下的人员则该分包商出现")
public IPage<RewardOrgCodeVo> listBadPageByOrgCode(StudioPageableDto pageable,
RewardOrgCodeVo rewardOrgCodeVo) {
return iRetributionService.listBadPageCompany(pageable, rewardOrgCodeVo, null);
}
}
package com.yeejoin.precontrol.controller;
import org.springframework.http.MediaType;
import org.springframework.web.bind.annotation.RequestMapping;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.Api;
import com.yeejoin.precontrol.common.entity.publics.CommonResponse;
import org.apache.commons.lang3.StringUtils;
import org.springframework.web.bind.annotation.RestController;
import com.yeejoin.precontrol.common.service.IRewardConfigService;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import org.springframework.beans.factory.annotation.Autowired;
import javax.servlet.http.HttpServletRequest;
import com.baomidou.mybatisplus.core.metadata.IPage;
import org.springframework.web.bind.annotation.*;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.yeejoin.precontrol.common.entity.RewardConfig;
import com.yeejoin.precontrol.common.utils.NameUtils;
import java.lang.reflect.Field;
import java.util.Arrays;
/**
* 奖励惩罚配置表
*
* @author duanwei
* @date 2021-04-06
*/
@RestController
@Api(tags = "奖励惩罚配置表Api")
@RequestMapping(value = "/reward-config", produces = MediaType.APPLICATION_JSON_UTF8_VALUE)
public class RewardConfigController {
@Autowired
IRewardConfigService iRewardConfigService;
/**
* 新增奖励惩罚配置表
* @return
*/
@RequestMapping(value = "/save", method = RequestMethod.POST)
@ApiOperation(httpMethod = "POST", value = "新增奖励惩罚配置表", notes = "新增奖励惩罚配置表")
public boolean saveRewardConfig(HttpServletRequest request, @RequestBody RewardConfig rewardConfig){
return iRewardConfigService.save(rewardConfig);
}
/**
* 根据id删除
* @param id
* @return
*/
@RequestMapping(value = "/{id}", method = RequestMethod.DELETE)
@ApiOperation(httpMethod = "DELETE", value = "根据id删除", notes = "根据id删除")
public boolean deleteById(HttpServletRequest request, @PathVariable Long id){
return iRewardConfigService.removeById(id);
}
/**
* 修改奖励惩罚配置表
* @return
*/
@RequestMapping(value = "/updateById", method = RequestMethod.PUT)
@ApiOperation(httpMethod = "PUT", value = "修改奖励惩罚配置表", notes = "修改奖励惩罚配置表")
public boolean updateByIdRewardConfig(HttpServletRequest request, @RequestBody RewardConfig rewardConfig){
return iRewardConfigService.updateById(rewardConfig);
}
/**
* 根据id查询
* @param id
* @return
*/
@RequestMapping(value = "/{id}", method = RequestMethod.GET)
@ApiOperation(httpMethod = "GET", value = "根据id查询", notes = "根据id查询")
public RewardConfig selectById(HttpServletRequest request, @PathVariable Long id){
return iRewardConfigService.getById(id);
}
/**
* 列表分页查询
* @return
*/
@RequestMapping(value = "/list", method = RequestMethod.GET)
@ApiOperation(httpMethod = "GET", value = "列表分页查询", notes = "列表分页查询")
public IPage<RewardConfig> listPage(String pageNum,String pageSize,
RewardConfig rewardConfig){
Page<RewardConfig> pageBean;
QueryWrapper<RewardConfig> rewardConfigQueryWrapper = new QueryWrapper<>();
Class<? extends RewardConfig> aClass = rewardConfig.getClass();
Arrays.stream(aClass.getDeclaredFields()).forEach(field -> {
try {
field.setAccessible(true);
Object o = field.get(rewardConfig);
if (o != null) {
Class<?> type = field.getType();
String name = NameUtils.camel2Underline(field.getName());
if (type.equals(Integer.class)) {
Integer fileValue = (Integer) field.get(rewardConfig);
rewardConfigQueryWrapper.eq(name, fileValue);
} else if (type.equals(Long.class)) {
Long fileValue = (Long) field.get(rewardConfig);
rewardConfigQueryWrapper.eq(name, fileValue);
} else if (type.equals(String.class)) {
String fileValue = (String) field.get(rewardConfig);
rewardConfigQueryWrapper.eq(name, fileValue);
} else {
String fileValue = (String) field.get(rewardConfig);
rewardConfigQueryWrapper.eq(name, fileValue);
}
}
}catch (Exception e) {
}
});
IPage<RewardConfig> page;
if (StringUtils.isBlank(pageNum) ||StringUtils.isBlank(pageSize)) {
pageBean = new Page<>(0, Long.MAX_VALUE);
}else{
pageBean = new Page<>(Integer.parseInt(pageNum), Integer.parseInt(pageSize));
}
page = iRewardConfigService.page(pageBean, rewardConfigQueryWrapper);
return page;
}
}
package com.yeejoin.precontrol.controller;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.yeejoin.amos.feign.privilege.model.AgencyUserModel;
import com.yeejoin.precontrol.common.dto.StudioPageableDto;
import com.yeejoin.precontrol.common.entity.Person;
import com.yeejoin.precontrol.common.entity.RewardExchange;
import com.yeejoin.precontrol.common.fileparser.utils.DateUtil;
import com.yeejoin.precontrol.common.service.IRewardExchangeService;
import com.yeejoin.precontrol.common.service.IRewardService;
import com.yeejoin.precontrol.common.utils.DateUtils;
import com.yeejoin.precontrol.common.utils.LocalDateTimeUtils;
import com.yeejoin.precontrol.common.utils.Response;
import com.yeejoin.precontrol.common.utils.StringUtil;
import com.yeejoin.precontrol.common.vo.RewardExchangeVo;
import com.yeejoin.precontrol.common.vo.RewardExchangeWechatVo;
import com.yeejoin.precontrol.common.vo.RewardListVo;
import com.yeejoin.precontrol.common.vo.RewardVo;
import com.yeejoin.precontrol.controller.publics.BaseController;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.MediaType;
import org.springframework.web.bind.annotation.*;
import java.math.BigDecimal;
import java.text.ParseException;
import java.util.*;
import java.util.stream.Collectors;
/**
* 奖励兑换api
*
* @author wbin
* @date 2021-04-06
*/
@RestController
@Api(tags = "奖励兑换api")
@RequestMapping(value = "/reward/exchange", produces = MediaType.APPLICATION_JSON_UTF8_VALUE)
public class RewardExchangeController extends BaseController {
@Autowired
IRewardExchangeService iRewardExchangeService;
@Autowired
IRewardService rewardService;
/**
* 奖励兑换
*/
@PostMapping(value = "/save")
@ApiOperation(httpMethod = "POST", value = "奖励兑换", notes = "奖励兑换")
public boolean saveExchange(@RequestBody RewardExchangeVo rewardExchangeVo) {
AgencyUserModel userInfo = getUserInfo();
if (userInfo != null) {
rewardExchangeVo.setCreateUserId(Long.valueOf(getUserId()));
}
return iRewardExchangeService.saveExchange(rewardExchangeVo);
}
/**
* 奖励兑换统计图
*/
@GetMapping(value = "/report")
@ApiOperation(httpMethod = "GET", value = "奖励兑换统计图", notes = "奖励兑换统计图")
public Object report(Integer count) throws Exception {
if (count == null) {
count = 30;
}
Map<String, Object> map = new HashMap<String, Object>();
// 统计的日期 数据
List<String> dateList = DateUtils.getAfterDateByNowDate(count);
Person person = getPerson();
String startDate = dateList.get(0);
String endDate = dateList.get(dateList.size() - 1);
List<RewardExchange> list = iRewardExchangeService.reportByUserIdAndBetweenDate(startDate, endDate, person.getId());
List<String> moneyList = new ArrayList();
for (String date : dateList) {
moneyList.add(processList(list, date));
}
// 日期
map.put("dateList", dateList);
// 金额
map.put("moneyList", moneyList);
//累计奖励总金额
String total = rewardService.selectTotalMoney(person.getId());
//已兑换总金额
String money = iRewardExchangeService.selectTotalMoney(person.getId());
processMoney(total, money, map);
return new Response(map);
}
/**
* 累计奖励总金额,已兑换总金额
*
* @param count
* @return
* @throws Exception
*/
@GetMapping(value = "/report/money")
@ApiOperation(httpMethod = "GET", value = "累计奖励总金额,已兑换总金额 ", notes = "累计奖励总金额,已兑换总金额")
public Object moneyTotal(Integer count) throws Exception {
Map<String, Object> map = new HashMap<String, Object>();
Person person = getPerson();
//累计奖励总金额
String total = rewardService.selectTotalMoney(person.getId());
//已兑换总金额
String money = iRewardExchangeService.selectTotalMoney(person.getId());
processMoney(total, money, map);
return new Response(map);
}
/**
* 处理金额
* @param total
* @param money
* @param map
*/
public static void processMoney(String total,String money, Map<String, Object> map){
if (StringUtil.isNotEmpty(total)) {
map.put("moneyTotal", new BigDecimal(total).setScale( 0, BigDecimal.ROUND_DOWN ).toPlainString());
} else {
map.put("moneyTotal", "0");
}
if(StringUtil.isNotEmpty(money)){
map.put("rewardTotal", new BigDecimal(money).setScale( 0, BigDecimal.ROUND_DOWN ).toPlainString());
}else{
map.put("rewardTotal", "0");
}
}
/**
* 计算每个日期兑换的金额总和
*
* @param dataList
* @param date
* @return
*/
public String processList(List<RewardExchange> dataList, String date) {
BigDecimal total = new BigDecimal("0");
if (dataList != null && dataList.size() > 0) {
List<BigDecimal> collect = dataList.stream().filter(item -> LocalDateTimeUtils.format(item.getCreateDate()).substring(0, 10).replace("-", "").equals(date.replace("-", "")))
.map(RewardExchange::getMoney).collect(Collectors.toList());
if (collect != null && collect.size() > 0) {
for (BigDecimal bigDecimal : collect) {
total = total.add(bigDecimal);
}
}
}
return total.toPlainString();
}
/**
* 选择日期的奖励兑换详情
*/
@GetMapping(value = "/report/detail")
@ApiOperation(httpMethod = "POST", value = "选择日期的奖励兑换详情", notes = "选择日期的奖励兑换详情")
public Object rewardDate(String date) {
Person person = getPerson();
List<RewardExchangeWechatVo> list = iRewardExchangeService.selectByDate(date, person.getId());
List<Object> retList = new ArrayList<Object>();
if (list != null && list.size() > 0) {
Map<String, List<RewardExchangeWechatVo>> collect = list.stream().collect(Collectors.groupingBy(RewardExchangeWechatVo::getBatchNo));
for (List<RewardExchangeWechatVo> arr : collect.values()) {
Map<String, Object> objectMap = new HashMap<String, Object>();
BigDecimal total = new BigDecimal("0");
if (arr != null && arr.size() > 0) {
for (RewardExchangeWechatVo bigDecimal : arr) {
total = total.add(bigDecimal.getMoney());
}
}
objectMap.put("count", arr.size());
objectMap.put("sumMoeny", total);
objectMap.put("list", arr);
retList.add(objectMap);
}
}
return new Response(retList);
}
@GetMapping(value = "/record")
@ApiOperation(httpMethod = "GET", value = "发放记录", notes = "发放记录")
public IPage<RewardExchangeWechatVo> exchangeRecord (StudioPageableDto pageable, Long personId)
{
IPage<RewardExchangeWechatVo> list = iRewardExchangeService.exchangeRecord(pageable, personId);
return list;
}
}
package com.yeejoin.precontrol.controller;
import java.util.Arrays;
import java.util.List;
import java.util.Map;
import java.util.Set;
import java.util.stream.Collectors;
import javax.validation.Valid;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.MediaType;
import org.springframework.util.CollectionUtils;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import com.alibaba.fastjson.JSONObject;
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.google.common.base.Joiner;
import com.yeejoin.amos.component.feign.model.FeignClientResult;
import com.yeejoin.amos.feign.privilege.Privilege;
import com.yeejoin.amos.feign.privilege.model.AgencyUserModel;
import com.yeejoin.precontrol.common.annotations.OpsLog;
import com.yeejoin.precontrol.common.entity.Person;
import com.yeejoin.precontrol.common.entity.RiskWork;
import com.yeejoin.precontrol.common.enums.OpsLogEnum;
import com.yeejoin.precontrol.common.param.RiskWorkParam;
import com.yeejoin.precontrol.common.service.IRiskWorkService;
import com.yeejoin.precontrol.common.utils.StringUtil;
import com.yeejoin.precontrol.common.vo.RiskWorkPersonVo;
import com.yeejoin.precontrol.common.vo.RiskWorkVo;
import com.yeejoin.precontrol.controller.publics.BaseController;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import lombok.extern.slf4j.Slf4j;
/**
* 风险作业管理表
*
* @author duanwei
* @date 2021-01-28
*/
@Slf4j
@RestController
@Api(tags = "风险作业管理表Api")
@RequestMapping(value = "/risk-work", produces = MediaType.APPLICATION_JSON_UTF8_VALUE)
public class RiskWorkController extends BaseController {
@Autowired
IRiskWorkService iRiskWorkService;
/**
* 新增风险作业管理表
*
* @return
*/
@RequestMapping(value = "/save", method = RequestMethod.POST)
@ApiOperation(httpMethod = "POST", value = "新增风险作业管理表", notes = "新增风险作业管理表")
@OpsLog(value=OpsLogEnum.EDIT_RISKWORK)
public RiskWorkParam saveRiskWork(@RequestBody @Valid RiskWorkParam riskWorkParam) {
if(log.isInfoEnabled()){
log.info("新增风险作业管理表:{}", JSONObject.toJSONString(riskWorkParam));
}
Person person = getPerson();
riskWorkParam.getRiskWork().setOrgCode(person!=null?person.getOrgCode():null);
return iRiskWorkService.saveWithChild(riskWorkParam, getUserId());
}
/**
* 根据id删除
*
* @param ids
* @return
*/
@RequestMapping(value = "/{ids}", method = RequestMethod.DELETE)
@ApiOperation(httpMethod = "DELETE", value = "根据id删除,批量刪除", notes = "根据id删除,批量刪除")
@OpsLog(value=OpsLogEnum.DELETE_RISKWORK)
public boolean deleteById(@PathVariable String ids) {
if(log.isInfoEnabled()){
log.info("根据id删除,批量刪除:{}", JSONObject.toJSONString(ids));
}
List<Long> idList = Arrays.stream(ids.split(",")).map(Long::parseLong).collect(Collectors.toList());
return iRiskWorkService.removeWithChild(idList);
}
/**
* 根据id查询
*
* @param id
* @return
*/
@RequestMapping(value = "/{id}", method = RequestMethod.GET)
@ApiOperation(httpMethod = "GET", value = "根据id查询", notes = "根据id查询")
public RiskWorkParam selectById(@PathVariable Long id) {
return iRiskWorkService.getWithChildById(id);
}
/**
* 列表分页查询
*
* @return QUALIFICATION_REQUIREMENT
*/
@RequestMapping(value = "/page/list", method = RequestMethod.GET)
@ApiOperation(httpMethod = "GET", value = "列表分页查询", notes = "列表分页查询")
public IPage<RiskWork> listPage(@RequestParam Integer pageNumber,
@RequestParam Integer pageSize,
@RequestParam(required = false) @ApiParam("风险作业名称") String name,
@RequestParam(required = false) @ApiParam("风险等级id") Integer level) {
buildRequestContext();
Person person = getPerson();
Page<RiskWork> pageBean = new Page<>(pageNumber, pageSize);
QueryWrapper<RiskWork> riskWorkQueryWrapper = new QueryWrapper<>();
if (StringUtil.isNotEmpty(name)) {
riskWorkQueryWrapper.lambda().like(RiskWork::getName, name);
}
if (StringUtil.isNotEmpty(level)) {
riskWorkQueryWrapper.lambda().eq(RiskWork::getLevel, level);
}
String orgCode=person!=null?person.getOrgCode():null;
if(orgCode!=null)
{
riskWorkQueryWrapper.lambda().like(RiskWork::getOrgCode, orgCode);
}
riskWorkQueryWrapper.orderByDesc("create_date");
IPage<RiskWork> page = iRiskWorkService.page(pageBean, riskWorkQueryWrapper);
Set<String> userIds = page.getRecords().stream().map(RiskWork::getCreateId).collect(Collectors.toSet());
userIds.remove(null);
userIds.remove("");
FeignClientResult<List<AgencyUserModel>> result = CollectionUtils.isEmpty(userIds) ? null : Privilege.agencyUserClient.queryByIds(Joiner.on(",").join(userIds),true);
if (result != null) {
List<AgencyUserModel> userModels = result.getResult();
Map<String, String> userMap = userModels.stream().collect(Collectors.toMap(AgencyUserModel::getUserId, AgencyUserModel::getRealName));
page.getRecords().forEach(r -> {
r.setCreateName(userMap.get(r.getCreateId()));
});
}
return page;
}
@ApiOperation(httpMethod = "GET", value = "风险作业列表查询,不分页", notes = "风险作业列表查询,不分页")
@RequestMapping(value = "/list-all", method = RequestMethod.GET)
public List<RiskWork> listAll(@RequestParam(required = false) String name){
Person person = getPerson();
String orgCode=person!=null?person.getOrgCode():null;
return iRiskWorkService.listAllWithDangerWork(name,orgCode);
}
@ApiOperation(httpMethod = "GET", value = "查询符合条件的人")
@GetMapping(value = "/person/list")
public List<RiskWorkPersonVo> matchConditionPerson(
@ApiParam(required = true,value = "风险作业id") @RequestParam Long riskWorkId,
@ApiParam(required = true,value = "人员类型") @RequestParam String personType,
@ApiParam(required = true,value = "公司id") @RequestParam Long companyId,
@ApiParam(value = "人姓名") @RequestParam(required = false) String name,
@ApiParam(required = true,value = "项目id") @RequestParam Long projectId){
buildRequestContext();
return iRiskWorkService.listPersonOfMatchCondition(riskWorkId,personType,companyId,projectId,name);
}
@ApiOperation(httpMethod = "GET", value = "查询关联风险计划的风险作业信息")
@GetMapping(value = "/detail/{taskRiskControlId}")
public RiskWorkVo getRiskWorkInfo(@PathVariable Long taskRiskControlId) {
return iRiskWorkService.getDetailByPlanId(taskRiskControlId);
}
}
package com.yeejoin.precontrol.controller;
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.yeejoin.precontrol.common.entity.RiskWorkHazadousWork;
import com.yeejoin.precontrol.common.service.IRiskWorkHazadousWorkService;
import com.yeejoin.precontrol.common.utils.NameUtils;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.MediaType;
import org.springframework.web.bind.annotation.*;
import javax.servlet.http.HttpServletRequest;
import java.util.Arrays;
/**
* 风险作业关联危险作业表
*
* @author duanwei
* @date 2021-01-28
*/
@RestController
@Api(tags = "风险作业关联危险作业表Api")
@RequestMapping(value = "/risk-work-hazadous-work", produces = MediaType.APPLICATION_JSON_UTF8_VALUE)
public class RiskWorkHazadousWorkController {
@Autowired
IRiskWorkHazadousWorkService iRiskWorkHazadousWorkService;
/**
* 新增风险作业关联危险作业表
*
* @return
*/
@RequestMapping(value = "/save", method = RequestMethod.POST)
@ApiOperation(httpMethod = "POST", value = "新增风险作业关联危险作业表", notes = "新增风险作业关联危险作业表")
public boolean saveRiskWorkHazadousWork(HttpServletRequest request, @RequestBody RiskWorkHazadousWork riskWorkHazadousWork) {
return iRiskWorkHazadousWorkService.save(riskWorkHazadousWork);
}
/**
* 根据id删除
*
* @param id
* @return
*/
@RequestMapping(value = "/{id}", method = RequestMethod.DELETE)
@ApiOperation(httpMethod = "DELETE", value = "根据id删除", notes = "根据id删除")
public boolean deleteById(HttpServletRequest request, @PathVariable Long id) {
return iRiskWorkHazadousWorkService.removeById(id);
}
/**
* 修改风险作业关联危险作业表
*
* @return
*/
@RequestMapping(value = "/updateById", method = RequestMethod.PUT)
@ApiOperation(httpMethod = "PUT", value = "修改风险作业关联危险作业表", notes = "修改风险作业关联危险作业表")
public boolean updateByIdRiskWorkHazadousWork(HttpServletRequest request, @RequestBody RiskWorkHazadousWork riskWorkHazadousWork) {
return iRiskWorkHazadousWorkService.updateById(riskWorkHazadousWork);
}
/**
* 根据id查询
*
* @param id
* @return
*/
@RequestMapping(value = "/{id}", method = RequestMethod.GET)
@ApiOperation(httpMethod = "GET", value = "根据id查询", notes = "根据id查询")
public RiskWorkHazadousWork selectById(HttpServletRequest request, @PathVariable Long id) {
return iRiskWorkHazadousWorkService.getById(id);
}
/**
* 列表分页查询
*
* @return
*/
@RequestMapping(value = "/list", method = RequestMethod.GET)
@ApiOperation(httpMethod = "GET", value = "列表分页查询", notes = "列表分页查询")
public IPage<RiskWorkHazadousWork> listPage(String pageNum, String pageSize,
RiskWorkHazadousWork riskWorkHazadousWork) {
Page<RiskWorkHazadousWork> pageBean;
QueryWrapper<RiskWorkHazadousWork> riskWorkHazadousWorkQueryWrapper = new QueryWrapper<>();
Class<? extends RiskWorkHazadousWork> aClass = riskWorkHazadousWork.getClass();
Arrays.stream(aClass.getDeclaredFields()).forEach(field -> {
try {
field.setAccessible(true);
Object o = field.get(riskWorkHazadousWork);
if (o != null) {
Class<?> type = field.getType();
String name = NameUtils.camel2Underline(field.getName());
if (type.equals(Integer.class)) {
Integer fileValue = (Integer) field.get(riskWorkHazadousWork);
riskWorkHazadousWorkQueryWrapper.eq(name, fileValue);
} else if (type.equals(Long.class)) {
Long fileValue = (Long) field.get(riskWorkHazadousWork);
riskWorkHazadousWorkQueryWrapper.eq(name, fileValue);
} else if (type.equals(String.class)) {
String fileValue = (String) field.get(riskWorkHazadousWork);
riskWorkHazadousWorkQueryWrapper.eq(name, fileValue);
} else {
String fileValue = (String) field.get(riskWorkHazadousWork);
riskWorkHazadousWorkQueryWrapper.eq(name, fileValue);
}
}
} catch (Exception e) {
}
});
IPage<RiskWorkHazadousWork> page;
if (StringUtils.isBlank(pageNum) || StringUtils.isBlank(pageSize)) {
pageBean = new Page<>(0, Long.MAX_VALUE);
} else {
pageBean = new Page<>(Integer.parseInt(pageNum), Integer.parseInt(pageSize));
}
page = iRiskWorkHazadousWorkService.page(pageBean, riskWorkHazadousWorkQueryWrapper);
return page;
}
}
package com.yeejoin.precontrol.controller;
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.yeejoin.precontrol.common.entity.RiskWorkMeasure;
import com.yeejoin.precontrol.common.service.IRiskWorkMeasureService;
import com.yeejoin.precontrol.common.utils.NameUtils;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.MediaType;
import org.springframework.web.bind.annotation.*;
import javax.servlet.http.HttpServletRequest;
import java.util.Arrays;
/**
* 管控措施
*
* @author duanwei
* @date 2021-01-28
*/
@RestController
@Api(tags = "管控措施Api")
@RequestMapping(value = "/risk-work-measure", produces = MediaType.APPLICATION_JSON_UTF8_VALUE)
public class RiskWorkMeasureController {
@Autowired
IRiskWorkMeasureService iRiskWorkMeasureService;
/**
* 新增管控措施
*
* @return
*/
@RequestMapping(value = "/save", method = RequestMethod.POST)
@ApiOperation(httpMethod = "POST", value = "新增管控措施", notes = "新增管控措施")
public boolean saveRiskWorkMeasure(HttpServletRequest request, @RequestBody RiskWorkMeasure riskWorkMeasure) {
return iRiskWorkMeasureService.save(riskWorkMeasure);
}
/**
* 根据id删除
*
* @param id
* @return
*/
@RequestMapping(value = "/{id}", method = RequestMethod.DELETE)
@ApiOperation(httpMethod = "DELETE", value = "根据id删除", notes = "根据id删除")
public boolean deleteById(HttpServletRequest request, @PathVariable Long id) {
return iRiskWorkMeasureService.removeById(id);
}
/**
* 修改管控措施
*
* @return
*/
@RequestMapping(value = "/updateById", method = RequestMethod.PUT)
@ApiOperation(httpMethod = "PUT", value = "修改管控措施", notes = "修改管控措施")
public boolean updateByIdRiskWorkMeasure(HttpServletRequest request, @RequestBody RiskWorkMeasure riskWorkMeasure) {
return iRiskWorkMeasureService.updateById(riskWorkMeasure);
}
/**
* 根据id查询
*
* @param id
* @return
*/
@RequestMapping(value = "/{id}", method = RequestMethod.GET)
@ApiOperation(httpMethod = "GET", value = "根据id查询", notes = "根据id查询")
public RiskWorkMeasure selectById(HttpServletRequest request, @PathVariable Long id) {
return iRiskWorkMeasureService.getById(id);
}
/**
* 列表分页查询
*
* @return
*/
@RequestMapping(value = "/list", method = RequestMethod.GET)
@ApiOperation(httpMethod = "GET", value = "列表分页查询", notes = "列表分页查询")
public IPage<RiskWorkMeasure> listPage(String pageNum, String pageSize,
RiskWorkMeasure riskWorkMeasure) {
Page<RiskWorkMeasure> pageBean;
QueryWrapper<RiskWorkMeasure> riskWorkMeasureQueryWrapper = new QueryWrapper<>();
Class<? extends RiskWorkMeasure> aClass = riskWorkMeasure.getClass();
Arrays.stream(aClass.getDeclaredFields()).forEach(field -> {
try {
field.setAccessible(true);
Object o = field.get(riskWorkMeasure);
if (o != null) {
Class<?> type = field.getType();
String name = NameUtils.camel2Underline(field.getName());
if (type.equals(Integer.class)) {
Integer fileValue = (Integer) field.get(riskWorkMeasure);
riskWorkMeasureQueryWrapper.eq(name, fileValue);
} else if (type.equals(Long.class)) {
Long fileValue = (Long) field.get(riskWorkMeasure);
riskWorkMeasureQueryWrapper.eq(name, fileValue);
} else if (type.equals(String.class)) {
String fileValue = (String) field.get(riskWorkMeasure);
riskWorkMeasureQueryWrapper.eq(name, fileValue);
} else {
String fileValue = (String) field.get(riskWorkMeasure);
riskWorkMeasureQueryWrapper.eq(name, fileValue);
}
}
} catch (Exception e) {
}
});
IPage<RiskWorkMeasure> page;
if (StringUtils.isBlank(pageNum) || StringUtils.isBlank(pageSize)) {
pageBean = new Page<>(0, Long.MAX_VALUE);
} else {
pageBean = new Page<>(Integer.parseInt(pageNum), Integer.parseInt(pageSize));
}
page = iRiskWorkMeasureService.page(pageBean, riskWorkMeasureQueryWrapper);
return page;
}
}
package com.yeejoin.precontrol.controller;
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.yeejoin.precontrol.common.entity.RiskWorkPersonRequirement;
import com.yeejoin.precontrol.common.service.IRiskWorkPersonRequirementService;
import com.yeejoin.precontrol.common.utils.NameUtils;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.MediaType;
import org.springframework.web.bind.annotation.*;
import javax.servlet.http.HttpServletRequest;
import java.util.Arrays;
/**
* 风险作业人员要求表
*
* @author duanwei
* @date 2021-01-28
*/
@RestController
@Api(tags = "风险作业人员要求表Api")
@RequestMapping(value = "/risk-work-person-requirement", produces = MediaType.APPLICATION_JSON_UTF8_VALUE)
public class RiskWorkPersonRequirementController {
@Autowired
IRiskWorkPersonRequirementService iRiskWorkPersonRequirementService;
/**
* 新增风险作业人员要求表
*
* @return
*/
@RequestMapping(value = "/save", method = RequestMethod.POST)
@ApiOperation(httpMethod = "POST", value = "新增风险作业人员要求表", notes = "新增风险作业人员要求表")
public boolean saveRiskWorkPersonRequirement(HttpServletRequest request, @RequestBody RiskWorkPersonRequirement riskWorkPersonRequirement) {
return iRiskWorkPersonRequirementService.save(riskWorkPersonRequirement);
}
/**
* 根据id删除
*
* @param id
* @return
*/
@RequestMapping(value = "/{id}", method = RequestMethod.DELETE)
@ApiOperation(httpMethod = "DELETE", value = "根据id删除", notes = "根据id删除")
public boolean deleteById(HttpServletRequest request, @PathVariable Long id) {
return iRiskWorkPersonRequirementService.removeById(id);
}
/**
* 修改风险作业人员要求表
*
* @return
*/
@RequestMapping(value = "/updateById", method = RequestMethod.PUT)
@ApiOperation(httpMethod = "PUT", value = "修改风险作业人员要求表", notes = "修改风险作业人员要求表")
public boolean updateByIdRiskWorkPersonRequirement(HttpServletRequest request, @RequestBody RiskWorkPersonRequirement riskWorkPersonRequirement) {
return iRiskWorkPersonRequirementService.updateById(riskWorkPersonRequirement);
}
/**
* 根据id查询
*
* @param id
* @return
*/
@RequestMapping(value = "/{id}", method = RequestMethod.GET)
@ApiOperation(httpMethod = "GET", value = "根据id查询", notes = "根据id查询")
public RiskWorkPersonRequirement selectById(HttpServletRequest request, @PathVariable Long id) {
return iRiskWorkPersonRequirementService.getById(id);
}
/**
* 列表分页查询
*
* @return
*/
@RequestMapping(value = "/list", method = RequestMethod.GET)
@ApiOperation(httpMethod = "GET", value = "列表分页查询", notes = "列表分页查询")
public IPage<RiskWorkPersonRequirement> listPage(String pageNum, String pageSize,
RiskWorkPersonRequirement riskWorkPersonRequirement) {
Page<RiskWorkPersonRequirement> pageBean;
QueryWrapper<RiskWorkPersonRequirement> riskWorkPersonRequirementQueryWrapper = new QueryWrapper<>();
Class<? extends RiskWorkPersonRequirement> aClass = riskWorkPersonRequirement.getClass();
Arrays.stream(aClass.getDeclaredFields()).forEach(field -> {
try {
field.setAccessible(true);
Object o = field.get(riskWorkPersonRequirement);
if (o != null) {
Class<?> type = field.getType();
String name = NameUtils.camel2Underline(field.getName());
if (type.equals(Integer.class)) {
Integer fileValue = (Integer) field.get(riskWorkPersonRequirement);
riskWorkPersonRequirementQueryWrapper.eq(name, fileValue);
} else if (type.equals(Long.class)) {
Long fileValue = (Long) field.get(riskWorkPersonRequirement);
riskWorkPersonRequirementQueryWrapper.eq(name, fileValue);
} else if (type.equals(String.class)) {
String fileValue = (String) field.get(riskWorkPersonRequirement);
riskWorkPersonRequirementQueryWrapper.eq(name, fileValue);
} else {
String fileValue = (String) field.get(riskWorkPersonRequirement);
riskWorkPersonRequirementQueryWrapper.eq(name, fileValue);
}
}
} catch (Exception e) {
}
});
IPage<RiskWorkPersonRequirement> page;
if (StringUtils.isBlank(pageNum) || StringUtils.isBlank(pageSize)) {
pageBean = new Page<>(0, Long.MAX_VALUE);
} else {
pageBean = new Page<>(Integer.parseInt(pageNum), Integer.parseInt(pageSize));
}
page = iRiskWorkPersonRequirementService.page(pageBean, riskWorkPersonRequirementQueryWrapper);
return page;
}
}
package com.yeejoin.precontrol.controller;
import java.util.Arrays;
import javax.servlet.http.HttpServletRequest;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.MediaType;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;
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.yeejoin.precontrol.common.dto.KnowledgeShareDto;
import com.yeejoin.precontrol.common.entity.Person;
import com.yeejoin.precontrol.common.entity.Task;
import com.yeejoin.precontrol.common.service.ITaskKnowledgeShareService;
import com.yeejoin.precontrol.common.utils.NameUtils;
import com.yeejoin.precontrol.controller.publics.BaseController;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
/**
* 知识分享任务表
*
* @author wujiang
* @date 2020-12-21
*/
@RestController
@Api(tags = "知识分享任务表Api")
@RequestMapping(value = "/task-knowledge-share", produces = MediaType.APPLICATION_JSON_UTF8_VALUE)
public class TaskKnowledgeShareController extends BaseController {
@Autowired
ITaskKnowledgeShareService iTaskKnowledgeShareService;
/**
* 新增知识分享
*
* @return
*
*/
@RequestMapping(value = "/save", method = RequestMethod.POST)
@ApiOperation(httpMethod = "POST", value = "新增知识分享", notes = "新增知识分享")
public boolean save(HttpServletRequest request, @RequestBody KnowledgeShareDto knowledgeShareDto) {
Person peron = getPerson();
knowledgeShareDto.setCreatePersonId(peron.getId());
knowledgeShareDto.setOrgCode(peron.getOrgCode());
knowledgeShareDto = iTaskKnowledgeShareService.saveOne(knowledgeShareDto);
iTaskKnowledgeShareService.knowledgeNotice(knowledgeShareDto); // 发送知识推送消息
return true;
}
/**
* 根据id删除
*
* @param id
* @return
*/
@RequestMapping(value = "/{id}", method = RequestMethod.DELETE)
@ApiOperation(httpMethod = "DELETE", value = "根据id删除", notes = "根据id删除")
public boolean deleteById(HttpServletRequest request, @PathVariable Long id) {
return iTaskKnowledgeShareService.removeById(id);
}
/**
* 修改知识分享
*
* @return
*/
@RequestMapping(value = "/updateById", method = RequestMethod.PUT)
@ApiOperation(httpMethod = "PUT", value = "修改知识分享", notes = "修改知识分享")
public boolean updateByIdTaskPersonFeedback(HttpServletRequest request,
@RequestBody KnowledgeShareDto knowledgeShareDto) {
return iTaskKnowledgeShareService.updateOneById(knowledgeShareDto);
}
/**
* 根据id查询
*
* @param id
* @return
*/
@RequestMapping(value = "/{id}", method = RequestMethod.GET)
@ApiOperation(httpMethod = "GET", value = "根据id查询", notes = "根据id查询")
public KnowledgeShareDto selectById(HttpServletRequest request, @PathVariable Long id) {
Person person = getPerson();
return iTaskKnowledgeShareService.queryById(person.getId(), id);
}
/**
* 列表分页查询
*
* @return
*/
@RequestMapping(value = "/list", method = RequestMethod.GET)
@ApiOperation(httpMethod = "GET", value = "列表分页查询", notes = "列表分页查询")
public IPage<Task> listPage(String pageNum, String pageSize, KnowledgeShareDto knowledgeShareDto) {
Page<Task> pageBean;
QueryWrapper<Task> knowledgeShareQueryWrapper = new QueryWrapper<>();
Class<? extends KnowledgeShareDto> aClass = knowledgeShareDto.getClass();
Arrays.stream(aClass.getDeclaredFields()).forEach(field -> {
try {
field.setAccessible(true);
Object o = field.get(knowledgeShareDto);
if (o != null) {
Class<?> type = field.getType();
String name = NameUtils.camel2Underline(field.getName());
if (type.equals(Integer.class)) {
Integer fileValue = (Integer) field.get(knowledgeShareDto);
knowledgeShareQueryWrapper.eq(name, fileValue);
} else if (type.equals(Long.class)) {
Long fileValue = (Long) field.get(knowledgeShareDto);
knowledgeShareQueryWrapper.eq(name, fileValue);
} else if (type.equals(String.class)) {
String fileValue = (String) field.get(knowledgeShareDto);
knowledgeShareQueryWrapper.eq(name, fileValue);
} else {
String fileValue = (String) field.get(knowledgeShareDto);
knowledgeShareQueryWrapper.eq(name, fileValue);
}
}
} catch (Exception e) {
}
});
IPage<Task> page;
if (StringUtils.isBlank(pageNum) || StringUtils.isBlank(pageSize)) {
pageBean = new Page<>(0, Long.MAX_VALUE);
} else {
pageBean = new Page<>(Integer.parseInt(pageNum), Integer.parseInt(pageSize));
}
page = iTaskKnowledgeShareService.page(pageBean, knowledgeShareQueryWrapper);
return page;
}
}
package com.yeejoin.precontrol.controller;
import java.util.Arrays;
import javax.servlet.http.HttpServletRequest;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.MediaType;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;
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.yeejoin.precontrol.common.entity.TaskPersonFeedback;
import com.yeejoin.precontrol.common.service.ITaskPersonFeedbackService;
import com.yeejoin.precontrol.common.utils.NameUtils;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
/**
* 人员反馈表
*
* @author duanwei
* @date 2020-12-08
*/
@RestController
@Api(tags = "人员反馈表Api")
@RequestMapping(value = "/task-person-feedback", produces = MediaType.APPLICATION_JSON_UTF8_VALUE)
public class TaskPersonFeedbackController {
@Autowired
ITaskPersonFeedbackService iTaskPersonFeedbackService;
/**
* 新增人员反馈表
*
* @return
*/
@RequestMapping(value = "/save", method = RequestMethod.POST)
@ApiOperation(httpMethod = "POST", value = "新增人员反馈表", notes = "新增人员反馈表")
public boolean saveTaskPersonFeedback(HttpServletRequest request,
@RequestBody TaskPersonFeedback taskPersonFeedback) {
return iTaskPersonFeedbackService.saveFeedBack(taskPersonFeedback);
}
/**
* 根据id删除
*
* @param id
* @return
*/
@RequestMapping(value = "/{id}", method = RequestMethod.DELETE)
@ApiOperation(httpMethod = "DELETE", value = "根据id删除", notes = "根据id删除")
public boolean deleteById(HttpServletRequest request, @PathVariable Long id) {
return iTaskPersonFeedbackService.removeById(id);
}
/**
* 修改人员反馈表
*
* @return
*/
@RequestMapping(value = "/updateById", method = RequestMethod.PUT)
@ApiOperation(httpMethod = "PUT", value = "修改人员反馈表", notes = "修改人员反馈表")
public boolean updateByIdTaskPersonFeedback(HttpServletRequest request,
@RequestBody TaskPersonFeedback taskPersonFeedback) {
return iTaskPersonFeedbackService.updateById(taskPersonFeedback);
}
/**
* 根据id查询
*
* @param id
* @return
*/
@RequestMapping(value = "/{id}", method = RequestMethod.GET)
@ApiOperation(httpMethod = "GET", value = "根据id查询", notes = "根据id查询")
public TaskPersonFeedback selectById(HttpServletRequest request, @PathVariable Long id) {
return iTaskPersonFeedbackService.getById(id);
}
/**
* 列表分页查询
*
* @return
*/
@RequestMapping(value = "/list", method = RequestMethod.GET)
@ApiOperation(httpMethod = "GET", value = "列表分页查询", notes = "列表分页查询")
public IPage<TaskPersonFeedback> listPage(String pageNum, String pageSize, TaskPersonFeedback taskPersonFeedback) {
Page<TaskPersonFeedback> pageBean;
QueryWrapper<TaskPersonFeedback> taskPersonFeedbackQueryWrapper = new QueryWrapper<>();
Class<? extends TaskPersonFeedback> aClass = taskPersonFeedback.getClass();
Arrays.stream(aClass.getDeclaredFields()).forEach(field -> {
try {
field.setAccessible(true);
Object o = field.get(taskPersonFeedback);
if (o != null) {
Class<?> type = field.getType();
String name = NameUtils.camel2Underline(field.getName());
if (type.equals(Integer.class)) {
Integer fileValue = (Integer) field.get(taskPersonFeedback);
taskPersonFeedbackQueryWrapper.eq(name, fileValue);
} else if (type.equals(Long.class)) {
Long fileValue = (Long) field.get(taskPersonFeedback);
taskPersonFeedbackQueryWrapper.eq(name, fileValue);
} else if (type.equals(String.class)) {
String fileValue = (String) field.get(taskPersonFeedback);
taskPersonFeedbackQueryWrapper.eq(name, fileValue);
} else {
String fileValue = (String) field.get(taskPersonFeedback);
taskPersonFeedbackQueryWrapper.eq(name, fileValue);
}
}
} catch (Exception e) {
}
});
IPage<TaskPersonFeedback> page;
if (StringUtils.isBlank(pageNum) || StringUtils.isBlank(pageSize)) {
pageBean = new Page<>(0, Long.MAX_VALUE);
} else {
pageBean = new Page<>(Integer.parseInt(pageNum), Integer.parseInt(pageSize));
}
page = iTaskPersonFeedbackService.page(pageBean, taskPersonFeedbackQueryWrapper);
return page;
}
}
package com.yeejoin.precontrol.controller;
import java.util.Arrays;
import java.util.List;
import javax.servlet.http.HttpServletRequest;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.http.MediaType;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;
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.yeejoin.precontrol.common.entity.TaskRiskControlPrePerson;
import com.yeejoin.precontrol.common.service.ITaskRiskControlPrePersonService;
import com.yeejoin.precontrol.common.utils.NameUtils;
import com.yeejoin.precontrol.common.vo.TaskRiskControlPrePersonVo;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
/**
* 风险管控预选人员表
*
* @author duanwei
* @date 2021-01-28
*/
@RestController
@Api(tags = "风险管控预选人员表Api")
@RequestMapping(value = "/task-risk-control-pre-person", produces = MediaType.APPLICATION_JSON_UTF8_VALUE)
public class TaskRiskControlPrePersonController {
@Autowired
ITaskRiskControlPrePersonService iTaskRiskControlPrePersonService;
/**
* 文件服务器地址
*/
@Value("${fileserver.domain}")
String fileServerUrl;
/**
* 新增风险管控预选人员表
* @return
*/
@RequestMapping(value = "/save", method = RequestMethod.POST)
@ApiOperation(httpMethod = "POST", value = "新增风险管控预选人员表", notes = "新增风险管控预选人员表")
public boolean saveTaskRiskControlPrePerson(HttpServletRequest request, @RequestBody TaskRiskControlPrePerson taskRiskControlPrePerson){
return iTaskRiskControlPrePersonService.save(taskRiskControlPrePerson);
}
/**
* 根据id删除
* @param id
* @return
*/
@RequestMapping(value = "/{id}", method = RequestMethod.DELETE)
@ApiOperation(httpMethod = "DELETE", value = "根据id删除", notes = "根据id删除")
public boolean deleteById(HttpServletRequest request, @PathVariable Long id){
return iTaskRiskControlPrePersonService.removeById(id);
}
/**
* 修改风险管控预选人员表
* @return
*/
@RequestMapping(value = "/updateById", method = RequestMethod.PUT)
@ApiOperation(httpMethod = "PUT", value = "修改风险管控预选人员表", notes = "修改风险管控预选人员表")
public boolean updateByIdTaskRiskControlPrePerson(HttpServletRequest request, @RequestBody TaskRiskControlPrePerson taskRiskControlPrePerson){
return iTaskRiskControlPrePersonService.updateById(taskRiskControlPrePerson);
}
/**
* 根据id查询
* @param id
* @return
*/
@RequestMapping(value = "/{id}", method = RequestMethod.GET)
@ApiOperation(httpMethod = "GET", value = "根据id查询", notes = "根据id查询")
public TaskRiskControlPrePerson selectById(HttpServletRequest request, @PathVariable Long id){
return iTaskRiskControlPrePersonService.getById(id);
}
/**
* 列表分页查询
* @return
*/
@RequestMapping(value = "/list", method = RequestMethod.GET)
@ApiOperation(httpMethod = "GET", value = "列表分页查询", notes = "列表分页查询")
public IPage<TaskRiskControlPrePersonVo> listPage(String pageNum,String pageSize,
TaskRiskControlPrePerson taskRiskControlPrePerson){
Page<TaskRiskControlPrePerson> pageBean;
QueryWrapper<TaskRiskControlPrePerson> taskRiskControlPrePersonQueryWrapper = new QueryWrapper<>();
Class<? extends TaskRiskControlPrePerson> aClass = taskRiskControlPrePerson.getClass();
Arrays.stream(aClass.getDeclaredFields()).forEach(field -> {
try {
field.setAccessible(true);
Object o = field.get(taskRiskControlPrePerson);
if (o != null) {
Class<?> type = field.getType();
String name = NameUtils.camel2Underline(field.getName());
if (type.equals(Integer.class)) {
Integer fileValue = (Integer) field.get(taskRiskControlPrePerson);
taskRiskControlPrePersonQueryWrapper.eq(name, fileValue);
} else if (type.equals(Long.class)) {
Long fileValue = (Long) field.get(taskRiskControlPrePerson);
taskRiskControlPrePersonQueryWrapper.eq(name, fileValue);
} else if (type.equals(String.class)) {
String fileValue = (String) field.get(taskRiskControlPrePerson);
taskRiskControlPrePersonQueryWrapper.eq(name, fileValue);
} else {
String fileValue = (String) field.get(taskRiskControlPrePerson);
taskRiskControlPrePersonQueryWrapper.eq(name, fileValue);
}
}
}catch (Exception e) {
}
});
// IPage<TaskRiskControlPrePerson> page;
// if (StringUtils.isBlank(pageNum) ||StringUtils.isBlank(pageSize)) {
// pageBean = new Page<>(0, Long.MAX_VALUE);
// }else{
// pageBean = new Page<>(Integer.parseInt(pageNum), Integer.parseInt(pageSize));
// }
// page = iTaskRiskControlPrePersonService.page(pageBean, taskRiskControlPrePersonQueryWrapper);
List<TaskRiskControlPrePersonVo> list = iTaskRiskControlPrePersonService.listVo(taskRiskControlPrePerson);
IPage<TaskRiskControlPrePersonVo> page1 = new Page<>(0, Long.MAX_VALUE);
list.forEach(i->i.setHeadPhoto(fileServerUrl+i.getHeadPhoto()));
page1.setRecords(list);
return page1;
}
}
package com.yeejoin.precontrol.controller;
import java.text.ParseException;
import java.util.HashMap;
import java.util.Map;
import javax.servlet.http.HttpServletRequest;
import com.yeejoin.precontrol.common.service.IPersonService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.MediaType;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.multipart.MultipartFile;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.yeejoin.precontrol.common.dto.CommonPageableDto;
import com.yeejoin.precontrol.common.dto.TaskPersonDto;
import com.yeejoin.precontrol.common.dto.TaskSalaryConfirmDto;
import com.yeejoin.precontrol.common.entity.Person;
import com.yeejoin.precontrol.common.entity.Task;
import com.yeejoin.precontrol.common.entity.TaskPerson;
import com.yeejoin.precontrol.common.entity.TaskSalaryConfirm;
import com.yeejoin.precontrol.common.enums.StatusEnum;
import com.yeejoin.precontrol.common.exception.BaseException;
import com.yeejoin.precontrol.common.param.PersonParam;
import com.yeejoin.precontrol.common.service.ITaskPersonService;
import com.yeejoin.precontrol.common.service.ITaskSalaryConfirmService;
import com.yeejoin.precontrol.common.vo.PersonVo;
import com.yeejoin.precontrol.common.vo.TaskSalaryConfirmOneVo;
import com.yeejoin.precontrol.common.vo.TaskSalaryConfirmVo;
import com.yeejoin.precontrol.controller.publics.BaseController;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
/**
* 薪资确认任务表
*
* @author duanwei
* @date 2020-12-08
*/
@RestController
@Api(tags = "薪资确认任务表Api")
@RequestMapping(value = "/task-salary-confirm", produces = MediaType.APPLICATION_JSON_UTF8_VALUE)
public class TaskSalaryConfirmController extends BaseController {
@Autowired
ITaskSalaryConfirmService iTaskSalaryConfirmService;
@Autowired
ITaskPersonService iTaskPersonService;
@Autowired
IPersonService personService;
/**
* 新增薪资确认任务表
*
* @return
*/
@RequestMapping(value = "/save", method = RequestMethod.POST)
@ApiOperation(httpMethod = "POST", value = "新增薪资确认任务表", notes = "新增薪资确认任务表")
public Task saveTaskSalaryConfirm(HttpServletRequest request,
@RequestBody TaskSalaryConfirmDto taskSalaryConfirmDto) throws ParseException {
Person person = getPerson();
return iTaskSalaryConfirmService.save(taskSalaryConfirmDto, person);
}
/**
* 根据id删除
*
* @param id
* @return
*/
@RequestMapping(value = "/{id}", method = RequestMethod.DELETE)
@ApiOperation(httpMethod = "DELETE", value = "根据id删除", notes = "根据id删除")
public boolean deleteById(HttpServletRequest request, @PathVariable Long id) {
return iTaskSalaryConfirmService.removeById(id);
}
/**
* 修改薪资确认任务表
*
* @return
*/
@RequestMapping(value = "/updateById", method = RequestMethod.PUT)
@ApiOperation(httpMethod = "PUT", value = "修改薪资确认任务表", notes = "修改薪资确认任务表")
public boolean updateByIdTaskSalaryConfirm(HttpServletRequest request,
@RequestBody TaskSalaryConfirm taskSalaryConfirm) {
return iTaskSalaryConfirmService.updateById(taskSalaryConfirm);
}
/**
* 根据id查询
*
* @param id
* @return
*/
@RequestMapping(value = "/{id}", method = RequestMethod.GET)
@ApiOperation(httpMethod = "GET", value = "根据id查询", notes = "根据id查询")
public TaskSalaryConfirmVo selectById(HttpServletRequest request, @PathVariable Long id) {
return iTaskSalaryConfirmService.queryById(id);
}
/**
* 列表分页查询
*
* @return
*/
@RequestMapping(value = "/list", method = RequestMethod.GET)
@ApiOperation(httpMethod = "GET", value = "列表分页查询", notes = "列表分页查询")
public Object listPage(CommonPageableDto pageable, TaskSalaryConfirmDto taskSalaryConfirmDto) {
IPage<TaskSalaryConfirmVo> iPage = iTaskSalaryConfirmService.pageInfo(pageable, taskSalaryConfirmDto);
return iPage;
}
/**
* 确认薪资
*
* @return
*/
@RequestMapping(value = "/confirm", method = RequestMethod.POST)
@ApiOperation(httpMethod = "POST", value = "确认薪资", notes = "确认薪资")
public boolean confirm(@RequestBody TaskPersonDto taskPersonDto) {
return iTaskSalaryConfirmService.confirm(taskPersonDto);
}
/**
* 薪资确认我的待办
*
* @return
*/
@RequestMapping(value = "/todo", method = RequestMethod.GET)
@ApiOperation(httpMethod = "GET", value = "我的待办列表分页查询", notes = "我的待办列表分页查询")
public Object todo(CommonPageableDto pageable, TaskSalaryConfirmOneVo taskSalaryConfirmOneVo) {
Person person = personService.getById(getPerson().getId());
//分包商只看自己的----userId;江西电建查看项目部的----orgCode
if (person.getIsJxdj() == 0) {
taskSalaryConfirmOneVo.setPersonId(person.getId());
taskSalaryConfirmOneVo.setOrgCode("");
}else {
taskSalaryConfirmOneVo.setOrgCode(person.getOrgCode());
}
return iTaskSalaryConfirmService.todo(pageable, taskSalaryConfirmOneVo);
}
/**
* 薪资确认我的待办详情
*
* @return
*/
@RequestMapping(value = "/todo/{taskPersonId}", method = RequestMethod.GET)
@ApiOperation(httpMethod = "GET", value = "我的待办详情查询", notes = "我的待办详情查询")
public Object todo(@PathVariable long taskPersonId) {
Long personId = getUserInfo().getSequenceNbr();
return iTaskSalaryConfirmService.todoDetail(taskPersonId,personId);
}
/**
* 薪资确认个人重新修改
*
* @return
*/
@RequestMapping(value = "/person/salary-modify", method = RequestMethod.POST)
@ApiOperation(httpMethod = "POST", value = "薪资确认个人重新修改", notes = "薪资确认个人重新修改")
public Object salaryModify(TaskPerson taskPerson) {
taskPerson.setReadStatus(StatusEnum.UNFINISHED.getValue());
return iTaskPersonService.updateById(taskPerson);
}
/**
* 薪资确认人员导入
*
* @return
* @throws Exception payAllCount
*/
@RequestMapping(value = "/person/import", method = RequestMethod.POST)
@ApiOperation(httpMethod = "POST", value = "薪资确认人员导入", notes = "薪资确认人员导入")
public Object personImport(
@ApiParam(value = "导入数据文件", required = true) @RequestBody(required = true) MultipartFile file)
throws Exception {
String fileName = file.getOriginalFilename();
if (!fileName.endsWith(".xls")) {
throw new BaseException("文件格式错误");
}
return iTaskSalaryConfirmService.personImport(file);
}
/**
* 薪资确认已发起的人员
*
* @return
* @throws Exception payAllCount
*/
@RequestMapping(value = "/{id}/person", method = RequestMethod.GET)
@ApiOperation(httpMethod = "GET", value = "薪资确认已发起的人员", notes = "薪资确认已发起的人员")
public Object persons(CommonPageableDto pageable, PersonParam personParam, @PathVariable("id") Long id) {
IPage<PersonVo> page = iTaskSalaryConfirmService.persons(id, pageable, personParam);
return page;
}
/**
* 薪资确认重新发起
*
* @return
* @throws Exception payAllCount
*/
@RequestMapping(value = "/resend", method = RequestMethod.POST)
@ApiOperation(httpMethod = "POST", value = "薪资确认重新发起", notes = "薪资确认重新发起")
public boolean resend(@RequestBody TaskSalaryConfirmOneVo salaryConfirmOneVo) {
return iTaskSalaryConfirmService.resend(salaryConfirmOneVo);
}
/**
* 薪资人数统计
*
* @return
*/
@RequestMapping(value = "/statistics/{id}", method = RequestMethod.GET)
@ApiOperation(httpMethod = "GET", value = "薪资人数统计", notes = "薪资人数统计")
public Object statistics(@PathVariable("id") Long id) {
return iTaskSalaryConfirmService.statistics(id);
}
/**
* 获取已发放比例
*/
@RequestMapping(value = "/paidRatio", method = RequestMethod.GET)
@ApiOperation(httpMethod = "GET", value = "薪资人数统计", notes = "薪资人数统计")
public Object statistics(Long projectId, Long companyId) {
Map<String, Integer> map = new HashMap<>();
map.put("ratio", iTaskSalaryConfirmService.paidRatio(projectId, companyId));
return map;
}
/**
* 是否有未阅读消息
*/
@RequestMapping(value = "/hasfirstRead", method = RequestMethod.GET)
@ApiOperation(httpMethod = "GET", value = "是否有未阅读消息", notes = "是否有未阅读消息")
public Object hasfirstRead() {
Person person = getPerson();
return iTaskSalaryConfirmService.hasFirstRead(person.getId());
}
/**
* 阅读消息
*/
@RequestMapping(value = "/dofirstRead", method = RequestMethod.POST)
@ApiOperation(httpMethod = "POST", value = " 阅读消息", notes = " 阅读消息")
public Object dofirstRead(@RequestBody Long id) {
return iTaskSalaryConfirmService.doFirstRead(id);
}
}
package com.yeejoin.precontrol.controller;
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.yeejoin.precontrol.common.entity.UserEvaluationLog;
import com.yeejoin.precontrol.common.service.IUserEvaluationLogService;
import com.yeejoin.precontrol.common.utils.NameUtils;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.apache.commons.lang3.StringUtils;
import org.apache.sis.util.collection.BackingStoreException;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.MediaType;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;
import org.typroject.tyboot.core.restful.exception.instance.BadRequest;
import javax.servlet.http.HttpServletRequest;
import java.util.Arrays;
import java.util.List;
import java.util.Optional;
/**
* 用户评价记录表
*
* @author tb
* @date 2021-01-28
*/
@RestController
@Api(tags = "用户评价记录表Api")
@RequestMapping(value = "/user-evaluation-log", produces = MediaType.APPLICATION_JSON_UTF8_VALUE)
public class UserEvaluationLogController {
@Autowired
IUserEvaluationLogService iUserEvaluationLogService;
/**
* 新增用户评价记录表
*
* @return
*/
@RequestMapping(value = "/save", method = RequestMethod.POST)
@ApiOperation(httpMethod = "POST", value = "新增用户评价记录表", notes = "新增用户评价记录表")
public boolean saveUserEvaluationLog(HttpServletRequest request,
@RequestBody List<UserEvaluationLog> userEvaluationLogs) {
Optional.ofNullable(userEvaluationLogs).orElseThrow(() -> new BadRequest("评价不能为空")).forEach(log -> {
Optional.ofNullable(log.getEvaluationUserId()).orElseThrow(() -> new BadRequest("评价人不能为空"));
Optional.ofNullable(log.getPersonId()).orElseThrow(() -> new BadRequest("被评价人不能为空"));
Optional.ofNullable(log.getRate()).orElseThrow(() -> new BadRequest("评分不能为空"));
});
return iUserEvaluationLogService.saveBatch(userEvaluationLogs);
}
/**
* 根据id删除
*
* @param id
* @return
*/
@RequestMapping(value = "/{id}", method = RequestMethod.DELETE)
@ApiOperation(httpMethod = "DELETE", value = "根据id删除", notes = "根据id删除")
public boolean deleteById(HttpServletRequest request, @PathVariable Long id) {
return iUserEvaluationLogService.removeById(id);
}
/**
* 根据被评价人id查询列表分页
*
* @return
*/
@RequestMapping(value = "/{personId}/page/list", method = RequestMethod.GET)
@ApiOperation(httpMethod = "GET", value = "根据被评价人id查询列表分页", notes = "根据被评价人id查询列表分页")
public IPage<UserEvaluationLog> listByPersonId(String pageNum, String pageSize, @PathVariable String personId) {
return iUserEvaluationLogService.listByPersonId(pageNum, pageSize, personId);
}
/**
* 根据被评价人id查询列表分页
*
* @return
*/
@RequestMapping(value = "/{taskId}/list", method = RequestMethod.GET)
@ApiOperation(httpMethod = "GET", value = "根据被任务id查询列表分页", notes = "根据被任务id查询列表分页")
public List<UserEvaluationLog> listByTaskId(@PathVariable String taskId) {
return iUserEvaluationLogService.listByTaskId(taskId);
}
/**
* 列表分页查询
*
* @return
*/
@RequestMapping(value = "/list", method = RequestMethod.GET)
@ApiOperation(httpMethod = "GET", value = "列表分页查询", notes = "列表分页查询")
public IPage<UserEvaluationLog> listPage(String pageNum, String pageSize,
UserEvaluationLog userEvaluationLog) {
Page<UserEvaluationLog> pageBean;
QueryWrapper<UserEvaluationLog> userEvaluationLogQueryWrapper = new QueryWrapper<>();
Class<? extends UserEvaluationLog> aClass = userEvaluationLog.getClass();
Arrays.stream(aClass.getDeclaredFields()).forEach(field -> {
try {
field.setAccessible(true);
Object o = field.get(userEvaluationLog);
if (o != null) {
Class<?> type = field.getType();
String name = NameUtils.camel2Underline(field.getName());
if (type.equals(Integer.class)) {
Integer fileValue = (Integer) field.get(userEvaluationLog);
userEvaluationLogQueryWrapper.eq(name, fileValue);
} else if (type.equals(Long.class)) {
Long fileValue = (Long) field.get(userEvaluationLog);
userEvaluationLogQueryWrapper.eq(name, fileValue);
} else if (type.equals(String.class)) {
String fileValue = (String) field.get(userEvaluationLog);
userEvaluationLogQueryWrapper.eq(name, fileValue);
} else {
String fileValue = (String) field.get(userEvaluationLog);
userEvaluationLogQueryWrapper.eq(name, fileValue);
}
}
} catch (Exception e) {
}
});
IPage<UserEvaluationLog> page;
if (StringUtils.isBlank(pageNum) || StringUtils.isBlank(pageSize)) {
pageBean = new Page<>(0, Long.MAX_VALUE);
} else {
pageBean = new Page<>(Integer.parseInt(pageNum), Integer.parseInt(pageSize));
}
page = iUserEvaluationLogService.page(pageBean, userEvaluationLogQueryWrapper);
return page;
}
}
\ No newline at end of file
package com.yeejoin.precontrol.controller;
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.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.yeejoin.amos.feign.privilege.model.AgencyUserModel;
import com.yeejoin.precontrol.common.dto.CommonPageableDto;
import com.yeejoin.precontrol.common.entity.Person;
import com.yeejoin.precontrol.common.service.IVideoBlockService;
import com.yeejoin.precontrol.common.vo.VideoBlockVo;
import com.yeejoin.precontrol.common.ws.WebSocketVideoBlock;
import com.yeejoin.precontrol.controller.publics.BaseController;
/**
* @Author: songLei
* @Description:
* @Date: 2021/10/15 10:08
* @Version: 1.0
*/
@RestController
@RequestMapping("/videoBlock")
public class VideoBlockController extends BaseController {
@Autowired
private IVideoBlockService videoBlockService;
/**
* @Description 记录用户浏览
* @Return Boolean
* @Date 2021/10/15 15:05
*/
@GetMapping("/browseVideo")
public Boolean browseVideo() {
AgencyUserModel model = getUserInfo();
return videoBlockService.browseVideo(model);
}
/**
* @Description 离开浏览
* @Return Boolean
* @Date 2021/10/15 15:28
*/
@GetMapping("/leaveBrowse")
public Boolean leaveBrowse() {
AgencyUserModel model = getUserInfo();
return videoBlockService.leaveBrowse(model);
}
/**
* @Description 列表
* @Return Boolean
* @Date 2021/10/15 15:28
*/
@GetMapping("/getPage")
public IPage<VideoBlockVo> getPage(CommonPageableDto pageable, VideoBlockVo vo) {
Person person =getPerson();
Page page = new Page();
if (pageable.getPageNumber() != null) {
page.setCurrent(pageable.getPageNumber());
}
if (pageable.getPageSize() != null) {
page.setSize(pageable.getPageSize());
}
vo.setOrgCode(person!=null?person.getOrgCode():null);
return videoBlockService.getPage(page, vo);
}
@PostMapping("/stop")
public boolean stop(@RequestBody VideoBlockVo vo) {
WebSocketVideoBlock.stop(vo.getPersonId());
return true;
}
}
package com.yeejoin.precontrol.controller;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.yeejoin.precontrol.common.entity.WorkTicket;
import com.yeejoin.precontrol.common.service.IWorkTicketService;
import com.yeejoin.precontrol.common.utils.RedisUtil;
import com.yeejoin.precontrol.common.vo.DistrictVo;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.MediaType;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;
import javax.servlet.http.HttpServletRequest;
import java.util.ArrayList;
import java.util.List;
/**
* 危险作业字典表
*
* @author duanwei
* @date 2020-08-26
*/
@RestController
@Api(tags = "危险作业字典表Api")
@RequestMapping(value = "/work-ticket", produces = MediaType.APPLICATION_JSON_UTF8_VALUE)
public class WorkTicketController {
/**
* 缓存服务
*/
@Autowired
RedisUtil redisUtil;
/**
* 危险作业服务
*/
@Autowired
IWorkTicketService iWorkTicketService;
/**
* 根据id查询
*
* @param id
* @return
*/
@RequestMapping(value = "/p/{id}", method = RequestMethod.GET)
@ApiOperation(httpMethod = "GET", value = "根据id查询", notes = "根据id查询")
public Object selectByParentId(HttpServletRequest request, @PathVariable Long id) {
List<WorkTicket> list = iWorkTicketService.list(new LambdaQueryWrapper<WorkTicket>().eq(WorkTicket::getPid, id));
return list;
}
/**
* 列表分页查询
*
* @return
*/
@RequestMapping(value = "/tree", method = RequestMethod.GET)
@ApiOperation(httpMethod = "GET", value = "列表tree查询", notes = "列表tree查询")
public Object tree() {
if (redisUtil.hasKey("workTicket")) {
return redisUtil.get("workTicket");
}
List<WorkTicket> list = iWorkTicketService.list();
List<DistrictVo> districtVos = new ArrayList<>();
list.forEach(d -> {
DistrictVo districtVo = new DistrictVo();
districtVo.setLabel(d.getExtName());
districtVo.setValue(String.valueOf(d.getId()));
districtVo.setId(d.getId());
districtVo.setPid(d.getPid());
districtVos.add(districtVo);
});
List<DistrictVo> menuTreeList = getMenuTreeList(0L, districtVos);
redisUtil.set("workTicket", menuTreeList, 3600);
return menuTreeList;
}
/**
* 递归循环
*
* @param pid
* @param list
* @return
*/
private List<DistrictVo> getMenuTreeList(Long pid, List<DistrictVo> list) {
List<DistrictVo> childrenList = new ArrayList<>();
for (int i = 0; i < list.size(); i++) {
DistrictVo districtVo = list.get(i);
if (districtVo.getPid().equals(pid)) {
districtVo.setChildren(getMenuTreeList(districtVo.getId(), list));
childrenList.add(districtVo);
}
}
return childrenList;
}
}
package com.yeejoin.precontrol.controller.hk;
import com.yeejoin.precontrol.common.entity.hk.model.dto.HKRequestDto;
import com.yeejoin.precontrol.common.service.hk.HkPlatFormService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
/**
* @Author: songLei
* @Description: 海康平台前端控制器
* @Date: 2021/4/29 11:40
* @Version: 1.0
*/
@RestController
@RequestMapping("/hkPlatForm")
public class HkPlatFormController {
@Autowired
private HkPlatFormService hkPlatFormService;
/**
* @Author songLei
* @Version 1.0
* @Description 根据区域编号获取下级监控点列表
* 根据指定的区域编号获取该区域下的监控点列表信息,返回结果分页展示。
* 注:返回的监控点不包括下级区域的。
* @Date 2021年4月30日10:20:11
*/
@GetMapping("/monitoringPointChildren")
public Object getMonitoringPointChildren(HKRequestDto dto){
return hkPlatFormService.getMonitoringPointChildren(dto);
}
/**
* @Author songLei
* @Version 1.0
* @Description 获取监控点预览取流URL
* @Date 2021/4/29 11:58
*/
@GetMapping("/monitoringPointPreviewURL")
public Object getMonitoringPointPreviewURL(HKRequestDto dto){
return hkPlatFormService.getMonitoringPointPreviewURL(dto);
}
/**
* @Author songLei
* @Version 1.0
* @Description 分页获取监控点资源
* 获取监控点列表接口可用来全量同步监控点信息,返回结果分页展示。
* @Date 2021年4月30日10:06:42
*/
@GetMapping("/getMonitoringPointPage")
public Object getMonitoringPointPage(HKRequestDto dto) {
return hkPlatFormService.getMonitoringPointPage(dto);
}
/**
* @Author songLei
* @Version 1.0
* @Description 获取根区域信息
* @Date 2021年9月15日17:26:13
*/
@GetMapping("/getRootZone")
public Object getRootZone() {
return hkPlatFormService.getRootZone();
}
/**
* @Author songLei
* @Version 1.0
* @Description 分页获取区域列表
* @Date 2021年9月15日17:26:13
*/
@GetMapping("/getRegions")
public Object getRegions (HKRequestDto dto){
dto.setPageNo(1);
dto.setPageSize(1000);
return hkPlatFormService.getRegions(dto);
}
}
package com.yeejoin.precontrol.controller.hk;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
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.yeejoin.precontrol.common.entity.Project;
import com.yeejoin.precontrol.common.entity.ProjectCamera;
import com.yeejoin.precontrol.common.entity.ProjectDevice;
import com.yeejoin.precontrol.common.entity.hk.model.dto.HKRequestDto;
import com.yeejoin.precontrol.common.entity.hk.model.vo.VideoTreeVo;
import com.yeejoin.precontrol.common.entity.hk.model.vo.VideoVo;
import com.yeejoin.precontrol.common.service.IProjectCameraService;
import com.yeejoin.precontrol.common.service.IProjectDeviceService;
import com.yeejoin.precontrol.common.service.IProjectService;
import com.yeejoin.precontrol.common.service.hk.HkPlatFormService;
import com.yeejoin.precontrol.common.utils.PlatformUtils;
import com.yeejoin.precontrol.common.vo.hik.HKResult;
import com.yeejoin.precontrol.common.vo.hik.Online;
import org.apache.commons.collections4.CollectionUtils;
import org.apache.commons.collections4.map.HashedMap;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
/**
* @Author: songLei
* @Description: 视频监控控制器
* @Date: 2021/5/10 9:19
* @Version: 1.0
*/
@RequestMapping("/videoSurveillance")
@RestController
public class VideoSurveillanceController {
@Autowired
private IProjectService projectService;
@Autowired
private HkPlatFormService hkPlatFormService;
@Autowired
PlatformUtils platformUtils;
@Autowired
private IProjectCameraService projectCameraService;
@GetMapping("/projectIPage")
public IPage<Project> projectIPage(Page page, String name) {
String orgCode = platformUtils.getOrgCode();
LambdaQueryWrapper<Project> wapper = new QueryWrapper<Project>().lambda().isNotNull(Project::getProjectRegion)
.like(Project::getName, name).orderByAsc(Project::getName);
if (orgCode != null) {
wapper.likeRight(Project::getOrgCode, orgCode);
}
return projectService.page(page, wapper);
}
@GetMapping("/getTree")
public Object getTree(Boolean isOnLine, Long projectId) {
String orgCode = platformUtils.getOrgCode();
LambdaQueryWrapper<Project> warpper;
if (StringUtils.isBlank(orgCode)) {
warpper = new QueryWrapper<Project>().lambda().isNotNull(Project::getProjectRegion)
.orderByAsc(Project::getName);
} else {
warpper = new QueryWrapper<Project>().lambda().likeRight(Project::getOrgCode, orgCode)
.isNotNull(Project::getProjectRegion).orderByAsc(Project::getName);
}
if (!StringUtils.isEmpty(orgCode)) {
warpper.like(Project::getOrgCode, orgCode);
}
if (projectId != null) {
warpper.like(Project::getId, projectId);
}
List<Project> projects = projectService.list(warpper);
List<VideoTreeVo> treeVoList = new ArrayList<>();
VideoTreeVo vo = new VideoTreeVo();
vo.setType("-1");
vo.setCode("0");
vo.setId(0l);
vo.setName("项目列表");
List<VideoTreeVo> treeVos = new ArrayList<>();
if (CollectionUtils.isNotEmpty(projects)) {
projects.stream().forEach(item -> {
VideoTreeVo treeVo = new VideoTreeVo();
treeVo.setName(item.getName());
treeVo.setCode(item.getProjectNum());
treeVo.setId(item.getId());
treeVo.setParentId("-1");
treeVo.setType("1");
List<ProjectCamera> projectDevices = projectCameraService.list(new QueryWrapper<ProjectCamera>()
.lambda().eq(ProjectCamera::getRegionIndexCode, item.getProjectRegion())
.orderByAsc(ProjectCamera::getChannelNo));
HKRequestDto dtoV = new HKRequestDto();
dtoV.setPageNo(1);
dtoV.setPageSize(1000);
dtoV.setRegionIndexCode(item.getProjectRegion());
List<HKResult> hkResults = (List<HKResult>) hkPlatFormService.getMonitoringPointChildren(dtoV);
List<String> indexCodes = new ArrayList<>();
projectDevices.stream().forEach(pc -> {
pc.setCameraName(
hkResults.stream().filter(y -> y.getCameraIndexCode().equals(pc.getCameraIndexCode()))
.findFirst().get().getCameraName());
indexCodes.add(pc.getCameraIndexCode());
});
HKRequestDto dto = new HKRequestDto();
dto.setPageNo(1);
dto.setPageSize(1000);
dto.setIndexCodes(indexCodes);
List<Online> onlines = hkPlatFormService.getIsOnline(dto);
List<VideoTreeVo> treeVosChildren = new ArrayList<>();
if (CollectionUtils.isNotEmpty(projectDevices)) {
projectDevices.stream().forEach(O -> {
VideoTreeVo tree = new VideoTreeVo();
tree.setName(O.getCameraName());
tree.setCode(O.getCameraIndexCode());
tree.setId(O.getId());
tree.setParentId(item.getId().toString());
tree.setType("2");
Integer on = onlines.stream().filter(x -> x.getIndexCode().equals(O.getCameraIndexCode()))
.findFirst().get().getOnline();
tree.setOnline(on);
if (isOnLine && 1 != tree.getOnline()) {
} else {
treeVosChildren.add(tree);
}
});
}
treeVo.setChildren(treeVosChildren);
treeVos.add(treeVo);
});
vo.setChildren(treeVos);
treeVoList.add(vo);
}
return treeVoList;
}
@GetMapping("/videoPage")
public IPage<VideoVo> videoPage(Page page, VideoTreeVo vo) {
String orgCode = platformUtils.getOrgCode();
List<Project> projects = projectService.list(
new QueryWrapper<Project>().lambda().eq(StringUtils.isNotBlank(orgCode), Project::getOrgCode, orgCode)
.isNotNull(Project::getProjectRegion));
String projectRegion = projects.stream().filter(a -> StringUtils.isNotBlank(a.getProjectRegion())).findFirst()
.get().getProjectRegion();
IPage<VideoVo> videoVoIPage = new Page<>();
IPage<ProjectCamera> cameraIPage;
if (StringUtils.isNotBlank(vo.getType())) {
if (vo.getType().equals("-1")) {
cameraIPage = projectCameraService.page(page, new QueryWrapper<ProjectCamera>().lambda()
.eq(ProjectCamera::getRegionIndexCode, projectRegion));
} else if (vo.getType().equals("1")) {
Project project = projectService.getById(vo.getId());
cameraIPage = projectCameraService.page(page, new QueryWrapper<ProjectCamera>().lambda()
.eq(ProjectCamera::getRegionIndexCode, project.getProjectRegion()));
} else {
cameraIPage = projectCameraService.page(page,
new QueryWrapper<ProjectCamera>().lambda().eq(ProjectCamera::getId, vo.getId()));
}
} else {
cameraIPage = projectCameraService.page(page,
new QueryWrapper<ProjectCamera>().lambda().eq(ProjectCamera::getRegionIndexCode, projectRegion));
}
if (CollectionUtils.isNotEmpty(cameraIPage.getRecords())) {
List<VideoVo> videoVos = new ArrayList<>();
Map<String, List<HKResult>> hkMap = new HashMap<>();
cameraIPage.getRecords().stream().forEach(item -> {
HKRequestDto dtoV = new HKRequestDto();
dtoV.setPageNo(1);
dtoV.setPageSize(1000);
dtoV.setRegionIndexCode(item.getRegionIndexCode());
List<HKResult> hkResults = hkMap.get(item.getRegionIndexCode());
if (hkResults == null) {
hkResults = (List<HKResult>) hkPlatFormService.getMonitoringPointChildren(dtoV);
hkMap.put(item.getRegionIndexCode(), hkResults);
}
HKRequestDto dto = new HKRequestDto();
dto.setCameraIndexCode(item.getCameraIndexCode());
Map<String, String> path = (Map<String, String>) hkPlatFormService.getMonitoringPointPreviewURL(dto);
String url = path.get("url");
VideoVo videoVo = new VideoVo();
videoVo.setCode(item.getCameraIndexCode());
videoVo.setId(item.getId());
videoVo.setName(hkResults.stream().filter(y -> y.getCameraIndexCode().equals(item.getCameraIndexCode()))
.findFirst().get().getCameraName());
// https://img.jinsom.cn/user_files/14871/publish/video/14794405_1619619953.mp4
videoVo.setUrl(url);
videoVo.setToken("true");
Integer on = hkResults.stream().filter(x -> x.getCameraIndexCode().equals(videoVo.getCode()))
.findFirst().get().getOnline();
if (vo.getOnline() == 1 && on != 1) {
} else {
videoVos.add(videoVo);
}
});
BeanUtils.copyProperties(cameraIPage, videoVoIPage);
videoVoIPage.setRecords(videoVos);
}
return videoVoIPage;
}
}
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