Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
H
hg-smart
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
platform
hg-smart
Commits
3ae5eda1
Commit
3ae5eda1
authored
Jul 29, 2024
by
liuyang
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
2024-07-26 定时添加设备计划
parent
f7c3c1a1
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
67 additions
and
0 deletions
+67
-0
ServiceHGSB002.java
.../java/com/baosight/hggp/hg/sb/service/ServiceHGSB002.java
+60
-0
DateUtil.java
src/main/java/com/baosight/hggp/util/DateUtil.java
+7
-0
No files found.
src/main/java/com/baosight/hggp/hg/sb/service/ServiceHGSB002.java
View file @
3ae5eda1
...
@@ -3,9 +3,11 @@ package com.baosight.hggp.hg.sb.service;
...
@@ -3,9 +3,11 @@ package com.baosight.hggp.hg.sb.service;
import
com.baosight.hggp.aspect.annotation.OperationLogAnnotation
;
import
com.baosight.hggp.aspect.annotation.OperationLogAnnotation
;
import
com.baosight.hggp.common.DdynamicEnum
;
import
com.baosight.hggp.common.DdynamicEnum
;
import
com.baosight.hggp.core.constant.CommonConstant
;
import
com.baosight.hggp.core.constant.CommonConstant
;
import
com.baosight.hggp.core.dao.DaoBase
;
import
com.baosight.hggp.core.dao.DaoUtils
;
import
com.baosight.hggp.core.dao.DaoUtils
;
import
com.baosight.hggp.core.security.UserSessionUtils
;
import
com.baosight.hggp.core.security.UserSessionUtils
;
import
com.baosight.hggp.hg.constant.HGConstant
;
import
com.baosight.hggp.hg.constant.HGConstant
;
import
com.baosight.hggp.hg.kc.domain.HGKC006A
;
import
com.baosight.hggp.hg.sb.domain.HGSB001
;
import
com.baosight.hggp.hg.sb.domain.HGSB001
;
import
com.baosight.hggp.hg.sb.domain.HGSB002A
;
import
com.baosight.hggp.hg.sb.domain.HGSB002A
;
import
com.baosight.hggp.hg.sb.tools.HGSBTools
;
import
com.baosight.hggp.hg.sb.tools.HGSBTools
;
...
@@ -28,6 +30,7 @@ import java.util.Arrays;
...
@@ -28,6 +30,7 @@ import java.util.Arrays;
import
java.util.HashMap
;
import
java.util.HashMap
;
import
java.util.List
;
import
java.util.List
;
import
java.util.Map
;
import
java.util.Map
;
import
java.util.stream.Collectors
;
/**
/**
* @author LiuYang
* @author LiuYang
...
@@ -165,4 +168,61 @@ public class ServiceHGSB002 extends ServiceEPBase {
...
@@ -165,4 +168,61 @@ public class ServiceHGSB002 extends ServiceEPBase {
}
}
return
inInfo
;
return
inInfo
;
}
}
@OperationLogAnnotation
(
operModul
=
"设备计划"
,
operType
=
"保存"
,
operDesc
=
"定时添加设备计划"
)
public
EiInfo
autoAdd
(
EiInfo
inInfo
)
{
try
{
String
systemDate
=
DateUtils
.
formatShort
(
DateUtils
.
date
());
inInfo
.
setCell
(
EiConstant
.
queryBlock
,
ACConstants
.
ROW_CODE_0
,
HGSB001
.
FIELD_MAINTAIN_DATE
,
systemDate
);
List
<
HGSB001
>
hgsb001s
=
DaoBase
.
getInstance
().
query
(
HGSB001
.
QUERY
,
new
HashMap
<
String
,
String
>(){{
put
(
HGSB001
.
FIELD_MAINTAIN_DATE
,
systemDate
);
}});
//List<HGSB001> resultBlock = inInfo.getBlock(EiConstant.resultBlock).getRows();
Map
<
String
,
List
<
HGSB001
>>
hgsb001Map
=
hgsb001s
.
stream
().
collect
(
Collectors
.
groupingBy
(
HGSB001:
:
getCompanyCode
,
Collectors
.
toList
()));
for
(
Map
.
Entry
<
String
,
List
<
HGSB001
>>
entry
:
hgsb001Map
.
entrySet
())
{
String
companyCode
=
entry
.
getKey
();
List
<
HGSB001
>
hgsb001List
=
entry
.
getValue
();
HGSB002
hgsb002
=
new
HGSB002
();
hgsb002
.
setDeleteFlag
(
CommonConstant
.
YesNo
.
NO_0
);
hgsb002
.
setCompanyCode
(
companyCode
);
hgsb002
.
setCompanyName
(
hgsb001List
.
get
(
0
).
getCompanyName
());
hgsb002
.
setPlanDate
(
systemDate
);
hgsb002
.
setPlanType
(
2
);
hgsb002
.
setPlanStartDate
(
systemDate
.
substring
(
0
,
6
)+
"01"
);
hgsb002
.
setPlanEndDate
(
systemDate
.
substring
(
0
,
6
)+
DateUtil
.
getDaysOfMonth
(
systemDate
));
hgsb002
.
setPlanUserId
(
"system"
);
hgsb002
.
setPlanUserName
(
"system"
);
hgsb002
.
setPlanStatus
(
0
);
hgsb002
.
setTaskStatus
(
0
);
this
.
add
(
hgsb002
);
this
.
addHgsb002a
(
hgsb001List
,
hgsb002
);
}
}
catch
(
Exception
e
){
LogUtils
.
setDetailMsg
(
inInfo
,
e
,
"自动添加设备计划失败"
);
}
return
inInfo
;
}
public
void
addHgsb002a
(
List
<
HGSB001
>
hgsb001List
,
HGSB002
hgsb002
)
{
for
(
HGSB001
hgsb001:
hgsb001List
)
{
//HGSB001 hgsb001 = new HGSB001();
//hgsb001.fromMap(map);
HGSB002A
hgsb002a
=
new
HGSB002A
();
hgsb002a
.
setDeleteFlag
(
CommonConstant
.
YesNo
.
NO_0
);
hgsb002a
.
setParentId
(
hgsb002
.
getId
());
hgsb002a
.
setGroupCode
(
hgsb001
.
getGroupCode
());
hgsb002a
.
setGroupName
(
hgsb001
.
getGroupName
());
hgsb002a
.
setDeviceType
(
hgsb001
.
getDeviceType
());
hgsb002a
.
setDeviceCode
(
hgsb001
.
getDeviceCode
());
hgsb002a
.
setDeviceName
(
hgsb001
.
getDeviceName
());
hgsb002a
.
setDeviceModel
(
hgsb001
.
getDeviceModel
());
DaoUtils
.
insert
(
HGSB002A
.
INSERT
,
hgsb002a
);
String
planCode
=
DateUtil
.
getDateOfDays
(
hgsb002
.
getPlanDate
(),
hgsb001
.
getPeriodDays
(),
DateUtil
.
DATE8_PATTERN
);
hgsb001
.
setMaintainDate
(
planCode
);
DaoUtils
.
update
(
HGSB001
.
UPDATE
,
hgsb001
);
}
}
}
}
src/main/java/com/baosight/hggp/util/DateUtil.java
View file @
3ae5eda1
...
@@ -114,6 +114,13 @@ public class DateUtil {
...
@@ -114,6 +114,13 @@ public class DateUtil {
return
DateUtil
.
toDateStr
(
calendar
.
getTime
(),
DATE8_PATTERN
);
//输出上个月的日期
return
DateUtil
.
toDateStr
(
calendar
.
getTime
(),
DATE8_PATTERN
);
//输出上个月的日期
}
}
public
static
String
getDateOfDays
(
String
date
,
int
day
,
String
pattern
){
Calendar
calendar
=
Calendar
.
getInstance
();
//日历对象
calendar
.
setTime
(
Objects
.
requireNonNull
(
DateUtil
.
toDate
(
date
,
pattern
)));
//设置当前日期
calendar
.
add
(
Calendar
.
DAY_OF_YEAR
,
day
);
//加上天数
return
DateUtil
.
toDateStr
(
calendar
.
getTime
(),
DATE8_PATTERN
);
//输出上个月的日期
}
private
static
SimpleDateFormat
getDateParser
(
String
pattern
)
{
private
static
SimpleDateFormat
getDateParser
(
String
pattern
)
{
return
new
SimpleDateFormat
(
pattern
);
return
new
SimpleDateFormat
(
pattern
);
}
}
...
...
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