Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
C
cloud-fb
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
王衍超
cloud-fb
Commits
337f46a0
Commit
337f46a0
authored
May 20, 2021
by
高晓磊
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
散户预警功能
parent
d5568749
Hide whitespace changes
Inline
Side-by-side
Showing
16 changed files
with
1114 additions
and
242 deletions
+1114
-242
RetailInfoConfiguration.java
...va/com/xyst/dinas/biz/config/RetailInfoConfiguration.java
+11
-0
RetailInfoConstant.java
.../java/com/xyst/dinas/biz/constant/RetailInfoConstant.java
+30
-0
RetailInfoDao.java
...z/src/main/java/com/xyst/dinas/biz/dao/RetailInfoDao.java
+7
-1
RetailInfoDaoImpl.java
...va/com/xyst/dinas/biz/internal/dao/RetailInfoDaoImpl.java
+77
-61
RetailInfoServiceImpl.java
...yst/dinas/biz/internal/service/RetailInfoServiceImpl.java
+127
-5
RetailInfoBuyAmountWarningCalculate.java
...as/biz/processor/RetailInfoBuyAmountWarningCalculate.java
+61
-0
RetailInfoBuyAmountWarningCalculator.java
...s/biz/processor/RetailInfoBuyAmountWarningCalculator.java
+79
-0
RetailInfoBuyCountWarningCalculate.java
...nas/biz/processor/RetailInfoBuyCountWarningCalculate.java
+63
-0
RetailInfoBuyCountWarningCalculator.java
...as/biz/processor/RetailInfoBuyCountWarningCalculator.java
+79
-0
RetailInfoService.java
...in/java/com/xyst/dinas/biz/service/RetailInfoService.java
+5
-0
WarningServiceImpl.java
...main/java/com/xyst/dinas/biz/warn/WarningServiceImpl.java
+233
-173
WarnSettingDao.java
...main/java/com/xyst/dinas/biz/warn/dao/WarnSettingDao.java
+21
-0
WarningService.java
.../java/com/xyst/dinas/biz/warn/service/WarningService.java
+8
-2
RetailInfoController.java
...ain/java/com/xyst/dinas/biz/web/RetailInfoController.java
+39
-0
RetailInfoWarningExe.mk
...in/model/com/xyst/dinas/biz/query/RetailInfoWarningExe.mk
+129
-0
RetailInfoWarningExe.jmx
...sources/com/xyst/dinas/biz/query/RetailInfoWarningExe.jmx
+145
-0
No files found.
backend/xyst.dinas.biz/src/main/java/com/xyst/dinas/biz/config/RetailInfoConfiguration.java
View file @
337f46a0
...
@@ -7,6 +7,8 @@ import com.xyst.dinas.biz.constant.RetailInfoConstant;
...
@@ -7,6 +7,8 @@ import com.xyst.dinas.biz.constant.RetailInfoConstant;
import
com.xyst.dinas.biz.dao.RetailInfoDao
;
import
com.xyst.dinas.biz.dao.RetailInfoDao
;
import
com.xyst.dinas.biz.internal.dao.RetailInfoDaoImpl
;
import
com.xyst.dinas.biz.internal.dao.RetailInfoDaoImpl
;
import
com.xyst.dinas.biz.internal.service.RetailInfoServiceImpl
;
import
com.xyst.dinas.biz.internal.service.RetailInfoServiceImpl
;
import
com.xyst.dinas.biz.processor.RetailInfoBuyAmountWarningCalculator
;
import
com.xyst.dinas.biz.processor.RetailInfoBuyCountWarningCalculator
;
import
com.xyst.dinas.biz.service.RetailInfoService
;
import
com.xyst.dinas.biz.service.RetailInfoService
;
import
com.xyst.dinas.biz.web.RetailInfoController
;
import
com.xyst.dinas.biz.web.RetailInfoController
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.beans.factory.annotation.Autowired
;
...
@@ -44,5 +46,14 @@ public class RetailInfoConfiguration {
...
@@ -44,5 +46,14 @@ public class RetailInfoConfiguration {
new
ClassPathResource
(
"/com/xyst/dinas/biz/datamodel/RetailInfo.jmx"
,
KClass
.
class
));
new
ClassPathResource
(
"/com/xyst/dinas/biz/datamodel/RetailInfo.jmx"
,
KClass
.
class
));
}
}
@Bean
(
"com.xyst.dinas.biz.processor.RetailInfoBuyCountWarningCalculator"
)
public
RetailInfoBuyCountWarningCalculator
retailInfoBuyCountWarningCalculator
()
{
return
new
RetailInfoBuyCountWarningCalculator
();
}
@Bean
(
"com.xyst.dinas.biz.processor.RetailInfoBuyAmountWarningCalculator"
)
public
RetailInfoBuyAmountWarningCalculator
retailInfoBuyAmountWarningCalculator
()
{
return
new
RetailInfoBuyAmountWarningCalculator
();
}
}
}
backend/xyst.dinas.biz/src/main/java/com/xyst/dinas/biz/constant/RetailInfoConstant.java
View file @
337f46a0
...
@@ -5,5 +5,35 @@ public interface RetailInfoConstant {
...
@@ -5,5 +5,35 @@ public interface RetailInfoConstant {
* 实体名
* 实体名
*/
*/
String
ENTITY
=
"com.xyst.dinas.biz.datamodel.RetailInfo"
;
String
ENTITY
=
"com.xyst.dinas.biz.datamodel.RetailInfo"
;
/**
* 实体名
*/
String
DETAIL_ENTITY
=
"com.xyst.dinas.biz.datamodel.RetailInfoAssociatedDinasTypeDetail"
;
/**
* 散客购买预警类型
*/
public
static
final
String
RETAIL_INFO_WARN_BILL_TYPE
=
"散客购买"
;
/**
* 散客购买预警指标-购买次数
*/
public
static
final
String
RETAIL_INFO_WARN_BUY_COUNT
=
"购买次数"
;
/**
* 散客购买预警指标-购买重量
*/
public
static
final
String
RETAIL_INFO_WARN_BUY_AMOUNT
=
"购买重量"
;
/**
* 购买次数预警计算器
*/
public
static
final
String
RETAIL_INFO_BUY_COUNT_WARNING_CALCULATOR
=
"com.xyst.dinas.biz.processor.RetailInfoBuyCountWarningCalculator"
;
/**
* 购买重量(总量)预警计算器
*/
public
static
final
String
RETAIL_INFO_BUY_AMOUNT_WARNING_CALCULATOR
=
"com.xyst.dinas.biz.processor.RetailInfoBuyAmountWarningCalculator"
;
}
}
backend/xyst.dinas.biz/src/main/java/com/xyst/dinas/biz/dao/RetailInfoDao.java
View file @
337f46a0
...
@@ -4,6 +4,7 @@ import com.beecode.bap.attachment.common.Page;
...
@@ -4,6 +4,7 @@ import com.beecode.bap.attachment.common.Page;
import
com.beecode.bcp.type.KObject
;
import
com.beecode.bcp.type.KObject
;
import
com.beecode.inz.basis.dao.BaseDao
;
import
com.beecode.inz.basis.dao.BaseDao
;
import
java.math.BigDecimal
;
import
java.util.List
;
import
java.util.List
;
import
java.util.UUID
;
import
java.util.UUID
;
...
@@ -23,6 +24,11 @@ public interface RetailInfoDao extends BaseDao {
...
@@ -23,6 +24,11 @@ public interface RetailInfoDao extends BaseDao {
List
<
KObject
>
getByName
(
String
name
,
UUID
id
);
List
<
KObject
>
getByName
(
String
name
,
UUID
id
);
void
modify
(
KObject
kobject
);
void
modify
(
KObject
kobject
,
KObject
oldKObject
);
void
deleteDetailByMasterId
(
UUID
uuid
);
Long
selectBuyCountByIdCard
(
String
idCard
,
UUID
uuid
);
BigDecimal
selectBuyAmountByIdCard
(
String
idCard
,
UUID
fromString
);
}
}
backend/xyst.dinas.biz/src/main/java/com/xyst/dinas/biz/internal/dao/RetailInfoDaoImpl.java
View file @
337f46a0
...
@@ -5,20 +5,26 @@ import com.beecode.bap.attachment.common.Page;
...
@@ -5,20 +5,26 @@ import com.beecode.bap.attachment.common.Page;
import
com.beecode.bcp.core.context.AminoContextHolder
;
import
com.beecode.bcp.core.context.AminoContextHolder
;
import
com.beecode.bcp.type.KClass
;
import
com.beecode.bcp.type.KClass
;
import
com.beecode.bcp.type.KObject
;
import
com.beecode.bcp.type.KObject
;
import
com.beecode.inz.basis.context.warehouse.WarehouseUserContextHolder
;
import
com.beecode.inz.basis.dao.WarehouseUserDao
;
import
com.beecode.inz.basis.internal.dao.AbstractBaseDao
;
import
com.beecode.inz.basis.internal.dao.AbstractBaseDao
;
import
com.beecode.inz.basis.pojo.WarehouseUser
;
import
com.beecode.inz.common.BaseConstants
;
import
com.beecode.inz.common.BaseConstants
;
import
com.xyst.dinas.biz.constant.ProductionLineConstant
;
import
com.xyst.dinas.biz.constant.RetailInfoConstant
;
import
com.xyst.dinas.biz.constant.RetailInfoConstant
;
import
com.xyst.dinas.biz.dao.DinasTypeDao
;
import
com.xyst.dinas.biz.dao.DinasTypeDao
;
import
com.xyst.dinas.biz.dao.RetailInfoDao
;
import
com.xyst.dinas.biz.dao.RetailInfoDao
;
import
com.xyst.dinas.biz.dao.StationDao
;
import
org.hibernate.criterion.DetachedCriteria
;
import
org.hibernate.criterion.DetachedCriteria
;
import
org.hibernate.criterion.Order
;
import
org.hibernate.criterion.Order
;
import
org.hibernate.criterion.Projections
;
import
org.hibernate.criterion.Restrictions
;
import
org.hibernate.criterion.Restrictions
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.orm.hibernate5.HibernateTemplate
;
import
org.springframework.orm.hibernate5.HibernateTemplate
;
import
java.math.BigDecimal
;
import
java.util.Date
;
import
java.util.Date
;
import
java.util.List
;
import
java.util.List
;
import
java.util.Objects
;
import
java.util.UUID
;
import
java.util.UUID
;
public
class
RetailInfoDaoImpl
extends
AbstractBaseDao
implements
RetailInfoDao
,
RetailInfoConstant
{
public
class
RetailInfoDaoImpl
extends
AbstractBaseDao
implements
RetailInfoDao
,
RetailInfoConstant
{
...
@@ -29,26 +35,31 @@ public class RetailInfoDaoImpl extends AbstractBaseDao implements RetailInfoDao,
...
@@ -29,26 +35,31 @@ public class RetailInfoDaoImpl extends AbstractBaseDao implements RetailInfoDao,
@Autowired
@Autowired
private
DinasTypeDao
dinasTypeDao
;
private
DinasTypeDao
dinasTypeDao
;
@Override
@Autowired
public
KObject
load
(
UUID
id
)
{
private
StationDao
stationDao
;
return
(
KObject
)
template
.
load
(
ENTITY
,
id
);
}
@Autowired
private
WarehouseUserDao
warehouseUserDao
;
@Override
public
KObject
load
(
UUID
id
)
{
return
(
KObject
)
template
.
load
(
ENTITY
,
id
);
}
@Override
@Override
public
Page
<
KObject
>
listRetailInfoInfoPaging
(
Page
<
KObject
>
page
,
Integer
retailInfoStatus
)
{
public
Page
<
KObject
>
listRetailInfoInfoPaging
(
Page
<
KObject
>
page
,
Integer
retailInfoStatus
)
{
KClass
bean
=
Amino
.
getStaticMetadataContext
().
getBean
(
RetailInfoConstant
.
ENTITY
,
KClass
.
class
);
KClass
bean
=
Amino
.
getStaticMetadataContext
().
getBean
(
RetailInfoConstant
.
ENTITY
,
KClass
.
class
);
DetachedCriteria
detachedCriteria
=
DetachedCriteria
.
forEntityName
(
bean
.
getName
());
DetachedCriteria
detachedCriteria
=
DetachedCriteria
.
forEntityName
(
bean
.
getName
());
// detachedCriteria.add(Restrictions.eq("department.id", departmentId));
detachedCriteria
.
add
(
Restrictions
.
eq
(
"del"
,
false
));
detachedCriteria
.
add
(
Restrictions
.
eq
(
"del"
,
false
));
if
(
null
!=
retailInfoStatus
)
{
if
(
null
!=
retailInfoStatus
)
{
detachedCriteria
.
add
(
Restrictions
.
eq
(
"retailInfoStatus"
,
retailInfoStatus
));
detachedCriteria
.
add
(
Restrictions
.
eq
(
"retailInfoStatus"
,
retailInfoStatus
));
}
}
dinasTypeDao
.
addRegionalCompanyFilter
(
detachedCriteria
);
dinasTypeDao
.
addRegionalCompanyFilter
(
detachedCriteria
);
detachedCriteria
.
addOrder
(
Order
.
desc
(
"sortOrder"
));
detachedCriteria
.
addOrder
(
Order
.
desc
(
"sortOrder"
));
int
offset
=
page
.
getPageSize
()
*
(
page
.
getPageNo
()
-
1
);
int
offset
=
page
.
getPageSize
()
*
(
page
.
getPageNo
()
-
1
);
page
.
setTotal
(
template
.
findByCriteria
(
detachedCriteria
).
size
());
page
.
setTotal
(
template
.
findByCriteria
(
detachedCriteria
).
size
());
List
<
KObject
>
list
=
(
List
<
KObject
>)
template
.
findByCriteria
(
detachedCriteria
,
offset
,
page
.
getPageSize
());
List
<
KObject
>
list
=
(
List
<
KObject
>)
template
.
findByCriteria
(
detachedCriteria
,
offset
,
page
.
getPageSize
());
page
.
setDatas
(
list
);
page
.
setDatas
(
list
);
return
page
;
return
page
;
}
}
...
@@ -57,17 +68,16 @@ public class RetailInfoDaoImpl extends AbstractBaseDao implements RetailInfoDao,
...
@@ -57,17 +68,16 @@ public class RetailInfoDaoImpl extends AbstractBaseDao implements RetailInfoDao,
public
List
<
KObject
>
listRetailInfoInfoByRegionalCompany
(
UUID
regionalCompanyId
)
{
public
List
<
KObject
>
listRetailInfoInfoByRegionalCompany
(
UUID
regionalCompanyId
)
{
KClass
bean
=
Amino
.
getStaticMetadataContext
().
getBean
(
RetailInfoConstant
.
ENTITY
,
KClass
.
class
);
KClass
bean
=
Amino
.
getStaticMetadataContext
().
getBean
(
RetailInfoConstant
.
ENTITY
,
KClass
.
class
);
DetachedCriteria
detachedCriteria
=
DetachedCriteria
.
forEntityName
(
bean
.
getName
());
DetachedCriteria
detachedCriteria
=
DetachedCriteria
.
forEntityName
(
bean
.
getName
());
// detachedCriteria.add(Restrictions.eq("department.id", departmentId));
detachedCriteria
.
add
(
Restrictions
.
eq
(
"del"
,
false
));
detachedCriteria
.
add
(
Restrictions
.
eq
(
"del"
,
false
));
if
(
null
==
regionalCompanyId
)
{
if
(
null
==
regionalCompanyId
)
{
KObject
currentLoginRegionalCompany
=
dinasTypeDao
.
getCurrentLoginRegionalCompany
();
KObject
currentLoginRegionalCompany
=
dinasTypeDao
.
getCurrentLoginRegionalCompany
();
if
(
null
!=
currentLoginRegionalCompany
)
{
if
(
null
!=
currentLoginRegionalCompany
)
{
regionalCompanyId
=
currentLoginRegionalCompany
.
getUuid
(
"id"
);
regionalCompanyId
=
currentLoginRegionalCompany
.
getUuid
(
"id"
);
}
}
}
}
if
(
null
!=
regionalCompanyId
)
{
if
(
null
!=
regionalCompanyId
)
{
detachedCriteria
.
add
(
Restrictions
.
eq
(
"regionalCompany.id"
,
regionalCompanyId
));
detachedCriteria
.
add
(
Restrictions
.
eq
(
"regionalCompany.id"
,
regionalCompanyId
));
}
}
detachedCriteria
.
addOrder
(
Order
.
desc
(
"sortOrder"
));
detachedCriteria
.
addOrder
(
Order
.
desc
(
"sortOrder"
));
return
(
List
<
KObject
>)
template
.
findByCriteria
(
detachedCriteria
);
return
(
List
<
KObject
>)
template
.
findByCriteria
(
detachedCriteria
);
...
@@ -76,15 +86,14 @@ public class RetailInfoDaoImpl extends AbstractBaseDao implements RetailInfoDao,
...
@@ -76,15 +86,14 @@ public class RetailInfoDaoImpl extends AbstractBaseDao implements RetailInfoDao,
@Override
@Override
public
List
<
KObject
>
getByName
(
String
name
,
UUID
id
)
{
public
List
<
KObject
>
getByName
(
String
name
,
UUID
id
)
{
// UUID departmentId = AminoContextHolder.getContext().getStaff().get("department").getUuid("id");
KClass
bean
=
Amino
.
getStaticMetadataContext
().
getBean
(
RetailInfoConstant
.
ENTITY
,
KClass
.
class
);
KClass
bean
=
Amino
.
getStaticMetadataContext
().
getBean
(
RetailInfoConstant
.
ENTITY
,
KClass
.
class
);
DetachedCriteria
detachedCriteria
=
DetachedCriteria
.
forEntityName
(
bean
.
getName
());
DetachedCriteria
detachedCriteria
=
DetachedCriteria
.
forEntityName
(
bean
.
getName
());
dinasTypeDao
.
addRegionalCompanyFilter
(
detachedCriteria
);
dinasTypeDao
.
addRegionalCompanyFilter
(
detachedCriteria
);
detachedCriteria
.
add
(
Restrictions
.
eq
(
"del"
,
false
));
detachedCriteria
.
add
(
Restrictions
.
eq
(
"del"
,
false
));
detachedCriteria
.
add
(
Restrictions
.
eq
(
"retailInfoName"
,
name
));
detachedCriteria
.
add
(
Restrictions
.
eq
(
"retailInfoName"
,
name
));
if
(
id
!=
null
)
{
if
(
id
!=
null
)
{
detachedCriteria
.
add
(
Restrictions
.
ne
(
"id"
,
id
));
detachedCriteria
.
add
(
Restrictions
.
ne
(
"id"
,
id
));
}
}
...
@@ -92,56 +101,62 @@ public class RetailInfoDaoImpl extends AbstractBaseDao implements RetailInfoDao,
...
@@ -92,56 +101,62 @@ public class RetailInfoDaoImpl extends AbstractBaseDao implements RetailInfoDao,
}
}
@Override
@Override
public
void
modify
(
KObject
kobject
)
{
public
void
modify
(
KObject
kobject
,
KObject
oldKObject
)
{
KObject
id
=
load
(
kobject
.
getUuid
(
"id"
));
kobject
.
set
(
"createUser"
,
oldKObject
.
get
(
"createUser"
));
kobject
.
set
(
BaseConstants
.
CREATOR
,
id
.
get
(
BaseConstants
.
CREATOR
));
kobject
.
set
(
BaseConstants
.
CREATE_TIME
,
oldKObject
.
getDate
(
BaseConstants
.
CREATE_TIME
));
kobject
.
set
(
BaseConstants
.
CREATE_TIME
,
id
.
getDate
(
BaseConstants
.
CREATE_TIME
));
WarehouseUser
warehouseUser
=
WarehouseUserContextHolder
.
getContext
().
getWarehouseUser
();
KObject
staff
=
AminoContextHolder
.
getContext
().
getStaff
();
kobject
.
set
(
"regionalCompany"
,
dinasTypeDao
.
getCurrentLoginRegionalCompany
());
kobject
.
set
(
"regionalCompany"
,
dinasTypeDao
.
getCurrentLoginRegionalCompany
());
kobject
.
set
(
BaseConstants
.
MODIFY_TIME
,
new
Date
());
kobject
.
set
(
"station"
,
stationDao
.
load
(
kobject
.
get
(
"station"
).
getUuid
(
BaseConstants
.
ID
)));
kobject
.
set
(
BaseConstants
.
MODIFIER
,
staff
);
kobject
.
set
(
BaseConstants
.
MODIFY_TIME
,
new
Date
());
kobject
.
set
(
BaseConstants
.
DEL
,
false
);
kobject
.
set
(
"updateUser"
,
warehouseUserDao
.
findById
(
warehouseUser
.
getId
()));
template
.
deleteAll
(
id
.
get
(
"productionLines"
).
toList
());
kobject
.
set
(
BaseConstants
.
DEL
,
false
);
KObject
productions
=
kobject
.
get
(
"productionLines"
);
if
(
null
!=
productions
){
List
<
KObject
>
kObjects
=
productions
.
toList
();
for
(
KObject
object
:
kObjects
)
{
if
(
null
==
object
.
getUuid
(
"id"
)){
object
.
set
(
"id"
,
UUID
.
randomUUID
());
}
object
.
set
(
"retailInfo"
,
kobject
);
template
.
save
(
ProductionLineConstant
.
ENTITY
,
object
);
}
}
template
.
merge
(
kobject
);
template
.
merge
(
kobject
);
}
}
@Override
public
void
deleteDetailByMasterId
(
UUID
uuid
)
{
template
.
execute
(
session
->
session
.
createQuery
(
"delete from "
+
DETAIL_ENTITY
+
" where master.id = :id"
).
setParameter
(
"id"
,
uuid
).
executeUpdate
()
);
}
@Override
public
Long
selectBuyCountByIdCard
(
String
idCard
,
UUID
uuid
)
{
KClass
bean
=
Amino
.
getStaticMetadataContext
().
getBean
(
RetailInfoConstant
.
ENTITY
,
KClass
.
class
);
DetachedCriteria
detachedCriteria
=
DetachedCriteria
.
forEntityName
(
bean
.
getName
());
detachedCriteria
.
add
(
Restrictions
.
eq
(
"del"
,
false
));
detachedCriteria
.
add
(
Restrictions
.
eq
(
"idCard"
,
idCard
));
detachedCriteria
.
add
(
Restrictions
.
eq
(
"station.id"
,
uuid
));
return
(
Long
)
detachedCriteria
.
setProjection
(
Projections
.
rowCount
()).
getExecutableCriteria
(
Objects
.
requireNonNull
(
template
.
getSessionFactory
()).
getCurrentSession
()).
setFirstResult
(
0
).
setMaxResults
(
1
).
uniqueResult
();
}
@Override
public
BigDecimal
selectBuyAmountByIdCard
(
String
idCard
,
UUID
fromString
)
{
KClass
bean
=
Amino
.
getStaticMetadataContext
().
getBean
(
RetailInfoConstant
.
DETAIL_ENTITY
,
KClass
.
class
);
DetachedCriteria
detachedCriteria
=
DetachedCriteria
.
forEntityName
(
bean
.
getName
());
detachedCriteria
.
createAlias
(
"master"
,
"master"
);
detachedCriteria
.
add
(
Restrictions
.
eq
(
"master.del"
,
false
));
detachedCriteria
.
add
(
Restrictions
.
eq
(
"master.idCard"
,
idCard
));
detachedCriteria
.
add
(
Restrictions
.
eq
(
"master.station.id"
,
fromString
));
return
(
BigDecimal
)
detachedCriteria
.
setProjection
(
Projections
.
sum
(
"purchaseAmount"
)).
getExecutableCriteria
(
Objects
.
requireNonNull
(
template
.
getSessionFactory
()).
getCurrentSession
()).
setFirstResult
(
0
).
setMaxResults
(
1
).
uniqueResult
();
}
@Override
@Override
public
UUID
create
(
KObject
kObject
)
{
public
UUID
create
(
KObject
kObject
)
{
KObject
staff
=
AminoContextHolder
.
getContext
().
getStaff
();
if
(
null
==
kObject
.
getUuid
(
"id"
)){
WarehouseUser
warehouseUser
=
WarehouseUserContextHolder
.
getContext
().
getWarehouseUser
();
kObject
.
set
(
"id"
,
UUID
.
randomUUID
());
if
(
null
==
kObject
.
getUuid
(
"id"
))
{
kObject
.
set
(
"id"
,
UUID
.
randomUUID
());
}
}
kObject
.
set
(
"station"
,
stationDao
.
load
(
kObject
.
get
(
"station"
).
getUuid
(
BaseConstants
.
ID
)));
kObject
.
set
(
"createUser"
,
warehouseUserDao
.
findById
(
warehouseUser
.
getId
()));
kObject
.
set
(
"regionalCompany"
,
dinasTypeDao
.
getCurrentLoginRegionalCompany
());
kObject
.
set
(
"regionalCompany"
,
dinasTypeDao
.
getCurrentLoginRegionalCompany
());
kObject
.
set
(
BaseConstants
.
CREATOR
,
staff
);
kObject
.
set
(
BaseConstants
.
CREATE_TIME
,
new
Date
());
kObject
.
set
(
BaseConstants
.
CREATE_TIME
,
new
Date
());
kObject
.
set
(
BaseConstants
.
DEL
,
false
);
kObject
.
set
(
BaseConstants
.
DEL
,
false
);
UUID
save
=
(
UUID
)
template
.
save
(
kObject
);
return
(
UUID
)
template
.
save
(
kObject
);
KObject
productions
=
kObject
.
get
(
"productionLines"
);
if
(
null
!=
productions
){
List
<
KObject
>
kObjects
=
productions
.
toList
();
for
(
KObject
object
:
kObjects
)
{
if
(
null
==
object
.
getUuid
(
"id"
)){
object
.
set
(
"id"
,
UUID
.
randomUUID
());
}
object
.
set
(
"retailInfo"
,
kObject
);
template
.
save
(
ProductionLineConstant
.
ENTITY
,
object
);
}
}
return
save
;
}
}
@Override
@Override
...
@@ -152,11 +167,12 @@ public class RetailInfoDaoImpl extends AbstractBaseDao implements RetailInfoDao,
...
@@ -152,11 +167,12 @@ public class RetailInfoDaoImpl extends AbstractBaseDao implements RetailInfoDao,
@Override
@Override
public
void
deleteById
(
UUID
id
)
{
public
void
deleteById
(
UUID
id
)
{
KObject
staff
=
AminoContextHolder
.
getContext
().
getStaff
();
WarehouseUser
warehouseUser
=
WarehouseUserContextHolder
.
getContext
().
getWarehouseUser
();
KObject
kobject
=
(
KObject
)
template
.
load
(
ENTITY
,
id
);
KObject
kobject
=
(
KObject
)
template
.
load
(
ENTITY
,
id
);
kobject
.
set
(
BaseConstants
.
MODIFY_TIME
,
new
Date
());
kobject
.
set
(
BaseConstants
.
MODIFY_TIME
,
new
Date
());
kobject
.
set
(
BaseConstants
.
MODIFIER
,
staff
);
kobject
.
set
(
"updateUser"
,
warehouseUser
);
kobject
.
set
(
BaseConstants
.
DEL
,
true
);
kobject
.
set
(
BaseConstants
.
DEL
,
true
);
kobject
.
set
(
BaseConstants
.
DISCARD
,
true
);
template
.
update
(
kobject
);
template
.
update
(
kobject
);
}
}
...
...
backend/xyst.dinas.biz/src/main/java/com/xyst/dinas/biz/internal/service/RetailInfoServiceImpl.java
View file @
337f46a0
...
@@ -2,12 +2,25 @@ package com.xyst.dinas.biz.internal.service;
...
@@ -2,12 +2,25 @@ package com.xyst.dinas.biz.internal.service;
import
com.beecode.bap.attachment.common.Page
;
import
com.beecode.bap.attachment.common.Page
;
import
com.beecode.bcp.type.KObject
;
import
com.beecode.bcp.type.KObject
;
import
com.beecode.bcp.type.json.JSONObjectUtils
;
import
com.beecode.inz.common.BaseConstants
;
import
com.xyst.dinas.biz.constant.RetailInfoConstant
;
import
com.xyst.dinas.biz.dao.DinasTypeDao
;
import
com.xyst.dinas.biz.dao.RetailInfoDao
;
import
com.xyst.dinas.biz.dao.RetailInfoDao
;
import
com.xyst.dinas.biz.processor.RetailInfoBuyAmountWarningCalculate
;
import
com.xyst.dinas.biz.processor.RetailInfoBuyCountWarningCalculate
;
import
com.xyst.dinas.biz.service.RetailInfoService
;
import
com.xyst.dinas.biz.service.RetailInfoService
;
import
com.xyst.dinas.biz.warn.BaseBusinessWarn
;
import
com.xyst.dinas.biz.warn.WarnSetting
;
import
com.xyst.dinas.biz.warn.WarnSettingEntity
;
import
com.xyst.dinas.biz.warn.WarnTargetTypeEnum
;
import
com.xyst.dinas.biz.warn.service.WarningService
;
import
org.apache.commons.collections.CollectionUtils
;
import
org.apache.commons.collections.CollectionUtils
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.transaction.annotation.Transactional
;
import
org.springframework.transaction.annotation.Transactional
;
import
java.math.BigDecimal
;
import
java.util.HashMap
;
import
java.util.List
;
import
java.util.List
;
import
java.util.UUID
;
import
java.util.UUID
;
...
@@ -17,6 +30,11 @@ public class RetailInfoServiceImpl implements RetailInfoService {
...
@@ -17,6 +30,11 @@ public class RetailInfoServiceImpl implements RetailInfoService {
@Autowired
@Autowired
private
RetailInfoDao
retailInfoDao
;
private
RetailInfoDao
retailInfoDao
;
@Autowired
private
DinasTypeDao
dinasTypeDao
;
@Autowired
private
WarningService
warningService
;
@Override
@Override
public
Page
<
KObject
>
queryByPaging
(
Page
<
KObject
>
page
,
Integer
retailInfoStatus
)
throws
Exception
{
public
Page
<
KObject
>
queryByPaging
(
Page
<
KObject
>
page
,
Integer
retailInfoStatus
)
throws
Exception
{
if
(
page
.
getPageNo
()==
0
||
page
.
getPageSize
()==
0
)
{
if
(
page
.
getPageNo
()==
0
||
page
.
getPageSize
()==
0
)
{
...
@@ -25,13 +43,88 @@ public class RetailInfoServiceImpl implements RetailInfoService {
...
@@ -25,13 +43,88 @@ public class RetailInfoServiceImpl implements RetailInfoService {
return
retailInfoDao
.
listRetailInfoInfoPaging
(
page
,
retailInfoStatus
);
return
retailInfoDao
.
listRetailInfoInfoPaging
(
page
,
retailInfoStatus
);
}
}
@Override
@Override
public
List
<
KObject
>
listRetailInfoInfoByRegionalCompany
(
UUID
regionalCompanyId
)
throws
Exception
{
public
List
<
KObject
>
listRetailInfoInfoByRegionalCompany
(
UUID
regionalCompanyId
)
{
return
retailInfoDao
.
listRetailInfoInfoByRegionalCompany
(
regionalCompanyId
);
return
retailInfoDao
.
listRetailInfoInfoByRegionalCompany
(
regionalCompanyId
);
}
}
@Override
@Override
public
UUID
addRetailInfo
(
KObject
kObject
)
{
public
UUID
addRetailInfo
(
KObject
newKobject
)
{
return
retailInfoDao
.
create
(
kObject
);
UUID
uuid
=
retailInfoDao
.
create
(
newKobject
);
setDetail
(
newKobject
,
uuid
);
//新增散户信息触发预警设置和预警记录
String
newRetailInfoName
=
newKobject
.
getString
(
"retailInfoName"
);
String
newIdCard
=
newKobject
.
getString
(
"idCard"
);
UUID
newStation
=
newKobject
.
get
(
"station"
).
getUuid
(
BaseConstants
.
ID
);
setWarnInfo
(
newKobject
,
uuid
,
newRetailInfoName
,
newIdCard
,
newStation
);
return
uuid
;
}
private
void
setWarnInfo
(
KObject
newKobject
,
UUID
uuid
,
String
retailInfoName
,
String
idCard
,
UUID
station
)
{
//购买次数预警
//查询场站是否有对应的预警模板
WarnSetting
templateCount
=
warningService
.
queryOneWarnSettingsByMemoAndType
(
RetailInfoConstant
.
RETAIL_INFO_WARN_BUY_COUNT
,
station
.
toString
(),
"template"
);
if
(
templateCount
==
null
){
templateCount
=
setWarningSettingEntity
(
newKobject
,
UUID
.
randomUUID
(),
RetailInfoConstant
.
RETAIL_INFO_WARN_BUY_COUNT
,
RetailInfoConstant
.
RETAIL_INFO_BUY_COUNT_WARNING_CALCULATOR
,
"0"
,
true
,
false
);
}
WarnSetting
warnSetting
=
warningService
.
queryOneWarnSettingsByMemoAndType
(
RetailInfoConstant
.
RETAIL_INFO_WARN_BUY_COUNT
,
idCard
,
station
.
toString
());
if
(
warnSetting
!=
null
)
{
BaseBusinessWarn
warn
=
warningService
.
createWarn
(
warnSetting
.
getSettingId
());
warn
.
setWarningCalculate
(
new
RetailInfoBuyCountWarningCalculate
(
retailInfoName
,
idCard
,
station
,
selectBuyCountByIdCard
(
idCard
,
station
)));
warn
.
warn
(
false
);
}
else
{
setWarningSettingEntity
(
newKobject
,
uuid
,
RetailInfoConstant
.
RETAIL_INFO_WARN_BUY_COUNT
,
RetailInfoConstant
.
RETAIL_INFO_BUY_COUNT_WARNING_CALCULATOR
,
templateCount
.
getMax
(),
false
,
true
);
}
//购买重量预警
//查询场站是否有对应的预警模板
templateCount
=
warningService
.
queryOneWarnSettingsByMemoAndType
(
RetailInfoConstant
.
RETAIL_INFO_WARN_BUY_AMOUNT
,
station
.
toString
(),
"template"
);
if
(
templateCount
==
null
){
templateCount
=
setWarningSettingEntity
(
newKobject
,
UUID
.
randomUUID
(),
RetailInfoConstant
.
RETAIL_INFO_WARN_BUY_AMOUNT
,
RetailInfoConstant
.
RETAIL_INFO_BUY_AMOUNT_WARNING_CALCULATOR
,
"0"
,
true
,
false
);
}
warnSetting
=
warningService
.
queryOneWarnSettingsByMemoAndType
(
RetailInfoConstant
.
RETAIL_INFO_WARN_BUY_AMOUNT
,
idCard
,
station
.
toString
());
if
(
warnSetting
!=
null
)
{
BaseBusinessWarn
warn
=
warningService
.
createWarn
(
warnSetting
.
getSettingId
());
warn
.
setWarningCalculate
(
new
RetailInfoBuyAmountWarningCalculate
(
retailInfoName
,
idCard
,
selectBuyAmountByIdCard
(
idCard
,
station
).
doubleValue
()));
warn
.
warn
(
false
);
}
else
{
setWarningSettingEntity
(
newKobject
,
uuid
,
RetailInfoConstant
.
RETAIL_INFO_WARN_BUY_AMOUNT
,
RetailInfoConstant
.
RETAIL_INFO_BUY_AMOUNT_WARNING_CALCULATOR
,
templateCount
.
getMax
(),
false
,
true
);
}
}
private
WarnSettingEntity
setWarningSettingEntity
(
KObject
kObject
,
UUID
uuid
,
String
target
,
String
warnCalculator
,
String
max
,
boolean
isTemplate
,
boolean
isOpen
)
{
WarnSettingEntity
warnSettingEntity
=
new
WarnSettingEntity
();
warnSettingEntity
.
setBillType
(
RetailInfoConstant
.
RETAIL_INFO_WARN_BILL_TYPE
);
warnSettingEntity
.
setBillId
(
uuid
);
warnSettingEntity
.
setTarget
(
target
);
warnSettingEntity
.
setMax
(
max
);
warnSettingEntity
.
setTargetType
(
WarnTargetTypeEnum
.
INT_TYPE
.
name
());
warnSettingEntity
.
setOpen
(
isOpen
);
HashMap
<
String
,
String
>
stringStringHashMap
=
new
HashMap
<>();
stringStringHashMap
.
put
(
"stationId"
,
kObject
.
get
(
"station"
).
getString
(
BaseConstants
.
ID
));
if
(
isTemplate
){
stringStringHashMap
.
put
(
"template"
,
"template"
);
}
else
{
stringStringHashMap
.
put
(
"idCard"
,
kObject
.
getString
(
"idCard"
));
stringStringHashMap
.
put
(
"retailInfoName"
,
kObject
.
getString
(
"retailInfoName"
));
}
warnSettingEntity
.
setMemo
(
JSONObjectUtils
.
toJson
(
stringStringHashMap
).
toString
());
warnSettingEntity
.
setWarnCalculator
(
warnCalculator
);
warningService
.
insertWarnSettingToIsNotice
(
warnSettingEntity
,
false
);
return
warnSettingEntity
;
}
private
void
setDetail
(
KObject
kObject
,
UUID
uuid
)
{
KObject
kObject1
=
kObject
.
get
(
"dinasTypeDetails"
);
List
<
KObject
>
kObjects
=
kObject1
.
toList
();
for
(
KObject
object
:
kObjects
)
{
object
.
set
(
"master"
,
retailInfoDao
.
load
(
uuid
));
object
.
set
(
"dinasType"
,
dinasTypeDao
.
load
(
object
.
get
(
"dinasType"
).
getUuid
(
BaseConstants
.
ID
)));
object
.
set
(
BaseConstants
.
ID
,
UUID
.
randomUUID
());
retailInfoDao
.
saveOrUpdate
(
object
);
}
}
}
@Override
@Override
...
@@ -54,9 +147,27 @@ public class RetailInfoServiceImpl implements RetailInfoService {
...
@@ -54,9 +147,27 @@ public class RetailInfoServiceImpl implements RetailInfoService {
}
}
@Override
@Override
public
void
update
(
KObject
kobject
)
{
public
void
update
(
KObject
newKobject
)
{
UUID
uuid
=
newKobject
.
getUuid
(
BaseConstants
.
ID
);
KObject
oldKObject
=
retailInfoDao
.
load
(
uuid
);
retailInfoDao
.
modify
(
newKobject
,
oldKObject
);
retailInfoDao
.
deleteDetailByMasterId
(
uuid
);
setDetail
(
newKobject
,
uuid
);
//新增散户信息触发预警设置和预警记录
String
newRetailInfoName
=
newKobject
.
getString
(
"retailInfoName"
);
String
newIdCard
=
newKobject
.
getString
(
"idCard"
);
UUID
newStation
=
newKobject
.
get
(
"station"
).
getUuid
(
BaseConstants
.
ID
);
String
oldRetailInfoName
=
oldKObject
.
getString
(
"retailInfoName"
);
String
oldIdCard
=
oldKObject
.
getString
(
"idCard"
);
UUID
oldStation
=
oldKObject
.
get
(
"station"
).
getUuid
(
BaseConstants
.
ID
);
retailInfoDao
.
modify
(
kobject
);
//购买预警
setWarnInfo
(
newKobject
,
uuid
,
newRetailInfoName
,
newIdCard
,
newStation
);
if
(!
oldIdCard
.
equals
(
newIdCard
)){
//旧的购买预警
setWarnInfo
(
oldKObject
,
uuid
,
oldRetailInfoName
,
oldIdCard
,
oldStation
);
}
}
}
@Override
@Override
...
@@ -64,5 +175,16 @@ public class RetailInfoServiceImpl implements RetailInfoService {
...
@@ -64,5 +175,16 @@ public class RetailInfoServiceImpl implements RetailInfoService {
retailInfoDao
.
deleteById
(
id
);
retailInfoDao
.
deleteById
(
id
);
}
}
@Override
public
Long
selectBuyCountByIdCard
(
String
idCard
,
UUID
uuid
)
{
return
retailInfoDao
.
selectBuyCountByIdCard
(
idCard
,
uuid
);
}
@Override
public
BigDecimal
selectBuyAmountByIdCard
(
String
idCard
,
UUID
fromString
)
{
return
retailInfoDao
.
selectBuyAmountByIdCard
(
idCard
,
fromString
);
}
}
}
backend/xyst.dinas.biz/src/main/java/com/xyst/dinas/biz/processor/RetailInfoBuyAmountWarningCalculate.java
0 → 100644
View file @
337f46a0
package
com
.
xyst
.
dinas
.
biz
.
processor
;
import
com.xyst.dinas.biz.warn.IWarningCalculator
;
import
com.xyst.dinas.biz.warn.WarnSetting
;
import
java.util.UUID
;
/**
* retail散客购买重量(总量)预警
*
* @author
* @date 2021年4月1日
*/
public
class
RetailInfoBuyAmountWarningCalculate
implements
IWarningCalculator
{
private
String
warnMessage
;
private
final
String
retailInfoName
;
private
final
String
idCard
;
private
final
double
buyAmount
;
/**
* 散客购买次数预警
* @param buyAmount 购买次数
*/
public
RetailInfoBuyAmountWarningCalculate
(
String
retailInfoName
,
String
idCard
,
double
buyAmount
)
{
this
.
retailInfoName
=
retailInfoName
;
this
.
idCard
=
idCard
;
this
.
buyAmount
=
buyAmount
;
}
@Override
public
boolean
isWarning
(
WarnSetting
warnSetting
)
{
String
max
=
warnSetting
.
getMax
();
String
target
=
warnSetting
.
getTarget
();
if
(
max
==
null
||
max
.
trim
().
length
()==
0
)
{
return
false
;
}
//业务数据与设置的阀值做比较,计算是否预警
if
(
buyAmount
>=
Integer
.
parseInt
(
max
))
{
warnMessage
=
"["
+
target
+
"]"
+
retailInfoName
+
":"
+
idCard
+
"购买总量:"
+
buyAmount
+
",超出预警值"
+
max
;
return
true
;
}
return
false
;
}
@Override
public
String
warnMessage
()
{
return
warnMessage
;
}
@Override
public
String
getActualValue
()
{
return
buyAmount
+
""
;
}
}
backend/xyst.dinas.biz/src/main/java/com/xyst/dinas/biz/processor/RetailInfoBuyAmountWarningCalculator.java
0 → 100644
View file @
337f46a0
package
com
.
xyst
.
dinas
.
biz
.
processor
;
import
com.beecode.bcp.type.json.JSONObjectUtils
;
import
com.xyst.dinas.biz.service.RetailInfoService
;
import
com.xyst.dinas.biz.warn.IWarningCalculator
;
import
com.xyst.dinas.biz.warn.WarnSetting
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
java.util.Map
;
import
java.util.UUID
;
/**
* retail散客购买重量预警
*
* @author
* @date 2021年4月23日
*/
public
class
RetailInfoBuyAmountWarningCalculator
implements
IWarningCalculator
{
/**重量
*
*/
private
double
buyAmount
;
private
String
message
;
@Autowired
private
RetailInfoService
retailInfoService
;
@Override
public
boolean
isWarning
(
WarnSetting
warnSetting
)
{
String
max
=
warnSetting
.
getMax
();
String
target
=
warnSetting
.
getTarget
();
if
(
max
==
null
||
max
.
trim
().
length
()==
0
)
{
return
false
;
}
Map
<
String
,
Object
>
stringObjectMap
=
JSONObjectUtils
.
toMap
(
warnSetting
.
getMemo
());
if
(!
stringObjectMap
.
containsKey
(
"idCard"
)){
return
false
;
}
Object
idCard
=
stringObjectMap
.
get
(
"idCard"
);
Object
stationId
=
stringObjectMap
.
get
(
"stationId"
);
Object
retailInfoName
=
stringObjectMap
.
get
(
"retailInfoName"
);
this
.
buyAmount
=
retailInfoService
.
selectBuyAmountByIdCard
(
idCard
.
toString
(),
UUID
.
fromString
(
stationId
.
toString
())).
doubleValue
();
//业务数据与设置的阀值做比较,计算是否预警
double
i
=
Double
.
parseDouble
(
max
);
if
(
i
>
0
&&
buyAmount
>=
i
)
{
message
=
"["
+
target
+
"]"
+
retailInfoName
+
":"
+
idCard
+
",购买总量:"
+
buyAmount
+
",超出预警值"
+
max
;
return
true
;
}
return
false
;
}
/**
* 预警消息
*
* @return
*/
@Override
public
String
warnMessage
()
{
return
this
.
message
;
}
/**
* 实际值
*
* @return
*/
@Override
public
String
getActualValue
()
{
return
this
.
buyAmount
+
""
;
}
}
backend/xyst.dinas.biz/src/main/java/com/xyst/dinas/biz/processor/RetailInfoBuyCountWarningCalculate.java
0 → 100644
View file @
337f46a0
package
com
.
xyst
.
dinas
.
biz
.
processor
;
import
com.xyst.dinas.biz.warn.IWarningCalculator
;
import
com.xyst.dinas.biz.warn.WarnSetting
;
import
java.util.UUID
;
/**
* retail散客购买次数预警
*
* @author
* @date 2021年4月1日
*/
public
class
RetailInfoBuyCountWarningCalculate
implements
IWarningCalculator
{
private
String
warnMessage
;
private
final
String
retailInfoName
;
private
final
String
idCard
;
private
final
long
buyCount
;
/**
* 散客购买次数预警
* @param buyCount 购买次数
*/
public
RetailInfoBuyCountWarningCalculate
(
String
retailInfoName
,
String
idCard
,
UUID
stationId
,
Long
buyCount
)
{
this
.
retailInfoName
=
retailInfoName
;
this
.
idCard
=
idCard
;
this
.
buyCount
=
buyCount
;
}
@Override
public
boolean
isWarning
(
WarnSetting
warnSetting
)
{
String
max
=
warnSetting
.
getMax
();
String
target
=
warnSetting
.
getTarget
();
if
(
max
==
null
||
max
.
trim
().
length
()==
0
)
{
return
false
;
}
//业务数据与设置的阀值做比较,计算是否预警
int
i
=
(
int
)
Double
.
parseDouble
(
max
);
if
(
i
>
0
&&
buyCount
>=
i
)
{
warnMessage
=
"["
+
target
+
"]"
+
retailInfoName
+
":"
+
idCard
+
"购买次数"
+
buyCount
+
",超出预警值"
+
max
;
return
true
;
}
return
false
;
}
@Override
public
String
warnMessage
()
{
return
warnMessage
;
}
@Override
public
String
getActualValue
()
{
return
buyCount
+
""
;
}
}
backend/xyst.dinas.biz/src/main/java/com/xyst/dinas/biz/processor/RetailInfoBuyCountWarningCalculator.java
0 → 100644
View file @
337f46a0
package
com
.
xyst
.
dinas
.
biz
.
processor
;
import
com.beecode.bcp.type.json.JSONObjectUtils
;
import
com.xyst.dinas.biz.service.RetailInfoService
;
import
com.xyst.dinas.biz.warn.IWarningCalculator
;
import
com.xyst.dinas.biz.warn.WarnSetting
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
java.util.Map
;
import
java.util.UUID
;
/**
* retail散客购买次数预警
*
* @author
* @date 2021年4月23日
*/
public
class
RetailInfoBuyCountWarningCalculator
implements
IWarningCalculator
{
/**
* 购买次数
*/
private
long
buyCount
;
private
String
message
;
@Autowired
private
RetailInfoService
retailInfoService
;
@Override
public
boolean
isWarning
(
WarnSetting
warnSetting
)
{
String
max
=
warnSetting
.
getMax
();
String
target
=
warnSetting
.
getTarget
();
if
(
max
==
null
||
max
.
trim
().
length
()==
0
)
{
return
false
;
}
Map
<
String
,
Object
>
stringObjectMap
=
JSONObjectUtils
.
toMap
(
warnSetting
.
getMemo
());
if
(!
stringObjectMap
.
containsKey
(
"idCard"
)){
return
false
;
}
Object
idCard
=
stringObjectMap
.
get
(
"idCard"
);
Object
stationId
=
stringObjectMap
.
get
(
"stationId"
);
Object
retailInfoName
=
stringObjectMap
.
get
(
"retailInfoName"
);
this
.
buyCount
=
retailInfoService
.
selectBuyCountByIdCard
(
idCard
.
toString
(),
UUID
.
fromString
(
stationId
.
toString
()));
//业务数据与设置的阀值做比较,计算是否预警
int
i
=
(
int
)
Double
.
parseDouble
(
max
);
if
(
i
>
0
&&
buyCount
>=
i
)
{
message
=
"["
+
target
+
"]"
+
retailInfoName
+
":"
+
idCard
+
"购买次数"
+
buyCount
+
",超出预警值"
+
max
;
return
true
;
}
return
false
;
}
/**
* 预警消息
*
* @return
*/
@Override
public
String
warnMessage
()
{
return
this
.
message
;
}
/**
* 实际值
*
* @return
*/
@Override
public
String
getActualValue
()
{
return
this
.
buyCount
+
""
;
}
}
backend/xyst.dinas.biz/src/main/java/com/xyst/dinas/biz/service/RetailInfoService.java
View file @
337f46a0
...
@@ -3,6 +3,7 @@ package com.xyst.dinas.biz.service;
...
@@ -3,6 +3,7 @@ package com.xyst.dinas.biz.service;
import
com.beecode.bap.attachment.common.Page
;
import
com.beecode.bap.attachment.common.Page
;
import
com.beecode.bcp.type.KObject
;
import
com.beecode.bcp.type.KObject
;
import
java.math.BigDecimal
;
import
java.util.List
;
import
java.util.List
;
import
java.util.UUID
;
import
java.util.UUID
;
...
@@ -23,4 +24,8 @@ public interface RetailInfoService {
...
@@ -23,4 +24,8 @@ public interface RetailInfoService {
void
update
(
KObject
kobject
);
void
update
(
KObject
kobject
);
void
deleteById
(
UUID
id
);
void
deleteById
(
UUID
id
);
Long
selectBuyCountByIdCard
(
String
toString
,
UUID
uuid
);
BigDecimal
selectBuyAmountByIdCard
(
String
idCard
,
UUID
fromString
);
}
}
backend/xyst.dinas.biz/src/main/java/com/xyst/dinas/biz/warn/WarningServiceImpl.java
View file @
337f46a0
...
@@ -3,6 +3,7 @@ package com.xyst.dinas.biz.warn;
...
@@ -3,6 +3,7 @@ package com.xyst.dinas.biz.warn;
import
java.time.LocalDateTime
;
import
java.time.LocalDateTime
;
import
java.util.*
;
import
java.util.*
;
import
com.xyst.dinas.biz.constant.RetailInfoConstant
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.lang.Nullable
;
import
org.springframework.lang.Nullable
;
import
org.springframework.transaction.annotation.Transactional
;
import
org.springframework.transaction.annotation.Transactional
;
...
@@ -20,141 +21,148 @@ import com.xyst.dinas.biz.warn.service.WarningService;
...
@@ -20,141 +21,148 @@ import com.xyst.dinas.biz.warn.service.WarningService;
import
com.xyst.dinas.biz.web.request.WarnSettingReq
;
import
com.xyst.dinas.biz.web.request.WarnSettingReq
;
@Transactional
@Transactional
public
class
WarningServiceImpl
implements
WarningService
{
public
class
WarningServiceImpl
implements
WarningService
{
@Autowired
@Autowired
private
WarnSettingDao
warnSettingDao
;
private
WarnSettingDao
warnSettingDao
;
/**
/**
* 新增预警设置<br/>
* 新增预警设置<br/>
* 自动触发预警
* 自动触发预警
*/
*/
@Override
@Override
public
UUID
insertWarnSetting
(
WarnSetting
warnSetting
)
{
public
UUID
insertWarnSetting
(
WarnSetting
warnSetting
)
{
String
billType
=
warnSetting
.
getBillType
();
return
insertWarnSettingToIsNotice
(
warnSetting
,
true
);
String
warnCalculator
=
warnSetting
.
warnCalculator
();
}
Assert
.
notNull
(
billType
,
"The billType must not be null!"
);
Assert
.
notNull
(
warnCalculator
,
"The warnCalculator must not be null!"
);
@Override
KClass
type
=
Amino
.
getApplicationMetadataContext
().
getBean
(
WarnSettingConstant
.
ENTITY_WARNSETTING
,
KClass
.
class
);
public
UUID
insertWarnSettingToIsNotice
(
WarnSetting
warnSetting
,
boolean
isNotice
)
{
KObject
setting
=
type
.
newInstance
();
String
billType
=
warnSetting
.
getBillType
();
setting
.
set
(
WarnSettingConstant
.
billType
,
billType
);
String
warnCalculator
=
warnSetting
.
warnCalculator
();
setting
.
set
(
WarnSettingConstant
.
billId
,
warnSetting
.
getBillId
());
Assert
.
notNull
(
billType
,
"The billType must not be null!"
);
setting
.
set
(
WarnSettingConstant
.
target
,
warnSetting
.
getTarget
());
Assert
.
notNull
(
warnCalculator
,
"The warnCalculator must not be null!"
);
setting
.
set
(
WarnSettingConstant
.
targetType
,
warnSetting
.
getTargetType
());
KClass
type
=
Amino
.
getApplicationMetadataContext
().
getBean
(
WarnSettingConstant
.
ENTITY_WARNSETTING
,
KClass
.
class
);
setting
.
set
(
WarnSettingConstant
.
min
,
warnSetting
.
getMin
());
KObject
setting
=
type
.
newInstance
();
setting
.
set
(
WarnSettingConstant
.
max
,
warnSetting
.
getMax
());
setting
.
set
(
WarnSettingConstant
.
billType
,
billType
);
setting
.
set
(
WarnSettingConstant
.
memo
,
warnSetting
.
getMemo
());
setting
.
set
(
WarnSettingConstant
.
billId
,
warnSetting
.
getBillId
());
setting
.
set
(
WarnSettingConstant
.
warnCalculator
,
warnCalculator
);
setting
.
set
(
WarnSettingConstant
.
target
,
warnSetting
.
getTarget
());
setting
.
set
(
WarnSettingConstant
.
isOpen
,
warnSetting
.
isOpen
()==
null
?
true
:
warnSetting
.
isOpen
());
setting
.
set
(
WarnSettingConstant
.
targetType
,
warnSetting
.
getTargetType
());
String
[]
personnel
=
warnSetting
.
getPersonnel
();
setting
.
set
(
WarnSettingConstant
.
min
,
warnSetting
.
getMin
());
if
(
personnel
!=
null
)
{
setting
.
set
(
WarnSettingConstant
.
max
,
warnSetting
.
getMax
());
String
personnelStr
=
UuidArrayToString
(
personnel
);
setting
.
set
(
WarnSettingConstant
.
memo
,
warnSetting
.
getMemo
());
setting
.
set
(
WarnSettingConstant
.
personnel
,
personnelStr
);
setting
.
set
(
WarnSettingConstant
.
warnCalculator
,
warnCalculator
);
}
setting
.
set
(
WarnSettingConstant
.
isOpen
,
warnSetting
.
isOpen
()
==
null
||
warnSetting
.
isOpen
());
setting
.
set
(
BaseConstants
.
CREATE_TIME
,
LocalDateTime
.
now
());
String
[]
personnel
=
warnSetting
.
getPersonnel
();
setting
.
set
(
BaseConstants
.
DEL
,
false
);
if
(
personnel
!=
null
)
{
setting
.
set
(
BaseConstants
.
DISCARD
,
false
);
String
personnelStr
=
UuidArrayToString
(
personnel
);
setting
.
set
(
WarnSettingConstant
.
personnel
,
personnelStr
);
}
setting
.
set
(
BaseConstants
.
CREATE_TIME
,
LocalDateTime
.
now
());
setting
.
set
(
BaseConstants
.
DEL
,
false
);
setting
.
set
(
BaseConstants
.
DISCARD
,
false
);
UUID
warSettingId
=
warnSettingDao
.
create
(
setting
);
UUID
warSettingId
=
warnSettingDao
.
create
(
setting
);
//新增后触发预警
//新增后触发预警
BaseBusinessWarn
baseBusinessWarn
=
new
BaseBusinessWarn
(
warSettingId
);
BaseBusinessWarn
baseBusinessWarn
=
new
BaseBusinessWarn
(
warSettingId
);
baseBusinessWarn
.
warn
(
);
baseBusinessWarn
.
warn
(
isNotice
);
return
warSettingId
;
return
warSettingId
;
}
}
/**
/**
* 更新预警设置<br/>
* 更新预警设置<br/>
* 自动触发预警
* 自动触发预警
*/
*/
@Override
@Override
public
void
updateWarnSetting
(
WarnSettingReq
warnSetting
)
{
public
void
updateWarnSetting
(
WarnSettingReq
warnSetting
)
{
UUID
warSettingId
=
warnSetting
.
getId
();
UUID
warSettingId
=
warnSetting
.
getId
();
Assert
.
notNull
(
warSettingId
,
"The warSettingId must not be null"
);
Assert
.
notNull
(
warSettingId
,
"The warSettingId must not be null"
);
KObject
warSettingIdObj
=
warnSettingDao
.
queryWarnSettingById
(
warSettingId
);
KObject
warSettingIdObj
=
warnSettingDao
.
queryWarnSettingById
(
warSettingId
);
List
<
UUID
>
personnel
=
warnSetting
.
getPersonnel
();
List
<
UUID
>
personnel
=
warnSetting
.
getPersonnel
();
if
(
personnel
!=
null
)
{
if
(
personnel
!=
null
)
{
String
personnelStr
=
UuidListToString
(
personnel
);
String
personnelStr
=
UuidListToString
(
personnel
);
warSettingIdObj
.
set
(
"personnel"
,
personnelStr
);
warSettingIdObj
.
set
(
"personnel"
,
personnelStr
);
}
}
String
min
=
warnSetting
.
getMin
();
String
min
=
warnSetting
.
getMin
();
if
(
min
!=
null
)
warSettingIdObj
.
set
(
WarnSettingConstant
.
min
,
min
);
if
(
min
!=
null
)
warSettingIdObj
.
set
(
WarnSettingConstant
.
min
,
min
);
String
max
=
warnSetting
.
getMax
();
String
max
=
warnSetting
.
getMax
();
if
(
max
!=
null
)
warSettingIdObj
.
set
(
WarnSettingConstant
.
max
,
max
);
if
(
max
!=
null
)
warSettingIdObj
.
set
(
WarnSettingConstant
.
max
,
max
);
Boolean
isOpen
=
warnSetting
.
isOpen
();
Boolean
isOpen
=
warnSetting
.
isOpen
();
if
(
isOpen
!=
null
)
warSettingIdObj
.
set
(
WarnSettingConstant
.
isOpen
,
isOpen
);
if
(
isOpen
!=
null
)
warSettingIdObj
.
set
(
WarnSettingConstant
.
isOpen
,
isOpen
);
warnSettingDao
.
update
(
warSettingIdObj
);
warnSettingDao
.
update
(
warSettingIdObj
);
//修改后触发预警
//修改后触发预警
BaseBusinessWarn
baseBusinessWarn
=
new
BaseBusinessWarn
(
warSettingId
);
BaseBusinessWarn
baseBusinessWarn
=
new
BaseBusinessWarn
(
warSettingId
);
baseBusinessWarn
.
warn
();
baseBusinessWarn
.
warn
();
}
}
/**
/**
* 新增预警执行记录
* 新增预警执行记录
* @param warnExeRecord
*
* @return
* @param warnExeRecord
*/
* @return
@Override
*/
@Override
public
UUID
insertWarnExe
(
WarnExeRecord
warnExeRecord
)
{
public
UUID
insertWarnExe
(
WarnExeRecord
warnExeRecord
)
{
KClass
type
=
Amino
.
getApplicationMetadataContext
().
getBean
(
WarnSettingConstant
.
ENTITY_WARNINGEXE
,
KClass
.
class
);
KClass
type
=
Amino
.
getApplicationMetadataContext
().
getBean
(
WarnSettingConstant
.
ENTITY_WARNINGEXE
,
KClass
.
class
);
JsonNode
json
=
JSONObjectUtils
.
toJson
(
warnExeRecord
);
JsonNode
json
=
JSONObjectUtils
.
toJson
(
warnExeRecord
);
KObject
object
=
JSONObjectUtils
.
toObject
(
json
,
type
);
KObject
object
=
JSONObjectUtils
.
toObject
(
json
,
type
);
object
.
set
(
WarnSettingConstant
.
START_TIME
,
warnExeRecord
.
getStartTime
());
object
.
set
(
WarnSettingConstant
.
START_TIME
,
warnExeRecord
.
getStartTime
());
object
.
set
(
WarnSettingConstant
.
RECENTLY_TIME
,
warnExeRecord
.
getRecentlyTime
());
object
.
set
(
WarnSettingConstant
.
RECENTLY_TIME
,
warnExeRecord
.
getRecentlyTime
());
UUID
warnSettingId
=
warnExeRecord
.
getWarnSettingId
();
UUID
warnSettingId
=
warnExeRecord
.
getWarnSettingId
();
KObject
warnSettingObj
=
warnSettingDao
.
queryWarnSettingById
(
warnSettingId
);
KObject
warnSettingObj
=
warnSettingDao
.
queryWarnSettingById
(
warnSettingId
);
object
.
set
(
WarnSettingConstant
.
WARN_SETTING
,
warnSettingObj
);
object
.
set
(
WarnSettingConstant
.
WARN_SETTING
,
warnSettingObj
);
object
.
set
(
WarnSettingConstant
.
WARN_STATE
,
warnExeRecord
.
getWarnState
());
object
.
set
(
WarnSettingConstant
.
WARN_STATE
,
warnExeRecord
.
getWarnState
());
object
.
set
(
WarnSettingConstant
.
ACTUAL_VALUE
,
warnExeRecord
.
getActualValue
());
object
.
set
(
WarnSettingConstant
.
ACTUAL_VALUE
,
warnExeRecord
.
getActualValue
());
return
warnSettingDao
.
create
(
object
);
return
warnSettingDao
.
create
(
object
);
}
}
@Override
@Override
public
void
updateWarnExe
(
WarnExeRecord
warnExeRecord
)
{
public
void
updateWarnExe
(
WarnExeRecord
warnExeRecord
)
{
KObject
object
=
warnSettingDao
.
queryWarningExeById
(
warnExeRecord
.
getId
());
KObject
object
=
warnSettingDao
.
queryWarningExeById
(
warnExeRecord
.
getId
());
if
(
warnExeRecord
.
getRecentlyTime
()!=
null
)
object
.
set
(
"recentlyTime"
,
warnExeRecord
.
getRecentlyTime
());
if
(
warnExeRecord
.
getRecentlyTime
()
!=
null
)
object
.
set
(
"recentlyTime"
,
warnExeRecord
.
getRecentlyTime
());
if
(
warnExeRecord
.
getEndTime
()!=
null
)
object
.
set
(
"endTime"
,
warnExeRecord
.
getEndTime
());
if
(
warnExeRecord
.
getEndTime
()
!=
null
)
object
.
set
(
"endTime"
,
warnExeRecord
.
getEndTime
());
if
(
warnExeRecord
.
getWarnState
()!=
null
)
object
.
set
(
"warnState"
,
warnExeRecord
.
getWarnState
());
if
(
warnExeRecord
.
getWarnState
()
!=
null
)
object
.
set
(
"warnState"
,
warnExeRecord
.
getWarnState
());
if
(
warnExeRecord
.
getActualValue
()!=
null
)
object
.
set
(
"actualValue"
,
warnExeRecord
.
getActualValue
());
if
(
warnExeRecord
.
getActualValue
()
!=
null
)
object
.
set
(
"actualValue"
,
warnExeRecord
.
getActualValue
());
warnSettingDao
.
update
(
object
);
warnSettingDao
.
update
(
object
);
}
}
/**
/**
* 结束一条预警设置的预警执行记录
* 结束一条预警设置的预警执行记录
* @param warnSettingId
*
*/
* @param warnSettingId
*/
@Override
@Override
public
void
endWarnStateBySettingId
(
UUID
warnSettingId
)
{
public
void
endWarnStateBySettingId
(
UUID
warnSettingId
)
{
KObject
warnExeRecord
=
warnSettingDao
.
queryWarnExeRecordBySettingId
(
warnSettingId
);
KObject
warnExeRecord
=
warnSettingDao
.
queryWarnExeRecordBySettingId
(
warnSettingId
);
warnSettingDao
.
endWarnRecordState
(
warnExeRecord
);
warnSettingDao
.
endWarnRecordState
(
warnExeRecord
);
}
}
@Override
@Override
public
WarnSetting
getWarnSetting
(
UUID
warnSettingId
)
{
public
WarnSetting
getWarnSetting
(
UUID
warnSettingId
)
{
return
warnSettingDao
.
getWarnSetting
(
warnSettingId
);
return
warnSettingDao
.
getWarnSetting
(
warnSettingId
);
}
}
@Override
@Override
public
WarnSetting
getWarnSetting
(
String
billType
,
UUID
billId
,
String
target
)
{
public
WarnSetting
getWarnSetting
(
String
billType
,
UUID
billId
,
String
target
)
{
return
warnSettingDao
.
getWarnSetting
(
billType
,
billId
,
target
);
return
warnSettingDao
.
getWarnSetting
(
billType
,
billId
,
target
);
}
}
public
List
<
KObject
>
queryWarnSettings
(
String
billType
,
@Nullable
UUID
billId
,
@Nullable
String
target
)
{
public
List
<
KObject
>
queryWarnSettings
(
String
billType
,
@Nullable
UUID
billId
,
@Nullable
String
target
)
{
return
warnSettingDao
.
queryWarnSettings
(
billType
,
billId
,
target
);
return
warnSettingDao
.
queryWarnSettings
(
billType
,
billId
,
target
);
}
}
@Override
@Override
public
WarnExeRecord
queryWarnExeRecord
(
UUID
warnSettingId
)
{
public
WarnExeRecord
queryWarnExeRecord
(
UUID
warnSettingId
)
{
return
warnSettingDao
.
queryWarnExeRecord
(
warnSettingId
);
return
warnSettingDao
.
queryWarnExeRecord
(
warnSettingId
);
}
}
@Override
@Override
public
List
<
WarnExeRecord
>
queryWarnExeRecords
(
UUID
warnSettingId
)
{
public
List
<
WarnExeRecord
>
queryWarnExeRecords
(
UUID
warnSettingId
)
{
return
null
;
return
null
;
}
}
@Override
@Override
public
void
ignoreWarnExeRecord
(
UUID
id
)
{
public
void
ignoreWarnExeRecord
(
UUID
id
)
{
...
@@ -165,15 +173,15 @@ public class WarningServiceImpl implements WarningService{
...
@@ -165,15 +173,15 @@ public class WarningServiceImpl implements WarningService{
@Override
@Override
public
HashMap
<
String
,
Object
>
warnRecodeGroupInfo
(
List
<
UUID
>
regionalCompanyIds
,
List
<
String
>
targets
)
{
public
HashMap
<
String
,
Object
>
warnRecodeGroupInfo
(
List
<
UUID
>
regionalCompanyIds
,
List
<
String
>
targets
)
{
return
warnSettingDao
.
warnRecodeGroupInfo
(
regionalCompanyIds
,
targets
);
return
warnSettingDao
.
warnRecodeGroupInfo
(
regionalCompanyIds
,
targets
);
}
}
@Override
@Override
public
KObject
queryWarnSettingById
(
UUID
id
)
{
public
KObject
queryWarnSettingById
(
UUID
id
)
{
KObject
KObj
=
warnSettingDao
.
queryWarnSettingById
(
id
);
KObject
KObj
=
warnSettingDao
.
queryWarnSettingById
(
id
);
return
KObj
;
return
KObj
;
}
}
/**
/**
...
@@ -184,71 +192,72 @@ public class WarningServiceImpl implements WarningService{
...
@@ -184,71 +192,72 @@ public class WarningServiceImpl implements WarningService{
@Override
@Override
public
void
deleteWarnSetting
(
UUID
warnSettingId
)
{
public
void
deleteWarnSetting
(
UUID
warnSettingId
)
{
KObject
kObject
=
warnSettingDao
.
queryWarnSettingById
(
warnSettingId
);
KObject
kObject
=
warnSettingDao
.
queryWarnSettingById
(
warnSettingId
);
kObject
.
set
(
BaseConstants
.
DEL
,
true
);
kObject
.
set
(
BaseConstants
.
DEL
,
true
);
kObject
.
set
(
"discard"
,
true
);
kObject
.
set
(
"discard"
,
true
);
warnSettingDao
.
update
(
kObject
);
warnSettingDao
.
update
(
kObject
);
//结束预警执行记录
//结束预警执行记录
KObject
warnExeRecord
=
warnSettingDao
.
queryWarnExeRecordBySettingId
(
warnSettingId
);
KObject
warnExeRecord
=
warnSettingDao
.
queryWarnExeRecordBySettingId
(
warnSettingId
);
warnSettingDao
.
endWarnRecordState
(
warnExeRecord
);
warnSettingDao
.
endWarnRecordState
(
warnExeRecord
);
}
}
/**
/**
* 开启或关闭预警设置; 可重复开启或关闭
* 开启或关闭预警设置; 可重复开启或关闭
* @param warnSettingId 预警设置ID
*
* @param isOpen 开启true/关闭false
* @param warnSettingId 预警设置ID
* @param isOpen 开启true/关闭false
*/
*/
public
void
onOffWarnSetting
(
UUID
warnSettingId
,
boolean
isOpen
)
{
@Override
KObject
warnSetting
=
warnSettingDao
.
queryWarnSettingById
(
warnSettingId
);
public
void
onOffWarnSetting
(
UUID
warnSettingId
,
boolean
isOpen
)
{
boolean
isOpen2
=
warnSetting
.
getBoolean
(
WarnSettingConstant
.
isOpen
);
KObject
warnSetting
=
warnSettingDao
.
queryWarnSettingById
(
warnSettingId
);
if
(
isOpen
==
isOpen2
)
return
;
boolean
isOpen2
=
warnSetting
.
getBoolean
(
WarnSettingConstant
.
isOpen
);
warnSetting
.
set
(
WarnSettingConstant
.
isOpen
,
isOpen
);
if
(
isOpen
==
isOpen2
)
return
;
warnSettingDao
.
update
(
warnSetting
);
warnSetting
.
set
(
WarnSettingConstant
.
isOpen
,
isOpen
);
if
(
isOpen
)
{
warnSettingDao
.
update
(
warnSetting
);
//再次开启,触发预警
if
(
isOpen
)
{
BaseBusinessWarn
baseBusinessWarn
=
new
BaseBusinessWarn
(
warnSettingId
);
//再次开启,触发预警
baseBusinessWarn
.
warn
();
BaseBusinessWarn
baseBusinessWarn
=
new
BaseBusinessWarn
(
warnSettingId
);
}
else
{
baseBusinessWarn
.
warn
();
//关闭预警,结束预警执行记录
}
else
{
KObject
warnExeRecord
=
warnSettingDao
.
queryWarnExeRecordBySettingId
(
warnSettingId
);
//关闭预警,结束预警执行记录
warnSettingDao
.
endWarnRecordState
(
warnExeRecord
);
KObject
warnExeRecord
=
warnSettingDao
.
queryWarnExeRecordBySettingId
(
warnSettingId
);
}
warnSettingDao
.
endWarnRecordState
(
warnExeRecord
);
}
}
}
private
String
UuidListToString
(
List
<
UUID
>
uuids
)
{
private
String
UuidListToString
(
List
<
UUID
>
uuids
)
{
StringBuilder
str
=
new
StringBuilder
();
StringBuilder
str
=
new
StringBuilder
();
for
(
int
i
=
0
;
i
<
uuids
.
size
();
i
++)
{
for
(
int
i
=
0
;
i
<
uuids
.
size
();
i
++)
{
if
(
i
==
uuids
.
size
()
-
1
)
{
if
(
i
==
uuids
.
size
()
-
1
)
{
str
.
append
(
uuids
.
get
(
i
).
toString
());
str
.
append
(
uuids
.
get
(
i
).
toString
());
}
else
{
}
else
{
str
.
append
(
uuids
.
get
(
i
).
toString
()).
append
(
","
);
str
.
append
(
uuids
.
get
(
i
).
toString
()).
append
(
","
);
}
}
}
}
return
str
.
toString
();
return
str
.
toString
();
}
private
String
UuidArrayToString
(
String
[]
uuids
)
{
StringBuilder
str
=
new
StringBuilder
();
for
(
int
i
=
0
;
i
<
uuids
.
length
;
i
++)
{
if
(
i
==
uuids
.
length
-
1
)
{
str
.
append
(
uuids
[
i
].
toString
());
}
else
{
str
.
append
(
uuids
[
i
].
toString
()).
append
(
","
);
}
}
return
str
.
toString
();
}
}
@Override
private
String
UuidArrayToString
(
String
[]
uuids
)
{
public
BaseBusinessWarn
createWarn
(
String
billType
,
UUID
billId
,
String
target
)
{
StringBuilder
str
=
new
StringBuilder
();
return
new
BaseBusinessWarn
(
billType
,
billId
,
target
);
for
(
int
i
=
0
;
i
<
uuids
.
length
;
i
++)
{
}
if
(
i
==
uuids
.
length
-
1
)
{
str
.
append
(
uuids
[
i
].
toString
());
}
else
{
str
.
append
(
uuids
[
i
].
toString
()).
append
(
","
);
}
}
return
str
.
toString
();
}
@Override
@Override
public
BaseBusinessWarn
createWarn
(
UUID
warnSettingId
)
{
public
BaseBusinessWarn
createWarn
(
String
billType
,
UUID
billId
,
String
target
)
{
return
new
BaseBusinessWarn
(
warnSettingId
);
return
new
BaseBusinessWarn
(
billType
,
billId
,
target
);
}
}
@Override
public
BaseBusinessWarn
createWarn
(
UUID
warnSettingId
)
{
return
new
BaseBusinessWarn
(
warnSettingId
);
}
@Override
@Override
...
@@ -266,4 +275,55 @@ public class WarningServiceImpl implements WarningService{
...
@@ -266,4 +275,55 @@ public class WarningServiceImpl implements WarningService{
return
new
ArrayList
<>(
strings
);
return
new
ArrayList
<>(
strings
);
}
}
@Override
public
WarnSetting
queryOneWarnSettingsByMemoAndType
(
String
target
,
String
...
memo
)
{
return
warnSettingDao
.
queryOneWarnSettingsByMemoAndType
(
target
,
memo
);
}
@Override
public
void
updateRetailInfoWarnSettingAllByTypeAndMemo
(
String
target
,
String
toString
,
Double
max
)
{
List
<?>
objects
=
warnSettingDao
.
queryWarnSettingsListByMemoAndType
(
target
,
toString
);
if
(
objects
.
size
()
<
1
)
{
String
warnCalculator
;
if
(
target
.
equals
(
RetailInfoConstant
.
RETAIL_INFO_WARN_BUY_AMOUNT
)){
warnCalculator
=
RetailInfoConstant
.
RETAIL_INFO_BUY_AMOUNT_WARNING_CALCULATOR
;
}
else
{
warnCalculator
=
RetailInfoConstant
.
RETAIL_INFO_BUY_COUNT_WARNING_CALCULATOR
;
}
setRetailInfoWarningSettingTemplateEntity
(
toString
,
UUID
.
randomUUID
(),
target
,
warnCalculator
,
max
);
}
for
(
Object
object
:
objects
)
{
KObject
object1
=
(
KObject
)
object
;
UUID
uuid
=
object1
.
getUuid
(
BaseConstants
.
ID
);
Assert
.
notNull
(
uuid
,
"The warSettingId must not be null"
);
KObject
warSettingIdObj
=
warnSettingDao
.
queryWarnSettingById
(
uuid
);
warSettingIdObj
.
set
(
WarnSettingConstant
.
max
,
max
);
warnSettingDao
.
update
(
warSettingIdObj
);
//修改后触发预警
BaseBusinessWarn
baseBusinessWarn
=
new
BaseBusinessWarn
(
uuid
);
baseBusinessWarn
.
warn
(
false
);
}
}
private
void
setRetailInfoWarningSettingTemplateEntity
(
String
stationId
,
UUID
billId
,
String
target
,
String
warnCalculator
,
Double
max
)
{
WarnSettingEntity
warnSettingEntity
=
new
WarnSettingEntity
();
warnSettingEntity
.
setBillType
(
RetailInfoConstant
.
RETAIL_INFO_WARN_BILL_TYPE
);
warnSettingEntity
.
setBillId
(
billId
);
warnSettingEntity
.
setTarget
(
target
);
if
(
target
.
equals
(
RetailInfoConstant
.
RETAIL_INFO_WARN_BUY_AMOUNT
)){
warnSettingEntity
.
setTargetType
(
WarnTargetTypeEnum
.
NUMBER_TYPE
.
name
());
}
else
if
(
target
.
equals
(
RetailInfoConstant
.
RETAIL_INFO_WARN_BUY_COUNT
)){
warnSettingEntity
.
setTargetType
(
WarnTargetTypeEnum
.
INT_TYPE
.
name
());
}
warnSettingEntity
.
setOpen
(
false
);
HashMap
<
String
,
String
>
stringStringHashMap
=
new
HashMap
<>();
stringStringHashMap
.
put
(
"stationId"
,
stationId
);
stringStringHashMap
.
put
(
"template"
,
"template"
);
warnSettingEntity
.
setMax
(
max
+
""
);
warnSettingEntity
.
setMemo
(
JSONObjectUtils
.
toJson
(
stringStringHashMap
).
toString
());
warnSettingEntity
.
setWarnCalculator
(
warnCalculator
);
insertWarnSettingToIsNotice
(
warnSettingEntity
,
false
);
}
}
}
backend/xyst.dinas.biz/src/main/java/com/xyst/dinas/biz/warn/dao/WarnSettingDao.java
View file @
337f46a0
...
@@ -293,4 +293,25 @@ public class WarnSettingDao {
...
@@ -293,4 +293,25 @@ public class WarnSettingDao {
detachedCriteria
.
add
(
dis
);
detachedCriteria
.
add
(
dis
);
}
}
}
}
public
WarnSetting
queryOneWarnSettingsByMemoAndType
(
String
retailInfoWarnBuyCount
,
String
...
memo
)
{
List
<?>
byCriteria
=
queryWarnSettingsListByMemoAndType
(
retailInfoWarnBuyCount
,
memo
);
if
(!
byCriteria
.
isEmpty
()){
Object
o
=
byCriteria
.
get
(
0
);
return
warnSettingToEntity
((
KObject
)
o
);
}
return
null
;
}
public
List
<?>
queryWarnSettingsListByMemoAndType
(
String
retailInfoWarnBuyCount
,
String
...
memo
)
{
KClass
bean
=
Amino
.
getStaticMetadataContext
().
getBean
(
WarnSettingConstant
.
ENTITY_WARNSETTING
,
KClass
.
class
);
DetachedCriteria
detachedCriteria
=
DetachedCriteria
.
forEntityName
(
bean
.
getName
());
for
(
String
s
:
memo
)
{
detachedCriteria
.
add
(
Restrictions
.
like
(
WarnSettingConstant
.
memo
,
s
,
MatchMode
.
ANYWHERE
));
}
detachedCriteria
.
add
(
Restrictions
.
eq
(
WarnSettingConstant
.
target
,
retailInfoWarnBuyCount
));
return
template
.
findByCriteria
(
detachedCriteria
);
}
}
}
backend/xyst.dinas.biz/src/main/java/com/xyst/dinas/biz/warn/service/WarningService.java
View file @
337f46a0
...
@@ -44,8 +44,10 @@ public interface WarningService {
...
@@ -44,8 +44,10 @@ public interface WarningService {
* @return
* @return
*/
*/
KObject
queryWarnSettingById
(
UUID
id
);
KObject
queryWarnSettingById
(
UUID
id
);
/**
UUID
insertWarnSettingToIsNotice
(
WarnSetting
warnSetting
,
boolean
isNotice
);
/**
* 更新预警设置
* 更新预警设置
* @param warnSetting
* @param warnSetting
*/
*/
...
@@ -98,4 +100,8 @@ public interface WarningService {
...
@@ -98,4 +100,8 @@ public interface WarningService {
HashMap
<
String
,
Object
>
warnRecodeGroupInfo
(
List
<
UUID
>
regionalCompanyIds
,
List
<
String
>
targets
);
HashMap
<
String
,
Object
>
warnRecodeGroupInfo
(
List
<
UUID
>
regionalCompanyIds
,
List
<
String
>
targets
);
ArrayList
<
String
>
getExistedWarningSettingPersonnelByBillType
(
UUID
id
);
ArrayList
<
String
>
getExistedWarningSettingPersonnelByBillType
(
UUID
id
);
WarnSetting
queryOneWarnSettingsByMemoAndType
(
String
target
,
String
...
memo
);
void
updateRetailInfoWarnSettingAllByTypeAndMemo
(
String
target
,
String
toString
,
Double
max
);
}
}
backend/xyst.dinas.biz/src/main/java/com/xyst/dinas/biz/web/RetailInfoController.java
View file @
337f46a0
...
@@ -9,6 +9,8 @@ import com.beecode.inz.basis.team.pojo.ResponseObj;
...
@@ -9,6 +9,8 @@ import com.beecode.inz.basis.team.pojo.ResponseObj;
import
com.beecode.nlib.utils.StringUtils
;
import
com.beecode.nlib.utils.StringUtils
;
import
com.xyst.dinas.biz.constant.RetailInfoConstant
;
import
com.xyst.dinas.biz.constant.RetailInfoConstant
;
import
com.xyst.dinas.biz.service.RetailInfoService
;
import
com.xyst.dinas.biz.service.RetailInfoService
;
import
com.xyst.dinas.biz.warn.WarnSetting
;
import
com.xyst.dinas.biz.warn.service.WarningService
;
import
org.slf4j.Logger
;
import
org.slf4j.Logger
;
import
org.slf4j.LoggerFactory
;
import
org.slf4j.LoggerFactory
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.beans.factory.annotation.Autowired
;
...
@@ -28,6 +30,8 @@ public class RetailInfoController {
...
@@ -28,6 +30,8 @@ public class RetailInfoController {
@Autowired
@Autowired
private
RetailInfoService
retailInfoService
;
private
RetailInfoService
retailInfoService
;
@Autowired
private
WarningService
warningService
;
@RequestMapping
(
value
=
"list/page"
,
method
=
RequestMethod
.
GET
)
@RequestMapping
(
value
=
"list/page"
,
method
=
RequestMethod
.
GET
)
public
ResponseObj
getListPage
(
public
ResponseObj
getListPage
(
...
@@ -122,4 +126,38 @@ public class RetailInfoController {
...
@@ -122,4 +126,38 @@ public class RetailInfoController {
return
ResponseObj
.
success
();
return
ResponseObj
.
success
();
}
}
/**
* 修改预警设置
* @param target
* @return
*/
@PutMapping
(
"/updateWarnSetting"
)
public
ResponseObj
updateWarnSetting
(
@RequestParam
(
"target"
)
String
target
,
@RequestParam
(
value
=
"max"
)
String
max
,
@RequestParam
(
value
=
"stationId"
)
UUID
stationId
){
if
(
StringUtils
.
isEmpty
(
target
)){
return
ResponseObj
.
error
(
400
,
"指标错误"
);
}
warningService
.
updateRetailInfoWarnSettingAllByTypeAndMemo
(
target
,
stationId
.
toString
(),
Double
.
parseDouble
(
max
));
return
ResponseObj
.
success
();
}
/**
* 获取预警设置模板
* @param target
* @return
*/
@GetMapping
(
"/getWarnSetting"
)
public
ResponseObj
updateWarnSetting
(
@RequestParam
(
"target"
)
String
target
,
@RequestParam
(
value
=
"stationId"
,
required
=
false
)
UUID
stationId
){
if
(
StringUtils
.
isEmpty
(
target
)){
return
ResponseObj
.
error
(
400
,
"指标错误"
);
}
WarnSetting
warnSetting
=
warningService
.
queryOneWarnSettingsByMemoAndType
(
target
,
stationId
.
toString
(),
"template"
);
return
ResponseObj
.
success
(
"查询成功"
,
warnSetting
);
}
}
}
\ No newline at end of file
backend/xyst.dinas.biz/src/main/model/com/xyst/dinas/biz/query/RetailInfoWarningExe.mk
0 → 100644
View file @
337f46a0
<model>
<header>
<type>inz.query.Query</type>
<package>com.xyst.dinas.biz.query</package>
<name>RetailInfoWarningExe</name>
<title>散户预警记录</title>
<tags></tags>
<description></description>
</header>
<content>
<customQuery id='a68b7ed6-e37c-447b-8f70-342afa606607'>
<kclass>com.xyst.dinas.biz.datamodel.WarningExe</kclass>
<innerScene title='全部'>
<id>8376206c-b50c-4c52-bb5a-e0c9f6696056</id>
<javaImplement>com.beecode.inz.common.scene.CommonAllScene</javaImplement>
<defaultExecute></defaultExecute>
<hide></hide>
</innerScene>
<innerScene title='已废弃'>
<id>7840dd0d-0c7b-413d-85c7-89e4a4a7957f</id>
<javaImplement>com.beecode.inz.common.scene.DefaultDiscardScene</javaImplement>
<defaultExecute></defaultExecute>
<hide></hide>
</innerScene>
<field title='id'>
<name>id</name>
<type>uuid</type>
<ref>
<type></type>
<name></name>
</ref>
<description></description>
</field>
<field title='开始时间'>
<name>startTime</name>
<type>datetime</type>
<ref>
<type></type>
<name></name>
</ref>
<description></description>
</field>
<field title='结束时间'>
<name>endTime</name>
<type>datetime</type>
<ref>
<type></type>
<name></name>
</ref>
<description></description>
</field>
<field title='业务id'>
<name>billId</name>
<type>uuid</type>
<ref>
<type></type>
<name></name>
</ref>
<description></description>
</field>
<field title='预警指标'>
<name>target</name>
<type>string</type>
<ref>
<type></type>
<name></name>
</ref>
<description></description>
</field>
<field title='预警消息'>
<name>message</name>
<type>string</type>
<ref>
<type></type>
<name></name>
</ref>
<description></description>
</field>
<field title='备注'>
<name>memo</name>
<type>string</type>
<ref>
<type></type>
<name></name>
</ref>
<description></description>
</field>
<field title='预警值'>
<name>max</name>
<type>string</type>
<ref>
<type></type>
<name></name>
</ref>
<description></description>
</field>
<field title='实际值'>
<name>actualValue</name>
<type>string</type>
<ref>
<type></type>
<name></name>
</ref>
<description></description>
</field>
<field title='创建时间'>
<name>createTime</name>
<type>datetime</type>
<ref>
<type></type>
<name></name>
</ref>
<description></description>
</field>
<field title='修改时间'>
<name>modifyTime</name>
<type>datetime</type>
<ref>
<type></type>
<name></name>
</ref>
<description></description>
</field>
</customQuery>
</content>
</model>
\ No newline at end of file
backend/xyst.dinas.biz/src/main/resources/com/xyst/dinas/biz/query/RetailInfoWarningExe.jmx
0 → 100644
View file @
337f46a0
<?xml version="1.0" encoding="UTF-8"?>
<metadata
xmlns=
"http://www.beecode.cn/schema/amino-metadata"
xmlns:m=
"http://www.beecode.cn/schema/inz-query"
>
<specification>
1.0
</specification>
<id>
a68b7ed6-e37c-447b-8f70-342afa606607
</id>
<name>
com.xyst.dinas.biz.query.RetailInfoWarningExe
</name>
<title>
散户预警记录
</title>
<define>
inz.query.Query
</define>
<define-version>
1.0
</define-version>
<dependency>
com.xyst.dinas.biz.datamodel.WarningExe
</dependency>
<content>
<m:query>
<m:type>
com.xyst.dinas.biz.datamodel.WarningExe
</m:type>
<m:dataProcessor></m:dataProcessor>
<m:authorityItem></m:authorityItem>
<m:innerScenes>
<m:innerScene>
<m:id>
8376206c-b50c-4c52-bb5a-e0c9f6696056
</m:id>
<m:title>
全部
</m:title>
<m:javaImplement>
com.beecode.inz.common.scene.CommonAllScene
</m:javaImplement>
<m:defaultExecute></m:defaultExecute>
<m:hide></m:hide>
</m:innerScene>
<m:innerScene>
<m:id>
7840dd0d-0c7b-413d-85c7-89e4a4a7957f
</m:id>
<m:title>
已废弃
</m:title>
<m:javaImplement>
com.beecode.inz.common.scene.DefaultDiscardScene
</m:javaImplement>
<m:defaultExecute></m:defaultExecute>
<m:hide></m:hide>
</m:innerScene>
</m:innerScenes>
<m:fields>
<m:field>
<m:name>
id
</m:name>
<m:title>
id
</m:title>
<m:type>
uuid
</m:type>
<m:ref>
<m:name></m:name>
<m:type></m:type>
</m:ref>
<m:desc></m:desc>
</m:field>
<m:field>
<m:name>
startTime
</m:name>
<m:title>
开始时间
</m:title>
<m:type>
datetime
</m:type>
<m:ref>
<m:name></m:name>
<m:type></m:type>
</m:ref>
<m:desc></m:desc>
</m:field>
<m:field>
<m:name>
endTime
</m:name>
<m:title>
结束时间
</m:title>
<m:type>
datetime
</m:type>
<m:ref>
<m:name></m:name>
<m:type></m:type>
</m:ref>
<m:desc></m:desc>
</m:field>
<m:field>
<m:name>
billId
</m:name>
<m:title>
业务id
</m:title>
<m:type>
uuid
</m:type>
<m:ref>
<m:name></m:name>
<m:type></m:type>
</m:ref>
<m:desc></m:desc>
</m:field>
<m:field>
<m:name>
target
</m:name>
<m:title>
预警指标
</m:title>
<m:type>
string
</m:type>
<m:ref>
<m:name></m:name>
<m:type></m:type>
</m:ref>
<m:desc></m:desc>
</m:field>
<m:field>
<m:name>
memo
</m:name>
<m:title>
备注
</m:title>
<m:type>
string
</m:type>
<m:ref>
<m:name></m:name>
<m:type></m:type>
</m:ref>
<m:desc></m:desc>
</m:field>
<m:field>
<m:name>
max
</m:name>
<m:title>
预警值
</m:title>
<m:type>
string
</m:type>
<m:ref>
<m:name></m:name>
<m:type></m:type>
</m:ref>
<m:desc></m:desc>
</m:field>
<m:field>
<m:name>
actualValue
</m:name>
<m:title>
实际值
</m:title>
<m:type>
string
</m:type>
<m:ref>
<m:name></m:name>
<m:type></m:type>
</m:ref>
<m:desc></m:desc>
</m:field>
<m:field>
<m:name>
message
</m:name>
<m:title>
预警消息
</m:title>
<m:type>
string
</m:type>
<m:ref>
<m:name></m:name>
<m:type></m:type>
</m:ref>
<m:desc></m:desc>
</m:field>
<m:field>
<m:name>
createTime
</m:name>
<m:title>
创建时间
</m:title>
<m:type>
datetime
</m:type>
<m:ref>
<m:name></m:name>
<m:type></m:type>
</m:ref>
<m:desc></m:desc>
</m:field>
<m:field>
<m:name>
modifyTime
</m:name>
<m:title>
修改时间
</m:title>
<m:type>
datetime
</m:type>
<m:ref>
<m:name></m:name>
<m:type></m:type>
</m:ref>
<m:desc></m:desc>
</m:field>
</m:fields>
</m:query>
</content>
</metadata>
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment