| | |
| | | import com.vci.ubcs.system.entity.MdmCountConfig; |
| | | import com.vci.ubcs.system.mapper.MdmCountConfigMapper; |
| | | import com.vci.ubcs.system.service.IMdmCountConfigService; |
| | | import com.vci.ubcs.system.vo.MdmCountConfigVO; |
| | | import org.springblade.core.log.exception.ServiceException; |
| | | import org.springblade.core.secure.utils.AuthUtil; |
| | | import org.springblade.core.tool.api.R; |
| | | import org.springblade.core.tool.utils.Func; |
| | | import org.springframework.stereotype.Service; |
| | | |
| | | import javax.annotation.Resource; |
| | | import java.sql.Wrapper; |
| | | import java.util.Date; |
| | | import java.util.stream.Collectors; |
| | | |
| | | /** |
| | | * 主数据统计首页配置服务 |
| | |
| | | @Service |
| | | public class MdmCountConfigServiceImpl extends ServiceImpl<MdmCountConfigMapper, MdmCountConfig> implements IMdmCountConfigService { |
| | | |
| | | /** |
| | | * 保存用户配置的主数据统计项 |
| | | * @param mdmCountConfigVO |
| | | * @return |
| | | */ |
| | | @Override |
| | | public boolean saveMdmCountConfig(MdmCountConfig mdmCountConfig) throws ServiceException{ |
| | | if(Func.isEmpty(mdmCountConfig) || Func.isBlank(mdmCountConfig.getUserId().toString())){ |
| | | public R saveMdmCountConfig(MdmCountConfigVO mdmCountConfigVO) throws ServiceException{ |
| | | if(Func.isEmpty(mdmCountConfigVO) || Func.isBlank(mdmCountConfigVO.getUserId().toString())){ |
| | | throw new ServiceException("主数据统计配置保存时缺少必填参数!"); |
| | | } |
| | | if(mdmCountConfigVO.getMdmNameList().isEmpty()) { |
| | | return R.status(false); |
| | | } |
| | | if(mdmCountConfigVO.getMdmNameList().size() > 7){ |
| | | return R.fail("显示的主数据配置项最多为8项"); |
| | | } |
| | | boolean res = false; |
| | | try { |
| | | MdmCountConfig mdmCountConfigDB = getMdmCountConfig(mdmCountConfig.getUserId().toString()); |
| | | String mdmNames = mdmCountConfigVO.getMdmNameList().stream().collect(Collectors.joining(",")); |
| | | MdmCountConfig mdmCountConfigDB = getMdmCountConfig(mdmCountConfigVO.getUserId().toString()); |
| | | MdmCountConfig mdmCountConfig = new MdmCountConfig(); |
| | | //新增 |
| | | if(Func.isBlank(mdmCountConfig.getId().toString())){ |
| | | Func.copy(mdmCountConfig,mdmCountConfigDB); |
| | | if(Func.isEmpty(mdmCountConfigDB)){ |
| | | mdmCountConfig.setUserId(mdmCountConfigVO.getUserId()); |
| | | }else { |
| | | //修改 |
| | | mdmCountConfigDB.setMdmName(mdmCountConfig.getMdmName()); |
| | | Func.copy(mdmCountConfigDB,mdmCountConfig); |
| | | } |
| | | res = this.saveOrUpdate(mdmCountConfigDB); |
| | | mdmCountConfig.setMdmName(mdmNames); |
| | | res = this.saveOrUpdate(mdmCountConfig); |
| | | }catch (Exception e){ |
| | | throw new ServiceException("配置保存失败,原因:"+e.getCause()); |
| | | } |
| | | return res; |
| | | return R.status(res); |
| | | } |
| | | |
| | | /** |
| | | * 获取当前用户有那些主数据统计配置在首页 |
| | | * @param userId |
| | | * @return |
| | | */ |
| | | @Override |
| | | public MdmCountConfig getMdmCountConfig(String userId) { |
| | | LambdaQueryWrapper<MdmCountConfig> wrapper = Wrappers.<MdmCountConfig>query(). |