From 592f175ea0ad02c4e22cb62e77ea9e1e9cfbe516 Mon Sep 17 00:00:00 2001 From: luxiaotao1123 <t1341870251@63.com> Date: 星期四, 08 十二月 2022 14:45:34 +0800 Subject: [PATCH] # --- src/main/java/com/zy/common/service/erp/dto/VoucherDto.java | 20 ++++++++++ src/main/java/com/zy/common/service/erp/ErpService.java | 38 ++++++++++++++---- src/main/java/com/zy/common/service/erp/task/ErpScheduler.java | 20 +++++++++ 3 files changed, 68 insertions(+), 10 deletions(-) diff --git a/src/main/java/com/zy/common/service/erp/ErpService.java b/src/main/java/com/zy/common/service/erp/ErpService.java index 6cea27b..a681f41 100644 --- a/src/main/java/com/zy/common/service/erp/ErpService.java +++ b/src/main/java/com/zy/common/service/erp/ErpService.java @@ -1,5 +1,7 @@ package com.zy.common.service.erp; +import com.core.common.Cools; +import com.zy.common.service.erp.dto.VoucherDto; import com.zy.common.service.erp.entity.Goods; import com.zy.common.service.erp.entity.Voucher; import com.zy.common.service.erp.entity.VoucherDetail; @@ -8,6 +10,7 @@ import org.springframework.jdbc.core.JdbcTemplate; import org.springframework.stereotype.Service; +import java.util.ArrayList; import java.util.List; /** @@ -27,27 +30,44 @@ /** * 鑾峰彇GOODS琛� */ - public List<Goods> selectGoods(Integer IsGetData) { -// String sql = "select * from Goods where IsGetData = '" + IsGetData +"'"; - String sql = "select * from Goods where 1=1"; + public List<Goods> selectGoods(Integer state) { + String sql = "select * from Goods where 1=1 where state = '" + state + "'"; return erpSqlServer.select(sql, Goods.class); } + + public List<VoucherDto> selectOrder(Integer state) { + List<VoucherDto> list = new ArrayList<>(); + List<Voucher> voucherList = this.selectVoucher(state); + if (!Cools.isEmpty(voucherList)) { + for (Voucher voucher : voucherList) { + List<VoucherDetail> voucherDetails = this.selectVoucherDetail(voucher.getVoucherID()); + if (!Cools.isEmpty(voucherDetails)) { + VoucherDto dto = new VoucherDto(); + list.add(dto); + dto.setVoucher(voucher); + dto.setDetails(voucherDetails); + } else { + log.error("{}鍗曟嵁鎵句笉鍒版槑缁嗭紝璇锋敞鎰忔鏌�", voucher.getVoucherID()); + } + } + } + return list; + } + /** * 鑾峰彇Voucher琛� */ - public List<Voucher> selectVoucher(Integer IsGetData) { -// String sql = "select * from Goods where IsGetData = '" + IsGetData +"'"; - String sql = "select * from Voucher where 1=1"; + public List<Voucher> selectVoucher(Integer state) { + String sql = "select * from Voucher where 1=1 where state = '" + state + "'"; return erpSqlServer.select(sql, Voucher.class); } /** * 鑾峰彇VoucherDetail琛� */ - public List<VoucherDetail> selectVoucherDetail(Integer IsGetData) { -// String sql = "select * from Goods where IsGetData = '" + IsGetData +"'"; - String sql = "select * from VoucherDetail where 1=1"; + public List<VoucherDetail> selectVoucherDetail(String VoucherID) { + String sql = "select * from VoucherDetail where 1=1 where VoucherID = '" + VoucherID + "'"; return erpSqlServer.select(sql, VoucherDetail.class); } diff --git a/src/main/java/com/zy/common/service/erp/dto/VoucherDto.java b/src/main/java/com/zy/common/service/erp/dto/VoucherDto.java new file mode 100644 index 0000000..c77e59d --- /dev/null +++ b/src/main/java/com/zy/common/service/erp/dto/VoucherDto.java @@ -0,0 +1,20 @@ +package com.zy.common.service.erp.dto; + +import com.zy.common.service.erp.entity.Voucher; +import com.zy.common.service.erp.entity.VoucherDetail; +import lombok.Data; + +import java.util.ArrayList; +import java.util.List; + +/** + * Created by vincent on 2022/12/8 + */ +@Data +public class VoucherDto { + + private Voucher voucher; + + private List<VoucherDetail> details = new ArrayList<>(); + +} diff --git a/src/main/java/com/zy/common/service/erp/task/ErpScheduler.java b/src/main/java/com/zy/common/service/erp/task/ErpScheduler.java index d60e592..64efa11 100644 --- a/src/main/java/com/zy/common/service/erp/task/ErpScheduler.java +++ b/src/main/java/com/zy/common/service/erp/task/ErpScheduler.java @@ -2,6 +2,7 @@ import com.alibaba.fastjson.JSON; import com.core.common.Cools; +import com.core.common.DateUtils; import com.core.exception.CoolException; import com.zy.asrs.entity.Mat; import com.zy.asrs.entity.Tag; @@ -9,6 +10,7 @@ import com.zy.asrs.service.TagService; import com.zy.asrs.task.AbstractHandler; import com.zy.common.service.erp.ErpService; +import com.zy.common.service.erp.dto.VoucherDto; import com.zy.common.service.erp.entity.Goods; import lombok.Synchronized; import lombok.extern.slf4j.Slf4j; @@ -17,6 +19,7 @@ import org.springframework.stereotype.Component; import org.springframework.transaction.annotation.Transactional; +import java.util.Date; import java.util.List; /** @@ -39,7 +42,8 @@ @Transactional public synchronized void syncMat() { Tag top = tagService.getTop(); - List<Goods> goods = erpService.selectGoods(1); + List<Goods> goods = erpService.selectGoods(0); + Date now = new Date(); if (!Cools.isEmpty(goods)) { for (Goods good : goods) { Mat mat = matService.selectByMatnr(good.getBarCode()); @@ -54,6 +58,12 @@ mat.setUnits(good.getNumOfBobbins()==null?null:good.getNumOfBobbins().doubleValue()); mat.setManuDate(good.getProdDate()); + mat.setCreateTime(now); + mat.setSku(good.getLocation()); + if (!Cools.isEmpty(good.getLastUpdatedDate())) { + mat.setUpdateTime(DateUtils.convert(good.getLastUpdatedDate().substring(0, 19))); + } + if (!matService.insert(mat)) { throw new CoolException(JSON.toJSONString(good) + "鍟嗗搧鍚屾澶辫触"); } @@ -62,4 +72,12 @@ } } + @Scheduled(cron = "0/5 * * * * ? ") + @Synchronized + @Transactional + public synchronized void syncOrder() { + List<VoucherDto> list = erpService.selectOrder(0); + System.out.println(JSON.toJSONString(list)); + } + } -- Gitblit v1.9.1