| import cn.hutool.core.bean.BeanUtil;  | 
| import cn.hutool.core.codec.Base64;  | 
| import cn.hutool.core.collection.CollUtil;  | 
| import cn.hutool.core.convert.Convert;  | 
| import cn.hutool.core.date.DateTime;  | 
| import cn.hutool.core.date.DateUtil;  | 
| import cn.hutool.core.date.TimeInterval;  | 
| import cn.hutool.core.lang.Dict;  | 
| import cn.hutool.core.thread.ThreadUtil;  | 
| import cn.hutool.core.util.NumberUtil;  | 
| import cn.hutool.core.util.StrUtil;  | 
| import com.xzx.gc.GcOrderApplication;  | 
| import com.xzx.gc.common.Result;  | 
| import com.xzx.gc.common.constant.CommonEnum;  | 
| import com.xzx.gc.common.constant.Constants;  | 
| import com.xzx.gc.common.constant.OrderEnum;  | 
| import com.xzx.gc.common.constant.UserEnum;  | 
| import com.xzx.gc.common.dto.gdmap.GdGEODto;  | 
| import com.xzx.gc.common.utils.BusinessUtil;  | 
| import com.xzx.gc.common.utils.IdUtils;  | 
| import com.xzx.gc.common.utils.RandomUtil;  | 
| import com.xzx.gc.common.utils.SpringUtil;  | 
| import com.xzx.gc.common.utils.gdmap.GdMapUtil;  | 
| import com.xzx.gc.common.utils.gdmap.GdTraceUtil;  | 
| import com.xzx.gc.entity.*;  | 
| import com.xzx.gc.model.order.FenceDto;  | 
| import com.xzx.gc.model.user.AccountVo;  | 
| import com.xzx.gc.order.dto.OrderCustomDto;  | 
| import com.xzx.gc.order.mapper.*;  | 
| import com.xzx.gc.order.service.*;  | 
| import com.xzx.order.RandomValue;  | 
| import org.junit.Test;  | 
| import org.junit.runner.RunWith;  | 
| import org.springframework.beans.factory.annotation.Autowired;  | 
| import org.springframework.boot.test.context.SpringBootTest;  | 
| import org.springframework.test.context.ActiveProfiles;  | 
| import org.springframework.test.context.junit4.SpringRunner;  | 
| import org.springframework.transaction.annotation.Transactional;  | 
| import tk.mybatis.mapper.entity.Example;  | 
|   | 
| import java.math.BigDecimal;  | 
| import java.math.RoundingMode;  | 
| import java.util.*;  | 
| import java.util.concurrent.CountDownLatch;  | 
| import java.util.stream.Collectors;  | 
|   | 
|   | 
| @RunWith(SpringRunner.class)  | 
| @SpringBootTest(classes = {GcOrderApplication.class})  | 
| @ActiveProfiles("dev")  | 
| public class SpringTest {  | 
|   | 
|     @Autowired  | 
|     private UserMapper userMapper;  | 
|   | 
|     @Autowired  | 
|     private ConfigService configService;  | 
|   | 
|     @Autowired  | 
|     private OrderStorageInfoMapper orderStorageInfoMapper;  | 
|   | 
|     @Autowired  | 
|     private OrderStorageInfoInsertMapper orderStorageInfoInsertMapper;  | 
|   | 
|     @Autowired  | 
|     private OrderStorageDetailMapper orderStorageDetailMapper;  | 
|   | 
|     @Autowired  | 
|     private OrderDetailMapper orderDetailMapper;  | 
|   | 
|     @Autowired  | 
|     private OrderDetailInsertMapper orderDetailInsertMapper;  | 
|   | 
|   | 
|     @Autowired  | 
|     private OrderItemInfoMapper orderItemInfoMapper;  | 
|   | 
|   | 
|     @Autowired  | 
|     private AccountMapper accountMapper;  | 
|   | 
|     @Autowired  | 
|     private AddressMapper addressMapper;  | 
|   | 
|     @Autowired  | 
|     private AddressLevelService addressLevelService;  | 
|   | 
|     @Autowired  | 
|     private OrderService orderService;  | 
|   | 
|     @Autowired  | 
|     private OrderMapper orderMapper;  | 
|   | 
|     @Autowired  | 
|     private OrderInsertMapper orderInsertMapper;  | 
|   | 
|     @Autowired  | 
|     private AddressInsertMapper addressInsertMapper;  | 
|   | 
|     @Autowired  | 
|     private UserInsertMapper userInsertMapper;  | 
|   | 
|     @Autowired  | 
|     private AccountInsertMapper accountInsertMapper;  | 
|   | 
|     @Autowired  | 
|     private AddressService addressService;  | 
|   | 
|     @Autowired  | 
|     private OrderItemInfoInsertMapper orderItemInfoInsertMapper;  | 
|   | 
|     @Autowired  | 
|     private SysEnvironmentalInfoService sysEnvironmentalInfoService;  | 
|   | 
|     @Autowired  | 
|     private FenceMapper fenceMapper;  | 
|   | 
|     @Autowired  | 
|     private UserService userService;  | 
|   | 
|     @Autowired  | 
|     private OtherUserService otherUserService;  | 
|   | 
|   | 
|     @Autowired  | 
|     private IdUtils idUtils;  | 
|   | 
|     @Autowired  | 
|     private BusinessUtil businessUtil;  | 
|   | 
|     @Autowired  | 
|     private PartnerGaodeService partnerGaodeService;  | 
|   | 
|     @Autowired  | 
|     private OrderComplaintService orderComplaintService;  | 
|   | 
|     @Autowired  | 
|     private PartnerTraceService partnerTraceService;  | 
|   | 
|     @Autowired  | 
|     private FenceService fenceService;  | 
|   | 
|     @Test  | 
|     public void 初始化报表(){  | 
| //        PartnerGaode byTownId = partnerGaodeService.findByTownId("1813");  | 
| //        System.out.println(byTownId.getId());  | 
| //        List<OrderComplaint> complaints = orderComplaintService.findPartner();  | 
| //        List<List<OrderComplaint>> complaintByTime = CollUtils.groupByField(complaints, "createTime");  | 
|   | 
|     }  | 
|   | 
|     @Test  | 
|     public void checkFence(){  | 
|         FenceDto fence = fenceService.getFence("1818", false, "112.939038", "28.165681", true);  | 
|     }  | 
|   | 
|   | 
|   | 
|   | 
|     public List<OtherUserInfo> findOther(List<OtherUserInfo> list,int size){  | 
|         List<OtherUserInfo> list2=new ArrayList<>();  | 
|         int[] ints = RandomUtil.randomCommon(0, list.size() - 1, size);  | 
|         for (int anInt : ints) {  | 
|             OtherUserInfo otherUserInfo = list.get(anInt);  | 
|             list2.add(otherUserInfo);  | 
|         }  | 
|         return list2;  | 
|     }  | 
|   | 
|     public List<UserInfo> findUser(List<UserInfo> list,int size){  | 
|         List<UserInfo> list2=new ArrayList<>();  | 
|         int[] ints = RandomUtil.randomCommon(0, list.size() - 1, size);  | 
|         for (int anInt : ints) {  | 
|             UserInfo otherUserInfo = list.get(anInt);  | 
|             list2.add(otherUserInfo);  | 
|         }  | 
|         return list2;  | 
|     }  | 
|   | 
|     public List<SysEnvironmentalInfo> findCate(List<SysEnvironmentalInfo> list,int size){  | 
|         List<SysEnvironmentalInfo> list2=new ArrayList<>();  | 
|         int[] ints = RandomUtil.randomCommon(0, list.size() - 1, size);  | 
|         for (int anInt : ints) {  | 
|             SysEnvironmentalInfo otherUserInfo = list.get(anInt);  | 
|             list2.add(otherUserInfo);  | 
|         }  | 
|         return list2;  | 
|     }  | 
|   | 
|   | 
|     @Test  | 
|     public void 假数据() throws InterruptedException {  | 
|         TimeInterval timer = DateUtil.timer();  | 
|         final String[] date = {null};  | 
|         final int[] len = {0};  | 
|         final int[] otherSize = {0};  | 
|         final int[] userSize = new int[1];  | 
|         final int[] weightAll = new int[1];  | 
|   | 
|         int size=5;  | 
|   | 
|         CountDownLatch countDownLatch = ThreadUtil.newCountDownLatch(size);  | 
|         for (int i = 0; i <size;i++) {  | 
|   | 
|             if(i==0){  | 
|                 //起始日期  | 
|                 date[0] ="2019-09-23 08:30:00";  | 
|                 //日期天的跨度  | 
|                 len[0] =8;  | 
|                 //回收员数目  | 
|                 otherSize[0] =4;  | 
|                 //每天50单  | 
|                 userSize[0] =50;  | 
|                 //公斤 总共2000公斤  | 
|                 weightAll[0] =2000;  | 
|             }else if(i==1){  | 
|   | 
|                 date[0] ="2019-10-01 08:30:00";  | 
|                 len[0] =31;  | 
|                 otherSize[0] =10;  | 
|                 userSize[0] =180;  | 
|                 weightAll[0] =4500;  | 
|             }else if(i==2){  | 
|                 date[0] ="2019-11-01 08:30:00";  | 
|                 len[0] =30;  | 
|                 otherSize[0] =20;  | 
|                 userSize[0] =300;  | 
|                 weightAll[0] =8000;  | 
|             }else  if(i==3){  | 
|                 date[0] ="2019-12-01 08:30:00";  | 
|                 len[0] =31;  | 
|                 otherSize[0] =30;  | 
|                 userSize[0] =500;  | 
|                 weightAll[0] =12000;  | 
|   | 
|             }else if(i==4){  | 
|                 date[0] ="2020-01-01 08:30:00";  | 
|                 len[0] =20;  | 
|                 otherSize[0] =35;  | 
|                 userSize[0] =550;  | 
|                 weightAll[0] =13000;  | 
|   | 
|             }  | 
|   | 
|             Runnable callable=()->{  | 
|                 Dict gen = gen(date[0], len[0], otherSize[0], userSize[0], weightAll[0]);  | 
|                 List<OrderInfo> orders= (List<OrderInfo>) gen.get("orders");  | 
|                 List<OrderItemInfo> orderItems= (List<OrderItemInfo>) gen.get("orderItems");  | 
|                 List<OrderDetailInfo> orderDetails= (List<OrderDetailInfo>) gen.get("orderDetails");  | 
|                 List<OrderStorageInfo> storages= (List<OrderStorageInfo>) gen.get("storages");  | 
|                 List<OrderStorageDetailInfo> storageDetails= (List<OrderStorageDetailInfo>) gen.get("storageDetails");  | 
|                 List<OrderStorageDetailInfo> storageDetails2= (List<OrderStorageDetailInfo>) gen.get("storageDetails2");  | 
|                 orderInsertMapper.insertBatchByPrimaryKeySelective(orders);  | 
|                 orderDetailInsertMapper.insertBatchByPrimaryKeySelective(orderDetails);  | 
|                 orderStorageInfoInsertMapper.insertBatchByPrimaryKeySelective(storages);  | 
|   | 
|   | 
|   | 
|                 //切分大小  一次执行几十万将导致Gc  | 
|                 int splitSize=10000;  | 
|   | 
|                 List<List<OrderItemInfo>> split = CollUtil.split(orderItems, splitSize);  | 
|                 for (List<OrderItemInfo> list : split) {  | 
|                     orderItemInfoInsertMapper.insertBatchByPrimaryKeySelective(list);  | 
|                 }  | 
|   | 
|                 List<List<OrderStorageDetailInfo>> split1 = CollUtil.split(storageDetails, splitSize);  | 
|                 for (List<OrderStorageDetailInfo> list : split1) {  | 
|                     orderStorageDetailMapper.insertList(list);  | 
|                 }  | 
|   | 
|   | 
|                 List<List<OrderStorageDetailInfo>> split2 = CollUtil.split(storageDetails2, splitSize);  | 
|                 for (List<OrderStorageDetailInfo> list : split2) {  | 
|                     orderStorageDetailMapper.insertList(list);  | 
|                 }  | 
|   | 
|                 countDownLatch.countDown();  | 
|   | 
|             };  | 
|             ThreadUtil.execAsync(callable,true);  | 
|         }  | 
|   | 
|         countDownLatch.await();  | 
|   | 
|         System.out.println("执行成功,耗时"+timer.intervalPretty());  | 
|   | 
|     }  | 
|   | 
|   | 
|     public Dict gen(String date, int len, int otherSize, int userSize, int weightAll){  | 
|   | 
|         Dict dict=Dict.create();  | 
|         Date dateDate=DateUtil.parseDateTime(date);  | 
| //        List<OtherUserInfo> list = otherUserService.findTest();  | 
|         List<OtherUserInfo> list = CollUtil.newArrayList();  | 
|   | 
|         //用户数=单日订单数*2  | 
|         int generUserSize=userSize*2;  | 
|   | 
|         List<UserInfo> userList=CollUtil.newArrayList();  | 
|         List<AccountInfo> accountList=CollUtil.newArrayList();  | 
|         List<AddressInfo> addrList=CollUtil.newArrayList();  | 
|   | 
|         //生成用户  | 
|         for (int i = 0; i < len; i++) {  | 
|             DateTime dateTime = DateUtil.offsetDay(dateDate, i);  | 
|             for (int j = 0; j < generUserSize; j++) {  | 
|                 //往后延迟1个半小时生成用户  | 
|                 int minute=90*60;  | 
|                 int timeIndex = (int) (Math.random() *minute);  | 
|                 Date createTime=DateUtil.offsetSecond(dateTime,-timeIndex);  | 
|                 String time=DateUtil.formatDateTime(createTime);  | 
|                 //新建一个非注册用户  | 
|                 String yh = idUtils.generate("YH", 3);  | 
|                 UserInfo userInfo2=new UserInfo();  | 
|                 userInfo2.setUserId(yh);  | 
|                 Map address = RandomValue.getAddress();  | 
|                 userInfo2.setMobilePhone(address.get("tel").toString());  | 
|                 userInfo2.setNickName(Base64.encode(address.get("name").toString()));  | 
|                 userInfo2.setRegistTime(time);  | 
|                 userInfo2.setDelFlag(Constants.DEL_NOT_FLAG);  | 
|                 userInfo2.setRegistType(Convert.toShort(CommonEnum.正常注册用户.getValue()));  | 
|                 userInfo2.setUserType(CommonEnum.普通用户.getValue());  | 
|                 userInfo2.setIsProhibit(false);  | 
|                 userInfo2.setSex(address.get("sex").toString());  | 
|                 userInfo2.setAvatar(Constants.DEFAULT_AVATAR);  | 
|                 userList.add(userInfo2);  | 
|   | 
|                 //增加一个默认账户  | 
|                 AccountInfo accountInfo =new AccountInfo();  | 
|                 accountInfo.setAccountId(idUtils.generate("ZH",4));  | 
|                 accountInfo.setAccountName(userInfo2.getMobilePhone());  | 
|                 accountInfo.setUserId(yh);  | 
|                 accountInfo.setFreezeMoney("0");  | 
|                 accountInfo.setWithdrawMoney("0");  | 
|                 accountInfo.setMoney("0");  | 
|                 accountInfo.setOverdraftLimit("0");  | 
|                 accountInfo.setDelFlag(0);  | 
|                 accountInfo.setIsProhibit("0");  | 
|                 accountInfo.setErrorTimes(0);  | 
|                 accountInfo.setCreateTime(time);  | 
|                 accountInfo.setUpdateTime(time);  | 
|                 accountList.add(accountInfo);  | 
|   | 
|                 //偶数就新增地址 奇数不新增  | 
|                 if((j+1)%2==0){  | 
|                     AddressInfo addressInfo=new AddressInfo();  | 
|                     addressInfo.setDelFlag(Convert.toStr(Constants.DEL_NOT_FLAG));  | 
|                     addressInfo.setMobilePhone(userInfo2.getMobilePhone());  | 
|                     addressInfo.setUserId(yh);  | 
|                     addressInfo.setProvinceId("1809");  | 
|                     addressInfo.setCityId("1810");  | 
|                     addressInfo.setTownshipId("1812");  | 
|                     addressInfo.setAddressArea("湖南省长沙市天心区");  | 
|                     addressInfo.setDetailAddress(address.get("road").toString());  | 
|                     addressInfo.setCreateTime(time);  | 
|                     addressInfo.setFlag(UserEnum.默认地址.getValue());  | 
|                     addressInfo.setDelFlag("0");  | 
|                     addressInfo.setRelaName(address.get("name").toString());  | 
|                     addressInfo.setRelaPhone(userInfo2.getMobilePhone());  | 
|                     addrList.add(addressInfo);  | 
|                 }  | 
|             }  | 
|         }  | 
|   | 
|         userInsertMapper.insertBatchByPrimaryKeySelective(userList);  | 
|         accountInsertMapper.insertBatchByPrimaryKeySelective(accountList);  | 
| //        addressInsertMapper.insertBatchByPrimaryKeySelective(addrList);  | 
|   | 
|   | 
|   | 
|         List<UserInfo> listUser =userService.findHaveAddr();  | 
|         List<SysEnvironmentalInfo> listSys =sysEnvironmentalInfoService.find();  | 
|   | 
|         for (Iterator<SysEnvironmentalInfo> iterator = listSys.iterator(); iterator.hasNext(); ) {  | 
|             SysEnvironmentalInfo next =  iterator.next();  | 
|             if(next.getParentId().toString().equals(Constants.HOUSE_HOLD_ITEM_TYPE)){  | 
|                 iterator.remove();  | 
|             }  | 
|         }  | 
|   | 
|         //9月23-30日数据  | 
|   | 
|   | 
|         int[] ints = RandomUtil.randomCommon(185, 189, 1);  | 
|   | 
|         List<OrderInfo> orders=new ArrayList<>();  | 
|         List<OrderItemInfo> orderItems=new ArrayList<>();  | 
|         List<OrderDetailInfo> orderDetails=new ArrayList<>();  | 
|         List<OrderStorageInfo> storages=new ArrayList<>();  | 
|         List<OrderStorageDetailInfo> storageDetails=new ArrayList<>();  | 
|         List<OrderStorageDetailInfo> storageDetails2=new ArrayList<>();  | 
|   | 
|   | 
|         for (int i = 0; i < len; i++) {  | 
|             DateTime dateTime = DateUtil.offsetDay(dateDate, i);  | 
|             //每日 回收人数4人  每天50单 总共2000公斤  | 
|             List<OtherUserInfo> other = findOther(list,otherSize);  | 
|             List<UserInfo> user = findUser(listUser,userSize);  | 
|             //每个订单的总公斤数  | 
|             int[] weights = RandomUtil.splitInteger(userSize, weightAll, false);  | 
|             System.out.println(user.size());  | 
|             int iIndex=0;  | 
|   | 
|   | 
|             for (UserInfo userInfo : user) {  | 
|                 String userId = userInfo.getUserId();  | 
|                 String mobilePhone = userInfo.getMobilePhone();  | 
|                 String address=userInfo.getDetailAddress();  | 
|                 String addrArea=userInfo.getAddressArea();  | 
|   | 
|                 //插入订单表  | 
|                 OrderInfo orderInfo=new OrderInfo();  | 
|                 orderInfo.setAddress(address);  | 
|                 orderInfo.setOrderStatus("5");  | 
|                 orderInfo.setOrderType("1");  | 
|                 orderInfo.setAddressArea(addrArea);  | 
|                 orderInfo.setCreateUserId(userId);  | 
|                 int index = (int) (Math.random() *other.size());  | 
|                 OtherUserInfo otherUserInfo = other.get(index);  | 
|                 orderInfo.setReceiver(otherUserInfo.getUserId());  | 
|                 //五点下班  | 
|                 int minute=8*60+30;  | 
|                 int timeIndex = (int) (Math.random() *minute);  | 
|                 Date createTime=DateUtil.offsetMinute(dateTime,timeIndex);  | 
|                 orderInfo.setCreateTime(createTime.toString());  | 
|                 //预约时间偏移1-2个小时  | 
|                 int hour=2;  | 
|                 int timeIndex2 = (int) (Math.random() *hour);  | 
|                 Date reserveTime=DateUtil.offsetHour(createTime,timeIndex2+1);  | 
|                 orderInfo.setReserveTime(reserveTime.toString());  | 
|                 orderInfo.setRelaPhone(mobilePhone);  | 
|                 String userName=userInfo.getRelaName();  | 
|                 orderInfo.setRelaName(userName);  | 
|                 orderInfo.setTownId(Convert.toStr(ints[0]));  | 
|                 orderInfo.setCreateType(Convert.toShort(1));  | 
|                 orderInfo.setDelFlag(Convert.toShort(0));  | 
|                 String orderId=idUtils.generate("DD",1);  | 
|                 orderInfo.setOrderId(orderId);  | 
|                 orders.add(orderInfo);  | 
| //                orderMapper.insertSelective(orderInfo);  | 
|   | 
|                 //插入订单详情  | 
|                 OrderDetailInfo orderDetailInfo=new OrderDetailInfo();  | 
|                 orderDetailInfo.setOrderId(orderId);  | 
|                 orderDetailInfo.setCreateUserName(userName);  | 
|                 orderDetailInfo.setMobilePhone(mobilePhone);  | 
|                 minute=31;  | 
|                 timeIndex = (int) (Math.random() *minute);  | 
|                 DateTime receiveTime = DateUtil.offsetMinute(createTime, timeIndex);  | 
|                 orderDetailInfo.setReceiveTime(receiveTime.toString());  | 
|                 orderDetailInfo.setReserveTime(reserveTime.toString());  | 
|                 minute=31;  | 
|                 timeIndex = (int) (Math.random() *minute);  | 
|                 Date completeTime=DateUtil.offsetMinute(reserveTime,timeIndex+30);  | 
|                 orderDetailInfo.setCompleteTime(completeTime.toString());  | 
|                 orderDetailInfo.setAddressId(userInfo.getAddressId());  | 
|   | 
|                 int weight = weights[iIndex];  | 
|   | 
|                 int cateSize=3;  | 
|                 if(weight<=5){  | 
|                     cateSize=1;  | 
|                 }  | 
|                 List<SysEnvironmentalInfo> cate = findCate(listSys,cateSize);  | 
|                 orderDetailInfo.setWeight(weight+"");  | 
|   | 
|                 //将分类重量分下  | 
|                 int[] itemWeithts = RandomUtil.splitInteger(cateSize,weight,false);  | 
|   | 
|   | 
|                 BigDecimal money=BigDecimal.ZERO;  | 
|                 int j=0;  | 
|                 for (SysEnvironmentalInfo sysEnvironmentalInfo : listSys) {  | 
|                     //插入订单分类表  | 
|                     OrderItemInfo orderItemInfo=new OrderItemInfo();  | 
|                     orderItemInfo.setOrderId(orderId);  | 
|                     orderItemInfo.setItemType(sysEnvironmentalInfo.getItemType());  | 
|                     if(cate.stream().filter(x->x.getItemType().equals(sysEnvironmentalInfo.getItemType())).count()>0){  | 
|                         orderItemInfo.setWeight(Convert.toStr(itemWeithts[j]));  | 
|                         j++;  | 
|                     }else {  | 
|                         orderItemInfo.setWeight(Convert.toStr(Constants.WEIGHT_INIT));  | 
|                     }  | 
|   | 
|                     String price = sysEnvironmentalInfo.getPrice();  | 
|                     BigDecimal mul = NumberUtil.mul(Convert.toBigDecimal(price), Convert.toBigDecimal(orderItemInfo.getWeight()));  | 
|                     orderItemInfo.setMoney(businessUtil.changeMoney(mul.toString()));  | 
|                     money=NumberUtil.add(money,mul);  | 
|                     orderItems.add(orderItemInfo);  | 
|   | 
|                 }  | 
|                 String allMoney=businessUtil.changeMoney(money.toString());  | 
|                 orderDetailInfo.setMoney(allMoney);  | 
|                 orderDetailInfo.setStorageMoney(allMoney);  | 
|                 orderDetailInfo.setReceiverName(otherUserInfo.getName());  | 
|                 orderDetailInfo.setReceiverPhone(otherUserInfo.getMobilePhone());  | 
|                 if(i/2==0) {  | 
|                     orderDetailInfo.setStorageUserId("USER1190571142298341376");  | 
|                     orderDetailInfo.setStorageUserName("陈松");  | 
|                     orderDetailInfo.setStorageUserPhone("17788919577");  | 
|                 }else{  | 
|                     orderDetailInfo.setStorageUserId("64");  | 
|                     orderDetailInfo.setStorageUserName("匡喜寿");  | 
|                     orderDetailInfo.setStorageUserPhone("13469424076");  | 
|                 }  | 
|                 orderDetails.add(orderDetailInfo);  | 
|   | 
|   | 
|                 //插入入库表  | 
|                 OrderStorageInfo orderStorageInfo=new OrderStorageInfo();  | 
|                 String rkId=idUtils.generate("RK",1);  | 
|                 orderStorageInfo.setStorageId(rkId);  | 
|                 orderStorageInfo.setOrderId(orderId);  | 
|                 if(i/2==0) {  | 
|                     orderStorageInfo.setStorageUserId("USER1190571142298341376");  | 
|                     orderStorageInfo.setStorageUserName("陈松");  | 
|                     orderStorageInfo.setStorageUserPhone("17788919577");  | 
|                 }else{  | 
|                     orderStorageInfo.setStorageUserId("64");  | 
|                     orderStorageInfo.setStorageUserName("匡喜寿");  | 
|                     orderStorageInfo.setStorageUserPhone("13469424076");  | 
|                 }  | 
|   | 
|                 minute=31;  | 
|                 timeIndex = (int) (Math.random() *minute);  | 
|                 DateTime dateTime1 = DateUtil.offsetMinute(dateTime, minute);  | 
|                 DateTime dateTime2 = DateUtil.offsetMinute(dateTime1, timeIndex);  | 
|                 orderStorageInfo.setStorageTime(dateTime2.toString());  | 
|                 orderStorageInfo.setStorageMoney(Convert.toBigDecimal(allMoney));  | 
|                 orderStorageInfo.setRecycleMoney(Convert.toBigDecimal(allMoney));  | 
|                 orderStorageInfo.setReceiver(orderInfo.getReceiver());  | 
|                 orderStorageInfo.setReceiverName(otherUserInfo.getName());  | 
|                 orderStorageInfo.setReceiverPhone(otherUserInfo.getMobilePhone());  | 
|                 orderStorageInfo.setReceiverAvatar(otherUserInfo.getAvatar());  | 
|                 orderStorageInfo.setSysStorageId(1L);  | 
|                 orderStorageInfo.setStorageWeight(Convert.toStr(weight));  | 
|                 orderStorageInfo.setRecycleWeight(Convert.toStr(weight));  | 
|                 storages.add(orderStorageInfo);  | 
|   | 
|                 //插入入库详情  | 
|                 int k=0;  | 
|                 for (SysEnvironmentalInfo sysEnvironmentalInfo : listSys) {  | 
|                     OrderStorageDetailInfo orderStorageDetailInfo = new OrderStorageDetailInfo();  | 
|                     orderStorageDetailInfo.setStorageId(rkId);  | 
|                     orderStorageDetailInfo.setItemType(sysEnvironmentalInfo.getItemType());  | 
|                     if(cate.stream().filter(x->x.getItemType().equals(sysEnvironmentalInfo.getItemType())).count()>0) {  | 
|                         orderStorageDetailInfo.setWeight(Convert.toBigDecimal(itemWeithts[k]));  | 
|                         k++;  | 
|                     }else{  | 
|                         orderStorageDetailInfo.setWeight(Constants.WEIGHT_INIT);  | 
|                     }  | 
|                     String price = sysEnvironmentalInfo.getPrice();  | 
|                     BigDecimal mul = NumberUtil.mul(Convert.toBigDecimal(price), Convert.toBigDecimal(orderStorageDetailInfo.getWeight()));  | 
|                     orderStorageDetailInfo.setMoney(businessUtil.changeMoney(mul.toString()));  | 
|                     orderStorageDetailInfo.setFlag("1");  | 
|                     storageDetails.add(orderStorageDetailInfo);  | 
|                     OrderStorageDetailInfo orderStorageDetailInfo1=new OrderStorageDetailInfo();  | 
|                     BeanUtil.copyProperties(orderStorageDetailInfo,orderStorageDetailInfo1);  | 
|                     orderStorageDetailInfo1.setFlag("2");  | 
|                     storageDetails2.add(orderStorageDetailInfo1);  | 
|                 }  | 
|                 iIndex++;  | 
|           }  | 
|         }  | 
|         dict.put("orders",orders);  | 
|         dict.put("orderItems",orderItems);  | 
|         dict.put("orderDetails",orderDetails);  | 
|         dict.put("storages",storages);  | 
|         dict.put("storageDetails",storageDetails);  | 
|         dict.put("storageDetails2",storageDetails2);  | 
|   | 
|         return dict;  | 
|     }  | 
|   | 
|     @Test  | 
|     public void fence(){  | 
| //        List<Fence> fences = fenceMapper.selectAll();  | 
| //        System.out.println(fences.size());  | 
|         List<String> list=new ArrayList<>();  | 
|         list.add("10");  | 
|         List<UserInfo> byIds = userService.findByIds(list);  | 
|         System.out.println(byIds.size());  | 
|     }  | 
|   | 
|   | 
|     @Test  | 
|     public void fixtaeget(){  | 
|         //修复意向客户的地址问题  | 
|   | 
|     }  | 
|     /**  | 
|      * 修复线上经纬度问题  | 
|      */  | 
|     @Test  | 
|     public void fixLon(){  | 
|         List<AddressInfo> addressInfos = addressService.findWithLonNull();  | 
|         System.out.println("为空的地址有"+addressInfos.size()+"条");  | 
|         int j=0;  | 
|         int i=0;  | 
|         for (AddressInfo addressInfo : addressInfos) {  | 
|             GdGEODto gdGEODto=new GdGEODto();  | 
|             AddressLevelInfo byTownIds = addressLevelService.find(addressInfo.getProvinceId(),addressInfo.getCityId(),addressInfo.getTownshipId());  | 
|             gdGEODto.setCity(byTownIds.getLevel2Name());  | 
|             gdGEODto.setAddress(addressInfo.getAddressArea()+addressInfo.getDetailAddress());  | 
|             Result locationByAddress = GdMapUtil.getLocationByAddress(gdGEODto);  | 
|             if(locationByAddress.getCode()==0&&locationByAddress.getData()!=null) {  | 
|                 addressInfo.setLongitude(locationByAddress.getData().toString().split(",")[0]);  | 
|                 addressInfo.setLatitude(locationByAddress.getData().toString().split(",")[1]);  | 
|                 j++;  | 
|                 addressMapper.updateByPrimaryKeySelective(addressInfo);  | 
|   | 
|   | 
|                 List<OrderCustomDto> byCreateUserId = orderService.findByAddressId(addressInfo.getAddressId().toString());  | 
|   | 
|   | 
|                 if(CollUtil.isNotEmpty(byCreateUserId)){  | 
|                     for (OrderCustomDto orderInfo : byCreateUserId) {  | 
|                         if(StrUtil.isBlank(orderInfo.getLongitude())||orderInfo.getLongitude().equals("0")){  | 
|                             OrderInfo orderInfo1=new OrderInfo();  | 
|                             orderInfo1.setOrderId(orderInfo.getOrderId());  | 
|                             orderInfo1.setLongitude(addressInfo.getLongitude());  | 
|                             orderInfo1.setLatitude(addressInfo.getLatitude());  | 
|                             orderInfo1.setTownId(addressInfo.getTownshipId());  | 
|                             orderMapper.updateByPrimaryKeySelective(orderInfo1);  | 
|                             i++;  | 
|                             System.out.println("修复订单:"+orderInfo1.getOrderId());  | 
|                         }  | 
|                     }  | 
|                 }  | 
|             }  | 
|         }  | 
|   | 
|   | 
|         System.out.println("一共修复订单"+i+"个");  | 
|         System.out.println("一共修复地址"+j+"个");  | 
|   | 
|     }  | 
|   | 
|   | 
|   | 
|     @Test  | 
|     public void fixLon2(){  | 
|         int j=0;  | 
|         int i=0;  | 
|   | 
|         List<OrderCustomDto> byCreateUserId = orderService.findWithLonNull();  | 
|   | 
|   | 
|         if(CollUtil.isNotEmpty(byCreateUserId)){  | 
|             for (OrderCustomDto orderInfo : byCreateUserId) {  | 
|                     OrderInfo orderInfo1=new OrderInfo();  | 
|   | 
|                     orderInfo1.setOrderId(orderInfo.getOrderId());  | 
|   | 
|                 String addressId = orderInfo.getAddressId();  | 
|   | 
|                 AddressInfo addressInfo = addressService.findById(addressId);  | 
|                 GdGEODto gdGEODto=new GdGEODto();  | 
|                 AddressLevelInfo byTownIds = addressLevelService.find(addressInfo.getProvinceId(),addressInfo.getCityId(),addressInfo.getTownshipId());  | 
|                 gdGEODto.setCity(byTownIds.getLevel2Name());  | 
|                 gdGEODto.setAddress(addressInfo.getAddressArea()+addressInfo.getDetailAddress());  | 
|                 Result locationByAddress = GdMapUtil.getLocationByAddress(gdGEODto);  | 
|                 if(locationByAddress.getCode()==0&&locationByAddress.getData()!=null) {  | 
|                     addressInfo.setLongitude(locationByAddress.getData().toString().split(",")[0]);  | 
|                     addressInfo.setLatitude(locationByAddress.getData().toString().split(",")[1]);  | 
|                     j++;  | 
|                     addressMapper.updateByPrimaryKeySelective(addressInfo);  | 
|   | 
|                     orderInfo1.setLongitude(addressInfo.getLongitude());  | 
|                     orderInfo1.setLatitude(addressInfo.getLatitude());  | 
|                     orderInfo1.setTownId(addressInfo.getTownshipId());  | 
|                     orderMapper.updateByPrimaryKeySelective(orderInfo1);  | 
|                     i++;  | 
|                 }  | 
|   | 
|   | 
|             }  | 
|         }  | 
|   | 
|         System.out.println("一共修复订单"+i+"个");  | 
|         System.out.println("一共修复地址"+j+"个");  | 
|   | 
|     }  | 
|   | 
|   | 
|   | 
|   | 
|   | 
|   | 
|     @Test  | 
|     public  void test(){  | 
|         //修改目标客户的状态  | 
| //        UserInfo userInfo=new UserInfo();  | 
| //        userInfo.setUserId("1");  | 
| //        userInfo.setDelFlag(Constants.DEL_NOT_FLAG);  | 
| //        int i = userMapper.updateByPrimaryKeySelective(userInfo);  | 
| //        System.out.println(i);  | 
| //        LogUtils.writeIp("192.168.1.110","请求头部对");  | 
| //        List<UserInfo> userInfos = userMapper.selectAll();  | 
|         Map<String,Object> createUserMap=new HashMap<>();  | 
|         createUserMap.put("userId", "37");  | 
|   | 
|         List<AccountVo> createUserAccount = accountMapper.queryMyMoney(createUserMap);  | 
|         String createUserMoney = createUserAccount.get(0).getMoney();  | 
|   | 
|         createUserMap.put("userId", "37");  | 
|         createUserMap.put("money", Convert.toBigDecimal("10"));  | 
|   | 
|         accountMapper.updateMyMoneyByOrder(createUserMap);  | 
|         createUserAccount = accountMapper.queryMyMoney(createUserMap);  | 
|         System.out.println(createUserMoney);  | 
|         System.out.println(createUserAccount.get(0).getMoney());  | 
|         accountMapper.updateMyMoneyByOrder(createUserMap);  | 
|     }  | 
|   | 
|   | 
|   | 
|     /**  | 
|      * 修改老数据没有入库重量和回收重量的问题  | 
|      */  | 
|     @Test  | 
|     public void test3(){  | 
|   | 
|         Example example=new Example(OrderStorageInfo.class);  | 
|         Example.Criteria criteria = example.createCriteria();  | 
|         criteria.andIsNull("recycleWeight");  | 
|         criteria.andIsNull("storageWeight");  | 
|         List<OrderStorageInfo> orderStorageInfos = orderStorageInfoMapper.selectByExample(example);  | 
|         if(CollUtil.isNotEmpty(orderStorageInfos)){  | 
|             System.out.println("总数:"+orderStorageInfos.size());  | 
|   | 
|             for (OrderStorageInfo orderStorageInfo : orderStorageInfos) {  | 
|                 String orderId = orderStorageInfo.getOrderId();  | 
|                 String storageId = orderStorageInfo.getStorageId();  | 
|   | 
|                 //修复入库重量  | 
|                 double sum=0;  | 
|                 OrderStorageDetailInfo orderStorageDetailInfo=new OrderStorageDetailInfo();  | 
|                 orderStorageDetailInfo.setStorageId(storageId);  | 
|                 orderStorageDetailInfo.setFlag("1");  | 
|                 List<OrderStorageDetailInfo> select = orderStorageDetailMapper.select(orderStorageDetailInfo);  | 
|                 if(CollUtil.isNotEmpty(select)){  | 
|                      sum = select.stream().mapToDouble(x -> Convert.toDouble(x.getWeight(),Convert.toDouble(Constants.WEIGHT_INIT))).sum();  | 
|                 }  | 
|   | 
|                 //修复回收重量  | 
|                 String[] split = orderId.split(",");  | 
|                 double sumAll=0;  | 
|                 for (String s : split) {  | 
|                     if(StrUtil.isNotBlank(s)){  | 
|                         OrderItemInfo orderDetailInfo=new OrderItemInfo();  | 
|                         orderDetailInfo.setOrderId(s);  | 
|                         List<OrderItemInfo> select1 = orderItemInfoMapper.select(orderDetailInfo);  | 
|                         if(CollUtil.isNotEmpty(select1)){  | 
|                             sumAll =sumAll+ select1.stream().mapToDouble(x -> Convert.toDouble(x.getWeight(),Convert.toDouble(Constants.WEIGHT_INIT))).sum();  | 
|                             System.out.println(s);  | 
|                             System.out.println(sumAll);  | 
|                         }  | 
|                     }  | 
|                 }  | 
|   | 
|                 if(sum!=0&sumAll!=0) {  | 
|                     String a=NumberUtil.roundStr(sum,3,RoundingMode.DOWN);  | 
|                     String a1=NumberUtil.roundStr(sumAll,3,RoundingMode.DOWN);  | 
|                     OrderStorageInfo orderStorageInfo1 = new OrderStorageInfo();  | 
|                     orderStorageInfo1.setStorageId(orderStorageInfo.getStorageId());  | 
|                     orderStorageInfo1.setRecycleWeight(a1);  | 
|                     orderStorageInfo1.setStorageWeight(a);  | 
|                     orderStorageInfoMapper.updateByPrimaryKeySelective(orderStorageInfo1);  | 
|                 }  | 
|             }  | 
|         }  | 
|   | 
|         System.out.println("修复完成");  | 
|   | 
|     }  | 
|   | 
|   | 
| }  |