| | |
| | | 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; |
| | |
| | | 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; |
| | |
| | | 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); |
| | | } |
| | | } |