|
@@ -13,6 +13,8 @@ import com.sky.ioc.tool.ReturnMsg;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
|
|
|
+import java.math.BigDecimal;
|
|
|
+import java.math.RoundingMode;
|
|
|
import java.text.DecimalFormat;
|
|
|
import java.util.List;
|
|
|
import java.util.Map;
|
|
@@ -35,43 +37,41 @@ public class SupermarketServiceImpl implements SupermarketService {
|
|
|
public ReturnMsg getCoreIndicators(IocParam iocParam) {
|
|
|
Indeicator indeicator = new Indeicator();
|
|
|
List<JSONObject> objects = indeicator.getList();
|
|
|
- /*ThreadLocalRandom random = ThreadLocalRandom.current();
|
|
|
- int orderCount = random.nextInt(100, 3000);
|
|
|
- int orderprice = random.nextInt(50,150);
|
|
|
- int price = random.nextInt(1,20);
|
|
|
-
|
|
|
- BigDecimal bigDecimal = new BigDecimal(orderprice*orderCount);
|
|
|
- BigDecimal decimal = bigDecimal.divide(new BigDecimal("10000"));
|
|
|
- DecimalFormat formater = new DecimalFormat("#.0");
|
|
|
-
|
|
|
- // 格式化完成之后得出结果
|
|
|
- double totalPrice = Double.parseDouble(formater.format(decimal));
|
|
|
- float compare = (float) Math.random();
|
|
|
+ Double totalPrice = supermarketOrderMapper.getTotalPriceByCompanyIdAndDeptId(iocParam);
|
|
|
+ totalPrice = totalPrice == null ? 0 : totalPrice;
|
|
|
+ BigDecimal bigDecimal = new BigDecimal(totalPrice);
|
|
|
+ // 转换为万元(除以10000)保留两位小数
|
|
|
+ BigDecimal decimal = bigDecimal.divide(new BigDecimal("10000"), 2, RoundingMode.HALF_UP);
|
|
|
+ totalPrice = decimal.doubleValue();
|
|
|
+ Integer totalOrder = supermarketOrderMapper.getTotalOrderByCompanyIdAndDeptId(iocParam);
|
|
|
+ Integer totalPerson = supermarketOrderMapper.getTotalPersonByCompanyIdAndDeptId(iocParam);
|
|
|
+ double avgPrice = 0d;
|
|
|
+ double avgPersonPrice = 0d;
|
|
|
+ if (totalPrice > 0) {
|
|
|
+ if (totalOrder > 0) {
|
|
|
+ BigDecimal avgPriceDec = bigDecimal.divide(new BigDecimal(totalOrder), 2, RoundingMode.HALF_UP);
|
|
|
+ avgPrice = avgPriceDec.doubleValue();
|
|
|
+ }
|
|
|
+ if (totalPerson > 0) {
|
|
|
+ BigDecimal avgPersonPriceDec = bigDecimal.divide(new BigDecimal(totalPerson), 2, RoundingMode.HALF_UP);
|
|
|
+ avgPersonPrice = avgPersonPriceDec.doubleValue();
|
|
|
+ }
|
|
|
+ }
|
|
|
+ ThreadLocalRandom random = ThreadLocalRandom.current();
|
|
|
+ double compare = random.nextDouble(-1, 1);
|
|
|
DecimalFormat decimalFormat = new DecimalFormat("#.0");
|
|
|
- compare = Float.parseFloat(decimalFormat.format(compare));
|
|
|
-
|
|
|
- objects.get(0).put("value",totalPrice);
|
|
|
- objects.get(0).put("compare",compare);
|
|
|
-
|
|
|
- objects.get(1).put("value",orderCount);
|
|
|
- objects.get(1).put("compare",compare);
|
|
|
-
|
|
|
- objects.get(2).put("value",orderprice);
|
|
|
- objects.get(2).put("compare",-compare);
|
|
|
+ compare = Double.parseDouble(decimalFormat.format(compare));
|
|
|
+ objects.get(0).put("value", totalPrice);
|
|
|
+ objects.get(0).put("compare", compare);
|
|
|
|
|
|
- objects.get(3).put("value",price);
|
|
|
- objects.get(3).put("compare",compare);*/
|
|
|
- objects.get(0).put("value",100);
|
|
|
- objects.get(0).put("compare",0.4);
|
|
|
+ objects.get(1).put("value", totalOrder);
|
|
|
+ objects.get(1).put("compare", compare);
|
|
|
|
|
|
- objects.get(1).put("value",2100);
|
|
|
- objects.get(1).put("compare",0.4);
|
|
|
+ objects.get(2).put("value", avgPersonPrice);
|
|
|
+ objects.get(2).put("compare", compare);
|
|
|
|
|
|
- objects.get(2).put("value",21);
|
|
|
- objects.get(2).put("compare",-0.4);
|
|
|
-
|
|
|
- objects.get(3).put("value",1);
|
|
|
- objects.get(3).put("compare",0.4);
|
|
|
+ objects.get(3).put("value", avgPrice);
|
|
|
+ objects.get(3).put("compare", compare);
|
|
|
indeicator.setWorthAttention("本月盈利将达12万元");
|
|
|
indeicator.setList(objects);
|
|
|
return ReturnMsg.ok(indeicator);
|
|
@@ -79,22 +79,22 @@ public class SupermarketServiceImpl implements SupermarketService {
|
|
|
|
|
|
@Override
|
|
|
public ReturnMsg getQuotientAnalysiss(IocParam iocParam) {
|
|
|
- String[] param = {"morningTotal","afternoonTotal","morningOrder","afternoonOrder","averageOrder"};
|
|
|
- String[] labKey = {"1月","2月","3月","4月","5月","6月","7月","8月","9月","10月","11月","12月"};
|
|
|
+ String[] param = {"morningTotal", "afternoonTotal", "morningOrder", "afternoonOrder", "averageOrder"};
|
|
|
+ String[] labKey = {"1月", "2月", "3月", "4月", "5月", "6月", "7月", "8月", "9月", "10月", "11月", "12月"};
|
|
|
List<Label> labels1 = GeneralMethod.getInstance().dataGeneration(param, labKey);
|
|
|
return ReturnMsg.ok(labels1);
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
public ReturnMsg getProductRanking(IocParam iocParam) {
|
|
|
- List<Map<String,String>> list = supermarketOrderMapper.getListByCompanyIdAndDeptId(iocParam);
|
|
|
+ List<Map<String, String>> list = supermarketOrderMapper.getListByCompanyIdAndDeptId(iocParam);
|
|
|
return ReturnMsg.ok(list);
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
public ReturnMsg getSupermarketInfoList() {
|
|
|
- String[] param = {"consumptionAmount","consumptionOrder"};
|
|
|
- String[] labKey = {"1月","2月","3月","4月","5月","6月","7月","8月","9月","10月","11月","12月"};
|
|
|
+ String[] param = {"consumptionAmount", "consumptionOrder"};
|
|
|
+ String[] labKey = {"1月", "2月", "3月", "4月", "5月", "6月", "7月", "8月", "9月", "10月", "11月", "12月"};
|
|
|
List<Label> labels1 = GeneralMethod.getInstance().dataGeneration(param, labKey);
|
|
|
return ReturnMsg.ok(labels1);
|
|
|
}
|
|
@@ -103,28 +103,32 @@ public class SupermarketServiceImpl implements SupermarketService {
|
|
|
public ReturnMsg getSupermarketCoreIndicators() {
|
|
|
Indeicator indeicator = new Indeicator();
|
|
|
List<JSONObject> objects = indeicator.getList();
|
|
|
- ThreadLocalRandom random = ThreadLocalRandom.current();
|
|
|
- int orderConut = random.nextInt(500, 3000);//订单数
|
|
|
- int price = random.nextInt(10,50);//单价
|
|
|
- int thirdPay = random.nextInt(1000,10000);//第三方支付
|
|
|
- int totalPrice = orderConut*price;//总金额
|
|
|
- while (thirdPay>totalPrice){
|
|
|
- thirdPay = random.nextInt(1000,10000);//第三方支付
|
|
|
- }
|
|
|
- float compare = (float) Math.random();
|
|
|
DecimalFormat decimalFormat = new DecimalFormat("#.0");
|
|
|
- compare = Float.parseFloat(decimalFormat.format(compare));
|
|
|
+ Double totalPrice = supermarketOrderMapper.getTotalPriceByCompanyIdAndDeptId(null);
|
|
|
+ totalPrice = totalPrice == null ? 0 : Double.valueOf(decimalFormat.format(totalPrice));
|
|
|
+ BigDecimal bigDecimal = new BigDecimal(totalPrice);
|
|
|
+ Integer totalOrder = supermarketOrderMapper.getTotalOrderByCompanyIdAndDeptId(null);
|
|
|
+ double avgPrice = 0d;
|
|
|
+ if (totalPrice > 0) {
|
|
|
+ BigDecimal avgPriceDec = bigDecimal.divide(new BigDecimal(totalOrder), 2, RoundingMode.HALF_UP);
|
|
|
+ avgPrice = avgPriceDec.doubleValue();
|
|
|
+ }
|
|
|
+ ThreadLocalRandom random = ThreadLocalRandom.current();
|
|
|
+ Double thirdPay = supermarketOrderMapper.getThirdTotalPriceByCompanyIdAndDeptId();
|
|
|
+ thirdPay = thirdPay == null ? 0 : Double.valueOf(decimalFormat.format(thirdPay));
|
|
|
+ double compare = random.nextDouble(-1, 1);
|
|
|
+ compare = Double.parseDouble(decimalFormat.format(compare));
|
|
|
|
|
|
- objects.get(0).put("value",totalPrice);
|
|
|
- objects.get(0).put("compare",compare);
|
|
|
+ objects.get(0).put("value", totalPrice);
|
|
|
+ objects.get(0).put("compare", compare);
|
|
|
|
|
|
- objects.get(1).put("value",orderConut);
|
|
|
- objects.get(1).put("compare",compare);
|
|
|
+ objects.get(1).put("value", totalOrder);
|
|
|
+ objects.get(1).put("compare", compare);
|
|
|
|
|
|
- objects.get(2).put("value",price);
|
|
|
- objects.get(2).put("compare",compare);
|
|
|
+ objects.get(2).put("value", avgPrice);
|
|
|
+ objects.get(2).put("compare", compare);
|
|
|
|
|
|
- objects.get(3).put("value",thirdPay);
|
|
|
+ objects.get(3).put("value", thirdPay);
|
|
|
|
|
|
indeicator.setWorthAttention("提高合同额");
|
|
|
indeicator.setList(objects);
|