| | |
| | | */ |
| | | 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.sxkj.gd.implement.dto.GdImplementListDTO; |
| | | import org.springframework.stereotype.Service; |
| | | import org.springframework.transaction.annotation.Transactional; |
| | | import org.sxkj.common.utils.HeaderUtils; |
| | | import org.sxkj.gd.common.GenericConverter; |
| | | import org.sxkj.gd.common.IdParam; |
| | | import org.sxkj.gd.implement.entity.GdImplementListEntity; |
| | | import org.sxkj.gd.implement.param.GdImplementListPageParam; |
| | | import org.sxkj.gd.implement.vo.GdImplementListVO; |
| | | 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.springframework.stereotype.Service; |
| | | import com.baomidou.mybatisplus.core.conditions.Wrapper; |
| | | import com.baomidou.mybatisplus.core.metadata.IPage; |
| | | import org.springblade.core.mp.base.BaseServiceImpl; |
| | | 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; |
| | | |
| | | /** |
| | |
| | | * @since 2026-01-31 |
| | | */ |
| | | @Service |
| | | @AllArgsConstructor |
| | | public class GdImplementListServiceImpl extends BaseServiceImpl<GdImplementListMapper, GdImplementListEntity> implements IGdImplementListService { |
| | | |
| | | private final IGdThingListMaterialRelService gdThingListMaterialRelService; |
| | | |
| | | @Override |
| | | public IPage<GdImplementListVO> selectGdImplementListPage(IPage<GdImplementListVO> page, GdImplementListPageParam gdImplementList) { |
| | | List<Long> deptList = SysCache.getDeptChildIds(Long.valueOf(AuthUtil.getDeptId())); |
| | | List<Long> deptList = new ArrayList<>(); |
| | | if (!AuthUtil.isAdministrator()) { |
| | | deptList = SysCache.getDeptChildIds(Long.valueOf(AuthUtil.getDeptId())); |
| | | } |
| | | gdImplementList.setDeptList(deptList); |
| | | gdImplementList.setAreaCode(HeaderUtils.formatAreaCode(gdImplementList.getAreaCode())); |
| | | 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()); |
| | | getThingListMaterialRelationVO.setResultConfig(gdImplement.getResultConfig()); |
| | | |
| | | List<GdThingListMaterialRelEntity> gdThingListMaterialRelEntityList = gdThingListMaterialRelService.list( |
| | | Wrappers.<GdThingListMaterialRelEntity>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<GdThingListMaterialRelEntity>() |
| | | .eq("implement_list_id", param.getImplementListId())); |
| | | |
| | | List<GdThingListMaterialRelEntity> gdThingListMaterialRelEntityList = getGdThingListMaterialRelEntities(param); |
| | | |
| | | // 批量新增材料关联关系 |
| | | gdThingListMaterialRelService.saveBatch(gdThingListMaterialRelEntityList); |
| | | |
| | | // 保存流程关联关系 |
| | | GdImplementListEntity gdImplementList = new GdImplementListEntity(); |
| | | gdImplementList.setId(param.getImplementListId()); |
| | | gdImplementList.setProcessDefinitionId(param.getProcessDefinitionId()); |
| | | gdImplementList.setProcessInstanceId(param.getProcessInstanceId()); |
| | | gdImplementList.setResultConfig(param.getResultConfig()); |
| | | updateById(gdImplementList); |
| | | |
| | | return true; |
| | | } |
| | | |
| | | return false; |
| | | } |
| | | |
| | | @Override |
| | | public List<GdImplementListExcel> exportGdImplementList(Wrapper<GdImplementListEntity> queryWrapper) { |
| | |
| | | return gdImplementListList; |
| | | } |
| | | |
| | | /** |
| | | * 获取材料关联关系(对象转换) |
| | | * @param param 材料关联关系参数 |
| | | * @return 材料关联关系 |
| | | */ |
| | | @NotNull |
| | | private static List<GdThingListMaterialRelEntity> getGdThingListMaterialRelEntities(ThingListMaterialRelationParam param) { |
| | | List<GdThingListMaterialRelEntity> 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; |
| | | } |
| | | |
| | | } |