文档库--编辑时,代替标准和被代替标准处理

This commit is contained in:
zhn
2022-03-01 15:55:01 +08:00
parent ace2989e51
commit 877d467713
3 changed files with 108 additions and 29 deletions
@@ -68,4 +68,14 @@ public interface BussDocumentLibraryEOMapper extends BaseMapper<BussDocumentLibr
@Param("condition") String condition);
/**
* 根据代替标准列表查询
*
* @param
* @param replaceStandard
* @return
*/
List<Map<String, Object>> getInfoListByReplaceStandard(@Param("replaceStandard") String replaceStandard);
}
@@ -59,5 +59,16 @@
select ${field}
${condition}
</select>
<!--根据代替标准列表查询-->
<select id="getInfoListByReplaceStandard" resultType="java.util.LinkedHashMap">
select * from buss_document_library
where 1=1
<if test="replaceStandard != null" >
and replace_standard in
<foreach collection="replaceStandard.split(',')" index="index" item="item" open="(" separator="," close=")">
#{item}
</foreach>
</if>
</select>
</mapper>
@@ -279,6 +279,36 @@ public class BussDocumentLibraryEOServiceImpl extends ServiceImpl<BussDocumentLi
queryWrapper.eq(BussDocumentLibraryEO::getId, id);
//通过id查询数据
List<Map<String, Object>> dataList = bussDocumentLibraryEOMapper.selectMaps(queryWrapper);
//处理被代替标准
//查询所有
List<Map<String, Object>> mapList = bussDocumentLibraryEOMapper.selectMaps(null);
List<String> replaceStandardNameList = new ArrayList<>();
for (Map<String, Object> map : mapList) {
//代替标准
String replaceStandard = (String) map.get("replace_standard");
if(StringUtils.isNotBlank(replaceStandard) && replaceStandard.contains(id)){
String serialNumber = (String) map.get("serial_number");
replaceStandardNameList.add(serialNumber);
}
}
if(replaceStandardNameList.size() != 0){
dataList.get(0).put("replaced_standard",StringUtils.join(replaceStandardNameList,","));
}
//代替标准中文
String replaceStandard = (String) dataList.get(0).get("replace_standard");
if(StringUtils.isNotBlank(replaceStandard)){
LambdaQueryWrapper<BussDocumentLibraryEO> queryWrapperTemp = new LambdaQueryWrapper<>();
queryWrapperTemp.in(BussDocumentLibraryEO::getId, Arrays.asList(replaceStandard.split(",")));
List<Map<String, Object>> dataListTemp = bussDocumentLibraryEOMapper.selectMaps(queryWrapperTemp);
if(dataListTemp.size()!= 0){
List<String> replaceStandardListNew = new ArrayList<>();
for (Map<String, Object> map : dataListTemp) {
replaceStandardListNew.add((String) map.get("serial_number"));
}
dataList.get(0).put("replace_standard",StringUtils.join(replaceStandardListNew,","));
dataList.get(0).put("replace_standard_id",replaceStandard);
}
}
return dataList;
}
@@ -290,6 +320,14 @@ public class BussDocumentLibraryEOServiceImpl extends ServiceImpl<BussDocumentLi
*/
@Override
public List<Map<String, Object>> getInfoById(String id, String cut) {
//处理被代替标准
//根据代替标准查询被代替标准集合
List<Map<String, Object>> replaceStandardList = bussDocumentLibraryEOMapper.getInfoListByReplaceStandard(id);
List<String> replaceStandardNameList = new ArrayList<>();
for (Map<String, Object> map : replaceStandardList) {
String serialNumber = (String) map.get("serial_number");
replaceStandardNameList.add(serialNumber);
}
//区域管理
List<OnlCgformArea> areaList = onlCgformAreaServiceImpl.queryList(new OnlCgformArea());
//字段属性
@@ -369,7 +407,11 @@ public class BussDocumentLibraryEOServiceImpl extends ServiceImpl<BussDocumentLi
if (dataList.size() != 0) {
dataList.get(0).entrySet().forEach(entry -> {
if (onlCgformField.getDbFieldName().equals(entry.getKey())) {
map.put("value", entry.getValue());
if(onlCgformField.getDbFieldName().equals("replaced_standard")){
map.put("value", StringUtils.join(replaceStandardNameList,","));
}else{
map.put("value", entry.getValue());
}
}
});
}
@@ -407,9 +449,14 @@ public class BussDocumentLibraryEOServiceImpl extends ServiceImpl<BussDocumentLi
* @param map
*/
public void addInfo(Map<String, Object> map) {
if(ObjectUtils.isNotEmpty(map.get("replace_standard_id"))){
map.put("replace_standard",map.get("replace_standard_id"));
}
//代替标准不为空,需要向被替代标准的法规工程师发送站内通知和飞书信息,提醒内容:"新标准编号"已实施,请注意更新“替代标准编号”状态
map.remove("cut");
map.remove("replace_standard_id");
//字段属性
List<OnlCgformField> fieldList = onlCgformFieldService.getFieldList(ModuleEnum.DOCUMENT_LIBRARY.getValue());
//时间类型字段
@@ -475,8 +522,11 @@ public class BussDocumentLibraryEOServiceImpl extends ServiceImpl<BussDocumentLi
* @param map
*/
public void updateInfo(Map<String, Object> map) {
if(ObjectUtils.isNotEmpty(map.get("replace_standard_id"))){
map.put("replace_standard",map.get("replace_standard_id"));
}
map.remove("cut");
map.remove("replace_standard_id");
//字段属性
List<OnlCgformField> fieldList = onlCgformFieldService.getFieldList(ModuleEnum.DOCUMENT_LIBRARY.getValue());
//时间类型字段
@@ -548,7 +598,12 @@ public class BussDocumentLibraryEOServiceImpl extends ServiceImpl<BussDocumentLi
}
} else {
valuesBuilder.append("'" + value + "'" + ",");
//编辑时replaced_standard被代替标准不存值,通过查询得到
if("replaced_standard".equals(key)){
valuesBuilder.append("'" + "" + "'" + ",");
}else{
valuesBuilder.append("'" + value + "'" + ",");
}
}
}
fieldsBuilder.append(key + ",");
@@ -969,38 +1024,41 @@ public class BussDocumentLibraryEOServiceImpl extends ServiceImpl<BussDocumentLi
//查询条件处理
for (Map.Entry<String, Object> entry : parameter.entrySet()) {
String key = entry.getKey();
String value = (String) entry.getValue();
if (StringUtils.isNotBlank(value)) {
for (Map<String, Object> map : mapList) {
String fieldName = (String) map.get("db_field_name");//字段
if (key.equals(fieldName)) {
//字段类型(判断是输入框还是下拉,等等)
String fieldType = (String) map.get("field_show_type");//字段类型
if (FieldTypeEnum.TEXT_STRING.getValue().equals(fieldType)) {
//输入框
conditionSb.append(" and " + key + " like concat(concat('%','" + value + "'),'%')");
} else if (FieldTypeEnum.PULL_SINGLE.getValue().equals(fieldType)
|| FieldTypeEnum.PULL_MORE.getValue().equals(fieldType)) {
StringBuilder valueSb = new StringBuilder();
for (String valueTemp : value.split(",")) {
valueSb.append("'" + valueTemp + "',");
}
String substring = valueSb.substring(0, valueSb.length() - 1);
//下拉单选或下拉多选
conditionSb.append(" and " + key + " in(" + substring + ")");
if(!"pageNo".equals(key) && !"pageSize".equals(key)){
String value = (String) entry.getValue();
if (StringUtils.isNotBlank(value)) {
for (Map<String, Object> map : mapList) {
String fieldName = (String) map.get("db_field_name");//字段
if (key.equals(fieldName)) {
//字段类型(判断是输入框还是下拉,等等)
String fieldType = (String) map.get("field_show_type");//字段类型
if (FieldTypeEnum.TEXT_STRING.getValue().equals(fieldType)) {
//输入框
conditionSb.append(" and " + key + " like concat(concat('%','" + value + "'),'%')");
} else if (FieldTypeEnum.PULL_SINGLE.getValue().equals(fieldType)
|| FieldTypeEnum.PULL_MORE.getValue().equals(fieldType)) {
StringBuilder valueSb = new StringBuilder();
for (String valueTemp : value.split(",")) {
valueSb.append("'" + valueTemp + "',");
}
String substring = valueSb.substring(0, valueSb.length() - 1);
//下拉单选或下拉多选
conditionSb.append(" and " + key + " in(" + substring + ")");
} else if (FieldTypeEnum.DATE_SINGLE.getValue().equals(fieldType)) {
//日期(区分单日期还时间范围)
if (value.contains(",")) {
conditionSb.append(" and " + "date_format(" + key + ",'%Y-%m-%d') >= '" + value.split(",")[0] + "'"
+ " and " + "date_format(" + key + ",'%Y-%m-%d') <= '" + value.split(",")[1] + "'");
} else {
conditionSb.append(" and " + "date_format(" + key + ",'%Y-%m-%d') = '" + value + "'");
} else if (FieldTypeEnum.DATE_SINGLE.getValue().equals(fieldType)) {
//日期(区分单日期还时间范围)
if (value.contains(",")) {
conditionSb.append(" and " + "date_format(" + key + ",'%Y-%m-%d') >= '" + value.split(",")[0] + "'"
+ " and " + "date_format(" + key + ",'%Y-%m-%d') <= '" + value.split(",")[1] + "'");
} else {
conditionSb.append(" and " + "date_format(" + key + ",'%Y-%m-%d') = '" + value + "'");
}
}
}
}
}
}
}
//处理列表表头排序
if (StringUtils.isNotBlank((String) parameter.get("orderByField"))) {