New file |
| | |
| | | package com.hx.other.service.controller; |
| | | |
| | | import com.hx.common.BaseController; |
| | | import com.hx.other.service.model.Employee; |
| | | import com.hx.other.service.model.OrdersTotal; |
| | | import com.hx.other.service.model.PerformanceInfo; |
| | | import com.hx.other.service.model.User; |
| | | import com.hx.other.service.service.EmployeeService; |
| | | import com.hx.other.service.service.OrdersTotalService; |
| | | import com.hx.other.service.service.PerformanceInfoService; |
| | | import com.hx.other.service.service.UserService; |
| | | import com.hx.resultTool.Result; |
| | | import org.springframework.web.bind.annotation.RequestMapping; |
| | | import org.springframework.web.bind.annotation.RestController; |
| | | |
| | | import javax.annotation.Resource; |
| | | import java.math.BigDecimal; |
| | | import java.util.*; |
| | | |
| | | /** |
| | | * @Author: cmg |
| | | * @Date: 2023/4/23 15:30 |
| | | */ |
| | | @RestController |
| | | @RequestMapping("/init/data") |
| | | public class InitDataController extends BaseController { |
| | | |
| | | @Resource |
| | | private EmployeeService employeeService; |
| | | |
| | | @Resource |
| | | private UserService userService; |
| | | |
| | | @Resource |
| | | private OrdersTotalService ordersTotalService; |
| | | |
| | | @Resource |
| | | private PerformanceInfoService performanceInfoService; |
| | | |
| | | @RequestMapping("/data") |
| | | public Result initData() |
| | | { |
| | | |
| | | String[] XING = new String[]{"赵", "钱", "孙", "李", "周", "吴", "郑", "王", "冯", "陈", "褚", "卫", "蒋", "沈", "韩", "杨", "朱", "秦", "尤", "许"}; |
| | | String[] MING = new String[]{"晓", "霜", "碧", "凡", "夏", "菡", "曼", "香", "若", "烟", "半", "梦", "雅", "绿", "冰", "蓝", "灵", "槐", "平", "安", "书", "翠", "翠", "风", "代", "云", "梦", "曼", "幼", "翠", "梦", "琪", "之", "雅", "之", "桃", "慕", "青", "尔", "岚", "初", "夏", "沛", "菡", "傲", "珊", "曼", "文", "乐", "菱", "惜", "文", "香", "寒",}; |
| | | String[] USER_LEVEL = new String[]{"准会员", "普卡", "潜客", "金卡", "钻石卡", "银卡", "黑钻卡"}; |
| | | String[] CHANNEL_TYPE = new String[]{"PR渠道", "TMK渠道", "三方平台", "会员", "前员工", "医生", "天猫", "大众点评", "微博", "抖音", "新氧", "爱尔健员工", "私域", "百度", "红人合作", "艾芯荟", "路过"}; |
| | | String[] SHOP_ID = new String[]{"4eefc8a1bfa611ecaeb57cd30a51ed1a", "605e391b620d11ebb06bb8599f4cafbe", "b88e3cd8620d11ebb06bb8599f4cafbe", |
| | | "b96aa6d1620d11ebb06bb8599f4cafbe", "bb4e8a7d620d11ebb06bb8599f4cafbe", "cd8b395f945c11ecaeb57cd30a51ed1a"}; |
| | | String[] SHOP_NAME = new String[]{"北京光华店", "新天地店", "东银店", "", "杭州店", "静安店", "古北店"}; |
| | | String[] USER_STATUS = new String[]{"active_member", "sleeping_member", "deep_sleep_member"}; |
| | | |
| | | String[] PROJECT_NAME = new String[]{"玻尿酸", "Fotona","海菲秀","皮秒","乔雅登","OPT"}; |
| | | String[] PROJECT_ID = new String[]{"000075ee7afc11ebb06bb8599f4cafbe", "007cc926647911ebb06bb8599f4cafbe","018cbc9e8b9711ebb06bb8599f4cafbe","01abe206620e11ebb06bb8599f4cafbe", |
| | | "035d7079647711ebb06bb8599f4cafbe","03b0269b620e11ebb06bb8599f4cafbe"}; |
| | | |
| | | |
| | | Random random = new Random(); |
| | | |
| | | //初始化顾问 |
| | | Employee employee = new Employee(); |
| | | employee.setCnName("王小雅"); |
| | | employeeService.insert(employee); |
| | | |
| | | int xLen = XING.length; |
| | | int mLen = MING.length; |
| | | Set<String> set = new HashSet<>(); |
| | | List<Employee> employeeList = new ArrayList<Employee>(); |
| | | for(int i = 0;i < 30;i ++) |
| | | { |
| | | employee = new Employee(); |
| | | employee.setCnName(XING[random.nextInt(xLen)] + MING[random.nextInt(mLen)]); |
| | | |
| | | if(set.contains(employee.getCnName())) |
| | | { |
| | | continue; |
| | | } |
| | | set.add(employee.getCnName()); |
| | | |
| | | employeeService.insert(employee); |
| | | employeeList.add(employee); |
| | | } |
| | | |
| | | //初始化用户 |
| | | User user; |
| | | int ranInt; |
| | | Calendar calendar; |
| | | List<User> userList = new ArrayList<>(); |
| | | set.clear(); |
| | | Map<String, User> map = new HashMap<>(); |
| | | for(int i = 0;i < 200;i ++) |
| | | { |
| | | user = new User(); |
| | | user.setName(XING[random.nextInt(xLen)] + MING[random.nextInt(mLen)]); |
| | | |
| | | if(set.contains(user.getName())) |
| | | { |
| | | continue; |
| | | } |
| | | set.add(user.getName()); |
| | | |
| | | user.setGender(random.nextInt(2) + 1); |
| | | |
| | | ranInt = random.nextInt(employeeList.size()); |
| | | user.setHisCorpUserId(employeeList.get(ranInt).getId()); |
| | | user.setHisCorpUserName(employeeList.get(ranInt).getCnName()); |
| | | user.setUserLevel(USER_LEVEL[random.nextInt(USER_LEVEL.length)]); |
| | | user.setChannelType(CHANNEL_TYPE[random.nextInt(CHANNEL_TYPE.length)]); |
| | | |
| | | ranInt = random.nextInt(SHOP_ID.length); |
| | | user.setShopId(SHOP_ID[ranInt]); |
| | | user.setShopName(SHOP_NAME[ranInt]); |
| | | |
| | | user.setUserStatus(USER_STATUS[random.nextInt(USER_STATUS.length)]); |
| | | |
| | | calendar = Calendar.getInstance(); |
| | | calendar.add(Calendar.YEAR, -1); |
| | | calendar.add(Calendar.DAY_OF_YEAR, random.nextInt(720) - 360); |
| | | |
| | | user.setCreateTime(calendar.getTime()); |
| | | |
| | | userService.insert(user); |
| | | |
| | | userList.add(user); |
| | | map.put(user.getId(), user); |
| | | } |
| | | |
| | | //初始化订单 |
| | | OrdersTotal ordersTotal; |
| | | List<OrdersTotal> ordersTotalList = new ArrayList<>(); |
| | | for(int i = 0;i < 10000; i ++) |
| | | { |
| | | ordersTotal = new OrdersTotal(); |
| | | ordersTotal.setActualTotal(BigDecimal.valueOf(random.nextInt(10000))); |
| | | ordersTotal.setOrderNo(UUID.randomUUID().toString()); |
| | | |
| | | user = userList.get(random.nextInt(userList.size())); |
| | | ordersTotal.setShopId(user.getShopId()); |
| | | ordersTotal.setShopName(user.getShopName()); |
| | | ordersTotal.setUserId(user.getId()); |
| | | ordersTotal.setUserName(user.getName()); |
| | | |
| | | calendar = Calendar.getInstance(); |
| | | calendar.add(Calendar.YEAR, -1); |
| | | calendar.add(Calendar.DAY_OF_YEAR, random.nextInt(720) - 360); |
| | | ordersTotal.setCreateTime(calendar.getTime()); |
| | | |
| | | ordersTotalService.insert(ordersTotal); |
| | | |
| | | ordersTotalList.add(ordersTotal); |
| | | } |
| | | |
| | | //初始化业绩 |
| | | PerformanceInfo performanceInfo; |
| | | for(int i = 0;i < 10000;i ++) |
| | | { |
| | | performanceInfo = new PerformanceInfo(); |
| | | |
| | | ranInt = random.nextInt(ordersTotalList.size()); |
| | | ordersTotal = ordersTotalList.get(ranInt); |
| | | performanceInfo.setPerformanceTotal(ordersTotal.getActualTotal()); |
| | | |
| | | user = map.get(ordersTotal.getUserId()); |
| | | performanceInfo.setBelongConsultantId(user.getHisCorpUserName()); |
| | | performanceInfo.setBelongConsultantId(user.getHisCorpUserId()); |
| | | performanceInfo.setUserId(user.getId()); |
| | | performanceInfo.setUserName(user.getName()); |
| | | |
| | | employee = employeeList.get(random.nextInt(employeeList.size())); |
| | | performanceInfo.setDeductionDoctorId(employee.getId()); |
| | | performanceInfo.setDeductionDoctorName(employee.getCnName()); |
| | | |
| | | performanceInfo.setDeductionTime(ordersTotal.getCreateTime()); |
| | | |
| | | employee = employeeList.get(random.nextInt(employeeList.size())); |
| | | performanceInfo.setNurseCorpUserId(employee.getId()); |
| | | performanceInfo.setNurseCorpUserName(employee.getCnName()); |
| | | |
| | | ranInt = random.nextInt(SHOP_ID.length); |
| | | performanceInfo.setServiceShopId(SHOP_ID[ranInt]); |
| | | performanceInfo.setServiceShopName(SHOP_NAME[ranInt]); |
| | | |
| | | performanceInfo.setCreateTime(ordersTotal.getCreateTime()); |
| | | |
| | | ranInt = random.nextInt(PROJECT_ID.length); |
| | | performanceInfo.setCommonId(PROJECT_ID[ranInt]); |
| | | performanceInfo.setCommonName(PROJECT_NAME[ranInt]); |
| | | |
| | | performanceInfoService.insert(performanceInfo); |
| | | } |
| | | |
| | | return Result.success(); |
| | | } |
| | | |
| | | |
| | | } |