对比新文件 |
| | |
| | | package com.iailab.module.report.framework.jmreport.core.service; |
| | | |
| | | import com.alibaba.fastjson.JSONObject; |
| | | import com.iailab.module.system.api.dict.DictDataApi; |
| | | import com.iailab.module.system.api.dict.dto.DictDataRespDTO; |
| | | import lombok.extern.slf4j.Slf4j; |
| | | import org.apache.commons.lang3.ObjectUtils; |
| | | import org.jeecg.modules.drag.service.IOnlDragExternalService; |
| | | import org.jeecg.modules.drag.vo.DragDictModel; |
| | | import org.jeecg.modules.drag.vo.DragLogDTO; |
| | | import org.slf4j.Logger; |
| | | import org.slf4j.LoggerFactory; |
| | | import org.springframework.beans.BeanUtils; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.context.annotation.Lazy; |
| | | import org.springframework.stereotype.Service; |
| | | import org.springframework.util.CollectionUtils; |
| | | |
| | | import javax.annotation.Resource; |
| | | import java.util.ArrayList; |
| | | import java.util.HashMap; |
| | | import java.util.List; |
| | | import java.util.Map; |
| | | |
| | | /** |
| | | * @Description: 字典处理 |
| | | * @Author: lsq |
| | | * @Date:2023-01-09 |
| | | * @Version:V1.0 |
| | | */ |
| | | @Slf4j |
| | | @Service("onlDragExternalServiceImpl") |
| | | public class JmDragExternalServiceImpl implements IOnlDragExternalService { |
| | | |
| | | private static Logger logger = LoggerFactory.getLogger(JmDragExternalServiceImpl.class); |
| | | |
| | | @Lazy |
| | | @Resource |
| | | private DictDataApi dictDataApi; |
| | | /** |
| | | * 根据多个字典code查询多个字典项 |
| | | * @param codeList |
| | | * @return key = dictCode ; value=对应的字典项 |
| | | */ |
| | | @Override |
| | | public Map<String, List<DragDictModel>> getManyDictItems(List<String> codeList, List<JSONObject> tableDictList) { |
| | | Map<String, List<DragDictModel>> manyDragDictItems = new HashMap<>(); |
| | | if(!CollectionUtils.isEmpty(codeList)){ |
| | | Map<String, List<DictDataRespDTO>> dictItemsMap = new HashMap<>(); |
| | | // Map<String, List<DictDataRespDTO>> dictItemsMap = dictDataApi.getManyDictItems(codeList); |
| | | dictItemsMap.forEach((k,v)->{ |
| | | List<DragDictModel> dictItems = new ArrayList<>(); |
| | | v.forEach(dictItem->{ |
| | | DragDictModel dictModel = new DragDictModel(); |
| | | BeanUtils.copyProperties(dictItem,dictModel); |
| | | dictItems.add(dictModel); |
| | | }); |
| | | manyDragDictItems.put(k,dictItems); |
| | | }); |
| | | } |
| | | |
| | | if(!CollectionUtils.isEmpty(tableDictList)){ |
| | | tableDictList.forEach(item->{ |
| | | List<DragDictModel> dictItems = new ArrayList<>(); |
| | | JSONObject object = JSONObject.parseObject(item.toString()); |
| | | String dictField = object.getString("dictField"); |
| | | String dictTable = object.getString("dictTable"); |
| | | String dictText = object.getString("dictText"); |
| | | String fieldName = object.getString("fieldName"); |
| | | List<DictDataRespDTO> dictItemsList = new ArrayList<>(); |
| | | // List<DictDataRespDTO> dictItemsList = dictDataApi.queryTableDictItemsByCode(dictTable,dictText,dictField); |
| | | dictItemsList.forEach(dictItem->{ |
| | | DragDictModel dictModel = new DragDictModel(); |
| | | BeanUtils.copyProperties(dictItem,dictModel); |
| | | dictItems.add(dictModel); |
| | | }); |
| | | manyDragDictItems.put(fieldName,dictItems); |
| | | }); |
| | | } |
| | | return manyDragDictItems; |
| | | } |
| | | |
| | | /** |
| | | * |
| | | * @param dictCode |
| | | * @return |
| | | */ |
| | | @Override |
| | | public List<DragDictModel> getDictItems(String dictCode) { |
| | | List<DragDictModel> dictItems = new ArrayList<>(); |
| | | if(ObjectUtils.isNotEmpty(dictCode)){ |
| | | List<DictDataRespDTO> dictItemsList = dictDataApi.getDictDataList(dictCode).getData(); |
| | | dictItemsList.forEach(dictItem->{ |
| | | DragDictModel dictModel = new DragDictModel(); |
| | | BeanUtils.copyProperties(dictItem,dictModel); |
| | | dictItems.add(dictModel); |
| | | }); |
| | | } |
| | | return dictItems; |
| | | } |
| | | |
| | | /** |
| | | * 添加日志 |
| | | * @param dragLogDTO |
| | | */ |
| | | @Override |
| | | public void addLog(DragLogDTO dragLogDTO) { |
| | | if(ObjectUtils.isNotEmpty(dragLogDTO)){ |
| | | logger.info(dragLogDTO.toString()); |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * 保存日志 |
| | | * @param logMsg |
| | | * @param logType |
| | | * @param operateType |
| | | */ |
| | | @Override |
| | | public void addLog(String logMsg, int logType, int operateType) { |
| | | logger.info(logMsg,logType,operateType); |
| | | } |
| | | } |