Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
D
dc-cost-system
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
bltdc
dc-cost-system
Commits
0dee97a6
Commit
0dee97a6
authored
Dec 29, 2020
by
huluobin
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
update
parent
23d83cf2
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
78 additions
and
9 deletions
+78
-9
CostPlanNoLock.java
...c/main/java/com/blt/other/common/lock/CostPlanNoLock.java
+58
-0
CostPlanNewController.java
...t/other/module/cost/controller/CostPlanNewController.java
+12
-5
CostDomain.java
...main/java/com/blt/other/module/cost/model/CostDomain.java
+0
-1
CostTemplateBaseColServiceImpl.java
...ule/cost/service/impl/CostTemplateBaseColServiceImpl.java
+1
-1
CostTemplateColServiceImpl.java
.../module/cost/service/impl/CostTemplateColServiceImpl.java
+1
-1
CostTemplateServiceImpl.java
...her/module/cost/service/impl/CostTemplateServiceImpl.java
+1
-1
AbstractCostPlanService.java
...e/cost/service/impl/costplan/AbstractCostPlanService.java
+5
-0
No files found.
bailuntec-cost-core/src/main/java/com/blt/other/common/lock/CostPlanNoLock.java
0 → 100644
View file @
0dee97a6
package
com
.
blt
.
other
.
common
.
lock
;
import
java.util.HashMap
;
import
java.util.concurrent.locks.ReentrantLock
;
/**
* 分段锁,系统提供一定数量的原始锁,根据传入用户id值获取对应的锁并加锁
* 注意:要锁的用户id值如果发生改变,有可能导致锁无法成功释放!!!
*/
public
class
CostPlanNoLock
{
private
final
static
HashMap
<
Integer
,
ReentrantLock
>
lockMap
=
new
HashMap
<>();
private
Integer
segments
=
500
;
// 默认分段数量
private
CostPlanNoLock
()
{
init
(
null
,
false
);
}
private
CostPlanNoLock
(
Integer
counts
,
boolean
fair
)
{
init
(
counts
,
fair
);
}
/*静态内部类实现单例*/
public
static
CostPlanNoLock
getInstance
()
{
return
SingletonHolder
.
instance
;
}
private
void
init
(
Integer
counts
,
boolean
fair
)
{
if
(
counts
!=
null
)
{
segments
=
counts
;
}
for
(
int
i
=
0
;
i
<
segments
;
i
++)
{
lockMap
.
put
(
i
,
new
ReentrantLock
(
fair
));
}
}
public
void
lock
(
int
key
)
{
ReentrantLock
lock
=
lockMap
.
get
(
key
%
segments
);
lock
.
lock
();
}
public
void
unlock
(
int
key
)
{
ReentrantLock
lock
=
lockMap
.
get
(
key
%
segments
);
lock
.
unlock
();
}
@Override
public
String
toString
()
{
return
"SegmentLock [segments="
+
segments
+
", lockMap="
+
lockMap
+
"]"
;
}
/*静态内部类实现单例*/
private
static
class
SingletonHolder
{
private
static
final
CostPlanNoLock
instance
=
new
CostPlanNoLock
(
null
,
true
);
}
}
bailuntec-cost-core/src/main/java/com/blt/other/module/cost/controller/CostPlanNewController.java
View file @
0dee97a6
package
com
.
blt
.
other
.
module
.
cost
.
controller
;
import
com.blt.other.common.lock.CostPlanNoLock
;
import
com.blt.other.common.util.CurUtils
;
import
com.blt.other.database.model.CostPlanDomain
;
import
com.blt.other.module.cost.dto.response.RestResp
;
...
...
@@ -41,13 +42,19 @@ public class CostPlanNewController {
@PostMapping
(
"/affirm"
)
public
Map
<
String
,
Object
>
affirm
(
@RequestParam
String
costPlanNo
)
{
Map
<
String
,
Object
>
result
=
new
HashMap
<>();
CostPlanService
costPlanService
=
CostPlanServiceFactory
.
getCostPlanService
(
costPlanNo
);
CostPlanNoLock
lock
=
CostPlanNoLock
.
getInstance
();
try
{
lock
.
lock
(
costPlanNo
.
hashCode
());
CostPlanService
costPlanService
=
CostPlanServiceFactory
.
getCostPlanService
(
costPlanNo
);
Integer
affirm
=
costPlanService
.
affirm
(
costPlanNo
);
result
.
put
(
"success"
,
true
);
result
.
put
(
"msg"
,
"已生成 "
+
affirm
+
" 张费用单"
);
Integer
affirm
=
costPlanService
.
affirm
(
costPlanNo
);
result
.
put
(
"success"
,
true
);
result
.
put
(
"msg"
,
"已生成 "
+
affirm
+
" 张费用单"
);
return
result
;
return
result
;
}
finally
{
lock
.
unlock
(
costPlanNo
.
hashCode
());
}
}
@ApiOperation
(
"/删除费用计划"
)
...
...
bailuntec-cost-core/src/main/java/com/blt/other/module/cost/model/CostDomain.java
View file @
0dee97a6
...
...
@@ -57,7 +57,6 @@ public class CostDomain implements Serializable {
private
String
costNo
;
@ApiModelProperty
(
"费用计划编号"
)
private
String
costPlanNo
;
@ApiModelProperty
(
"当前部门id"
)
private
Integer
costDepartmentId
;
...
...
bailuntec-cost-core/src/main/java/com/blt/other/module/cost/service/impl/
costtemplate/
CostTemplateBaseColServiceImpl.java
→
bailuntec-cost-core/src/main/java/com/blt/other/module/cost/service/impl/CostTemplateBaseColServiceImpl.java
View file @
0dee97a6
package
com
.
blt
.
other
.
module
.
cost
.
service
.
impl
.
costtemplate
;
package
com
.
blt
.
other
.
module
.
cost
.
service
.
impl
;
import
com.bailuntec.common.BeanUtils
;
import
com.bailuntec.common.ListUtil
;
...
...
bailuntec-cost-core/src/main/java/com/blt/other/module/cost/service/impl/
costtemplate/
CostTemplateColServiceImpl.java
→
bailuntec-cost-core/src/main/java/com/blt/other/module/cost/service/impl/CostTemplateColServiceImpl.java
View file @
0dee97a6
package
com
.
blt
.
other
.
module
.
cost
.
service
.
impl
.
costtemplate
;
package
com
.
blt
.
other
.
module
.
cost
.
service
.
impl
;
import
com.bailuntec.common.ListUtil
;
import
com.bailuntec.common.StringUtils
;
...
...
bailuntec-cost-core/src/main/java/com/blt/other/module/cost/service/impl/
costtemplate/
CostTemplateServiceImpl.java
→
bailuntec-cost-core/src/main/java/com/blt/other/module/cost/service/impl/CostTemplateServiceImpl.java
View file @
0dee97a6
package
com
.
blt
.
other
.
module
.
cost
.
service
.
impl
.
costtemplate
;
package
com
.
blt
.
other
.
module
.
cost
.
service
.
impl
;
import
com.bailuntec.common.StringUtils
;
import
com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper
;
...
...
bailuntec-cost-core/src/main/java/com/blt/other/module/cost/service/impl/costplan/AbstractCostPlanService.java
View file @
0dee97a6
...
...
@@ -4,7 +4,9 @@ import com.bailuntec.common.ListUtil;
import
com.bailuntec.cost.api.dto.CostPlanDto
;
import
com.blt.other.common.exception.BizRuntimeException
;
import
com.blt.other.database.model.*
;
import
com.blt.other.module.auth.dao.OaUserMapper
;
import
com.blt.other.module.auth.dao.UserDao
;
import
com.blt.other.module.auth.model.OaUser
;
import
com.blt.other.module.cost.dao.*
;
import
com.blt.other.module.cost.dto.request.GetAllCostPlanReq
;
import
com.blt.other.module.cost.dto.response.GetAllCostPlanResp
;
...
...
@@ -179,6 +181,9 @@ public abstract class AbstractCostPlanService implements CostPlanService {
return
result
;
}
@Resource
OaUserMapper
oaUserMapper
;
protected
CostDomain
planToCost
(
String
costPlanNo
)
{
CostDomain
costDomain
=
new
CostDomain
();
CostPlanDomain
costPlanDomain
=
costPlanDao
.
selectByNo
(
costPlanNo
);
...
...
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