修复对判空的支持

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

View File

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

View File

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

View File

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

View File

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