| | |
| | | package com.jcdm.main.om.productionOrde.service.impl; |
| | | |
| | | import java.text.SimpleDateFormat; |
| | | import java.util.Date; |
| | | import java.util.List; |
| | | import java.util.stream.Collectors; |
| | | |
| | | import cn.hutool.core.util.ObjectUtil; |
| | | import cn.hutool.json.JSONObject; |
| | | import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; |
| | | import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper; |
| | | import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; |
| | | import com.jcdm.common.core.domain.AjaxResult; |
| | | import com.jcdm.common.utils.DateUtils; |
| | |
| | | import com.jcdm.main.om.productionOrde.mapper.OmProductionOrdeInfoMapper; |
| | | import com.jcdm.main.om.productionOrde.service.IOmProductionOrdeInfoService; |
| | | import com.jcdm.main.restful.factoryMes.service.RestfulService; |
| | | import lombok.extern.slf4j.Slf4j; |
| | | import org.slf4j.Logger; |
| | | import org.slf4j.LoggerFactory; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.stereotype.Service; |
| | | |
| | |
| | | * @author ruimin |
| | | * @date 2023-12-11 |
| | | */ |
| | | @Slf4j |
| | | @Service |
| | | public class OmProductionOrdeInfoServiceImpl extends ServiceImpl<OmProductionOrdeInfoMapper,OmProductionOrdeInfo> implements IOmProductionOrdeInfoService |
| | | { |
| | | private static final Logger logger = LoggerFactory.getLogger("sys-user"); |
| | | public SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); |
| | | |
| | | @Autowired |
| | | private OmProductionOrdeInfoMapper omProductionOrdeInfoMapper; |
| | | |
| | |
| | | |
| | | @Override |
| | | public AjaxResult trolleyYardBinDing(OmProductionOrdeInfo omProductionOrdeInfo) { |
| | | OmProductionOrdeInfo clearTrolleyYard = omProductionOrdeInfoService.getOne(new LambdaQueryWrapper<OmProductionOrdeInfo>().eq(OmProductionOrdeInfo::getTrolleyYard, omProductionOrdeInfo.getTrolleyYard())); |
| | | if(clearTrolleyYard!=null){ |
| | | clearTrolleyYard.setTrolleyYard(""); |
| | | omProductionOrdeInfoService.saveOrUpdate(clearTrolleyYard); |
| | | } |
| | | OmProductionOrdeInfo one = omProductionOrdeInfoService.getOne(new LambdaQueryWrapper<OmProductionOrdeInfo>().eq(OmProductionOrdeInfo::getProductNum, omProductionOrdeInfo.getProductNum())); |
| | | one.setTrolleyYard(omProductionOrdeInfo.getTrolleyYard()); |
| | | omProductionOrdeInfoService.saveOrUpdate(one); |
| | | logger.info("绑定pack码{}到小车:{}",omProductionOrdeInfo.getProductNum(),omProductionOrdeInfo.getTrolleyYard()); |
| | | |
| | | return AjaxResult.success(); |
| | | } |
| | | |
| | |
| | | List<OmProductionOrdeInfo> list = omProductionOrdeInfoService.list(new LambdaQueryWrapper<OmProductionOrdeInfo>().eq(OmProductionOrdeInfo::getProductNum, omProductionOrdeInfo.getProductNum()).isNotNull(OmProductionOrdeInfo::getTrolleyYard)); |
| | | return list; |
| | | } |
| | | |
| | | @Override |
| | | public AjaxResult workReportingByStation(OmProductionOrdeInfo info) { |
| | | OmProductionOrdeInfo omProductionOrdeInfo = omProductionOrdeInfoService.getById(info.getId()); |
| | | logger.info("OP230报工开始-工厂MES异步方法"); |
| | | String reportResult = RestfulService.getWorkReportResultFeedback(omProductionOrdeInfo.getProductNum(), info.getStationCode(), format.format(new Date())); |
| | | JSONObject jsonObject = new JSONObject(reportResult); |
| | | String code = jsonObject.getStr("code"); |
| | | String status = jsonObject.getJSONObject("data").getStr("resultCode"); |
| | | if("success".equals(code)&&"S".equals(status)){ |
| | | //如果成功,执行报工成功方法,修改是否报工为1,添加报工时间 |
| | | this.updateOrderByProductNum("1",omProductionOrdeInfo.getProductNum(),info.getStationCode()); |
| | | }else{ |
| | | //解析工厂mes返回结果,如果失败,执行报工失败方法,修改是否报工为2,添加报工时间 |
| | | this.updateOrderByProductNum("2",omProductionOrdeInfo.getProductNum(),info.getStationCode()); |
| | | } |
| | | return null; |
| | | } |
| | | |
| | | @Override |
| | | public void updateOrderByProductNum(String onlineCompletionMark, String productNum, String stationCode) { |
| | | LambdaUpdateWrapper<OmProductionOrdeInfo> updateWrapper = new LambdaUpdateWrapper<>(); |
| | | if(stationCode.equals("POP230")){ |
| | | updateWrapper.set(OmProductionOrdeInfo::getOnlineCompletionMark,onlineCompletionMark); |
| | | updateWrapper.set(OmProductionOrdeInfo::getActualStartTime,new Date()); |
| | | } |
| | | if(stationCode.equals("POP430")){ |
| | | updateWrapper.set(OmProductionOrdeInfo::getSfResult,onlineCompletionMark); |
| | | } |
| | | updateWrapper.eq(OmProductionOrdeInfo::getProductNum,productNum); |
| | | OmProductionOrdeInfo omProductionOrdeInfo = new OmProductionOrdeInfo(); |
| | | omProductionOrdeInfoService.update(omProductionOrdeInfo,updateWrapper); |
| | | } |
| | | } |