/* * Copyright (c) 2018-2028, Chill Zhuang All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * * Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * Neither the name of the dreamlu.net developer nor the names of its * contributors may be used to endorse or promote products derived from * this software without specific prior written permission. * Author: Chill 庄骞 (smallchill@163.com) */ package org.sxkj.gd.implement.service.impl; import com.baomidou.mybatisplus.core.conditions.Wrapper; import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; import com.baomidou.mybatisplus.core.metadata.IPage; import com.baomidou.mybatisplus.core.toolkit.Wrappers; import lombok.AllArgsConstructor; import org.jetbrains.annotations.NotNull; import org.springblade.core.mp.base.BaseServiceImpl; import org.springblade.core.mp.support.Condition; import org.springblade.core.secure.utils.AuthUtil; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; import org.sxkj.gd.common.GenericConverter; import org.sxkj.gd.common.IdParam; import org.sxkj.gd.implement.entity.GdImplementListEntity; import org.sxkj.gd.implement.entity.GdThingListMaterialRelEntity; import org.sxkj.gd.implement.excel.GdImplementListExcel; import org.sxkj.gd.implement.mapper.GdImplementListMapper; import org.sxkj.gd.implement.param.GdImplementListPageParam; import org.sxkj.gd.implement.param.ThingListMaterialRelationParam; import org.sxkj.gd.implement.service.IGdImplementListService; import org.sxkj.gd.implement.service.IGdThingListMaterialRelService; import org.sxkj.gd.implement.vo.GdImplementListVO; import org.sxkj.gd.implement.vo.GetThingListMaterialRelationVO; import org.sxkj.gd.implement.wrapper.GdThingListMaterialRelWrapper; import org.sxkj.system.cache.SysCache; import java.util.ArrayList; import java.util.List; /** * 实施清单主表 服务实现类 * * @author Aix * @since 2026-01-31 */ @Service @AllArgsConstructor public class GdImplementListServiceImpl extends BaseServiceImpl implements IGdImplementListService { private final IGdThingListMaterialRelService gdThingListMaterialRelService; @Override public IPage selectGdImplementListPage(IPage page, GdImplementListPageParam gdImplementList) { List deptList = SysCache.getDeptChildIds(Long.valueOf(AuthUtil.getDeptId())); gdImplementList.setDeptList(deptList); return page.setRecords(baseMapper.selectGdImplementListPage(page, gdImplementList)); } @Override public GetThingListMaterialRelationVO getThingListMaterialRelation(IdParam idParam) { GetThingListMaterialRelationVO getThingListMaterialRelationVO = new GetThingListMaterialRelationVO(); // 查询实施清单详情 GdImplementListEntity gdImplement = getOne(Condition.getQueryWrapper(GenericConverter.convert(idParam, GdImplementListEntity.class))); getThingListMaterialRelationVO.setImplementListId(gdImplement.getId()); getThingListMaterialRelationVO.setProcessDefinitionId(gdImplement.getProcessDefinitionId()); getThingListMaterialRelationVO.setProcessInstanceId(gdImplement.getProcessInstanceId()); List gdThingListMaterialRelEntityList = gdThingListMaterialRelService.list( Wrappers.query() .lambda().eq(GdThingListMaterialRelEntity::getImplementListId, idParam.getId())); getThingListMaterialRelationVO.setThingListMaterialRels(GdThingListMaterialRelWrapper.build().listVO(gdThingListMaterialRelEntityList)); return getThingListMaterialRelationVO; } @Override @Transactional public boolean thingListMaterialRelation(ThingListMaterialRelationParam param) { if (null != param.getImplementListId()) { // 关联关系先删除,在新增 gdThingListMaterialRelService.remove( new QueryWrapper() .eq("implement_list_id", param.getImplementListId())); List gdThingListMaterialRelEntityList = getGdThingListMaterialRelEntities(param); // 批量新增材料关联关系 gdThingListMaterialRelService.saveBatch(gdThingListMaterialRelEntityList); // 保存流程关联关系 GdImplementListEntity gdImplementList = new GdImplementListEntity(); gdImplementList.setId(param.getImplementListId()); gdImplementList.setProcessDefinitionId(param.getProcessDefinitionId()); gdImplementList.setProcessInstanceId(param.getProcessInstanceId()); updateById(gdImplementList); return true; } return false; } @Override public List exportGdImplementList(Wrapper queryWrapper) { List gdImplementListList = baseMapper.exportGdImplementList(queryWrapper); //gdImplementListList.forEach(gdImplementList -> { // gdImplementList.setTypeName(DictCache.getValue(DictEnum.YES_NO, GdImplementList.getType())); //}); return gdImplementListList; } /** * 获取材料关联关系(对象转换) * @param param 材料关联关系参数 * @return 材料关联关系 */ @NotNull private static List getGdThingListMaterialRelEntities(ThingListMaterialRelationParam param) { List gdThingListMaterialRelEntityList = new ArrayList<>(); int index = 0; for (Long materialId : param.getMaterialIds()) { GdThingListMaterialRelEntity gdThingListMaterialRelEntity = new GdThingListMaterialRelEntity(); gdThingListMaterialRelEntity.setImplementListId(param.getImplementListId()); gdThingListMaterialRelEntity.setMaterialId(materialId); gdThingListMaterialRelEntity.setSort(index); index += 1; gdThingListMaterialRelEntityList.add(gdThingListMaterialRelEntity); } return gdThingListMaterialRelEntityList; } }