|
@@ -83,33 +83,41 @@ public class PurchasePriceServiceImpl extends ServiceImpl<PurchasePriceMapper, P
|
|
|
@Override
|
|
|
@Transactional(rollbackFor = Exception.class)
|
|
|
public String purchasePriceAdd(PurchasePrice purchasePrice) {
|
|
|
- try{
|
|
|
- String compId = purchasePrice.getCompId();
|
|
|
- String mainId = IdGenerator.generateUUID();
|
|
|
- purchasePrice.setId(mainId);
|
|
|
- purchasePrice.setStatus(StatusEnum.PURCHASE_REVIEWED.getName());
|
|
|
- purchasePrice.setStatusFlag(StatusEnum.PURCHASE_REVIEWED.getFlag());
|
|
|
- // 操作主表数据
|
|
|
- this.insert(purchasePrice);
|
|
|
-
|
|
|
- // 操作明细表数据
|
|
|
- for(PurchasePriceDetail tmp : purchasePrice.getDetails()){
|
|
|
- tmp.setId(IdGenerator.generateUUID());
|
|
|
- tmp.setCompId(compId);
|
|
|
- tmp.setMainId(mainId);
|
|
|
- this.purchasePriceDetailService.insert(tmp);
|
|
|
- }
|
|
|
- // 操作打印表数据
|
|
|
- for(PurchasePriceDetailPrint tmp : purchasePrice.getDetailPrints()){
|
|
|
- tmp.setId(IdGenerator.generateUUID());
|
|
|
- tmp.setCompId(compId);
|
|
|
- tmp.setMainId(mainId);
|
|
|
- this.purchasePriceDetailPrintService.insert(tmp);
|
|
|
- }
|
|
|
- return "ok";
|
|
|
+ //查同一仓库同一货名是否已设置
|
|
|
+ List<PurchasePrice> purchasePriceList=this.selectList(new EntityWrapper<PurchasePrice>()
|
|
|
+ .eq("warehouse_id",purchasePrice.getWarehouseId())
|
|
|
+ .eq("goods_name",purchasePrice.getGoodsName()));
|
|
|
+ if (!CollectionUtils.isEmpty(purchasePriceList)){
|
|
|
+ throw new YException(YExceptionEnum.PURCHASE_PRICE_ERROR);
|
|
|
}
|
|
|
- catch (Exception e){
|
|
|
- System.out.println("新增收购价格异常:"+e.toString());
|
|
|
+ else {
|
|
|
+ try {
|
|
|
+ String compId = purchasePrice.getCompId();
|
|
|
+ String mainId = IdGenerator.generateUUID();
|
|
|
+ purchasePrice.setId(mainId);
|
|
|
+ purchasePrice.setStatus(StatusEnum.PURCHASE_REVIEWED.getName());
|
|
|
+ purchasePrice.setStatusFlag(StatusEnum.PURCHASE_REVIEWED.getFlag());
|
|
|
+ // 操作主表数据
|
|
|
+ this.insert(purchasePrice);
|
|
|
+
|
|
|
+ // 操作明细表数据
|
|
|
+ for (PurchasePriceDetail tmp : purchasePrice.getDetails()) {
|
|
|
+ tmp.setId(IdGenerator.generateUUID());
|
|
|
+ tmp.setCompId(compId);
|
|
|
+ tmp.setMainId(mainId);
|
|
|
+ this.purchasePriceDetailService.insert(tmp);
|
|
|
+ }
|
|
|
+ // 操作打印表数据
|
|
|
+ for (PurchasePriceDetailPrint tmp : purchasePrice.getDetailPrints()) {
|
|
|
+ tmp.setId(IdGenerator.generateUUID());
|
|
|
+ tmp.setCompId(compId);
|
|
|
+ tmp.setMainId(mainId);
|
|
|
+ this.purchasePriceDetailPrintService.insert(tmp);
|
|
|
+ }
|
|
|
+ return "ok";
|
|
|
+ } catch (Exception e) {
|
|
|
+ System.out.println("新增收购价格异常:" + e.toString());
|
|
|
+ }
|
|
|
}
|
|
|
boolean isStartWorkflow = StringUtils.isBlank(purchasePrice.getWorkflowId());
|
|
|
// 不是退回的单子
|
|
@@ -211,4 +219,40 @@ public class PurchasePriceServiceImpl extends ServiceImpl<PurchasePriceMapper, P
|
|
|
this.warehouseBaseInfoService.updateById(warehouseBaseInfo);
|
|
|
return "ok";
|
|
|
}
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 查潮粮单价
|
|
|
+ * @param purchasePrice
|
|
|
+ * @return
|
|
|
+ */
|
|
|
+ @Override
|
|
|
+ public Float tidalGrainPrice(PurchasePrice purchasePrice) {
|
|
|
+ Float tidalGrainPrice=0.0f;
|
|
|
+ PurchasePrice purchasePrice1=this.selectOne(new EntityWrapper<PurchasePrice>()
|
|
|
+ .eq("warehouse_id",purchasePrice.getWarehouseId())
|
|
|
+ .eq("goods_name",purchasePrice.getGoodsName())
|
|
|
+ .eq("status_flag","3"));
|
|
|
+ if (purchasePrice1!=null){
|
|
|
+ PurchasePriceDetailPrint purchasePriceDetailPrint=purchasePriceDetailPrintService.selectOne(new EntityWrapper<PurchasePriceDetailPrint>()
|
|
|
+ .eq("main_id",purchasePrice1.getId())
|
|
|
+ .le("water_min",purchasePrice.getWaterContent())
|
|
|
+ .ge("water_max",purchasePrice.getWaterContent()));
|
|
|
+ if (purchasePriceDetailPrint!=null){
|
|
|
+ if ("一等品".equals(purchasePrice.getGrade())){
|
|
|
+ tidalGrainPrice=purchasePriceDetailPrint.getPrice1();
|
|
|
+ }
|
|
|
+ else if ("二等品".equals(purchasePrice.getGrade())){
|
|
|
+ tidalGrainPrice=purchasePriceDetailPrint.getPrice2();
|
|
|
+ }
|
|
|
+ if ("三等品".equals(purchasePrice.getGrade())){
|
|
|
+ tidalGrainPrice=purchasePriceDetailPrint.getPrice3();
|
|
|
+ }
|
|
|
+ if ("等外".equals(purchasePrice.getGrade())){
|
|
|
+ tidalGrainPrice=purchasePriceDetailPrint.getPriceOther();
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return tidalGrainPrice;
|
|
|
+ }
|
|
|
+
|
|
|
}
|