| | |
| | | import cn.hutool.core.bean.BeanUtil; |
| | | import cn.hutool.json.JSONUtil; |
| | | import com.baomidou.mybatisplus.core.toolkit.Wrappers; |
| | | import com.ruoyi.basic.mapper.IfsInventoryQuantityMapper; |
| | | import com.ruoyi.basic.pojo.IfsInventoryQuantity; |
| | | import com.ruoyi.common.numgen.NumberGenerator; |
| | | import com.ruoyi.common.utils.api.MesApiUtils; |
| | | import com.ruoyi.inspect.pojo.IfsSplitOrderRecord; |
| | | import com.ruoyi.inspect.service.IfsSplitOrderRecordService; |
| | | import lombok.extern.slf4j.Slf4j; |
| | | import org.aspectj.lang.JoinPoint; |
| | | import org.aspectj.lang.annotation.AfterReturning; |
| | | import org.aspectj.lang.annotation.Aspect; |
| | | import org.aspectj.lang.annotation.Before; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.stereotype.Component; |
| | | import org.springframework.transaction.annotation.Isolation; |
| | |
| | | |
| | | private final static String LOCATION_NO = "WG-02-001";//mes外购合格库位 |
| | | |
| | | @Autowired |
| | | private IfsInventoryQuantityMapper ifsInventoryQuantityMapper; |
| | | |
| | | @Autowired |
| | | private NumberGenerator<IfsSplitOrderRecord> splitOrderRecordNumberGenerator; |
| | | |
| | | @AfterReturning(value = "execution(* com.ruoyi.inspect.service.impl.InsOrderServiceImpl.moveRawMaterial(..))") |
| | | @Before(value = "execution(* com.ruoyi.inspect.service.impl.InsOrderServiceImpl.moveRawMaterial(..))") |
| | | @Transactional(rollbackFor = Exception.class,isolation = Isolation.READ_COMMITTED) |
| | | public void doAfterReturning(JoinPoint joinPoint) { |
| | | Object[] args = joinPoint.getArgs(); |
| | |
| | | .last("limit 1") |
| | | ); |
| | | if(Objects.nonNull(one)){ |
| | | //查询对应记录是否有相同批号和零件的订单记录 |
| | | List<IfsInventoryQuantity> quantityList = ifsInventoryQuantityMapper.selectList(Wrappers.<IfsInventoryQuantity>lambdaQuery() |
| | | .eq(IfsInventoryQuantity::getUpdateBatchNo, one.getLotBatchNo()) |
| | | .eq(IfsInventoryQuantity::getPartNo, one.getPartNo()) |
| | | .ne(IfsInventoryQuantity::getId,ifsInventoryQuantity.getId()) |
| | | //查询对应记录相同批号和零件且已同步的订单记录 |
| | | List<IfsSplitOrderRecord> quantityList = ifsSplitOrderRecordService.list(Wrappers.<IfsSplitOrderRecord>lambdaQuery() |
| | | .eq(IfsSplitOrderRecord::getPartNo,one.getPartNo()) |
| | | .eq(IfsSplitOrderRecord::getLotBatchNo,one.getLotBatchNo()) |
| | | .ne(IfsSplitOrderRecord::getId,one.getId()) |
| | | .eq(IfsSplitOrderRecord::getSyncStatus,1) |
| | | ); |
| | | //获取已检验的数据条数 |
| | | long count = quantityList.stream().filter(f -> f.getIsFinish().equals(1)).count(); |
| | | if(!quantityList.isEmpty() && count>0){ |
| | | //生成新的系统编号 |
| | | one.setSystemNo(splitOrderRecordNumberGenerator.generateNumberWithPrefix(IfsSplitOrderRecord.DIGIT,IfsSplitOrderRecord.PREFIX,IfsSplitOrderRecord::getSystemNo)); |
| | | if(!quantityList.isEmpty()){ |
| | | //使用相同的系统编号 |
| | | one.setSystemNo(quantityList.get(0).getSystemNo()); |
| | | } |
| | | //同步MES实时库存 |
| | | Map<String, Object> requestMap = new HashMap<>(); |
| | | requestMap.put("partNo", one.getPartNo()); // 零件编号 |
| | | requestMap.put("systemNo", one.getSystemNo()); // 系统编号 |
| | | requestMap.put("newSystemNo", one.getSystemNo()); // 新系统编号 |
| | | requestMap.put("spec", one.getSpec()); // 规格 |
| | | requestMap.put("partBatchNo", one.getLotBatchNo()); // 零件批号 |
| | | requestMap.put("newPartBatchNo", one.getLotBatchNo()); // 新零件批号 |
| | | requestMap.put("stockQuantity", one.getLength()); // 库存数量1 |
| | | requestMap.put("qty", one.getQtyStock()); // 库存数量2 |
| | | requestMap.put("insulationColor", one.getInsulationColor()); // 绝缘颜色 |
| | |
| | | requestMap.put("remark", one.getRemark()); // 备注 |
| | | |
| | | String jsonStr = JSONUtil.toJsonStr(Collections.singletonList(requestMap)); |
| | | log.info("同步MES实时库存请求参数-->{}",jsonStr); |
| | | boolean b = mesApiUtils.batchAddStock(jsonStr); |
| | | //同步成功,更新同步状态 |
| | | if(b){ |