Commit 73c75df5 authored by kongfm's avatar kongfm

不存在值班数据则不查找 修改sql 方法去除 by kongfm 2021-09-14

parent 7419f974
......@@ -86,4 +86,23 @@ public interface DynamicFormInstanceMapper extends BaseMapper<DynamicFormInstanc
@Param("groupCode") String groupCode);
List<DynamicFormInstance> getInstanceByCodeAndValue(String code, String value);
/**
* 新分页查询带日期过滤// 不存在值班数据则不查找 修改sql 方法去除 by kongfm 2021-09-14
*
* @param page 分页信息
* @param appKey 应用
* @param fieldCodes 字段
* @param groupCode 表单类型
* @return IPage<Map < String, Object>>
*/
IPage<Map<String, Object>> pageListNew(
Page page,
@Param("appKey") String appKey,
@Param("fieldCodes") Map<String, Object> fieldCodes,
@Param("groupCode") String groupCode,
@Param("params") Map<String, String> params,
@Param("stratTime") String stratTime,
@Param("endTime") String endTime
);
}
......@@ -198,4 +198,61 @@
</if>
</where>
</select>
<!--不存在值班数据则不查找 修改sql 方法去除 by kongfm 2021-09-14-->
<select id="pageListNew" resultType="java.util.Map">
select
d.*
from
(
select
i.INSTANCE_ID instanceId,
i.GROUP_CODE groupCode,
<foreach collection="fieldCodes" item="value" index="key" separator=",">
MAX(CASE WHEN i.FIELD_CODE = #{key} THEN i.FIELD_VALUE END) as ${key},
IF(FIND_IN_SET(i.field_type,'radio,select,treeSelect'), MAX(CASE WHEN i.FIELD_CODE = #{key} THEN
i.FIELD_VALUE_LABEL END), null) as ${key}Label
</foreach>
from
cb_dynamic_form_instance i
where
i.GROUP_CODE = #{groupCode}
and i.is_delete = 0
<if test="appKey != null and appKey !=''">
and i.APP_KEY = #{appKey}
</if>
<foreach collection="params" index="key" item="value" separator="">
<if test="key != null and key == 'instanceIds' ">
and find_in_set(i.instance_id, #{value}) > 0
</if>
</foreach>
GROUP by
i.INSTANCE_ID) d
<if test="params != null and params.size() > 0">
where
d.instanceId in (
select tt.instance_id from cb_duty_person_shift tt where tt.duty_date >= #{stratTime}
and tt.duty_date <![CDATA[<=]]> #{endTime}
)
<foreach collection="params" index="key" item="value" separator="">
<choose>
<when test="fieldCodes[key] == 'like' and value !=null and value !=''">
and d.${key} like concat('%',#{value},'%')
</when>
<when test="fieldCodes[key] == 'eq' and value !=null and value !=''">
and d.${key} = #{value}
</when>
<when test="fieldCodes[key] == 'ge' and value !=null and value !=''">
and d.${key} >= #{value}
</when>
<when test="fieldCodes[key] == 'le' and value !=null and value !=''">
and d.${key} <![CDATA[<=]]> #{value}
</when>
</choose>
</foreach>
</if>
order by instanceId desc
</select>
</mapper>
......@@ -77,17 +77,13 @@ public class DutyCommonServiceImpl implements IDutyCommonService {
throws ParseException {
// 1.已column为准 进行返回
String groupCode = this.getGroupCode();
IPage<Map<String, Object>> iPage = dynamicFormInstanceService.pageList(current, size, groupCode);
// 不存在值班数据则不查找 修改sql 方法去除 by kongfm 2021-09-14
IPage<Map<String, Object>> iPage = dynamicFormInstanceService.pageListNew(current, size, groupCode, beginDate, endDate);
for (Map<String, Object> m : iPage.getRecords()) {
this.fillDutyShiftData(beginDate, endDate, m);
}
// BUG 2807 如果不存在值班数据则不显示
List<Map<String, Object>> list = iPage.getRecords();
list = list.stream().filter(m ->
m.get("dutyShift") != null && ((List<DutyPersonShiftDto>) m.get("dutyShift")).size() > 0
).collect(Collectors.toList());
iPage.setTotal(list.size());
iPage.setRecords(list);
// 不存在值班数据则不查找 修改sql 方法去除 by kongfm 2021-09-14
return iPage;
}
......
......@@ -132,6 +132,14 @@ public class DynamicFormInstanceServiceImpl extends BaseService<DynamicFormInsta
Page page = new Page(current, size);
return this.getBaseMapper().pageList(page, RequestContext.getAppKey(), fieldCodes, groupCode, params);
}
// 不存在值班数据则不查找 修改sql 方法去除 by kongfm 2021-09-14
public IPage<Map<String, Object>> pageListNew(int current, int size, String groupCode, String beginDate, String endDate) {
Map<String, String> params = this.getRequestParamMap();
List<DynamicFormColumn> columns = dynamicFormColumnService.list(new LambdaQueryWrapper<DynamicFormColumn>().eq(DynamicFormColumn::getGroupCode, groupCode));
Map<String, Object> fieldCodes = Bean.listToMap(columns, "fieldCode", "queryStrategy", DynamicFormColumn.class);
Page page = new Page(current, size);
return this.getBaseMapper().pageListNew(page, RequestContext.getAppKey(), fieldCodes, groupCode, params, beginDate, endDate);
}
public IPage<Map<String, Object>> pageList(int current, int size, String groupCode, Map<String, String> params) {
List<DynamicFormColumn> columns = dynamicFormColumnService.list(new LambdaQueryWrapper<DynamicFormColumn>().eq(DynamicFormColumn::getGroupCode, groupCode));
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment