| | |
| | | package com.aps.core.service.impl; |
| | | |
| | | import java.util.List; |
| | | |
| | | import com.aps.common.core.utils.DateUtils; |
| | | import com.aps.common.core.utils.StringUtils; |
| | | import com.aps.common.core.utils.uuid.IdUtils; |
| | | import com.aps.core.domain.*; |
| | | import com.aps.core.domain.ApsWeldSeam; |
| | | import com.aps.core.domain.ApsWeldSeamStatistics; |
| | | import com.aps.core.domain.ApsWeldSeamTemp; |
| | | import com.aps.core.mapper.ApsWeldSeamMapper; |
| | | import com.aps.core.mapper.ApsWeldSeamStatisticsMapper; |
| | | import com.aps.core.mapper.ApsWeldSeamTempMapper; |
| | | import com.aps.core.service.IApsWeldSeamService; |
| | | import org.springframework.beans.BeanUtils; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.stereotype.Service; |
| | | import com.aps.core.mapper.ApsWeldSeamMapper; |
| | | import com.aps.core.service.IApsWeldSeamService; |
| | | import org.springframework.transaction.annotation.Transactional; |
| | | |
| | | import java.util.List; |
| | | |
| | | /** |
| | | * 焊缝Service业务层处理 |
| | | * |
| | | * |
| | | * @author wwj |
| | | * @date 2025-04-09 |
| | | */ |
| | | @Service |
| | | public class ApsWeldSeamServiceImpl implements IApsWeldSeamService |
| | | { |
| | | public class ApsWeldSeamServiceImpl implements IApsWeldSeamService { |
| | | @Autowired |
| | | private ApsWeldSeamMapper apsWeldSeamMapper; |
| | | @Autowired |
| | | private ApsWeldSeamTempMapper apsWeldSeamTempMapper; |
| | | @Autowired |
| | | private ApsWeldSeamStatisticsMapper apsWeldSeamStatisticsMapper; |
| | | |
| | | /** |
| | | * 查询焊缝 |
| | | * |
| | | * |
| | | * @param id 焊缝主键 |
| | | * @return 焊缝 |
| | | */ |
| | | @Override |
| | | public ApsWeldSeam selectApsWeldSeamById(String id) |
| | | { |
| | | public ApsWeldSeam selectApsWeldSeamById(String id) { |
| | | return apsWeldSeamMapper.selectApsWeldSeamById(id); |
| | | } |
| | | |
| | | /** |
| | | * 查询焊缝列表 |
| | | * |
| | | * |
| | | * @param apsWeldSeam 焊缝 |
| | | * @return 焊缝 |
| | | */ |
| | | @Override |
| | | public List<ApsWeldSeam> selectApsWeldSeamList(ApsWeldSeam apsWeldSeam) |
| | | { |
| | | public List<ApsWeldSeam> selectApsWeldSeamList(ApsWeldSeam apsWeldSeam) { |
| | | return apsWeldSeamMapper.selectApsWeldSeamList(apsWeldSeam); |
| | | } |
| | | |
| | | /** |
| | | * 新增焊缝 |
| | | * |
| | | * |
| | | * @param apsWeldSeam 焊缝 |
| | | * @return 结果 |
| | | */ |
| | | @Override |
| | | public int insertApsWeldSeam(ApsWeldSeam apsWeldSeam) |
| | | { |
| | | public int insertApsWeldSeam(ApsWeldSeam apsWeldSeam) { |
| | | apsWeldSeam.setId(IdUtils.fastUUID()); |
| | | apsWeldSeam.setCreateTime(DateUtils.getNowDate()); |
| | | return apsWeldSeamMapper.insertApsWeldSeam(apsWeldSeam); |
| | |
| | | |
| | | /** |
| | | * 修改焊缝 |
| | | * |
| | | * |
| | | * @param apsWeldSeam 焊缝 |
| | | * @return 结果 |
| | | */ |
| | | @Override |
| | | public int updateApsWeldSeam(ApsWeldSeam apsWeldSeam) |
| | | { |
| | | public int updateApsWeldSeam(ApsWeldSeam apsWeldSeam) { |
| | | return apsWeldSeamMapper.updateApsWeldSeam(apsWeldSeam); |
| | | } |
| | | |
| | | /** |
| | | * 批量删除焊缝 |
| | | * |
| | | * |
| | | * @param ids 需要删除的焊缝主键 |
| | | * @return 结果 |
| | | */ |
| | | @Override |
| | | public int deleteApsWeldSeamByIds(String[] ids) |
| | | { |
| | | public int deleteApsWeldSeamByIds(String[] ids) { |
| | | return apsWeldSeamMapper.deleteApsWeldSeamByIds(ids); |
| | | } |
| | | |
| | | /** |
| | | * 删除焊缝信息 |
| | | * |
| | | * |
| | | * @param id 焊缝主键 |
| | | * @return 结果 |
| | | */ |
| | | @Override |
| | | public int deleteApsWeldSeamById(String id) |
| | | { |
| | | public int deleteApsWeldSeamById(String id) { |
| | | return apsWeldSeamMapper.deleteApsWeldSeamById(id); |
| | | } |
| | | |
| | | @Override |
| | | public int confirmWeldSeam(ApsWeldSeamTemp apsWeldSeamTemp) { |
| | | //查询临时表数据 |
| | | List<ApsWeldSeamTemp> apsWeldSeamTemps=apsWeldSeamTempMapper.selectApsWeldSeamTempList(apsWeldSeamTemp); |
| | | int count=0; |
| | | String[] ids=new String[apsWeldSeamTemps.size()]; |
| | | for (int i = 0; i <apsWeldSeamTemps.size() ; i++) { |
| | | List<ApsWeldSeamTemp> apsWeldSeamTemps = apsWeldSeamTempMapper.selectApsWeldSeamTempList(apsWeldSeamTemp); |
| | | int count = 0; |
| | | String[] ids = new String[apsWeldSeamTemps.size()]; |
| | | for (int i = 0; i < apsWeldSeamTemps.size(); i++) { |
| | | //记录临时表id |
| | | ids[i]=apsWeldSeamTemps.get(i).getId(); |
| | | ApsWeldSeam apsWeldSeam=new ApsWeldSeam(); |
| | | ids[i] = apsWeldSeamTemps.get(i).getId(); |
| | | ApsWeldSeam apsWeldSeam = new ApsWeldSeam(); |
| | | BeanUtils.copyProperties(apsWeldSeamTemps.get(i), apsWeldSeam); |
| | | //通过工单号查询是否存在数据 |
| | | ApsWeldSeam apsWeldSeam1=apsWeldSeamMapper.selectApsWeldSeamByWorkOrderNo(apsWeldSeam.getWorkOrderNo()); |
| | | ApsWeldSeam apsWeldSeam1 = apsWeldSeamMapper.selectApsWeldSeamByWorkOrderNo(apsWeldSeam.getWorkOrderNo()); |
| | | //当工单号存在则更新数据否则插入数据 |
| | | if(StringUtils.isNotEmpty(apsWeldSeam1.getId())){ |
| | | if (StringUtils.isNotEmpty(apsWeldSeam1.getId())) { |
| | | apsWeldSeam.setId(apsWeldSeam1.getId()); |
| | | apsWeldSeamMapper.updateApsWeldSeam(apsWeldSeam); |
| | | }else { |
| | | } else { |
| | | //插入正式表,并记录 |
| | | apsWeldSeam.setId(IdUtils.fastUUID()); |
| | | apsWeldSeamMapper.insertApsWeldSeam(apsWeldSeam); |
| | |
| | | count++; |
| | | } |
| | | //插入数量与临时表查询一直则删除临时表数据 |
| | | if (count==apsWeldSeamTemps.size()) { |
| | | if (count == apsWeldSeamTemps.size()) { |
| | | apsWeldSeamTempMapper.deleteApsWeldSeamTempByIds(ids); |
| | | } |
| | | //插入焊缝统计表 |
| | | List<ApsWeldSeamStatistics> apsWeldSeamStatistics=apsWeldSeamMapper.weldSeamStat(apsWeldSeamTemps); |
| | | List<ApsWeldSeamStatistics> apsWeldSeamStatistics = apsWeldSeamMapper.weldSeamStat(apsWeldSeamTemps); |
| | | for (int i = 0; i < apsWeldSeamStatistics.size(); i++) { |
| | | List<ApsWeldSeamStatistics> apsWeldSeamStatistics1 = apsWeldSeamStatisticsMapper.selectApsWeldSeamStatisticsList(apsWeldSeamStatistics.get(i)); |
| | | if (apsWeldSeamStatistics1.size() > 0) { |
| | | ApsWeldSeamStatistics apsWeldSeamStatistics2 = apsWeldSeamStatistics1.get(0); |
| | | apsWeldSeamStatistics2.setPipingOrderRequirement(apsWeldSeamStatistics.get(i).getPipingOrderRequirement()); |
| | | apsWeldSeamStatistics2.setGasOrderRequirement(apsWeldSeamStatistics.get(i).getGasOrderRequirement()); |
| | | apsWeldSeamStatistics2.setPipingPredictionRequirement(apsWeldSeamStatistics.get(i).getPipingPredictionRequirement()); |
| | | apsWeldSeamStatistics2.setGasPredictionRequirement(apsWeldSeamStatistics.get(i).getGasPredictionRequirement()); |
| | | //预留紧急订单产出是否为空 |
| | | if (apsWeldSeamStatistics2.getReserveEmergencyOrderOutput() != null) { |
| | | apsWeldSeamStatistics2.setTotal(apsWeldSeamStatistics2.getPipingOrderRequirement() + apsWeldSeamStatistics2.getPipingPredictionRequirement() + apsWeldSeamStatistics2.getGasOrderRequirement() + apsWeldSeamStatistics2.getGasPredictionRequirement() + apsWeldSeamStatistics2.getReserveEmergencyOrderOutput()); |
| | | //天数不为空计算需求日焊缝 |
| | | if(apsWeldSeamStatistics2.getDays()!=null){ |
| | | // 转换为 double 类型进行除法运算 |
| | | double result = (double) apsWeldSeamStatistics2.getTotal() / apsWeldSeamStatistics2.getDays(); |
| | | // 四舍五入 |
| | | long roundedResult = Math.round(result); |
| | | apsWeldSeamStatistics2.setRequirementDayWeldSeam(roundedResult); |
| | | //判断生产日焊缝不为空计算是否满足 |
| | | if(apsWeldSeamStatistics2.getProductionDayWeldSeam()!=null){ |
| | | if(apsWeldSeamStatistics2.getProductionDayWeldSeam()>=apsWeldSeamStatistics2.getRequirementDayWeldSeam()){ |
| | | apsWeldSeamStatistics2.setIsSatisfy("是"); |
| | | }else{ |
| | | apsWeldSeamStatistics2.setIsSatisfy("否"); |
| | | } |
| | | } |
| | | } |
| | | } |
| | | apsWeldSeamStatisticsMapper.updateApsWeldSeamStatistics(apsWeldSeamStatistics2); |
| | | }else { |
| | | apsWeldSeamStatistics.get(i).setId(IdUtils.fastUUID()); |
| | | apsWeldSeamStatistics.get(i).setCreateTime(DateUtils.getNowDate()); |
| | | apsWeldSeamStatisticsMapper.insertApsWeldSeamStatistics(apsWeldSeamStatistics.get(i)); |
| | | } |
| | | |
| | | } |
| | | return 1; |
| | | } |
| | | } |