Commit ba4387c6 authored by suhuiguang's avatar suhuiguang

Merge branch 'developer' of http://172.16.10.76/moa/amos-boot-biz into developer

parents 50f7384e dce5787f
......@@ -11,21 +11,21 @@
<attribute name="maven.pomderived" value="true"/>
</attributes>
</classpathentry>
<classpathentry kind="src" output="target/test-classes" path="src/test/java">
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.8">
<attributes>
<attribute name="test" value="true"/>
<attribute name="optional" value="true"/>
<attribute name="maven.pomderived" value="true"/>
</attributes>
</classpathentry>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.8">
<classpathentry kind="con" path="org.eclipse.m2e.MAVEN2_CLASSPATH_CONTAINER">
<attributes>
<attribute name="maven.pomderived" value="true"/>
</attributes>
</classpathentry>
<classpathentry kind="con" path="org.eclipse.m2e.MAVEN2_CLASSPATH_CONTAINER">
<classpathentry kind="src" output="target/test-classes" path="src/test/java">
<attributes>
<attribute name="optional" value="true"/>
<attribute name="maven.pomderived" value="true"/>
<attribute name="test" value="true"/>
</attributes>
</classpathentry>
<classpathentry kind="output" path="target/classes"/>
......
......@@ -3,11 +3,7 @@
<modelVersion>4.0.0</modelVersion>
<artifactId>amos-boot-biz-common</artifactId>
<packaging>jar</packaging>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>
<parent>
<artifactId>amos-biz-boot</artifactId>
<groupId>com.amosframework.boot</groupId>
......@@ -15,6 +11,73 @@
</parent>
<dependencies>
<dependency>
<groupId>com.yeejoin</groupId>
<artifactId>amos-feign-systemctl</artifactId>
<version>${amos.version}</version>
</dependency>
<dependency>
<groupId>org.typroject</groupId>
<artifactId>tyboot-core-rdbms</artifactId>
<version>${tyboot-version}</version>
<exclusions>
<exclusion>
<groupId>org.typroject</groupId>
<artifactId>*</artifactId>
</exclusion>
<exclusion>
<groupId>com.baomidou</groupId>
<artifactId>mybatis-plus-boot-starter</artifactId>
</exclusion>
<exclusion>
<artifactId>mysql-connector-java</artifactId>
<groupId>mysql</groupId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<artifactId>mysql-connector-java</artifactId>
<groupId>mysql</groupId>
</dependency>
<dependency>
<groupId>org.typroject</groupId>
<artifactId>tyboot-core-restful</artifactId>
<version>${tyboot-version}</version>
<exclusions>
<exclusion>
<groupId>org.typroject</groupId>
<artifactId>*</artifactId>
</exclusion>
<exclusion>
<groupId>io.springfox</groupId>
<artifactId>springfox-swagger-ui</artifactId>
</exclusion>
<exclusion>
<groupId>io.springfox</groupId>
<artifactId>springfox-swagger2</artifactId>
</exclusion>
<exclusion>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-undertow</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>org.typroject</groupId>
<artifactId>tyboot-core-auth</artifactId>
<version>${tyboot-version}</version>
<exclusions>
<exclusion>
<groupId>org.typroject</groupId>
<artifactId>*</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>com.amosframework.boot</groupId>
<artifactId>amos-boot-core</artifactId>
<version>1.0.0</version>
</dependency>
<dependency>
<groupId>com.baomidou</groupId>
<artifactId>mybatis-plus-generator</artifactId>
......@@ -27,18 +90,7 @@
<groupId>org.mybatis.spring.boot</groupId>
<artifactId>mybatis-spring-boot-starter</artifactId>
</dependency>
<!-- knife4j -->
<dependency>
<groupId>com.github.xiaoymin</groupId>
<artifactId>knife4j-spring-boot-starter</artifactId>
<version>${knife4j-spring-boot-starter.version}</version>
<exclusions>
<exclusion>
<groupId>org.javassist</groupId>
<artifactId>javassist</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>org.javassist</groupId>
<artifactId>javassist</artifactId>
......
package com.yeejoin.amos.boot.biz.common.controller;
import java.util.*;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collection;
import java.util.HashMap;
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.beans.factory.annotation.Value;
......@@ -15,11 +21,12 @@ import org.typroject.tyboot.core.foundation.enumeration.UserType;
import org.typroject.tyboot.core.restful.doc.TycloudOperation;
import org.typroject.tyboot.core.restful.utils.ResponseHelper;
import org.typroject.tyboot.core.restful.utils.ResponseModel;
import com.alibaba.fastjson.JSON;
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.amos.boot.biz.common.controller.BaseController;
import com.yeejoin.amos.boot.biz.common.dao.mapper.DataDictionaryMapper;
import com.yeejoin.amos.boot.biz.common.entity.DataDictionary;
import com.yeejoin.amos.boot.biz.common.service.impl.DataDictionaryServiceImpl;
import com.yeejoin.amos.boot.biz.common.utils.Menu;
......@@ -28,10 +35,10 @@ import com.yeejoin.amos.boot.biz.common.utils.NameUtils;
import com.yeejoin.amos.boot.biz.common.utils.RedisKey;
import com.yeejoin.amos.boot.biz.common.utils.RedisUtils;
import com.yeejoin.amos.boot.biz.common.utils.TreeParser;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
/**
* 数据字典
*
......@@ -43,232 +50,235 @@ import io.swagger.annotations.ApiOperation;
@RequestMapping(value = "/data-dictionary")
public class DataDictionaryController extends BaseController {
@Autowired
DataDictionaryServiceImpl iDataDictionaryService;
@Autowired
RedisUtils redisUtils;
@Value("${redis.cache.failure.time}")
private long time;
@Autowired
DataDictionaryServiceImpl iDataDictionaryService;
@Autowired
RedisUtils redisUtils;
/**
* 新增数据字典
*
* @return
*/
@TycloudOperation(needAuth = true, ApiLevel = UserType.AGENCY)
@RequestMapping(value = "/save", method = RequestMethod.POST)
@ApiOperation(httpMethod = "POST", value = "新增数据字典", notes = "新增数据字典")
public boolean saveDataDictionary(HttpServletRequest request, @RequestBody DataDictionary dataDictionary) {
return iDataDictionaryService.save(dataDictionary);
}
@Value("${redis.cache.failure.time}")
private long time;
@Autowired
DataDictionaryMapper dataDictionaryMapper;
/**
* 根据id删除
*
* @param id
* @return
*/
@TycloudOperation(needAuth = true, ApiLevel = UserType.AGENCY)
@RequestMapping(value = "/{id}", method = RequestMethod.DELETE)
@ApiOperation(httpMethod = "DELETE", value = "根据id删除", notes = "根据id删除")
public boolean deleteById(HttpServletRequest request, @PathVariable Long id) {
return iDataDictionaryService.removeById(id);
}
/**
* 新增数据字典
*
* @return
*/
@TycloudOperation(needAuth = true, ApiLevel = UserType.AGENCY)
@RequestMapping(value = "/save", method = RequestMethod.POST)
@ApiOperation(httpMethod = "POST", value = "新增数据字典", notes = "新增数据字典")
public boolean saveDataDictionary(HttpServletRequest request, @RequestBody DataDictionary dataDictionary) {
return iDataDictionaryService.save(dataDictionary);
}
/**
* 根据id删除
*
* @param id
* @return
*/
@TycloudOperation(needAuth = true, ApiLevel = UserType.AGENCY)
@RequestMapping(value = "/{id}", method = RequestMethod.DELETE)
@ApiOperation(httpMethod = "DELETE", value = "根据id删除", notes = "根据id删除")
public boolean deleteById(HttpServletRequest request, @PathVariable Long id) {
return iDataDictionaryService.removeById(id);
}
/**
* 修改数据字典
*
* @return
*/
@TycloudOperation(needAuth = true, ApiLevel = UserType.AGENCY)
@RequestMapping(value = "/updateById", method = RequestMethod.PUT)
@ApiOperation(httpMethod = "PUT", value = "修改数据字典", notes = "修改数据字典")
public boolean updateByIdDataDictionary(HttpServletRequest request, @RequestBody DataDictionary dataDictionary) {
return iDataDictionaryService.updateById(dataDictionary);
}
/**
* 修改数据字典
*
* @return
*/
@TycloudOperation(needAuth = true, ApiLevel = UserType.AGENCY)
@RequestMapping(value = "/updateById", method = RequestMethod.PUT)
@ApiOperation(httpMethod = "PUT", value = "修改数据字典", notes = "修改数据字典")
public boolean updateByIdDataDictionary(HttpServletRequest request, @RequestBody DataDictionary dataDictionary) {
return iDataDictionaryService.updateById(dataDictionary);
}
/**
* 根据id查询
*
* @param id
* @return
*/
@TycloudOperation(needAuth = true, ApiLevel = UserType.AGENCY)
@RequestMapping(value = "/{id}", method = RequestMethod.GET)
@ApiOperation(httpMethod = "GET", value = "根据id查询", notes = "根据id查询")
public DataDictionary selectById(HttpServletRequest request, @PathVariable Long id) {
return iDataDictionaryService.getById(id);
}
/**
* 根据id查询
*
* @param id
* @return
*/
@TycloudOperation(needAuth = true, ApiLevel = UserType.AGENCY)
@RequestMapping(value = "/{id}", method = RequestMethod.GET)
@ApiOperation(httpMethod = "GET", value = "根据id查询", notes = "根据id查询")
public DataDictionary selectById(HttpServletRequest request, @PathVariable Long id) {
return iDataDictionaryService.getById(id);
}
/**
* 列表分页查询
*
* @return
*/
@TycloudOperation(needAuth = true, ApiLevel = UserType.AGENCY)
@RequestMapping(value = "/list", method = RequestMethod.GET)
@ApiOperation(httpMethod = "GET", value = "列表分页查询", notes = "列表分页查询")
public IPage<DataDictionary> listPage(String pageNum, String pageSize, DataDictionary dataDictionary) {
Page<DataDictionary> pageBean;
QueryWrapper<DataDictionary> dataDictionaryQueryWrapper = new QueryWrapper<>();
Class<? extends DataDictionary> aClass = dataDictionary.getClass();
Arrays.stream(aClass.getDeclaredFields()).forEach(field -> {
try {
field.setAccessible(true);
Object o = field.get(dataDictionary);
if (o != null) {
Class<?> type = field.getType();
String name = NameUtils.camel2Underline(field.getName());
if (type.equals(Integer.class)) {
Integer fileValue = (Integer) field.get(dataDictionary);
dataDictionaryQueryWrapper.eq(name, fileValue);
} else if (type.equals(Long.class)) {
Long fileValue = (Long) field.get(dataDictionary);
dataDictionaryQueryWrapper.eq(name, fileValue);
} else if (type.equals(String.class)) {
String fileValue = (String) field.get(dataDictionary);
dataDictionaryQueryWrapper.eq(name, fileValue);
} else {
String fileValue = (String) field.get(dataDictionary);
dataDictionaryQueryWrapper.eq(name, fileValue);
}
}
} catch (Exception e) {
throw new RuntimeException("系统异常");
}
});
IPage<DataDictionary> 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 = iDataDictionaryService.page(pageBean, dataDictionaryQueryWrapper);
return page;
}
/**
* 列表分页查询
*
* @return
*/
@TycloudOperation(needAuth = true, ApiLevel = UserType.AGENCY)
@RequestMapping(value = "/list", method = RequestMethod.GET)
@ApiOperation(httpMethod = "GET", value = "列表分页查询", notes = "列表分页查询")
public IPage<DataDictionary> listPage(String pageNum, String pageSize, DataDictionary dataDictionary) {
@TycloudOperation(needAuth = true, ApiLevel = UserType.AGENCY)
@RequestMapping(value = "/gwmcDataDictionary/{type}", method = RequestMethod.GET)
@ApiOperation(httpMethod = "GET", value = "根据字典类型查询字典", notes = "根据字典类型查询字典")
public ResponseModel<Object> gwmcDataDictionary(@PathVariable String type) throws Exception {
Page<DataDictionary> pageBean;
QueryWrapper<DataDictionary> dataDictionaryQueryWrapper = new QueryWrapper<>();
Class<? extends DataDictionary> aClass = dataDictionary.getClass();
Arrays.stream(aClass.getDeclaredFields()).forEach(field -> {
try {
field.setAccessible(true);
Object o = field.get(dataDictionary);
if (o != null) {
Class<?> type = field.getType();
String name = NameUtils.camel2Underline(field.getName());
if (type.equals(Integer.class)) {
Integer fileValue = (Integer) field.get(dataDictionary);
dataDictionaryQueryWrapper.eq(name, fileValue);
} else if (type.equals(Long.class)) {
Long fileValue = (Long) field.get(dataDictionary);
dataDictionaryQueryWrapper.eq(name, fileValue);
} else if (type.equals(String.class)) {
String fileValue = (String) field.get(dataDictionary);
dataDictionaryQueryWrapper.eq(name, fileValue);
} else {
String fileValue = (String) field.get(dataDictionary);
dataDictionaryQueryWrapper.eq(name, fileValue);
}
}
} catch (Exception e) {
throw new RuntimeException("系统异常");
}
});
IPage<DataDictionary> 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 = iDataDictionaryService.page(pageBean, dataDictionaryQueryWrapper);
return page;
}
QueryWrapper<DataDictionary> queryWrapper = new QueryWrapper<>();
queryWrapper.eq("type", type);
queryWrapper.orderByAsc("sort_num");
@TycloudOperation(needAuth = true, ApiLevel = UserType.AGENCY)
@RequestMapping(value = "/gwmcDataDictionary/{type}", method = RequestMethod.GET)
@ApiOperation(httpMethod = "GET", value = "根据字典类型查询字典", notes = "根据字典类型查询字典")
public ResponseModel<Object> gwmcDataDictionary(@PathVariable String type) throws Exception {
if (redisUtils.hasKey(RedisKey.DATA_DICTIONARY_CODE + type)) {
Object obj = redisUtils.get(RedisKey.DATA_DICTIONARY_CODE + type);
return ResponseHelper.buildResponse(obj);
} else {
Collection<DataDictionary> list = iDataDictionaryService.list(queryWrapper);
List<Menu> menus = TreeParser.getTree(null, list, DataDictionary.class.getName(), "getCode", 0, "getName",
"getParent", null);
redisUtils.set(RedisKey.DATA_DICTIONARY_CODE + type, JSON.toJSON(menus), time);
return ResponseHelper.buildResponse(menus);
}
}
QueryWrapper<DataDictionary> queryWrapper = new QueryWrapper<>();
queryWrapper.eq("type", type);
queryWrapper.orderByAsc("sort_num");
@TycloudOperation(needAuth = true, ApiLevel = UserType.AGENCY)
@RequestMapping(value = "/dataDictionary", method = RequestMethod.GET)
@ApiOperation(httpMethod = "GET", value = "根据字典类型查询字典2", notes = "根据字典类型查询字典2")
public ResponseModel<Object> getDictionary(@RequestParam String type) throws Exception {
if (redisUtils.hasKey(RedisKey.DATA_DICTIONARY_CODE + type)) {
Object obj = redisUtils.get(RedisKey.DATA_DICTIONARY_CODE + type);
return ResponseHelper.buildResponse(obj);
} else {
Collection<DataDictionary> list = iDataDictionaryService.list(queryWrapper);
List<Menu> menus = TreeParser.getTree(null, list, DataDictionary.class.getName(), "getCode", 0, "getName"
, "getParent", null);
redisUtils.set(RedisKey.DATA_DICTIONARY_CODE + type, JSON.toJSON(menus), time);
return ResponseHelper.buildResponse(menus);
}
}
QueryWrapper<DataDictionary> queryWrapper = new QueryWrapper<>();
queryWrapper.eq("type", type);
queryWrapper.orderByAsc("sort_num");
@TycloudOperation(needAuth = true, ApiLevel = UserType.AGENCY)
@RequestMapping(value = "/dataDictionary", method = RequestMethod.GET)
@ApiOperation(httpMethod = "GET", value = "根据字典类型查询字典2", notes = "根据字典类型查询字典2")
public ResponseModel<Object> getDictionary(@RequestParam String type) throws Exception {
if (redisUtils.hasKey(RedisKey.DATA_DICTIONARY_CODE + type)) {
Object obj = redisUtils.get(RedisKey.DATA_DICTIONARY_CODE + type);
return ResponseHelper.buildResponse(obj);
} else {
Collection<DataDictionary> list = iDataDictionaryService.list(queryWrapper);
List<Menu> menus = TreeParser.getTree(null, list, DataDictionary.class.getName(), "getCode", 0, "getName",
"getParent", null);
redisUtils.set(RedisKey.DATA_DICTIONARY_CODE + type, JSON.toJSON(menus), time);
return ResponseHelper.buildResponse(menus);
}
}
QueryWrapper<DataDictionary> queryWrapper = new QueryWrapper<>();
queryWrapper.eq("type", type);
queryWrapper.orderByAsc("sort_num");
@TycloudOperation(needAuth = true, ApiLevel = UserType.AGENCY)
@RequestMapping(value = "/gwmcDataDictionary/FireChemical/{type}", method = RequestMethod.GET)
@ApiOperation(httpMethod = "GET", value = "根据字典类型查询危险品字典", notes = "根据字典类型查询危险品字典")
public ResponseModel<Object> gwmcDataDictionaryFireChemical(@PathVariable String type) throws Exception {
if (redisUtils.hasKey(RedisKey.DATA_DICTIONARY_CODE + type)) {
Object obj = redisUtils.get(RedisKey.DATA_DICTIONARY_CODE + type);
return ResponseHelper.buildResponse(obj);
} else {
Collection<DataDictionary> list = iDataDictionaryService.list(queryWrapper);
List<Menu> menus = TreeParser.getTree(null, list, DataDictionary.class.getName(), "getCode", 0, "getName"
, "getParent", null);
redisUtils.set(RedisKey.DATA_DICTIONARY_CODE + type, JSON.toJSON(menus), time);
return ResponseHelper.buildResponse(menus);
}
}
QueryWrapper<DataDictionary> queryWrapper = new QueryWrapper<>();
queryWrapper.eq("type", type);
queryWrapper.orderByAsc("sort_num");
@TycloudOperation(needAuth = true, ApiLevel = UserType.AGENCY)
@RequestMapping(value = "/gwmcDataDictionary/FireChemical/{type}", method = RequestMethod.GET)
@ApiOperation(httpMethod = "GET", value = "根据字典类型查询危险品字典", notes = "根据字典类型查询危险品字典")
public ResponseModel<Object> gwmcDataDictionaryFireChemical(@PathVariable String type) throws Exception {
if (redisUtils.hasKey(RedisKey.DATA_DICTIONARY_CODE + type)) {
Object obj = redisUtils.get(RedisKey.DATA_DICTIONARY_CODE + type);
return ResponseHelper.buildResponse(obj);
} else {
Collection<DataDictionary> list = iDataDictionaryService.list(queryWrapper);
List<MenuFrom> menus = TreeParser.getTreexin(null, list, DataDictionary.class.getName(), "getCode", 0,
"getName", "getParent", null);
MenuFrom Me = new MenuFrom("-1", "-1", "-1", "危化品库", "危化品库", "危化品库", "-1", null);
Me.setIsLeaf(false);
Me.setChildren(menus);
redisUtils.set(RedisKey.DATA_DICTIONARY_CODE + type, JSON.toJSON(Me), time);
return ResponseHelper.buildResponse(Me);
}
}
QueryWrapper<DataDictionary> queryWrapper = new QueryWrapper<>();
queryWrapper.eq("type", type);
queryWrapper.orderByAsc("sort_num");
@TycloudOperation(needAuth = true, ApiLevel = UserType.AGENCY)
@RequestMapping(value = "/form/list", method = RequestMethod.GET)
@ApiOperation(httpMethod = "GET", value = "根据表态类型多个code查询表单数据项", notes = "根据表态类型多个code查询表单数据项")
public ResponseModel<Object> selectFormdListItem(HttpServletRequest request, String types) {
HashMap<Object, Object> objectObjectHashMap = new HashMap<>();
try {
String[] typest = types.split(",");
for (String type : typest) {
QueryWrapper<DataDictionary> queryWrapper = new QueryWrapper<>();
queryWrapper.eq("type", type);
queryWrapper.orderByAsc("sort_num");
if (redisUtils.hasKey(RedisKey.DATA_DICTIONARY_CODE_XIN + type)) {
Object obj = redisUtils.get(RedisKey.DATA_DICTIONARY_CODE_XIN + type);
objectObjectHashMap.put(type, obj);
} else {
Collection<DataDictionary> list = iDataDictionaryService.list(queryWrapper);
List<MenuFrom> menus = null;
menus = TreeParser.getTreexin(null, list, DataDictionary.class.getName(), "getCode", 0, "getName",
"getParent", null);
redisUtils.set(RedisKey.DATA_DICTIONARY_CODE_XIN + type, JSON.toJSON(menus), time);
objectObjectHashMap.put(type, menus);
}
}
} catch (Exception e) {
e.printStackTrace();
throw new RuntimeException("系统异常!");
}
return ResponseHelper.buildResponse(objectObjectHashMap);
}
if (redisUtils.hasKey(RedisKey.DATA_DICTIONARY_CODE + type)) {
Object obj = redisUtils.get(RedisKey.DATA_DICTIONARY_CODE + type);
return ResponseHelper.buildResponse(obj);
} else {
Collection<DataDictionary> list = iDataDictionaryService.list(queryWrapper);
List<MenuFrom> menus = TreeParser.getTreexin(null, list, DataDictionary.class.getName(), "getCode", 0,
"getName", "getParent", null);
MenuFrom Me = new MenuFrom("-1", "-1", "-1", "危化品库", "危化品库", "危化品库", "-1", null);
Me.setIsLeaf(false);
Me.setChildren(menus);
redisUtils.set(RedisKey.DATA_DICTIONARY_CODE + type, JSON.toJSON(Me), time);
return ResponseHelper.buildResponse(Me);
}
}
@TycloudOperation(needAuth = true, ApiLevel = UserType.AGENCY)
@RequestMapping(value = "/form/list", method = RequestMethod.GET)
@ApiOperation(httpMethod = "GET", value = "根据表态类型多个code查询表单数据项", notes = "根据表态类型多个code查询表单数据项")
public ResponseModel<Object> selectFormdListItem(HttpServletRequest request, String types) {
HashMap<Object, Object> objectObjectHashMap = new HashMap<>();
try {
String[] typest = types.split(",");
for (String type : typest) {
QueryWrapper<DataDictionary> queryWrapper = new QueryWrapper<>();
queryWrapper.eq("type", type);
queryWrapper.orderByAsc("sort_num");
if (redisUtils.hasKey(RedisKey.DATA_DICTIONARY_CODE_XIN + type)) {
Object obj = redisUtils.get(RedisKey.DATA_DICTIONARY_CODE_XIN + type);
objectObjectHashMap.put(type, obj);
} else {
Collection<DataDictionary> list = iDataDictionaryService.list(queryWrapper);
List<MenuFrom> menus = null;
menus = TreeParser.getTreexin(null, list, DataDictionary.class.getName(), "getCode", 0, "getName",
"getParent", null);
redisUtils.set(RedisKey.DATA_DICTIONARY_CODE_XIN + type, JSON.toJSON(menus), time);
objectObjectHashMap.put(type, menus);
}
}
} catch (Exception e) {
e.printStackTrace();
throw new RuntimeException("系统异常!");
}
return ResponseHelper.buildResponse(objectObjectHashMap);
}
@TycloudOperation(needAuth = true, ApiLevel = UserType.AGENCY)
@RequestMapping(value = "/dataDictionaryTree", method = RequestMethod.GET)
@ApiOperation(httpMethod = "GET", value = "根据字典类型查询字典树", notes = "根据字典类型查询字典树")
public ResponseModel<Object> getDictionaryTree(@RequestParam String type, @RequestParam String rootName) throws Exception {
QueryWrapper<DataDictionary> queryWrapper = new QueryWrapper<>();
queryWrapper.eq("type", type);
queryWrapper.orderByAsc("sort_num");
Collection<DataDictionary> list = iDataDictionaryService.list(queryWrapper);
List<Menu> menus = TreeParser.getTree(null, list, DataDictionary.class.getName(), "getCode", 0, "getName"
, "getParent", null);
// 创建根节点
Menu menu = new Menu(-1L, rootName, -1L, menus, 0);
List<Menu> menuList = new ArrayList<>();
// 挂在主节点
menuList.add(menu);
return ResponseHelper.buildResponse(menuList);
}
@TycloudOperation(needAuth = true, ApiLevel = UserType.AGENCY)
@RequestMapping(value = "/dataDictionaryTree", method = RequestMethod.GET)
@ApiOperation(httpMethod = "GET", value = "根据字典类型查询字典树", notes = "根据字典类型查询字典树")
public ResponseModel<Object> getDictionaryTree(@RequestParam String type, @RequestParam String rootName)
throws Exception {
QueryWrapper<DataDictionary> queryWrapper = new QueryWrapper<>();
queryWrapper.eq("type", type);
queryWrapper.orderByAsc("sort_num");
Collection<DataDictionary> list = null;
if ("YJLDDW".equals(type)) {
list = dataDictionaryMapper.getNoInLinkUnit();
} else {
list = iDataDictionaryService.list(queryWrapper);
}
List<Menu> menus = TreeParser.getTree(null, list, DataDictionary.class.getName(), "getCode", 0, "getName", "getParent",
null);
// 创建根节点
Menu menu = new Menu(-1L, rootName, -1L, menus, 0);
List<Menu> menuList = new ArrayList<>();
// 挂在主节点
menuList.add(menu);
return ResponseHelper.buildResponse(menuList);
}
}
......@@ -17,4 +17,9 @@ public interface DataDictionaryMapper extends BaseMapper<DataDictionary> {
* @return
*/
public List<DataDictionary> getDataDictionaryListAndCount();
/**
* 获取包含联动单位的联动单位树信息
* @return
*/
public List<DataDictionary> getNoInLinkUnit();
}
......@@ -23,4 +23,26 @@ GROUP BY
</select>
<select id ="getNoInLinkUnit" resultType="com.yeejoin.amos.boot.biz.common.entity.DataDictionary">
SELECT
cbb.*
FROM
cb_data_dictionary cbb
LEFT JOIN (
SELECT
emergency_linkage_unit_code,
COUNT(1) count
FROM
cb_linkage_unit
GROUP BY
emergency_linkage_unit_code
) elink ON elink.emergency_linkage_unit_code = cbb.`code`
WHERE
cbb.type = 'YJLDDW'
AND elink.count IS NOT NULL
</select>
</mapper>
......@@ -3,33 +3,18 @@
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>
<artifactId>amos-boot-core</artifactId>
<packaging>jar</packaging>
<parent>
<artifactId>amos-biz-boot</artifactId>
<groupId>com.amosframework.boot</groupId>
<version>1.0.0</version>
</parent>
<artifactId>amos-boot-system-jpush</artifactId>
<version>8.0.0</version>
<dependencies>
<dependency>
<groupId>com.amosframework.boot</groupId>
<artifactId>amos-boot-module-jpush-biz</artifactId>
<version>${amos-biz-boot.version}</version>
<exclusions>
<exclusion>
<groupId>com.baomidou</groupId>
<artifactId>mybatis-plus-generator</artifactId>
</exclusion>
</exclusions>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
</plugin>
</plugins>
</build>
</project>
package com.yeejoin.amos.boot.biz.config;
package com.yeejoin.amos.boot.core.config;
import java.util.ArrayList;
import java.util.List;
......@@ -7,8 +7,6 @@ import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.bind.annotation.RestController;
import com.yeejoin.amos.boot.biz.common.constants.CommonConstant;
import io.swagger.annotations.ApiOperation;
import springfox.documentation.builders.ApiInfoBuilder;
import springfox.documentation.builders.ParameterBuilder;
......@@ -23,10 +21,6 @@ import springfox.documentation.swagger2.annotations.EnableSwagger2WebMvc;
/**
* @Author lichenglong
*/
//@Configuration
//@EnableSwagger2
//@EnableKnife4j
//@Import(BeanValidatorPluginsConfiguration.class)
@Configuration
@EnableSwagger2WebMvc
public class Swagger2Config {
......@@ -67,16 +61,6 @@ public class Swagger2Config {
.globalOperationParameters(setHeaderToken());
}
/***
* oauth2配置
* 需要增加swagger授权回调地址
* http://localhost:8888/webjars/springfox-swagger-ui/o2c.html
* @return
*/
// @Bean
// SecurityScheme securityScheme() {
// return new ApiKey(CommonConstant.X_ACCESS_TOKEN, CommonConstant.X_ACCESS_TOKEN, "header");
// }
/**
* JWT token
* @return
......@@ -116,25 +100,5 @@ public class Swagger2Config {
.build();
}
/**
* 新增 securityContexts 保持登录状态
*/
// private List<SecurityContext> securityContexts() {
// return new ArrayList(
// Collections.singleton(SecurityContext.builder()
// .securityReferences(defaultAuth())
// .forPaths(PathSelectors.regex("^(?!auth).*$"))
// .build())
// );
// }
//
// private List<SecurityReference> defaultAuth() {
// AuthorizationScope authorizationScope = new AuthorizationScope("global", "accessEverything");
// AuthorizationScope[] authorizationScopes = new AuthorizationScope[1];
// authorizationScopes[0] = authorizationScope;
// return new ArrayList(
// Collections.singleton(new SecurityReference(CommonConstant.X_ACCESS_TOKEN, authorizationScopes)));
// }
}
package org.typroject.tyboot.core.restful.doc;
/**
* 此类是为了覆盖原有类,为空,不用写具体实现
* @author lichenglong
*
*/
public class Swagger2 {
}
......@@ -38,4 +38,7 @@ public class CompanyDto {
@ApiModelProperty(value = "单位名称")
private String name;
@ApiModelProperty(value = "重点部位数量")
private int keySiteNum;
}
......@@ -220,8 +220,12 @@
a.companyMaleEmployees,
a.companyFemaleEmployees,
a.managementType,
Round(st_distance(point(a.longitude,a.latitude),point(#{par.longitude},#{par.latitude}))*111195,1) AS distance
FROM important_companys a
Round(st_distance(point(a.longitude,a.latitude),point(#{par.longitude},#{par.latitude}))*111195,1) AS distance,
case when cks_d.count is null then 0 else cks_d.count end as keySiteNum
FROM important_companys a left join (
SELECT cks.belong_id ,count(cks.belong_id) count from cb_key_site cks GROUP BY cks.belong_id
)cks_d
on a.id=cks_d.belong_id
where a.longitude is not null and a.latitude is not null
<if test='par.distance!=null'>
and Round(st_distance(point(a.longitude,a.latitude),point(#{par.longitude},#{par.latitude}))*111195,1) &lt;=
......
......@@ -105,7 +105,7 @@
select distinct (case
when ISNULL(belong_fighting_system_id) = 0 and LENGTH(trim(belong_fighting_system_id)) > 0
then belong_fighting_system_id
else 0 end) belong_fighting_system_id,
else -2 end) belong_fighting_system_id,
(case
when ISNULL(belong_fighting_system) = 0 and LENGTH(trim(belong_fighting_system)) > 0
then belong_fighting_system
......@@ -125,7 +125,7 @@
<if test="belongFightingSystemId > -1">
and belong_fighting_system_id = #{belongFightingSystemId}
</if>
<if test="belongFightingSystemId == -1">
<if test="belongFightingSystemId == -2">
and belong_fighting_system_id is null
</if>
</if>
......
......@@ -43,6 +43,11 @@
<artifactId>jsoup</artifactId>
<version>1.11.2</version>
</dependency>
<dependency>
<groupId>cn.jpush.api</groupId>
<artifactId>jpush-client</artifactId>
<version>3.3.10</version>
</dependency>
</dependencies>
</project>
<?xml version="1.0" encoding="UTF-8"?>
<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>
<artifactId>amos-boot-module-api</artifactId>
<groupId>com.amosframework.boot</groupId>
<version>1.0.0</version>
</parent>
<artifactId>amos-boot-module-jpush-api</artifactId>
<dependencies>
<dependency>
<groupId>com.amosframework.boot</groupId>
<artifactId>amos-boot-biz-common</artifactId>
<version>${amos-biz-boot.version}</version>
<exclusions>
<exclusion>
<groupId>com.baomidou</groupId>
<artifactId>mybatis-plus-generator</artifactId>
</exclusion>
<exclusion>
<groupId>com.baomidou</groupId>
<artifactId>mybatis-plus-boot-starter</artifactId>
</exclusion>
<exclusion>
<groupId>org.mybatis.spring.boot</groupId>
<artifactId>mybatis-spring-boot-starter</artifactId>
</exclusion>
</exclusions>
</dependency>
</dependencies>
</project>
......@@ -26,7 +26,6 @@ public class Check extends BasicEntity {
private static final long serialVersionUID = 1L;
/**
* 参考地址
......@@ -175,6 +174,18 @@ public class Check extends BasicEntity {
*/
@Column(name="dep_name")
private String depName;
/**
* 责任单位id
*/
@Column(name="company_id")
private String companyId;
/**
* 责任单位名称
*/
@Column(name="company_name")
private String companyName;
@Column(name="error_classify")
private String errorClassify;
......@@ -412,4 +423,19 @@ public class Check extends BasicEntity {
this.routeName = routeName;
}
public String getCompanyId() {
return companyId;
}
public void setCompanyId(String companyId) {
this.companyId = companyId;
}
public String getCompanyName() {
return companyName;
}
public void setCompanyName(String companyName) {
this.companyName = companyName;
}
}
\ No newline at end of file
package com.yeejoin.amos.supervision.dao.entity;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.NamedQuery;
import javax.persistence.Table;
import javax.persistence.*;
import java.util.List;
/**
......@@ -89,6 +85,53 @@ public class CheckInput extends BasicEntity {
*/
private String remark;
/**
* 执行人ids
*/
@Column(name="user_id")
private String userId;
/**
* 执行人名称
*/
@Column(name="user_name")
private String userName;
/**
* 执行部门ids
*/
@Column(name="dep_id")
private String depId;
/**
* 执行部门名称
*/
@Column(name="dep_name")
private String depName;
/**
* 安全隐患个数
*/
@Column(name="safety_danger_num")
private int safetyDangerNum;
/**
* 重大隐患个数
*/
@Column(name="major_danger_num")
private int majorDangerNum;
@Transient
public List<CheckShot> getCheckShotList() {
return checkShotList;
}
public void setCheckShotList(List<CheckShot> checkShotList) {
this.checkShotList = checkShotList;
}
private List<CheckShot> checkShotList;
public String getRemark() {
return remark;
}
......@@ -201,4 +244,51 @@ public class CheckInput extends BasicEntity {
this.pointClassifyName = pointClassifyName;
}
public String getUserId() {
return userId;
}
public void setUserId(String userId) {
this.userId = userId;
}
public String getUserName() {
return userName;
}
public void setUserName(String userName) {
this.userName = userName;
}
public String getDepId() {
return depId;
}
public void setDepId(String depId) {
this.depId = depId;
}
public String getDepName() {
return depName;
}
public void setDepName(String depName) {
this.depName = depName;
}
public int getMajorDangerNum() {
return majorDangerNum;
}
public void setMajorDangerNum(int majorDangerNum) {
this.majorDangerNum = majorDangerNum;
}
public int getSafetyDangerNum() {
return safetyDangerNum;
}
public void setSafetyDangerNum(int safetyDangerNum) {
this.safetyDangerNum = safetyDangerNum;
}
}
\ No newline at end of file
......@@ -55,6 +55,30 @@ public class PlanTaskDetail extends BasicEntity {
@Column(name="status")
private String status="0";
/**
* 检查项个数
*/
@Column(name="item_num")
private int itemNum;
/**
* 已执行个数
*/
@Column(name="executed_num")
private int executedNum;
/**
* 已执行个数
*/
@Column(name="safety_danger_num")
private int safetyDangerNum;
/**
* 已执行个数
*/
@Column(name="major_danger_num")
private int majorDangerNum;
public PlanTaskDetail() {
}
......@@ -112,6 +136,45 @@ public class PlanTaskDetail extends BasicEntity {
public void setExecutorId(String executorId) {
this.executorId = executorId;
}
public int getItemNum() {
return itemNum;
}
public void setItemNum(int itemNum) {
this.itemNum = itemNum;
}
public int getExecutedNum() {
return executedNum;
}
public void setExecutedNum(int executedNum) {
this.executedNum = executedNum;
}
public Date getExecutorDate() {
return executorDate;
}
public void setExecutorDate(Date executorDate) {
this.executorDate = executorDate;
}
public int getSafetyDangerNum() {
return safetyDangerNum;
}
public void setSafetyDangerNum(int safetyDangerNum) {
this.safetyDangerNum = safetyDangerNum;
}
public int getMajorDangerNum() {
return majorDangerNum;
}
public void setMajorDangerNum(int majorDangerNum) {
this.majorDangerNum = majorDangerNum;
}
}
\ No newline at end of file
......@@ -23,7 +23,6 @@
<module>amos-boot-module-fas-api</module>
<module>amos-boot-module-maintenance-api</module>
<module>amos-boot-module-supervision-api</module>
<module>amos-boot-module-jpush-api</module>
<module>amos-boot-module-knowledgebase-api</module>
</modules>
</project>
\ No newline at end of file
......@@ -359,6 +359,12 @@ public class MaintenanceCompanyServiceImpl
filedParamsMap.put("status", paramsMap.get("status").toString());
}
mainTableList = this.checkMaintenanceCompanyList(wrapper, paramsMap);
/*BUG 2503 人员头像存在附件中,获取附件信息返回前端 start*/
for (MaintenanceCompany m:mainTableList
) {
m.setAttachments(sourceFileService.getAttachments(m.getSequenceNbr()));
}
/* *BUG 2503 end*/
List<Long> instanceIds = Lists.transform(mainTableList, MaintenanceCompany::getInstanceId);
filedParamsMap.put("instanceIds", Joiner.on(",").join(instanceIds));
break;
......@@ -388,6 +394,7 @@ public class MaintenanceCompanyServiceImpl
if (!ObjectUtils.isEmpty(detail)) {
r.putAll(Bean.BeantoMap(detail));
}
});
return page;
}
......
......@@ -24,11 +24,22 @@
<exclusions>
<exclusion>
<groupId>org.typroject</groupId>
<artifactId>tyboot-core-auth</artifactId>
<artifactId>*</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>org.typroject</groupId>
<artifactId>tyboot-component-emq</artifactId>
<version>${tyboot-version}</version>
</dependency>
<dependency>
<groupId>javax.servlet</groupId>
<artifactId>javax.servlet-api</artifactId>
<version>4.0.1</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.apache.poi</groupId>
<artifactId>poi-scratchpad</artifactId>
<version>3.15</version>
......
......@@ -95,7 +95,10 @@
<dependency>
<groupId>org.liquibase</groupId>
<artifactId>liquibase-core</artifactId>
<version>3.8.9</version>
</dependency>
<dependency>
<groupId>cn.jpush.api</groupId>
<artifactId>jpush-client</artifactId>
</dependency>
</dependencies>
......
......@@ -95,6 +95,10 @@
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-mail</artifactId>
</dependency>
<dependency>
<groupId>cn.jpush.api</groupId>
<artifactId>jpush-client</artifactId>
</dependency>
</dependencies>
</project>
<?xml version="1.0" encoding="UTF-8"?>
<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>
<artifactId>amos-boot-module-biz</artifactId>
<groupId>com.amosframework.boot</groupId>
<version>1.0.0</version>
</parent>
<artifactId>amos-boot-module-supervision-biz</artifactId>
<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>
<artifactId>amos-boot-module-biz</artifactId>
<groupId>com.amosframework.boot</groupId>
<version>1.0.0</version>
</parent>
<artifactId>amos-boot-module-supervision-biz</artifactId>
<dependencies>
<dependency>
<dependencies>
<dependency>
<groupId>com.amosframework.boot</groupId>
<artifactId>amos-boot-module-supervision-api</artifactId>
<version>${amos-biz-boot.version}</version>
......@@ -92,6 +94,10 @@
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-mail</artifactId>
</dependency>
</dependencies>
<dependency>
<groupId>cn.jpush.api</groupId>
<artifactId>jpush-client</artifactId>
</dependency>
</dependencies>
</project>
......@@ -249,77 +249,6 @@ public class CheckController extends AbstractBaseController {
FileHelper.exportZip(list, fileName, response);
}
@TycloudOperation(ApiLevel = UserType.AGENCY)
@ApiOperation(value = "保存巡检记录<font color='blue'>手机app</font>", notes = "保存巡检记录<font color='blue'>手机app</font>")
@RequestMapping(value = "/saveRecord", produces = "application/json;charset=UTF-8", method = RequestMethod.POST)
public CommonResponse saveCheckRecord(
@ApiParam(value = "检查信息", required = false) @RequestBody(required = true) CheckRecordParam requestParam) {
Toke token = new Toke();
token.setProduct(request.getHeader("product"));
token.setToke(request.getHeader("X-Access-Token"));
token.setAppKey(request.getHeader("appKey"));
int statu = -1;
PlanTask planTask = null;
if (requestParam.getPlanTaskId() != null && requestParam.getPlanTaskId() != 0) {
planTask = planTaskService.selectPlanTaskStatus(requestParam.getPlanTaskId());
}
AgencyUserModel user = getUserInfo();
String userId = user.getUserId();
String realName = user.getRealName();
requestParam.setIsOffline(requestParam.getIsOffline() == null ? false : requestParam.getIsOffline());
try {
if (planTask != null) {
if (!ToolUtils.transBeanList(planTask.getUserId()).contains(userId.toString())) {
return CommonResponseUtil.failure("无权执行该任务");
}
statu = planTask.getFinishStatus();
if (!requestParam.getIsOffline() && statu == PlanTaskFinishStatusEnum.OVERTIME.getValue()) {
return CommonResponseUtil.failure("任务已超时,上传失败!");
} else if (statu == PlanTaskFinishStatusEnum.FINISHED.getValue()) {
return CommonResponseUtil.failure("任务已完成!");
}
Date checkTime = requestParam.getIsOffline() ? DateUtil.getLongDate(requestParam.getCheckTime()) : new Date();
Date beginTime = DateUtil.getLongDate(planTask.getBeginTime());
Date endTime = DateUtil.getLongDate(planTask.getEndTime());
int beginCompareTo = checkTime.compareTo(beginTime);
int endCompareTo = checkTime.compareTo(endTime);
if (beginCompareTo == -1 || endCompareTo == 1) {
return CommonResponseUtil.failure("请在计划时间内完成任务!");
}
}
int count = checkService.checkHasRecord(requestParam);
if (count < 1 || requestParam.getPlanTaskId() < 1) {
ReginParams reginParams = getSelectedOrgInfo();
String orgCode = getOrgCode(reginParams);
String departmentId = getDepartmentId(reginParams);
requestParam.setOrgCode(orgCode);
requestParam.setUserId(getUserId());
requestParam.setCheckDepartmentId(departmentId);
CheckDto checkDto = checkService.saveCheckRecord(requestParam, getUserInfo(), reginParams.getDepartment(), token);
if (StringUtil.isNotEmpty(checkDto)) {
asyncTaskf(checkDto.getCheckId());
}
is.pointCheckInfoPushToB(checkDto.getCheckId());
//数字换流站页面刷新
try {
webMqttComponent.publish(patrolTopic, "");
} catch (Exception e) {
log.error("数字换流站页面推送失败-----------" + e.getMessage());
}
return CommonResponseUtil.success(checkDto);
} else {
return CommonResponseUtil.success("无需重新巡检");
}
} catch (Exception e) {
e.printStackTrace();
// TODO Auto-generated catch block
log.error(e.getMessage());
return CommonResponseUtil.failure("数据提交失败");
}
}
@Async
public void asyncTaskf(Long id) {
......@@ -645,4 +574,20 @@ public class CheckController extends AbstractBaseController {
return ResponseHelper.buildResponse(checkService.getPlanExecuteTeams());
}
@TycloudOperation(ApiLevel = UserType.AGENCY)
@ApiOperation(value = "保存检查记录", notes = "保存检查记录")
@RequestMapping(value = "/saveRecord", produces = "application/json;charset=UTF-8", method = RequestMethod.POST)
public ResponseModel saveSupervisionCheckRecord( @ApiParam(value = "检查信息", required = false) @RequestBody(required = true) CheckRecordParam requestParam) {
try {
ReginParams reginParams = getSelectedOrgInfo();
String orgCode = getOrgCode(reginParams);
requestParam.setOrgCode(orgCode);
CheckDto checkDto = checkService.saveCheckRecord(requestParam, reginParams);
return ResponseHelper.buildResponse(checkDto);
} catch (Exception e) {
log.error(e.getMessage(), e);
return ResponseHelper.buildResponse(e.getMessage());
}
}
}
......@@ -283,4 +283,6 @@ public interface CheckMapper extends BaseMapper {
List<Map<String, Object>> getPlanExecuteTeams();
int checkHasRecord(@Param(value = "planTaskId") Long planTaskId, @Param(value = "pointId") Long pointId);
}
......@@ -6,7 +6,9 @@ import org.apache.ibatis.annotations.Param;
public interface PlanTaskDetailMapper extends BaseMapper {
void finishTaskDetail(@Param(value="planTaskDetailId") long planTaskDetailId, @Param(value="pointId") long pointId, @Param(value="planTaskId") long planTaskId
, @Param(value="executorId") String executorId);
, @Param(value="executorId") String executorId , @Param(value="executorName") String executorName);
Map findPlanTaskByTaskIdAndPointId(@Param(value="planTaskId") long planTaskId,@Param(value="pointId") long pointId);
int findPlanTaskDetailByTaskId( @Param(value="planTaskId") long planTaskId);
}
package com.yeejoin.amos.supervision.business.param;
import com.yeejoin.amos.supervision.dao.entity.CheckShot;
import lombok.Data;
import java.util.ArrayList;
import java.util.List;
@Data
public class CheckInputParam {
private long inputItemId;
private String inputValue;
private String selectName;
private boolean isCheck;
private String remark;
private Long classifyIds;
private Long routePointItemId;
private List<String> checkInputImg;
public List<String> getCheckInputImg() {
return checkInputImg;
}
public void setCheckInputImg(List<String> checkInputImg) {
this.checkInputImg = checkInputImg;
}
public String getRemark() {
return remark;
}
public void setRemark(String remark) {
this.remark = remark;
}
public long getInputItemId() {
return inputItemId;
}
public void setInputItemId(long inputItemId) {
this.inputItemId = inputItemId;
}
public String getInputValue() {
return inputValue;
}
public void setInputValue(String inputValue) {
this.inputValue = inputValue;
}
public String getSelectName() {
return selectName;
}
public void setSelectName(String selectName) {
this.selectName = selectName;
}
public boolean getIsCheck() {
return isCheck;
}
public void setIsCheck(boolean isCheck) {
this.isCheck = isCheck;
}
public Long getClassifyIds() {
return classifyIds;
}
public void setClassifyIds(Long classifyIds) {
this.classifyIds = classifyIds;
}
public Long getRoutePointItemId() {
return routePointItemId;
}
public void setRoutePointItemId(Long routePointItemId) {
this.routePointItemId = routePointItemId;
}
private String userId;
private String userName;
private String depId;
private String depName;
private List<CheckShot> checkInputShot = new ArrayList<>();
}
package com.yeejoin.amos.supervision.business.param;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import java.util.ArrayList;
import java.util.List;
@Data
public class CheckRecordParam {
@ApiModelProperty(value = "任务id",required = true)
private Long planTaskId;
private Long pointId;
private String pointName;
private Long checkId;
private String remark;
private String userId;
private String orgCode;
private String checkDepartmentId;
private List<String> checkRecordImg;
/**
* 检查项分类
*/
private Long classId;
/**
* 路线id
*/
private Long routeId;
/**
* 检查时间
*/
private String checkTime;
private String checkMode;
/**
* 是否离线提交
*/
private Boolean isOffline = false;
private List<CheckInputParam> checkItems;
public Long getPointId() {
return pointId;
}
public void setPointId(Long pointId) {
this.pointId = pointId;
}
public Long getCheckId() {
return checkId;
}
public void setCheckId(Long checkId) {
this.checkId = checkId;
}
public String getRemark() {
return remark;
}
public void setRemark(String remark) {
this.remark = remark;
}
public List<CheckInputParam> getCheckItems() {
return checkItems;
}
public void setCheckItems(List<CheckInputParam> checkItems) {
this.checkItems = checkItems;
}
public Long getPlanTaskId() {
return planTaskId;
}
public void setPlanTaskId(Long planTaskId) {
this.planTaskId = planTaskId;
}
public String getUserId() {
return userId;
}
public void setUserId(String userId) {
this.userId = userId;
}
public String getOrgCode() {
return orgCode;
}
public void setOrgCode(String orgCode) {
this.orgCode = orgCode;
}
public String getCheckTime() {
return checkTime;
}
public String getCheckMode() {
return checkMode;
}
public void setCheckTime(String checkTime) {
this.checkTime = checkTime;
}
public Long getRouteId() {
return routeId;
}
public void setRouteId(Long routeId) {
this.routeId = routeId;
}
public String getPointName() {
return pointName;
}
public void setPointName(String pointName) {
this.pointName = pointName;
}
public void setCheckMode(String checkMode) {
this.checkMode = checkMode;
}
public Long getClassId() {
return classId;
}
public void setClassId(Long classId) {
this.classId = classId;
}
public Boolean getIsOffline() {
return isOffline;
}
@ApiModelProperty(value = "点id",required = true)
private Long pointId;
public void setIsOffline(Boolean isOffline) {
this.isOffline = isOffline;
}
@ApiModelProperty(value = "组织机构")
private String orgCode;
public String getCheckDepartmentId() {
return checkDepartmentId;
}
@ApiModelProperty(value = "备注")
private String remark;
public void setCheckDepartmentId(String checkDepartmentId) {
this.checkDepartmentId = checkDepartmentId;
}
@ApiModelProperty(value = "路线id")
private Long routeId;
public List<String> getCheckRecordImg() {
return checkRecordImg;
}
@ApiModelProperty(value = "检查时间")
private String checkTime;
public void setCheckRecordImg(List<String> checkRecordImg) {
this.checkRecordImg = checkRecordImg;
}
/**
* 检查项
*/
@ApiModelProperty(value = "检查项",required = true)
private List<CheckInputParam> checkItems = new ArrayList<>();
}
......@@ -62,6 +62,12 @@ public class PlanInfoPageParam extends CommonPageable {
*/
private String leadPerson;
/**
* 计划执行状态
* @return
*/
private int finishStatus;
public String getOwnerId() {
return ownerId;
}
......@@ -141,4 +147,12 @@ public class PlanInfoPageParam extends CommonPageable {
public void setLeadPerson(String leadPerson) {
this.leadPerson = leadPerson;
}
public int getFinishStatus() {
return finishStatus;
}
public void setFinishStatus(int finishStatus) {
this.finishStatus = finishStatus;
}
}
......@@ -16,11 +16,14 @@ import java.util.stream.Collectors;
import javax.annotation.Resource;
import javax.transaction.Transactional;
import com.yeejoin.amos.boot.biz.common.bo.ReginParams;
import com.yeejoin.amos.supervision.business.constants.XJConstant;
import com.yeejoin.amos.supervision.business.dao.mapper.CheckMapper;
import com.yeejoin.amos.supervision.business.service.intfc.ICheckService;
import com.yeejoin.amos.supervision.business.service.intfc.IEquipmentHandlerService;
import com.yeejoin.amos.supervision.business.service.intfc.IPlanTaskService;
import com.yeejoin.amos.supervision.business.service.intfc.IPointService;
import com.yeejoin.amos.supervision.business.util.ToolUtils;
import com.yeejoin.amos.supervision.business.vo.CheckAnalysisVo;
import com.yeejoin.amos.supervision.business.vo.CheckInfoVo;
import com.yeejoin.amos.supervision.common.enums.*;
......@@ -144,6 +147,9 @@ public class CheckServiceImpl implements ICheckService {
@Autowired
IPointDao iPointDao;
@Autowired
IPlanTaskService planTaskService;
// @Value("${file.ip}")
// private String fileIp;
//
......@@ -173,224 +179,6 @@ public class CheckServiceImpl implements ICheckService {
}
@Override
@Transactional
public CheckDto saveCheckRecord(CheckRecordParam requestParam, AgencyUserModel user, DepartmentBo departmentModel, Toke token) {
PlanTaskDetail taskDetail = null;
PlanTask planTask = null;
Check check = new Check();
HashMap<String, Object> routeParam = new HashMap<String, Object>();
Map detail = null;
Boolean isOffline = requestParam.getIsOffline();
Point point = iPointService.queryPointById(requestParam.getPointId());
try {
if (!ObjectUtils.isEmpty(requestParam) && !ObjectUtils.isEmpty(requestParam.getPlanTaskId()) && requestParam.getPlanTaskId() > 0) {
detail = planTaskDetailMapper.findPlanTaskByTaskIdAndPointId(requestParam.getPlanTaskId(), requestParam.getPointId());
if (!ObjectUtils.isEmpty(detail)) {
check = checkDao.findByPlanTaskIdAndPointId(requestParam.getPlanTaskId(), requestParam.getPointId());
planTask = planTaskDao.findById(requestParam.getPlanTaskId()).get();
routeParam.put("routeId", planTask.getRouteId());
routeParam.put("pointId", requestParam.getPointId());
if (ObjectUtils.isEmpty(check)) {
check = new Check();
}
check.setPlanTaskDetailId(Long.parseLong(detail.get("planTaskDetailId").toString()));
check.setRouteId(Long.parseLong(detail.get("routeId").toString()));
check.setRouteName(detail.get("routeName").toString());
check.setPlanTaskId(requestParam.getPlanTaskId());
check.setPlanId(planTask.getPlanId());
check.setPlanName(detail.get("planName").toString());
check.setPointName(detail.get("pointName").toString());
requestParam.setPointName(detail.get("pointName").toString());
}
} else {
taskDetail = new PlanTaskDetail();
planTask = new PlanTask();
check.setPlanTaskDetailId(0);
check.setRouteId(0);
check.setPlanTaskId(0);
check.setPlanId(0);
}
check.setPointId(requestParam.getPointId());
if (ObjectUtils.isEmpty(requestParam.getPointName())) {
check.setPointName(point == null ? "" : point.getName());
}
check.setRemark(requestParam.getRemark());
check.setCheckTime(DateUtil.getLongDate(requestParam.getCheckTime()));
check.setUploadTime(new Date());
check.setOrgCode(requestParam.getOrgCode());
check.setUserId(user.getUserId().toString());
check.setUserName(user.getRealName());
// Department dep = user.getDepartment();
if (departmentModel != null) {
check.setDepId(departmentModel.getSequenceNbr().toString());
check.setDepName(departmentModel.getDepartmentName());
}
check.setCheckMode(requestParam.getCheckMode());
List<CheckInputParam> list = requestParam.getCheckItems();
List<CheckInput> checkItemList = new ArrayList<>();
List<Map<String, Object>> unqualifiedcheckItemList = Lists.newArrayList();
String error = "";
HashMap<String, String> errorClassifyNames = new HashMap<>();
List<EquipmentInputItemRo> equipmentInputItemRoList = new ArrayList<>();
int score = 0;
for (CheckInputParam item : list) {
String pointClassifyName = null;
PointClassify pointClassify = null;
if (StringUtil.isNotEmpty(item.getClassifyIds()) && iPointClassifyDao.existsById(item.getClassifyIds())) {
pointClassify = iPointClassifyDao.findById(item.getClassifyIds()).get();
pointClassifyName = pointClassify.getName();
}
InputItem inputItem = inputItemDao.findById(item.getInputItemId()).get();
CheckInput checkInput = new CheckInput();
if (isOffline && check.getId() != 0) {
checkInput = checkInputDao.findByCheckIdAndInputIdAndPointClassifyId(check.getId(), inputItem.getId(), item.getClassifyIds());
}
checkInput.setCreateDate(new Date());
checkInput.setOrgCode(requestParam.getOrgCode());
checkInput.setInputId(Long.valueOf(item.getInputItemId() + ""));
checkInput.setInputName(inputItem.getName());
checkInput.setOrderNo(inputItem.getOrderNo());
checkInput.setRemark(item.getRemark());
//1.校验结果
if (XJConstant.INPUT_ITEM_SELECT.equals(inputItem.getItemType())) {
checkInput = paraseSelect(checkInput, inputItem.getDataJson(), item, inputItem.getIsScore());
} else if (XJConstant.INPUT_ITEM_NUMBER.equals(inputItem.getItemType())) {
checkInput = paraseNumber(checkInput, inputItem.getDataJson(), item, inputItem.getIsScore());
} else if (XJConstant.INPUT_ITEM_TEXT.equals(inputItem.getItemType())) {
checkInput = paraseText(checkInput, inputItem.getDataJson(), item, inputItem.getIsScore());
}
if (XJConstant.NO.equals(checkInput.getIsOk())) {
String classifyName = pointClassifyName != null ? pointClassifyName + "-" : "";
error += (classifyName + inputItem.getName() + "=" + (ObjectUtils.isEmpty(item.getInputValue()) ? "" : item.getInputValue()) + ";");
errorClassifyNames.put(pointClassifyName != null ? pointClassifyName : "", "");
checkInput.setIsOk(CheckStatusEnum.UNQUALIFIED.getCode());
Map<String, Object> unCheckMap = Maps.newHashMap();
unCheckMap.put("itemId", item.getInputItemId());
unCheckMap.put("routeId", check.getRouteId());
unCheckMap.put("pointId", requestParam.getPointId());
unCheckMap.put("name", inputItem.getName());
unCheckMap.put("inputValue", item.getInputValue());
unqualifiedcheckItemList.add(unCheckMap);
} else {
checkInput.setIsOk(CheckStatusEnum.QUALIFIED.getCode());
}
checkInput.setRoutePointItemId(item.getRoutePointItemId());
checkInput.setInputValue(item.getInputValue());
checkInput.setPointClassifyId(item.getClassifyIds());
checkInput.setPointClassifyName(pointClassifyName);
score += checkInput.getScore();
checkItemList.add(checkInput);
EquipmentInputItemRo equipmentInputItemRo = new EquipmentInputItemRo();
if (!StringUtils.isBlank(pointClassify.getName())) {
equipmentInputItemRo.setEquipmentName(pointClassify.getName());
}
equipmentInputItemRo.setCheckResult(item.getInputValue());
equipmentInputItemRo.setRuleType(RuleTypeEnum.CHECKRESULT.getCode());
equipmentInputItemRo.setCheckContent(inputItem.getItemNo());
if (!StringUtils.isBlank(pointClassify.getEquipmentId())) {
equipmentInputItemRoList.add(equipmentInputItemRo);
}
}
if (!ObjectUtils.isEmpty(error) && error.endsWith(";")) {
error.substring(0, error.length() - 1);
check.setIsOk(CheckStatusEnum.UNQUALIFIED.getCode());
} else {
check.setIsOk(CheckStatusEnum.QUALIFIED.getCode());
}
check.setError(error);
check.setErrorClassify(StringUtils.join(errorClassifyNames.keySet(), ","));
//计划外巡检是否计分 ,计划内默认都是计分
if (XJConstant.POINT_OK_SCORE.equals(point.getIsScore()) || requestParam.getPlanTaskId() != null) {
check.setScore(score);
} else {
check.setScore(Integer.parseInt(XJConstant.POINT_NOT_SCORE));
}
check = checkDao.save(check);
if (point != null) {
//冗余记录最新一次检查记录,方便其他业务查询
point.setLastCheckId(String.valueOf(check.getId()));
iPointDao.save(point);
}
List<CheckShot> imgList = new ArrayList<>();
for (CheckInput item : checkItemList) {
item.setCheckId(check.getId());
//检查点图片保存 checkInputId
Check finalCheck = check;
list.forEach(x -> {
if (x.getInputItemId() == item.getInputId() && (x.getClassifyIds() == item.getPointClassifyId() || x.getClassifyIds() == null)) {
if (x.getCheckInputImg() != null && x.getCheckInputImg().size() > 0) {
for (int i = 0; i < x.getCheckInputImg().size(); i++) {
CheckShot img = new CheckShot();
img.setCheckId(finalCheck.getId());
img.setOrgCode(finalCheck.getOrgCode());
img.setCreateDate(new Date());
img.setPointName(finalCheck.getPointName());
img.setShotType("1".equals(point.getIsFixed()) ? "定点" : "普通");
img.setPhotoData(x.getCheckInputImg().get(i));
img.setCheckInputId(x.getInputItemId());
if (item.getPointClassifyId() == null) {
img.setClassifyId(0);
} else {
img.setClassifyId(item.getPointClassifyId());
}
imgList.add(img);
}
}
}
});
}
//现场图片保存
if (requestParam.getCheckRecordImg() != null && requestParam.getCheckRecordImg().size() > 0) {
for (int i = 0; i < requestParam.getCheckRecordImg().size(); i++) {
CheckShot img = new CheckShot();
img.setCheckId(check.getId());
img.setOrgCode(check.getOrgCode());
img.setCreateDate(new Date());
img.setPointName(check.getPointName());
img.setCheckInputId(0);
img.setShotType("1".equals(point.getIsFixed()) ? "定点" : "普通");
img.setPhotoData(requestParam.getCheckRecordImg().get(i));
img.setClassifyId(0);
imgList.add(img);
}
}
List<CheckInput> checkInputList = checkInputDao.saveAll(checkItemList);
//规则请求结果
checkInputList.forEach(checkInput -> {
InputItem inputItem = inputItemDao.findById(checkInput.getInputId()).get();
for (int i = 0; i < equipmentInputItemRoList.size(); i++) {
if (inputItem.getItemNo().equals(equipmentInputItemRoList.get(i).getCheckContent())) {
equipmentInputItemRoList.get(i).setCheckInputId(Long.valueOf(checkInput.getId()).toString());
}
}
});
equipmentHandlerService.getRulesCheckResult(equipmentInputItemRoList, token);
if (imgList.size() > 0) {
checkService.saveCheckImg(imgList);
}
if (check.getPlanTaskId() > 0) {
planTaskDetailMapper.finishTaskDetail(Long.parseLong(detail.get("planTaskDetailId").toString()), requestParam.getPointId(), requestParam.getPlanTaskId(), user.getUserId());
} else {
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
planTaskMapper.reformStatistics(user.getUserId(), sdf.format(new Date()), requestParam.getOrgCode());
}
return new CheckDto(check.getId(), unqualifiedcheckItemList);
} catch (Exception e) {
e.printStackTrace();
return null;
}
}
@Override
public void delCheckById(List<Long> list) {
// List<Long> pointIdList = checkDao.getPointIdList(list);
checkDao.deleteBatch(list);
......@@ -505,11 +293,6 @@ public class CheckServiceImpl implements ICheckService {
}
@Override
public int checkHasRecord(CheckRecordParam requestParam) {
return checkMapper.checkHasRecord(requestParam);
}
@Override
public AppPointCheckRespone queryCheckPointDetail(String toke, String product, String appKey, long checkId) {
// List list = checkMapper.queryCheckPointInputItem(planTaskId, pointId);
List<PointCheckDetailBo> list = checkMapper.findCheckPointInputItem(checkId);
......@@ -1597,4 +1380,216 @@ public class CheckServiceImpl implements ICheckService {
public List<Long> getPlanCheckDataCount(HashMap<String, Object> param) {
return checkMapper.getPlanCheckDataCount(param);
}
@Override
@Transactional
public CheckDto saveCheckRecord(CheckRecordParam recordParam, ReginParams reginParams) throws Exception {
ReginParams.PersonIdentity personIdentity = reginParams.getPersonIdentity();
//执行人-维保人员,非amos 账号
if (ObjectUtils.isEmpty(reginParams.getUserModel()) && ObjectUtils.isEmpty(reginParams.getCompany()) && ObjectUtils.isEmpty(reginParams.getDepartment()) ) {
throw new RuntimeException("获取用户信息失败");
}
String mtUserSeq = reginParams.getUserModel().getUserId();
String userName = reginParams.getUserModel().getUserName();
// String mtUserSeq = personIdentity.getPersonSeq();
PlanTask planTask = planTaskService.selectPlanTaskStatus(recordParam.getPlanTaskId());
Map detail = planTaskDetailMapper.findPlanTaskByTaskIdAndPointId(recordParam.getPlanTaskId(), recordParam.getPointId());
//1.前置校验
this.checkCanFinishTask(mtUserSeq, planTask, recordParam.getPointId());
Point point = iPointService.queryPointById(recordParam.getPointId());
Check check = new Check();
if (ObjectUtils.isEmpty(point) || ObjectUtils.isEmpty(detail)) {
throw new Exception("前置校验不通过");
}
//2.加工准备的数据
try {
// 检查记录表中是否有该点记录
Check checkByPointId = checkDao.findByPlanTaskIdAndPointId(recordParam.getPlanTaskId(), recordParam.getPointId());
if (ObjectUtils.isEmpty(checkByPointId)) {
// 新增
check.setPlanTaskDetailId(Long.parseLong(detail.get("planTaskDetailId").toString()));
check.setRouteId(Long.parseLong(detail.get("routeId").toString()));
check.setRouteName(detail.get("routeName").toString());
check.setPlanTaskId(recordParam.getPlanTaskId());
check.setPlanId(planTask.getPlanId());
check.setPlanName(detail.get("planName").toString());
check.setPointName(point.getName());
check.setPointId(point.getId());
check.setRemark(recordParam.getRemark());
check.setOrgCode(recordParam.getOrgCode());
check.setUserId(mtUserSeq);
check.setCheckTime(new Date());
check.setUploadTime(new Date());
check.setUserName(reginParams.getUserModel().getUserName());
check.setCompanyId(reginParams.getCompany().getSequenceNbr().toString());
check.setCompanyName(reginParams.getCompany().getCompanyName());
check.setDepId(reginParams.getDepartment().getSequenceNbr().toString());
check.setDepName(reginParams.getDepartment().getDepartmentName());
} else {
// 更新
check = checkByPointId;
check.setCheckTime(new Date());
check.setUploadTime(new Date());
String userId = check.getUserId();
String userName1 = check.getUserName();
String companyId = check.getCompanyId();
String companyName = check.getCompanyName();
String depId = check.getDepId();
String depName = check.getDepName();
if (!userId.contains(mtUserSeq)) {
check.setUserId(userId+","+mtUserSeq);
check.setUserName(userName1+","+userName);
}
if (!companyId.contains(reginParams.getCompany().getSequenceNbr().toString())) {
check.setCompanyId(companyId+","+reginParams.getCompany().getSequenceNbr().toString());
}
if (!companyName.contains(reginParams.getCompany().getCompanyName())) {
check.setCompanyName(companyName+","+reginParams.getCompany().getCompanyName());
}
if (!depId.contains(reginParams.getDepartment().getSequenceNbr().toString())) {
check.setDepId(depId+","+reginParams.getDepartment().getSequenceNbr().toString());
}
if (!depName.contains(reginParams.getDepartment().getDepartmentName())) {
check.setDepName(depName+","+reginParams.getDepartment().getDepartmentName());
}
}
List<CheckInputParam> list = recordParam.getCheckItems();
List<CheckInput> checkItemList = new ArrayList<>();
List<Map<String, Object>> unqualifiedCheckItemList = Lists.newArrayList();
StringBuilder error = new StringBuilder();
int score = 0;
for (CheckInputParam item : list) {
List<CheckShot> checkShots = new ArrayList<>();
InputItem inputItem = inputItemDao.findById(item.getInputItemId()).get();
CheckInput checkInput = new CheckInput();
checkInput.setCreateDate(new Date());
checkInput.setOrgCode(recordParam.getOrgCode());
checkInput.setInputId(inputItem.getId());
checkInput.setInputName(inputItem.getName());
checkInput.setOrderNo(inputItem.getOrderNo());
checkInput.setRemark(item.getRemark());
checkInput.setUserId(item.getUserId());
checkInput.setUserName(item.getUserName());
checkInput.setDepId(item.getDepId());
checkInput.setDepName(item.getDepName());
checkInput.setSafetyDangerNum(0);
checkInput.setMajorDangerNum(0);
//1.校验结果
if (XJConstant.INPUT_ITEM_SELECT.equals(inputItem.getItemType())) {
paraseSelect(checkInput, inputItem.getDataJson(), item, inputItem.getIsScore());
} else if (XJConstant.INPUT_ITEM_NUMBER.equals(inputItem.getItemType())) {
paraseNumber(checkInput, inputItem.getDataJson(), item, inputItem.getIsScore());
} else if (XJConstant.INPUT_ITEM_TEXT.equals(inputItem.getItemType())) {
paraseText(checkInput, inputItem.getDataJson(), item, inputItem.getIsScore());
}
if (XJConstant.NO.equals(checkInput.getIsOk())) {
error.append(inputItem.getName()).append("=").append(ObjectUtils.isEmpty(item.getInputValue()) ? "" : item.getInputValue()).append(";");
checkInput.setIsOk(CheckStatusEnum.UNQUALIFIED.getCode());
Map<String, Object> unCheckMap = Maps.newHashMap();
unCheckMap.put("itemId", item.getInputItemId());
unCheckMap.put("routeId", check.getRouteId());
unCheckMap.put("pointId", point.getId());
unCheckMap.put("name", inputItem.getName());
unCheckMap.put("inputValue", item.getInputValue());
unqualifiedCheckItemList.add(unCheckMap);
} else {
checkInput.setIsOk(CheckStatusEnum.QUALIFIED.getCode());
}
checkInput.setRoutePointItemId(item.getRoutePointItemId());
checkInput.setInputValue(item.getInputValue());
score += checkInput.getScore();
for (CheckShot shotDto : item.getCheckInputShot()) {
CheckShot img = new CheckShot();
img.setCreateDate(new Date());
img.setPointName(check.getPointName());
img.setShotType(shotDto.getShotType());
img.setPhotoData(shotDto.getPhotoData());
checkShots.add(img);
}
checkInput.setCheckShotList(checkShots);
checkItemList.add(checkInput);
}
if (!ObjectUtils.isEmpty(error.toString()) && error.toString().endsWith(";")) {
error.substring(0, error.length() - 1);
check.setIsOk(CheckStatusEnum.UNQUALIFIED.getCode());
} else {
check.setIsOk(CheckStatusEnum.QUALIFIED.getCode());
}
check.setError(error.toString());
//计划外巡检是否计分 ,计划内默认都是计分
if (XJConstant.POINT_OK_SCORE.equals(point.getIsScore()) || recordParam.getPlanTaskId() != null) {
check.setScore(score);
} else {
check.setScore(Integer.parseInt(XJConstant.POINT_NOT_SCORE));
}
//3.主表入库
check = checkDao.save(check);
//冗余记录最新一次检查记录,方便其他业务查询--当前为维保到期时间用到
point.setLastCheckId(String.valueOf(check.getId()));
iPointDao.save(point);
Check finalCheck = check;
//4.检查项入库
checkItemList.forEach(checkInput -> checkInput.setCheckId(finalCheck.getId()));
if (!checkItemList.isEmpty()) {
checkInputDao.saveAll(checkItemList);
}
List<CheckShot> allShot = new ArrayList<>();
checkItemList.forEach(c -> {
c.getCheckShotList().forEach(s -> {
s.setCheckId(c.getCheckId());
s.setOrgCode(recordParam.getOrgCode());
s.setCheckInputId(c.getId());
});
allShot.addAll(c.getCheckShotList());
});
//5.图片入库
if (!allShot.isEmpty()) {
checkShotDao.saveAll(allShot);
}
planTaskDetailMapper.finishTaskDetail(Long.parseLong(detail.get("planTaskDetailId").toString()), recordParam.getPointId(), recordParam.getPlanTaskId(), mtUserSeq, userName);
//7.返回不合格记录
return new CheckDto(check.getId(), unqualifiedCheckItemList);
} catch (Exception e) {
throw new Exception(e.getMessage(),e);
}
}
private void checkCanFinishTask(String mtUserSeq, PlanTask planTask, Long pointId) throws Exception {
int status;
// int count = checkService.checkHasRecord(planTask.getId(), pointId);
// if (count > 0) {
// throw new RuntimeException("任务已执行,不能重复执行");
// }
if (!ToolUtils.transBeanList(planTask.getUserId()).contains(mtUserSeq)) {
throw new RuntimeException("无权执行该任务");
}
status = planTask.getFinishStatus();
if (status == PlanTaskFinishStatusEnum.OVERTIME.getValue()) {
throw new RuntimeException("任务已超时,上传失败!");
} else if (status == PlanTaskFinishStatusEnum.FINISHED.getValue()) {
throw new RuntimeException("任务已完成!");
}
Date checkTime = new Date();
Date beginTime = DateUtil.getLongDate(planTask.getBeginTime());
Date endTime = DateUtil.getLongDate(planTask.getEndTime());
int beginCompareTo = checkTime.compareTo(beginTime);
int endCompareTo = checkTime.compareTo(endTime);
if (beginCompareTo < 0 || endCompareTo > 0) {
throw new RuntimeException("请在计划时间内完成任务!");
}
}
@Override
public int checkHasRecord(Long planTaskId, Long pointId) {
return checkMapper.checkHasRecord(planTaskId, pointId);
}
}
......@@ -36,15 +36,13 @@ import com.yeejoin.amos.supervision.core.common.response.AppCheckInputRespone;
import com.yeejoin.amos.supervision.core.common.response.AppPointCheckRespone;
import com.yeejoin.amos.supervision.core.util.DateUtil;
import com.yeejoin.amos.supervision.core.util.StringUtil;
import com.yeejoin.amos.supervision.dao.entity.Check;
import com.yeejoin.amos.supervision.dao.entity.Plan;
import com.yeejoin.amos.supervision.dao.entity.PlanTask;
import com.yeejoin.amos.supervision.dao.entity.PlanTaskDetail;
import com.yeejoin.amos.supervision.dao.entity.*;
import com.yeejoin.amos.supervision.exception.YeeException;
import com.yeejoin.amos.supervision.feign.RemoteSecurityService;
import com.yeejoin.amos.supervision.quartz.IJobService;
import org.apache.commons.collections.CollectionUtils;
import org.assertj.core.util.Lists;
import org.checkerframework.checker.units.qual.A;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
......@@ -96,6 +94,9 @@ public class PlanTaskServiceImpl implements IPlanTaskService {
@Autowired
private EquipFeign equipFeign;
@Autowired
private IPointInputItemDao pointInputItemDao;
@Override
public Page<HashMap<String, Object>> getPlanTaskInfo(PlanTaskPageParam params) {
long total = planTaskMapper.countPlanTask(params);
......@@ -510,6 +511,11 @@ public class PlanTaskServiceImpl implements IPlanTaskService {
planTaskDetailInstance.setIsFinish(Integer.parseInt(XJConstant.PLAN_TASK_DET_FINISH_YES));
planTaskDetailInstance.setStatus("1");
}
// 查询点下检查项的个数
List<PointInputItem> pointInputItemByPointId = pointInputItemDao.getPointInputItemByPointId(pointId.longValue());
planTaskDetailInstance.setItemNum(pointInputItemByPointId.size());
// 2.保存执行数据明细表
planTaskDetail.saveAndFlush(planTaskDetailInstance);
}
......
......@@ -4,6 +4,7 @@ import java.util.HashMap;
import java.util.List;
import java.util.Map;
import com.yeejoin.amos.boot.biz.common.bo.ReginParams;
import com.yeejoin.amos.supervision.business.vo.CheckAnalysisVo;
import com.yeejoin.amos.supervision.business.vo.CheckInfoVo;
import com.yeejoin.amos.supervision.core.common.request.CommonPageable;
......@@ -46,7 +47,7 @@ public interface ICheckService {
void saveCheckImg(List<CheckShot> imgList);
CheckDto saveCheckRecord(CheckRecordParam requestParam, AgencyUserModel user, DepartmentBo departmentModel, Toke token);
// CheckDto saveCheckRecord(CheckRecordParam requestParam, AgencyUserModel user, DepartmentBo departmentModel, Toke token);
/**
* 巡检记录删除
......@@ -64,15 +65,6 @@ public interface ICheckService {
*/
List<Map> queryUnqualifiedInputItem(int checkId);
/**
* 检查该店时候已经巡检完成
*
* @param requestParam
* @return
*/
int checkHasRecord(CheckRecordParam requestParam);
AppPointCheckRespone queryCheckPointDetail(String toke,String product,String appKey,long checkId);
AppPointCheckRespone queryCheckPointDetailInVersion2(String toke,String product,String appKey,long checkId);
......@@ -278,4 +270,20 @@ public interface ICheckService {
List<Map<String, String>> getPlanExecuteStates();
List<Map<String, Object>> getPlanExecuteTeams();
/**
* 保存检查记录
* @param recordParam 填写记录
* @param reginParams 权限信息
* @return CheckDto
*/
CheckDto saveCheckRecord(CheckRecordParam recordParam, ReginParams reginParams) throws Exception;
/**
* 校验是否已经填写过
* @param planTaskId
* @param pointId
* @return
*/
int checkHasRecord(Long planTaskId, Long pointId);
}
......@@ -17,8 +17,6 @@ public class CheckParamUtil {
if("checkTime".equals(name)){
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM");
param.setCheckTime(daoCriterias.get(i).getValue().toString());
}else if("userId".equals(name)){
param.setUserId(daoCriterias.get(i).getValue().toString());
}else if("routeId".equals(name)){
param.setRouteId(Long.valueOf(daoCriterias.get(i).getValue().toString()));
}else if("orgCode".equals(name) && operator.equals(QueryOperatorEnum.EQUAL.getName())){
......
......@@ -81,10 +81,13 @@ public class CtiController extends BaseController {
* @return
*/
@TycloudOperation(ApiLevel = UserType.AGENCY)
@GetMapping(value = "/info/{connectId}")
@GetMapping(value = "/info/{serviceconnectionid}")
@ApiOperation(httpMethod = "GET", value = "获取通话话单详情", notes = "获取通话话单详情")
public ResponseModel<JSONObject> getCallInfo(@PathVariable String connectId) {
JSONArray recordInfos = ctiService.getCallInfo(connectId);
public ResponseModel<JSONObject> getCallInfo(@PathVariable String serviceconnectionid) {
JSONArray recordInfos = ctiService.getCallInfo(serviceconnectionid);
if(recordInfos.size() == 0) {
throw new BadRequest("未找到相关通话信息");
}
JSONObject recordInfo = recordInfos.getJSONObject(0);
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss.SSSZ");
return ResponseHelper.buildResponse(recordInfo);
......
......@@ -116,7 +116,7 @@ public class VoiceRecordFileController extends BaseController {
/**
* 新增通话记录
* 新增-通话记录
*
* @return
*/
......@@ -135,13 +135,13 @@ public class VoiceRecordFileController extends BaseController {
}
JSONObject recordInfo = recordInfos.getJSONObject(0);
model.setTel(recordInfo.getString("telephone"));
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss.SSSZ");
Date telStartTime = null;
Date telEndTime = null;
try {
telStartTime = sdf.parse(recordInfo.getString("connectTime"));
telEndTime = sdf.parse(recordInfo.getString("hangupTime"));
} catch (ParseException e) {
telStartTime = DateUtils.longStr2Date(recordInfo.getString("connectTime"));
telEndTime = DateUtils.longStr2Date(recordInfo.getString("hangupTime"));
} catch (Exception e) {
throw new BadRequest("日期转换错误");
}
model.setTelStartTime(telStartTime);
......@@ -152,8 +152,13 @@ public class VoiceRecordFileController extends BaseController {
model.setFileType("坐席呼出");
}
// 获取附件
Map<String, String> downloadFile = ctiService.downLoadRecordFile(model.getConnectId());
// 获取附件 需要延时5S
try {
Thread.sleep(5000);
} catch (InterruptedException e) {
e.printStackTrace();
}
Map<String, String> downloadFile = ctiService.downLoadRecordFile(recordInfo.getString("connectionid"));
if(downloadFile.isEmpty()) {
throw new BadRequest("未找到附件文件");
}
......
package com.yeejoin.amos.boot.module.tzs.biz.service.impl;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
import com.google.common.collect.Maps;
import com.yeejoin.amos.boot.biz.common.utils.DateUtils;
import com.yeejoin.amos.boot.biz.common.utils.RedisKey;
import com.yeejoin.amos.boot.biz.common.utils.RedisUtils;
import com.yeejoin.amos.boot.module.tzs.api.dto.AlertCalledDto;
import com.yeejoin.amos.boot.module.tzs.api.dto.AlertCalledFormDto;
import com.yeejoin.amos.boot.module.tzs.api.dto.AlertCalledObjsDto;
import com.yeejoin.amos.boot.module.tzs.api.dto.AlertCalledQueryDto;
import com.yeejoin.amos.boot.module.tzs.api.dto.FormValue;
import com.yeejoin.amos.boot.module.tzs.api.entity.AlertCalled;
import com.yeejoin.amos.boot.module.tzs.api.entity.AlertFormValue;
import com.yeejoin.amos.boot.module.tzs.api.entity.Elevator;
import com.yeejoin.amos.boot.module.tzs.api.enums.AlertStageEnums;
import com.yeejoin.amos.boot.module.tzs.api.enums.DispatchPaperEnums;
import com.yeejoin.amos.boot.module.tzs.api.mapper.AlertCalledMapper;
import com.yeejoin.amos.boot.module.tzs.api.service.IAlertCalledService;
import com.yeejoin.amos.boot.module.tzs.api.service.ICtiService;
import com.yeejoin.amos.boot.module.tzs.biz.utils.BeanDtoVoUtils;
import com.yeejoin.amos.boot.module.tzs.biz.utils.HttpUtils;
import com.yeejoin.amos.component.feign.model.FeignClientResult;
import com.yeejoin.amos.feign.privilege.model.AgencyUserModel;
import com.yeejoin.amos.feign.systemctl.Systemctl;
import com.yeejoin.amos.feign.systemctl.model.FileInfoModel;
import org.apache.commons.fileupload.FileItem;
import org.apache.commons.fileupload.FileItemFactory;
import org.apache.commons.fileupload.disk.DiskFileItemFactory;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.http.MediaType;
import org.springframework.mock.web.MockMultipartFile;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.web.multipart.MultipartFile;
import org.springframework.web.multipart.commons.CommonsMultipartFile;
import org.typroject.tyboot.core.rdbms.service.BaseService;
import org.typroject.tyboot.core.restful.exception.instance.BadRequest;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.security.MessageDigest;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
/**
......@@ -70,11 +36,14 @@ public class CtiServiceImpl implements ICtiService {
*/
private long time = 6000l;
private final String APP_KEY = "4e805006-3fef-ae43-3915-a153731007c4";
@Value("${tzs.cti.appkey}")
private String APP_KEY;
private final String SECRET_KEY = "7bd29115-99ee-4f7d-1fb1-7c4719d5f43a";
@Value("${tzs.cti.secretkey}")
private String SECRET_KEY;
private String ctiUrl = "http://36.46.151.113:8000";
@Value("${tzs.cti.url}")
private String ctiUrl;
@Override
public String getAccessToken() {
......@@ -144,11 +113,11 @@ public class CtiServiceImpl implements ICtiService {
}
@Override
public JSONArray getCallInfo(String connectionid) {
public JSONArray getCallInfo(String serviceconnectionid) {
String token = this.getAccessToken();
String url = ctiUrl + "/onOpenAuth/cti/openApi/querycalllist1";
String url = ctiUrl + "/onOpenAuth/cti/openApi/queryservicelist1";
JSONObject params = new JSONObject();
params.put("connectionid",connectionid);
params.put("serviceconnectionid",serviceconnectionid);
Map<String,String> header = new HashMap<>();
header.put("accessToken",token);
String responseStr = HttpUtils.doPostWithHeader(url,params.toJSONString(),header);
......
......@@ -51,6 +51,5 @@
<module>amos-boot-module-fas-biz</module>
<module>amos-boot-module-maintenance-biz</module>
<module>amos-boot-module-supervision-biz</module>
<module>amos-boot-module-jpush-biz</module>
</modules>
</project>
\ No newline at end of file
......@@ -29,7 +29,7 @@ emqx.password=a123456
rule.definition.load=false
rule.definition.model-package=com.yeejoin.amos.boot.module.jcs.api.dto
rule.definition.default-agency=jcs
rule.definition.localIp=172.16.3.39
rule.definition.localIp=172.16.10.66
## mongodb properties:
spring.data.mongodb.uri=mongodb://172.16.10.66:27017/command_db
......
......@@ -154,5 +154,11 @@
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;
</sql>
</changeSet>
<changeSet author="chenhao" id="2021-08-31-chenhao-1">
<comment>modify table cb_firefighters_thought add one columns</comment>
<sql>
ALTER TABLE `cb_firefighters_thought` modify talking_time datetime COMMENT '谈话时间';
</sql>
</changeSet>
</databaseChangeLog>
<?xml version="1.0" encoding="UTF-8"?>
<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>
<artifactId>amos-biz-boot</artifactId>
<groupId>com.amosframework.boot</groupId>
<version>1.0.0</version>
</parent>
<artifactId>amos-boot-system-supervision</artifactId>
<dependencies>
<dependency>
<groupId>com.amosframework.boot</groupId>
<artifactId>amos-boot-module-supervision-biz</artifactId>
<version>${amos-biz-boot.version}</version>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
</plugin>
</plugins>
</build>
<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>
<artifactId>amos-biz-boot</artifactId>
<groupId>com.amosframework.boot</groupId>
<version>1.0.0</version>
</parent>
<artifactId>amos-boot-system-supervision</artifactId>
<dependencies>
<dependency>
<groupId>com.amosframework.boot</groupId>
<artifactId>amos-boot-module-supervision-biz</artifactId>
<version>${amos-biz-boot.version}</version>
</dependency>
<dependency>
<groupId>cn.jpush.api</groupId>
<artifactId>jpush-client</artifactId>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
</plugin>
</plugins>
</build>
</project>
......@@ -250,16 +250,16 @@
order by pci.order_no
</select>
<select id="checkHasRecord" resultType="int">
SELECT
count(1) num
FROM
p_check c
WHERE
is_ok in (1,2)
and c.point_id = #{pointId}
and c.plan_task_id = #{planTaskId}
</select>
<!-- <select id="checkHasRecord" resultType="int">-->
<!-- SELECT-->
<!-- count(1) num-->
<!-- FROM-->
<!-- p_check c-->
<!-- WHERE-->
<!-- is_ok in (1,2)-->
<!-- and c.point_id = #{pointId}-->
<!-- and c.plan_task_id = #{planTaskId}-->
<!-- </select>-->
<select id="pieChartData" resultType="Map">
SELECT
......@@ -1956,4 +1956,15 @@
FROM
p_check pc
</select>
<select id="checkHasRecord" resultType="int">
SELECT
count(1) num
FROM
p_check c
WHERE
c.point_id = #{pointId}
and c.plan_task_id = #{planTaskId}
</select>
</mapper>
\ No newline at end of file
......@@ -3,7 +3,7 @@
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.yeejoin.amos.supervision.business.dao.mapper.PlanTaskDetailMapper">
<update id="finishTaskDetail">
call updatePlanTask(#{planTaskId}, #{pointId}, #{planTaskDetailId} ,#{executorId})
call updatePlanTask(#{planTaskId}, #{pointId}, #{planTaskDetailId} ,#{executorId},#{executorName})
</update>
<select id="findPlanTaskByTaskIdAndPointId" resultType="Map">
......
......@@ -37,7 +37,6 @@ emqx.broker=tcp://172.16.10.85:1883
emqx.user-name=super
emqx.password=a123456
## redisʱʱ
redis.cache.failure.time=10800
failure.work.flow.processDefinitionKey=malfunction_repair
\ No newline at end of file
tzs.cti.appkey=4e805006-3fef-ae43-3915-a153731007c4
tzs.cti.secretkey=7bd29115-99ee-4f7d-1fb1-7c4719d5f43a
tzs.cti.url=http://36.46.151.113:8000
......@@ -8,6 +8,8 @@ spring.jackson.date-format=yyyy-MM-dd HH:mm:ss
logging.config=classpath:logback-${spring.profiles.active}.xml
mybatis-plus.configuration.log-impl=org.apache.ibatis.logging.stdout.StdOutImpl
## DB properties:
spring.datasource.driver-class-name=com.mysql.cj.jdbc.Driver
spring.datasource.type=com.zaxxer.hikari.HikariDataSource
spring.datasource.hikari.minimum-idle=10
spring.datasource.hikari.maximum-pool-size=25
......@@ -17,6 +19,24 @@ spring.datasource.hikari.pool-name=DatebookHikariCP
spring.datasource.hikari.max-lifetime=120000
spring.datasource.hikari.connection-timeout=30000
spring.datasource.hikari.connection-test-query=SELECT 1
## eureka properties:
eureka.client.registry-fetch-interval-seconds=5
eureka.instance.prefer-ip-address=true
management.endpoint.health.show-details=always
management.endpoints.web.exposure.include=*
eureka.instance.health-check-url-path=/actuator/health
eureka.instance.lease-expiration-duration-in-seconds=10
eureka.instance.lease-renewal-interval-in-seconds=5
eureka.instance.metadata-map.management.context-path=${server.servlet.context-path}/actuator
eureka.instance.status-page-url-path=/actuator/info
eureka.instance.metadata-map.management.api-docs=http://localhost:${server.port}${server.servlet.context-path}/doc.html
## redis properties:
spring.redis.lettuce.pool.max-active=200
spring.redis.lettuce.pool.max-wait=-1
spring.redis.lettuce.pool.max-idle=10
spring.redis.lettuce.pool.min-idle=0
spring.redis.expire.time=300
iot.fegin.name=AMOS-API-IOT
......@@ -24,4 +44,12 @@ equip.fegin.name=AMOS-EQUIPMANAGE
supervision.feign.name = AMOS-SUPERVISION-API
security.systemctl.name=AMOS-API-SYSTEMCTL
\ No newline at end of file
security.systemctl.name=AMOS-API-SYSTEMCTL
jcs.company.topic.add=jcs/company/topic/add
jcs.company.topic.delete=jcs/company/topic/delete
## 设备联动服务(车库门、广播、警铃)
control.fegin.name=JCS-API-CONTROL
## redis超时时间
redis.cache.failure.time=10800
failure.work.flow.processDefinitionKey=malfunction_repair
......@@ -4,34 +4,23 @@
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>
<artifactId>amos-boot-module-biz</artifactId>
<artifactId>amos-boot-utils</artifactId>
<groupId>com.amosframework.boot</groupId>
<version>1.0.0</version>
</parent>
<artifactId>amos-boot-module-jpush-biz</artifactId>
<artifactId>amos-boot-utils-jpush</artifactId>
<dependencies>
<dependency>
<groupId>com.amosframework.boot</groupId>
<artifactId>amos-boot-module-jpush-api</artifactId>
<artifactId>amos-boot-core</artifactId>
<version>${amos-biz-boot.version}</version>
</dependency>
<dependency>
<groupId>com.amosframework.boot</groupId>
<artifactId>amos-boot-biz-common</artifactId>
<version>${amos-biz-boot.version}</version>
<exclusions>
<exclusion>
<groupId>com.baomidou</groupId>
<artifactId>mybatis-plus-generator</artifactId>
</exclusion>
<exclusion>
<groupId>com.baomidou</groupId>
<artifactId>mybatis-plus-boot-starter</artifactId>
</exclusion>
</exclusions>
<groupId>cn.jpush.api</groupId>
<artifactId>jpush-client</artifactId>
</dependency>
</dependencies>
</project>
......@@ -16,7 +16,7 @@ import org.springframework.context.ConfigurableApplicationContext;
import org.springframework.context.annotation.ComponentScan;
import org.springframework.core.env.Environment;
import org.springframework.scheduling.annotation.EnableAsync;
import org.typroject.tyboot.core.restful.exception.GlobalExceptionHandler;
//import org.typroject.tyboot.core.restful.exception.GlobalExceptionHandler;
/**
* <pre>
......@@ -40,7 +40,7 @@ public class JpushApplication {
public static void main(String[] args) throws UnknownHostException {
ConfigurableApplicationContext context = SpringApplication.run(JpushApplication.class, args);
GlobalExceptionHandler.setAlwaysOk(true);
// GlobalExceptionHandler.setAlwaysOk(true);
Environment env = context.getEnvironment();
String ip = InetAddress.getLocalHost().getHostAddress();
String port = env.getProperty("server.port");
......
package com.yeejoin.amos.jpush.service.business.controller;
import com.yeejoin.amos.jpush.common.entity.CommonResponse;
import com.yeejoin.amos.jpush.common.entity.CommonResponseUtil;
import com.yeejoin.amos.jpush.service.business.param.PushMsgParam;
import com.yeejoin.amos.jpush.service.jpush.AppMessagePushService;
import cn.jpush.api.push.model.PushPayload;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
......@@ -17,8 +12,11 @@ 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 org.typroject.tyboot.core.foundation.enumeration.UserType;
import org.typroject.tyboot.core.restful.doc.TycloudOperation;
import com.yeejoin.amos.jpush.common.entity.CommonResponse;
import com.yeejoin.amos.jpush.common.entity.CommonResponseUtil;
import com.yeejoin.amos.jpush.service.business.param.PushMsgParam;
import com.yeejoin.amos.jpush.service.jpush.AppMessagePushService;
/**
......@@ -40,7 +38,7 @@ public class UserController {
//极光推送
@ApiOperation(value = "发送消息", notes = "发送消息")
@RequestMapping(value = "/sendMessage", method = RequestMethod.POST)
public CommonResponse sendMessage(@RequestBody List<PushMsgParam> responses) {
......@@ -53,7 +51,7 @@ public class UserController {
return CommonResponseUtil.failure("发送失败");
}
}
@ApiOperation(value = "发送消息", notes = "发送消息")
@RequestMapping(value = "/sendMessageone", method = RequestMethod.POST)
public CommonResponse sendMessageone(@RequestBody PushMsgParam responses) {
......@@ -66,7 +64,6 @@ public class UserController {
return CommonResponseUtil.failure("发送失败");
}
}
@ApiOperation(value = "发送消息", notes = "发送消息")
@RequestMapping(value = "/pushNoticeMany", method = RequestMethod.POST)
public CommonResponse pushNoticeMany(@RequestBody PushMsgParam responses) {
......@@ -79,7 +76,6 @@ public class UserController {
return CommonResponseUtil.failure("发送失败");
}
}
@ApiOperation(value = "发送消息", notes = "发送消息")
@RequestMapping(value = "/buildPushPayload", method = RequestMethod.POST)
public CommonResponse buildPushPayload(@RequestBody PushMsgParam responses) {
......@@ -92,7 +88,7 @@ public class UserController {
return CommonResponseUtil.failure("发送失败");
}
}
@ApiOperation(value = "删除别名关联设备", notes = "删除别名关联设备")
@RequestMapping(value = "/pushDevice", method = RequestMethod.GET)
public CommonResponse pushDevice(@RequestParam("alias") String alias) {
......@@ -108,7 +104,6 @@ public class UserController {
return CommonResponseUtil.failure();
}
}
@ApiOperation(value = "别名关联设备", notes = "别名关联设备")
@RequestMapping(value = "/PushDeviceRegistration", method = RequestMethod.GET)
public CommonResponse PushDeviceRegistration(@RequestParam("registrationId") String registrationId,@RequestParam("alias") String alias) {
......
......@@ -3,20 +3,16 @@
*/
package com.yeejoin.amos.jpush.service.constants;
import java.text.SimpleDateFormat;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import java.text.SimpleDateFormat;
/**
* 常量
*/
public class XJConstant {
private static final Logger logger = LoggerFactory.getLogger(XJConstant.class);
/**
* 构造方法
*/
private XJConstant() {
logger.debug(XJConstant.CONSTRUCTOR);
}
......
......@@ -42,203 +42,203 @@ import cn.jpush.api.push.model.notification.Notification;
@Component
public class AppMessagePushService {
protected static final Logger log = LoggerFactory.getLogger(AppMessagePushService.class);
protected static final Logger log = LoggerFactory
.getLogger(AppMessagePushService.class);
@Value("${params.isPush}")
private String isPush;
private static RestTemplate restTemplate;
private static ObjectMapper objectMapper = new ObjectMapper();
//端口443
protected static final String URL ="https://device.jpush.cn/";
protected static final String APP_KEY = "1b3f7b961200f4b236811dfe";
protected static final String MASTER_SECRET = "8b650e645fb3a43c96be02b2";
private static JPushClient jpushClient = new JPushClient(MASTER_SECRET,
APP_KEY);
public static String buildJpushUserKey(String userId) {
@Value("${params.isPush}")
private String isPush;
private static RestTemplate restTemplate;
private static ObjectMapper objectMapper = new ObjectMapper();
// 端口443
protected static final String URL = "https://device.jpush.cn/";
protected static final String APP_KEY = "1b3f7b961200f4b236811dfe";
protected static final String MASTER_SECRET = "8b650e645fb3a43c96be02b2";
private static JPushClient jpushClient = new JPushClient(MASTER_SECRET, APP_KEY);
public static String buildJpushUserKey(String userId) {
// return XJConstant.JPUSH_USER_KEY + "_" + userId;
return userId;
}
public void sendMessage(List<PushMsgParam> responses) {
try {
if (responses != null && "true".equals(isPush)) {
for (PushMsgParam response : responses) {
PushPayload payload = buildPushPayload(response);
jpushClient.sendPush(payload);
}
}
} catch (Exception e) {
log.error(e.getMessage(), e);
e.printStackTrace();
}
}
public static PushPayload buildPushPayload(PushMsgParam response) {
Builder builder= PushPayload.newBuilder();
builder.setPlatform(Platform.all());
//设置如果用户不在线、离线消息保存的时间
Options options=Options.sendno();
options.setTimeToLive(86400l);
options.setApnsProduction(true);
builder.setOptions(options);
//设置推送方式
List<String> recivers = response.getRecivers();
List<String> users = Lists.newArrayList();
recivers.forEach(e -> users.add(buildJpushUserKey(e)));
if (JPushTypeEnum.ALL.getCode().equals(response.getType())) {
builder.setAudience(Audience.all());//Audience设置为all,说明采用广播方式推送,所有用户都可以接收到
} else if (JPushTypeEnum.TAG.getCode().equals(response.getType())) {
builder.setAudience(Audience.tag(users));//根据标签推送
} else {
builder.setAudience(Audience.alias(users));//根据别名推送
}
builder.setNotification(Notification.newBuilder()
.addPlatformNotification(AndroidNotification.newBuilder().addExtras(response.getExtras()).setAlert(response.getContent()).setTitle(response.getSubject()).build())
.build());
PushPayload pushPayload=builder.build();
return pushPayload;
}
public void sendMessage(PushMsgParam response) {
try {
if (null != response && "true".equals(isPush)) {
Builder builder= PushPayload.newBuilder();
builder.setPlatform(Platform.all());
Options options=Options.sendno();
options.setTimeToLive(86400l);
options.setApnsProduction(true);
builder.setOptions(options);
//设置推送方式
List<String> recivers = response.getRecivers();
List<String> users = Lists.newArrayList();
recivers.forEach(e -> users.add(buildJpushUserKey(e)));
builder.setAudience(Audience.all());
builder.setNotification(Notification.newBuilder()
.addPlatformNotification(AndroidNotification.newBuilder().addExtras(response.getExtras()).setAlert(response.getContent()).setTitle(response.getSubject()).build())
.build());
PushPayload payload=builder.build();
jpushClient.sendPush(payload);
}
} catch (Exception e) {
log.error(e.getMessage(), e);
e.printStackTrace();
}
}
public static void pushNoticeMany( PushMsgParam response){
PushPayload payload = buildPushPayload(response);
try {
return userId;
}
public void sendMessage(List<PushMsgParam> responses) {
try {
if (responses != null && "true".equals(isPush)) {
for (PushMsgParam response : responses) {
PushPayload payload = buildPushPayload(response);
jpushClient.sendPush(payload);
} catch (APIConnectionException e) {
}
}
} catch (Exception e) {
log.error(e.getMessage(), e);
e.printStackTrace();
}
}
public static PushPayload buildPushPayload(PushMsgParam response) {
Builder builder = PushPayload.newBuilder();
builder.setPlatform(Platform.all());
// 设置如果用户不在线、离线消息保存的时间
Options options = Options.sendno();
options.setTimeToLive(86400l);
options.setApnsProduction(true);
builder.setOptions(options);
// 设置推送方式
List<String> recivers = response.getRecivers();
List<String> users = Lists.newArrayList();
recivers.forEach(e -> users.add(buildJpushUserKey(e)));
if (JPushTypeEnum.ALL.getCode().equals(response.getType())) {
builder.setAudience(Audience.all());// Audience设置为all,说明采用广播方式推送,所有用户都可以接收到
} else if (JPushTypeEnum.TAG.getCode().equals(response.getType())) {
builder.setAudience(Audience.tag(users));// 根据标签推送
} else {
builder.setAudience(Audience.alias(users));// 根据别名推送
}
builder.setNotification(Notification.newBuilder()
.addPlatformNotification(AndroidNotification.newBuilder().addExtras(response.getExtras())
.setAlert(response.getContent()).setTitle(response.getSubject()).build())
.build());
PushPayload pushPayload = builder.build();
return pushPayload;
}
public void sendMessage(PushMsgParam response) {
try {
if (null != response && "true".equals(isPush)) {
Builder builder = PushPayload.newBuilder();
builder.setPlatform(Platform.all());
Options options = Options.sendno();
options.setTimeToLive(86400l);
options.setApnsProduction(true);
builder.setOptions(options);
// 设置推送方式
List<String> recivers = response.getRecivers();
List<String> users = Lists.newArrayList();
recivers.forEach(e -> users.add(buildJpushUserKey(e)));
builder.setAudience(Audience.all());
builder.setNotification(Notification.newBuilder()
.addPlatformNotification(AndroidNotification.newBuilder().addExtras(response.getExtras())
.setAlert(response.getContent()).setTitle(response.getSubject()).build())
.build());
PushPayload payload = builder.build();
jpushClient.sendPush(payload);
}
} catch (Exception e) {
log.error(e.getMessage(), e);
e.printStackTrace();
}
}
public static void pushNoticeMany(PushMsgParam response) {
PushPayload payload = buildPushPayload(response);
try {
jpushClient.sendPush(payload);
} catch (APIConnectionException e) {
e.printStackTrace();
} catch (APIRequestException e) {
e.printStackTrace();
}
}
// 删除一个别名,以及该别名与设备的绑定关系。
public static boolean PushDevice(String alias) {
CloseableHttpClient httpClient = null;
CloseableHttpResponse httpResponse = null;
try {
httpClient = HttpClients.createDefault();
HttpDelete httpDelete = new HttpDelete(URL + "v3/aliases/" + alias);
RequestConfig requestConfig = RequestConfig.custom().setConnectTimeout(35000)
.setConnectionRequestTimeout(35000).setSocketTimeout(60000).build();
httpDelete.setConfig(requestConfig);
httpDelete.addHeader("Accept", "application/json");
httpDelete.addHeader("Authorization", "Basic " + Base64(APP_KEY + ":" + MASTER_SECRET));
httpResponse = httpClient.execute(httpDelete);
return true;
} catch (Exception e) {
e.printStackTrace();
return false;
} finally {
// 关闭资源
if (null != httpResponse) {
try {
httpResponse.close();
} catch (IOException e) {
e.printStackTrace();
}
}
if (null != httpClient) {
try {
httpClient.close();
} catch (IOException e) {
e.printStackTrace();
} catch (APIRequestException e) {
}
}
}
}
// 设置设备的别名与标签
public static boolean PushDeviceRegistration(String registrationId, String alias) {
CloseableHttpClient httpClient = null;
CloseableHttpResponse httpResponse = null;
try {
httpClient = HttpClients.createDefault();
HttpPost httpPost = new HttpPost(URL + "v3/devices/" + registrationId);
RequestConfig requestConfig = RequestConfig.custom().setConnectTimeout(35000)
.setConnectionRequestTimeout(35000).setSocketTimeout(60000).build();
httpPost.setConfig(requestConfig);
httpPost.addHeader("Accept", "application/json");
httpPost.addHeader("Authorization", "Basic " + Base64(APP_KEY + ":" + MASTER_SECRET));
if (null != alias) {
Map<String, Object> nvps = new HashMap<>();
// 通过map集成entrySet方法获取entity
nvps.put("alias", alias);
nvps.put("tags", "");
nvps.put("mobile", "");
String json = JSON.toJSONString(nvps);
StringEntity stringEntity = new StringEntity(json, "UTF-8");// 解决中文乱码问题
httpPost.setEntity(stringEntity);
httpResponse = httpClient.execute(httpPost);
return true;
} else {
return false;
}
} catch (Exception e) {
e.printStackTrace();
return false;
} finally {
// 关闭资源
if (null != httpResponse) {
try {
httpResponse.close();
} catch (IOException e) {
e.printStackTrace();
}
}
if (null != httpClient) {
try {
httpClient.close();
} catch (IOException e) {
e.printStackTrace();
}
}
//删除一个别名,以及该别名与设备的绑定关系。
public static boolean PushDevice(String alias) {
CloseableHttpClient httpClient = null;
CloseableHttpResponse httpResponse = null;
try {
httpClient = HttpClients.createDefault();
HttpDelete httpDelete = new HttpDelete(URL +"v3/aliases/"+alias);
RequestConfig requestConfig = RequestConfig.custom().setConnectTimeout(35000)
.setConnectionRequestTimeout(35000)
.setSocketTimeout(60000)
.build();
httpDelete.setConfig(requestConfig);
httpDelete.addHeader("Accept", "application/json");
httpDelete.addHeader("Authorization", "Basic "+Base64(APP_KEY+":"+MASTER_SECRET));
httpResponse = httpClient.execute(httpDelete);
return true;
} catch (Exception e) {
e.printStackTrace();
return false;
} finally {
// 关闭资源
if (null != httpResponse) {
try {
httpResponse.close();
} catch (IOException e) {
e.printStackTrace();
}
}
if (null != httpClient) {
try {
httpClient.close();
} catch (IOException e) {
e.printStackTrace();
}
}
}
}
//设置设备的别名与标签
public static boolean PushDeviceRegistration(String registrationId,String alias) {
CloseableHttpClient httpClient = null;
CloseableHttpResponse httpResponse = null;
try {
httpClient = HttpClients.createDefault();
HttpPost httpPost = new HttpPost(URL +"v3/devices/"+registrationId);
RequestConfig requestConfig = RequestConfig.custom().setConnectTimeout(35000)
.setConnectionRequestTimeout(35000)
.setSocketTimeout(60000)
.build();
httpPost.setConfig(requestConfig);
httpPost.addHeader("Accept", "application/json");
httpPost.addHeader("Authorization", "Basic "+Base64(APP_KEY+":"+MASTER_SECRET));
if (null != alias ) {
Map<String, Object> nvps = new HashMap<>();
// 通过map集成entrySet方法获取entity
nvps.put("alias", alias);
nvps.put("tags", "");
nvps.put("mobile", "");
String json= JSON.toJSONString(nvps);
StringEntity stringEntity = new StringEntity(json,"UTF-8");//解决中文乱码问题
httpPost.setEntity(stringEntity);
httpResponse = httpClient.execute(httpPost);
return true;
}else{
return false;
}
} catch (Exception e) {
e.printStackTrace();
return false;
} finally {
// 关闭资源
if (null != httpResponse) {
try {
httpResponse.close();
} catch (IOException e) {
e.printStackTrace();
}
}
if (null != httpClient) {
try {
httpClient.close();
} catch (IOException e) {
e.printStackTrace();
}
}
}
}
//Base64转码
public static String Base64(String code) {
final Base64.Encoder encoder = Base64.getEncoder();
byte[] textByte;
try {
textByte = code.getBytes("UTF-8");
//编码
String encodedText = encoder.encodeToString(textByte);
return encodedText;
} catch (UnsupportedEncodingException e) {
}
}
}
}
// Base64转码
public static String Base64(String code) {
final Base64.Encoder encoder = Base64.getEncoder();
byte[] textByte;
try {
textByte = code.getBytes("UTF-8");
// 编码
String encodedText = encoder.encodeToString(textByte);
return encodedText;
} catch (UnsupportedEncodingException e) {
e.printStackTrace();
return "";
}
}
}
}
......@@ -1159,10 +1159,10 @@ public class DateUtil {
return true;
}
public static void main(String[] args)
{
//
}
// public static void main(String[] args)
// {
// //
// }
/**
* 将date 按照指定 的 格式 formatStr 转换成 字符串
......
......@@ -8,5 +8,10 @@ eureka.instance.metadata-map.management.context-path=${server.servlet.context-pa
eureka.instance.status-page-url-path=/actuator/info
eureka.instance.metadata-map.management.api-docs=http://localhost:${server.port}${server.servlet.context-path}/swagger-ui.html
## redis properties:
spring.redis.database=0
spring.redis.host=172.16.10.85
spring.redis.port=6379
spring.redis.password=amos2019Redis
params.isPush=true
\ No newline at end of file
server.port=7800
spring.application.name=AMOS-PUSH
server.servlet.context-path=/jpush
server.port=7800
spring.profiles.active=dev
spring.jackson.time-zone=GMT+8
spring.jackson.date-format=yyyy-MM-dd HH:mm:ss
ribbon.eureka.enabled=true
ribbon.ConnectTimeout=60000
ribbon.ReadTimeout=60000
ribbon.OkToRetryOnAllOperations=true
ribbon.MaxAutoRetriesNextServer=2
ribbon.MaxAutoRetries=1
spring.jackson.serialization.write-dates-as-timestamps=true
<?xml version="1.0" encoding="UTF-8"?>
<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>
<artifactId>amos-biz-boot</artifactId>
<groupId>com.amosframework.boot</groupId>
<version>1.0.0</version>
</parent>
<artifactId>amos-boot-utils</artifactId>
<packaging>pom</packaging>
<dependencies>
</dependencies>
<modules>
<module>amos-boot-utils-jpush</module>
</modules>
</project>
......@@ -37,9 +37,12 @@
<artifactId>spring-cloud-starter-netflix-eureka-server</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
<dependency>
<groupId>com.netflix.hystrix</groupId>
<artifactId>hystrix-javanica</artifactId>
<version>1.5.18</version>
<scope>compile</scope>
<exclusions>
<exclusion>
......@@ -61,7 +64,11 @@
<artifactId>fastjson</artifactId>
<version>1.2.67</version>
</dependency>
<dependency>
<groupId>com.yeejoin</groupId>
<artifactId>amos-feign-privilege</artifactId>
<version>${amos.version}</version>
</dependency>
<dependency>
<groupId>com.alibaba</groupId>
......@@ -162,16 +169,11 @@
<artifactId>spring-boot-starter-websocket</artifactId>
</dependency>
<dependency>
<groupId>cn.jpush.api</groupId>
<artifactId>jpush-client</artifactId>
<version>3.3.10</version>
</dependency>
<dependency>
<groupId>org.apache.commons</groupId>
<artifactId>commons-jexl</artifactId>
<version>2.1.1</version>
</dependency>
<!-- MQTT依赖 -->
<!-- MQTT���� -->
<dependency>
<groupId>org.springframework.integration</groupId>
<artifactId>spring-integration-stream</artifactId>
......@@ -185,73 +187,22 @@
<artifactId>lombok</artifactId>
<scope>provided</scope>
</dependency>
<!-- knife4j -->
<dependency>
<groupId>org.typroject</groupId>
<artifactId>tyboot-core-restful</artifactId>
<version>${tyboot-version}</version>
<exclusions>
<exclusion>
<groupId>org.typroject</groupId>
<artifactId>*</artifactId>
</exclusion>
<exclusion>
<groupId>io.springfox</groupId>
<artifactId>springfox-swagger-ui</artifactId>
</exclusion>
<exclusion>
<groupId>io.springfox</groupId>
<artifactId>springfox-swagger2</artifactId>
</exclusion>
<exclusion>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-undertow</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>com.yeejoin</groupId>
<artifactId>amos-feign-privilege</artifactId>
<version>${amos.version}</version>
</dependency>
<dependency>
<groupId>com.yeejoin</groupId>
<artifactId>amos-feign-systemctl</artifactId>
<version>${amos.version}</version>
</dependency>
<dependency>
<groupId>org.typroject</groupId>
<artifactId>tyboot-core-rdbms</artifactId>
<version>${tyboot-version}</version>
<groupId>com.github.xiaoymin</groupId>
<artifactId>knife4j-spring-boot-starter</artifactId>
<version>${knife4j-spring-boot-starter.version}</version>
<exclusions>
<exclusion>
<groupId>org.typroject</groupId>
<artifactId>*</artifactId>
</exclusion>
<exclusion>
<groupId>com.baomidou</groupId>
<artifactId>mybatis-plus-boot-starter</artifactId>
</exclusion>
<exclusion>
<artifactId>mysql-connector-java</artifactId>
<groupId>mysql</groupId>
<groupId>org.javassist</groupId>
<artifactId>javassist</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<artifactId>mysql-connector-java</artifactId>
<groupId>mysql</groupId>
<version>8.0.22</version>
</dependency>
<dependency>
<groupId>org.typroject</groupId>
<artifactId>tyboot-core-auth</artifactId>
<version>${tyboot-version}</version>
<exclusions>
<exclusion>
<groupId>org.typroject</groupId>
<artifactId>*</artifactId>
</exclusion>
</exclusions>
<groupId>io.swagger</groupId>
<artifactId>swagger-annotations</artifactId>
<version>1.5.13</version>
</dependency>
</dependencies>
<dependencyManagement>
......@@ -291,6 +242,16 @@
<artifactId>mybatis-spring-boot-starter</artifactId>
<version>2.1.0</version>
</dependency>
<dependency>
<groupId>cn.jpush.api</groupId>
<artifactId>jpush-client</artifactId>
<version>3.3.10</version>
</dependency>
<dependency>
<groupId>org.liquibase</groupId>
<artifactId>liquibase-core</artifactId>
<version>4.4.3</version>
</dependency>
</dependencies>
</dependencyManagement>
<repositories>
......@@ -308,16 +269,16 @@
<name>maven-public</name>
<url>http://172.16.1.6:8081/nexus/content/repositories/maven-public/</url>
</repository>
<!-- <repository>-->
<!-- <id>maven-public1</id>-->
<!-- <name>maven-public</name>-->
<!-- <url>http://repo.typroject.org:8081/repository/maven-public/</url>-->
<!-- </repository>-->
<!-- <repository>-->
<!-- <id>maven-snapshot</id>-->
<!-- <name>maven-snapshot</name>-->
<!-- <url>http://repo.typroject.org:8081/repository/maven-snapshots/</url>-->
<!-- </repository>-->
<!-- <repository> -->
<!-- <id>maven-public1</id> -->
<!-- <name>maven-public</name> -->
<!-- <url>http://repo.typroject.org:8081/repository/maven-public/</url> -->
<!-- </repository> -->
<!-- <repository> -->
<!-- <id>maven-snapshot</id> -->
<!-- <name>maven-snapshot</name> -->
<!-- <url>http://repo.typroject.org:8081/repository/maven-snapshots/</url> -->
<!-- </repository> -->
</repositories>
<modules>
......@@ -330,6 +291,7 @@
<module>amos-boot-system-patrol</module>
<module>amos-boot-system-maintenance</module>
<module>amos-boot-system-supervision</module>
<module>amos-boot-system-jpush</module>
<module>amos-boot-core</module>
<module>amos-boot-utils</module>
</modules>
</project>
\ No newline at end of file
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