|
@@ -8,16 +8,22 @@ import com.alibaba.fastjson.JSONException;
|
|
import com.alibaba.fastjson.JSONObject;
|
|
import com.alibaba.fastjson.JSONObject;
|
|
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
|
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
|
import com.baomidou.mybatisplus.core.toolkit.StringUtils;
|
|
import com.baomidou.mybatisplus.core.toolkit.StringUtils;
|
|
|
|
+import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
|
import io.swagger.models.auth.In;
|
|
import io.swagger.models.auth.In;
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
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.PurchaseOrder;
|
|
|
|
+import vip.xiaonuo.purchase.entity.PurchasePrice;
|
|
import vip.xiaonuo.purchase.entity.vo.*;
|
|
import vip.xiaonuo.purchase.entity.vo.*;
|
|
import vip.xiaonuo.purchase.mapper.PurchaseOrderMapper;
|
|
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 vip.xiaonuo.purchase.service.IPurchaseOrderService;
|
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
|
import org.springframework.stereotype.Service;
|
|
import org.springframework.stereotype.Service;
|
|
|
|
+import vip.xiaonuo.quality.entity.QualityWarning;
|
|
|
|
+import vip.xiaonuo.warehouse.entity.WarehouseStockDetail;
|
|
|
|
|
|
import java.math.BigDecimal;
|
|
import java.math.BigDecimal;
|
|
import java.math.RoundingMode;
|
|
import java.math.RoundingMode;
|
|
@@ -28,6 +34,9 @@ import java.time.YearMonth;
|
|
import java.time.temporal.ChronoUnit;
|
|
import java.time.temporal.ChronoUnit;
|
|
import java.util.*;
|
|
import java.util.*;
|
|
|
|
|
|
|
|
+import static vip.xiaonuo.money.service.impl.MoneyBusinessServiceImpl.calculateYOYChange;
|
|
|
|
+import static vip.xiaonuo.money.service.impl.MoneyBusinessServiceImpl.calculateYOYZiJinYvE;
|
|
|
|
+
|
|
/**
|
|
/**
|
|
* <p>
|
|
* <p>
|
|
* 采购订单表 服务实现类
|
|
* 采购订单表 服务实现类
|
|
@@ -41,6 +50,8 @@ public class PurchaseOrderServiceImpl extends ServiceImpl<PurchaseOrderMapper, P
|
|
|
|
|
|
@Autowired
|
|
@Autowired
|
|
private PurchaseOrderMapper purchaseOrderMapper;
|
|
private PurchaseOrderMapper purchaseOrderMapper;
|
|
|
|
+ @Autowired
|
|
|
|
+ private PurchasePriceMapper purchasePriceMapper;
|
|
|
|
|
|
@Override
|
|
@Override
|
|
public PurchaseOrderVo getOrder(PurchaseParam purchaseParam) {
|
|
public PurchaseOrderVo getOrder(PurchaseParam purchaseParam) {
|
|
@@ -334,6 +345,136 @@ public class PurchaseOrderServiceImpl extends ServiceImpl<PurchaseOrderMapper, P
|
|
return array;
|
|
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) {
|
|
public static JSONArray jsonArraySort(JSONArray jsonArr, String sortKey, boolean is_desc) {
|
|
//存放排序结果json数组
|
|
//存放排序结果json数组
|