Commit 5b150b96 authored by 周健威's avatar 周健威

Merge remote-tracking branch 'origin/dev' into dev

parents 690fd145 b961e366
...@@ -10,4 +10,5 @@ ace-modules/ace-tool/src/main/resources/application-dev.yml ...@@ -10,4 +10,5 @@ ace-modules/ace-tool/src/main/resources/application-dev.yml
src/main/test/** src/main/test/**
logs/** logs/**
xx-order/xx-order-server/logs/** xx-order/xx-order-server/logs/**
*.log
...@@ -46,6 +46,10 @@ public class UserBusinessBiz { ...@@ -46,6 +46,10 @@ public class UserBusinessBiz {
List<AppUserRelation> teamMemberBos = memberPage.getData(); List<AppUserRelation> teamMemberBos = memberPage.getData();
if (CollectionUtils.isEmpty(teamMemberBos)) { if (CollectionUtils.isEmpty(teamMemberBos)) {
userTeamMemberVo.setPageNum(pageNo);
userTeamMemberVo.setPageSize(pageSize);
userTeamMemberVo.setTotalIncome(new BigDecimal(0));
userTeamMemberVo.setUserTeamMemberBos(Collections.EMPTY_LIST);
return userTeamMemberVo; return userTeamMemberVo;
} }
......
...@@ -107,7 +107,7 @@ ...@@ -107,7 +107,7 @@
l.id = m.user_id l.id = m.user_id
left join left join
`app_user_position` as aup `app_user_position` as aup
on d.position_id= aup.level on aup.id = d.position_id
where l.isdel = 0 where l.isdel = 0
<if test="mobile !=null and mobile !='' "> <if test="mobile !=null and mobile !='' ">
and l.username like CONCAT('%',#{mobile},'%') and l.username like CONCAT('%',#{mobile},'%')
......
package com.xxfc.platform.app.entity.dto;
import com.github.wxiaoqi.security.common.vo.PageParam;
import lombok.Data;
/**
* @author libin
* @version 1.0
* @description
* @data 2019/8/9 16:25
*/
@Data
public class BuyVehicleFormFindDTO extends PageParam {
private Long startTime;
private Long endTime;
private Integer companyId;
private Integer areaId;
private Integer status;
}
...@@ -59,14 +59,14 @@ public class BuyVehicleFormPageVo { ...@@ -59,14 +59,14 @@ public class BuyVehicleFormPageVo {
private Integer status; private Integer status;
/** /**
* 申请 * 负责
*/ */
private String applyName; private String leaderName;
/** /**
* 申请人电话 * 负责人电话
*/ */
private String applyPhone; private String leaderPhone;
} }
package com.xxfc.platform.app.biz; package com.xxfc.platform.app.biz;
import com.github.wxiaoqi.security.admin.entity.AppUserLogin;
import com.github.wxiaoqi.security.admin.feign.UserFeign;
import com.github.wxiaoqi.security.common.vo.PageDataVO; import com.github.wxiaoqi.security.common.vo.PageDataVO;
import com.xxfc.platform.app.entity.dto.BuyVehicleFormFindDTO; import com.xxfc.platform.app.entity.dto.BuyVehicleFormFindDTO;
import com.xxfc.platform.app.entity.vo.BuyVehicleFormPageVo; import com.xxfc.platform.app.entity.vo.BuyVehicleFormPageVo;
import com.xxfc.platform.vehicle.feign.VehicleFeign; import com.xxfc.platform.vehicle.feign.VehicleFeign;
import com.xxfc.platform.vehicle.pojo.vo.BranComanyLeaderVo;
import org.apache.commons.collections.CollectionUtils; import org.apache.commons.collections.CollectionUtils;
import org.springframework.beans.BeanUtils; import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
...@@ -13,10 +16,7 @@ import com.xxfc.platform.app.entity.BuyVehicleForm; ...@@ -13,10 +16,7 @@ import com.xxfc.platform.app.entity.BuyVehicleForm;
import com.xxfc.platform.app.mapper.BuyVehicleFormMapper; import com.xxfc.platform.app.mapper.BuyVehicleFormMapper;
import com.github.wxiaoqi.security.common.biz.BaseBiz; import com.github.wxiaoqi.security.common.biz.BaseBiz;
import java.util.ArrayList; import java.util.*;
import java.util.Collections;
import java.util.List;
import java.util.Objects;
import java.util.stream.Collectors; import java.util.stream.Collectors;
/** /**
...@@ -32,6 +32,9 @@ public class BuyVehicleFormBiz extends BaseBiz<BuyVehicleFormMapper, BuyVehicleF ...@@ -32,6 +32,9 @@ public class BuyVehicleFormBiz extends BaseBiz<BuyVehicleFormMapper, BuyVehicleF
@Autowired @Autowired
private VehicleFeign vehicleFeign; private VehicleFeign vehicleFeign;
@Autowired
private UserFeign userFeign;
public PageDataVO<BuyVehicleFormPageVo> findBuyVehicleFormWithPage(BuyVehicleFormFindDTO buyVehicleFormFindDTO) { public PageDataVO<BuyVehicleFormPageVo> findBuyVehicleFormWithPage(BuyVehicleFormFindDTO buyVehicleFormFindDTO) {
PageDataVO<BuyVehicleFormPageVo> buyVehicleFormPage = new PageDataVO<>(); PageDataVO<BuyVehicleFormPageVo> buyVehicleFormPage = new PageDataVO<>();
List<Integer> cpyIds = new ArrayList<>(); List<Integer> cpyIds = new ArrayList<>();
...@@ -43,6 +46,8 @@ public class BuyVehicleFormBiz extends BaseBiz<BuyVehicleFormMapper, BuyVehicleF ...@@ -43,6 +46,8 @@ public class BuyVehicleFormBiz extends BaseBiz<BuyVehicleFormMapper, BuyVehicleF
boolean flag = companyIds.contains(buyVehicleFormFindDTO.getCompanyId()); boolean flag = companyIds.contains(buyVehicleFormFindDTO.getCompanyId());
if (flag){ if (flag){
cpyIds.add(buyVehicleFormFindDTO.getCompanyId()); cpyIds.add(buyVehicleFormFindDTO.getCompanyId());
}else {
return buyVehicleFormPage;
} }
} }
}else { }else {
...@@ -57,13 +62,20 @@ public class BuyVehicleFormBiz extends BaseBiz<BuyVehicleFormMapper, BuyVehicleF ...@@ -57,13 +62,20 @@ public class BuyVehicleFormBiz extends BaseBiz<BuyVehicleFormMapper, BuyVehicleF
return buyVehicleFormPage; return buyVehicleFormPage;
} }
List<Integer> userIds = data.stream().map(BuyVehicleForm::getUserId).collect(Collectors.toList()); List<Integer> companyIds = data.stream().map(BuyVehicleForm::getCompanyId).collect(Collectors.toList());
Map<Integer, BranComanyLeaderVo> comanyLeaderVoMap = vehicleFeign.findCompanyLeaderMapByIds(companyIds);
List<BuyVehicleFormPageVo> buyVehicleFormPageVoList = new ArrayList<>(); List<BuyVehicleFormPageVo> buyVehicleFormPageVoList = new ArrayList<>();
BuyVehicleFormPageVo buyVehicleFormPageVo; BuyVehicleFormPageVo buyVehicleFormPageVo;
for (BuyVehicleForm buyVehicleForm : data) { for (BuyVehicleForm buyVehicleForm : data) {
buyVehicleFormPageVo = new BuyVehicleFormPageVo(); buyVehicleFormPageVo = new BuyVehicleFormPageVo();
BeanUtils.copyProperties(buyVehicleForm,buyVehicleFormPageVo); BeanUtils.copyProperties(buyVehicleForm,buyVehicleFormPageVo);
if(comanyLeaderVoMap!=null) {
BranComanyLeaderVo branComanyLeaderVo = comanyLeaderVoMap.get(buyVehicleForm.getCompanyId());
buyVehicleFormPageVo.setLeaderName(branComanyLeaderVo == null ? "" : branComanyLeaderVo.getLeader());
buyVehicleFormPageVo.setLeaderPhone(branComanyLeaderVo == null ? "" : branComanyLeaderVo.getPhone());
buyVehicleFormPageVo.setCompanyName(branComanyLeaderVo == null ? "" : branComanyLeaderVo.getName());
}
buyVehicleFormPageVoList.add(buyVehicleFormPageVo); buyVehicleFormPageVoList.add(buyVehicleFormPageVo);
} }
...@@ -74,4 +86,8 @@ public class BuyVehicleFormBiz extends BaseBiz<BuyVehicleFormMapper, BuyVehicleF ...@@ -74,4 +86,8 @@ public class BuyVehicleFormBiz extends BaseBiz<BuyVehicleFormMapper, BuyVehicleF
buyVehicleFormPage.setTotalCount(pageDataVO.getTotalCount()); buyVehicleFormPage.setTotalCount(pageDataVO.getTotalCount());
return buyVehicleFormPage; return buyVehicleFormPage;
} }
public void processApplyStatusById(Integer id) {
mapper.updateApplyStatusById(id);
}
} }
\ No newline at end of file
...@@ -17,4 +17,6 @@ import java.util.List; ...@@ -17,4 +17,6 @@ import java.util.List;
public interface BuyVehicleFormMapper extends Mapper<BuyVehicleForm> { public interface BuyVehicleFormMapper extends Mapper<BuyVehicleForm> {
List<BuyVehicleForm> findBuyVehicleForms(@Param("bvf") BuyVehicleFormFindDTO buyVehicleFormFindDTO,@Param("companyIds") List<Integer> companyIds); List<BuyVehicleForm> findBuyVehicleForms(@Param("bvf") BuyVehicleFormFindDTO buyVehicleFormFindDTO,@Param("companyIds") List<Integer> companyIds);
void updateApplyStatusById(Integer id);
} }
...@@ -6,10 +6,7 @@ import com.xxfc.platform.app.biz.BuyVehicleFormBiz; ...@@ -6,10 +6,7 @@ import com.xxfc.platform.app.biz.BuyVehicleFormBiz;
import com.xxfc.platform.app.entity.dto.BuyVehicleFormFindDTO; import com.xxfc.platform.app.entity.dto.BuyVehicleFormFindDTO;
import com.xxfc.platform.app.entity.vo.BuyVehicleFormPageVo; import com.xxfc.platform.app.entity.vo.BuyVehicleFormPageVo;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PathVariable; import org.springframework.web.bind.annotation.*;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
/** /**
* @author libin * @author libin
...@@ -18,20 +15,21 @@ import org.springframework.web.bind.annotation.RestController; ...@@ -18,20 +15,21 @@ import org.springframework.web.bind.annotation.RestController;
* @data 2019/8/9 13:55 * @data 2019/8/9 13:55
*/ */
@RestController @RestController
@RequestMapping("buy_vehicle") @RequestMapping("admin/buy_vehicle")
public class BuyVehicleFormAdminController { public class BuyVehicleFormAdminController {
@Autowired @Autowired
private BuyVehicleFormBiz vehicleFormBiz; private BuyVehicleFormBiz vehicleFormBiz;
@PostMapping("/page") @PostMapping("/page")
public ObjectRestResponse<BuyVehicleFormPageVo> findBuyVehicleFormWithPage(BuyVehicleFormFindDTO buyVehicleFormFindDTO){ public ObjectRestResponse<BuyVehicleFormPageVo> findBuyVehicleFormWithPage(@RequestBody BuyVehicleFormFindDTO buyVehicleFormFindDTO){
PageDataVO<BuyVehicleFormPageVo> pageDataVO = vehicleFormBiz.findBuyVehicleFormWithPage(buyVehicleFormFindDTO); PageDataVO<BuyVehicleFormPageVo> pageDataVO = vehicleFormBiz.findBuyVehicleFormWithPage(buyVehicleFormFindDTO);
return ObjectRestResponse.succ(pageDataVO); return ObjectRestResponse.succ(pageDataVO);
} }
@PostMapping("/status/id") @PostMapping("/status/{id}")
public ObjectRestResponse<Void> processApplyById(@PathVariable("id") Integer id){ public ObjectRestResponse<Void> processApplyById(@PathVariable(value = "id") Integer id){
vehicleFormBiz.processApplyStatusById(id);
return ObjectRestResponse.succ();
} }
} }
...@@ -21,21 +21,29 @@ ...@@ -21,21 +21,29 @@
<select id="findBuyVehicleForms" resultMap="buyVehicleFormMap"> <select id="findBuyVehicleForms" resultMap="buyVehicleFormMap">
select * from `buy_vehicle_form` where 1=1 select * from `buy_vehicle_form` where 1=1
<if test="bvf.startTime != null and bvf.endTime !=null"> <if test="bvf.startTime != null and bvf.endTime !=null">
and `bookTime` between #{bvf.startTime} and #{bvf.endTime} and `book_time` between #{bvf.startTime} and #{bvf.endTime}
</if> </if>
<if test="bvf.startTime != null and bvf.endTime == null"> <if test="bvf.startTime != null and bvf.endTime == null">
and `bookTime`>= #{bvf.startTime} and `book_time`>= #{bvf.startTime}
</if> </if>
<if test="bvf.endTime != null and bvf.startTime == null"> <if test="bvf.endTime != null and bvf.startTime == null">
and <![CDATA[ `bookTime`<= #{bvf.endTime}]]> and <![CDATA[ `book_time`<= #{bvf.endTime}]]>
</if> </if>
<if test="bvf.areaId != null || bvf.companyId !=null"> <if test="bvf.areaId != null || bvf.companyId !=null">
<if test="companyIds != null and companyIds.size() != 0"> <if test="companyIds != null and companyIds.size() != 0">
and `company_id` in and `company_id` in
<foreach collection="companyIds" item="companyId" separator=","> <foreach collection="companyIds" item="cpyId" close=")" open="(" separator=",">
#{companyId} #{cpyId}
</foreach> </foreach>
</if> </if>
</if> </if>
<if test="bvf.status != null">
and `status`=#{bvf.status}
</if>
order by `book_time` desc
</select> </select>
<update id="updateApplyStatusById">
update `buy_vehicle_form` set `status`=1 where `id`=#{id}
</update>
</mapper> </mapper>
\ No newline at end of file
...@@ -6,6 +6,7 @@ import com.xxfc.platform.vehicle.common.RestResponse; ...@@ -6,6 +6,7 @@ import com.xxfc.platform.vehicle.common.RestResponse;
import com.xxfc.platform.vehicle.entity.*; import com.xxfc.platform.vehicle.entity.*;
import com.xxfc.platform.vehicle.pojo.*; import com.xxfc.platform.vehicle.pojo.*;
import com.xxfc.platform.vehicle.pojo.vo.AccompanyingItemVo; import com.xxfc.platform.vehicle.pojo.vo.AccompanyingItemVo;
import com.xxfc.platform.vehicle.pojo.vo.BranComanyLeaderVo;
import org.springframework.cloud.openfeign.FeignClient; import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.web.bind.annotation.*; import org.springframework.web.bind.annotation.*;
...@@ -117,6 +118,9 @@ public interface VehicleFeign { ...@@ -117,6 +118,9 @@ public interface VehicleFeign {
@GetMapping("/accompanyingItem/app/unauth/items") @GetMapping("/accompanyingItem/app/unauth/items")
public RestResponse<List<AccompanyingItemVo>> listAccompanyingItem(); public RestResponse<List<AccompanyingItemVo>> listAccompanyingItem();
@GetMapping("/findByAreaId") @GetMapping("/branchCompany/findByAreaId")
List<Integer> findCompanyIdsByAreaId(@RequestParam(value = "areaId") Integer areaId); List<Integer> findCompanyIdsByAreaId(@RequestParam(value = "areaId") Integer areaId);
@GetMapping("/branchCompany/company")
Map<Integer, BranComanyLeaderVo> findCompanyLeaderMapByIds(@RequestParam(value = "companyIds") List<Integer> companyIds);
} }
package com.xxfc.platform.vehicle.pojo.vo;
import lombok.Data;
/**
* @author libin
* @version 1.0
* @description
* @data 2019/8/9 18:44
*/
@Data
public class BranComanyLeaderVo {
/**
* 负责人
*/
private String leader;
/**
* 负责人联系电话
*/
private String phone;
/**
* 公司名
*/
private String name;
}
...@@ -20,6 +20,7 @@ import com.xxfc.platform.vehicle.mapper.BranchCompanyMapper; ...@@ -20,6 +20,7 @@ import com.xxfc.platform.vehicle.mapper.BranchCompanyMapper;
import com.xxfc.platform.vehicle.pojo.BranchCompanyVo; import com.xxfc.platform.vehicle.pojo.BranchCompanyVo;
import com.xxfc.platform.vehicle.pojo.CompanyDetail; import com.xxfc.platform.vehicle.pojo.CompanyDetail;
import com.xxfc.platform.vehicle.pojo.CompanySearchDTO; import com.xxfc.platform.vehicle.pojo.CompanySearchDTO;
import com.xxfc.platform.vehicle.pojo.vo.BranComanyLeaderVo;
import com.xxfc.platform.vehicle.util.excel.ExcelImport; import com.xxfc.platform.vehicle.util.excel.ExcelImport;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import org.apache.commons.collections.CollectionUtils; import org.apache.commons.collections.CollectionUtils;
...@@ -331,4 +332,17 @@ public class BranchCompanyBiz extends BaseBiz<BranchCompanyMapper, BranchCompany ...@@ -331,4 +332,17 @@ public class BranchCompanyBiz extends BaseBiz<BranchCompanyMapper, BranchCompany
public List<Integer> selectCompanyIdsByAreaId(Integer areaId) { public List<Integer> selectCompanyIdsByAreaId(Integer areaId) {
return mapper.findCompanyIdsByAreaId(areaId); return mapper.findCompanyIdsByAreaId(areaId);
} }
public Map<Integer, BranComanyLeaderVo> findCompanyLeaderMapByIds(List<Integer> companyIds) {
Map<Integer,BranComanyLeaderVo> companyIdAndLeaderMap = new HashMap<>(companyIds.size());
List<BranchCompany> branchCompanies = mapper.selectByIdList(companyIds);
if (CollectionUtils.isEmpty(branchCompanies)){
return companyIdAndLeaderMap;
}
return branchCompanies.stream().collect(Collectors.toMap(BranchCompany::getId,branchCompany -> {
BranComanyLeaderVo branComanyLeaderVo = new BranComanyLeaderVo();
BeanUtils.copyProperties(branchCompany,branComanyLeaderVo);
return branComanyLeaderVo;
}));
}
} }
...@@ -2,12 +2,13 @@ package com.xxfc.platform.vehicle.mapper; ...@@ -2,12 +2,13 @@ package com.xxfc.platform.vehicle.mapper;
import com.xxfc.platform.vehicle.entity.BranchCompany; import com.xxfc.platform.vehicle.entity.BranchCompany;
import org.apache.ibatis.annotations.Param; import org.apache.ibatis.annotations.Param;
import tk.mybatis.mapper.additional.idlist.SelectByIdListMapper;
import tk.mybatis.mapper.common.Mapper; import tk.mybatis.mapper.common.Mapper;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
public interface BranchCompanyMapper extends Mapper<BranchCompany> { public interface BranchCompanyMapper extends Mapper<BranchCompany>, SelectByIdListMapper<BranchCompany,Integer> {
List<BranchCompany> search(@Param("lon") String lon, @Param("lat") String lat, @Param("addrCity") Integer addrCity); List<BranchCompany> search(@Param("lon") String lon, @Param("lat") String lat, @Param("addrCity") Integer addrCity);
List<BranchCompany> selectByZoneId(Map<String, Object> param); List<BranchCompany> selectByZoneId(Map<String, Object> param);
......
...@@ -16,6 +16,7 @@ import com.xxfc.platform.vehicle.pojo.BranchCompanyVo; ...@@ -16,6 +16,7 @@ import com.xxfc.platform.vehicle.pojo.BranchCompanyVo;
import com.xxfc.platform.vehicle.pojo.CompanyDetail; import com.xxfc.platform.vehicle.pojo.CompanyDetail;
import com.xxfc.platform.vehicle.pojo.CompanySearchDTO; import com.xxfc.platform.vehicle.pojo.CompanySearchDTO;
import com.github.wxiaoqi.security.common.vo.PageDataVO; import com.github.wxiaoqi.security.common.vo.PageDataVO;
import com.xxfc.platform.vehicle.pojo.vo.BranComanyLeaderVo;
import io.swagger.annotations.Api; import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation; import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
...@@ -27,6 +28,7 @@ import org.springframework.web.multipart.MultipartFile; ...@@ -27,6 +28,7 @@ import org.springframework.web.multipart.MultipartFile;
import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletRequest;
import java.util.List; import java.util.List;
import java.util.Map;
@RestController @RestController
@RequestMapping("/branchCompany") @RequestMapping("/branchCompany")
...@@ -169,4 +171,9 @@ public class BranchCompanyController extends BaseController<BranchCompanyBiz> { ...@@ -169,4 +171,9 @@ public class BranchCompanyController extends BaseController<BranchCompanyBiz> {
public List<Integer> findCompanyIdsByAreaId(@RequestParam(value = "areaId") Integer areaId){ public List<Integer> findCompanyIdsByAreaId(@RequestParam(value = "areaId") Integer areaId){
return baseBiz.selectCompanyIdsByAreaId(areaId); return baseBiz.selectCompanyIdsByAreaId(areaId);
} }
@GetMapping("/company")
Map<Integer, BranComanyLeaderVo> findCompanyLeaderMapByIds(@RequestParam("companyIds") List<Integer> companyIds){
return baseBiz.findCompanyLeaderMapByIds(companyIds);
}
} }
package com.xxfc.platform.vehicle;
import org.joda.time.DateTime;
import org.joda.time.format.DateTimeFormat;
import org.junit.Test;
import java.lang.reflect.Array;
import java.util.Arrays;
import java.util.List;
public class ListTest {
@Test
public void ListTest(){
List<Object> objects = Arrays.asList();
DateTime startDay= DateTime.parse("2019-07-30 00:00:00", DateTimeFormat.forPattern("yyyy-MM-dd HH:mm:ss"));
System.out.println(startDay);
}
}
package com.xxfc.platform.vehicle;
import cn.hutool.core.comparator.PinyinComparator;
import cn.hutool.core.date.DateUnit;
import cn.hutool.core.date.DateUtil;
import cn.hutool.core.io.FileUtil;
import cn.hutool.core.io.file.FileWriter;
import cn.hutool.core.util.PinyinUtil;
import cn.hutool.core.util.StrUtil;
import cn.hutool.json.JSONUtil;
import com.ace.cache.annotation.Cache;
import com.alibaba.fastjson.JSONObject;
import com.github.stuxuhai.jpinyin.PinyinHelper;
import com.github.wxiaoqi.security.common.msg.TableResultResponse;
import com.github.wxiaoqi.security.common.util.Query;
import com.google.common.collect.Sets;
import com.mysql.cj.conf.RuntimeProperty;
import com.xxfc.platform.vehicle.VehicleApplication;
import com.xxfc.platform.vehicle.biz.SysRegionBiz;
import com.xxfc.platform.vehicle.constant.RedisKey;
import com.xxfc.platform.vehicle.entity.SysRegion;
import lombok.Builder;
import lombok.Data;
import lombok.Getter;
import lombok.Setter;
import org.joda.time.DateTime;
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.data.redis.core.RedisTemplate;
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
import java.io.PrintStream;
import java.util.*;
@RunWith(SpringJUnit4ClassRunner.class)
@SpringBootTest(classes={VehicleApplication.class})
public class RegionTest {
@Autowired
private RedisTemplate customRedisTemplate;
@Autowired
private SysRegionBiz sysRegionBiz;
// public static final String TEST_REDIS_KEY ="redis:{1}";
private final String TEST_REDIS_KEY ="redis:{1}";
@Data
public class Title{
String title;
List<String> lists;
}
@Data
public class City{
List<Title> city;
}
@Data
public class NewData{
Long id;
String name;
String lat;
String lon;
}
@Data
public class NewTitle{
String title;
List<NewData> lists;
}
@Data
public class NewCity{
List<NewTitle> city;
}
@Test
public void test() throws Exception {
String jsonstr = "{\"city\":[{\"title\":\"A\",\"lists\":[\"阿坝\",\"阿拉善\",\"阿里\",\"安康\",\"安庆\",\"鞍山\",\"安顺\",\"安阳\",\"澳门\"]},{\"title\":\"B\",\"lists\":[\"北京\",\"白银\",\"保定\",\"宝鸡\",\"保山\",\"包头\",\"巴中\",\"北海\",\"蚌埠\",\"本溪\",\"毕节\",\"滨州\",\"百色\",\"亳州\"]},{\"title\":\"C\",\"lists\":[\"重庆\",\"成都\",\"长沙\",\"长春\",\"沧州\",\"常德\",\"昌都\",\"长治\",\"常州\",\"巢湖\",\"潮州\",\"承德\",\"郴州\",\"赤峰\",\"池州\",\"崇左\",\"楚雄\",\"滁州\",\"朝阳\"]},{\"title\":\"D\",\"lists\":[\"大连\",\"东莞\",\"大理\",\"丹东\",\"大庆\",\"大同\",\"大兴安岭\",\"德宏\",\"德阳\",\"德州\",\"定西\",\"迪庆\",\"东营\"]},{\"title\":\"E\",\"lists\":[\"鄂尔多斯\",\"恩施\",\"鄂州\"]},{\"title\":\"F\",\"lists\":[\"福州\",\"防城港\",\"佛山\",\"抚顺\",\"抚州\",\"阜新\",\"阜阳\"]},{\"title\":\"G\",\"lists\":[\"广州\",\"桂林\",\"贵阳\",\"甘南\",\"赣州\",\"甘孜\",\"广安\",\"广元\",\"贵港\",\"果洛\"]},{\"title\":\"H\",\"lists\":[\"杭州\",\"哈尔滨\",\"合肥\",\"海口\",\"呼和浩特\",\"海北\",\"海东\",\"海南\",\"海西\",\"邯郸\",\"汉中\",\"鹤壁\",\"河池\",\"鹤岗\",\"黑河\",\"衡水\",\"衡阳\",\"河源\",\"贺州\",\"红河\",\"淮安\",\"淮北\",\"怀化\",\"淮南\",\"黄冈\",\"黄南\",\"黄山\",\"黄石\",\"惠州\",\"葫芦岛\",\"呼伦贝尔\",\"湖州\",\"菏泽\"]},{\"title\":\"J\",\"lists\":[\"济南\",\"佳木斯\",\"吉安\",\"江门\",\"焦作\",\"嘉兴\",\"嘉峪关\",\"揭阳\",\"吉林\",\"金昌\",\"晋城\",\"景德镇\",\"荆门\",\"荆州\",\"金华\",\"济宁\",\"晋中\",\"锦州\",\"九江\",\"酒泉\"]},{\"title\":\"K\",\"lists\":[\"昆明\",\"开封\"]},{\"title\":\"L\",\"lists\":[\"兰州\",\"拉萨\",\"来宾\",\"莱芜\",\"廊坊\",\"乐山\",\"凉山\",\"连云港\",\"聊城\",\"辽阳\",\"辽源\",\"丽江\",\"临沧\",\"临汾\",\"临夏\",\"临沂\",\"林芝\",\"丽水\",\"六安\",\"六盘水\",\"柳州\",\"陇南\",\"龙岩\",\"娄底\",\"漯河\",\"洛阳\",\"泸州\",\"吕梁\"]},{\"title\":\"M\",\"lists\":[\"马鞍山\",\"茂名\",\"眉山\",\"梅州\",\"绵阳\",\"牡丹江\"]},{\"title\":\"N\",\"lists\":[\"南京\",\"南昌\",\"南宁\",\"宁波\",\"南充\",\"南平\",\"南通\",\"南阳\",\"那曲\",\"内江\",\"宁德\",\"怒江\"]},{\"title\":\"P\",\"lists\":[\"盘锦\",\"攀枝花\",\"平顶山\",\"平凉\",\"萍乡\",\"莆田\",\"濮阳\"]},{\"title\":\"Q\",\"lists\":[\"青岛\",\"黔东南\",\"黔南\",\"黔西南\",\"庆阳\",\"清远\",\"秦皇岛\",\"钦州\",\"齐齐哈尔\",\"泉州\",\"曲靖\",\"衢州\"]},{\"title\":\"R\",\"lists\":[\"日喀则\",\"日照\"]},{\"title\":\"S\",\"lists\":[\"上海\",\"深圳\",\"苏州\",\"沈阳\",\"石家庄\",\"三门峡\",\"三明\",\"三亚\",\"商洛\",\"商丘\",\"上饶\",\"山南\",\"汕头\",\"汕尾\",\"韶关\",\"绍兴\",\"邵阳\",\"十堰\",\"朔州\",\"四平\",\"绥化\",\"遂宁\",\"随州\",\"宿迁\",\"宿州\"]},{\"title\":\"T\",\"lists\":[\"天津\",\"太原\",\"泰安\",\"泰州\",\"台州\",\"唐山\",\"天水\",\"铁岭\",\"铜川\",\"通化\",\"通辽\",\"铜陵\",\"铜仁\",\"台湾\"]},{\"title\":\"W\",\"lists\":[\"武汉\",\"乌鲁木齐\",\"无锡\",\"威海\",\"潍坊\",\"文山\",\"温州\",\"乌海\",\"芜湖\",\"乌兰察布\",\"武威\",\"梧州\"]},{\"title\":\"X\",\"lists\":[\"厦门\",\"西安\",\"西宁\",\"襄阳\",\"湘潭\",\"湘西\",\"咸宁\",\"咸阳\",\"孝感\",\"邢台\",\"新乡\",\"信阳\",\"新余\",\"忻州\",\"西双版纳\",\"宣城\",\"许昌\",\"徐州\",\"香港\",\"锡林郭勒\",\"兴安\"]},{\"title\":\"Y\",\"lists\":[\"银川\",\"雅安\",\"延安\",\"延边\",\"盐城\",\"阳江\",\"阳泉\",\"扬州\",\"烟台\",\"宜宾\",\"宜昌\",\"宜春\",\"营口\",\"益阳\",\"永州\",\"岳阳\",\"榆林\",\"运城\",\"云浮\",\"玉树\",\"玉溪\",\"玉林\"]},{\"title\":\"Z\",\"lists\":[\"杂多县\",\"赞皇县\",\"枣强县\",\"枣阳市\",\"枣庄\",\"泽库县\",\"曾都区\",\"泽普县\",\"泽州县\",\"札达县\",\"扎赉特旗\",\"扎兰屯市\",\"扎鲁特旗\",\"扎囊县\",\"张北县\",\"张店区\",\"章贡区\",\"张家港\",\"张家界\",\"张家口\",\"漳平市\",\"漳浦县\",\"章丘市\",\"樟树市\",\"张湾区\",\"彰武县\",\"漳县\",\"张掖\",\"漳州\",\"长子县\",\"湛河区\",\"湛江\",\"站前区\",\"沾益县\",\"诏安县\",\"召陵区\",\"昭平县\",\"肇庆\",\"昭通\",\"赵县\",\"昭阳区\",\"招远市\",\"肇源县\",\"肇州县\",\"柞水县\",\"柘城县\",\"浙江\",\"镇安县\",\"振安区\",\"镇巴县\",\"正安县\",\"正定县\",\"正蓝旗\",\"正宁县\",\"蒸湘区\",\"正镶白旗\",\"正阳县\",\"郑州\",\"镇海区\",\"镇江\",\"浈江区\",\"镇康县\",\"镇赉县\",\"镇平县\",\"振兴区\",\"镇雄县\",\"镇原县\",\"志丹县\",\"治多县\",\"芝罘区\",\"枝江市\",\"芷江侗族自治县\",\"织金县\",\"中方县\",\"中江县\",\"钟楼区\",\"中牟县\",\"中宁县\",\"中山\",\"中山区\",\"钟山区\",\"钟山县\",\"中卫\",\"钟祥市\",\"中阳县\",\"中原区\",\"周村区\",\"周口\",\"周宁县\",\"舟曲县\",\"舟山\",\"周至县\",\"庄河市\",\"诸城市\",\"珠海\",\"珠晖区\",\"诸暨市\",\"驻马店\",\"准格尔旗\",\"涿鹿县\",\"卓尼\",\"涿州市\",\"卓资县\",\"珠山区\",\"竹山县\",\"竹溪县\",\"株洲\",\"株洲县\",\"淄博\",\"子长县\",\"淄川区\",\"自贡\",\"秭归县\",\"紫金县\",\"自流井区\",\"资溪县\",\"资兴市\",\"资阳\"]}]}";
//City city = JSONObject.parseObject
City city = JSONUtil.toBean(jsonstr, City.class);
NewCity newCity = new NewCity();
newCity.setCity(new ArrayList<NewTitle>());
for(Title title : city.getCity()) {
NewTitle newTitle = new NewTitle();
newTitle.setTitle(title.getTitle());
newTitle.setLists(new ArrayList<NewData>());
for(String str : title.getLists()) {
TableResultResponse<SysRegion> sysRegionTableResultResponse = sysRegionBiz.selectByQuery(new Query(new HashMap<String, Object>(){{
put("name", str);
}}));
NewData newData = new NewData(){{
setId(sysRegionTableResultResponse.getData().getRows().get(0).getId());
setName(sysRegionTableResultResponse.getData().getRows().get(0).getName());
}};
// builder()
// .id(sysRegionTableResultResponse.getData().getRows().get(0).getId()).name(sysRegionTableResultResponse.getData().getRows().get(0).getName()).build();
newTitle.getLists().add(newData);
}
newCity.getCity().add(newTitle);
}
//
// List<SysRegion> sysRegions = sysRegionBiz.selectCity();
// String str = new String();
// str += "{ \n\"city\": [";
// for(int i = 1;i<=26;i++) {
// str += "\n{ \"title\": \""+(char)(64+i)+"\", \n";
// str += "\"lists\":[\n";
// Boolean flag = false;
// for(SysRegion sysRegion : sysRegions) {
// if(PinyinHelper.getShortPinyin(sysRegion.getName()).substring(0,1).equals(String.valueOf((char)(96+i)))){
// //(sysRegion.getName()))
// String name = sysRegion.getName();
// if("直辖县级".equals(name)) {
// //获得父级
// SysRegion sysRegionP = sysRegionBiz.selectOne(SysRegion.builder().id(sysRegion.getParentId()).build());
// name = sysRegionP.getName();
// }
// str += "{\"id\":"+sysRegion.getId()+", \"name\":\""+name+"\"},\n";
// flag = true;
// }
// }
// if(flag) {
// str = StrUtil.sub(str, 0, str.length() - 2);
// }
// str += "]";
// str += "},\n";
// }
// str = StrUtil.sub(str, 0, str.length() - 2);
// str += "] \n }";
FileWriter writer = new FileWriter("D://"+ DateUtil.currentSeconds()+ "test.properties");
writer.write(JSONUtil.toJsonStr(newCity));
System.out.println("test");
}
// @Test
// public void test1() {
// int i = DateTime.now().getMinuteOfDay() / 5;
// System.out.println("DateTime.now().getMinuteOfDay() / 5++++++++++++"+i);
// String redisLockKey = RedisKey.SYS_REGION_REFRESH_LOCK +i;//同一日每5分钟只刷新一次
// System.out.println("redisLockKey++++++++++++++++"+redisLockKey);
// String s = String.valueOf(DateTime.now().getMillis());
// System.out.println("s++++++++++++++++++"+s);
// Boolean suc = customRedisTemplate.opsForValue().setIfAbsent(redisLockKey, s);
// Boolean test1 = customRedisTemplate.opsForValue().setIfAbsent("1", "2");
// Boolean test2 = customRedisTemplate.opsForValue().setIfAbsent("1", "3");
// System.out.println("test1///////////////////////////////"+test1);
// System.out.println("test2///////////////////////////////"+test2);
// System.out.println("suc++++++++++++++++++++"+suc);
// }
//
// @Test
// public void testRedis() {
// SysRegion sysRegion = getSysRegion(1);
// System.out.println("sysRegion+++++++++"+sysRegion);
// System.out.println("TEST_REDIS_KEY+++++++++++" + TEST_REDIS_KEY);
// }
//
// @Cache(key = TEST_REDIS_KEY)
// private SysRegion getSysRegion(int id){
// SysRegion sysRegion = sysRegionBiz.selectById(2);
// return sysRegion;
// }
@Test
public void testStream(){
List<Integer> integers = Arrays.asList(1, 3, 5, 7, 9,9);
HashSet<Integer> objects = new HashSet<>();
objects.addAll(integers);
System.out.println(objects);
System.out.println("获取最小值");
Optional<Integer> min = objects.parallelStream().min(Integer::compareTo);
if (min.isPresent()) {
System.out.println(min.get());
}
System.out.println("获取最大");
Optional<Integer> max = integers.parallelStream().max(Integer::compareTo);
if (max.isPresent()) {
System.out.println(max.get());
}
System.out.println("排序");
integers.stream().sorted().forEach(elem -> System.out.println(elem));
System.out.println("筛选");
integers.parallelStream().filter(e ->e>1).filter(e -> e<9).forEach(e -> System.out.println(e));
System.out.println("list的总和为");
integers.stream().reduce((a,b) -> a+b).ifPresent(System.out::println);
}
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment