自动化立体仓库 - WMS系统
zyx
2024-02-22 8a9b1bc2a82166cfa563bc32057503a0274c561d
src/main/java/com/zy/asrs/utils/PlaExcelListener.java
@@ -14,6 +14,7 @@
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;
@@ -26,12 +27,14 @@
 * 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() {
@@ -60,6 +63,7 @@
     */
    @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);
@@ -89,7 +93,7 @@
                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())){
@@ -103,9 +107,15 @@
                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());
@@ -114,7 +124,12 @@
            excel.setStep(2);
            excel.setStatus(GlobleParameter.PLA_STATUS_00);
            BeanUtils.copyProperties(excel,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++;
        }
    }