Browse Source

仓库报表

3254194295 3 years ago
parent
commit
6870b67e06

+ 5 - 1
platform-dao/src/main/java/com/platform/dao/enums/InStoreTypeEnum.java

@@ -32,7 +32,11 @@ public enum InStoreTypeEnum {
     /**
     /**
      * 盘点校准
      * 盘点校准
      */
      */
-    STORE_CHECK(5);
+    STORE_CHECK(5),
+    /**
+     * 包含发运入库和盘点校准
+     */
+    OTHER_RUKU(6);
 
 
     private Integer value;
     private Integer value;
 
 

+ 5 - 1
platform-dao/src/main/java/com/platform/dao/enums/OutStoreTypeEnum.java

@@ -32,7 +32,11 @@ public enum OutStoreTypeEnum {
     /**
     /**
      * 盘点校准
      * 盘点校准
      */
      */
-    STORE_CHECK(5);
+    STORE_CHECK(5),
+    /**
+     * 其他出库,包含4和5
+     */
+    CHUKU_OTHER(6);
 
 
     private Integer value;
     private Integer value;
 
 

+ 4 - 1
platform-dao/src/main/resources/mapper/store/InStoreFormMapper.xml

@@ -70,9 +70,12 @@
         <if test="inNo != null and inNo != ''">
         <if test="inNo != null and inNo != ''">
             and instoreform.in_no = #{inNo}
             and instoreform.in_no = #{inNo}
         </if>
         </if>
-        <if test="type != null">
+        <if test="type != null and type!=6">
             and instoreform.type = #{type}
             and instoreform.type = #{type}
         </if>
         </if>
+        <if test="type==6">
+            and (instoreform.type=4 or instoreform.type=5)
+        </if>
         <if test="remark != null and remark != ''">
         <if test="remark != null and remark != ''">
             and instoreform.remark = #{remark}
             and instoreform.remark = #{remark}
         </if>
         </if>

+ 5 - 2
platform-dao/src/main/resources/mapper/store/OutStoreFormMapper.xml

@@ -53,8 +53,11 @@
         <if test="outNo != null and outNo != ''">
         <if test="outNo != null and outNo != ''">
             and outstoreform.out_no = #{outNo}
             and outstoreform.out_no = #{outNo}
         </if>
         </if>
-        <if test="type != null">
-            and outstoreform.type = #{type}
+        <if test="type != null and type!=6">
+            and instoreform.type = #{type}
+        </if>
+        <if test="type==6">
+            and (instoreform.type=4 or instoreform.type=5)
         </if>
         </if>
         <if test="remark != null and remark != ''">
         <if test="remark != null and remark != ''">
             and outstoreform.remark = #{remark}
             and outstoreform.remark = #{remark}

+ 73 - 70
platform-service/src/main/java/com/platform/service/store/impl/InStoreFormServiceImpl.java

@@ -77,7 +77,7 @@ public class InStoreFormServiceImpl extends BaseServiceImpl<InStoreFormMapper, I
 
 
     @Override
     @Override
     public StoreWorkBenchVO getCurrentlyList(String userId) {
     public StoreWorkBenchVO getCurrentlyList(String userId) {
-        StoreWorkBenchVO storeWorkBenchVO=new StoreWorkBenchVO();
+        StoreWorkBenchVO storeWorkBenchVO = new StoreWorkBenchVO();
         LocalDateTime now = LocalDateTime.now();
         LocalDateTime now = LocalDateTime.now();
 
 
         List<LocalDateTime> currentWeekStartAndEndList = DateUtils.currentWeek();
         List<LocalDateTime> currentWeekStartAndEndList = DateUtils.currentWeek();
@@ -85,7 +85,7 @@ public class InStoreFormServiceImpl extends BaseServiceImpl<InStoreFormMapper, I
         LocalDateTime searchEndTime = now.withHour(23).withMinute(59).withSecond(59);
         LocalDateTime searchEndTime = now.withHour(23).withMinute(59).withSecond(59);
         // 总数
         // 总数
         InStoreFormDTO queryDTO = new InStoreFormDTO();
         InStoreFormDTO queryDTO = new InStoreFormDTO();
-        OutStoreFormDTO queryDTO2=new OutStoreFormDTO();
+        OutStoreFormDTO queryDTO2 = new OutStoreFormDTO();
         queryDTO2.setSearchStartTime(searchStartTime);
         queryDTO2.setSearchStartTime(searchStartTime);
         queryDTO2.setStatus(InStoreStatusEnum.EXECUTING.getValue());
         queryDTO2.setStatus(InStoreStatusEnum.EXECUTING.getValue());
         queryDTO.setStatus(OutStoreStatusEnum.EXECUTING.getValue());
         queryDTO.setStatus(OutStoreStatusEnum.EXECUTING.getValue());
@@ -95,25 +95,25 @@ public class InStoreFormServiceImpl extends BaseServiceImpl<InStoreFormMapper, I
         queryDTO.setUserId(userId);
         queryDTO.setUserId(userId);
         queryDTO2.setUserId(userId);
         queryDTO2.setUserId(userId);
         List<InStoreDetailVO> list = inStoreDetailMapper.getCurrentlyList(queryDTO) == null ? new ArrayList<>() : inStoreDetailMapper.getCurrentlyList(queryDTO);
         List<InStoreDetailVO> list = inStoreDetailMapper.getCurrentlyList(queryDTO) == null ? new ArrayList<>() : inStoreDetailMapper.getCurrentlyList(queryDTO);
-        List<OutStoreDetailVO> list2=outStoreDetailMapper.getCurrentlyList(queryDTO2) == null ? new ArrayList<>() : outStoreDetailMapper.getCurrentlyList(queryDTO2);
+        List<OutStoreDetailVO> list2 = outStoreDetailMapper.getCurrentlyList(queryDTO2) == null ? new ArrayList<>() : outStoreDetailMapper.getCurrentlyList(queryDTO2);
         List<InStoreDetailVO> result = new ArrayList<>();
         List<InStoreDetailVO> result = new ArrayList<>();
-        List<OutStoreDetailVO> result2=new ArrayList<>();
-        for(LocalDateTime tempDate: currentWeekStartAndEndList){
+        List<OutStoreDetailVO> result2 = new ArrayList<>();
+        for (LocalDateTime tempDate : currentWeekStartAndEndList) {
             InStoreDetailVO vo = new InStoreDetailVO();
             InStoreDetailVO vo = new InStoreDetailVO();
-            OutStoreDetailVO vo1=new OutStoreDetailVO();
+            OutStoreDetailVO vo1 = new OutStoreDetailVO();
             int tempTotalNum = 0;
             int tempTotalNum = 0;
             vo.setWeekDayName(tempDate.getDayOfWeek().getDisplayName(TextStyle.FULL, Locale.CHINA));
             vo.setWeekDayName(tempDate.getDayOfWeek().getDisplayName(TextStyle.FULL, Locale.CHINA));
             vo1.setWeekDayName(tempDate.getDayOfWeek().getDisplayName(TextStyle.FULL, Locale.CHINA));
             vo1.setWeekDayName(tempDate.getDayOfWeek().getDisplayName(TextStyle.FULL, Locale.CHINA));
-            for(InStoreDetailVO useVO: list){
-                if(useVO.getCreatedTime().toLocalDate().isEqual(tempDate.toLocalDate())){
-                    tempTotalNum+=1;
+            for (InStoreDetailVO useVO : list) {
+                if (useVO.getCreatedTime().toLocalDate().isEqual(tempDate.toLocalDate())) {
+                    tempTotalNum += 1;
                 }
                 }
             }
             }
             vo.setNum(new BigDecimal(tempTotalNum));
             vo.setNum(new BigDecimal(tempTotalNum));
-            int tempTotalNum2=0;
-            for(OutStoreDetailVO useVO: list2){
-                if(useVO.getCreatedTime().toLocalDate().isEqual(tempDate.toLocalDate())){
-                    tempTotalNum2+=1;
+            int tempTotalNum2 = 0;
+            for (OutStoreDetailVO useVO : list2) {
+                if (useVO.getCreatedTime().toLocalDate().isEqual(tempDate.toLocalDate())) {
+                    tempTotalNum2 += 1;
                 }
                 }
             }
             }
             vo1.setNum(new BigDecimal(tempTotalNum2));
             vo1.setNum(new BigDecimal(tempTotalNum2));
@@ -127,39 +127,39 @@ public class InStoreFormServiceImpl extends BaseServiceImpl<InStoreFormMapper, I
 
 
     @Override
     @Override
     public StoreWorkBenchVO getStoreWorkBenchVO(String userId) {
     public StoreWorkBenchVO getStoreWorkBenchVO(String userId) {
-        StoreDTO query=new StoreDTO();
+        StoreDTO query = new StoreDTO();
         query.setUserId(userId);
         query.setUserId(userId);
-        Integer count=storeMapper.getStoreNums(query);
+        Integer count = storeMapper.getStoreNums(query);
 
 
-        SpareStoreDTO spareStoreDTO=new SpareStoreDTO();
+        SpareStoreDTO spareStoreDTO = new SpareStoreDTO();
         spareStoreDTO.setUserId(userId);
         spareStoreDTO.setUserId(userId);
-        List<SpareStoreVO> spareStoreVOS=spareStoreMapper.selectList(spareStoreDTO);
-        Double totalPrice=0.0;
-        for(SpareStoreVO vo:spareStoreVOS){
-            totalPrice+=(vo.getNum().intValue())*(vo.getPrice().doubleValue());
+        List<SpareStoreVO> spareStoreVOS = spareStoreMapper.selectList(spareStoreDTO);
+        Double totalPrice = 0.0;
+        for (SpareStoreVO vo : spareStoreVOS) {
+            totalPrice += (vo.getNum().intValue()) * (vo.getPrice().doubleValue());
         }
         }
-        DecimalFormat df=new DecimalFormat("0.00");
-        Double s=new Double(df.format(totalPrice));
-        InStoreFormDTO queryDTO=new InStoreFormDTO();
+        DecimalFormat df = new DecimalFormat("0.00");
+        Double s = new Double(df.format(totalPrice));
+        InStoreFormDTO queryDTO = new InStoreFormDTO();
         queryDTO.setUserId(userId);
         queryDTO.setUserId(userId);
-        OutStoreFormDTO queryDTO2=new OutStoreFormDTO();
+        OutStoreFormDTO queryDTO2 = new OutStoreFormDTO();
         queryDTO2.setUserId(userId);
         queryDTO2.setUserId(userId);
-        List<OutStoreFormVO> outStoreFormVOS=outStoreFormMapper.selectOutStoreList(queryDTO2);
-        List<InStoreFormVO> inStoreFormVOS=inStoreFormMapper.getInStoreDetailVOs(queryDTO);
-        StoreWorkBenchVO storeWorkBenchVO=new StoreWorkBenchVO();
-        BigDecimal num=new BigDecimal(0);
-        BigDecimal purchaseNum=new BigDecimal(0);
-        BigDecimal xzNum=new BigDecimal(0);
-        BigDecimal dbNum=new BigDecimal(0);
-        BigDecimal otherNum=new BigDecimal(0);
-        BigDecimal num1=new BigDecimal(0);
-        BigDecimal lyNum=new BigDecimal(0);
-        BigDecimal dbNum2=new BigDecimal(0);
-        BigDecimal bfNum=new BigDecimal(0);
-        BigDecimal otherNum2=new BigDecimal(0);
-        BigDecimal pdNum=new BigDecimal(0);
-        for(OutStoreFormVO vo:outStoreFormVOS){
-            if(vo!=null) {
+        List<OutStoreFormVO> outStoreFormVOS = outStoreFormMapper.selectOutStoreList(queryDTO2);
+        List<InStoreFormVO> inStoreFormVOS = inStoreFormMapper.getInStoreDetailVOs(queryDTO);
+        StoreWorkBenchVO storeWorkBenchVO = new StoreWorkBenchVO();
+        BigDecimal num = new BigDecimal(0);
+        BigDecimal purchaseNum = new BigDecimal(0);
+        BigDecimal xzNum = new BigDecimal(0);
+        BigDecimal dbNum = new BigDecimal(0);
+        BigDecimal otherNum = new BigDecimal(0);
+        BigDecimal num1 = new BigDecimal(0);
+        BigDecimal lyNum = new BigDecimal(0);
+        BigDecimal dbNum2 = new BigDecimal(0);
+        BigDecimal bfNum = new BigDecimal(0);
+        BigDecimal otherNum2 = new BigDecimal(0);
+        BigDecimal pdNum = new BigDecimal(0);
+        for (OutStoreFormVO vo : outStoreFormVOS) {
+            if (vo != null) {
                 //领用出库
                 //领用出库
                 if ((OutStoreTypeEnum.CHUKU_LINGYONG.getValue()).equals(vo.getType())) {
                 if ((OutStoreTypeEnum.CHUKU_LINGYONG.getValue()).equals(vo.getType())) {
                     lyNum = new BigDecimal(lyNum.intValue() + vo.getOutStoreNum().intValue());
                     lyNum = new BigDecimal(lyNum.intValue() + vo.getOutStoreNum().intValue());
@@ -176,31 +176,32 @@ public class InStoreFormServiceImpl extends BaseServiceImpl<InStoreFormMapper, I
                     otherNum2 = new BigDecimal(otherNum2.intValue() + vo.getOutStoreNum().intValue());
                     otherNum2 = new BigDecimal(otherNum2.intValue() + vo.getOutStoreNum().intValue());
                 }
                 }
 
 
+
             }
             }
         }
         }
-        num1=new BigDecimal(lyNum.intValue()+dbNum2.intValue()+bfNum.intValue()+otherNum2.intValue());
-        for(InStoreFormVO vo:inStoreFormVOS) {
+        num1 = new BigDecimal(lyNum.intValue() + dbNum2.intValue() + bfNum.intValue() + otherNum2.intValue());
+        for (InStoreFormVO vo : inStoreFormVOS) {
             if (vo != null) {
             if (vo != null) {
                 System.out.println(vo.getType());
                 System.out.println(vo.getType());
-            //采购入库
-            if (InStoreTypeEnum.CAIGOU_RUKU.getValue().equals(vo.getType())) {
-                purchaseNum = new BigDecimal(lyNum.intValue() + vo.getInStoreNum().intValue());
-            }
-            //闲置入库
-            if ((InStoreTypeEnum.XIANZHI_RUKU.getValue().equals(vo.getType()))) {
-                xzNum = new BigDecimal(xzNum.intValue() + vo.getInStoreNum().intValue());
-            }
-            //调拨入库
-            if ((InStoreTypeEnum.DIAOBO_RUKU.getValue()).equals(vo.getType())) {
-                dbNum = new BigDecimal(bfNum.intValue() + vo.getInStoreNum().intValue());
-            }
-            if ((InStoreTypeEnum.FAYUN_RUKU.getValue()).equals(vo.getType()) || (InStoreTypeEnum.STORE_CHECK.getValue()).equals(vo.getType())) {
-                otherNum = new BigDecimal(otherNum.intValue() + vo.getInStoreNum().intValue());
+                //采购入库
+                if (InStoreTypeEnum.CAIGOU_RUKU.getValue().equals(vo.getType())) {
+                    purchaseNum = new BigDecimal(lyNum.intValue() + vo.getInStoreNum().intValue());
+                }
+                //闲置入库
+                if ((InStoreTypeEnum.XIANZHI_RUKU.getValue().equals(vo.getType()))) {
+                    xzNum = new BigDecimal(xzNum.intValue() + vo.getInStoreNum().intValue());
+                }
+                //调拨入库
+                if ((InStoreTypeEnum.DIAOBO_RUKU.getValue()).equals(vo.getType())) {
+                    dbNum = new BigDecimal(bfNum.intValue() + vo.getInStoreNum().intValue());
+                }
+                if ((InStoreTypeEnum.FAYUN_RUKU.getValue()).equals(vo.getType()) || (InStoreTypeEnum.STORE_CHECK.getValue()).equals(vo.getType())) {
+                    otherNum = new BigDecimal(otherNum.intValue() + vo.getInStoreNum().intValue());
+                }
             }
             }
-        }
 
 
         }
         }
-        num=new BigDecimal(purchaseNum.intValue()+xzNum.intValue()+dbNum.intValue()+otherNum.intValue());
+        num = new BigDecimal(purchaseNum.intValue() + xzNum.intValue() + dbNum.intValue() + otherNum.intValue());
 
 
         storeWorkBenchVO.setInTotalNum(num);
         storeWorkBenchVO.setInTotalNum(num);
         storeWorkBenchVO.setPurchaseApplyNum(purchaseNum);
         storeWorkBenchVO.setPurchaseApplyNum(purchaseNum);
@@ -317,6 +318,7 @@ public class InStoreFormServiceImpl extends BaseServiceImpl<InStoreFormMapper, I
 
 
     /**
     /**
      * 入库,只记录不更新
      * 入库,只记录不更新
+     *
      * @param model
      * @param model
      * @return
      * @return
      */
      */
@@ -324,9 +326,9 @@ public class InStoreFormServiceImpl extends BaseServiceImpl<InStoreFormMapper, I
     public InStoreForm saveModelByDTO(InStoreFormDTO model) {
     public InStoreForm saveModelByDTO(InStoreFormDTO model) {
         Store store = storeService.getModelById(model.getStoreId());
         Store store = storeService.getModelById(model.getStoreId());
         if (store == null) {
         if (store == null) {
-            throw new BusinessException("仓库不存在, storeId:" + model.getStoreId() );
+            throw new BusinessException("仓库不存在, storeId:" + model.getStoreId());
         }
         }
-        if (store.getLevel().equals(StoreLevelEnum.ZONGCANG)){
+        if (store.getLevel().equals(StoreLevelEnum.ZONGCANG)) {
             throw new BusinessException("请选择库位");
             throw new BusinessException("请选择库位");
         }
         }
         UserInfo userInfo = SecurityUtils.getUserInfo();
         UserInfo userInfo = SecurityUtils.getUserInfo();
@@ -408,7 +410,7 @@ public class InStoreFormServiceImpl extends BaseServiceImpl<InStoreFormMapper, I
     public void updateModelByDTO(InStoreFormDTO model) {
     public void updateModelByDTO(InStoreFormDTO model) {
         Store store = storeService.getModelById(model.getStoreId());
         Store store = storeService.getModelById(model.getStoreId());
         if (store == null) {
         if (store == null) {
-            throw new BusinessException("仓库不存在, storeId:" + model.getStoreId() );
+            throw new BusinessException("仓库不存在, storeId:" + model.getStoreId());
         }
         }
         if (store.getLevel().equals(StoreLevelEnum.ZONGCANG)) {
         if (store.getLevel().equals(StoreLevelEnum.ZONGCANG)) {
             throw new BusinessException("请选择库位");
             throw new BusinessException("请选择库位");
@@ -551,8 +553,8 @@ public class InStoreFormServiceImpl extends BaseServiceImpl<InStoreFormMapper, I
         UserInfo userInfo = SecurityUtils.getUserInfo();
         UserInfo userInfo = SecurityUtils.getUserInfo();
         InStoreForm model = this.getModelById(id);
         InStoreForm model = this.getModelById(id);
         // 采购单入库的路由至新流程
         // 采购单入库的路由至新流程
-        if(InStoreTypeEnum.CAIGOU_RUKU.getValue() == model.getType()){
-            handlePurchaseInForm(model,userInfo);
+        if (InStoreTypeEnum.CAIGOU_RUKU.getValue() == model.getType()) {
+            handlePurchaseInForm(model, userInfo);
             return;
             return;
         }
         }
 
 
@@ -614,20 +616,21 @@ public class InStoreFormServiceImpl extends BaseServiceImpl<InStoreFormMapper, I
 
 
     /**
     /**
      * 处理采购入库单的入库操作
      * 处理采购入库单的入库操作
+     *
      * @param form
      * @param form
      */
      */
     @Transactional(rollbackFor = Exception.class)
     @Transactional(rollbackFor = Exception.class)
-    void handlePurchaseInForm(InStoreForm form,UserInfo userInfo){
+    void handlePurchaseInForm(InStoreForm form, UserInfo userInfo) {
         PurchaseStoreForm storeForm = new PurchaseStoreForm();
         PurchaseStoreForm storeForm = new PurchaseStoreForm();
         storeForm.setId(form.getPurchaseId());
         storeForm.setId(form.getPurchaseId());
         storeForm.setUpdateUserName(userInfo.getUsername());
         storeForm.setUpdateUserName(userInfo.getUsername());
         storeForm.setUpdateUserId(userInfo.getUserId());
         storeForm.setUpdateUserId(userInfo.getUserId());
         storeForm.setUpdateTime(LocalDateTime.now());
         storeForm.setUpdateTime(LocalDateTime.now());
-        try{
+        try {
             String storeId = form.getStoreId();
             String storeId = form.getStoreId();
             // 找到入库备件明细
             // 找到入库备件明细
             Weekend<PurchaseStoreFormDetail> detailWeekend = new Weekend<>(PurchaseStoreFormDetail.class);
             Weekend<PurchaseStoreFormDetail> detailWeekend = new Weekend<>(PurchaseStoreFormDetail.class);
-            detailWeekend.weekendCriteria().andEqualTo(PurchaseStoreFormDetail::getPurchaseStoreFormId, form.getPurchaseId()).andEqualTo(PurchaseStoreFormDetail::getDeleteFlag,PurchaseStoreFormDetailDelFlagEnum.NORMAL.getValue());
+            detailWeekend.weekendCriteria().andEqualTo(PurchaseStoreFormDetail::getPurchaseStoreFormId, form.getPurchaseId()).andEqualTo(PurchaseStoreFormDetail::getDeleteFlag, PurchaseStoreFormDetailDelFlagEnum.NORMAL.getValue());
             List<PurchaseStoreFormDetail> detailList = purchaseStoreFormDetailMapper.selectByExample(detailWeekend);
             List<PurchaseStoreFormDetail> detailList = purchaseStoreFormDetailMapper.selectByExample(detailWeekend);
             // 更新库存
             // 更新库存
             for (PurchaseStoreFormDetail detail : detailList) {
             for (PurchaseStoreFormDetail detail : detailList) {
@@ -672,10 +675,10 @@ public class InStoreFormServiceImpl extends BaseServiceImpl<InStoreFormMapper, I
             mapper.updateByPrimaryKeySelective(updForm);
             mapper.updateByPrimaryKeySelective(updForm);
             // 修正采购入库单状态
             // 修正采购入库单状态
             storeForm.setStatus(PurchaseStoreFormStatusEnum.COMPLETED.getValue());
             storeForm.setStatus(PurchaseStoreFormStatusEnum.COMPLETED.getValue());
-        }catch (Exception e){
-            log.error("采购入库失败----------------"+e.getCause().getMessage());
+        } catch (Exception e) {
+            log.error("采购入库失败----------------" + e.getCause().getMessage());
             storeForm.setStatus(PurchaseStoreFormStatusEnum.STORE_FAIL.getValue());
             storeForm.setStatus(PurchaseStoreFormStatusEnum.STORE_FAIL.getValue());
-        }finally {
+        } finally {
             purchaseStoreFormMapper.updateByPrimaryKeySelective(storeForm);
             purchaseStoreFormMapper.updateByPrimaryKeySelective(storeForm);
         }
         }
     }
     }
@@ -853,7 +856,7 @@ public class InStoreFormServiceImpl extends BaseServiceImpl<InStoreFormMapper, I
                 spareStore.setUpdateTime(LocalDateTime.now());
                 spareStore.setUpdateTime(LocalDateTime.now());
                 spareStore.setUpdateUserId(userInfo.getUserId());
                 spareStore.setUpdateUserId(userInfo.getUserId());
                 spareStore.setUpdateUserName(userInfo.getRealName());
                 spareStore.setUpdateUserName(userInfo.getRealName());
-                spareStore.setPrice(getNewPrice(spareStore,detail));
+                spareStore.setPrice(getNewPrice(spareStore, detail));
                 spareStoreMapper.updateByPrimaryKeySelective(spareStore);
                 spareStoreMapper.updateByPrimaryKeySelective(spareStore);
             }
             }
         }
         }