فهرست منبع

入库按钮和撤销按钮问题

3254194295 3 سال پیش
والد
کامیت
4f5a11bf24

+ 1 - 1
platform-dao/src/main/java/com/platform/dao/mapper/store/StoreMapper.java

@@ -25,5 +25,5 @@ public interface StoreMapper extends MyMapper<Store> {
 
     List<StoreVO> selectVOList(StoreDTO model);
 
-    Integer getStoreNums(String userId);
+    Integer getStoreNums(StoreDTO storeDTO);
 }

+ 15 - 1
platform-rest/src/main/java/com/platform/rest/controller/store/InStoreFormController.java

@@ -80,10 +80,24 @@ public class InStoreFormController {
     @PutMapping("/in/{id}")
     @PreAuthorize("@pms.hasPermission('store-in-store-forms-edit')")
     public R updateStore(@PathVariable("id") String id) {
-        inStoreFormService.updateStore(id);
+        inStoreFormService.updateStore(id,false);
         return new R<>();
     }
 
+  /**
+   * 更新库存
+   *
+   * @param id 入库登记表DTO
+   * @return R
+   */
+  @SysLog("更新库存")
+  @PutMapping("/back/{id}")
+  @PreAuthorize("@pms.hasPermission('store-in-store-forms-edit')")
+  public R updateStore2(@PathVariable("id") String id) {
+    inStoreFormService.updateStore(id,true);
+    return new R<>();
+  }
+
   /**
    * 通过id删除一条记录
    *

+ 1 - 1
platform-service/src/main/java/com/platform/service/store/InStoreFormService.java

@@ -83,7 +83,7 @@ public interface InStoreFormService extends IBaseService<InStoreForm, InStoreFor
      * @param id
      * @return
      */
-    void updateStore(String id);
+    void updateStore(String id,boolean flag);
 
     InStoreForm saveModelByBackForm(SpareBackFormDTO sparePickFormDTO, List<SpareBackDetailVO> selectDetailList);
     void saveModelByStoreCheckJob(List<StoreCheckJobVO> jobs);

+ 81 - 77
platform-service/src/main/java/com/platform/service/store/impl/InStoreFormServiceImpl.java

@@ -69,8 +69,8 @@ public class InStoreFormServiceImpl extends BaseServiceImpl<InStoreFormMapper, I
     private InStoreFormMapper inStoreFormMapper;
     private OutStoreFormMapper outStoreFormMapper;
     private StoreMapper storeMapper;
-    private PurchaseStoreFormDetailMapper purchaseStoreFormDetailMapper;
-    private PurchaseStoreFormMapper purchaseStoreFormMapper;
+//    private PurchaseStoreFormDetailMapper purchaseStoreFormDetailMapper;
+//    private PurchaseStoreFormMapper purchaseStoreFormMapper;
 
 
     @Override
@@ -139,7 +139,7 @@ public class InStoreFormServiceImpl extends BaseServiceImpl<InStoreFormMapper, I
     public StoreWorkBenchVO getStoreWorkBenchVO(String userId) {
         StoreDTO query=new StoreDTO();
         query.setUserId(userId);
-        Integer count=storeMapper.getStoreNums(userId);
+        Integer count=storeMapper.getStoreNums(query);
 
         SpareStoreDTO spareStoreDTO=new SpareStoreDTO();
         spareStoreDTO.setUserId(userId);
@@ -370,7 +370,7 @@ public class InStoreFormServiceImpl extends BaseServiceImpl<InStoreFormMapper, I
         ;
         inStoreForm.setTotalPrice(totalPrice);
         mapper.updateByPrimaryKey(inStoreForm);
-        updateStore(inStoreForm.getId());
+        updateStore(inStoreForm.getId(),false);
         return inStoreForm;
     }
 
@@ -406,7 +406,7 @@ public class InStoreFormServiceImpl extends BaseServiceImpl<InStoreFormMapper, I
         }
         ;
         // 更新库存
-        updateStore(inStoreForm.getId());
+        updateStore(inStoreForm.getId(),false);
         return inStoreForm;
     }
 
@@ -534,7 +534,7 @@ public class InStoreFormServiceImpl extends BaseServiceImpl<InStoreFormMapper, I
         }
 
         // 采购验收后,直接入库,并通知仓库负责人
-        this.updateStore(inStoreForm.getId());
+        this.updateStore(inStoreForm.getId(),false);
         SpringContextHolder.publishEvent(new WorkplaceBacklogEvent(WorkplaceBacklogTypeEnum.PURCHASE_WUZI_MESSAGE.getValue(), WorkplaceBacklogDetailTypeEnum.PURCHASE_WUZI_MESSAGE.getValue(),
                 inStoreForm.getId(), MessageTemplateUtil.getPurchaseWuZiInStore(inStoreForm.getId()),
                 inStoreForm.getId(), ListUtils.newArrayList(store.getUserId())));
@@ -552,16 +552,20 @@ public class InStoreFormServiceImpl extends BaseServiceImpl<InStoreFormMapper, I
      * @param id
      */
     @Override
-    public void updateStore(String id) {
+    public void updateStore(String id,boolean flag) {
         // 入库单详情
         UserInfo userInfo = SecurityUtils.getUserInfo();
         InStoreForm model = this.getModelById(id);
         // 采购单入库的路由至新流程
-        if(InStoreTypeEnum.CAIGOU_RUKU.getValue() == model.getType()){
-            handlePurchaseInForm(model,userInfo);
-            return;
+//        if(InStoreTypeEnum.CAIGOU_RUKU.getValue() == model.getType()){
+//            handlePurchaseInForm(model,userInfo);
+//            return;
+//        }
+        if(flag){
+            model.setStatus(InStoreStatusEnum.NOT_EXECUTE.getValue());
+        }else{
+            model.setStatus(InStoreStatusEnum.EXECUTING.getValue());
         }
-        model.setStatus(InStoreStatusEnum.NOT_EXECUTE.getValue());
         mapper.updateByPrimaryKey(model);
 
         // 找到明细
@@ -619,64 +623,64 @@ public class InStoreFormServiceImpl extends BaseServiceImpl<InStoreFormMapper, I
      * 处理采购入库单的入库操作
      * @param form
      */
-    @Transactional(rollbackFor = Exception.class)
-    void handlePurchaseInForm(InStoreForm form,UserInfo userInfo){
-        PurchaseStoreForm storeForm = new PurchaseStoreForm();
-        storeForm.setId(form.getPurchaseId());
-        storeForm.setUpdateUserName(userInfo.getUsername());
-        storeForm.setUpdateUserId(userInfo.getUserId());
-        storeForm.setUpdateTime(LocalDateTime.now());
-        try{
-            String storeId = form.getStoreId();
-            // 找到入库备件明细
-            Weekend<PurchaseStoreFormDetail> detailWeekend = new Weekend<>(PurchaseStoreFormDetail.class);
-            detailWeekend.weekendCriteria().andEqualTo(PurchaseStoreFormDetail::getPurchaseStoreFormId, form.getPurchaseId()).andEqualTo(PurchaseStoreFormDetail::getDeleteFlag,PurchaseStoreFormDetailDelFlagEnum.NORMAL.getValue());
-            List<PurchaseStoreFormDetail> detailList = purchaseStoreFormDetailMapper.selectByExample(detailWeekend);
-            // 更新库存
-            for (PurchaseStoreFormDetail detail : detailList) {
-                // 更新库存信息
-                Weekend<SpareStore> spareStoreWeekend = new Weekend<>(SpareStore.class);
-                spareStoreWeekend.weekendCriteria().andEqualTo(SpareStore::getSpareId, detail.getSparePartInfoId())
-                        .andEqualTo(SpareStore::getStoreId, storeId);
-                SpareStore spareStore = spareStoreMapper.selectOneByExample(spareStoreWeekend);
-                if (ObjectUtil.isNull(spareStore)) {
-                    spareStore = new SpareStore();
-                    spareStore.setCreatedUserId(userInfo.getUserId());
-                    spareStore.setCreatedUserName(userInfo.getRealName());
-                    spareStore.setCreatedTime(LocalDateTime.now());
-                    spareStore.setId(IdGeneratorUtils.getObjectId());
-                    spareStore.setNum(detail.getNum());
-                    spareStore.setSpareId(detail.getSparePartInfoId());
-                    spareStore.setDelFlag(DelFlagEnum.NORMAL.getValue());
-                    spareStore.setStoreId(storeId);
-                    spareStore.setPrice(detail.getPrice());
-                    spareStore.setInitPrice(detail.getPrice());
-                    spareStore.setInitPurchasePrice(detail.getPrice());
-                    spareStoreMapper.insertSelective(spareStore);
-                } else {
-                    // 重新计算商品库存价格
-                    spareStore.setUpdateTime(LocalDateTime.now());
-                    spareStore.setUpdateUserId(userInfo.getUserId());
-                    spareStore.setUpdateUserName(userInfo.getRealName());
-                    spareStore.setPrice(getNewPrice(spareStore, detail));
-                    spareStore.setNum(BigDecimalUtil.add(spareStore.getNum(), detail.getNum()));
-                    spareStoreMapper.updateByPrimaryKeySelective(spareStore);
-                }
-            }
-            // 修改入库单状态
-            InStoreForm updForm = new InStoreForm();
-            updForm.setId(form.getId());
-            updForm.setStatus(InStoreStatusEnum.EXECUTING.getValue());
-            mapper.updateByPrimaryKey(updForm);
-            // 修正采购入库单状态
-            storeForm.setStatus(PurchaseStoreFormStatusEnum.COMPLETED.getValue());
-        }catch (Exception e){
-            log.error("采购入库失败----------------"+e.getCause().getMessage());
-            storeForm.setStatus(PurchaseStoreFormStatusEnum.STORE_FAIL.getValue());
-        }finally {
-            purchaseStoreFormMapper.updateByPrimaryKey(storeForm);
-        }
-    }
+//    @Transactional(rollbackFor = Exception.class)
+//    void handlePurchaseInForm(InStoreForm form,UserInfo userInfo){
+//        PurchaseStoreForm storeForm = new PurchaseStoreForm();
+//        storeForm.setId(form.getPurchaseId());
+//        storeForm.setUpdateUserName(userInfo.getUsername());
+//        storeForm.setUpdateUserId(userInfo.getUserId());
+//        storeForm.setUpdateTime(LocalDateTime.now());
+//        try{
+//            String storeId = form.getStoreId();
+//            // 找到入库备件明细
+//            Weekend<PurchaseStoreFormDetail> detailWeekend = new Weekend<>(PurchaseStoreFormDetail.class);
+//            detailWeekend.weekendCriteria().andEqualTo(PurchaseStoreFormDetail::getPurchaseStoreFormId, form.getPurchaseId()).andEqualTo(PurchaseStoreFormDetail::getDeleteFlag,PurchaseStoreFormDetailDelFlagEnum.NORMAL.getValue());
+//            List<PurchaseStoreFormDetail> detailList = purchaseStoreFormDetailMapper.selectByExample(detailWeekend);
+//            // 更新库存
+//            for (PurchaseStoreFormDetail detail : detailList) {
+//                // 更新库存信息
+//                Weekend<SpareStore> spareStoreWeekend = new Weekend<>(SpareStore.class);
+//                spareStoreWeekend.weekendCriteria().andEqualTo(SpareStore::getSpareId, detail.getSparePartInfoId())
+//                        .andEqualTo(SpareStore::getStoreId, storeId);
+//                SpareStore spareStore = spareStoreMapper.selectOneByExample(spareStoreWeekend);
+//                if (ObjectUtil.isNull(spareStore)) {
+//                    spareStore = new SpareStore();
+//                    spareStore.setCreatedUserId(userInfo.getUserId());
+//                    spareStore.setCreatedUserName(userInfo.getRealName());
+//                    spareStore.setCreatedTime(LocalDateTime.now());
+//                    spareStore.setId(IdGeneratorUtils.getObjectId());
+//                    spareStore.setNum(detail.getNum());
+//                    spareStore.setSpareId(detail.getSparePartInfoId());
+//                    spareStore.setDelFlag(DelFlagEnum.NORMAL.getValue());
+//                    spareStore.setStoreId(storeId);
+//                    spareStore.setPrice(detail.getPrice());
+//                    spareStore.setInitPrice(detail.getPrice());
+//                    spareStore.setInitPurchasePrice(detail.getPrice());
+//                    spareStoreMapper.insertSelective(spareStore);
+//                } else {
+//                    // 重新计算商品库存价格
+//                    spareStore.setUpdateTime(LocalDateTime.now());
+//                    spareStore.setUpdateUserId(userInfo.getUserId());
+//                    spareStore.setUpdateUserName(userInfo.getRealName());
+//                    spareStore.setPrice(getNewPrice(spareStore, detail));
+//                    spareStore.setNum(BigDecimalUtil.add(spareStore.getNum(), detail.getNum()));
+//                    spareStoreMapper.updateByPrimaryKeySelective(spareStore);
+//                }
+//            }
+//            // 修改入库单状态
+//            InStoreForm updForm = new InStoreForm();
+//            updForm.setId(form.getId());
+//            updForm.setStatus(InStoreStatusEnum.EXECUTING.getValue());
+//            mapper.updateByPrimaryKey(updForm);
+//            // 修正采购入库单状态
+//            storeForm.setStatus(PurchaseStoreFormStatusEnum.COMPLETED.getValue());
+//        }catch (Exception e){
+//            log.error("采购入库失败----------------"+e.getCause().getMessage());
+//            storeForm.setStatus(PurchaseStoreFormStatusEnum.STORE_FAIL.getValue());
+//        }finally {
+//            purchaseStoreFormMapper.updateByPrimaryKey(storeForm);
+//        }
+//    }
 
     /**
      * 软件修改后,可以通过新增来处理库存单价和数量不符的情况,首先看看库存数量,若是数量是对的,就入一个为0的数量进去,
@@ -697,13 +701,13 @@ public class InStoreFormServiceImpl extends BaseServiceImpl<InStoreFormMapper, I
         return price;
     }
 
-    private BigDecimal getNewPrice(SpareStore spareStore, PurchaseStoreFormDetail detail) {
-        BigDecimal totalStorePrice = BigDecimalUtil.mul(spareStore.getPrice(), spareStore.getNum());
-        BigDecimal totalPrice = BigDecimalUtil.add(totalStorePrice, detail.getTotalPrice());
-        BigDecimal totalNum = BigDecimalUtil.add(spareStore.getNum(), detail.getNum());
-        BigDecimal price = BigDecimalUtil.div(totalPrice, totalNum);
-        return price;
-    }
+//    private BigDecimal getNewPrice(SpareStore spareStore, PurchaseStoreFormDetail detail) {
+//        BigDecimal totalStorePrice = BigDecimalUtil.mul(spareStore.getPrice(), spareStore.getNum());
+//        BigDecimal totalPrice = BigDecimalUtil.add(totalStorePrice, detail.getTotalPrice());
+//        BigDecimal totalNum = BigDecimalUtil.add(spareStore.getNum(), detail.getNum());
+//        BigDecimal price = BigDecimalUtil.div(totalPrice, totalNum);
+//        return price;
+//    }
 
     @Override
     public InStoreForm saveModelByBackForm(SpareBackFormDTO sparePickFormDTO, List<SpareBackDetailVO> selectDetailList) {
@@ -801,7 +805,7 @@ public class InStoreFormServiceImpl extends BaseServiceImpl<InStoreFormMapper, I
         }
         if (!CollectionUtils.isEmpty(formList)) {
             for (InStoreForm form : formList) {
-                updateStore(form.getId());
+                updateStore(form.getId(),false);
             }
         }