| | |
| | | import com.aps.core.domain.ApsGasPipelineCapacityPlan; |
| | | import com.aps.core.mapper.ApsGasPipelineCapacityPlanMapper; |
| | | import com.aps.core.service.IApsGasPipelineCapacityPlanService; |
| | | import lombok.SneakyThrows; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.stereotype.Service; |
| | | import org.springframework.transaction.annotation.Transactional; |
| | | |
| | | import java.sql.Timestamp; |
| | | import java.text.SimpleDateFormat; |
| | | import java.time.LocalDateTime; |
| | | import java.util.Calendar; |
| | | import java.util.Date; |
| | | import java.util.List; |
| | | |
| | | /** |
| | |
| | | * @date 2025-04-24 |
| | | */ |
| | | @Service |
| | | public class ApsGasPipelineCapacityPlanServiceImpl implements IApsGasPipelineCapacityPlanService |
| | | { |
| | | public class ApsGasPipelineCapacityPlanServiceImpl implements IApsGasPipelineCapacityPlanService { |
| | | @Autowired |
| | | private ApsGasPipelineCapacityPlanMapper apsGasPipelineCapacityPlanMapper; |
| | | |
| | |
| | | * @return 气体管路产能规划 |
| | | */ |
| | | @Override |
| | | public ApsGasPipelineCapacityPlan selectApsGasPipelineCapacityPlanById(Long id) |
| | | { |
| | | public ApsGasPipelineCapacityPlan selectApsGasPipelineCapacityPlanById(Long id) { |
| | | return apsGasPipelineCapacityPlanMapper.selectApsGasPipelineCapacityPlanById(id); |
| | | } |
| | | |
| | |
| | | * @return 气体管路产能规划 |
| | | */ |
| | | @Override |
| | | public List<ApsGasPipelineCapacityPlan> selectApsGasPipelineCapacityPlanList(ApsGasPipelineCapacityPlan apsGasPipelineCapacityPlan) |
| | | { |
| | | public List<ApsGasPipelineCapacityPlan> selectApsGasPipelineCapacityPlanList(ApsGasPipelineCapacityPlan apsGasPipelineCapacityPlan) { |
| | | return apsGasPipelineCapacityPlanMapper.selectApsGasPipelineCapacityPlanList(apsGasPipelineCapacityPlan); |
| | | } |
| | | |
| | |
| | | * @return 结果 |
| | | */ |
| | | @Override |
| | | public int insertApsGasPipelineCapacityPlan(ApsGasPipelineCapacityPlan apsGasPipelineCapacityPlan) |
| | | { |
| | | public int insertApsGasPipelineCapacityPlan(ApsGasPipelineCapacityPlan apsGasPipelineCapacityPlan) { |
| | | apsGasPipelineCapacityPlan.setCreateTime(DateUtils.getNowDate()); |
| | | apsGasPipelineCapacityPlan.setCreateBy(SecurityUtils.getUsername()); |
| | | return apsGasPipelineCapacityPlanMapper.insertApsGasPipelineCapacityPlan(apsGasPipelineCapacityPlan); |
| | |
| | | * @return 结果 |
| | | */ |
| | | @Override |
| | | public int updateApsGasPipelineCapacityPlan(ApsGasPipelineCapacityPlan apsGasPipelineCapacityPlan) |
| | | { |
| | | public int updateApsGasPipelineCapacityPlan(ApsGasPipelineCapacityPlan apsGasPipelineCapacityPlan) { |
| | | apsGasPipelineCapacityPlan.setUpdateTime(DateUtils.getNowDate()); |
| | | apsGasPipelineCapacityPlan.setUpdateBy(SecurityUtils.getUsername()); |
| | | return apsGasPipelineCapacityPlanMapper.updateApsGasPipelineCapacityPlan(apsGasPipelineCapacityPlan); |
| | |
| | | * @return 结果 |
| | | */ |
| | | @Override |
| | | public int deleteApsGasPipelineCapacityPlanByIds(Long[] ids) |
| | | { |
| | | public int deleteApsGasPipelineCapacityPlanByIds(Long[] ids) { |
| | | return apsGasPipelineCapacityPlanMapper.deleteApsGasPipelineCapacityPlanByIds(ids); |
| | | } |
| | | |
| | |
| | | * @return 结果 |
| | | */ |
| | | @Override |
| | | public int deleteApsGasPipelineCapacityPlanById(Long id) |
| | | { |
| | | public int deleteApsGasPipelineCapacityPlanById(Long id) { |
| | | return apsGasPipelineCapacityPlanMapper.deleteApsGasPipelineCapacityPlanById(id); |
| | | } |
| | | |
| | | @SneakyThrows |
| | | @Override |
| | | @Transactional(rollbackFor = Exception.class) |
| | | public void copyPlan(String date, String factory, String toStart, String toEnd) { |
| | | |
| | | String[] dtSrc = date.split("-"); |
| | | SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM"); |
| | | Calendar dtStart = Calendar.getInstance(); |
| | | dtStart.setTime(sdf.parse(toStart)); |
| | | dtStart.set(Calendar.DAY_OF_MONTH, 1); |
| | | Calendar dtEnd = Calendar.getInstance(); |
| | | dtEnd.setTime(sdf.parse(toEnd)); |
| | | dtEnd.set(Calendar.DAY_OF_MONTH, 2); |
| | | |
| | | ApsGasPipelineCapacityPlan plan = new ApsGasPipelineCapacityPlan(); |
| | | plan.setYear(Integer.valueOf(dtSrc[0]).toString()); |
| | | plan.setMonth(Integer.valueOf(dtSrc[1]).toString()); |
| | | plan.setOrgCode(factory); |
| | | List<ApsGasPipelineCapacityPlan> templatePlans = apsGasPipelineCapacityPlanMapper.selectApsGasPipelineCapacityPlanList(plan); |
| | | while (dtStart.before(dtEnd)) { |
| | | String year = dtStart.get(Calendar.YEAR) + ""; |
| | | String month = (dtStart.get(Calendar.MONTH) + 1) + ""; |
| | | apsGasPipelineCapacityPlanMapper.deleteByDateAndFactory( |
| | | year, |
| | | month, |
| | | factory |
| | | ); |
| | | templatePlans.forEach(p -> { |
| | | p.setYear(year); |
| | | p.setMonth(month); |
| | | p.setCreateBy(SecurityUtils.getUsername()); |
| | | p.setCreateTime(new Date()); |
| | | p.setUpdateBy(null); |
| | | p.setUpdateTime(null); |
| | | apsGasPipelineCapacityPlanMapper.insertApsGasPipelineCapacityPlan(p); |
| | | }); |
| | | |
| | | dtStart.add(Calendar.MONTH, 1); |
| | | } |
| | | |
| | | } |
| | | } |