Skip to content
切换导航条
切换导航条
当前项目
正在载入...
登录
孙克
/
smf-core
转到一个项目
切换导航栏
切换导航栏固定状态
项目
群组
代码片段
帮助
项目
活动
版本库
流水线
图表
问题
0
合并请求
0
维基
网络
创建新的问题
作业
提交
问题看板
文件
提交
网络
比较
分支
标签
Commit 66e812f4
由
sunke
编写于
2021-07-22 10:09:03 +0800
浏览文件
选项
浏览文件
标签
下载
电子邮件补丁
差异文件
任务查询
1 个父辈
61f09ef1
隐藏空白字符变更
内嵌
并排
正在显示
13 个修改的文件
包含
593 行增加
和
22 行删除
src/main/java/com/neotel/smfcore/common/annotation/QueryCondition.java
src/main/java/com/neotel/smfcore/common/utils/QueryHelp.java
src/main/java/com/neotel/smfcore/core/order/rest/OrderController.java
src/main/java/com/neotel/smfcore/core/order/rest/bean/query/OrderQueryCondition.java
src/main/java/com/neotel/smfcore/core/system/rest/TaskController.java
src/main/java/com/neotel/smfcore/core/system/rest/bean/dto/TaskDto.java
src/main/java/com/neotel/smfcore/core/system/rest/bean/mapstruct/TaskMapper.java
src/main/java/com/neotel/smfcore/core/system/rest/bean/query/TaskQueryCondition.java
src/main/java/com/neotel/smfcore/core/system/service/manager/impl/DataLogManagerImpl.java
src/main/java/com/neotel/smfcore/core/system/util/TaskService.java
src/main/java/com/neotel/smfcore/hella/rest/HellaSensorShelfController.java
src/main/java/com/neotel/smfcore/security/config/SwaggerConfig.java
src/main/resources/config/application.yml
src/main/java/com/neotel/smfcore/common/annotation/QueryCondition.java
查看文件 @
66e812f
...
...
@@ -52,6 +52,10 @@ public @interface QueryCondition {
* 不包含
*/
NIN
,
/**
* 模糊查询
*/
LIKE
,
/**
* between
...
...
src/main/java/com/neotel/smfcore/common/utils/QueryHelp.java
查看文件 @
66e812f
...
...
@@ -3,6 +3,7 @@ package com.neotel.smfcore.common.utils;
import
cn.hutool.core.collection.CollUtil
;
import
cn.hutool.core.collection.CollectionUtil
;
import
cn.hutool.core.util.ObjectUtil
;
import
com.google.common.collect.Lists
;
import
com.neotel.smfcore.common.annotation.QueryCondition
;
import
lombok.extern.slf4j.Slf4j
;
import
org.springframework.data.mongodb.core.query.Criteria
;
...
...
@@ -18,7 +19,8 @@ import java.util.regex.Pattern;
@Slf4j
public
class
QueryHelp
{
public
static
<
C
>
Query
getQuery
(
C
c
){
Criteria
criteria
=
new
Criteria
();
//Criteria criteria = new Criteria();
List
<
Criteria
>
allCriteria
=
Lists
.
newArrayList
();
if
(
c
!=
null
){
try
{
List
<
Field
>
fields
=
getAllFields
(
c
.
getClass
(),
new
ArrayList
<>());
...
...
@@ -40,51 +42,77 @@ public class QueryHelp {
String
blurry
=
q
.
blurry
();
String
[]
blurrys
=
blurry
.
split
(
","
);
if
(
ObjectUtil
.
isNotEmpty
(
blurry
))
{
List
<
Criteria
>
orCriterialList
=
Lists
.
newArrayList
();
Criteria
orCriterial
=
new
Criteria
();
for
(
String
s
:
blurrys
)
{
Pattern
pattern
=
Pattern
.
compile
(
escapeExprSpecialWord
(
val
.
toString
()),
Pattern
.
CASE_INSENSITIVE
);
criteria
=
criteria
.
and
(
s
).
regex
(
pattern
);
//criteria = criteria.and(s).regex(pattern);
orCriterialList
.
add
(
Criteria
.
where
(
s
).
regex
(
pattern
));
}
if
(!
orCriterialList
.
isEmpty
()){
allCriteria
.
add
(
new
Criteria
().
orOperator
(
orCriterialList
));
}
continue
;
}
switch
(
q
.
type
())
{
case
EQ:
criteria
=
criteria
.
and
(
propName
).
is
(
val
);
//criteria = criteria.and(attributeName).is(val);
allCriteria
.
add
(
Criteria
.
where
(
attributeName
).
is
(
val
));
break
;
case
GT:
criteria
=
criteria
.
and
(
propName
).
gt
(
val
);
//criteria = criteria.and(attributeName).gt(val);
allCriteria
.
add
(
Criteria
.
where
(
attributeName
).
gt
(
val
));
break
;
case
LT:
criteria
=
criteria
.
and
(
propName
).
lt
(
val
);
//criteria = criteria.and(attributeName).lt(val);
allCriteria
.
add
(
Criteria
.
where
(
attributeName
).
lt
(
val
));
break
;
case
LTE:
criteria
=
criteria
.
and
(
propName
).
lte
(
val
);
//criteria = criteria.and(attributeName).lte(val);
allCriteria
.
add
(
Criteria
.
where
(
attributeName
).
lte
(
val
));
break
;
case
IN:
if
(
CollUtil
.
isNotEmpty
((
Collection
<
Object
>)
val
))
{
criteria
=
criteria
.
and
(
propName
).
in
((
Collection
<
Object
>)
val
);
//criteria = criteria.and(attributeName).in((Collection<Object>) val);
allCriteria
.
add
(
Criteria
.
where
(
attributeName
).
in
(
val
));
}
break
;
case
NIN:
if
(
CollUtil
.
isNotEmpty
((
Collection
<
Object
>)
val
))
{
criteria
=
criteria
.
and
(
propName
).
nin
((
Collection
<
Object
>)
val
);
//criteria = criteria.and(attributeName).nin((Collection<Object>) val);
allCriteria
.
add
(
Criteria
.
where
(
attributeName
).
nin
(
val
));
}
break
;
case
NE:
criteria
=
criteria
.
and
(
propName
).
ne
(
val
);
//criteria = criteria.and(attributeName).ne(val);
allCriteria
.
add
(
Criteria
.
where
(
attributeName
).
ne
(
val
));
break
;
case
NOT:
criteria
=
criteria
.
and
(
propName
).
not
();
//criteria = criteria.and(attributeName).not();
allCriteria
.
add
(
Criteria
.
where
(
attributeName
).
not
());
break
;
case
LIKE:
Pattern
pattern
=
Pattern
.
compile
(
escapeExprSpecialWord
(
val
.
toString
()),
Pattern
.
CASE_INSENSITIVE
);
//criteria = criteria.and(attributeName).regex(pattern);
allCriteria
.
add
(
Criteria
.
where
(
attributeName
).
regex
(
pattern
));
break
;
case
IS_NULL:
criteria
=
criteria
.
and
(
propName
).
is
(
null
);
//criteria = criteria.and(attributeName).is(null);
allCriteria
.
add
(
Criteria
.
where
(
attributeName
).
is
(
null
));
break
;
case
EXISTS:
criteria
=
criteria
.
and
(
propName
).
exists
(
true
);
//criteria = criteria.and(attributeName).exists(true);
allCriteria
.
add
(
Criteria
.
where
(
attributeName
).
exists
(
true
));
break
;
case
BETWEEN:
List
<
Object
>
between
=
new
ArrayList
<>((
List
<
Object
>)
val
);
criteria
=
criteria
.
and
(
propName
).
gte
(
between
.
get
(
0
)).
lte
(
between
.
get
(
1
));
//criteria = criteria.and(attributeName).gte(between.get(0)).lte(between.get(1));
Object
start
=
between
.
get
(
0
);
Object
end
=
between
.
get
(
1
);
allCriteria
.
add
(
Criteria
.
where
(
attributeName
).
gte
(
start
));
allCriteria
.
add
(
Criteria
.
where
(
attributeName
).
lte
(
between
.
get
(
1
)));
break
;
default
:
break
;
}
...
...
@@ -96,7 +124,7 @@ public class QueryHelp {
}
}
return
new
Query
(
criteria
);
return
new
Query
(
new
Criteria
().
andOperator
(
allCriteria
)
);
}
...
...
src/main/java/com/neotel/smfcore/core/order/rest/OrderController.java
0 → 100644
查看文件 @
66e812f
package
com
.
neotel
.
smfcore
.
core
.
order
.
rest
;
import
com.google.common.collect.Lists
;
import
com.neotel.smfcore.common.annotation.QueryCondition
;
import
com.neotel.smfcore.common.exception.ValidateException
;
import
com.neotel.smfcore.common.utils.PageUtil
;
import
com.neotel.smfcore.common.utils.QueryHelp
;
import
com.neotel.smfcore.common.utils.SecurityUtils
;
import
com.neotel.smfcore.core.order.rest.bean.query.OrderQueryCondition
;
import
com.neotel.smfcore.core.order.service.manager.ILiteOrderItemManager
;
import
com.neotel.smfcore.core.order.service.manager.ILiteOrderManager
;
import
com.neotel.smfcore.core.order.service.po.LiteOrder
;
import
com.neotel.smfcore.security.rest.bean.vo.UserPassVo
;
import
com.neotel.smfcore.security.service.manager.IGroupManager
;
import
com.neotel.smfcore.security.service.manager.IRoleManager
;
import
com.neotel.smfcore.security.service.manager.IUserManager
;
import
com.neotel.smfcore.security.service.po.Group
;
import
com.neotel.smfcore.security.service.po.Role
;
import
com.neotel.smfcore.security.service.po.User
;
import
io.swagger.annotations.Api
;
import
io.swagger.annotations.ApiOperation
;
import
lombok.RequiredArgsConstructor
;
import
lombok.extern.slf4j.Slf4j
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.data.domain.Pageable
;
import
org.springframework.http.HttpStatus
;
import
org.springframework.http.ResponseEntity
;
import
org.springframework.security.access.prepost.PreAuthorize
;
import
org.springframework.security.crypto.password.PasswordEncoder
;
import
org.springframework.util.CollectionUtils
;
import
org.springframework.util.ObjectUtils
;
import
org.springframework.validation.annotation.Validated
;
import
org.springframework.web.bind.annotation.*
;
import
java.util.List
;
import
java.util.Set
;
@Slf4j
@Api
(
tags
=
"系统:工单管理"
)
@RestController
@RequestMapping
(
"/api/orders"
)
@RequiredArgsConstructor
public
class
OrderController
{
@Autowired
private
ILiteOrderManager
liteOrderManager
;
@Autowired
private
ILiteOrderItemManager
liteOrderItemManager
;
@Autowired
private
IUserManager
userManager
;
@Autowired
private
IGroupManager
groupManager
;
// @ApiOperation("导出用户数据")
// @GetMapping(value = "/download")
// @PreAuthorize("@el.check('user:list')")
// public void download(HttpServletResponse response, UserQueryCriteria criteria) throws IOException {
// userService.download(userService.queryAll(criteria), response);
// }
@ApiOperation
(
"查询工单"
)
@GetMapping
@PreAuthorize
(
"@el.check('order:list')"
)
public
ResponseEntity
<
Object
>
query
(
OrderQueryCondition
criteria
,
Pageable
pageable
){
User
user
=
userManager
.
findByUserName
(
SecurityUtils
.
getCurrentUsername
());
if
(
user
!=
null
){
//数据权限
if
(!
user
.
getIsAdmin
()){
Set
<
String
>
groupIds
=
user
.
getGroups
();
List
<
String
>
groupNames
=
Lists
.
newArrayList
();
if
(!
ObjectUtils
.
isEmpty
(
groupIds
)){
for
(
String
groupId
:
groupIds
)
{
Group
group
=
groupManager
.
get
(
groupId
);
groupNames
.
add
(
group
.
getGroupName
());
}
}
//都没有权限,返回空
if
(
ObjectUtils
.
isEmpty
(
groupNames
)){
return
new
ResponseEntity
<>(
PageUtil
.
toPage
(
null
,
0
),
HttpStatus
.
OK
);
}
criteria
.
setSourceList
(
groupNames
);
}
}
List
<
LiteOrder
>
orderList
=
liteOrderManager
.
findByPage
(
QueryHelp
.
getQuery
(
criteria
),
pageable
);
return
new
ResponseEntity
<>(
PageUtil
.
toPage
(
orderList
,
0
),
HttpStatus
.
OK
);
}
// @ApiOperation("新增用户")
// @PostMapping
// @PreAuthorize("@el.check('user:add')")
// public ResponseEntity<Object> create(@Validated @RequestBody User resources){
// if(!hasLevel(resources)) {
// return new ResponseEntity<>(HttpStatus.BAD_REQUEST);
// }
// // 默认密码 123456
// resources.setPassword(passwordEncoder.encode("123456"));
// try {
// userManager.save(resources);
// } catch (ValidateException e) {
// log.error("新增用户 user:add ["+resources.toString()+"]出错:"+e);
// return new ResponseEntity<>(HttpStatus.INTERNAL_SERVER_ERROR);
// }
// return new ResponseEntity<>(HttpStatus.CREATED);
// }
// @ApiOperation("修改用户")
// @PutMapping
// @PreAuthorize("@el.check('user:edit')")
//// public ResponseEntity<Object> update(@Validated(User.Update.class) @RequestBody User resources) throws Exception {
// public ResponseEntity<Object> update(@Validated @RequestBody User resources) {
// if(!hasLevel(resources)) {
// return new ResponseEntity<>(HttpStatus.BAD_REQUEST);
// }
// try {
// userManager.update(resources);
// } catch (Exception e) {
// log.error("修改用户 user:edit ["+resources.toString()+"]出错:"+e);
// return new ResponseEntity<>(HttpStatus.INTERNAL_SERVER_ERROR);
// }
// return new ResponseEntity<>(HttpStatus.NO_CONTENT);
// }
// @ApiOperation("修改用户:个人中心")
// @PutMapping(value = "center")
//// public ResponseEntity<Object> center(@Validated(User.Update.class) @RequestBody User resources){
// public ResponseEntity<Object> center(@Validated @RequestBody User resources){
// if(!resources.getId().equals(SecurityUtils.getCurrentUserId())){
//// throw new BadRequestException("不能修改他人资料");
// log.error("修改用户:个人中心:不能修改他人资料,操作失败");
// return new ResponseEntity<>(HttpStatus.BAD_REQUEST);
// }
// userManager.updateCenter(resources);
// return new ResponseEntity<>(HttpStatus.NO_CONTENT);
// }
// @ApiOperation("删除用户")
// @DeleteMapping
// @PreAuthorize("@el.check('user:del')")
// public ResponseEntity<Object> delete(@RequestBody Set<String> ids){
// for (String id : ids) {
// User user=userManager.get(id);
// if(!hasLevel(user)) {
// return new ResponseEntity<>(HttpStatus.BAD_REQUEST);
// }
// }
// try {
// userManager.deleteUsers(ids);
// } catch (ValidateException e) {
// log.error("删除用户出错:"+e);
// return new ResponseEntity<>(HttpStatus.INTERNAL_SERVER_ERROR);
// }
// return new ResponseEntity<>(HttpStatus.OK);
// }
// @ApiOperation("修改密码")
// @PostMapping(value = "/updatePass")
// public ResponseEntity<Object> updatePass(@RequestBody UserPassVo passVo) throws Exception {
//
// User user = userManager.get(SecurityUtils.getCurrentUserId());
// if(!passwordEncoder.matches(passVo.getOldPass(), user.getPassword())){
//// throw new BadRequestException("修改失败,旧密码错误");
// log.error("用户["+SecurityUtils.getCurrentUsername()+"]修改密码失败:旧密码错误");
// return new ResponseEntity<>(HttpStatus.BAD_REQUEST);
// }
// if(passwordEncoder.matches(passVo.getNewPass(), user.getPassword())){
//// throw new BadRequestException("新密码不能与旧密码相同");
// log.error("用户["+SecurityUtils.getCurrentUsername()+"]修改密码失败:新密码不能与旧密码相同");
// return new ResponseEntity<>(HttpStatus.BAD_REQUEST);
// }
// userManager.updatePass(user.getUsername(),passwordEncoder.encode(passVo.getNewPass()));
// return new ResponseEntity<>(HttpStatus.OK);
// }
// @Log("修改邮箱")
// @ApiOperation("修改邮箱")
// @PostMapping(value = "/updateEmail/{code}")
// public ResponseEntity<Object> updateEmail(@PathVariable String code, @RequestBody User user) throws Exception {
// String password = RsaUtils.decryptByPrivateKey(RsaProperties.privateKey,user.getPassword());
// UserDto userDto = userService.findByName(SecurityUtils.getCurrentUsername());
// if(!passwordEncoder.matches(password, userDto.getPassword())){
// throw new BadRequestException("密码错误");
// }
// verificationCodeService.validated(CodeEnum.EMAIL_RESET_EMAIL_CODE.getKey() + user.getEmail(), code);
// userService.updateEmail(userDto.getUsername(),user.getEmail());
// return new ResponseEntity<>(HttpStatus.OK);
// }
}
src/main/java/com/neotel/smfcore/core/order/rest/bean/query/OrderQueryCondition.java
0 → 100644
查看文件 @
66e812f
package
com
.
neotel
.
smfcore
.
core
.
order
.
rest
.
bean
.
query
;
import
com.neotel.smfcore.common.annotation.QueryCondition
;
import
lombok.Data
;
import
java.util.Date
;
import
java.util.List
;
@Data
public
class
OrderQueryCondition
{
@QueryCondition
(
blurry
=
"orderNo"
)
private
String
blurry
;
@QueryCondition
(
type
=
QueryCondition
.
Type
.
BETWEEN
)
private
List
<
Date
>
createTime
;
@QueryCondition
(
type
=
QueryCondition
.
Type
.
IN
,
propName
=
"source"
)
private
List
<
String
>
sourceList
;
}
src/main/java/com/neotel/smfcore/core/system/rest/TaskController.java
0 → 100644
查看文件 @
66e812f
package
com
.
neotel
.
smfcore
.
core
.
system
.
rest
;
import
com.google.common.collect.Lists
;
import
com.neotel.smfcore.common.utils.PageUtil
;
import
com.neotel.smfcore.common.utils.QueryHelp
;
import
com.neotel.smfcore.core.system.rest.bean.dto.TaskDto
;
import
com.neotel.smfcore.core.system.rest.bean.mapstruct.TaskMapper
;
import
com.neotel.smfcore.core.system.rest.bean.query.TaskQueryCondition
;
import
com.neotel.smfcore.core.system.service.manager.IDataLogManager
;
import
com.neotel.smfcore.core.system.service.po.DataLog
;
import
com.neotel.smfcore.core.system.util.TaskService
;
import
io.swagger.annotations.Api
;
import
io.swagger.annotations.ApiOperation
;
import
lombok.RequiredArgsConstructor
;
import
lombok.extern.slf4j.Slf4j
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.data.domain.Pageable
;
import
org.springframework.http.HttpStatus
;
import
org.springframework.http.ResponseEntity
;
import
org.springframework.security.access.prepost.PreAuthorize
;
import
org.springframework.util.ObjectUtils
;
import
org.springframework.web.bind.annotation.*
;
import
java.util.List
;
import
java.util.Set
;
@Slf4j
@Api
(
tags
=
"任务管理"
)
@RestController
@RequestMapping
(
"/api/tasks"
)
@RequiredArgsConstructor
public
class
TaskController
{
@Autowired
private
TaskService
taskService
;
@Autowired
private
IDataLogManager
dataLogManager
;
@Autowired
private
final
TaskMapper
taskMapper
;
// @ApiOperation("导出用户数据")
// @GetMapping(value = "/download")
// @PreAuthorize("@el.check('user:list')")
// public void download(HttpServletResponse response, UserQueryCriteria criteria) throws IOException {
// userService.download(userService.queryAll(criteria), response);
// }
@ApiOperation
(
"查询出入库日志"
)
@GetMapping
(
"/history"
)
@PreAuthorize
(
"@el.check('task:list')"
)
public
ResponseEntity
<
Object
>
query
(
TaskQueryCondition
criteria
,
Pageable
pageable
){
List
<
DataLog
>
taskList
=
dataLogManager
.
findByPage
(
QueryHelp
.
getQuery
(
criteria
),
pageable
);
return
new
ResponseEntity
<>(
PageUtil
.
toPage
(
taskMapper
.
toDto
(
taskList
),
0
),
HttpStatus
.
OK
);
}
@ApiOperation
(
"获取队列中的任务"
)
@GetMapping
@PreAuthorize
(
"@el.check('task:inQueue','task:list')"
)
public
ResponseEntity
<
Object
>
query
(
String
[]
cids
){
List
<
DataLog
>
resultTasks
=
Lists
.
newArrayList
();
List
<
DataLog
>
allTasks
=
taskService
.
getAllTasks
();
if
(!
ObjectUtils
.
isEmpty
(
cids
)){
List
<
String
>
cidList
=
Lists
.
newArrayList
(
cids
);
for
(
DataLog
task
:
allTasks
)
{
String
cid
=
task
.
getCid
();
if
(
cidList
.
contains
(
cid
)){
resultTasks
.
add
(
task
);
}
}
}
// DataLog testTask = new DataLog();
// testTask.setCid("123");
// testTask.setStatus("FINISHED");
// resultTasks.add(testTask);
List
<
TaskDto
>
resultDtos
=
taskMapper
.
toDto
(
resultTasks
);
return
new
ResponseEntity
<>(
resultDtos
,
HttpStatus
.
OK
);
}
@ApiOperation
(
"取消任务"
)
@DeleteMapping
@PreAuthorize
(
"@el.check('task:cancel')"
)
public
ResponseEntity
<
Object
>
cancel
(
@RequestBody
Set
<
String
>
ids
){
for
(
String
taskId
:
ids
)
{
taskService
.
cancelTask
(
taskId
);
}
return
new
ResponseEntity
<>(
HttpStatus
.
OK
);
}
}
src/main/java/com/neotel/smfcore/core/system/rest/bean/dto/TaskDto.java
0 → 100644
查看文件 @
66e812f
package
com
.
neotel
.
smfcore
.
core
.
system
.
rest
.
bean
.
dto
;
import
lombok.Getter
;
import
lombok.Setter
;
import
java.io.Serializable
;
import
java.util.List
;
@Getter
@Setter
public
class
TaskDto
implements
Serializable
{
/**
* 是否是单盘出库(联电指出库项目,默认为false即默认批量出库)
*/
private
boolean
singleOut
=
false
;
/**
* 所属料仓
*/
private
String
storageName
;
/**
* 料仓 cid
*/
private
String
cid
;
/**
* 料仓 ID
*/
private
String
storageId
;
/**
* 仓位 ID
*/
private
String
posId
;
/**
* 仓位名称
*/
private
String
posName
;
//二维码(Reel ID)
private
String
barcode
;
/**
* 物料编号
*/
private
String
partNumber
;
/**
*数量(从 barCode 中读取)
*/
private
int
num
;
/**
* 类型:入库OP.PUT_IN,出库OP.CHECKOUT
*/
private
int
type
;
/**
* 状态:OP_STATUS
*/
private
String
status
;
/**
* 指定批次Id
*/
private
String
batchId
;
/**
* 批次显示内容
*/
private
String
batchInfo
;
/**
* 指令来源:站位列表 指定订单工单 MES
*/
private
String
sourceType
;
/**
* 来源 id,
*/
private
String
sourceId
;
/**
* 来源名称
*/
private
String
sourceName
;
/**
* 子来源 ID(单个站位)
*/
private
String
subSourceId
;
/**
* 子来源名称
*/
private
String
subSourceInfo
;
/**
* 创建人
*/
private
String
creator
;
/**
* 操作人
*/
private
String
operator
;
/**
* 关联条码,夹具时关联相关的物料,用于入库完成时插入相关物料
*/
private
List
<
String
>
relationCodes
;
private
String
memo
;
/**
* 搅拌时间(锡膏搅拌任务使用)
*/
private
int
mixTime
;
/**
* 亮灯料架颜色
*/
private
String
lightColor
=
""
;
}
src/main/java/com/neotel/smfcore/core/system/rest/bean/mapstruct/TaskMapper.java
0 → 100644
查看文件 @
66e812f
package
com
.
neotel
.
smfcore
.
core
.
system
.
rest
.
bean
.
mapstruct
;
import
com.neotel.smfcore.common.base.BaseMapper
;
import
com.neotel.smfcore.core.system.rest.bean.dto.TaskDto
;
import
com.neotel.smfcore.core.system.service.po.DataLog
;
import
org.mapstruct.Mapper
;
import
org.mapstruct.ReportingPolicy
;
@Mapper
(
componentModel
=
"spring"
,
unmappedTargetPolicy
=
ReportingPolicy
.
IGNORE
)
public
interface
TaskMapper
extends
BaseMapper
<
TaskDto
,
DataLog
>
{
}
src/main/java/com/neotel/smfcore/core/system/rest/bean/query/TaskQueryCondition.java
0 → 100644
查看文件 @
66e812f
package
com
.
neotel
.
smfcore
.
core
.
system
.
rest
.
bean
.
query
;
import
com.neotel.smfcore.common.annotation.QueryCondition
;
import
lombok.Data
;
import
org.springframework.format.annotation.DateTimeFormat
;
import
java.util.Date
;
import
java.util.List
;
@Data
public
class
TaskQueryCondition
{
@QueryCondition
(
blurry
=
"barcode,partNumber,posName,sourceName,subSourceInfo,memo"
)
private
String
blurry
;
@QueryCondition
private
String
barcode
;
@QueryCondition
(
type
=
QueryCondition
.
Type
.
BETWEEN
)
@DateTimeFormat
(
pattern
=
"yyyy-MM-dd HH:mm:ss"
)
private
List
<
Date
>
updateDate
;
@QueryCondition
(
type
=
QueryCondition
.
Type
.
IN
,
propName
=
"status"
)
private
List
<
String
>
statusList
;
@QueryCondition
private
String
storageId
;
}
src/main/java/com/neotel/smfcore/core/system/service/manager/impl/DataLogManagerImpl.java
查看文件 @
66e812f
package
com
.
neotel
.
smfcore
.
core
.
system
.
service
.
manager
.
impl
;
import
com.neotel.smfcore.common.exception.ValidateException
;
import
com.neotel.smfcore.core.system.service.dao.IDataLogDao
;
import
com.neotel.smfcore.core.system.service.manager.IDataLogManager
;
import
com.neotel.smfcore.core.system.service.po.DataLog
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.data.domain.Pageable
;
import
org.springframework.data.mongodb.core.query.Query
;
import
org.springframework.stereotype.Service
;
...
...
@@ -12,6 +14,9 @@ import java.util.List;
@Service
public
class
DataLogManagerImpl
implements
IDataLogManager
{
@Autowired
private
IDataLogDao
dataLogDao
;
@Override
public
DataLog
get
(
String
id
)
{
return
null
;
...
...
@@ -19,7 +24,7 @@ public class DataLogManagerImpl implements IDataLogManager {
@Override
public
DataLog
save
(
DataLog
object
)
throws
ValidateException
{
return
null
;
return
dataLogDao
.
save
(
object
)
;
}
@Override
...
...
@@ -29,11 +34,11 @@ public class DataLogManagerImpl implements IDataLogManager {
@Override
public
List
<
DataLog
>
findByPage
(
Query
query
,
Pageable
pageable
)
{
return
null
;
return
dataLogDao
.
findByQuery
(
query
,
pageable
)
;
}
@Override
public
List
<
DataLog
>
findByQuery
(
Query
query
)
{
return
null
;
return
dataLogDao
.
findByQuery
(
query
)
;
}
}
src/main/java/com/neotel/smfcore/core/system/util/TaskService.java
查看文件 @
66e812f
...
...
@@ -149,6 +149,18 @@ public class TaskService {
}
/**
* 获取所有任务
*/
public
List
<
DataLog
>
getAllTasks
(){
List
<
DataLog
>
allTasks
=
getFinishedTasks
();
Collection
<
DataLog
>
queueTasks
=
getQueueTasks
();
if
(!
queueTasks
.
isEmpty
()){
allTasks
.
addAll
(
queueTasks
);
}
return
allTasks
;
}
/**
* 获取某个料仓所有任务队列中的任务(等待中和执行中)
*/
public
Collection
<
DataLog
>
getQueueTasks
(
String
cid
)
{
...
...
@@ -161,6 +173,24 @@ public class TaskService {
return
tasks
;
}
private
boolean
cancelTask
(
DataLog
task
)
{
if
(
task
!=
null
)
{
//从正在执行和等待列表中移除
removeQueueTask
(
task
);
task
.
setStatus
(
OP_STATUS
.
CANCEL
.
name
());
updateFinishedTask
(
task
);
log
.
info
(
"任务["
+
task
.
getId
()
+
"] posName["
+
task
.
getPosName
()
+
"] Reel Id["
+
task
.
getBarcode
()
+
"]取消成功"
);
return
true
;
}
return
false
;
}
public
boolean
cancelTask
(
String
taskId
)
{
DataLog
task
=
dataLogDao
.
findOneById
(
taskId
);
return
cancelTask
(
task
);
}
/**
* 清除某个已经完成或取消的任务
*/
...
...
src/main/java/com/neotel/smfcore/hella/rest/HellaSensorShelfController.java
查看文件 @
66e812f
package
com
.
neotel
.
smfcore
.
hella
.
rest
;
import
com.neotel.smfcore.common.bean.ResultBean
;
import
com.neotel.smfcore.common.utils.SecurityUtils
;
import
com.neotel.smfcore.core.barcode.service.manager.IBarcodeManager
;
import
com.neotel.smfcore.core.barcode.service.po.Barcode
;
import
com.neotel.smfcore.core.device.util.DataCache
;
...
...
@@ -10,6 +11,8 @@ import com.neotel.smfcore.core.storage.service.po.StoragePos;
import
com.neotel.smfcore.core.system.service.po.DataLog
;
import
com.neotel.smfcore.core.system.util.TaskService
;
import
com.neotel.smfcore.hella.handler.HellaServiceHandler
;
import
io.swagger.annotations.Api
;
import
io.swagger.annotations.ApiOperation
;
import
lombok.extern.slf4j.Slf4j
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.stereotype.Controller
;
...
...
@@ -23,9 +26,10 @@ import java.util.*;
/**
*
扫码
料架
*
感应
料架
*/
@Controller
@Api
(
tags
=
"海拉感应料架"
)
@RequestMapping
(
"/api/sensorShelf"
)
@Slf4j
public
class
HellaSensorShelfController
{
...
...
@@ -44,7 +48,24 @@ public class HellaSensorShelfController {
@Autowired
protected
IBarcodeManager
barcodeManager
;
/**
* 扫码
*/
@ApiOperation
(
"扫码入库"
)
@RequestMapping
(
"/codeIn"
)
@ResponseBody
public
ResultBean
codeIn
(
HttpServletRequest
request
,
HttpSession
httpSession
){
String
codeStr
=
request
.
getParameter
(
"code"
);
String
groupStr
=
request
.
getParameter
(
"group"
);
String
loginUser
=
SecurityUtils
.
getLoginUsername
();
Collection
<
DataLog
>
queueTasks
=
taskService
.
getQueueTasks
();
for
(
DataLog
queueTask
:
queueTasks
)
{
if
(
queueTask
.
isPutInTask
()
&&
queueTask
.
getSourceName
().
equals
(
groupStr
)){
return
ResultBean
.
newErrorResult
(-
1
,
"the task of ["
+
queueTask
.
getBarcode
()+
"] is unfinished."
);
}
}
return
hellaServiceHandler
.
checkMaterial
(
loginUser
,
groupStr
,
codeStr
);
}
}
src/main/java/com/neotel/smfcore/security/config/SwaggerConfig.java
查看文件 @
66e812f
...
...
@@ -27,6 +27,7 @@ import org.springframework.core.Ordered;
import
org.springframework.data.domain.Pageable
;
import
springfox.documentation.builders.ApiInfoBuilder
;
import
springfox.documentation.builders.PathSelectors
;
import
springfox.documentation.builders.RequestHandlerSelectors
;
import
springfox.documentation.schema.AlternateTypeRule
;
import
springfox.documentation.schema.AlternateTypeRuleConvention
;
import
springfox.documentation.service.*
;
...
...
@@ -74,12 +75,24 @@ public class SwaggerConfig {
private
ApiInfo
apiInfo
()
{
return
new
ApiInfoBuilder
()
.
description
(
"
一个简单且易上手的 Spring boot 后台管理框架
"
)
.
description
(
"
挚锦SMF 接口文档
"
)
.
title
(
"SMF 接口文档"
)
.
version
(
"1.7.819"
)
.
build
();
}
@Bean
public
Docket
web_api_prdt
()
{
return
new
Docket
(
DocumentationType
.
SWAGGER_2
)
.
apiInfo
(
apiInfo
())
.
select
()
.
apis
(
RequestHandlerSelectors
.
any
())
.
paths
(
PathSelectors
.
ant
(
"/service/store/**"
))
.
build
()
.
groupName
(
"设备通信"
)
.
pathMapping
(
"/"
);
}
private
List
<
SecurityScheme
>
securitySchemes
()
{
//设置请求头信息
List
<
SecurityScheme
>
securitySchemes
=
new
ArrayList
<>();
...
...
src/main/resources/config/application.yml
查看文件 @
66e812f
...
...
@@ -2,7 +2,7 @@ server:
port
:
8800
hella
:
host
:
192.168.1.3
host
:
port
:
9900
...
...
编写
预览
支持
Markdown
格式
附加文件
你添加了
0
人
到此讨论。请谨慎行事。
Finish editing this message first!
Cancel
请
注册
或
登录
后发表评论