Merge remote-tracking branch 'origin/master'

This commit is contained in:
wangzhijiang
2022-03-02 15:34:52 +08:00
25 changed files with 1103 additions and 224 deletions
@@ -123,7 +123,7 @@
<select id="getFieldList" resultType="com.jero.generater.modules.online.cgform.entity.OnlCgformField">
select * from onl_cgform_field ocf
left join onl_cgform_head och on ocf.cgform_head_id = och.id
where table_name =#{tableName} and is_delete = 0
where table_name =#{tableName} and ocf.is_delete = 0
order by order_num asc
</select>
@@ -183,6 +183,19 @@ public class SysDictController {
return Result.OK(res);
}
/**
* 获取全部字典数据(中英文切换)
*
* @return
*/
@ApiOperation(value = "字典控制器-获取全部字典数据", notes = "字典控制器-获取全部字典数据")
@RequestMapping(value = "/queryAllDictItemsByCut", method = RequestMethod.GET)
public Result<?> queryAllDictItemsByCut(HttpServletRequest request,String cut) {
Map<String, List<DictModel>> res = new HashMap<String, List<DictModel>>();
res = sysDictService.queryAllDictItemsByCut(cut);
return Result.OK(res);
}
/**
* 获取字典数据
* @param dictCode
@@ -23,6 +23,7 @@ public interface ISysDictService extends IService<SysDict> {
public List<DictModel> queryDictItemsByCode(String code);
public Map<String,List<DictModel>> queryAllDictItems();
public Map<String,List<DictModel>> queryAllDictItemsByCut(String cut);
@Deprecated
List<DictModel> queryTableDictItemsByCode(String table, String text, String code);
@@ -7,6 +7,7 @@ import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.jero.common.constant.CacheConstant;
import com.jero.common.constant.CommonConstant;
import com.jero.common.constant.enums.CutEnum;
import com.jero.common.system.vo.DictModel;
import com.jero.common.system.vo.DictQuery;
import com.jero.common.util.oConvertUtils;
@@ -88,6 +89,31 @@ public class SysDictServiceImpl extends ServiceImpl<SysDictMapper, SysDict> impl
return res;
}
@Override
public Map<String, List<DictModel>> queryAllDictItemsByCut(String cut) {
Map<String, List<DictModel>> res = new HashMap<String, List<DictModel>>();
List<SysDict> ls = sysDictMapper.selectList(null);
LambdaQueryWrapper<SysDictItem> queryWrapper = new LambdaQueryWrapper<SysDictItem>();
queryWrapper.eq(SysDictItem::getStatus, 1);
queryWrapper.orderByAsc(SysDictItem::getSortOrder);
List<SysDictItem> sysDictItemList = sysDictItemMapper.selectList(queryWrapper);
for (SysDict d : ls) {
List<DictModel> dictModelList = sysDictItemList.stream().filter(s -> d.getId().equals(s.getDictId())).map(item -> {
DictModel dictModel = new DictModel();
if(CutEnum.CN.getValue().equals(cut)){
dictModel.setText(item.getItemText());
}else{
dictModel.setText(item.getEnName());
}
dictModel.setValue(item.getItemValue());
return dictModel;
}).collect(Collectors.toList());
res.put(d.getDictCode(), dictModelList);
}
log.debug("-------登录加载系统字典-----" + res.toString());
return res;
}
/**
* 通过查询指定code 获取字典值text
* @param code
@@ -419,7 +419,7 @@ public class BussDocumentLibraryEOServiceImpl extends ServiceImpl<BussDocumentLi
dataList.get(0).entrySet().forEach(entry -> {
if (fieldPullList.contains(entry.getKey())) {
//下拉选处理数据字典
dictItem(sysDictItems, entry, onlCgformFieldList);
dictItem(sysDictItems, entry, onlCgformFieldList,cut);
}
});
@@ -614,6 +614,7 @@ public class BussDocumentLibraryEOServiceImpl extends ServiceImpl<BussDocumentLi
* @param map
*/
public void updateInfo(Map<String, Object> map) {
String cut = (String) map.get("cut");
if (ObjectUtils.isNotEmpty(map.get("replace_standard_id"))) {
map.put("replace_standard", map.get("replace_standard_id"));
}
@@ -642,7 +643,7 @@ public class BussDocumentLibraryEOServiceImpl extends ServiceImpl<BussDocumentLi
queryWrapper.eq(BussDocumentLibraryEO::getId, id);
List<Map<String, Object>> dataList = bussDocumentLibraryEOMapper.selectMaps(queryWrapper);
//更新log
updateLog(map, dataList, fieldList, fieldDateList, fieldFileList, fieldPullList);
updateLog(map, dataList, fieldList, fieldDateList, fieldFileList, fieldPullList,cut);
//判断该条数据是否订阅
@@ -742,7 +743,8 @@ public class BussDocumentLibraryEOServiceImpl extends ServiceImpl<BussDocumentLi
List<OnlCgformField> fieldList,
List<OnlCgformField> fieldDateList,
List<OnlCgformField> fieldFileList,
List<OnlCgformField> fieldPullList) {
List<OnlCgformField> fieldPullList,
String cut) {
Map<String, Object> mapTemp = new HashMap<>();
mapCopy(map, mapTemp);
//时间类型的字段
@@ -760,14 +762,14 @@ public class BussDocumentLibraryEOServiceImpl extends ServiceImpl<BussDocumentLi
.filter(e -> entry.getKey().equals(e.getDictField()))
.collect(Collectors.toList());
//下拉选处理数据字典
dictItem(sysDictItems, entry, collect);
dictItem(sysDictItems, entry, collect,cut);
}
for (Map.Entry<String, Object> entry : mapTemp.entrySet()) {
List<OnlCgformField> collect = fieldPullList.stream()
.filter(e -> entry.getKey().equals(e.getDictField()))
.collect(Collectors.toList());
//下拉选处理数据字典
dictItem(sysDictItems, entry, collect);
dictItem(sysDictItems, entry, collect,cut);
}
StringBuilder sb = new StringBuilder();
@@ -992,7 +994,7 @@ public class BussDocumentLibraryEOServiceImpl extends ServiceImpl<BussDocumentLi
}
String fieldStr = fieldSb.substring(0, fieldSb.length() - 1);
String field = " bdl.id,bdl.serial_number,bdl.title,bdl.state,of.file_name,of.connect_id," + fieldStr
String field = " of.id,bdl.serial_number,bdl.title,bdl.state,of.file_name,of.connect_id," + fieldStr
+ " from oss_file of join buss_document_library bdl" + join.toString();
//查询条件
@@ -1058,6 +1060,7 @@ public class BussDocumentLibraryEOServiceImpl extends ServiceImpl<BussDocumentLi
}
public IPage getInfoPage(Map<String, Object> parameter) {
String cut = (String) parameter.get("cut");//中英文切换标识
//需要查询的字段
List<OnlCgformField> fieldList = onlCgformFieldService.getFieldList("1");
if (fieldList.size() != 0) {
@@ -1100,7 +1103,7 @@ public class BussDocumentLibraryEOServiceImpl extends ServiceImpl<BussDocumentLi
.filter(e -> entry.getKey().equals(e.getDictField()))
.collect(Collectors.toList());
//下拉选处理数据字典
dictItem(sysDictItems, entry, collect);
dictItem(sysDictItems, entry, collect,cut);
}
}
//收藏和订阅
@@ -1218,13 +1221,14 @@ public class BussDocumentLibraryEOServiceImpl extends ServiceImpl<BussDocumentLi
* @param entry
* @param collect
*/
private void dictItem(List<SysDictItem> sysDictItems, Map.Entry<String, Object> entry, List<OnlCgformField> collect) {
private void dictItem(List<SysDictItem> sysDictItems, Map.Entry<String, Object> entry, List<OnlCgformField> collect,String cut) {
Map<String, Object> map = new HashMap<>();
//通过dictField判断字段是否为下拉选(不为空则为下拉选)
if (collect.size() != 0 && StringUtils.isNotBlank(collect.get(0).getDictField())) {
String value = (String) entry.getValue();
//数据字典中文
List<String> dictItemsCh = new ArrayList<>();
List<String> dictItemsEn = new ArrayList<>();
if (StringUtils.isNotBlank(value)) {
for (String itemValue : value.split(",")) {
//字段的数据字典
@@ -1236,13 +1240,23 @@ public class BussDocumentLibraryEOServiceImpl extends ServiceImpl<BussDocumentLi
.filter(e -> itemValue.equals(e.getItemValue()))
.collect(Collectors.toList());
if (dictItems.size() != 0) {
List<String> itemText = dictItems.stream().map(SysDictItem::getItemText).collect(Collectors.toList());
List<String> itemText = new ArrayList<>();
if(CutEnum.CN.getValue().equals(cut)){
itemText = dictItems.stream().map(SysDictItem::getItemText).collect(Collectors.toList());
}else {
itemText = dictItems.stream().map(SysDictItem::getEnName).collect(Collectors.toList());
}
dictItemsCh.addAll(itemText);
dictItemsEn.addAll(itemText);
}
}
}
}
entry.setValue(StringUtils.join(dictItemsCh, ","));
if(CutEnum.CN.getValue().equals(cut)){
entry.setValue(StringUtils.join(dictItemsCh, ","));
}else{
entry.setValue(StringUtils.join(dictItemsEn, ","));
}
}
}
@@ -1330,6 +1344,7 @@ public class BussDocumentLibraryEOServiceImpl extends ServiceImpl<BussDocumentLi
*/
@Override
public void exportExcel(Map<String, Object> map, HttpServletResponse response, HttpServletRequest request) {
String cut = (String) map.get("cut");
//String flag = "file"为带文件导出标识
String flag = (String) map.get("flag");
// String flag = "file";
@@ -1359,8 +1374,11 @@ public class BussDocumentLibraryEOServiceImpl extends ServiceImpl<BussDocumentLi
if (!"file".equals(flag)) {
fieldListTemp = fieldListTemp.stream().filter(e -> !FieldTypeEnum.FILE.getValue().equals(e.getFieldShowType())).collect(Collectors.toList());
}
headerFieldList = fieldListTemp.stream().map(OnlCgformField::getDbFieldTxt).collect(Collectors.toList());
if(CutEnum.CN.getValue().equals(cut)){
headerFieldList = fieldListTemp.stream().map(OnlCgformField::getDbFieldTxt).collect(Collectors.toList());
}else{
headerFieldList = fieldListTemp.stream().map(OnlCgformField::getDbFieldEnName).collect(Collectors.toList());
}
}
//查询字段
List<String> conditionFieldList = fieldList.stream().map(OnlCgformField::getDbFieldName).collect(Collectors.toList());
@@ -1368,6 +1386,8 @@ public class BussDocumentLibraryEOServiceImpl extends ServiceImpl<BussDocumentLi
String condition = getConditionStr(map);
//导出数据(全部导出的数据)
List<Map<String, Object>> datas = bussDocumentLibraryEOMapper.getInfoList(" " + StringUtils.join(conditionFieldList, ","), condition);
//处理对应标准,代替标准,被代替标准(由id转中文)
getStandard(datas);
//部分导出
String partId = (String) map.get("id");
if (StringUtils.isNotBlank(partId)) {
@@ -1380,7 +1400,7 @@ public class BussDocumentLibraryEOServiceImpl extends ServiceImpl<BussDocumentLi
String header = StringUtils.join(headerFieldList, ",");
createHeader(workbook, sheet, header);
// 创建数据
createDatas(workbook, sheet, datas, header, fieldListTemp);
createDatas(workbook, sheet, datas, header, fieldListTemp,cut);
if (!"file".equals(flag)) {
//不带文件导出
@@ -1453,7 +1473,58 @@ public class BussDocumentLibraryEOServiceImpl extends ServiceImpl<BussDocumentLi
}
}
public void createDatas(Workbook workbook, Sheet sheet, List<Map<String, Object>> datas, String header, List<OnlCgformField> fieldList) {
/**
* 处理对应标准,代替标准,被代替标准(由id转中文)
* @param datas
*/
private void getStandard(List<Map<String, Object>> datas) {
List<Map<String, Object>> datasTemp = new ArrayList<>();
for (Map<String, Object> data : datas) {
Map<String,Object> mapTemp = new HashMap<>();
mapCopy(data,mapTemp);
datasTemp.add(mapTemp);
}
for (Map<String, Object> data : datas) {
String idTemp = (String) data.get("id");
String correspondingStandard = (String) data.get("corresponding_standard");
String replaceStandard = (String) data.get("replace_standard");
StringBuilder correspondingStandardSb = new StringBuilder();
StringBuilder replaceStandardSb = new StringBuilder();
StringBuilder replacedStandardSb = new StringBuilder();
datasTemp.forEach(entry->{
String id = (String) entry.get("id");
String replaceStandardTemp = (String) entry.get("replace_standard");
//对应标准
if(StringUtils.isNotBlank(correspondingStandard) && correspondingStandard.contains(id)){
correspondingStandardSb.append((String) entry.get("serial_number")+",");
}
//代替标准
if(StringUtils.isNotBlank(replaceStandard) && replaceStandard.contains(id)){
replaceStandardSb.append((String) entry.get("serial_number")+",");
}
//被代替标准
if(StringUtils.isNotBlank(replaceStandardTemp) && replaceStandardTemp.contains(idTemp)){
replacedStandardSb.append((String) entry.get("serial_number")+",");
}
});
//对应标准
if(StringUtils.isNotBlank(correspondingStandardSb)){
String correspondingStandardStr = correspondingStandardSb.substring(0, correspondingStandardSb.length() - 1);
data.put("corresponding_standard",correspondingStandardStr);
}
//代替标准
if(StringUtils.isNotBlank(replaceStandardSb)){
String replaceStandardStr = replaceStandardSb.substring(0, replaceStandardSb.length() - 1);
data.put("replace_standard",replaceStandardStr);
}
if(StringUtils.isNotBlank(replacedStandardSb)){
String replacedStandardStr = replacedStandardSb.substring(0, replacedStandardSb.length() - 1);
data.put("replaced_standard",replacedStandardStr);
}
}
}
public void createDatas(Workbook workbook, Sheet sheet, List<Map<String, Object>> datas, String header, List<OnlCgformField> fieldList,String cut) {
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
CellStyle cellStyle = workbook.createCellStyle();//初始化单元格格式对象
cellStyle.setAlignment(HorizontalAlignment.CENTER);
@@ -1485,7 +1556,7 @@ public class BussDocumentLibraryEOServiceImpl extends ServiceImpl<BussDocumentLi
.filter(e -> entry.getKey().equals(e.getDictField()))
.collect(Collectors.toList());
//下拉选处理数据字典
dictItem(sysDictItems, entry, collect);
dictItem(sysDictItems, entry, collect,cut);
}
Row row = sheet.createRow(i + 1);
i++;