|  |  | 
 |  |  | package com.doumee.biz.system.impl; | 
 |  |  |  | 
 |  |  | import com.alibaba.fastjson.JSONArray; | 
 |  |  | import com.alibaba.fastjson.JSONObject; | 
 |  |  | import com.doumee.biz.system.SystemDictDataBiz; | 
 |  |  | import com.doumee.core.constants.ResponseStatus; | 
 |  |  | import com.doumee.core.exception.BusinessException; | 
 |  |  | import com.doumee.core.model.LoginUserInfo; | 
 |  |  | import com.doumee.core.utils.Constants; | 
 |  |  | import com.doumee.dao.business.vo.UnitCodeVo; | 
 |  |  | import com.doumee.dao.system.model.SystemDict; | 
 |  |  | import com.doumee.dao.system.model.SystemDictData; | 
 |  |  | import com.doumee.service.system.SystemDictDataService; | 
 |  |  | 
 |  |  | import org.springframework.beans.factory.annotation.Autowired; | 
 |  |  | import org.springframework.stereotype.Service; | 
 |  |  |  | 
 |  |  | import java.util.Arrays; | 
 |  |  | import java.util.Date; | 
 |  |  | import java.util.List; | 
 |  |  | import java.util.Optional; | 
 |  |  | import java.util.*; | 
 |  |  |  | 
 |  |  | @Service | 
 |  |  | public class SystemDictDataBizImpl implements SystemDictDataBiz { | 
 |  |  | 
 |  |  |     public Integer create(SystemDictData systemDictData) { | 
 |  |  |         SystemDictData queryDto = new SystemDictData(); | 
 |  |  |         queryDto.setDictId(systemDictData.getDictId()); | 
 |  |  |         queryDto.setCode(systemDictData.getCode()); | 
 |  |  |         queryDto.setLabel(systemDictData.getLabel()); | 
 |  |  |         queryDto.setDeleted(Boolean.FALSE); | 
 |  |  |         SystemDictData dictData = systemDictDataService.findOne(queryDto); | 
 |  |  |         if (dictData != null) { | 
 |  |  |             throw new BusinessException(ResponseStatus.DATA_EXISTS.getCode(), "数据值已存在"); | 
 |  |  |             throw new BusinessException(ResponseStatus.DATA_EXISTS.getCode(), "数据标签已存在"); | 
 |  |  |         } | 
 |  |  |         return systemDictDataService.create(systemDictData); | 
 |  |  |     } | 
 |  |  | 
 |  |  |     public void updateById(SystemDictData systemDictData) { | 
 |  |  |         SystemDictData queryDto = new SystemDictData(); | 
 |  |  |         queryDto.setDictId(systemDictData.getDictId()); | 
 |  |  |         queryDto.setCode(systemDictData.getLabel()); | 
 |  |  |         queryDto.setLabel(systemDictData.getLabel()); | 
 |  |  |         queryDto.setDeleted(Boolean.FALSE); | 
 |  |  |         SystemDictData dictData = systemDictDataService.findOne(queryDto); | 
 |  |  |         if (dictData != null && !dictData.getId().equals(systemDictData.getId())) { | 
 |  |  |             throw new BusinessException(ResponseStatus.DATA_EXISTS.getCode(), "数据值已存在"); | 
 |  |  |             throw new BusinessException(ResponseStatus.DATA_EXISTS.getCode(), "数据标签已存在"); | 
 |  |  |         } | 
 |  |  |         systemDictDataService.updateById(systemDictData); | 
 |  |  |     } | 
 |  |  |  | 
 |  |  |  | 
 |  |  |     @Override | 
 |  |  |     public  String getUnitName(String unitCode, List<UnitCodeVo> unitCodeVoList) { | 
 |  |  |         if(unitCodeVoList!=null){ | 
 |  |  |             for(UnitCodeVo  c :unitCodeVoList){ | 
 |  |  |                 if(StringUtils.equals(c.getCode(),unitCode)){ | 
 |  |  |                     return  c.getName(); | 
 |  |  |                 } | 
 |  |  |             } | 
 |  |  |         } | 
 |  |  |         return null; | 
 |  |  |     } | 
 |  |  |     @Override | 
 |  |  |     public void updateByIdNew(SystemDictData systemDictData) { | 
 |  |  |         systemDictDataService.updateById(systemDictData); | 
 |  |  |     } | 
 |  |  |     @Override | 
 |  |  |     public   List<UnitCodeVo> getUnitList(){ | 
 |  |  |         List<UnitCodeVo> list = new ArrayList<>(); | 
 |  |  |         try { | 
 |  |  |             String  temp =  queryByCode(Constants.ZBOM,Constants.UNIT_CODE).getCode(); | 
 |  |  |             JSONArray array  = JSONObject.parseArray(temp); | 
 |  |  |             if(array!=null ){ | 
 |  |  |                 for (int i = 0; i < array.size(); i++) { | 
 |  |  |                     list.add(JSONObject.toJavaObject(array.getJSONObject(i),UnitCodeVo.class)); | 
 |  |  |                 } | 
 |  |  |             } | 
 |  |  |         }catch (Exception e){ | 
 |  |  |             e.printStackTrace(); | 
 |  |  |         } | 
 |  |  |         return list; | 
 |  |  |     } | 
 |  |  |  | 
 |  |  |     @Override | 
 |  |  |     public SystemDictData queryByCode(String dicCode, String label){ |