| | |
| | | import com.zy.asrs.service.PlaService; |
| | | import com.zy.common.entity.MatExcel; |
| | | import com.zy.common.entity.PlaExcel; |
| | | import lombok.Data; |
| | | import lombok.extern.slf4j.Slf4j; |
| | | import org.springframework.beans.BeanUtils; |
| | | |
| | |
| | | * Created by vincent on 2019-11-25 |
| | | */ |
| | | @Slf4j |
| | | @Data |
| | | public class PlaExcelListener extends AnalysisEventListener<PlaExcel> { |
| | | |
| | | private static final String OWNER_HZ = "海正生物"; |
| | | private static final String OWNER_HNE = "海诺尔"; |
| | | |
| | | private int total = 0; |
| | | private int index = 1; |
| | | private Long userId; |
| | | |
| | | public PlaExcelListener() { |
| | |
| | | */ |
| | | @Override |
| | | public void invoke(PlaExcel excel, AnalysisContext ctx) { |
| | | index ++; |
| | | PlaService plaService = SpringUtils.getBean(PlaService.class); |
| | | NodeService nodeService = SpringUtils.getBean(NodeService.class); |
| | | MatService matService = SpringUtils.getBean(MatService.class); |
| | |
| | | setPla(pla); |
| | | }catch (Exception e){ |
| | | log.info(e.getMessage() + "Pla: " + pla.getBatch()); |
| | | throw new CoolException(e.getMessage()); |
| | | throw new CoolException(e.getMessage() + ",批号:" + excel.getBatch() + ", 包号:" + excel.getPackageNo()); |
| | | } |
| | | |
| | | if(!Cools.isEmpty(pla.getLocNo())){ |
| | |
| | | pla.setStatus(GlobleParameter.PLA_STATUS_1); |
| | | pla.setPakinTime(new Date()); |
| | | } |
| | | if (!plaService.insert(pla)) { |
| | | throw new CoolException("保存商品信息失败,商品编码:" + excel.getMatnr()); |
| | | try { |
| | | plaService.insert(pla); |
| | | }catch (Exception e){ |
| | | log.error("保存商品信息失败,批号:" + excel.getBatch() + ", 包号:" + excel.getPackageNo() + "原因为:" + e.getMessage()); |
| | | throw new CoolException("保存商品信息失败,批号:" + excel.getBatch() + ", 包号:" + excel.getPackageNo() + "原因为:" + e.getMessage()); |
| | | } |
| | | // if (!plaService.insert(pla)) { |
| | | // throw new CoolException("保存商品信息失败,商品编码:" + excel.getMatnr()); |
| | | // } |
| | | total++; |
| | | }else if (pla.getStatus().equals(GlobleParameter.PLA_STATUS_00)){ |
| | | excel.setId(pla.getId()); |
| | |
| | | excel.setStep(2); |
| | | excel.setStatus(GlobleParameter.PLA_STATUS_00); |
| | | BeanUtils.copyProperties(excel,pla); |
| | | plaService.updateById(pla); |
| | | try { |
| | | plaService.updateById(pla); |
| | | }catch (Exception e){ |
| | | log.error("保存商品信息失败,批号:" + excel.getBatch() + ", 包号:" + excel.getPackageNo() + "原因为:" + e.getMessage()); |
| | | throw new CoolException("保存商品信息失败,批号:" + excel.getBatch() + ", 包号:" + excel.getPackageNo() + "原因为:" + e.getMessage()); |
| | | } |
| | | total++; |
| | | } |
| | | } |