| | |
| | | import com.aps.common.core.utils.DateUtils; |
| | | import com.aps.common.security.utils.SecurityUtils; |
| | | import com.aps.core.domain.ApsGasPipelinePrediction; |
| | | import com.aps.core.domain.ApsMaterialProductGroupManagement; |
| | | import com.aps.core.mapper.ApsGasPipelinePredictionMapper; |
| | | import com.aps.core.service.IApsGasPipelinePredictionService; |
| | | import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper; |
| | | import io.micrometer.common.util.StringUtils; |
| | | import lombok.SneakyThrows; |
| | | import org.apache.poi.ss.usermodel.Row; |
| | |
| | | |
| | | import java.math.BigDecimal; |
| | | import java.sql.Timestamp; |
| | | import java.util.ArrayList; |
| | | import java.util.Date; |
| | | import java.util.List; |
| | | import java.text.SimpleDateFormat; |
| | | import java.util.*; |
| | | import java.util.stream.Collectors; |
| | | |
| | | /** |
| | | * 管路手工气体预测数据Service业务层处理 |
| | |
| | | * @date 2025-05-19 |
| | | */ |
| | | @Service |
| | | public class ApsGasPipelinePredictionServiceImpl implements IApsGasPipelinePredictionService |
| | | { |
| | | public class ApsGasPipelinePredictionServiceImpl implements IApsGasPipelinePredictionService { |
| | | @Autowired |
| | | private ApsGasPipelinePredictionMapper apsGasPipelinePredictionMapper; |
| | | |
| | |
| | | * @return 管路手工气体预测数据 |
| | | */ |
| | | @Override |
| | | public ApsGasPipelinePrediction selectApsGasPipelinePredictionById(Long id) |
| | | { |
| | | public ApsGasPipelinePrediction selectApsGasPipelinePredictionById(Long id) { |
| | | return apsGasPipelinePredictionMapper.selectApsGasPipelinePredictionById(id); |
| | | } |
| | | |
| | |
| | | * @return 管路手工气体预测数据 |
| | | */ |
| | | @Override |
| | | public List<ApsGasPipelinePrediction> selectApsGasPipelinePredictionList(ApsGasPipelinePrediction apsGasPipelinePrediction) |
| | | { |
| | | public List<ApsGasPipelinePrediction> selectApsGasPipelinePredictionList(ApsGasPipelinePrediction apsGasPipelinePrediction) { |
| | | return apsGasPipelinePredictionMapper.selectApsGasPipelinePredictionList(apsGasPipelinePrediction); |
| | | } |
| | | |
| | |
| | | * @return 结果 |
| | | */ |
| | | @Override |
| | | public int insertApsGasPipelinePrediction(ApsGasPipelinePrediction apsGasPipelinePrediction) |
| | | { |
| | | public int insertApsGasPipelinePrediction(ApsGasPipelinePrediction apsGasPipelinePrediction) { |
| | | apsGasPipelinePrediction.setCreateTime(DateUtils.getNowDate()); |
| | | return apsGasPipelinePredictionMapper.insertApsGasPipelinePrediction(apsGasPipelinePrediction); |
| | | } |
| | |
| | | * @return 结果 |
| | | */ |
| | | @Override |
| | | public int updateApsGasPipelinePrediction(ApsGasPipelinePrediction apsGasPipelinePrediction) |
| | | { |
| | | public int updateApsGasPipelinePrediction(ApsGasPipelinePrediction apsGasPipelinePrediction) { |
| | | apsGasPipelinePrediction.setUpdateTime(DateUtils.getNowDate()); |
| | | return apsGasPipelinePredictionMapper.updateApsGasPipelinePrediction(apsGasPipelinePrediction); |
| | | } |
| | |
| | | * @return 结果 |
| | | */ |
| | | @Override |
| | | public int deleteApsGasPipelinePredictionByIds(Long[] ids) |
| | | { |
| | | public int deleteApsGasPipelinePredictionByIds(Long[] ids) { |
| | | return apsGasPipelinePredictionMapper.deleteApsGasPipelinePredictionByIds(ids); |
| | | } |
| | | |
| | |
| | | * @return 结果 |
| | | */ |
| | | @Override |
| | | public int deleteApsGasPipelinePredictionById(Long id) |
| | | { |
| | | public int deleteApsGasPipelinePredictionById(Long id) { |
| | | return apsGasPipelinePredictionMapper.deleteApsGasPipelinePredictionById(id); |
| | | } |
| | | |
| | |
| | | } |
| | | } |
| | | if (!list.isEmpty()) { |
| | | apsGasPipelinePredictionMapper.deleteAll(); |
| | | |
| | | List<Map<String, Object>> facCodeKey = apsGasPipelinePredictionMapper.selectByFacOrMaterial( |
| | | list.stream().map(ApsGasPipelinePrediction::getFactory).collect(Collectors.toSet()), |
| | | list.stream().map(ApsGasPipelinePrediction::getMaterialCode).collect(Collectors.toSet()) |
| | | ); |
| | | if (!facCodeKey.isEmpty()) { |
| | | SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM"); |
| | | Iterator<ApsGasPipelinePrediction> it = list.iterator(); |
| | | while (it.hasNext()) { |
| | | ApsGasPipelinePrediction item = it.next(); |
| | | String key = item.getFactory() + "##" + item.getMaterialCode() + "##" + sdf.format(item.getPredictDate()); |
| | | facCodeKey.stream() |
| | | .filter(map -> map.get("key").equals(key)) |
| | | .forEach(row -> { |
| | | item.setId((Long) row.get("id")); |
| | | item.setCreateBy(null); |
| | | item.setCreateTime(null); |
| | | item.setUpdateBy(SecurityUtils.getUsername()); |
| | | item.setUpdateTime(new Timestamp(System.currentTimeMillis())); |
| | | apsGasPipelinePredictionMapper.updateById(item); |
| | | it.remove(); |
| | | }); |
| | | } |
| | | } |
| | | if (!list.isEmpty()) { |
| | | apsGasPipelinePredictionMapper.insert(list); |
| | | } |
| | | } |
| | | return list.size(); |
| | | } |
| | | return 0; |