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; import lombok.extern.slf4j.Slf4j; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.jdbc.core.JdbcTemplate; import org.springframework.stereotype.Service; import java.util.ArrayList; import java.util.List; /** * Created by vincent on 2020/11/27 */ @Slf4j @Service public class ErpService { @Autowired private ErpSqlServer erpSqlServer; @Autowired private JdbcTemplate jdbcTemplate; //////////////////////成品、原材料入库通知单数据提取////////////////////////////////////////////////// /** * 获取GOODS表 */ public List selectGoods(Integer state) { String sql = "select * from Goods where 1=1 where state = '" + state + "'"; return erpSqlServer.select(sql, Goods.class); } public List selectOrder(Integer state) { List list = new ArrayList<>(); List voucherList = this.selectVoucher(state); if (!Cools.isEmpty(voucherList)) { for (Voucher voucher : voucherList) { List 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 selectVoucher(Integer state) { String sql = "select * from Voucher where 1=1 where state = '" + state + "'"; return erpSqlServer.select(sql, Voucher.class); } /** * 获取VoucherDetail表 */ public List selectVoucherDetail(String VoucherID) { String sql = "select * from VoucherDetail where 1=1 where VoucherID = '" + VoucherID + "'"; return erpSqlServer.select(sql, VoucherDetail.class); } }