|
@@ -5,8 +5,10 @@ import com.sky.ioc.entity.Indeicator;
|
|
|
import com.sky.ioc.entity.Label;
|
|
|
import com.sky.ioc.entity.domain.supermarket.SupermarketOrder;
|
|
|
import com.sky.ioc.entity.params.IocParam;
|
|
|
+import com.sky.ioc.entity.params.IocTimeRange;
|
|
|
import com.sky.ioc.mapper.SupermarketOrderMapper;
|
|
|
import com.sky.ioc.service.supermarket.SupermarketService;
|
|
|
+import com.sky.ioc.tool.DateUtil;
|
|
|
import com.sky.ioc.tool.FalseData;
|
|
|
import com.sky.ioc.tool.GeneralMethod;
|
|
|
import com.sky.ioc.tool.ReturnMsg;
|
|
@@ -16,6 +18,7 @@ import org.springframework.stereotype.Service;
|
|
|
import java.math.BigDecimal;
|
|
|
import java.math.RoundingMode;
|
|
|
import java.text.DecimalFormat;
|
|
|
+import java.util.ArrayList;
|
|
|
import java.util.List;
|
|
|
import java.util.Map;
|
|
|
import java.util.concurrent.ThreadLocalRandom;
|
|
@@ -80,8 +83,50 @@ 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月"};
|
|
|
- List<Label> labels1 = GeneralMethod.getInstance().dataGeneration(param, labKey);
|
|
|
+ String startStr = iocParam.getTimeRange().getStartDate();
|
|
|
+ String endStr = iocParam.getTimeRange().getEndDate();
|
|
|
+ List<String> list = DateUtil.getBetweenDays(startStr, endStr);
|
|
|
+ String[] labKey = list.toArray(new String[0]);
|
|
|
+ // String[] labKey = {"1月", "2月", "3月", "4月", "5月", "6月", "7月", "8月", "9月", "10月", "11月", "12月"};
|
|
|
+ // List<Label> labels1 = GeneralMethod.getInstance().dataGeneration(param, labKey);
|
|
|
+ List<Label> labels1 = new ArrayList<>();
|
|
|
+ DecimalFormat decimalFormat = new DecimalFormat("#.0");
|
|
|
+ for (int i = 0; i < labKey.length; i++) {
|
|
|
+ Label label = new Label();
|
|
|
+ JSONObject jsonObject = new JSONObject();
|
|
|
+ IocParam iocParam1 = new IocParam();
|
|
|
+ IocTimeRange iocTimeRange = new IocTimeRange();
|
|
|
+ iocTimeRange.setStartDate(labKey[i]+" 00:00:00");
|
|
|
+ iocTimeRange.setEndDate(labKey[i]+" 12:00:00");
|
|
|
+ iocParam1.setTimeRange(iocTimeRange);
|
|
|
+ IocParam iocParam2 = new IocParam();
|
|
|
+ IocTimeRange iocTimeRange2 = new IocTimeRange();
|
|
|
+ iocTimeRange2.setStartDate(labKey[i]+" 12:00:01");
|
|
|
+ iocTimeRange2.setEndDate(labKey[i]+" 23:59:59");
|
|
|
+ iocParam2.setTimeRange(iocTimeRange2);
|
|
|
+ //上午
|
|
|
+ Double totalPrice = supermarketOrderMapper.getTotalPriceByCompanyIdAndDeptId(iocParam1);
|
|
|
+ totalPrice = totalPrice == null ? 0 : Double.valueOf(decimalFormat.format(totalPrice));
|
|
|
+ Integer totalOrder = supermarketOrderMapper.getTotalOrderByCompanyIdAndDeptId(iocParam1);
|
|
|
+ //下午
|
|
|
+ Double afternoonTotalPrice = supermarketOrderMapper.getTotalPriceByCompanyIdAndDeptId(iocParam2);
|
|
|
+ afternoonTotalPrice = afternoonTotalPrice == null ? 0 : Double.valueOf(decimalFormat.format(afternoonTotalPrice));
|
|
|
+ Integer afternoonTotalOrder = supermarketOrderMapper.getTotalOrderByCompanyIdAndDeptId(iocParam2);
|
|
|
+ BigDecimal bigDecimal = new BigDecimal(totalPrice+afternoonTotalPrice);
|
|
|
+ double avgPrice = 0d;
|
|
|
+ if (totalPrice+afternoonTotalPrice > 0) {
|
|
|
+ BigDecimal avgPriceDec = bigDecimal.divide(new BigDecimal(totalOrder+afternoonTotalOrder), 2, RoundingMode.HALF_UP);
|
|
|
+ avgPrice = avgPriceDec.doubleValue();
|
|
|
+ }
|
|
|
+ jsonObject.put(param[0],totalPrice);
|
|
|
+ jsonObject.put(param[1],afternoonTotalPrice);
|
|
|
+ jsonObject.put(param[2],totalOrder);
|
|
|
+ jsonObject.put(param[3],afternoonTotalOrder);
|
|
|
+ jsonObject.put(param[4],avgPrice);
|
|
|
+ label.setJsonObject(jsonObject);
|
|
|
+ label.setLabel(labKey[i]);
|
|
|
+ labels1.add(label);
|
|
|
+ }
|
|
|
return ReturnMsg.ok(labels1);
|
|
|
}
|
|
|
|
|
@@ -92,22 +137,44 @@ public class SupermarketServiceImpl implements SupermarketService {
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
- public ReturnMsg getSupermarketInfoList() {
|
|
|
+ public ReturnMsg getSupermarketInfoList(IocParam iocParam) {
|
|
|
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);
|
|
|
+ String startStr = iocParam.getTimeRange().getStartDate();
|
|
|
+ String endStr = iocParam.getTimeRange().getEndDate();
|
|
|
+ List<String> list = DateUtil.getBetweenDays(startStr, endStr);
|
|
|
+ String[] labKey = list.toArray(new String[0]);
|
|
|
+ //List<Label> labels1 = GeneralMethod.getInstance().dataGeneration(param, labKey);
|
|
|
+ List<Label> labels1 = new ArrayList<>();
|
|
|
+ DecimalFormat decimalFormat = new DecimalFormat("#.0");
|
|
|
+ for (int i = 0; i < labKey.length; i++) {
|
|
|
+ Label label = new Label();
|
|
|
+ JSONObject jsonObject = new JSONObject();
|
|
|
+ IocParam iocParam1 = new IocParam();
|
|
|
+ IocTimeRange iocTimeRange = new IocTimeRange();
|
|
|
+ iocTimeRange.setStartDate(labKey[i]+" 00:00:00");
|
|
|
+ iocTimeRange.setEndDate(labKey[i]+" 23:59:59");
|
|
|
+ iocParam1.setTimeRange(iocTimeRange);
|
|
|
+ Double totalPrice = supermarketOrderMapper.getTotalPriceByCompanyIdAndDeptId(iocParam1);
|
|
|
+ totalPrice = totalPrice == null ? 0 : Double.valueOf(decimalFormat.format(totalPrice));
|
|
|
+ Integer totalOrder = supermarketOrderMapper.getTotalOrderByCompanyIdAndDeptId(iocParam1);
|
|
|
+ jsonObject.put(param[0],totalPrice);
|
|
|
+ jsonObject.put(param[1],totalOrder);
|
|
|
+ label.setJsonObject(jsonObject);
|
|
|
+ label.setLabel(labKey[i]);
|
|
|
+ labels1.add(label);
|
|
|
+ }
|
|
|
return ReturnMsg.ok(labels1);
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
- public ReturnMsg getSupermarketCoreIndicators() {
|
|
|
+ public ReturnMsg getSupermarketCoreIndicators(IocParam iocParam) {
|
|
|
Indeicator indeicator = new Indeicator();
|
|
|
List<JSONObject> objects = indeicator.getList();
|
|
|
DecimalFormat decimalFormat = new DecimalFormat("#.0");
|
|
|
- Double totalPrice = supermarketOrderMapper.getTotalPriceByCompanyIdAndDeptId(null);
|
|
|
+ Double totalPrice = supermarketOrderMapper.getTotalPriceByCompanyIdAndDeptId(iocParam);
|
|
|
totalPrice = totalPrice == null ? 0 : Double.valueOf(decimalFormat.format(totalPrice));
|
|
|
BigDecimal bigDecimal = new BigDecimal(totalPrice);
|
|
|
- Integer totalOrder = supermarketOrderMapper.getTotalOrderByCompanyIdAndDeptId(null);
|
|
|
+ Integer totalOrder = supermarketOrderMapper.getTotalOrderByCompanyIdAndDeptId(iocParam);
|
|
|
double avgPrice = 0d;
|
|
|
if (totalPrice > 0) {
|
|
|
BigDecimal avgPriceDec = bigDecimal.divide(new BigDecimal(totalOrder), 2, RoundingMode.HALF_UP);
|