|  |  | 
 |  |  | package com.zy.common.service.erp; | 
 |  |  |  | 
 |  |  | import com.core.common.Cools; | 
 |  |  | import com.core.common.DateUtils; | 
 |  |  | import com.zy.common.service.erp.dto.VoucherDto; | 
 |  |  | import com.zy.common.service.erp.entity.Goods; | 
 |  |  | import com.zy.common.service.erp.entity.Voucher; | 
 |  |  | 
 |  |  |         return erpSqlServer.select(sql, Goods.class); | 
 |  |  |     } | 
 |  |  |  | 
 |  |  |     public Goods selectGoodsOne(String barCode) { | 
 |  |  |         String sql = "select top 1 * from Goods where BarCode = '" + barCode + "'"; | 
 |  |  |         List<Goods> select = erpSqlServer.select(sql, Goods.class); | 
 |  |  |         if (Cools.isEmpty(select)) { | 
 |  |  |             return null; | 
 |  |  |         } else { | 
 |  |  |             return select.get(0); | 
 |  |  |         } | 
 |  |  |     } | 
 |  |  |  | 
 |  |  |     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) { | 
 |  |  |                 VoucherDto dto = new VoucherDto(); | 
 |  |  |                 dto.setVoucher(voucher); | 
 |  |  |                 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()); | 
 |  |  |                 } | 
 |  |  |                 list.add(dto); | 
 |  |  |             } | 
 |  |  |         } | 
 |  |  |         return list; | 
 |  |  | 
 |  |  |      * 修改 Goods 表 state | 
 |  |  |      */ | 
 |  |  |     public boolean updateStateForGoods(String barcode, Integer state){ | 
 |  |  |         String sql = "update Goods set State = ''{1}'', LastUpdatedDate = ''{{2}}'' where BarCode = ''{0}''"; | 
 |  |  |         sql = MessageFormat.format(sql, barcode, state, new Date()); | 
 |  |  |         String sql = "update Goods set State = ''{1}'', LastUpdatedDate = ''{2}'' where BarCode = ''{0}''"; | 
 |  |  |         sql = MessageFormat.format(sql, barcode, state, DateUtils.convert(new Date())); | 
 |  |  |         return erpSqlServer.update(sql) > 0; | 
 |  |  |     } | 
 |  |  |  | 
 |  |  |     /** | 
 |  |  |      * 修改 Goods 表 state, location | 
 |  |  |      */ | 
 |  |  |     public boolean updateStateAndLocForGoods(String barcode, Integer state, String loc){ | 
 |  |  |         String sql = "update Goods set State = ''{1}'', LastUpdatedDate = ''{2}'', Location = ''{3}'' where BarCode = ''{0}''"; | 
 |  |  |         sql = MessageFormat.format(sql, barcode, state, DateUtils.convert(new Date()), loc); | 
 |  |  |         return erpSqlServer.update(sql) > 0; | 
 |  |  |     } | 
 |  |  |  | 
 |  |  |     /** | 
 |  |  |      * 修改 Voucher 表 state | 
 |  |  |      */ | 
 |  |  |     public boolean updateStateForVoucher(String voucherID, Integer state){ | 
 |  |  |         String sql = "update Voucher set State = ''{1}'', LastUpdatedDate = ''{2}'' where VoucherID = ''{0}''"; | 
 |  |  |         sql = MessageFormat.format(sql, voucherID, state, DateUtils.convert(new Date())); | 
 |  |  |         return erpSqlServer.update(sql) > 0; | 
 |  |  |     } | 
 |  |  |  | 
 |  |  |     /** | 
 |  |  |      * 修改 VoucherDetail 表 | 
 |  |  |      */ | 
 |  |  |     public boolean updateTimeForVoucherDetail(String voucherID){ | 
 |  |  |         String sql = "update VoucherDetail set LastUpdatedDate = ''{1}'' where VoucherID = ''{0}''"; | 
 |  |  |         sql = MessageFormat.format(sql, voucherID, DateUtils.convert(new Date())); | 
 |  |  |         return erpSqlServer.update(sql) > 0; | 
 |  |  |     } | 
 |  |  |  | 
 |  |  |     /** | 
 |  |  |      * 新增 VoucherDetail 表 | 
 |  |  |      */ | 
 |  |  |     public boolean insertVoucherDetail(VoucherDetail voucherDetail){ | 
 |  |  |         String sql = "insert [VoucherDetail] ([VoucherID], [Barcode], [PickID], [LastUpdatedDate]) values (''{0}'', ''{1}'', ''{2}'', ''{3}'');"; | 
 |  |  |         sql = MessageFormat.format(sql | 
 |  |  |                 , voucherDetail.getVoucherID() | 
 |  |  |                 , voucherDetail.getBarcode() | 
 |  |  |                 , voucherDetail.getPickID() | 
 |  |  |                 , voucherDetail.getLastUpdatedDate()); | 
 |  |  |         return erpSqlServer.update(sql) > 0; | 
 |  |  |     } | 
 |  |  |  | 
 |  |  | } |