1
luxiaotao1123
2021-09-24 33817dd27d0527bf7eff142bf74c09fceb628590
src/main/java/com/zy/asrs/task/handler/WorkLogHandler.java
@@ -11,7 +11,9 @@
import com.zy.asrs.task.core.ReturnT;
import com.zy.common.service.erp.ErpService;
import com.zy.common.service.erp.entity.OutStockBillEntry;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.transaction.interceptor.TransactionAspectSupport;
@@ -23,9 +25,10 @@
/**
 * Created by vincent on 2020/7/6
 */
@Slf4j
@Service
@RestController
public class WorkLogHandler extends AbstractHandler<String> {
public class WorkLogHandler extends AbstractHandler<Exception> {
    @Autowired
    private WrkMastService wrkMastService;
@@ -43,23 +46,11 @@
    private ErpService erpService;
    @Autowired
    private OutStockService outStockService;
    @GetMapping("/test1")
    public String test1(String barcode){
        Wrapper<WaitPakin> wrapper = new EntityWrapper<WaitPakin>().eq("zpallet", barcode);
        // erp关联订单处理
        List<WaitPakin> waitPakins = waitPakinService.selectList(wrapper);
        for (WaitPakin waitPakin : waitPakins) {
            boolean erpRes = erpService.incrementPakIn(waitPakin.getSupplier(), waitPakin.getMatnr(), waitPakin.getAnfme());
            if (!erpRes) {
                exceptionHandle("更新ERP入库数据[matnr={0}]失败", waitPakin.getMatnr());
            }
        }
        return "ok";
    }
    @Autowired
    private JdbcTemplate jdbcTemplate;
    @Transactional
    public ReturnT<String> start(WrkMast wrkMast) {
    public ReturnT<Exception> start(WrkMast wrkMast) {
        try {
            if (!Cools.isEmpty(wrkMast.getBarcode())) {
@@ -95,14 +86,23 @@
                for (WrkDetl wrkDetl: wrkDetls) {
                    if (!Cools.isEmpty(wrkDetl)) {
                        Integer FInterI = outStockService.queryOutStockFInterID(wrkDetl.getSupplier()); // 获取出库单主表主键
                        if (!erpService.incrementCPakOut(FInterI, wrkDetl.getMatnr(),  wrkDetl.getAnfme(), wrkDetl.getSupplier())) {
                            exceptionHandle("更新ERP成品出库数据[matnr={0}]失败", wrkDetl.getMatnr());
                        log.info("incrementCPakOut---" + wrkMast.getWrkNo() + "----FInterI" + FInterI);
                        if (!Cools.isEmpty(FInterI)) {
                            if (!erpService.incrementCPakOut(FInterI, wrkDetl.getMatnr(),  wrkDetl.getAnfme(), wrkDetl.getSupplier())) {
                                log.error("erpService.incrementCPakOut");
                                exceptionHandle("[xtyasrs_dual]更新ERP成品出库数据[matnr={0}]失败", wrkDetl.getMatnr());
                            }
//                            if (!outStockService.incrementCPakOut(FInterI, wrkDetl.getMatnr(),  wrkDetl.getAnfme(), wrkDetl.getSupplier())) {
//                                exceptionHandle("[xtyasrs]更新ERP成品出库数据[matnr={0}]失败", wrkDetl.getMatnr());
//                            }
                        }
//                        if (wrkDetl.getMemo().equals("原材料")) {
//                            // 待实现
//                        } else if (wrkDetl.getMemo().equals("成品")) {
//
//                        }
                        if (wrkDetl.getMemo().equals("原材料")) {
                            // 待实现
                        } else if (wrkDetl.getMemo().equals("成品")) {
                        }
                    }
                }
            }
@@ -124,9 +124,9 @@
//                exceptionHandle("删除工作明细档[workNo={0}]失败", wrkMast.getWrkNo());
            }
        } catch (Exception e) {
            e.printStackTrace();
//            e.printStackTrace();
            TransactionAspectSupport.currentTransactionStatus().setRollbackOnly();
            return FAIL.setMsg(e.getMessage());
            return FAIL.setContent(e);
        }
        return SUCCESS;
    }