|
|
|
@ -46,10 +46,10 @@ public class CaseUsersServiceImpl implements CaseUsersService {
|
|
|
|
|
@Resource
|
|
|
|
|
private CaseAreaMapper caseAreaMapper;
|
|
|
|
|
|
|
|
|
|
@Value("${export.path}")
|
|
|
|
|
private String exportPath;
|
|
|
|
|
@Value("${export.url}")
|
|
|
|
|
private String exportUrl;
|
|
|
|
|
// @Value("${export.path}")
|
|
|
|
|
// private String exportPath;
|
|
|
|
|
// @Value("${export.url}")
|
|
|
|
|
// private String exportUrl;
|
|
|
|
|
private String uploadPath;
|
|
|
|
|
private String fileName;
|
|
|
|
|
|
|
|
|
@ -76,6 +76,16 @@ public class CaseUsersServiceImpl implements CaseUsersService {
|
|
|
|
|
return caseUser;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public CaseUsers findByUserNo(JSONObject jsonObject) {
|
|
|
|
|
|
|
|
|
|
CaseUsers caseUsers = new CaseUsers();
|
|
|
|
|
String userNo = jsonObject.getString("userNo");
|
|
|
|
|
caseUsers.setUserNo(userNo);
|
|
|
|
|
caseUsers = caseUsersMapper.selectOne(caseUsers);
|
|
|
|
|
return caseUsers;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public CaseUsers findByUserNo(String userNo) {
|
|
|
|
|
|
|
|
|
|
CaseUsers caseUser = new CaseUsers();
|
|
|
|
@ -685,151 +695,151 @@ public class CaseUsersServiceImpl implements CaseUsersService {
|
|
|
|
|
* @param params
|
|
|
|
|
* @return
|
|
|
|
|
*/
|
|
|
|
|
public String export(JSONObject params) {
|
|
|
|
|
|
|
|
|
|
Integer state = params.getInteger("state");
|
|
|
|
|
String key = params.getString("key");
|
|
|
|
|
Integer companyId = params.getInteger("companyId");
|
|
|
|
|
Integer storeId = params.getInteger("storeId");
|
|
|
|
|
Condition condition = new Condition(CaseUsers.class);
|
|
|
|
|
Example.Criteria criteria = condition.createCriteria();
|
|
|
|
|
criteria.andCondition("state=" + state);
|
|
|
|
|
|
|
|
|
|
if (null != companyId) {
|
|
|
|
|
|
|
|
|
|
criteria.andCondition("company_id=" + companyId);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (null != storeId) {
|
|
|
|
|
|
|
|
|
|
criteria.andCondition("store_id=" + storeId);
|
|
|
|
|
}
|
|
|
|
|
if (null != key) {
|
|
|
|
|
|
|
|
|
|
key = com.bsd.cases.util.StringUtils.generateLike(key);
|
|
|
|
|
criteria.andLike("userName", key).orLike("userNo", key);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
List<CaseUsers> usersList = caseUsersMapper.selectByExample(condition);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
String[] title = {"员工姓名", "员工号", "电话", "店铺编号", "店铺编号", "店铺编号", "店铺编号", "用户类型"};
|
|
|
|
|
//创建HSSF工作薄
|
|
|
|
|
HSSFWorkbook workbook = new HSSFWorkbook();
|
|
|
|
|
//创建一个Sheet页
|
|
|
|
|
HSSFSheet sheet = workbook.createSheet();
|
|
|
|
|
//创建第一行(一般是表头)
|
|
|
|
|
HSSFRow row0 = sheet.createRow(0);
|
|
|
|
|
//创建列
|
|
|
|
|
HSSFCell cell = null;
|
|
|
|
|
|
|
|
|
|
// 设置字体
|
|
|
|
|
HSSFFont font = workbook.createFont();
|
|
|
|
|
font.setFontName("黑体"); //字体
|
|
|
|
|
font.setFontHeightInPoints((short) 12);
|
|
|
|
|
// 设置单元格类型
|
|
|
|
|
HSSFCellStyle cellStyle = workbook.createCellStyle();
|
|
|
|
|
cellStyle.setFont(font);
|
|
|
|
|
cellStyle.setAlignment(HorizontalAlignment.CENTER); //水平布局:居中
|
|
|
|
|
cellStyle.setWrapText(true);
|
|
|
|
|
|
|
|
|
|
//设置表头
|
|
|
|
|
for (int i = 0; i < title.length; i++) {
|
|
|
|
|
|
|
|
|
|
cell = row0.createCell(i);
|
|
|
|
|
cell.setCellStyle(cellStyle);
|
|
|
|
|
cell.setCellValue(title[i]);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//填充20行数据
|
|
|
|
|
for (int i = 0; i < usersList.size(); i++) {
|
|
|
|
|
|
|
|
|
|
CaseUsers users = usersList.get(i);
|
|
|
|
|
HSSFRow row = sheet.createRow(i + 1);
|
|
|
|
|
HSSFCell cell1 = row.createCell(0);
|
|
|
|
|
cell1.setCellStyle(cellStyle);
|
|
|
|
|
cell1.setCellValue(i + 1);
|
|
|
|
|
|
|
|
|
|
HSSFCell cell2 = row.createCell(1);
|
|
|
|
|
cell2.setCellStyle(cellStyle);
|
|
|
|
|
cell2.setCellValue(users.getUserName());
|
|
|
|
|
|
|
|
|
|
HSSFCell cell3 = row.createCell(2);
|
|
|
|
|
cell3.setCellStyle(cellStyle);
|
|
|
|
|
cell3.setCellValue(users.getUserNo());
|
|
|
|
|
|
|
|
|
|
HSSFCell cell4 = row.createCell(3);
|
|
|
|
|
cell4.setCellStyle(cellStyle);
|
|
|
|
|
cell4.setCellValue(users.getStoreCode());
|
|
|
|
|
|
|
|
|
|
HSSFCell cell5 = row.createCell(4);
|
|
|
|
|
cell5.setCellStyle(cellStyle);
|
|
|
|
|
cell5.setCellValue(users.getStoreName());
|
|
|
|
|
|
|
|
|
|
HSSFCell cell6 = row.createCell(5);
|
|
|
|
|
cell6.setCellStyle(cellStyle);
|
|
|
|
|
cell6.setCellValue(users.getCompanyCode());
|
|
|
|
|
|
|
|
|
|
HSSFCell cell7 = row.createCell(6);
|
|
|
|
|
cell7.setCellStyle(cellStyle);
|
|
|
|
|
cell7.setCellValue(users.getCompanyName());
|
|
|
|
|
|
|
|
|
|
HSSFCell cell8 = row.createCell(7);
|
|
|
|
|
cell8.setCellStyle(cellStyle);
|
|
|
|
|
|
|
|
|
|
int role = users.getRole();
|
|
|
|
|
|
|
|
|
|
switch (role) {
|
|
|
|
|
|
|
|
|
|
case Constants.MOFANG_USER:
|
|
|
|
|
|
|
|
|
|
cell8.setCellValue("店铺用户");
|
|
|
|
|
break;
|
|
|
|
|
case Constants.WECHAT_USER:
|
|
|
|
|
|
|
|
|
|
cell8.setCellValue("微信用户");
|
|
|
|
|
break;
|
|
|
|
|
case Constants.HEAD_USER:
|
|
|
|
|
|
|
|
|
|
cell8.setCellValue("总部用户");
|
|
|
|
|
break;
|
|
|
|
|
case Constants.COMPANY_USER:
|
|
|
|
|
|
|
|
|
|
cell8.setCellValue("店铺用户");
|
|
|
|
|
break;
|
|
|
|
|
default:
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
sheet.autoSizeColumn((short) 0);
|
|
|
|
|
sheet.autoSizeColumn((short) 1);
|
|
|
|
|
sheet.autoSizeColumn((short) 2);
|
|
|
|
|
sheet.autoSizeColumn((short) 3);
|
|
|
|
|
sheet.autoSizeColumn((short) 4);
|
|
|
|
|
sheet.autoSizeColumn((short) 5);
|
|
|
|
|
sheet.autoSizeColumn((short) 6);
|
|
|
|
|
sheet.autoSizeColumn((short) 7);
|
|
|
|
|
|
|
|
|
|
String fileName = System.currentTimeMillis() + ".xls";
|
|
|
|
|
String absPath = exportPath + fileName;
|
|
|
|
|
String url = exportUrl + fileName;
|
|
|
|
|
//保存到本地
|
|
|
|
|
File file = new File(absPath);
|
|
|
|
|
FileOutputStream outputStream = null;
|
|
|
|
|
try {
|
|
|
|
|
outputStream = new FileOutputStream(file);
|
|
|
|
|
workbook.write(outputStream);
|
|
|
|
|
outputStream.flush();
|
|
|
|
|
outputStream.close();
|
|
|
|
|
} catch (FileNotFoundException e) {
|
|
|
|
|
e.printStackTrace();
|
|
|
|
|
} catch (IOException e) {
|
|
|
|
|
e.printStackTrace();
|
|
|
|
|
}
|
|
|
|
|
//将Excel写入输出流中
|
|
|
|
|
return url;
|
|
|
|
|
}
|
|
|
|
|
// public String export(JSONObject params) {
|
|
|
|
|
//
|
|
|
|
|
// Integer state = params.getInteger("state");
|
|
|
|
|
// String key = params.getString("key");
|
|
|
|
|
// Integer companyId = params.getInteger("companyId");
|
|
|
|
|
// Integer storeId = params.getInteger("storeId");
|
|
|
|
|
// Condition condition = new Condition(CaseUsers.class);
|
|
|
|
|
// Example.Criteria criteria = condition.createCriteria();
|
|
|
|
|
// criteria.andCondition("state=" + state);
|
|
|
|
|
//
|
|
|
|
|
// if (null != companyId) {
|
|
|
|
|
//
|
|
|
|
|
// criteria.andCondition("company_id=" + companyId);
|
|
|
|
|
// }
|
|
|
|
|
//
|
|
|
|
|
// if (null != storeId) {
|
|
|
|
|
//
|
|
|
|
|
// criteria.andCondition("store_id=" + storeId);
|
|
|
|
|
// }
|
|
|
|
|
// if (null != key) {
|
|
|
|
|
//
|
|
|
|
|
// key = com.bsd.cases.util.StringUtils.generateLike(key);
|
|
|
|
|
// criteria.andLike("userName", key).orLike("userNo", key);
|
|
|
|
|
// }
|
|
|
|
|
//
|
|
|
|
|
// List<CaseUsers> usersList = caseUsersMapper.selectByExample(condition);
|
|
|
|
|
//
|
|
|
|
|
//
|
|
|
|
|
// String[] title = {"员工姓名", "员工号", "电话", "店铺编号", "店铺编号", "店铺编号", "店铺编号", "用户类型"};
|
|
|
|
|
// //创建HSSF工作薄
|
|
|
|
|
// HSSFWorkbook workbook = new HSSFWorkbook();
|
|
|
|
|
// //创建一个Sheet页
|
|
|
|
|
// HSSFSheet sheet = workbook.createSheet();
|
|
|
|
|
// //创建第一行(一般是表头)
|
|
|
|
|
// HSSFRow row0 = sheet.createRow(0);
|
|
|
|
|
// //创建列
|
|
|
|
|
// HSSFCell cell = null;
|
|
|
|
|
//
|
|
|
|
|
// // 设置字体
|
|
|
|
|
// HSSFFont font = workbook.createFont();
|
|
|
|
|
// font.setFontName("黑体"); //字体
|
|
|
|
|
// font.setFontHeightInPoints((short) 12);
|
|
|
|
|
// // 设置单元格类型
|
|
|
|
|
// HSSFCellStyle cellStyle = workbook.createCellStyle();
|
|
|
|
|
// cellStyle.setFont(font);
|
|
|
|
|
// cellStyle.setAlignment(HorizontalAlignment.CENTER); //水平布局:居中
|
|
|
|
|
// cellStyle.setWrapText(true);
|
|
|
|
|
//
|
|
|
|
|
// //设置表头
|
|
|
|
|
// for (int i = 0; i < title.length; i++) {
|
|
|
|
|
//
|
|
|
|
|
// cell = row0.createCell(i);
|
|
|
|
|
// cell.setCellStyle(cellStyle);
|
|
|
|
|
// cell.setCellValue(title[i]);
|
|
|
|
|
// }
|
|
|
|
|
//
|
|
|
|
|
// //填充20行数据
|
|
|
|
|
// for (int i = 0; i < usersList.size(); i++) {
|
|
|
|
|
//
|
|
|
|
|
// CaseUsers users = usersList.get(i);
|
|
|
|
|
// HSSFRow row = sheet.createRow(i + 1);
|
|
|
|
|
// HSSFCell cell1 = row.createCell(0);
|
|
|
|
|
// cell1.setCellStyle(cellStyle);
|
|
|
|
|
// cell1.setCellValue(i + 1);
|
|
|
|
|
//
|
|
|
|
|
// HSSFCell cell2 = row.createCell(1);
|
|
|
|
|
// cell2.setCellStyle(cellStyle);
|
|
|
|
|
// cell2.setCellValue(users.getUserName());
|
|
|
|
|
//
|
|
|
|
|
// HSSFCell cell3 = row.createCell(2);
|
|
|
|
|
// cell3.setCellStyle(cellStyle);
|
|
|
|
|
// cell3.setCellValue(users.getUserNo());
|
|
|
|
|
//
|
|
|
|
|
// HSSFCell cell4 = row.createCell(3);
|
|
|
|
|
// cell4.setCellStyle(cellStyle);
|
|
|
|
|
// cell4.setCellValue(users.getStoreCode());
|
|
|
|
|
//
|
|
|
|
|
// HSSFCell cell5 = row.createCell(4);
|
|
|
|
|
// cell5.setCellStyle(cellStyle);
|
|
|
|
|
// cell5.setCellValue(users.getStoreName());
|
|
|
|
|
//
|
|
|
|
|
// HSSFCell cell6 = row.createCell(5);
|
|
|
|
|
// cell6.setCellStyle(cellStyle);
|
|
|
|
|
// cell6.setCellValue(users.getCompanyCode());
|
|
|
|
|
//
|
|
|
|
|
// HSSFCell cell7 = row.createCell(6);
|
|
|
|
|
// cell7.setCellStyle(cellStyle);
|
|
|
|
|
// cell7.setCellValue(users.getCompanyName());
|
|
|
|
|
//
|
|
|
|
|
// HSSFCell cell8 = row.createCell(7);
|
|
|
|
|
// cell8.setCellStyle(cellStyle);
|
|
|
|
|
//
|
|
|
|
|
// int role = users.getRole();
|
|
|
|
|
//
|
|
|
|
|
// switch (role) {
|
|
|
|
|
//
|
|
|
|
|
// case Constants.MOFANG_USER:
|
|
|
|
|
//
|
|
|
|
|
// cell8.setCellValue("店铺用户");
|
|
|
|
|
// break;
|
|
|
|
|
// case Constants.WECHAT_USER:
|
|
|
|
|
//
|
|
|
|
|
// cell8.setCellValue("微信用户");
|
|
|
|
|
// break;
|
|
|
|
|
// case Constants.HEAD_USER:
|
|
|
|
|
//
|
|
|
|
|
// cell8.setCellValue("总部用户");
|
|
|
|
|
// break;
|
|
|
|
|
// case Constants.COMPANY_USER:
|
|
|
|
|
//
|
|
|
|
|
// cell8.setCellValue("店铺用户");
|
|
|
|
|
// break;
|
|
|
|
|
// default:
|
|
|
|
|
// break;
|
|
|
|
|
// }
|
|
|
|
|
// }
|
|
|
|
|
//
|
|
|
|
|
// sheet.autoSizeColumn((short) 0);
|
|
|
|
|
// sheet.autoSizeColumn((short) 1);
|
|
|
|
|
// sheet.autoSizeColumn((short) 2);
|
|
|
|
|
// sheet.autoSizeColumn((short) 3);
|
|
|
|
|
// sheet.autoSizeColumn((short) 4);
|
|
|
|
|
// sheet.autoSizeColumn((short) 5);
|
|
|
|
|
// sheet.autoSizeColumn((short) 6);
|
|
|
|
|
// sheet.autoSizeColumn((short) 7);
|
|
|
|
|
//
|
|
|
|
|
// String fileName = System.currentTimeMillis() + ".xls";
|
|
|
|
|
// String absPath = exportPath + fileName;
|
|
|
|
|
// String url = exportUrl + fileName;
|
|
|
|
|
// //保存到本地
|
|
|
|
|
// File file = new File(absPath);
|
|
|
|
|
// FileOutputStream outputStream = null;
|
|
|
|
|
// try {
|
|
|
|
|
// outputStream = new FileOutputStream(file);
|
|
|
|
|
// workbook.write(outputStream);
|
|
|
|
|
// outputStream.flush();
|
|
|
|
|
// outputStream.close();
|
|
|
|
|
// } catch (FileNotFoundException e) {
|
|
|
|
|
// e.printStackTrace();
|
|
|
|
|
// } catch (IOException e) {
|
|
|
|
|
// e.printStackTrace();
|
|
|
|
|
// }
|
|
|
|
|
// //将Excel写入输出流中
|
|
|
|
|
// return url;
|
|
|
|
|
// }
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|