zhangyuewww 2 年之前
父节点
当前提交
c25d434fd2

+ 1 - 1
winsea-haixin-plugin-yiliangyiyun/src/main/java/com/yh/saas/plugin/yiliangyiyun/controller/SpeedGoodsInfoController.java

@@ -59,7 +59,7 @@ public class SpeedGoodsInfoController {
         return speedGoodsInfoService.editInfo(speedGoodsInfo);
     }
     /**
-     * 归零
+     * 计算加权成本
      * @param speedGoodsInfo
      * @return
      */

+ 3 - 1
winsea-haixin-plugin-yiliangyiyun/src/main/java/com/yh/saas/plugin/yiliangyiyun/entity/SpeedGoodsInfo.java

@@ -1,6 +1,7 @@
 package com.yh.saas.plugin.yiliangyiyun.entity;
 
 import java.io.Serializable;
+import java.util.List;
 
 import com.baomidou.mybatisplus.annotations.TableField;
 import com.baomidou.mybatisplus.annotations.TableId;
@@ -58,7 +59,8 @@ public class SpeedGoodsInfo extends BaseModel<SpeedGoodsInfo> {
      */
     @TableField(exist = false)
     private String flag;
-
+    @TableField(exist = false)
+    private List<SpeedWarehouseInOutInfo> speedWarehouseInOutInfoList;
 
     @Override
     protected Serializable pkVal() {

+ 25 - 3
winsea-haixin-plugin-yiliangyiyun/src/main/java/com/yh/saas/plugin/yiliangyiyun/service/impl/SpeedGoodsInfoServiceImpl.java

@@ -3,9 +3,12 @@ package com.yh.saas.plugin.yiliangyiyun.service.impl;
 import com.baomidou.mybatisplus.mapper.EntityWrapper;
 import com.yh.saas.common.support.util.IdGenerator;
 import com.yh.saas.plugin.yiliangyiyun.entity.SpeedGoodsInfo;
+import com.yh.saas.plugin.yiliangyiyun.entity.SpeedWarehouseInOutInfo;
 import com.yh.saas.plugin.yiliangyiyun.mapper.SpeedGoodsInfoMapper;
 import com.yh.saas.plugin.yiliangyiyun.service.ISpeedGoodsInfoService;
 import com.baomidou.mybatisplus.service.impl.ServiceImpl;
+import com.yh.saas.plugin.yiliangyiyun.service.ISpeedWarehouseInOutInfoService;
+import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
 import org.springframework.util.CollectionUtils;
 
@@ -21,7 +24,8 @@ import java.util.List;
  */
 @Service
 public class SpeedGoodsInfoServiceImpl extends ServiceImpl<SpeedGoodsInfoMapper, SpeedGoodsInfo> implements ISpeedGoodsInfoService {
-
+    @Autowired
+    private ISpeedWarehouseInOutInfoService speedWarehouseInOutInfoService;
     @Override
     public List<SpeedGoodsInfo> selectInfo(SpeedGoodsInfo speedGoodsInfo) {
         List<SpeedGoodsInfo> speedGoodsInfoList=this.selectList(new EntityWrapper<SpeedGoodsInfo>()
@@ -63,8 +67,26 @@ public class SpeedGoodsInfoServiceImpl extends ServiceImpl<SpeedGoodsInfoMapper,
 
     @Override
     public String makeZero(SpeedGoodsInfo speedGoodsInfo) {
-        speedGoodsInfo.setWeightedCost(0d);
-        speedGoodsInfo.setStorage(0d);
+        List<SpeedWarehouseInOutInfo> speedWarehouseInOutInfoList=speedGoodsInfo.getSpeedWarehouseInOutInfoList();
+        if (!CollectionUtils.isEmpty(speedWarehouseInOutInfoList)){
+            Double grainFundTotal=0d;
+            Float weightTotal=0f;
+            for (SpeedWarehouseInOutInfo speedWarehouseInOutInfo:speedWarehouseInOutInfoList){
+                //只统计入库数据
+                if ("2".equals(speedWarehouseInOutInfo.getInOutFlag())){
+                    if (speedWarehouseInOutInfo.getGrainFund()!=null&&speedWarehouseInOutInfo.getNetWeight()!=null&&speedGoodsInfo.getGoodsName().equals(speedWarehouseInOutInfo.getGoodsName())){
+                        weightTotal=weightTotal+speedWarehouseInOutInfo.getNetWeight();
+                        grainFundTotal=grainFundTotal+speedWarehouseInOutInfo.getGrainFund();
+                    }
+                }
+            }
+            if (weightTotal!=0) {
+                speedGoodsInfo.setWeightedCost(grainFundTotal / weightTotal);
+            }
+            else {
+                speedGoodsInfo.setWeightedCost(0d);
+            }
+        }
         this.updateById(speedGoodsInfo);
         return "ok";
     }

+ 59 - 23
winsea-haixin-plugin-yiliangyiyun/src/main/java/com/yh/saas/plugin/yiliangyiyun/service/impl/SpeedWarehouseInOutInfoServiceImpl.java

@@ -46,6 +46,8 @@ import java.util.*;
 public class SpeedWarehouseInOutInfoServiceImpl extends ServiceImpl<SpeedWarehouseInOutInfoMapper, SpeedWarehouseInOutInfo> implements ISpeedWarehouseInOutInfoService {
     @Autowired
     private ISpeedGoodsInfoService speedGoodsInfoService;
+    @Autowired
+    private ISpeedCustomerInfoService speedCustomerInfoService;
     @Value("${file-root-path}")
     private String localPath;
     @Override
@@ -122,12 +124,12 @@ public class SpeedWarehouseInOutInfoServiceImpl extends ServiceImpl<SpeedWarehou
                             .eq("comp_id",speedWarehouseInOutInfo.getCompId())
                             .eq("goods_name",speedWarehouseInOutInfo.getGoodsName()));
                     if (speedGoodsInfo!=null){
-                        //粮款不为空时计算新加权成本
-                        if (speedWarehouseInOutInfo.getGrainFund()!=null) {
-                            //新成本=(原成本*原库存+本次粮款)/(原库存+本次净重)
-                            speedGoodsInfo.setWeightedCost((speedGoodsInfo.getWeightedCost() * speedGoodsInfo.getStorage() +speedWarehouseInOutInfo.getGrainFund())
-                                    /(speedGoodsInfo.getStorage()+speedWarehouseInOutInfo.getNetWeight()));
-                        }
+//                        //粮款不为空时计算新加权成本
+//                        if (speedWarehouseInOutInfo.getGrainFund()!=null) {
+//                            //新成本=(原成本*原库存+本次粮款)/(原库存+本次净重)
+//                            speedGoodsInfo.setWeightedCost((speedGoodsInfo.getWeightedCost() * speedGoodsInfo.getStorage() +speedWarehouseInOutInfo.getGrainFund())
+//                                    /(speedGoodsInfo.getStorage()+speedWarehouseInOutInfo.getNetWeight()));
+//                        }
                         speedGoodsInfo.setStorage(speedGoodsInfo.getStorage()-speedWarehouseInOutInfo.getNetWeight());
                         speedGoodsInfoService.updateById(speedGoodsInfo);
                     }
@@ -144,12 +146,12 @@ public class SpeedWarehouseInOutInfoServiceImpl extends ServiceImpl<SpeedWarehou
                             .eq("comp_id",speedWarehouseInOutInfo.getCompId())
                             .eq("goods_name",speedWarehouseInOutInfo.getGoodsName()));
                     if (speedGoodsInfo!=null){
-                        //粮款不为空时计算新加权成本
-                        if (speedWarehouseInOutInfo.getGrainFund()!=null) {
-                            //新成本=(原成本*原库存+本次粮款)/(原库存+本次净重)
-                            speedGoodsInfo.setWeightedCost((speedGoodsInfo.getWeightedCost() * speedGoodsInfo.getStorage() +speedWarehouseInOutInfo.getGrainFund())
-                                    /(speedGoodsInfo.getStorage()+speedWarehouseInOutInfo.getNetWeight()));
-                        }
+//                        //粮款不为空时计算新加权成本
+//                        if (speedWarehouseInOutInfo.getGrainFund()!=null) {
+//                            //新成本=(原成本*原库存+本次粮款)/(原库存+本次净重)
+//                            speedGoodsInfo.setWeightedCost((speedGoodsInfo.getWeightedCost() * speedGoodsInfo.getStorage() +speedWarehouseInOutInfo.getGrainFund())
+//                                    /(speedGoodsInfo.getStorage()+speedWarehouseInOutInfo.getNetWeight()));
+//                        }
                         speedGoodsInfo.setStorage(speedGoodsInfo.getStorage()+speedWarehouseInOutInfo.getNetWeight());
                         speedGoodsInfoService.updateById(speedGoodsInfo);
                     }
@@ -169,11 +171,11 @@ public class SpeedWarehouseInOutInfoServiceImpl extends ServiceImpl<SpeedWarehou
                             .eq("goods_name",speedWarehouseInOutInfo.getGoodsName()));
                     if (speedGoodsInfo!=null){
                         //粮款不为空时计算新加权成本
-                        if (speedWarehouseInOutInfo.getGrainFund()!=null) {
-                            //新成本=(原成本*原库存+本次粮款)/(原库存+本次净重)
-                            speedGoodsInfo.setWeightedCost((speedGoodsInfo.getWeightedCost() * speedGoodsInfo.getStorage() +speedWarehouseInOutInfo.getGrainFund())
-                                    /(speedGoodsInfo.getStorage()+speedWarehouseInOutInfo.getNetWeight()));
-                        }
+//                        if (speedWarehouseInOutInfo.getGrainFund()!=null) {
+//                            //新成本=(原成本*原库存+本次粮款)/(原库存+本次净重)
+//                            speedGoodsInfo.setWeightedCost((speedGoodsInfo.getWeightedCost() * speedGoodsInfo.getStorage() +speedWarehouseInOutInfo.getGrainFund())
+//                                    /(speedGoodsInfo.getStorage()+speedWarehouseInOutInfo.getNetWeight()));
+//                        }
                         //加上原净重再减去新净重
                         speedGoodsInfo.setStorage(speedGoodsInfo.getStorage()+speedWarehouseInOutInfo1.getNetWeight()-speedWarehouseInOutInfo.getNetWeight());
                         speedGoodsInfoService.updateById(speedGoodsInfo);
@@ -191,17 +193,23 @@ public class SpeedWarehouseInOutInfoServiceImpl extends ServiceImpl<SpeedWarehou
                             .eq("goods_name",speedWarehouseInOutInfo.getGoodsName()));
                     if (speedGoodsInfo!=null){
                         //粮款不为空时计算新加权成本
-                        if (speedWarehouseInOutInfo.getGrainFund()!=null) {
-                            //新成本=(原成本*原库存+本次粮款)/(原库存+本次净重)
-                            speedGoodsInfo.setWeightedCost((speedGoodsInfo.getWeightedCost() * speedGoodsInfo.getStorage() +speedWarehouseInOutInfo.getGrainFund())
-                                    /(speedGoodsInfo.getStorage()+speedWarehouseInOutInfo.getNetWeight()));
-                        }
+//                        if (speedWarehouseInOutInfo.getGrainFund()!=null) {
+//                            //新成本=(原成本*原库存+本次粮款)/(原库存+本次净重)
+//                            speedGoodsInfo.setWeightedCost((speedGoodsInfo.getWeightedCost() * speedGoodsInfo.getStorage() +speedWarehouseInOutInfo.getGrainFund())
+//                                    /(speedGoodsInfo.getStorage()+speedWarehouseInOutInfo.getNetWeight()));
+//                        }
                         //减去原净重再加上新净重
                         speedGoodsInfo.setStorage(speedGoodsInfo.getStorage()-speedWarehouseInOutInfo1.getNetWeight()+speedWarehouseInOutInfo.getNetWeight());
                         speedGoodsInfoService.updateById(speedGoodsInfo);
                     }
                 }
             }
+            this.updateById(speedWarehouseInOutInfo);
+        }
+        //更新被选择客户更新时间
+        SpeedCustomerInfo speedCustomerInfo=speedCustomerInfoService.selectById(speedWarehouseInOutInfo.getCustomerId());
+        if (speedCustomerInfo!=null){
+            speedCustomerInfoService.updateById(speedCustomerInfo);
         }
         return "ok";
     }
@@ -209,6 +217,23 @@ public class SpeedWarehouseInOutInfoServiceImpl extends ServiceImpl<SpeedWarehou
     @Override
     public void deleteInfo(String id) {
         SpeedWarehouseInOutInfo speedWarehouseInOutInfo = this.selectById(id);
+        //净重不为空,操作库存
+        if (speedWarehouseInOutInfo.getNetWeight()!=null){
+            SpeedGoodsInfo speedGoodsInfo=speedGoodsInfoService.selectOne(new EntityWrapper<SpeedGoodsInfo>()
+                    .eq("comp_id",speedWarehouseInOutInfo.getCompId())
+                    .eq("goods_name",speedWarehouseInOutInfo.getGoodsName()));
+            if (speedGoodsInfo!=null){
+                //出库加库存
+                if ("1".equals(speedWarehouseInOutInfo.getInOutFlag())) {
+                    speedGoodsInfo.setStorage(speedGoodsInfo.getStorage() + speedWarehouseInOutInfo.getNetWeight());
+                }
+                //入库减库存
+                else{
+                    speedGoodsInfo.setStorage(speedGoodsInfo.getStorage() - speedWarehouseInOutInfo.getNetWeight());
+                }
+                speedGoodsInfoService.updateById(speedGoodsInfo);
+            }
+        }
         this.deleteById(speedWarehouseInOutInfo.getId());
     }
 
@@ -488,7 +513,8 @@ public class SpeedWarehouseInOutInfoServiceImpl extends ServiceImpl<SpeedWarehou
         sheet.setColumnWidth(12, 12 * 256 + 184);
         sheet.setColumnWidth(13, 12 * 256 + 184);
         sheet.setColumnWidth(14, "日期".getBytes().length*2*256);
-        sheet.setColumnWidth(15, 1 * 256 + 184);
+        sheet.setColumnWidth(15, 12 * 256 + 184);
+        sheet.setColumnWidth(16, 1 * 256 + 184);
 
         // 创建单元格对象
         HSSFCell cell = null;
@@ -538,6 +564,8 @@ public class SpeedWarehouseInOutInfoServiceImpl extends ServiceImpl<SpeedWarehou
         cell.setCellStyle(styleTitle);
         cell = row0.createCell(14);
         cell.setCellStyle(styleTitle);
+        cell = row0.createCell(15);
+        cell.setCellStyle(styleTitle);
         rownum++;
 
 
@@ -584,6 +612,8 @@ public class SpeedWarehouseInOutInfoServiceImpl extends ServiceImpl<SpeedWarehou
         cell.setCellStyle(contextstyle1);
         cell = rowp.createCell(14);
         cell.setCellStyle(styleDetail);
+        cell = rowp.createCell(15);
+        cell.setCellStyle(styleDetail);
         rownum++;
 
         HSSFRow row1 = sheet.createRow((int) rownum);
@@ -630,6 +660,9 @@ public class SpeedWarehouseInOutInfoServiceImpl extends ServiceImpl<SpeedWarehou
         cell = row1.createCell(14);
         cell.setCellValue("日期");
         cell.setCellStyle(styleDetail);
+        cell = row1.createCell(15);
+        cell.setCellValue("收支状态");
+        cell.setCellStyle(styleDetail);
         rownum++;
 
 
@@ -691,6 +724,9 @@ public class SpeedWarehouseInOutInfoServiceImpl extends ServiceImpl<SpeedWarehou
                 String date = addDateOneDay(speedWarehouseInOutInfo1.getCreateDate() != null ? speedWarehouseInOutInfo1.getCreateDate() : new Date());
                 cell.setCellValue(date);
                 cell.setCellStyle(styleDetail);
+                cell = rowx.createCell(15);
+                cell.setCellValue(editString(speedWarehouseInOutInfo1.getStatus()));
+                cell.setCellStyle(styleDetail);
                 rownum++;
             }
 

+ 1 - 0
winsea-haixin-plugin-yiliangyiyun/src/main/resources/mapper/SpeedCustomerInfoMapper.xml

@@ -19,6 +19,7 @@
             AND (lower(customer_name) like lower(CONCAT('%',#{searchKeyWord},'%'))
             OR lower(customer_phone) like lower(CONCAT('%',#{searchKeyWord},'%')))
         </if>
+        ORDER BY update_date DESC
     </select>
     <select id="getCountByCondition" parameterType="Map" resultType="java.lang.Integer">
         SELECT

+ 6 - 4
winsea-haixin-plugin-yiliangyiyun/src/main/resources/mapper/SpeedWarehouseInOutInfoMapper.xml

@@ -11,6 +11,7 @@
         <if test="searchKeyWord != null and searchKeyWord != ''">
             AND (lower(customer_name) like lower(CONCAT('%',#{searchKeyWord},'%'))
             OR lower(car_number) like lower(CONCAT('%',#{searchKeyWord},'%'))
+            OR lower(business_no) like lower(CONCAT('%',#{searchKeyWord},'%'))
             OR lower(goods_name) like lower(CONCAT('%',#{searchKeyWord},'%')))
         </if>
         <if test="status != null and status != ''">
@@ -24,10 +25,10 @@
                 AND in_out_flag ='1'
             </if>
             <if test="searchType == 3">
-                AND( in_out_flag ='2' and car_number!='盘盈')
+                AND( in_out_flag ='2' and (car_number!='盘盈' OR car_number is null))
             </if>
             <if test="searchType == 4">
-                AND( in_out_flag ='1' and car_number!='盘亏')
+                AND( in_out_flag ='1' and (car_number!='盘亏' OR car_number is null))
             </if>
         </if>
         <if test="startDate != null">
@@ -74,6 +75,7 @@
         <if test="searchKeyWord != null and searchKeyWord != ''">
             AND (lower(customer_name) like lower(CONCAT('%',#{searchKeyWord},'%'))
             OR lower(car_number) like lower(CONCAT('%',#{searchKeyWord},'%'))
+            OR lower(business_no) like lower(CONCAT('%',#{searchKeyWord},'%'))
             OR lower(goods_name) like lower(CONCAT('%',#{searchKeyWord},'%')))
         </if>
         <if test="status != null and status != ''">
@@ -87,10 +89,10 @@
                 AND in_out_flag ='1'
             </if>
             <if test="searchType == 3">
-                AND( in_out_flag ='2' and car_number!='盘盈')
+                AND( in_out_flag ='2' and (car_number!='盘盈' OR car_number is null))
             </if>
             <if test="searchType == 4">
-                AND( in_out_flag ='1' and car_number!='盘亏')
+                AND( in_out_flag ='1' and (car_number!='盘亏' OR car_number is null))
             </if>
         </if>
         <if test="startDate != null">