修复对判空的支持

This commit is contained in:
wulin 2020-10-22 09:45:22 +08:00
parent 2562b7c608
commit ea176a3155
5 changed files with 132 additions and 111 deletions

View File

@ -106,32 +106,35 @@ public class FlowChartController {
@ApiOperation("保存流程节点小流程列表")
@ApiResponses({@ApiResponse(code = 200, message = "成功", response = FlowChartDetailRecord.class)})
public R saveDetailProcs(@RequestBody @ApiParam FlowChartDetailRecordListReq flowChartDetailRecordListReq) {
List<FlowChartDetailRecord> inserts = new ArrayList<>();
List<FlowChartDetailRecord> updaes = new ArrayList<>();
int index = 0;
for (FlowChartDetailRecordSimpleReq req:flowChartDetailRecordListReq.getRecordSimpleDtos()
) {
FlowChartDetailRecord flowChartDetailRecord = new FlowChartDetailRecord();
BeanUtils.copyProperties(req, flowChartDetailRecord);
flowChartDetailRecord.setChartId(flowChartDetailRecordListReq.getId());
flowChartDetailRecord.setEvaluationGroupId(flowChartDetailRecordListReq.getEvaluationGroupId());
flowChartDetailRecord.setStepIndex(index);
if(flowChartDetailRecord.getId() != null && flowChartDetailRecord.getId().intValue() > 0){
updaes.add(flowChartDetailRecord);
}else{
inserts.add(flowChartDetailRecord);
}
if(flowChartDetailRecord.getIsDelete() == null || flowChartDetailRecord.getIsDelete().intValue() == 0){
index++;
}
if(flowChartDetailRecordListReq.getRecordSimpleDtos() != null && flowChartDetailRecordListReq.getRecordSimpleDtos().size() > 0){
List<FlowChartDetailRecord> inserts = new ArrayList<>();
List<FlowChartDetailRecord> updaes = new ArrayList<>();
int index = 0;
for (FlowChartDetailRecordSimpleReq req:flowChartDetailRecordListReq.getRecordSimpleDtos()
) {
FlowChartDetailRecord flowChartDetailRecord = new FlowChartDetailRecord();
BeanUtils.copyProperties(req, flowChartDetailRecord);
flowChartDetailRecord.setChartId(flowChartDetailRecordListReq.getId());
flowChartDetailRecord.setEvaluationGroupId(flowChartDetailRecordListReq.getEvaluationGroupId());
flowChartDetailRecord.setStepIndex(index);
if(flowChartDetailRecord.getId() != null && flowChartDetailRecord.getId().intValue() > 0){
updaes.add(flowChartDetailRecord);
}else{
inserts.add(flowChartDetailRecord);
}
if(flowChartDetailRecord.getIsDelete() == null || flowChartDetailRecord.getIsDelete().intValue() == 0){
index++;
}
}
if(inserts.size() > 0){
flowChartDetailRecordService.insertFlowChartDetailRecords(inserts);
}
if(updaes.size() > 0){
flowChartDetailRecordService.updateBatchById(updaes);//.updateCoverFlowChartDetailRecordByIds(updaes);
}
}
if(inserts.size() > 0){
flowChartDetailRecordService.insertFlowChartDetailRecords(inserts);
}
if(updaes.size() > 0){
flowChartDetailRecordService.updateBatchById(updaes);//.updateCoverFlowChartDetailRecordByIds(updaes);
}
return R.ok();
}

View File

@ -40,16 +40,20 @@ public class ResultModelController {
public R getByGroupId(@RequestParam @ApiParam("考核组ID") Long id) {
//List<ResultModel> resultModels = resultModelService.selectResultModelByGroupId(id);
return R.ok().put("data",getResultModelDto(id));
}
private List<ResultModelDto> getResultModelDto(Long id){
List<ResultModelDto> resultModelDtos = resultModelService.selectResultDtoByGroupId(id);
for (ResultModelDto dto:resultModelDtos
) {
) {
List<ResultTagetLibDto> libDtos = resultTagetLibService.selectResultTagetLibByModelId(dto.getId());
dto.setTagetLibs(libDtos);
}
return R.ok().put("data",resultModelDtos);
return resultModelDtos;
}
@RequestMapping("/getById")
public R getById(@RequestBody ResultModel resultModel) {
resultModel = resultModelService.selectResultModelById(resultModel.getId());
@ -79,6 +83,8 @@ public class ResultModelController {
public R saveDetail(@RequestBody @ApiParam ResultModelDetailReq resultModelDetailReq) {
int resultModelOrderBy = 0;
for (ResultModelItemReq itemReq:
resultModelDetailReq.getModelItems()) {
@ -94,35 +100,38 @@ public class ResultModelController {
}else{
resultModelService.insertResultModel(resultModel);
}
int libOrderBy = 0;
List<ResultTagetLib> inserts = new ArrayList<>();
List<ResultTagetLib> updates = new ArrayList<>();
for (ResultTagetLibItemReq req:itemReq.getTagetLibItems()
) {
ResultTagetLib resultTagetLib = new ResultTagetLib();
BeanUtils.copyProperties(req, resultTagetLib);
resultTagetLib.setModelId(resultModel.getId());
resultTagetLib.setOrderBy(libOrderBy);
if(resultTagetLib.getId() != null && resultTagetLib.getId().intValue() > 0){
updates.add(resultTagetLib);
}else{
inserts.add(resultTagetLib);
if(itemReq.getTagetLibItems() != null){
int libOrderBy = 0;
List<ResultTagetLib> inserts = new ArrayList<>();
List<ResultTagetLib> updates = new ArrayList<>();
for (ResultTagetLibItemReq req:itemReq.getTagetLibItems()
) {
ResultTagetLib resultTagetLib = new ResultTagetLib();
BeanUtils.copyProperties(req, resultTagetLib);
resultTagetLib.setModelId(resultModel.getId());
resultTagetLib.setOrderBy(libOrderBy);
if(resultTagetLib.getId() != null && resultTagetLib.getId().intValue() > 0){
updates.add(resultTagetLib);
}else{
inserts.add(resultTagetLib);
}
if(resultTagetLib.getIsDelete() == null || resultTagetLib.getIsDelete().intValue() == 0){
libOrderBy++;
}
}
if(resultTagetLib.getIsDelete() == null || resultTagetLib.getIsDelete().intValue() == 0){
libOrderBy++;
if(inserts.size() > 0){
resultTagetLibService.insertResultTagetLibs(inserts);
}
if(updates.size() > 0){
resultTagetLibService.updateBatchById(updates);
}
}
if(inserts.size() > 0){
resultTagetLibService.insertResultTagetLibs(inserts);
}
if(updates.size() > 0){
resultTagetLibService.updateBatchById(updates);
if(resultModel.getIsDelete() == null || resultModel.getIsDelete().intValue() == 0){
resultModelOrderBy++;
}
}
if(resultModel.getIsDelete() == null || resultModel.getIsDelete().intValue() == 0){
resultModelOrderBy++;
}
}
return R.ok();

View File

@ -85,16 +85,18 @@
</update>
<insert id="insertEvaluationStartStaffs" parameterType="EvaluationStartStaff" useGeneratedKeys="true" keyProperty="id" >
insert into lz_evaluation_start_staff(
evaluation_id,
start_id,
staff_id,
type
<if test="item.evaluationId != null">evaluation_id, </if>
<if test="item.startId != null">start_id, </if>
<if test="item.staffId != null">staff_id, </if>
<if test="item.type != null">type, </if>
is_delete
)values
<foreach collection="list" item="item" separator="," open="(" close=")">
#{ item.evaluationId},
#{ item.startId},
#{ item.staffId},
#{ item.type}
<if test="item.evaluationId != null">#{ item.evaluationId}, </if>
<if test="item.startId != null">#{ item.startId}, </if>
<if test="item.staffId != null">#{ item.staffId}, </if>
<if test="item.type != null">#{ item.type}, </if>
0
</foreach>
</insert>

View File

@ -118,51 +118,55 @@
</select>
<insert id="insertFlowChartDetailRecords" parameterType="FlowChartDetailRecord" useGeneratedKeys="true" keyProperty="id" >
<foreach collection="list" item="item" separator=";">
insert into lz_flow_chart_detail_record(
chart_id,
evaluation_group_id,
status,
opt_ids,
opt_type,
role_ids,
step_type,
step_index,
weight
)values
<foreach collection="list" item="item" separator="," open="(" close=")">
#{ item.chartId},
#{ item.evaluationGroupId},
#{ item.status},
#{ item.optIds},
#{ item.optType},
#{ item.roleIds},
#{ item.stepType},
#{ item.stepIndex},
#{ item.weight}
<if test="chartId != null">chart_id, </if>
<if test="evaluationGroupId != null">evaluation_group_id, </if>
<if test="status != null">status, </if>
<if test="optIds != null">opt_ids, </if>
<if test="optType != null">opt_type, </if>
<if test="roleIds != null">role_ids, </if>
<if test="stepType != null">step_type, </if>
<if test="stepIndex != null">step_index, </if>
<if test="weight != null">weight, </if>
is_delete
)values(
<if test="chartId != null">#{ item.chartId}, </if>
<if test="evaluationGroupId != null">#{ item.evaluationGroupId}, </if>
<if test="status != null">#{ item.status}, </if>
<if test="optIds != null">#{ item.optIds}, </if>
<if test="optType != null">#{ item.optType}, </if>
<if test="roleIds != null">#{ item.roleIds}, </if>
<if test="stepType != null">#{ item.stepType}, </if>
<if test="stepIndex != null">#{ item.stepIndex}, </if>
<if test="weight != null">#{ item.weight}, </if>
0
)
</foreach>
</insert>
<insert id="updateCoverFlowChartDetailRecordByIds" parameterType="FlowChartDetailRecord" useGeneratedKeys="true" keyProperty="id" >
<update id="updateCoverFlowChartDetailRecordByIds" parameterType="FlowChartDetailRecord" useGeneratedKeys="true" keyProperty="id" >
<foreach collection="list" item="item" separator=";">
update
lz_flow_chart_detail_record
set
<if test="item.isDelete != null">is_delete = #{item.isDelete},</if>
chart_id = #{ item.chartId},
evaluation_group_id = #{ item.evaluationGroupId},
status = #{ item.status},
opt_ids = #{ item.optIds},
opt_type = #{ item.optType},
role_ids = #{ item.roleIds},
step_type = #{ item.stepType},
step_index = #{ item.stepIndex},
weight = #{ item.weight}
<if test="item.chartId != null">chart_id = #{ item.chartId},</if>
<if test="item.evaluationGroupId != null">evaluation_group_id = #{ item.evaluationGroupId},</if>
<if test="item.status != null">status = #{ item.status},</if>
<if test="item.optIds != null">opt_ids = #{ item.optIds},</if>
<if test="item.optType != null">opt_type = #{ item.optType},</if>
<if test="item.roleIds != null">role_ids = #{ item.roleIds},</if>
<if test="item.stepType != null">step_type = #{ item.stepType},</if>
<if test="item.stepIndex != null">step_index = #{ item.stepIndex},</if>
<if test="item.weight != null">weight = #{ item.weight}</if>
,gmt_modified = now()
where id = #{item.id}
</foreach>
;
</insert>
</update>
</mapper>

View File

@ -105,40 +105,43 @@
</update>
<insert id="insertResultTagetLibs" parameterType="FlowChartDetailRecord" useGeneratedKeys="true" keyProperty="id" >
<foreach collection="list" item="item" separator=";">
insert into lz_result_taget_lib(
name,
model_id,
weight,
key_result,
order_by
)values
<foreach collection="list" item="item" separator="," open="(" close=")">
<if test="item.name != null">name, </if>
<if test="item.modelId != null">model_id, </if>
<if test="item.weight != null">weight, </if>
<if test="item.keyResult != null">key_result, </if>
<if test="item.orderBy != null">order_by, </if>
is_delete
)values(
#{ item.name},
#{ item.modelId},
#{ item.weight},
#{ item.keyResult},
#{ item.orderBy}
<if test="item.name != null">#{ item.name}, </if>
<if test="item.modelId != null">#{ item.modelId}, </if>
<if test="item.weight != null">#{ item.weight}, </if>
<if test="item.keyResult != null">#{ item.keyResult}, </if>
<if test="item.orderBy != null">#{ item.orderBy},</if>
0
)
</foreach>
</insert>
<insert id="updateResultTagetLibByIds" parameterType="FlowChartDetailRecord" useGeneratedKeys="true" keyProperty="id" >
<update id="updateResultTagetLibByIds" parameterType="FlowChartDetailRecord" useGeneratedKeys="true" keyProperty="id" >
<foreach collection="list" item="item" separator=";">
update
lz_result_taget_lib
set
<if test="item.isDelete != null">is_delete = #{item.isDelete},</if>
name = #{item.name},
model_id = #{item.modelId},
weight = #{item.weight},
key_result = #{item.keyResult},
order_by = #{item.orderBy}
<if test="item.name != null">name = #{item.name},</if>
<if test="item.modelId != null">model_id = #{item.modelId},</if>
<if test="item.weight != null"> weight = #{item.weight},</if>
<if test="item.keyResult != null">key_result = #{item.keyResult},</if>
<if test="item.orderBy != null">order_by = #{item.orderBy}</if>
,gmt_modified = now()
where id = #{item.id}
</foreach>
;
</insert>
</update>
</mapper>