| | |
| | | package com.aps.core.service.impl; |
| | | |
| | | import com.aps.common.core.utils.DateUtils; |
| | | import com.aps.common.core.utils.StringUtils; |
| | | import com.aps.common.security.utils.DictUtils; |
| | | import com.aps.common.security.utils.SecurityUtils; |
| | | import com.aps.core.domain.ApsShop; |
| | | import com.aps.core.domain.ApsStandardProcess; |
| | | import com.aps.core.mapper.ApsShopMapper; |
| | | import com.aps.core.mapper.ApsStandardProcessMapper; |
| | | import com.aps.core.service.IApsStandardProcessService; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.stereotype.Service; |
| | | |
| | | import java.util.List; |
| | | import java.util.Objects; |
| | | import java.util.stream.Collectors; |
| | | |
| | | /** |
| | | * 标准工序Service业务层处理 |
| | | * |
| | | * |
| | | * @author hjy |
| | | * @date 2025-04-23 |
| | | */ |
| | | @Service |
| | | public class ApsStandardProcessServiceImpl implements IApsStandardProcessService |
| | | { |
| | | public class ApsStandardProcessServiceImpl implements IApsStandardProcessService { |
| | | @Autowired |
| | | private ApsStandardProcessMapper apsStandardProcessMapper; |
| | | |
| | | @Autowired |
| | | private ApsShopMapper apsShopMapper; |
| | | |
| | | /** |
| | | * 查询标准工序 |
| | | * |
| | | * |
| | | * @param id 标准工序主键 |
| | | * @return 标准工序 |
| | | */ |
| | | @Override |
| | | public ApsStandardProcess selectApsStandardProcessById(Long id) |
| | | { |
| | | public ApsStandardProcess selectApsStandardProcessById(Long id) { |
| | | return apsStandardProcessMapper.selectApsStandardProcessById(id); |
| | | } |
| | | |
| | | /** |
| | | * 查询标准工序列表 |
| | | * |
| | | * |
| | | * @param apsStandardProcess 标准工序 |
| | | * @return 标准工序 |
| | | */ |
| | | @Override |
| | | public List<ApsStandardProcess> selectApsStandardProcessList(ApsStandardProcess apsStandardProcess) |
| | | { |
| | | public List<ApsStandardProcess> selectApsStandardProcessList(ApsStandardProcess apsStandardProcess) { |
| | | return apsStandardProcessMapper.selectApsStandardProcessList(apsStandardProcess); |
| | | } |
| | | |
| | | /** |
| | | * 新增标准工序 |
| | | * |
| | | * |
| | | * @param apsStandardProcess 标准工序 |
| | | * @return 结果 |
| | | */ |
| | | @Override |
| | | public int insertApsStandardProcess(ApsStandardProcess apsStandardProcess) |
| | | { |
| | | public int insertApsStandardProcess(ApsStandardProcess apsStandardProcess) { |
| | | apsStandardProcess.setCreateTime(DateUtils.getNowDate()); |
| | | apsStandardProcess.setCreateBy(SecurityUtils.getUsername()); |
| | | return apsStandardProcessMapper.insertApsStandardProcess(apsStandardProcess); |
| | |
| | | |
| | | /** |
| | | * 修改标准工序 |
| | | * |
| | | * |
| | | * @param apsStandardProcess 标准工序 |
| | | * @return 结果 |
| | | */ |
| | | @Override |
| | | public int updateApsStandardProcess(ApsStandardProcess apsStandardProcess) |
| | | { |
| | | public int updateApsStandardProcess(ApsStandardProcess apsStandardProcess) { |
| | | apsStandardProcess.setUpdateTime(DateUtils.getNowDate()); |
| | | apsStandardProcess.setUpdateBy(SecurityUtils.getUsername()); |
| | | return apsStandardProcessMapper.updateApsStandardProcess(apsStandardProcess); |
| | |
| | | |
| | | /** |
| | | * 批量删除标准工序 |
| | | * |
| | | * |
| | | * @param ids 需要删除的标准工序主键 |
| | | * @return 结果 |
| | | */ |
| | | @Override |
| | | public int deleteApsStandardProcessByIds(Long[] ids) |
| | | { |
| | | public int deleteApsStandardProcessByIds(Long[] ids) { |
| | | return apsStandardProcessMapper.deleteApsStandardProcessByIds(ids); |
| | | } |
| | | |
| | | /** |
| | | * 删除标准工序信息 |
| | | * |
| | | * |
| | | * @param id 标准工序主键 |
| | | * @return 结果 |
| | | */ |
| | | @Override |
| | | public int deleteApsStandardProcessById(Long id) |
| | | { |
| | | public int deleteApsStandardProcessById(Long id) { |
| | | return apsStandardProcessMapper.deleteApsStandardProcessById(id); |
| | | } |
| | | |
| | | /** |
| | | * 导入数据 |
| | | * |
| | | * @param tempList |
| | | * @return true/false |
| | | */ |
| | |
| | | public boolean importData(List<ApsStandardProcess> tempList) { |
| | | try { |
| | | if (!tempList.isEmpty()) { |
| | | tempList.forEach(temp->{ |
| | | DictUtils.CacheValue cacheFactory = DictUtils.getCacheValue("aps_factory"); |
| | | DictUtils.CacheValue cacheDomain = DictUtils.getCacheValue("aps_domain"); |
| | | |
| | | List<ApsShop> shops = apsShopMapper.selectApsByName(tempList.stream() |
| | | .map(ApsStandardProcess::getWorkShop) |
| | | .filter(StringUtils::isNotEmpty) |
| | | .collect(Collectors.toSet())); |
| | | tempList.forEach(temp -> { |
| | | temp.setCreateBy(SecurityUtils.getUsername()); |
| | | temp.setCreateTime(DateUtils.getNowDate()); |
| | | apsStandardProcessMapper.insertApsStandardProcess(temp); |
| | | temp.setMajor(cacheDomain.get(temp.getMajor())); |
| | | temp.setPlant(cacheFactory.get(temp.getPlant())); |
| | | temp.setWorkShop(shops.stream() |
| | | .filter(shop -> Objects.equals(shop.getShopName(), temp.getWorkShop())) |
| | | .filter(shop -> Objects.equals(shop.getPlantCode(), temp.getPlant())) |
| | | .map(ApsShop::getShopCode) |
| | | .findFirst() |
| | | .orElse(null)); |
| | | }); |
| | | apsStandardProcessMapper.insert(tempList); |
| | | } |
| | | } catch (Exception e) { |
| | | e.printStackTrace(); |
| | |
| | | } |
| | | return true; |
| | | } |
| | | |
| | | @Override |
| | | public List<ApsStandardProcess> selectApsStandardProcessListAll(ApsStandardProcess apsStandardProcess) { |
| | | return apsStandardProcessMapper.selectApsStandardProcessList(apsStandardProcess); |
| | | } |
| | | } |