| | |
| | | package com.qianwen.mdc.service.workshop;
|
| | |
|
| | | import java.util.ArrayList;
|
| | | import java.util.List;
|
| | | import java.util.stream.Collectors;
|
| | |
|
| | | import org.apache.tomcat.util.buf.StringUtils;
|
| | | import org.springframework.beans.factory.annotation.Autowired;
|
| | | import org.springframework.stereotype.Service;
|
| | | import org.springframework.transaction.annotation.Transactional;
|
| | |
|
| | | import com.qianwen.mdc.domain.Machine;
|
| | | import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
| | | import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
| | | import com.qianwen.mdc.domain.Section;
|
| | | import com.qianwen.mdc.domain.workshop.Workshop;
|
| | | import com.qianwen.mdc.domain.workshop.WorkshopAssembler;
|
| | | import com.qianwen.mdc.dto.WorkshopDTO;
|
| | | import com.qianwen.mdc.dto.machine.MachineDTO;
|
| | | import com.qianwen.mdc.mapper.MachineMapper;
|
| | | import com.qianwen.mdc.dto.workshop.WorkshopDTO;
|
| | | import com.qianwen.mdc.dto.workshop.WorkshopFullDTO;
|
| | | import com.qianwen.mdc.dto.workshop.WorkshopQueryDTO;
|
| | | import com.qianwen.mdc.mapper.SectionMapper;
|
| | | import com.qianwen.mdc.mapper.WorkshopMapper;
|
| | |
|
| | |
| | | private WorkshopMapper workshopMapper;
|
| | | @Autowired
|
| | | private SectionMapper sectionMapper;
|
| | | @Transactional
|
| | | public void save(WorkshopDTO workshopDTO) {
|
| | | Workshop ws = new Workshop();
|
| | | ws.setName(workshopDTO.getName());
|
| | | |
| | | workshopMapper.insert(ws);
|
| | | }
|
| | | @Transactional
|
| | | public void modify(WorkshopDTO workshopDTO) {
|
| | |
|
| | | Workshop ws = workshopMapper.selectById(workshopDTO.getId());
|
| | | ws.setName(workshopDTO.getName());
|
| | | |
| | | workshopMapper.updateById(ws);
|
| | | }
|
| | |
|
| | |
|
| | | /**
|
| | | * 获取车间列表,附带车间下的工段数据
|
| | | * @return
|
| | | */
|
| | | @Transactional(readOnly=true)
|
| | | public List<WorkshopDTO> listWithSections() {
|
| | | List<Workshop> list = workshopMapper.selectList(null);
|
| | | List<Workshop> list = workshopMapper.selectList(Wrappers.emptyWrapper());
|
| | | return list.stream().map(ws -> {
|
| | | List<Section> sectionList = sectionMapper.queryByWorkshopId(ws.getId());
|
| | | WorkshopDTO wsDTO = WorkshopAssembler.toDTO(ws,sectionList);
|
| | |
| | | return wsDTO;
|
| | | }).collect(Collectors.toList());
|
| | | }
|
| | |
|
| | | @Transactional(readOnly=true)
|
| | | public Page<WorkshopFullDTO> pageQuery(WorkshopQueryDTO dto) {
|
| | | Page<WorkshopFullDTO> rowPage = new Page<>(dto.finalPageNo(),dto.finalPageSize());
|
| | | rowPage = workshopMapper.queryPage(rowPage, dto);
|
| | | |
| | | rowPage.getRecords().forEach((ws) -> {
|
| | | List<Section> sectionList = sectionMapper.queryByWorkshopId(ws.getId());
|
| | | List<String> nameList = new ArrayList<>();
|
| | | for(Section s : sectionList) {
|
| | | nameList.add(s.getName());
|
| | | }
|
| | | |
| | | ws.setSectionNames(StringUtils.join(nameList,','));
|
| | | });
|
| | | |
| | | return rowPage;
|
| | | }
|
| | | }
|