523096025 2 月之前
父节点
当前提交
814b534343

+ 4 - 0
huimv-farm/src/main/java/vip/xiaonuo/hr/modular/baseemployeeinfo/entity/vo/PerNum.java

@@ -5,6 +5,10 @@ import lombok.Data;
 @Data
 public class PerNum {
     private String name;
+    private String oneYear;
+    private String twoYear;
+    private String threeYear;
+    private String fourYear;
     private long value;
 
     public PerNum(String name, long value) {

+ 6 - 4
huimv-farm/src/main/java/vip/xiaonuo/money/service/impl/MoneyBusinessServiceImpl.java

@@ -280,7 +280,7 @@ public class MoneyBusinessServiceImpl extends ServiceImpl<MoneyBusinessMapper, M
         }
         // 计算同比变化率
         double percentageChange = (Math.abs((currentValue - previousValue) / previousValue)) * 100;
-        if (percentageChange >200){
+        if (percentageChange >500){
             return "100%";
         }
         return String.format("%.2f%%", percentageChange);
@@ -289,13 +289,15 @@ public class MoneyBusinessServiceImpl extends ServiceImpl<MoneyBusinessMapper, M
     public static String calculateYOYZiJinYvE(double currentValue, double previousValue) {
         // 处理零值情况
         if (previousValue == 0) {
-            return "0%";
+            return "0";
         }
         // 计算同比变化率
         double percentageChange = ((currentValue - previousValue) /previousValue) * 100;
         if (percentageChange >200){
-            return "100%";
+            return "100";
         }
-        return String.format("%.2f%%", percentageChange);
+        return String.format("%.2f", percentageChange);
     }
+
+
 }

+ 86 - 0
huimv-farm/src/main/java/vip/xiaonuo/purchase/controller/PurchaseDongShiController.java

@@ -0,0 +1,86 @@
+package vip.xiaonuo.purchase.controller;
+
+
+import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
+import com.github.xiaoymin.knife4j.annotations.ApiOperationSupport;
+import io.swagger.annotations.Api;
+import io.swagger.annotations.ApiOperation;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.validation.annotation.Validated;
+import org.springframework.web.bind.annotation.PostMapping;
+import org.springframework.web.bind.annotation.RequestBody;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RestController;
+import vip.xiaonuo.common.pojo.CommonResult;
+import vip.xiaonuo.purchase.param.*;
+import vip.xiaonuo.purchase.service.IPurchaseOrderService;
+
+import java.util.List;
+import java.util.Map;
+
+
+/**
+ * <p>
+ * 采购单品价格表 前端控制器
+ * </p>
+ *
+ * @author author
+ * @since 2024-11-27
+ */
+@RequestMapping("/dongShi")
+@Api(tags = "董事长控制器")
+@RestController
+@Validated
+public class PurchaseDongShiController {
+
+    @Autowired
+    private IPurchaseOrderService purchaseOrderService;
+
+    @ApiOperationSupport(order = 1)
+    @ApiOperation("供应链指标卡")
+    @PostMapping("/getIndicator")
+    public CommonResult<PurchaseAllParam> getIndicator(@RequestBody DongShiPurchaseParam priceParam) {
+        return CommonResult.data(purchaseOrderService.getIndicator(priceParam));
+    }
+
+    @ApiOperationSupport(order = 1)
+    @ApiOperation("采购金额、预付金额详细")
+    @PostMapping("/getCaiGouYvFuDetil")
+    public CommonResult<List<PurchaseAllParam>> getCaiGouYvFuDetil(@RequestBody DongShiPurchaseParam priceParam) {
+        return CommonResult.data(purchaseOrderService.getCaiGouYvFuDetil(priceParam));
+    }
+
+
+    @ApiOperationSupport(order = 1)
+    @ApiOperation("采购金额趋势")
+    @PostMapping("/getCaiGouYvFuQuShi")
+    public CommonResult<List<PurchaseAllParam>> getCaiGouYvFuQuShi(@RequestBody DongShiPurchaseParam priceParam) {
+        return CommonResult.data(purchaseOrderService.getCaiGouYvFuQuShi(priceParam));
+    }
+
+    @ApiOperationSupport(order = 1)
+    @ApiOperation("主要原材料")
+    @PostMapping("/getZhuYaoYuanCaiLiao")
+    public CommonResult<List<PurchaseYuanCaiLiaoParam> > getZhuYaoYuanCaiLiao(@RequestBody DongShiPurchaseParam priceParam) {
+        return CommonResult.data(purchaseOrderService.getZhuYaoYuanCaiLiao(priceParam));
+    }
+    @ApiOperationSupport(order = 1)
+    @ApiOperation("供应商")
+    @PostMapping("/getGongYingShang")
+    public CommonResult<Page<GongYingShangParam>> getGongYingShang(@RequestBody DongShiPurchaseParam priceParam) {
+        return CommonResult.data(purchaseOrderService.getGongYingShang(priceParam));
+    }
+
+    @ApiOperationSupport(order = 1)
+    @ApiOperation("物料筛选")
+    @PostMapping("/getWuLiaoShaiXuan")
+    public CommonResult<List<String >> getWuLiaoShaiXuan(@RequestBody DongShiPurchaseParam priceParam) {
+        return CommonResult.data(purchaseOrderService.getWuLiaoShaiXuan(priceParam));
+    }
+
+    @ApiOperation("库存物料数量金额")
+    @PostMapping("/getKuCunWuLiao")
+    public CommonResult<List<DongShiKuCunWuliaoVoParam >> getKuCunWuLiao(@RequestBody DongShiKuCunWuliaoParam priceParam) {
+        return CommonResult.data(purchaseOrderService.getKuCunWuLiao(priceParam));
+    }
+}

+ 8 - 0
huimv-farm/src/main/java/vip/xiaonuo/purchase/mapper/PurchaseOrderMapper.java

@@ -3,10 +3,12 @@ package vip.xiaonuo.purchase.mapper;
 import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
 import com.baomidou.mybatisplus.core.toolkit.Constants;
 import org.apache.ibatis.annotations.Param;
+import vip.xiaonuo.money.param.DsBusAllParam;
 import vip.xiaonuo.purchase.entity.PurchaseOrder;
 import com.baomidou.mybatisplus.core.mapper.BaseMapper;
 import vip.xiaonuo.purchase.entity.vo.PurchaseMaterialVo;
 import vip.xiaonuo.purchase.entity.vo.PurchaseOrderTypeVo;
+import vip.xiaonuo.purchase.param.PurchaseAllParam;
 
 import java.util.List;
 
@@ -23,4 +25,10 @@ public interface PurchaseOrderMapper extends BaseMapper<PurchaseOrder> {
     List<PurchaseOrderTypeVo> listType(String month, String year, String lastMonth, Integer lastYear,String orgId);
 
     List<PurchaseMaterialVo> getSupplier(@Param(Constants.WRAPPER) QueryWrapper<PurchaseOrder> queryWrapper);
+
+    PurchaseAllParam purchaseAll(@Param(Constants.WRAPPER)  QueryWrapper<PurchaseOrder> wapper);
+
+    List<PurchaseAllParam> getCaiGouYvFuDetailMonth(@Param(Constants.WRAPPER)QueryWrapper<PurchaseOrder> wapper);
+
+    List<PurchaseAllParam> getCaiGouYvFuDetailYear(@Param(Constants.WRAPPER) QueryWrapper<PurchaseOrder> wapper);
 }

+ 17 - 0
huimv-farm/src/main/java/vip/xiaonuo/purchase/mapper/PurchasePriceMapper.java

@@ -1,7 +1,17 @@
 package vip.xiaonuo.purchase.mapper;
 
+import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
+import com.baomidou.mybatisplus.core.toolkit.Constants;
+import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
+import org.apache.ibatis.annotations.Param;
+import vip.xiaonuo.purchase.entity.PurchaseOrder;
 import vip.xiaonuo.purchase.entity.PurchasePrice;
 import com.baomidou.mybatisplus.core.mapper.BaseMapper;
+import vip.xiaonuo.purchase.param.DongShiKuCunWuliaoVoParam;
+import vip.xiaonuo.purchase.param.GongYingShangParam;
+import vip.xiaonuo.purchase.param.PurchaseYuanCaiLiaoParam;
+
+import java.util.List;
 
 /**
  * <p>
@@ -13,4 +23,11 @@ import com.baomidou.mybatisplus.core.mapper.BaseMapper;
  */
 public interface PurchasePriceMapper extends BaseMapper<PurchasePrice> {
 
+    List<PurchaseYuanCaiLiaoParam> getZhuYaoYuanCaiLiao( @Param(Constants.WRAPPER)QueryWrapper<PurchasePrice> wapper);
+
+    Page<GongYingShangParam> getGongYingShang(Page<GongYingShangParam> page, @Param(Constants.WRAPPER) QueryWrapper<PurchaseOrder> wapper);
+
+    List<String> getWuLiaoShaiXuan(@Param(Constants.WRAPPER) QueryWrapper<PurchaseOrder> wapper);
+
+    List<DongShiKuCunWuliaoVoParam> getKuCunWuLiao(@Param(Constants.WRAPPER) QueryWrapper<PurchaseOrder> wapper);
 }

+ 37 - 0
huimv-farm/src/main/java/vip/xiaonuo/purchase/param/DongShiKuCunWuliaoParam.java

@@ -0,0 +1,37 @@
+/*
+ * Copyright [2022] [https://www.baiduc.com]
+ *
+ * Snowy采用APACHE LICENSE 2.0开源协议,您在使用过程中,需要注意以下几点:
+ *
+ * 1.请不要删除和修改根目录下的LICENSE文件。
+ * 2.请不要删除和修改Snowy源码头部的版权声明。
+ * 3.本项目代码可免费商业使用,商业使用请保留源码和相关描述文件的项目出处,作者声明等。
+ * 4.分发源码时候,请注明软件出处 https://www.baiduc.com
+ * 5.不可二次分发开源参与同类竞品,如有想法可联系团队xiaonuobase@qq.com商议合作。
+ * 6.若您的项目无法满足以上几点,需要更多功能代码,获取Snowy商业授权许可,请在官网购买授权,地址为 https://www.baiduc.com
+ */
+package vip.xiaonuo.purchase.param;
+
+import io.swagger.annotations.ApiModelProperty;
+import lombok.Getter;
+import lombok.Setter;
+
+/**
+ * 人员明细Id参数
+ *
+ * @author 余
+ * @date  2024/11/14 15:02
+ **/
+@Getter
+@Setter
+public class DongShiKuCunWuliaoParam {
+
+
+    @ApiModelProperty(value = "orgId", required = true)
+    private String orgId;
+
+    @ApiModelProperty(value = "名字")
+    private String name;
+
+
+}

+ 42 - 0
huimv-farm/src/main/java/vip/xiaonuo/purchase/param/DongShiKuCunWuliaoVoParam.java

@@ -0,0 +1,42 @@
+/*
+ * Copyright [2022] [https://www.baiduc.com]
+ *
+ * Snowy采用APACHE LICENSE 2.0开源协议,您在使用过程中,需要注意以下几点:
+ *
+ * 1.请不要删除和修改根目录下的LICENSE文件。
+ * 2.请不要删除和修改Snowy源码头部的版权声明。
+ * 3.本项目代码可免费商业使用,商业使用请保留源码和相关描述文件的项目出处,作者声明等。
+ * 4.分发源码时候,请注明软件出处 https://www.baiduc.com
+ * 5.不可二次分发开源参与同类竞品,如有想法可联系团队xiaonuobase@qq.com商议合作。
+ * 6.若您的项目无法满足以上几点,需要更多功能代码,获取Snowy商业授权许可,请在官网购买授权,地址为 https://www.baiduc.com
+ */
+package vip.xiaonuo.purchase.param;
+
+import io.swagger.annotations.ApiModelProperty;
+import lombok.Getter;
+import lombok.Setter;
+
+/**
+ * 人员明细Id参数
+ *
+ * @author 余
+ * @date  2024/11/14 15:02
+ **/
+@Getter
+@Setter
+public class DongShiKuCunWuliaoVoParam {
+
+
+
+
+
+    @ApiModelProperty(value = "库存物料金额", position = 6)
+    private String kuCunMoney;
+
+    @ApiModelProperty(value = "库存物料数量", position = 6)
+    private String kuCunNum;
+
+    @ApiModelProperty(value = "日期", position = 6)
+    private String ymonth;
+
+}

+ 44 - 0
huimv-farm/src/main/java/vip/xiaonuo/purchase/param/DongShiPurchaseParam.java

@@ -0,0 +1,44 @@
+/*
+ * Copyright [2022] [https://www.baiduc.com]
+ *
+ * Snowy采用APACHE LICENSE 2.0开源协议,您在使用过程中,需要注意以下几点:
+ *
+ * 1.请不要删除和修改根目录下的LICENSE文件。
+ * 2.请不要删除和修改Snowy源码头部的版权声明。
+ * 3.本项目代码可免费商业使用,商业使用请保留源码和相关描述文件的项目出处,作者声明等。
+ * 4.分发源码时候,请注明软件出处 https://www.baiduc.com
+ * 5.不可二次分发开源参与同类竞品,如有想法可联系团队xiaonuobase@qq.com商议合作。
+ * 6.若您的项目无法满足以上几点,需要更多功能代码,获取Snowy商业授权许可,请在官网购买授权,地址为 https://www.baiduc.com
+ */
+package vip.xiaonuo.purchase.param;
+
+import io.swagger.annotations.ApiModelProperty;
+import lombok.Getter;
+import lombok.Setter;
+
+/**
+ * 人员明细Id参数
+ *
+ * @author 余
+ * @date  2024/11/14 15:02
+ **/
+@Getter
+@Setter
+public class DongShiPurchaseParam {
+
+
+    @ApiModelProperty(value = "orgId", required = true)
+    private String orgId;
+
+    @ApiModelProperty(value = "时间,格式为'2024-10-01'")
+    private String time;
+    @ApiModelProperty(value = "0 是年 ,1是月")
+    private Integer type;
+
+    @ApiModelProperty(value = "当前页码", required = true)
+    private Integer pageNum;
+
+    @ApiModelProperty(value = "页数大小", required = true)
+    private Integer pageSize;
+
+}

+ 16 - 0
huimv-farm/src/main/java/vip/xiaonuo/purchase/param/GongYingShangParam.java

@@ -0,0 +1,16 @@
+package vip.xiaonuo.purchase.param;
+
+
+import io.swagger.annotations.ApiModelProperty;
+import lombok.Data;
+
+@Data
+public class GongYingShangParam {
+    @ApiModelProperty(value = "主要原材料金额", position = 2)
+    private String gongYingName;
+
+    private String money;
+    private Integer sort;
+
+
+}

+ 74 - 0
huimv-farm/src/main/java/vip/xiaonuo/purchase/param/PurchaseAllParam.java

@@ -0,0 +1,74 @@
+package vip.xiaonuo.purchase.param;
+
+
+import io.swagger.annotations.ApiModelProperty;
+import lombok.Data;
+
+@Data
+public class PurchaseAllParam {
+    @ApiModelProperty(value = "采购金额", position = 2)
+    private String caiGouMoney;
+    @ApiModelProperty(value = "采购金额环比/同比", position = 2)
+    private String caiGouMoneyOnYear;
+    @ApiModelProperty(value = "采购金额增加或者减少", position = 2)
+    private boolean caiGouMoneyIsOn;
+
+    /**
+     * 营业成本
+     */
+    @ApiModelProperty(value = "主要原材料采购金额", position = 3)
+    private String zhuYaoMoney;
+    @ApiModelProperty(value = "主要原材料环比/同比", position = 2)
+    private boolean zhuYaoMoneyIsOn;
+    @ApiModelProperty(value = "主要原材料增加或者减少", position = 2)
+    private String zhuYaoMoneyOnYear;
+
+    /**
+     * 净利润
+     */
+    @ApiModelProperty(value = "主要原材料采购数量", position = 4)
+    private String zhuYaoNum;
+    @ApiModelProperty(value = "主要原材料采购数量环比/同比", position = 2)
+    private boolean zhuYaoNumIsOn;
+    @ApiModelProperty(value = "主要原材料采购数量增加或者减少", position = 2)
+    private String zhuYaoNumOnYear;
+
+    /**
+     * 已交税金
+     */
+    @ApiModelProperty(value = "采购预期应付", position = 5)
+    private String yvQiYingFu;
+    @ApiModelProperty(value = "采购预期应付环比/同比", position = 2)
+    private boolean yvQiYingFuIsOn;
+    @ApiModelProperty(value = "采购预期应付增加或者减少", position = 2)
+    private String yvQiYingFuOnYear;
+
+    /**
+     * 当前资金余额
+     */
+    @ApiModelProperty(value = "库存物料金额", position = 6)
+    private String kuCunMoney;
+    @ApiModelProperty(value = "库存物料金额环比/同比", position = 2)
+    private boolean kuCunMoneyIsOn;
+    @ApiModelProperty(value = "库存物料金额增加或者减少", position = 2)
+    private String kuCunMoneyOnYear;
+
+    @ApiModelProperty(value = "主要原材料库存金额", position = 6)
+    private String zhuYaoYuanCaiLiaoMoney;
+    @ApiModelProperty(value = "主要原材料库存金额环比/同比", position = 2)
+    private boolean zhuYaoYuanCaiLiaoMoneyIsOn;
+    @ApiModelProperty(value = "主要原材料库存金额增加或者减少", position = 2)
+    private String zhuYaoYuanCaiLiaoMoneyOnYear;
+
+    @ApiModelProperty(value = "主要原材料库存数量", position = 6)
+    private String zhuYaoYuanCaiLiaoNum;
+    @ApiModelProperty(value = "主要原材料库存金额环比/同比", position = 2)
+    private boolean zhuYaoYuanCaiLiaoNumIsOn;
+    @ApiModelProperty(value = "主要原材料库存金额增加或者减少", position = 2)
+    private String zhuYaoYuanCaiLiaoNumOnYear;
+
+
+    private String ymonth;
+
+
+}

+ 15 - 0
huimv-farm/src/main/java/vip/xiaonuo/purchase/param/PurchaseYuanCaiLiaoParam.java

@@ -0,0 +1,15 @@
+package vip.xiaonuo.purchase.param;
+
+
+import io.swagger.annotations.ApiModelProperty;
+import lombok.Data;
+
+@Data
+public class PurchaseYuanCaiLiaoParam {
+    @ApiModelProperty(value = "主要原材料金额", position = 2)
+    private String 羊毛粗脂;
+
+    private String ymonth;
+
+
+}

+ 17 - 2
huimv-farm/src/main/java/vip/xiaonuo/purchase/service/IPurchaseOrderService.java

@@ -1,13 +1,14 @@
 package vip.xiaonuo.purchase.service;
 
 import com.alibaba.fastjson.JSONArray;
+import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
 import vip.xiaonuo.purchase.entity.PurchaseOrder;
 import com.baomidou.mybatisplus.extension.service.IService;
 import vip.xiaonuo.purchase.entity.vo.*;
-import vip.xiaonuo.purchase.param.PurchaseOrderParam;
-import vip.xiaonuo.purchase.param.PurchaseParam;
+import vip.xiaonuo.purchase.param.*;
 
 import java.util.List;
+import java.util.Map;
 
 /**
  * <p>
@@ -33,4 +34,18 @@ public interface IPurchaseOrderService extends IService<PurchaseOrder> {
 
     //供应商占比分析
     JSONArray materialType(PurchaseParam param);
+
+    PurchaseAllParam getIndicator(DongShiPurchaseParam priceParam);
+
+    List<PurchaseAllParam> getCaiGouYvFuDetil(DongShiPurchaseParam priceParam);
+
+    List<PurchaseAllParam> getCaiGouYvFuQuShi(DongShiPurchaseParam priceParam);
+
+     List<PurchaseYuanCaiLiaoParam> getZhuYaoYuanCaiLiao(DongShiPurchaseParam priceParam);
+
+    Page<GongYingShangParam> getGongYingShang(DongShiPurchaseParam priceParam);
+
+    List<String > getWuLiaoShaiXuan(DongShiPurchaseParam priceParam);
+
+    List<DongShiKuCunWuliaoVoParam > getKuCunWuLiao(DongShiKuCunWuliaoParam priceParam);
 }

+ 143 - 2
huimv-farm/src/main/java/vip/xiaonuo/purchase/service/impl/PurchaseOrderServiceImpl.java

@@ -8,16 +8,22 @@ import com.alibaba.fastjson.JSONException;
 import com.alibaba.fastjson.JSONObject;
 import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
 import com.baomidou.mybatisplus.core.toolkit.StringUtils;
+import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
 import io.swagger.models.auth.In;
 import org.springframework.beans.factory.annotation.Autowired;
+import vip.xiaonuo.money.entity.MoneyBusiness;
+import vip.xiaonuo.money.param.DsBusAllParam;
 import vip.xiaonuo.purchase.entity.PurchaseOrder;
+import vip.xiaonuo.purchase.entity.PurchasePrice;
 import vip.xiaonuo.purchase.entity.vo.*;
 import vip.xiaonuo.purchase.mapper.PurchaseOrderMapper;
-import vip.xiaonuo.purchase.param.PurchaseOrderParam;
-import vip.xiaonuo.purchase.param.PurchaseParam;
+import vip.xiaonuo.purchase.mapper.PurchasePriceMapper;
+import vip.xiaonuo.purchase.param.*;
 import vip.xiaonuo.purchase.service.IPurchaseOrderService;
 import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
 import org.springframework.stereotype.Service;
+import vip.xiaonuo.quality.entity.QualityWarning;
+import vip.xiaonuo.warehouse.entity.WarehouseStockDetail;
 
 import java.math.BigDecimal;
 import java.math.RoundingMode;
@@ -28,6 +34,9 @@ import java.time.YearMonth;
 import java.time.temporal.ChronoUnit;
 import java.util.*;
 
+import static vip.xiaonuo.money.service.impl.MoneyBusinessServiceImpl.calculateYOYChange;
+import static vip.xiaonuo.money.service.impl.MoneyBusinessServiceImpl.calculateYOYZiJinYvE;
+
 /**
  * <p>
  * 采购订单表 服务实现类
@@ -41,6 +50,8 @@ public class PurchaseOrderServiceImpl extends ServiceImpl<PurchaseOrderMapper, P
 
     @Autowired
     private PurchaseOrderMapper purchaseOrderMapper;
+    @Autowired
+    private PurchasePriceMapper purchasePriceMapper;
 
     @Override
     public PurchaseOrderVo getOrder(PurchaseParam purchaseParam) {
@@ -334,6 +345,136 @@ public class PurchaseOrderServiceImpl extends ServiceImpl<PurchaseOrderMapper, P
         return array;
     }
 
+    @Override
+    public  PurchaseAllParam getIndicator(DongShiPurchaseParam priceParam) {
+        String orgId = priceParam.getOrgId();
+        String time = priceParam.getTime();
+        Date date ;
+        if (StringUtils.isBlank(time)){
+            date = DateUtil.beginOfMonth(new Date());
+        }else {
+
+            date = DateUtil.beginOfMonth(   DateUtil.parse(time,"yyyy-MM"));
+        }
+
+    QueryWrapper<PurchaseOrder> wapper = new QueryWrapper<PurchaseOrder>();
+        wapper.eq(StringUtils.isNotBlank(orgId),"org_id", orgId).between("create_time", date, DateUtil.endOfMonth(date));
+        PurchaseAllParam purchaseAllParam =  purchaseOrderMapper.purchaseAll(wapper);
+        wapper.clear();
+        wapper.eq(StringUtils.isNotBlank(orgId),"org_id", orgId)
+            .between("create_time", DateUtil.offsetMonth(date,-12), DateUtil.endOfMonth(DateUtil.offsetMonth(date,-12)));
+        PurchaseAllParam lasthaseAllParam =  purchaseOrderMapper.purchaseAll(wapper);
+//
+//    //计算同比
+        purchaseAllParam.setCaiGouMoneyIsOn(getDouble(lasthaseAllParam.getCaiGouMoney()) <getDouble(purchaseAllParam.getCaiGouMoney()));
+        purchaseAllParam.setKuCunMoneyIsOn(getDouble(lasthaseAllParam.getKuCunMoney()) <getDouble(purchaseAllParam.getKuCunMoney()));
+        purchaseAllParam.setZhuYaoMoneyIsOn(getDouble(lasthaseAllParam.getZhuYaoMoney()) <getDouble(purchaseAllParam.getZhuYaoMoney()));
+        purchaseAllParam.setZhuYaoNumIsOn(getDouble(lasthaseAllParam.getZhuYaoNum()) <getDouble(purchaseAllParam.getZhuYaoNum()));
+        purchaseAllParam.setYvQiYingFuIsOn(getDouble(lasthaseAllParam.getYvQiYingFu()) <getDouble(purchaseAllParam.getYvQiYingFu()));
+        purchaseAllParam.setZhuYaoYuanCaiLiaoMoneyIsOn(getDouble(lasthaseAllParam.getZhuYaoYuanCaiLiaoMoney()) <getDouble(purchaseAllParam.getZhuYaoYuanCaiLiaoMoney()));
+        purchaseAllParam.setZhuYaoYuanCaiLiaoNumIsOn(getDouble(lasthaseAllParam.getZhuYaoYuanCaiLiaoNum()) <getDouble(purchaseAllParam.getZhuYaoYuanCaiLiaoNum()));
+
+        purchaseAllParam.setCaiGouMoneyOnYear(calculateYOYChange(getDouble(purchaseAllParam.getCaiGouMoney()),getDouble(lasthaseAllParam.getCaiGouMoney())));
+        purchaseAllParam.setKuCunMoneyOnYear(calculateYOYChange(getDouble(purchaseAllParam.getKuCunMoney()),getDouble(lasthaseAllParam.getKuCunMoney())));
+        purchaseAllParam.setZhuYaoMoneyOnYear(calculateYOYChange(getDouble(purchaseAllParam.getZhuYaoMoney()),getDouble(lasthaseAllParam.getZhuYaoMoney())));
+        purchaseAllParam.setZhuYaoNumOnYear(calculateYOYChange(getDouble(purchaseAllParam.getZhuYaoNum()),getDouble(lasthaseAllParam.getZhuYaoNum())));
+        purchaseAllParam.setYvQiYingFuOnYear(calculateYOYChange(getDouble(purchaseAllParam.getYvQiYingFu()),getDouble(lasthaseAllParam.getYvQiYingFu())));
+        purchaseAllParam.setZhuYaoYuanCaiLiaoMoneyOnYear(calculateYOYChange(getDouble(purchaseAllParam.getZhuYaoYuanCaiLiaoMoney()),getDouble(lasthaseAllParam.getZhuYaoYuanCaiLiaoMoney())));
+        purchaseAllParam.setZhuYaoYuanCaiLiaoNumOnYear(calculateYOYChange(getDouble(purchaseAllParam.getZhuYaoYuanCaiLiaoNum()),getDouble(lasthaseAllParam.getZhuYaoYuanCaiLiaoNum())));
+
+
+        return purchaseAllParam;
+    }
+
+    @Override
+    public List<PurchaseAllParam> getCaiGouYvFuDetil(DongShiPurchaseParam priceParam) {
+        String orgId = priceParam.getOrgId();
+        Integer type = priceParam.getType();
+        QueryWrapper<PurchaseOrder> wapper = new QueryWrapper<PurchaseOrder>();
+        wapper.eq( StringUtils.isNotBlank(orgId),"org_id", orgId).orderByAsc("ymonth").groupBy("ymonth");
+        List<PurchaseAllParam> busAllParams;
+        if (ObjectUtil.isEmpty(type) || 0 ==  type){
+             busAllParams= purchaseOrderMapper.getCaiGouYvFuDetailMonth(wapper);
+        }else {
+            busAllParams = purchaseOrderMapper.getCaiGouYvFuDetailYear(wapper);
+        }
+        return busAllParams;
+    }
+
+    @Override
+    public List<PurchaseAllParam> getCaiGouYvFuQuShi(DongShiPurchaseParam priceParam) {
+        String orgId = priceParam.getOrgId();
+        Integer type = priceParam.getType();
+        QueryWrapper<PurchaseOrder> wapper = new QueryWrapper<PurchaseOrder>();
+        wapper.eq( StringUtils.isNotBlank(orgId),"org_id", orgId).orderByAsc("ymonth").groupBy("ymonth");
+        List<PurchaseAllParam> busAllParams;
+        if (ObjectUtil.isEmpty(type) || 0 ==  type){
+            busAllParams= purchaseOrderMapper.getCaiGouYvFuDetailMonth(wapper);
+        }else {
+            busAllParams = purchaseOrderMapper.getCaiGouYvFuDetailYear(wapper);
+        }
+
+        for (int i = 0; i < busAllParams.size() -1 ; i++) {
+            PurchaseAllParam  lastDsBus  = busAllParams.get(i);
+            PurchaseAllParam dsBusAllParam = busAllParams.get(i + 1);
+            dsBusAllParam.setCaiGouMoneyOnYear(calculateYOYZiJinYvE(getDouble(dsBusAllParam.getCaiGouMoney()),getDouble(lastDsBus.getCaiGouMoney()) ));
+            dsBusAllParam.setCaiGouMoneyIsOn(getDouble(lastDsBus.getCaiGouMoney()) <getDouble(dsBusAllParam.getCaiGouMoney()));
+        }
+        PurchaseAllParam dsBusAllParam = busAllParams.get(0);
+        dsBusAllParam.setCaiGouMoneyIsOn(true);
+        dsBusAllParam.setCaiGouMoneyOnYear("0%");
+        return busAllParams;
+    }
+
+    @Override
+    public List<PurchaseYuanCaiLiaoParam>getZhuYaoYuanCaiLiao(DongShiPurchaseParam priceParam) {
+        String orgId = priceParam.getOrgId();
+        QueryWrapper<PurchasePrice> wapper = new QueryWrapper<PurchasePrice>();
+//        Page<PurchaseYuanCaiLiaoParam> page = new Page<>(priceParam.getPageNum(), priceParam.getPageSize());
+        wapper.eq( StringUtils.isNotBlank(orgId),"org_id", orgId).eq("material","羊毛粗脂").orderByAsc("ymonth").groupBy("ymonth");
+
+        return  purchasePriceMapper.getZhuYaoYuanCaiLiao(wapper);
+    }
+
+    @Override
+    public Page<GongYingShangParam> getGongYingShang(DongShiPurchaseParam priceParam) {
+        String orgId = priceParam.getOrgId();
+        QueryWrapper<PurchaseOrder> wapper = new QueryWrapper<PurchaseOrder>();
+        Page<GongYingShangParam> page = new Page<>(priceParam.getPageNum(), priceParam.getPageSize());
+        wapper.eq( StringUtils.isNotBlank(orgId),"org_id", orgId).groupBy("supplier");
+        Page<GongYingShangParam> gongYingShang = purchasePriceMapper.getGongYingShang(page, wapper);
+        for (int i = 0; i < priceParam.getPageSize(); i++) {
+            GongYingShangParam gongYingShangParam = gongYingShang.getRecords().get(i);
+            gongYingShangParam.setSort((priceParam.getPageNum()-1) *priceParam.getPageSize() + i+ 1 );
+        }
+        return  gongYingShang;
+    }
+
+    @Override
+    public List<String> getWuLiaoShaiXuan(DongShiPurchaseParam priceParam) {
+        QueryWrapper<PurchaseOrder> wapper = new QueryWrapper<PurchaseOrder>();
+        String orgId = priceParam.getOrgId();
+        wapper.eq( StringUtils.isNotBlank(orgId),"org_id", orgId).eq("stock_name","原料库").groupBy("material_name");
+        return purchasePriceMapper.getWuLiaoShaiXuan(wapper);
+    }
+
+    @Override
+    public List<DongShiKuCunWuliaoVoParam> getKuCunWuLiao(DongShiKuCunWuliaoParam priceParam) {
+        QueryWrapper<PurchaseOrder> wapper = new QueryWrapper<PurchaseOrder>();
+        String orgId = priceParam.getOrgId();
+        String name = priceParam.getName();
+        wapper.eq( StringUtils.isNotBlank(orgId),"org_id", orgId).eq(StringUtils.isNotBlank(name),"material_name",name);
+        List<DongShiKuCunWuliaoVoParam> list = purchasePriceMapper.getKuCunWuLiao(wapper);
+        return list;
+    }
+
+    private Double getDouble(String balance) {
+        if (StringUtils.isBlank(balance)){
+            return 0.0;
+        }
+        return Double.parseDouble(balance);
+//        return  balance;
+    }
     /*数组排序*/
     public static JSONArray jsonArraySort(JSONArray jsonArr, String sortKey, boolean is_desc) {
         //存放排序结果json数组

+ 52 - 0
huimv-farm/src/main/resources/mapper/PurchaseOrderMapper.xml

@@ -21,4 +21,56 @@
         ${ew.customSqlSegment}
         group by supplier
     </select>
+    <select id="purchaseAll" resultType="vip.xiaonuo.purchase.param.PurchaseAllParam">
+ SELECT
+    ROUND(IFNULL(SUM(purchase_money) , 0)/10000, 2) AS caiGouMoney,
+
+    ROUND(IFNULL( (SELECT SUM(purchase_money)
+     FROM `purchase_order`  ${ew.customSqlSegment}   AND  material ='羊毛粗脂'), 0)/10000, 2) AS zhuYaoMoney ,
+
+      ROUND(IFNULL( (SELECT SUM(cai_gou)
+     FROM `purchase_order`    ${ew.customSqlSegment}   AND  material ='羊毛粗脂'), 0), 2) AS zhuYaoNum,
+
+    ROUND(IFNULL(SUM(invoice_price), 0)/10000, 2) AS yvQiYingFu,
+
+      ROUND(IFNULL( (SELECT SUM(kuncun_wuliao_money)
+     FROM  `warehouse_kucun_money`   ${ew.customSqlSegment}    ), 0)/10000, 2) AS kuCunMoney,
+
+     ROUND(IFNULL( (SELECT SUM(zhuyao_wuliao_money)
+     FROM  `warehouse_kucun_money`   ${ew.customSqlSegment}   ), 0)/10000, 2) AS zhuYaoYuanCaiLiaoMoney,
+
+
+      ROUND(IFNULL( (SELECT SUM(material_number )
+     FROM  `warehouse_stock_detail`    ${ew.customSqlSegment}   AND   material_name ='羊毛粗脂'  ), 0), 2) AS zhuYaoYuanCaiLiaoNum
+   FROM
+    `purchase_order`
+     ${ew.customSqlSegment}
+
+    </select>
+    <select id="getCaiGouYvFuDetailMonth" resultType="vip.xiaonuo.purchase.param.PurchaseAllParam">
+           SELECT
+    ROUND(IFNULL(SUM(purchase_money ) , 0) / 10000, 2) AS caiGouMoney,
+    ROUND(IFNULL(SUM(CASE WHEN material = '羊毛粗脂' THEN purchase_money ELSE 0 END),0) / 10000 , 2) AS zhuYaoMoney,
+    ROUND(IFNULL(SUM(CASE WHEN material = '羊毛粗脂' THEN cai_gou ELSE 0 END), 2)) AS zhuYaoNum,
+    ROUND(IFNULL(SUM(invoice_price) , 0)/ 10000, 2) AS yvQiYingFu,
+    DATE_FORMAT(create_time, '%Y-%m') AS ymonth
+FROM
+    `purchase_order`
+ ${ew.customSqlSegment}
+
+
+
+    </select>
+    <select id="getCaiGouYvFuDetailYear" resultType="vip.xiaonuo.purchase.param.PurchaseAllParam">
+          SELECT
+    ROUND(IFNULL(SUM(purchase_money ) , 0) / 10000, 2) AS caiGouMoney,
+    ROUND(IFNULL(SUM(CASE WHEN material = '羊毛粗脂' THEN purchase_money ELSE 0 END),0) / 10000 , 2) AS zhuYaoMoney,
+    ROUND(IFNULL(SUM(CASE WHEN material = '羊毛粗脂' THEN cai_gou ELSE 0 END), 2)) AS zhuYaoNum,
+    ROUND(IFNULL(SUM(invoice_price) , 0)/ 10000, 2) AS yvQiYingFu,
+    DATE_FORMAT(create_time, '%Y') AS ymonth
+FROM
+    `purchase_order`
+ ${ew.customSqlSegment}
+
+    </select>
 </mapper>

+ 26 - 0
huimv-farm/src/main/resources/mapper/PurchasePriceMapper.xml

@@ -2,4 +2,30 @@
 <!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
 <mapper namespace="vip.xiaonuo.purchase.mapper.PurchasePriceMapper">
 
+    <select id="getZhuYaoYuanCaiLiao" resultType="vip.xiaonuo.purchase.param.PurchaseYuanCaiLiaoParam">
+    SELECT ROUND(IFNULL(AVG(price), 0), 2) "羊毛粗脂"  , DATE_FORMAT(create_time, '%Y-%m')
+    ymonth  FROM `purchase_price`  ${ew.customSqlSegment}
+    </select>
+    <select id="getGongYingShang" resultType="vip.xiaonuo.purchase.param.GongYingShangParam">
+SELECT ROUND(IFNULL(SUM(purchase_money ) , 0) /10000 , 2)    money
+ ,supplier gongYingName
+  FROM `purchase_order`
+  ${ew.customSqlSegment}
+   ORDER BY (ROUND(IFNULL(SUM(purchase_money ) , 0) , 2))  DESC
+    </select>
+    <select id="getWuLiaoShaiXuan" resultType="java.lang.String">
+        SELECT
+    material_name-- 明确计数的别名
+FROM
+    `warehouse_stock_detail`
+HAVING
+    SUM(material_number) > 0
+    </select>
+    <select id="getKuCunWuLiao" resultType="vip.xiaonuo.purchase.param.DongShiKuCunWuliaoVoParam">
+SELECT   ROUND(IFNULL(SUM(material_number), 0) , 2)   kuCunNum  , DATE_FORMAT(create_time, '%Y-%m') ymonth ,
+ ROUND(IFNULL( (SELECT SUM(kuncun_wuliao_money)
+     FROM `warehouse_kucun_money`
+      ${ew.customSqlSegment} and  DATE_FORMAT(date_time, '%Y-%m') = DATE_FORMAT(mb.create_time, '%Y-%m') ), 0)/10000, 2) AS kuCunMoney
+FROM `warehouse_stock_detail` mb  ${ew.customSqlSegment}   group by ymonth
+</select>
 </mapper>