package com.gk.firework.Controller;
|
|
import com.alibaba.fastjson.JSONObject;
|
import com.gk.firework.Controller.Base.BaseController;
|
import com.gk.firework.Domain.DTO.JiangWaiDeadlineReqDTO;
|
import com.gk.firework.Domain.DistrictInfo;
|
import com.gk.firework.Domain.Enterprise;
|
import com.gk.firework.Domain.Exception.BusinessException;
|
import com.gk.firework.Domain.UserInfo;
|
import com.gk.firework.Domain.UserRolesInfo;
|
import com.gk.firework.Domain.Utils.*;
|
import com.gk.firework.Service.*;
|
import io.swagger.annotations.*;
|
import org.apache.catalina.User;
|
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Value;
|
import org.springframework.web.bind.annotation.*;
|
import org.springframework.web.multipart.MultipartFile;
|
|
import java.io.File;
|
import java.io.FileInputStream;
|
import java.io.InputStream;
|
import java.text.SimpleDateFormat;
|
import java.util.*;
|
|
@Api(tags = "用户管理数据接口")
|
@RestController
|
public class UserController extends BaseController {
|
|
@Autowired
|
UserService userService;
|
@Autowired
|
RoleService roleService;
|
@Autowired
|
UserRolesService userRolesService;
|
@Autowired
|
RolePermissionsService rolePermissionsService;
|
@Autowired
|
ExcelExportService excelExportService;
|
@Autowired
|
DistrictService districtService;
|
@Autowired
|
UserRolesService userRolesInfoService;
|
@Autowired
|
EnterpriseService enterpriseService;
|
@Autowired
|
UserDeadlineService userDeadlineService;
|
|
@Value("${filePath}")
|
private String filePath; //配置文件配置的物理保存地址
|
|
@GetMapping("/user")
|
@ApiOperation(value = "获取用户数据",response = Msg.class)
|
@ApiImplicitParams({
|
@ApiImplicitParam(name = "pageIndex",value = "当前页码"),
|
@ApiImplicitParam(name = "pageSize",value = "每页行数"),
|
@ApiImplicitParam(name = "sort",value = "排序规则"),
|
@ApiImplicitParam(name = "order",value = "排序字段"),
|
@ApiImplicitParam(name = "username",value = "用户名"),
|
@ApiImplicitParam(name = "company",value = "单位"),
|
@ApiImplicitParam(name = "department",value = "部门"),
|
@ApiImplicitParam(name = "job",value = "职务"),
|
@ApiImplicitParam(name = "type",value = "用户类型"),
|
@ApiImplicitParam(name = "province",value = "省份"),
|
@ApiImplicitParam(name = "city",value = "城市"),
|
@ApiImplicitParam(name = "area",value = "区县"),
|
@ApiImplicitParam(name = "town",value = "乡镇"),
|
@ApiImplicitParam(name = "community",value = "社区"),
|
})
|
public Msg getUserInfo(@RequestParam(defaultValue = "0") Integer pageIndex, @RequestParam(defaultValue = "10") Integer pageSize, String sort,String order,
|
String username,String company, String department, String job,Byte type,
|
String province, String city, String area, String town, String community){
|
Msg msg = new Msg();
|
msg.setCode("200");
|
msg.setMessage("success");
|
|
PageInfo pageInfo = new PageInfo(pageIndex, pageSize,sort,order);
|
HashMap<String, Object> condition = new HashMap<String, Object>();
|
|
if (StringUtils.isNotBlank(username)) {
|
condition.put("username", username.trim());
|
}
|
|
if (StringUtils.isNotBlank(company)) {
|
condition.put("company", company.trim());
|
}
|
|
if (StringUtils.isNotBlank(department)) {
|
condition.put("department", department.trim());
|
}
|
|
if (StringUtils.isNotBlank(job)){
|
condition.put("job",job.trim());
|
}
|
|
if (type != null){
|
condition.put("type",type);
|
}
|
|
if (StringUtils.isNotBlank(province)){
|
condition.put("province",province.trim());
|
}
|
|
if (StringUtils.isNotBlank(city)){
|
condition.put("city",city.trim());
|
}
|
|
if (StringUtils.isNotBlank(area)){
|
condition.put("area",area.trim());
|
}
|
|
if (StringUtils.isNotBlank(town)){
|
condition.put("town",town.trim());
|
}
|
|
if (StringUtils.isNotBlank(community)){
|
condition.put("community",community.trim());
|
}
|
|
UserInfo userInfo = userService.selectByUser(getUser().getUsername());
|
if (StringUtils.isNotBlank(userInfo.getCompanynumber())){
|
condition.put("username", userInfo.getUsername());
|
}else{
|
condition.put("provinceSee", userInfo.getProvince());
|
condition.put("citySee",userInfo.getCity());
|
condition.put("areaSee",userInfo.getArea());
|
condition.put("townSee",userInfo.getTown());
|
condition.put("communitySee",userInfo.getCommunity());
|
}
|
|
condition.put("iscompany",(byte)0);
|
condition.put("issale",(byte)0);
|
pageInfo.setCondition(condition);
|
userService.selectUserDataGrid(pageInfo);
|
msg.setResult(pageInfo);
|
return msg;
|
}
|
|
@PostMapping("/adduser")
|
@ApiOperation(value = "添加用户数据",response = Msg.class)
|
@ApiImplicitParams({
|
@ApiImplicitParam(name = "username",value = "用户名",required = true),
|
@ApiImplicitParam(name = "password",value = "密码",required = true),
|
@ApiImplicitParam(name = "type",value = "用户类型",required = true),
|
@ApiImplicitParam(name = "email",value = "邮箱"),
|
@ApiImplicitParam(name = "phone",value = "办公电话"),
|
@ApiImplicitParam(name = "mobile",value = "手机号"),
|
@ApiImplicitParam(name = "company",value = "单位"),
|
@ApiImplicitParam(name = "department",value = "部门"),
|
@ApiImplicitParam(name = "job",value = "职务"),
|
@ApiImplicitParam(name = "createdby",value = "创建人"),
|
@ApiImplicitParam(name = "province",value = "省份"),
|
@ApiImplicitParam(name = "city",value = "城市"),
|
@ApiImplicitParam(name = "area",value = "区县"),
|
@ApiImplicitParam(name = "town",value = "乡镇"),
|
@ApiImplicitParam(name = "community",value = "社区"),
|
})
|
public Msg addUserInfo(@RequestBody JSONObject jsonObject){
|
Msg msg = new Msg();
|
msg.setCode("200");
|
msg.setMessage("success");
|
UserInfo userInfo = new UserInfo();
|
userInfo.setUsername(jsonObject.getString("username"));
|
String password = jsonObject.getString("password");
|
String PW_PATTERN = "(?=.*[A-Z])(?=.*[a-z])(?=.*[0-9])(?=.*[~!@#$%^&*_.]).{8,}";
|
if (!password.matches(PW_PATTERN)){
|
msg.setCode("500");
|
msg.setMessage("密码必须8位以上,并且包含大小写字母、数字、特殊符号三种以上");
|
return msg;
|
}else {
|
userInfo.setPassword(Base64Encrypt.encode(password.getBytes()));
|
}
|
String mobile = jsonObject.getString("mobile");
|
if (StringUtils.isNotBlank(mobile) && mobile.length() == 11){
|
userInfo.setMobile(mobile);
|
}else if (StringUtils.isNotBlank(mobile)){
|
msg.setCode("500");
|
msg.setMessage("手机号必须为11位数");
|
return msg;
|
}
|
try {
|
userInfo.setType(jsonObject.getInteger("type"));
|
}catch (Exception e) {
|
msg.setCode("500");
|
msg.setMessage("用户类型必须为数字");
|
return msg;
|
}
|
userInfo.setEmail(jsonObject.getString("email"));
|
userInfo.setPhone(jsonObject.getString("phone"));
|
userInfo.setCompany(jsonObject.getString("company"));
|
userInfo.setDepartment(jsonObject.getString("department"));
|
userInfo.setJob(jsonObject.getString("job"));
|
userInfo.setCreatedby(jsonObject.getString("createdby"));
|
userInfo.setCreateddate(new Date());
|
userInfo.setLastmodifiedby(jsonObject.getString("createdby"));
|
userInfo.setLastmodifieddate(new Date());
|
userInfo.setProvince(jsonObject.getString("province"));
|
userInfo.setCity(jsonObject.getString("city"));
|
userInfo.setArea(jsonObject.getString("area"));
|
userInfo.setTown(jsonObject.getString("town"));
|
userInfo.setCommunity(jsonObject.getString("community"));
|
userInfo.setCode(jsonObject.getString("code"));
|
userInfo.setIsdel((byte)0);
|
userInfo.setIssale((byte)0);
|
UserInfo userInfoExist = userService.selectByUser(userInfo.getUsername());
|
if (null != userInfoExist){
|
msg.setCode("500");
|
msg.setMessage("用户名重复");
|
return msg;
|
}else {
|
userService.save(userInfo);
|
}
|
return msg;
|
}
|
|
@PostMapping("/importUser")
|
@ApiOperation(value = "导入用户数据",response = Msg.class)
|
@ApiImplicitParams({
|
@ApiImplicitParam(name = "file",value = "文件",required = true),
|
@ApiImplicitParam(name = "operator",value = "操作人",required = true),
|
})
|
@ResponseBody
|
public Msg importUser(String operator,MultipartFile file){
|
Msg msg = new Msg();
|
msg.setCode("200");
|
msg.setMessage("success");
|
|
String filesave ="";
|
try {
|
SimpleDateFormat sdf = new SimpleDateFormat( "yyyyMMddHHmmssSSS" );
|
if (file == null)
|
{
|
msg.setCode("404");
|
msg.setMessage("未找到上传文件");
|
return msg;
|
}
|
|
long size = file.getSize();
|
if(0 == size)
|
{
|
msg.setCode("404");
|
msg.setMessage("上传文件大小为空");
|
return msg;
|
}
|
|
if(!FileOptUtils.isDirExists(filePath)){
|
msg.setCode("500");
|
msg.setMessage("发生错误或不为目录");
|
return msg;
|
}
|
|
filesave = filePath + operator + "_" + sdf.format(new Date()) +".xlsx";
|
|
file.transferTo(new File(filesave));
|
InputStream in = new FileInputStream(filesave);
|
String name = file.getOriginalFilename();
|
Boolean isExcel2007 = name.substring(name.lastIndexOf(".") + 1).endsWith("xlsx")? true:false;
|
BooleanReason blret = excelExportService.importUserExcel(in,operator,isExcel2007);
|
if(blret.getValue().equals(false))
|
{
|
msg.setCode("500");
|
msg.setMessage(blret.getResultmsg());
|
return msg;
|
}
|
} catch (Exception e) {
|
e.printStackTrace();
|
msg.setCode("500");
|
msg.setMessage("导入发生错误");
|
return msg;
|
}
|
|
return msg;
|
}
|
|
|
@PostMapping("/importUserCode")
|
@ApiOperation(value = "导入用户数据",response = Msg.class)
|
@ApiImplicitParams({
|
@ApiImplicitParam(name = "file",value = "文件",required = true),
|
@ApiImplicitParam(name = "operator",value = "操作人",required = true),
|
})
|
@ResponseBody
|
public Msg importUserCode(String operator,MultipartFile file){
|
Msg msg = new Msg();
|
msg.setCode("200");
|
msg.setMessage("success");
|
|
String filesave ="";
|
try {
|
SimpleDateFormat sdf = new SimpleDateFormat( "yyyyMMddHHmmssSSS" );
|
if (file == null)
|
{
|
msg.setCode("404");
|
msg.setMessage("未找到上传文件");
|
return msg;
|
}
|
|
long size = file.getSize();
|
if(0 == size)
|
{
|
msg.setCode("404");
|
msg.setMessage("上传文件大小为空");
|
return msg;
|
}
|
|
if(!FileOptUtils.isDirExists(filePath)){
|
msg.setCode("500");
|
msg.setMessage("发生错误或不为目录");
|
return msg;
|
}
|
|
filesave = filePath + operator + "_" + sdf.format(new Date()) +".xlsx";
|
|
file.transferTo(new File(filesave));
|
InputStream in = new FileInputStream(filesave);
|
String name = file.getOriginalFilename();
|
Boolean isExcel2007 = name.substring(name.lastIndexOf(".") + 1).endsWith("xlsx")? true:false;
|
BooleanReason blret = excelExportService.importUserCodeExcel(in,operator,isExcel2007);
|
if(blret.getValue().equals(false))
|
{
|
msg.setCode("500");
|
msg.setMessage(blret.getResultmsg());
|
return msg;
|
}
|
} catch (Exception e) {
|
e.printStackTrace();
|
msg.setCode("500");
|
msg.setMessage("导入发生错误");
|
return msg;
|
}
|
|
return msg;
|
}
|
|
|
@PostMapping("/putuser")
|
@ApiOperation(value = "修改用户数据",response = Msg.class)
|
@ApiImplicitParams({
|
@ApiImplicitParam(name = "id",value = "用户id",required = true),
|
@ApiImplicitParam(name = "username",value = "用户名",required = true),
|
@ApiImplicitParam(name = "password",value = "密码"),
|
@ApiImplicitParam(name = "type",value = "用户类型",required = true),
|
@ApiImplicitParam(name = "email",value = "邮箱"),
|
@ApiImplicitParam(name = "phone",value = "办公电话"),
|
@ApiImplicitParam(name = "mobile",value = "手机号"),
|
@ApiImplicitParam(name = "company",value = "单位"),
|
@ApiImplicitParam(name = "department",value = "部门"),
|
@ApiImplicitParam(name = "job",value = "职务"),
|
@ApiImplicitParam(name = "lastmodifiedby",value = "更新人"),
|
@ApiImplicitParam(name = "province",value = "省份"),
|
@ApiImplicitParam(name = "city",value = "城市"),
|
@ApiImplicitParam(name = "area",value = "区县"),
|
@ApiImplicitParam(name = "town",value = "乡镇"),
|
@ApiImplicitParam(name = "community",value = "社区"),
|
})
|
public Msg putUserInfo(@RequestBody JSONObject jsonObject){
|
Msg msg = new Msg();
|
msg.setCode("200");
|
msg.setMessage("success");
|
Long id = jsonObject.getLong("id");
|
String username = jsonObject.getString("username");
|
List<UserInfo> userList = userService.selectUserInfo(id,username);
|
if (userList.size() > 0){
|
msg.setCode("500");
|
msg.setMessage("用户名重复");
|
return msg;
|
}
|
UserInfo userInfo = new UserInfo();
|
userInfo.setId(jsonObject.getLong("id"));
|
userInfo.setUsername(jsonObject.getString("username"));
|
String password = jsonObject.getString("password");
|
String PW_PATTERN = "(?=.*[A-Z])(?=.*[a-z])(?=.*[0-9])(?=.*[~!@#$%^&*_.]).{8,}";
|
if (StringUtils.isNotBlank(password)&& !password.matches(PW_PATTERN)){
|
msg.setCode("500");
|
msg.setMessage("密码必须8位以上,并且包含大小写字母、数字、特殊符号三种以上");
|
return msg;
|
}else if(StringUtils.isNotBlank(password)){
|
userInfo.setPassword(Base64Encrypt.encode(password.getBytes()));
|
}
|
String mobile = jsonObject.getString("mobile");
|
if (StringUtils.isNotBlank(mobile) && mobile.length() == 11){
|
userInfo.setMobile(mobile);
|
}else if (StringUtils.isNotBlank(mobile)){
|
msg.setCode("500");
|
msg.setMessage("手机号必须为11位数");
|
return msg;
|
}
|
try {
|
userInfo.setType(jsonObject.getInteger("type"));
|
}catch (Exception e) {
|
msg.setCode("500");
|
msg.setMessage("用户类型必须为数字");
|
return msg;
|
}
|
userInfo.setEmail(jsonObject.getString("email"));
|
userInfo.setPhone(jsonObject.getString("phone"));
|
userInfo.setCompany(jsonObject.getString("company"));
|
userInfo.setDepartment(jsonObject.getString("department"));
|
userInfo.setJob(jsonObject.getString("job"));
|
userInfo.setCreatedby(jsonObject.getString("lastmodifiedby"));
|
userInfo.setCreateddate(new Date());
|
userInfo.setLastmodifiedby(jsonObject.getString("lastmodifiedby"));
|
userInfo.setLastmodifieddate(new Date());
|
userInfo.setProvince(jsonObject.getString("province"));
|
userInfo.setCity(jsonObject.getString("city"));
|
userInfo.setArea(jsonObject.getString("area"));
|
userInfo.setTown(jsonObject.getString("town"));
|
userInfo.setCommunity(jsonObject.getString("community"));
|
userInfo.setCode(jsonObject.getString("code"));
|
userService.updateById(userInfo);
|
// 如果修改为新疆企业 会重置 截止日期
|
String province = jsonObject.getString("province");
|
// 不修改原代码 无论怎样 是新疆 就重置
|
UserInfo company = userService.getById(userInfo.getId());
|
if (company.getCompanyid() != null) {
|
userService.updateDeadline2NullByComapnyId(company.getCompanyid());
|
}
|
return msg;
|
|
}
|
|
|
@PostMapping("/jiangWai/deadline/set")
|
public Msg updateJinagWaiDeadline(@RequestBody JiangWaiDeadlineReqDTO reqDTO) {
|
userService.updateDeadline(reqDTO,getUser());
|
return success();
|
}
|
|
|
@PostMapping("/userroles")
|
@ApiOperation(value = "修改用户角色",response = Msg.class)
|
@ApiImplicitParams({
|
@ApiImplicitParam(name = "id",value = "用户id",required = true),
|
@ApiImplicitParam(name = "roles",value = "用户名",required = true),
|
|
})
|
public Msg updateUserRole(@RequestBody JSONObject jsonObject){
|
Msg msg = new Msg();
|
msg.setCode("200");
|
msg.setMessage("success");
|
Long userid = jsonObject.getLong("id");
|
String roles = jsonObject.getString("roles");
|
if (StringUtils.isNotBlank(roles)){
|
userRolesInfoService.deleteByUserId(userid);
|
roles = roles.replace("[","").replace("]","");
|
List<String> list = StringUtils.toList(roles);
|
for (String role : list){
|
UserRolesInfo userRolesInfo = new UserRolesInfo();
|
userRolesInfo.setUserid(userid);
|
userRolesInfo.setRoleid(Long.parseLong(role.trim()));
|
userRolesInfoService.save(userRolesInfo);
|
}
|
}
|
return msg;
|
|
}
|
|
@PostMapping("/deluser")
|
@ApiOperation(value = "删除用户数据", notes = "删除用户数据", response = Msg.class)
|
@ApiImplicitParams({
|
@ApiImplicitParam(paramType="query",name = "id",value = "id",required = true),
|
@ApiImplicitParam(paramType="body",name = "lastmodifiedby",value = "更新人"),
|
|
})
|
public Msg delUserInfo(@ApiParam(value = "id,lastmodifiedby")
|
@RequestBody JSONObject jsonObject){
|
Msg msg = new Msg();
|
msg.setCode("200");
|
msg.setMessage("success");
|
UserInfo userInfo = new UserInfo();
|
userInfo.setId(jsonObject.getLong("id"));
|
userInfo.setLastmodifiedby(jsonObject.getString("lastmodifiedby"));
|
userInfo.setLastmodifieddate(new Date());
|
userInfo.setIsdel((byte)1);
|
userService.updateById(userInfo);
|
return msg;
|
}
|
|
@PostMapping("/importDistrict")
|
@ApiOperation(value = "导入省市数据",response = Msg.class)
|
@ApiImplicitParams({
|
@ApiImplicitParam(name = "file",value = "文件",required = true),
|
@ApiImplicitParam(name = "operator",value = "操作人",required = true),
|
})
|
@ResponseBody
|
public Msg importDistrict(String operator,MultipartFile file){
|
Msg msg = new Msg();
|
msg.setCode("200");
|
msg.setMessage("success");
|
|
String filesave ="";
|
try {
|
SimpleDateFormat sdf = new SimpleDateFormat( "yyyyMMddHHmmssSSS" );
|
if (file == null)
|
{
|
msg.setCode("404");
|
msg.setMessage("未找到上传文件");
|
return msg;
|
}
|
|
long size = file.getSize();
|
if(0 == size)
|
{
|
msg.setCode("404");
|
msg.setMessage("上传文件大小为空");
|
return msg;
|
}
|
|
if(!FileOptUtils.isDirExists(filePath)){
|
msg.setCode("500");
|
msg.setMessage("发生错误或不为目录");
|
return msg;
|
}
|
|
filesave = filePath + operator + "_" + sdf.format(new Date()) +".xlsx";
|
|
file.transferTo(new File(filesave));
|
InputStream in = new FileInputStream(filesave);
|
String name = file.getOriginalFilename();
|
Boolean isExcel2007 = name.substring(name.lastIndexOf(".") + 1).endsWith("xlsx")? true:false;
|
BooleanReason blret = excelExportService.importDistrictExcel(in,operator,isExcel2007);
|
if(blret.getValue().equals(false))
|
{
|
msg.setCode("500");
|
msg.setMessage(blret.getResultmsg());
|
return msg;
|
}
|
} catch (Exception e) {
|
e.printStackTrace();
|
msg.setCode("500");
|
msg.setMessage("导入发生错误");
|
return msg;
|
}
|
|
return msg;
|
}
|
|
@GetMapping("/district")
|
@ApiOperation(value = "获取省市区数据",response = Msg.class)
|
@ApiImplicitParams({
|
@ApiImplicitParam(name = "type",value = "类型"),
|
@ApiImplicitParam(name = "parentname",value = "上级名称"),
|
@ApiImplicitParam(name = "parenttype",value = "上级类型"),
|
})
|
public Msg getdistrictInfo(String type,String parentname,String parenttype){
|
Msg msg = new Msg();
|
msg.setCode("200");
|
msg.setMessage("success");
|
List<DistrictInfo> districtInfoList = new ArrayList<> ();
|
if (parenttype.equals("0")){
|
districtInfoList = districtService.selectDistrictInfo(type, parenttype);
|
}else {
|
districtInfoList = districtService.selectDistrictByName(type,parentname,parenttype);
|
}
|
msg.setResult(districtInfoList);
|
return msg;
|
}
|
|
@GetMapping("/districtByName")
|
@ApiOperation(value = "获取省市区数据",response = Msg.class)
|
@ApiImplicitParams({
|
@ApiImplicitParam(name = "province",value = "省份"),
|
@ApiImplicitParam(name = "city",value = "城市"),
|
@ApiImplicitParam(name = "area",value = "区县"),
|
@ApiImplicitParam(name = "town",value = "街道"),
|
@ApiImplicitParam(name = "community",value = "社区"),
|
})
|
public Msg getDistrictByName(String province,String city,String area,String town,String community){
|
Msg msg = new Msg();
|
msg.setCode("200");
|
msg.setMessage("success");
|
|
if (StringUtils.isBlank(province)){
|
List<DistrictInfo> provinceList = districtService.selectDistrictInfo("1", "0");
|
Map<String,Object> map = new HashMap<> ();
|
map.put("provinceList",provinceList);
|
msg.setResult(map);
|
}else if (StringUtils.isBlank(city)){
|
List<DistrictInfo> provinceList = districtService.selectDistrictInfo("1", "0");
|
DistrictInfo provinceInfo = districtService.selectInfoByName(province,(byte)1);
|
List<DistrictInfo> cityList = districtService.selectDistrictInfo("2", provinceInfo.getCode());
|
Map<String,Object> map = new HashMap<> ();
|
map.put("provinceList",provinceList);
|
map.put("cityList",cityList);
|
msg.setResult(map);
|
}else if (StringUtils.isBlank(area)){
|
List<DistrictInfo> provinceList = districtService.selectDistrictInfo("1", "0");
|
DistrictInfo provinceInfo = districtService.selectInfoByName(province,(byte)1);
|
List<DistrictInfo> cityList = districtService.selectDistrictInfo("2", provinceInfo.getCode());
|
DistrictInfo cityInfo = districtService.selectInfoByName(city,(byte)2);
|
List<DistrictInfo> areaList = districtService.selectDistrictInfo("3", cityInfo.getCode());
|
Map<String,Object> map = new HashMap<> ();
|
map.put("provinceList",provinceList);
|
map.put("cityList",cityList);
|
map.put("areaList",areaList);
|
msg.setResult(map);
|
}else if (StringUtils.isBlank(town)){
|
List<DistrictInfo> provinceList = districtService.selectDistrictInfo("1", "0");
|
DistrictInfo provinceInfo = districtService.selectInfoByName(province,(byte)1);
|
List<DistrictInfo> cityList = districtService.selectDistrictInfo("2", provinceInfo.getCode());
|
DistrictInfo cityInfo = districtService.selectInfoByName(city,(byte)2);
|
List<DistrictInfo> areaList = districtService.selectDistrictInfo("3", cityInfo.getCode());
|
DistrictInfo areaInfo = districtService.selectInfoByName(area,(byte)3);
|
List<DistrictInfo> townList = districtService.selectDistrictInfo("4", areaInfo.getCode());
|
|
Map<String,Object> map = new HashMap<> ();
|
map.put("provinceList",provinceList);
|
map.put("cityList",cityList);
|
map.put("areaList",areaList);
|
map.put("townList",townList);
|
msg.setResult(map);
|
}else{
|
List<DistrictInfo> provinceList = districtService.selectDistrictInfo("1", "0");
|
DistrictInfo provinceInfo = districtService.selectInfoByName(province,(byte)1);
|
List<DistrictInfo> cityList = districtService.selectDistrictInfo("2", provinceInfo.getCode());
|
DistrictInfo cityInfo = districtService.selectInfoByName(city,(byte)2);
|
List<DistrictInfo> areaList = districtService.selectDistrictInfo("3", cityInfo.getCode());
|
DistrictInfo areaInfo = districtService.selectInfoByName(area,(byte)3);
|
List<DistrictInfo> townList = districtService.selectDistrictInfo("4", areaInfo.getCode());
|
DistrictInfo townInfo = districtService.selectInfoByName(town,(byte)4);
|
List<DistrictInfo> communityList = districtService.selectDistrictInfo("5", townInfo.getCode());
|
|
Map<String,Object> map = new HashMap<> ();
|
map.put("provinceList",provinceList);
|
map.put("cityList",cityList);
|
map.put("areaList",areaList);
|
map.put("townList",townList);
|
map.put("communityList",communityList);
|
msg.setResult(map);
|
}
|
return msg;
|
}
|
|
@GetMapping("/enterpriseUser")
|
@ApiOperation(value = "获取企业用户数据",response = Msg.class)
|
@ApiImplicitParams({
|
@ApiImplicitParam(name = "pageIndex",value = "当前页码"),
|
@ApiImplicitParam(name = "pageSize",value = "每页行数"),
|
@ApiImplicitParam(name = "sort",value = "排序规则"),
|
@ApiImplicitParam(name = "order",value = "排序字段"),
|
@ApiImplicitParam(name = "username",value = "用户名"),
|
@ApiImplicitParam(name = "company",value = "单位"),
|
@ApiImplicitParam(name = "department",value = "部门"),
|
@ApiImplicitParam(name = "job",value = "职务"),
|
@ApiImplicitParam(name = "type",value = "用户类型"),
|
@ApiImplicitParam(name = "province",value = "省份"),
|
@ApiImplicitParam(name = "city",value = "城市"),
|
@ApiImplicitParam(name = "area",value = "区县"),
|
@ApiImplicitParam(name = "town",value = "乡镇"),
|
@ApiImplicitParam(name = "community",value = "社区"),
|
})
|
public Msg getEnterpriseUserInfo(@RequestParam(defaultValue = "0") Integer pageIndex, @RequestParam(defaultValue = "10") Integer pageSize, String sort,String order,
|
String username,String company, String department, String job,Byte type, String province, String city, String area, String town, String community){
|
Msg msg = new Msg();
|
msg.setCode("200");
|
msg.setMessage("success");
|
|
PageInfo pageInfo = new PageInfo(pageIndex, pageSize,sort,order);
|
HashMap<String, Object> condition = new HashMap<String, Object>();
|
|
if (StringUtils.isNotBlank(username)) {
|
condition.put("username", username.trim());
|
}
|
|
if (StringUtils.isNotBlank(company)) {
|
condition.put("company", company.trim());
|
}
|
|
if (StringUtils.isNotBlank(department)) {
|
condition.put("department", department.trim());
|
}
|
|
if (StringUtils.isNotBlank(job)){
|
condition.put("job",job.trim());
|
|
}
|
if (type != null){
|
condition.put("type",type);
|
}
|
UserInfo userInfo = userService.getById(getUser().getId());
|
if (userInfo.getCompanyid() != null){
|
condition.put("companyid", userInfo.getCompanyid());
|
}else if (userInfo.getType() == 3){
|
condition.put("province",userInfo.getProvince());
|
condition.put("city",userInfo.getCity());
|
condition.put("area",userInfo.getArea());
|
condition.put("town",userInfo.getTown());
|
condition.put("community",userInfo.getCommunity());
|
}
|
|
if (StringUtils.isNotBlank(province) && condition.get("province") == null) {
|
condition.put("province", province.trim());
|
if (StringUtils.isNotBlank(city)) {
|
condition.put("city", city.trim());
|
}
|
|
if (StringUtils.isNotBlank(area)) {
|
condition.put("area", area.trim());
|
}
|
|
if (StringUtils.isNotBlank(town)) {
|
condition.put("town", town.trim());
|
}
|
|
if (StringUtils.isNotBlank(community)) {
|
condition.put("community", community.trim());
|
}
|
}
|
condition.put("iscompany",(byte)1);
|
condition.put("issale",(byte)0);
|
pageInfo.setCondition(condition);
|
userService.selectUserDataGrid(pageInfo);
|
msg.setResult(pageInfo);
|
return msg;
|
}
|
|
@GetMapping("/saleUser")
|
@ApiOperation(value = "获取终端机用户数据",response = Msg.class)
|
@ApiImplicitParams({
|
@ApiImplicitParam(name = "pageIndex",value = "当前页码"),
|
@ApiImplicitParam(name = "pageSize",value = "每页行数"),
|
@ApiImplicitParam(name = "sort",value = "排序规则"),
|
@ApiImplicitParam(name = "order",value = "排序字段"),
|
@ApiImplicitParam(name = "username",value = "用户名"),
|
@ApiImplicitParam(name = "company",value = "单位"),
|
@ApiImplicitParam(name = "department",value = "部门"),
|
@ApiImplicitParam(name = "job",value = "职务"),
|
@ApiImplicitParam(name = "type",value = "用户类型"),
|
@ApiImplicitParam(name = "province",value = "省份"),
|
@ApiImplicitParam(name = "city",value = "城市"),
|
@ApiImplicitParam(name = "area",value = "区县"),
|
@ApiImplicitParam(name = "town",value = "乡镇"),
|
@ApiImplicitParam(name = "community",value = "社区"),
|
})
|
public Msg getSaleUserInfo(@RequestParam(defaultValue = "0") Integer pageIndex, @RequestParam(defaultValue = "10") Integer pageSize, String sort,String order,
|
String username,String company, String department, String job,Byte type, String province, String city, String area, String town, String community,
|
String safetySuperVision){
|
Msg msg = new Msg();
|
msg.setCode("200");
|
msg.setMessage("success");
|
|
PageInfo pageInfo = new PageInfo(pageIndex, pageSize,sort,order);
|
HashMap<String, Object> condition = new HashMap<String, Object>();
|
|
if (StringUtils.isNotBlank(username)) {
|
condition.put("username", username.trim());
|
}
|
|
if (StringUtils.isNotBlank(company)) {
|
condition.put("company", company.trim());
|
}
|
|
if (StringUtils.isNotBlank(department)) {
|
condition.put("department", department.trim());
|
}
|
|
if (StringUtils.isNotBlank(job)){
|
condition.put("job",job.trim());
|
|
}
|
if (type != null){
|
condition.put("type",type);
|
}
|
UserInfo userInfo = userService.getById(getUser().getId());
|
if (userInfo.getCompanyid() != null){
|
condition.put("companyid", userInfo.getCompanyid());
|
}else if (userInfo.getType() == 3){
|
condition.put("province",userInfo.getProvince());
|
condition.put("city",userInfo.getCity());
|
condition.put("area",userInfo.getArea());
|
condition.put("town",userInfo.getTown());
|
condition.put("community",userInfo.getCommunity());
|
}
|
|
if (StringUtils.isNotBlank(province) && condition.get("province") == null) {
|
condition.put("province", province.trim());
|
if (StringUtils.isNotBlank(city)) {
|
condition.put("city", city.trim());
|
}
|
|
if (StringUtils.isNotBlank(area)) {
|
condition.put("area", area.trim());
|
}
|
|
if (StringUtils.isNotBlank(town)) {
|
condition.put("town", town.trim());
|
}
|
|
if (StringUtils.isNotBlank(community)) {
|
condition.put("community", community.trim());
|
}
|
}
|
condition.put("safetysupervision",safetySuperVision);
|
condition.put("iscompany",(byte)1);
|
condition.put("issale",(byte)1);
|
pageInfo.setCondition(condition);
|
userService.selectUserDataGrid(pageInfo);
|
msg.setResult(pageInfo);
|
return msg;
|
}
|
|
}
|