Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
A
amos-boot-biz
Project
Project
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
项目统一框架
amos-boot-biz
Commits
d918cd61
Commit
d918cd61
authored
Oct 24, 2023
by
zhangsen
Browse files
Options
Browse Files
Download
Plain Diff
Merge remote-tracking branch 'origin/developer' into developer
parents
0032aa18
7b142008
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
339 additions
and
71 deletions
+339
-71
IdxBizFanWeightController.java
...odule/jxiop/biz/controller/IdxBizFanWeightController.java
+164
-36
IdxBizPvWeightController.java
...module/jxiop/biz/controller/IdxBizPvWeightController.java
+175
-35
No files found.
amos-boot-system-jxiop/amos-boot-module-jxiop-analyse-biz/src/main/java/com/yeejoin/amos/boot/module/jxiop/biz/controller/IdxBizFanWeightController.java
View file @
d918cd61
...
...
@@ -124,82 +124,210 @@ public class IdxBizFanWeightController extends BaseController {
@TycloudOperation
(
ApiLevel
=
UserType
.
AGENCY
,
needAuth
=
false
)
@PostMapping
(
value
=
"/update"
)
@ApiOperation
(
httpMethod
=
"POST"
,
value
=
"根据sequenceNbr更新"
,
notes
=
"根据sequenceNbr更新"
)
public
ResponseModel
<
IdxBizFanWeight
>
update
(
@RequestBody
Map
<
String
,
List
<
IdxBizFanWeight
>>
map
)
{
public
ResponseModel
<
IdxBizFanWeight
>
update
(
@RequestBody
Map
<
String
,
Object
>
value
)
{
if
(
value
!=
null
)
{
List
<
String
>
list1
=
Arrays
.
asList
(
value
.
get
(
"ids"
).
toString
().
split
(
","
));
LambdaQueryWrapper
<
IdxBizFanWeight
>
qu1
=
new
LambdaQueryWrapper
<>();
qu1
.
in
(!
list1
.
isEmpty
(),
IdxBizFanWeight:
:
getSequenceNbr
,
list1
);
List
<
IdxBizFanWeight
>
list
=
idxBizFanWeightMapper
.
selectList
(
qu1
);
IdxBizFanWeight
reviewDto
=
list
.
get
(
0
);
//获取所属,同类指标
if
(
map
!=
null
){
List
<
IdxBizFanWeight
>
list
=
map
.
get
(
"data"
);
// Float list= map.get("data");
//判断是否同一层级
String
flagtype
=
null
;
String
flagtype
=
null
;
for
(
IdxBizFanWeight
idxBizFanWeight
:
list
)
{
if
(
flagtype
==
null
){
if
(
flagtype
==
null
)
{
switch
(
reviewDto
.
getType
())
{
case
"1"
:
flagtype
=
idxBizFanWeight
.
getArae
()
;
flagtype
=
idxBizFanWeight
.
getArae
()+
idxBizFanWeight
.
getStation
()+
idxBizFanWeight
.
getEquipmentName
()+
idxBizFanWeight
.
getSubarray
()+
idxBizFanWeight
.
getPointName
()+
idxBizFanWeight
.
getType
();
}
else
{
if
(!
flagtype
.
equals
(
idxBizFanWeight
.
getArae
()+
idxBizFanWeight
.
getStation
()+
idxBizFanWeight
.
getEquipmentName
()+
idxBizFanWeight
.
getSubarray
()+
idxBizFanWeight
.
getPointName
()+
idxBizFanWeight
.
getType
())){
break
;
case
"2"
:
flagtype
=
idxBizFanWeight
.
getArae
()
+
idxBizFanWeight
.
getStation
();
break
;
case
"3"
:
flagtype
=
idxBizFanWeight
.
getArae
()
+
idxBizFanWeight
.
getStation
()
+
idxBizFanWeight
.
getEquipmentName
()
;
break
;
case
"4"
:
flagtype
=
idxBizFanWeight
.
getArae
()
+
idxBizFanWeight
.
getStation
()
+
idxBizFanWeight
.
getEquipmentName
()
+
idxBizFanWeight
.
getSubarray
()
;
break
;
case
"5"
:
flagtype
=
idxBizFanWeight
.
getArae
()
+
idxBizFanWeight
.
getStation
()
+
idxBizFanWeight
.
getEquipmentName
()
+
idxBizFanWeight
.
getSubarray
()
+
idxBizFanWeight
.
getPointName
()
;
break
;
}
}
else
{
switch
(
reviewDto
.
getType
())
{
case
"1"
:
if
(!
flagtype
.
equals
(
idxBizFanWeight
.
getArae
()
))
{
throw
new
BadRequest
(
"配置权重必须是同一个层级的数据"
);
}
break
;
case
"2"
:
if
(!
flagtype
.
equals
(
idxBizFanWeight
.
getArae
()
+
idxBizFanWeight
.
getStation
()
))
{
throw
new
BadRequest
(
"配置权重必须是同一个层级的数据"
);
}
break
;
case
"3"
:
if
(!
flagtype
.
equals
(
idxBizFanWeight
.
getArae
()
+
idxBizFanWeight
.
getStation
()
+
idxBizFanWeight
.
getEquipmentName
()
))
{
throw
new
BadRequest
(
"配置权重必须是同一个层级的数据"
);
}
Float
value
=
list
.
stream
().
map
(
e
->
e
.
getValue
()).
reduce
(
Float:
:
sum
).
get
();
IdxBizFanWeight
reviewDto
=
list
.
get
(
0
);
LambdaQueryWrapper
<
IdxBizFanWeight
>
qu
=
new
LambdaQueryWrapper
<>();
qu
.
eq
(!
StringUtils
.
isEmpty
(
reviewDto
.
getType
()),
IdxBizFanWeight:
:
getType
,
reviewDto
.
getType
());
qu
.
eq
(!
StringUtils
.
isEmpty
(
reviewDto
.
getArae
()),
IdxBizFanWeight:
:
getArae
,
reviewDto
.
getArae
());
qu
.
eq
(!
StringUtils
.
isEmpty
(
reviewDto
.
getStation
()),
IdxBizFanWeight:
:
getStation
,
reviewDto
.
getStation
());
qu
.
eq
(!
StringUtils
.
isEmpty
(
reviewDto
.
getSubarray
()),
IdxBizFanWeight:
:
getSubarray
,
reviewDto
.
getSubarray
());
qu
.
eq
(!
StringUtils
.
isEmpty
(
reviewDto
.
getEquipmentName
()),
IdxBizFanWeight:
:
getEquipmentName
,
reviewDto
.
getEquipmentName
());
qu
.
eq
(!
StringUtils
.
isEmpty
(
reviewDto
.
getPointName
()),
IdxBizFanWeight:
:
getPointName
,
reviewDto
.
getPointName
());
break
;
case
"4"
:
if
(!
flagtype
.
equals
(
idxBizFanWeight
.
getArae
()
+
idxBizFanWeight
.
getStation
()
+
idxBizFanWeight
.
getEquipmentName
()
+
idxBizFanWeight
.
getSubarray
()
))
{
throw
new
BadRequest
(
"配置权重必须是同一个层级的数据"
);
}
break
;
case
"5"
:
if
(!
flagtype
.
equals
(
idxBizFanWeight
.
getArae
()
+
idxBizFanWeight
.
getStation
()
+
idxBizFanWeight
.
getEquipmentName
()
+
idxBizFanWeight
.
getSubarray
()
+
idxBizFanWeight
.
getPointName
()
))
{
throw
new
BadRequest
(
"配置权重必须是同一个层级的数据"
);
}
break
;
}
}
Float
valued
=
list
.
size
()
*
Float
.
valueOf
(
value
.
get
(
"data"
).
toString
());
LambdaQueryWrapper
<
IdxBizFanWeight
>
qu
=
new
LambdaQueryWrapper
<>();
qu
.
eq
(!
StringUtils
.
isEmpty
(
reviewDto
.
getType
()),
IdxBizFanWeight:
:
getType
,
reviewDto
.
getType
());
qu
.
eq
(!
StringUtils
.
isEmpty
(
reviewDto
.
getArae
()),
IdxBizFanWeight:
:
getArae
,
reviewDto
.
getArae
());
qu
.
eq
(!
StringUtils
.
isEmpty
(
reviewDto
.
getStation
()),
IdxBizFanWeight:
:
getStation
,
reviewDto
.
getStation
());
qu
.
eq
(!
StringUtils
.
isEmpty
(
reviewDto
.
getSubarray
()),
IdxBizFanWeight:
:
getSubarray
,
reviewDto
.
getSubarray
());
qu
.
eq
(!
StringUtils
.
isEmpty
(
reviewDto
.
getEquipmentName
()),
IdxBizFanWeight:
:
getEquipmentName
,
reviewDto
.
getEquipmentName
());
qu
.
eq
(!
StringUtils
.
isEmpty
(
reviewDto
.
getPointName
()),
IdxBizFanWeight:
:
getPointName
,
reviewDto
.
getPointName
());
List
<
IdxBizFanWeight
>
listdata
=
idxBizFanWeightMapper
.
selectList
(
qu
);
//设置权重值,
int
num
=
listdata
.
size
()-
list
.
size
();
int
num
=
listdata
.
size
()
-
list
.
size
();
if
(
num
==
0
)
{
if
(
valued
!=
1
)
{
throw
new
BadRequest
(
"超出权重最大值限制,层级下权重等级总和为1"
);
}
}
//值不能大于1
if
(
value
>
1
)
{
if
(
valued
>
1
)
{
throw
new
BadRequest
(
"超出权重最大值限制,层级下权重等级总和为1"
);
}
if
(
value
!=
1
&&
num
!=
0
)
{
if
(
valued
!=
1
&&
num
!=
0
)
{
throw
new
BadRequest
(
"超出权重最大值限制,层级下权重等级总和为1"
);
}
//剩余权重值
float
formattedNum
=
num
!=
0
?
Float
.
parseFloat
(
new
DecimalFormat
(
"0.0000"
).
format
((
1
-
value
)/
num
)):
0
;
float
formattedNum
=
num
!=
0
?
Float
.
parseFloat
(
new
DecimalFormat
(
"0.0000000000"
).
format
((
1
-
valued
)
/
num
))
:
0
;
for
(
IdxBizFanWeight
listdatum
:
listdata
)
{
for
(
IdxBizFanWeight
idxBizPvWeight
:
list
)
{
if
(
idxBizPvWeight
.
getSequenceNbr
().
equals
(
listdatum
.
getSequenceNbr
()))
{
if
(
idxBizPvWeight
.
getSequenceNbr
().
equals
(
listdatum
.
getSequenceNbr
()))
{
listdatum
.
setValue
(
idxBizPvWeight
.
getValue
());
break
;
}
else
{
}
else
{
listdatum
.
setValue
(
formattedNum
);
break
;
}
}
idxBizFanWeightMapper
.
updateById
(
listdatum
);
}
}
}
return
ResponseHelper
.
buildResponse
(
null
);
}
// @Transactional
// @TycloudOperation(ApiLevel = UserType.AGENCY, needAuth = false)
// @PostMapping(value = "/update")
// @ApiOperation(httpMethod = "POST", value = "根据sequenceNbr更新", notes = "根据sequenceNbr更新")
// public ResponseModel<IdxBizFanWeight> update(@RequestBody Map<String,List<IdxBizFanWeight>> map) {
// //获取所属,同类指标
// if(map!=null){
// List<IdxBizFanWeight> list= map.get("data");
// //判断是否同一层级
// String flagtype=null;
// for (IdxBizFanWeight idxBizFanWeight : list) {
// if(flagtype==null){
//
// flagtype= idxBizFanWeight.getArae()+idxBizFanWeight.getStation()+idxBizFanWeight.getEquipmentName()+idxBizFanWeight.getSubarray()+idxBizFanWeight.getPointName()+idxBizFanWeight.getType();
// }else{
// if(!flagtype.equals(idxBizFanWeight.getArae()+idxBizFanWeight.getStation()+idxBizFanWeight.getEquipmentName()+idxBizFanWeight.getSubarray()+idxBizFanWeight.getPointName()+idxBizFanWeight.getType())){
// throw new BadRequest("配置权重必须是同一个层级的数据");
// }
// }
// }
// Float value= list.stream().map(e->e.getValue()).reduce(Float::sum).get();
// IdxBizFanWeight reviewDto= list.get(0);
// LambdaQueryWrapper<IdxBizFanWeight> qu=new LambdaQueryWrapper<>();
// qu.eq(!StringUtils.isEmpty(reviewDto.getType()),IdxBizFanWeight::getType,reviewDto.getType());
// qu.eq(!StringUtils.isEmpty(reviewDto.getArae()),IdxBizFanWeight::getArae,reviewDto.getArae());
// qu.eq(!StringUtils.isEmpty(reviewDto.getStation()), IdxBizFanWeight::getStation,reviewDto.getStation());
// qu.eq(!StringUtils.isEmpty(reviewDto.getSubarray()),IdxBizFanWeight::getSubarray,reviewDto.getSubarray());
// qu.eq(!StringUtils.isEmpty(reviewDto.getEquipmentName()),IdxBizFanWeight::getEquipmentName,reviewDto.getEquipmentName());
// qu.eq(!StringUtils.isEmpty(reviewDto.getPointName()),IdxBizFanWeight::getPointName,reviewDto.getPointName());
// List<IdxBizFanWeight> listdata = idxBizFanWeightMapper.selectList(qu);
//
// //设置权重值,
// int num= listdata.size()-list.size();
//
// //值不能大于1
// if(value>1){
// throw new BadRequest("超出权重最大值限制,层级下权重等级总和为1");
// }
// if(value!=1&&num!=0){
// throw new BadRequest("超出权重最大值限制,层级下权重等级总和为1");
// }
//
//
//
//
// //剩余权重值
// float formattedNum =num!=0? Float.parseFloat(new DecimalFormat("0.0000000000").format((1-value)/num)):0;
//
// for (IdxBizFanWeight listdatum : listdata) {
// for (IdxBizFanWeight idxBizPvWeight : list) {
// if(idxBizPvWeight.getSequenceNbr().equals(listdatum.getSequenceNbr())){
// listdatum.setValue(idxBizPvWeight.getValue());
// break;
// }else{
// listdatum.setValue(formattedNum);
// break;
// }
// }
// idxBizFanWeightMapper.updateById(listdatum);
// }
//
//
// }
//
// return ResponseHelper.buildResponse(null);
// }
@TycloudOperation
(
ApiLevel
=
UserType
.
AGENCY
,
needAuth
=
false
)
@GetMapping
(
value
=
"/list"
)
@ApiOperation
(
httpMethod
=
"get"
,
value
=
"根据sequenceNbr更新"
,
notes
=
"根据sequenceNbr更新"
)
public
ResponseModel
<
Map
<
String
,
Object
>>
list
(
String
ids
)
{
List
<
String
>
list
=
Arrays
.
asList
(
ids
.
split
(
","
));
LambdaQueryWrapper
<
IdxBizFanWeight
>
qu
=
new
LambdaQueryWrapper
<>();
qu
.
in
(!
list
.
isEmpty
(),
IdxBizFanWeight:
:
getSequenceNbr
,
list
);
List
<
IdxBizFanWeight
>
listdata
=
idxBizFanWeightMapper
.
selectList
(
qu
);
public
ResponseModel
<
Map
<
String
,
Object
>>
list
(
String
ids
)
{
Map
<
String
,
Object
>
data
=
new
HashMap
<>();
data
.
put
(
"data"
,
listdata
);
data
.
put
(
"ids"
,
ids
);
return
ResponseHelper
.
buildResponse
(
data
);
}
// @TycloudOperation(ApiLevel = UserType.AGENCY, needAuth = false)
// @GetMapping (value = "/list")
// @ApiOperation(httpMethod = "get", value = "根据sequenceNbr更新", notes = "根据sequenceNbr更新")
// public ResponseModel<Map<String,Object>> list( String ids
// ) {
// List<String> list= Arrays.asList(ids.split(","));
// LambdaQueryWrapper<IdxBizFanWeight> qu=new LambdaQueryWrapper<>();
// qu.in(!list.isEmpty(),IdxBizFanWeight::getSequenceNbr,list);
// List<IdxBizFanWeight> listdata = idxBizFanWeightMapper.selectList(qu);
// Map<String,Object> data=new HashMap<>();
//
// data.put("data",listdata);
// return ResponseHelper.buildResponse(data);
// }
}
amos-boot-system-jxiop/amos-boot-module-jxiop-analyse-biz/src/main/java/com/yeejoin/amos/boot/module/jxiop/biz/controller/IdxBizPvWeightController.java
View file @
d918cd61
...
...
@@ -9,7 +9,7 @@ import com.github.pagehelper.PageHelper;
import
com.github.pagehelper.PageInfo
;
import
com.yeejoin.amos.boot.biz.common.controller.BaseController
;
import
com.yeejoin.amos.boot.module.jxiop.biz.dto.IdxBiz3yudDto
;
import
com.yeejoin.amos.boot.module.jxiop.biz.entity.IdxBiz
Fan
Weight
;
import
com.yeejoin.amos.boot.module.jxiop.biz.entity.IdxBiz
Pv
Weight
;
import
com.yeejoin.amos.boot.module.jxiop.biz.entity.IdxBizPvWeight
;
import
com.yeejoin.amos.boot.module.jxiop.biz.mapper2.IdxBizPvWeightMapper
;
import
io.swagger.annotations.Api
;
...
...
@@ -133,82 +133,222 @@ public class IdxBizPvWeightController extends BaseController {
return
ResponseHelper
.
buildResponse
(
list
);
}
@Transactional
@TycloudOperation
(
ApiLevel
=
UserType
.
AGENCY
,
needAuth
=
false
)
@PostMapping
(
value
=
"/update"
)
@PostMapping
(
value
=
"/update"
)
@ApiOperation
(
httpMethod
=
"POST"
,
value
=
"根据sequenceNbr更新"
,
notes
=
"根据sequenceNbr更新"
)
public
ResponseModel
<
IdxBizPvWeight
>
update
(
@RequestBody
Map
<
String
,
List
<
IdxBizPvWeight
>>
map
)
{
public
ResponseModel
<
IdxBizPvWeight
>
update
(
@RequestBody
Map
<
String
,
Object
>
value
)
{
if
(
value
!=
null
)
{
List
<
String
>
list1
=
Arrays
.
asList
(
value
.
get
(
"ids"
).
toString
().
split
(
","
));
LambdaQueryWrapper
<
IdxBizPvWeight
>
qu1
=
new
LambdaQueryWrapper
<>();
qu1
.
in
(!
list1
.
isEmpty
(),
IdxBizPvWeight:
:
getSequenceNbr
,
list1
);
List
<
IdxBizPvWeight
>
list
=
idxBizPvWeightMapper
.
selectList
(
qu1
);
IdxBizPvWeight
reviewDto
=
list
.
get
(
0
);
//获取所属,同类指标
if
(
map
!=
null
){
List
<
IdxBizPvWeight
>
list
=
map
.
get
(
"data"
);
// Float list= map.get("data");
//判断是否同一层级
String
flagtype
=
null
;
for
(
IdxBizPvWeight
idxBizPvWeight
:
list
)
{
if
(
flagtype
==
null
){
String
flagtype
=
null
;
for
(
IdxBizPvWeight
idxBizFanWeight
:
list
)
{
if
(
flagtype
==
null
)
{
switch
(
reviewDto
.
getType
())
{
case
"1"
:
flagtype
=
idxBizFanWeight
.
getArae
()
;
break
;
case
"2"
:
flagtype
=
idxBizFanWeight
.
getArae
()
+
idxBizFanWeight
.
getStation
();
break
;
case
"3"
:
flagtype
=
idxBizFanWeight
.
getArae
()
+
idxBizFanWeight
.
getStation
()
+
idxBizFanWeight
.
getEquipmentName
()
;
break
;
case
"4"
:
flagtype
=
idxBizFanWeight
.
getArae
()
+
idxBizFanWeight
.
getStation
()
+
idxBizFanWeight
.
getEquipmentName
()
+
idxBizFanWeight
.
getSubarray
()
;
flagtype
=
idxBizPvWeight
.
getArae
()+
idxBizPvWeight
.
getStation
()+
idxBizPvWeight
.
getEquipmentName
()+
idxBizPvWeight
.
getSubarray
()+
idxBizPvWeight
.
getPointName
()+
idxBizPvWeight
.
getType
();
}
else
{
if
(!
flagtype
.
equals
(
idxBizPvWeight
.
getArae
()+
idxBizPvWeight
.
getStation
()+
idxBizPvWeight
.
getEquipmentName
()+
idxBizPvWeight
.
getSubarray
()+
idxBizPvWeight
.
getPointName
()+
idxBizPvWeight
.
getType
())){
break
;
case
"5"
:
flagtype
=
idxBizFanWeight
.
getArae
()
+
idxBizFanWeight
.
getStation
()
+
idxBizFanWeight
.
getEquipmentName
()
+
idxBizFanWeight
.
getSubarray
()
+
idxBizFanWeight
.
getPointName
()
;
break
;
}
}
else
{
switch
(
reviewDto
.
getType
())
{
case
"1"
:
if
(!
flagtype
.
equals
(
idxBizFanWeight
.
getArae
()
))
{
throw
new
BadRequest
(
"配置权重必须是同一个层级的数据"
);
}
break
;
case
"2"
:
if
(!
flagtype
.
equals
(
idxBizFanWeight
.
getArae
()
+
idxBizFanWeight
.
getStation
()
))
{
throw
new
BadRequest
(
"配置权重必须是同一个层级的数据"
);
}
break
;
case
"3"
:
if
(!
flagtype
.
equals
(
idxBizFanWeight
.
getArae
()
+
idxBizFanWeight
.
getStation
()
+
idxBizFanWeight
.
getEquipmentName
()
))
{
throw
new
BadRequest
(
"配置权重必须是同一个层级的数据"
);
}
Float
value
=
list
.
stream
().
map
(
e
->
e
.
getValue
()).
reduce
(
Float:
:
sum
).
get
();
IdxBizPvWeight
reviewDto
=
list
.
get
(
0
);
LambdaQueryWrapper
<
IdxBizPvWeight
>
qu
=
new
LambdaQueryWrapper
<>();
qu
.
eq
(!
StringUtils
.
isEmpty
(
reviewDto
.
getType
()),
IdxBizPvWeight:
:
getType
,
reviewDto
.
getType
());
qu
.
eq
(!
StringUtils
.
isEmpty
(
reviewDto
.
getArae
()),
IdxBizPvWeight:
:
getArae
,
reviewDto
.
getArae
());
qu
.
eq
(!
StringUtils
.
isEmpty
(
reviewDto
.
getStation
()),
IdxBizPvWeight:
:
getStation
,
reviewDto
.
getStation
());
qu
.
eq
(!
StringUtils
.
isEmpty
(
reviewDto
.
getSubarray
()),
IdxBizPvWeight:
:
getSubarray
,
reviewDto
.
getSubarray
());
qu
.
eq
(!
StringUtils
.
isEmpty
(
reviewDto
.
getEquipmentName
()),
IdxBizPvWeight:
:
getEquipmentName
,
reviewDto
.
getEquipmentName
());
qu
.
eq
(!
StringUtils
.
isEmpty
(
reviewDto
.
getPointName
()),
IdxBizPvWeight:
:
getPointName
,
reviewDto
.
getPointName
());
break
;
case
"4"
:
if
(!
flagtype
.
equals
(
idxBizFanWeight
.
getArae
()
+
idxBizFanWeight
.
getStation
()
+
idxBizFanWeight
.
getEquipmentName
()
+
idxBizFanWeight
.
getSubarray
()
))
{
throw
new
BadRequest
(
"配置权重必须是同一个层级的数据"
);
}
break
;
case
"5"
:
if
(!
flagtype
.
equals
(
idxBizFanWeight
.
getArae
()
+
idxBizFanWeight
.
getStation
()
+
idxBizFanWeight
.
getEquipmentName
()
+
idxBizFanWeight
.
getSubarray
()
+
idxBizFanWeight
.
getPointName
()
))
{
throw
new
BadRequest
(
"配置权重必须是同一个层级的数据"
);
}
break
;
}
}
Float
valued
=
list
.
size
()
*
Float
.
valueOf
(
value
.
get
(
"data"
).
toString
());
LambdaQueryWrapper
<
IdxBizPvWeight
>
qu
=
new
LambdaQueryWrapper
<>();
qu
.
eq
(!
StringUtils
.
isEmpty
(
reviewDto
.
getType
()),
IdxBizPvWeight:
:
getType
,
reviewDto
.
getType
());
qu
.
eq
(!
StringUtils
.
isEmpty
(
reviewDto
.
getArae
()),
IdxBizPvWeight:
:
getArae
,
reviewDto
.
getArae
());
qu
.
eq
(!
StringUtils
.
isEmpty
(
reviewDto
.
getStation
()),
IdxBizPvWeight:
:
getStation
,
reviewDto
.
getStation
());
qu
.
eq
(!
StringUtils
.
isEmpty
(
reviewDto
.
getSubarray
()),
IdxBizPvWeight:
:
getSubarray
,
reviewDto
.
getSubarray
());
qu
.
eq
(!
StringUtils
.
isEmpty
(
reviewDto
.
getEquipmentName
()),
IdxBizPvWeight:
:
getEquipmentName
,
reviewDto
.
getEquipmentName
());
qu
.
eq
(!
StringUtils
.
isEmpty
(
reviewDto
.
getPointName
()),
IdxBizPvWeight:
:
getPointName
,
reviewDto
.
getPointName
());
List
<
IdxBizPvWeight
>
listdata
=
idxBizPvWeightMapper
.
selectList
(
qu
);
//设置权重值,
int
num
=
listdata
.
size
()-
list
.
size
();
int
num
=
listdata
.
size
()
-
list
.
size
();
if
(
num
==
0
)
{
if
(
valued
!=
1
)
{
throw
new
BadRequest
(
"超出权重最大值限制,层级下权重等级总和为1"
);
}
}
//值不能大于1
if
(
value
>
1
)
{
if
(
valued
>
1
)
{
throw
new
BadRequest
(
"超出权重最大值限制,层级下权重等级总和为1"
);
}
if
(
value
!=
1
&&
num
!=
0
)
{
if
(
valued
!=
1
&&
num
!=
0
)
{
throw
new
BadRequest
(
"超出权重最大值限制,层级下权重等级总和为1"
);
}
//剩余权重值
float
formattedNum
=
num
!=
0
?
Float
.
parseFloat
(
new
DecimalFormat
(
"0.0000"
).
format
((
1
-
value
)/
num
)):
0
;
float
formattedNum
=
num
!=
0
?
Float
.
parseFloat
(
new
DecimalFormat
(
"0.0000000000"
).
format
((
1
-
valued
)
/
num
))
:
0
;
for
(
IdxBizPvWeight
listdatum
:
listdata
)
{
for
(
IdxBizPvWeight
idxBizPvWeight
:
list
)
{
if
(
idxBizPvWeight
.
getSequenceNbr
().
equals
(
listdatum
.
getSequenceNbr
()))
{
if
(
idxBizPvWeight
.
getSequenceNbr
().
equals
(
listdatum
.
getSequenceNbr
()))
{
listdatum
.
setValue
(
idxBizPvWeight
.
getValue
());
break
;
}
else
{
}
else
{
listdatum
.
setValue
(
formattedNum
);
break
;
}
}
idxBizPvWeightMapper
.
updateById
(
listdatum
);
}
}
}
return
ResponseHelper
.
buildResponse
(
null
);
}
// @Transactional
// @TycloudOperation(ApiLevel = UserType.AGENCY, needAuth = false)
// @PostMapping (value = "/update")
// @ApiOperation(httpMethod = "POST", value = "根据sequenceNbr更新", notes = "根据sequenceNbr更新")
// public ResponseModel<IdxBizPvWeight> update(@RequestBody Map<String,List<IdxBizPvWeight>> map) {
// //获取所属,同类指标
// if(map!=null){
// List<IdxBizPvWeight> list= map.get("data");
// //判断是否同一层级
// String flagtype=null;
// for (IdxBizPvWeight idxBizPvWeight : list) {
// if(flagtype==null){
//
// flagtype= idxBizPvWeight.getArae()+idxBizPvWeight.getStation()+idxBizPvWeight.getEquipmentName()+idxBizPvWeight.getSubarray()+idxBizPvWeight.getPointName()+idxBizPvWeight.getType();
// }else{
// if(!flagtype.equals(idxBizPvWeight.getArae()+idxBizPvWeight.getStation()+idxBizPvWeight.getEquipmentName()+idxBizPvWeight.getSubarray()+idxBizPvWeight.getPointName()+idxBizPvWeight.getType())){
// throw new BadRequest("配置权重必须是同一个层级的数据");
// }
// }
// }
// Float value= list.stream().map(e->e.getValue()).reduce(Float::sum).get();
// IdxBizPvWeight reviewDto= list.get(0);
// LambdaQueryWrapper<IdxBizPvWeight> qu=new LambdaQueryWrapper<>();
// qu.eq(!StringUtils.isEmpty(reviewDto.getType()),IdxBizPvWeight::getType,reviewDto.getType());
// qu.eq(!StringUtils.isEmpty(reviewDto.getArae()),IdxBizPvWeight::getArae,reviewDto.getArae());
// qu.eq(!StringUtils.isEmpty(reviewDto.getStation()), IdxBizPvWeight::getStation,reviewDto.getStation());
// qu.eq(!StringUtils.isEmpty(reviewDto.getSubarray()),IdxBizPvWeight::getSubarray,reviewDto.getSubarray());
// qu.eq(!StringUtils.isEmpty(reviewDto.getEquipmentName()),IdxBizPvWeight::getEquipmentName,reviewDto.getEquipmentName());
// qu.eq(!StringUtils.isEmpty(reviewDto.getPointName()),IdxBizPvWeight::getPointName,reviewDto.getPointName());
// List<IdxBizPvWeight> listdata = idxBizPvWeightMapper.selectList(qu);
//
// //设置权重值,
// int num= listdata.size()-list.size();
//
// //值不能大于1
// if(value>1){
// throw new BadRequest("超出权重最大值限制,层级下权重等级总和为1");
// }
// if(value!=1&&num!=0){
// throw new BadRequest("超出权重最大值限制,层级下权重等级总和为1");
// }
//
// //剩余权重值
//
// float formattedNum =num!=0? Float.parseFloat(new DecimalFormat("0.0000").format((1-value)/num)):0;
//
// for (IdxBizPvWeight listdatum : listdata) {
// for (IdxBizPvWeight idxBizPvWeight : list) {
// if(idxBizPvWeight.getSequenceNbr().equals(listdatum.getSequenceNbr())){
// listdatum.setValue(idxBizPvWeight.getValue());
// break;
// }else{
// listdatum.setValue(formattedNum);
// break;
// }
// }
// idxBizPvWeightMapper.updateById(listdatum);
// }
//
//
// }
//
// return ResponseHelper.buildResponse(null);
// }
@TycloudOperation
(
ApiLevel
=
UserType
.
AGENCY
,
needAuth
=
false
)
@GetMapping
(
value
=
"/list"
)
@ApiOperation
(
httpMethod
=
"get"
,
value
=
"根据sequenceNbr更新"
,
notes
=
"根据sequenceNbr更新"
)
public
ResponseModel
<
Map
<
String
,
Object
>>
list
(
String
ids
)
{
List
<
String
>
list
=
Arrays
.
asList
(
ids
.
split
(
","
));
LambdaQueryWrapper
<
IdxBizPvWeight
>
qu
=
new
LambdaQueryWrapper
<>();
qu
.
in
(!
list
.
isEmpty
(),
IdxBizPvWeight:
:
getSequenceNbr
,
list
);
List
<
IdxBizPvWeight
>
listdata
=
idxBizPvWeightMapper
.
selectList
(
qu
);
Map
<
String
,
Object
>
data
=
new
HashMap
<>();
data
.
put
(
"
data"
,
listdata
);
data
.
put
(
"
ids"
,
ids
);
return
ResponseHelper
.
buildResponse
(
data
);
}
// @TycloudOperation(ApiLevel = UserType.AGENCY, needAuth = false)
// @GetMapping (value = "/list")
// @ApiOperation(httpMethod = "get", value = "根据sequenceNbr更新", notes = "根据sequenceNbr更新")
// public ResponseModel<Map<String,Object>> list( String ids
// ) {
// List<String> list= Arrays.asList(ids.split(","));
// LambdaQueryWrapper<IdxBizPvWeight> qu=new LambdaQueryWrapper<>();
// qu.in(!list.isEmpty(),IdxBizPvWeight::getSequenceNbr,list);
// List<IdxBizPvWeight> listdata = idxBizPvWeightMapper.selectList(qu);
// Map<String,Object> data=new HashMap<>();
//
// data.put("data",listdata);
// return ResponseHelper.buildResponse(data);
// }
}
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