Commit b826ece5 authored by liuchao's avatar liuchao

no message

parent 3c59d26c
package com.qiankun.controller;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.io.UnsupportedEncodingException;
import java.net.URLEncoder;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.HashMap;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
import java.util.ResourceBundle;
import java.util.Set;
......@@ -10,23 +17,42 @@ import java.util.Set;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import com.qiankun.utils.JwtTokenUtil;
import com.qiankun.utils.UserUtils;
import org.apache.commons.lang.StringUtils;
import org.apache.poi.hssf.usermodel.HSSFSheet;
import org.apache.poi.ss.usermodel.BorderStyle;
import org.apache.poi.ss.usermodel.CellStyle;
import org.apache.poi.ss.usermodel.IndexedColors;
import org.apache.poi.ss.usermodel.PaperSize;
import org.apache.poi.ss.util.CellRangeAddress;
import org.apache.poi.xssf.usermodel.XSSFCell;
import org.apache.poi.xssf.usermodel.XSSFCellStyle;
import org.apache.poi.xssf.usermodel.XSSFFont;
import org.apache.poi.xssf.usermodel.XSSFPrintSetup;
import org.apache.poi.xssf.usermodel.XSSFRow;
import org.apache.poi.xssf.usermodel.XSSFSheet;
import org.apache.poi.xssf.usermodel.XSSFWorkbook;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.multipart.MultipartFile;
import org.springframework.web.servlet.ModelAndView;
import com.qiankun.annotation.Auth;
import com.qiankun.controller.base.BaseController;
import com.qiankun.dao.core.Hints;
import com.qiankun.entity.Blood;
import com.qiankun.entity.Contacts;
import com.qiankun.entity.User;
import com.qiankun.pages.IPageList;
import com.qiankun.service.UserService;
import com.qiankun.utils.JwtTokenUtil;
import com.qiankun.utils.MD5;
import com.qiankun.utils.SessionUtils;
import com.qiankun.utils.UserUtils;
import com.qiankun.vo.UserVo;
@Controller
......@@ -122,6 +148,7 @@ public class UserController extends BaseController<Object>{
@Auth(verifyLogin = false,verifyURL = false)
@RequestMapping(value = "/wx/api/user/save",method = RequestMethod.POST)
public @ResponseBody Map<String,Object> saveUserformWX(@RequestBody UserVo userVo, HttpServletResponse response, HttpServletRequest request) throws Exception{
userVo.setOrigin("1");
return this.saveUser(userVo, response, request);
}
......@@ -180,6 +207,7 @@ public class UserController extends BaseController<Object>{
map.put("status", 2);
}
user.setOrigin(userVo.getOrigin());
user.setUserName(userVo.getMobile());
user.setName(userVo.getName());
user.setOpenid(userVo.getOpenid());
......@@ -299,15 +327,434 @@ public class UserController extends BaseController<Object>{
@RequestMapping("/api/user/del")
public ModelAndView delUser(String id, HttpServletResponse response, HttpServletRequest request) throws Exception {
ModelAndView view = new ModelAndView();
User userSession = SessionUtils.getUser(request);
ResourceBundle rb = ResourceBundle.getBundle("system");
String superAdmin = rb.getString("account");
if (superAdmin.equals(userSession.getMobile()) && (superAdmin.equals(userSession.getUserName()))) {
userService.remove(id);
User user = userService.findById(id);
user.setRemove(true);
userService.save(user);
return view;
}
@RequestMapping("/user/importpage")
public ModelAndView userImportPage(HttpServletResponse response, HttpServletRequest request) throws Exception {
ModelAndView view = new ModelAndView();
view.setViewName("user/import");
return view;
}
@RequestMapping(value = "/user/import", method = RequestMethod.POST)
public ModelAndView userImport(@RequestParam(value = "file", required = false) MultipartFile file, Integer type, HttpServletResponse response, HttpServletRequest request) throws Exception {
ModelAndView view = new ModelAndView();
if (file == null) {
view.getModelMap().addAttribute("status", "fileNotExist");
return view;
} else {
InputStream excelFileIo = file.getInputStream();
XSSFWorkbook xssfWorkbook = new XSSFWorkbook(excelFileIo);
XSSFSheet xssfSheet = xssfWorkbook.getSheetAt(0);
int rowstart = xssfSheet.getFirstRowNum()+1;
int rowEnd = xssfSheet.getLastRowNum();
XSSFRow row1 = xssfSheet.getRow(rowstart);
if (null == row1) {
xssfWorkbook.close();
return null;
}
Date date = new Date();
for (int i = rowstart + 1; i <= rowEnd; i++) {
XSSFRow row = xssfSheet.getRow(i);
if (null == row)
continue;
int cellStart = row.getFirstCellNum();
int cellEnd = row.getLastCellNum();
if (cellStart < 0 || cellEnd < 0) {
continue;
}
User u = null;
Blood b = new Blood();
Contacts c1 = new Contacts();
Contacts c2 = new Contacts();
if (type == 1) {
String paperId = row.getCell(7).getStringCellValue();
if (paperId.length()==15) {
paperId = UserUtils.get18Ic(paperId);
}
u = userService.findByPaperId(paperId);
if (u == null) {
u = new User();
} else {
u.getBlood().clear();
u.getContacts().clear();
}
u.setMarrowCode(row.getCell(0).getStringCellValue());
u.setName(row.getCell(2).getStringCellValue());
u.setGender(row.getCell(4).getStringCellValue());
u.setBirthday(row.getCell(5).getStringCellValue());
u.setPaperType(row.getCell(6).getStringCellValue());
u.setPaperId(paperId);
u.setNation(row.getCell(8).getStringCellValue());
u.setNativePlace(row.getCell(9).getStringCellValue());
u.setNationality(row.getCell(10).getStringCellValue());
u.setEducation(row.getCell(11).getStringCellValue());
u.setDomicilePlace(row.getCell(12).getStringCellValue());
u.setAddr(row.getCell(14).getStringCellValue());
u.setUnit(row.getCell(16).getStringCellValue());
u.setProfession(row.getCell(17).getStringCellValue());
u.setUnitAddr(row.getCell(18).getStringCellValue());
u.setUnitTel(row.getCell(20).getStringCellValue());
u.setMobile(row.getCell(21).getStringCellValue());
u.setTel(row.getCell(22).getStringCellValue());
u.setQq(row.getCell(23).getStringCellValue());
u.setEmail(row.getCell(24).getStringCellValue());
if (StringUtils.isNotBlank(row.getCell(25).getStringCellValue())) {
u.setDonateBloodCount(Integer.valueOf(row.getCell(25).getStringCellValue()));
}
u.setBloodType(row.getCell(26).getStringCellValue());
if (StringUtils.isNotBlank(row.getCell(27).getStringCellValue())) {
u.setHeight(Integer.valueOf(row.getCell(27).getStringCellValue()));
}
if (StringUtils.isNotBlank(row.getCell(28).getStringCellValue())) {
u.setWeight(Integer.valueOf(row.getCell(28).getStringCellValue()));
}
u.setWeixin(row.getCell(29).getStringCellValue());
u.setRemark(row.getCell(30).getStringCellValue());
c1.setName(row.getCell(31).getStringCellValue());
c1.setRelation(row.getCell(32).getStringCellValue());
c1.setAddr(row.getCell(33).getStringCellValue());
c1.setMobile(row.getCell(35).getStringCellValue());
c1.setQq(row.getCell(36).getStringCellValue());
c1.setWeixin(row.getCell(38).getStringCellValue());
c1.setUser(u);
c2.setName(row.getCell(40).getStringCellValue());
c2.setRelation(row.getCell(41).getStringCellValue());
c2.setAddr(row.getCell(42).getStringCellValue());
c2.setMobile(row.getCell(44).getStringCellValue());
c2.setQq(row.getCell(45).getStringCellValue());
c2.setWeixin(row.getCell(47).getStringCellValue());
c2.setUser(u);
u.getContacts().add(c1);
u.getContacts().add(c2);
b.setBloodId(row.getCell(1).getStringCellValue());
b.setBloodCollect(row.getCell(49).getStringCellValue());
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
String d = row.getCell(50).getStringCellValue();
if (d != null) {
b.setUpdateTime(sdf.parse(d));
}
b.setReview(row.getCell(53).getStringCellValue());
b.setUser(u);
u.getBlood().add(b);
} else if (type == 2) {
String paperId = row.getCell(5).getStringCellValue();
if (paperId.length()==15) {
paperId = UserUtils.get18Ic(paperId);
}
u = userService.findByPaperId(paperId);
if (u == null) {
u = new User();
} else {
view.getModelMap().addAttribute("userPage", "Illegal Users");
u.getBlood().clear();
u.getContacts().clear();
}
u.setName(row.getCell(2).getStringCellValue());
u.setGender(row.getCell(3).getStringCellValue());
u.setPaperType(row.getCell(4).getStringCellValue());
u.setPaperId(row.getCell(5).getStringCellValue());
u.setBirthday(row.getCell(6).getStringCellValue());
u.setNativePlace(row.getCell(7).getStringCellValue());
u.setNationality(row.getCell(8).getStringCellValue());
u.setNation(row.getCell(9).getStringCellValue());
u.setDomicilePlace(row.getCell(10).getStringCellValue());
u.setAddr(row.getCell(12).getStringCellValue());
u.setUnit(row.getCell(14).getStringCellValue());
u.setProfession(row.getCell(15).getStringCellValue());
u.setUnitAddr(row.getCell(16).getStringCellValue());
u.setTel(row.getCell(18).getStringCellValue());
u.setMobile(row.getCell(19).getStringCellValue());
u.setUnitTel(row.getCell(20).getStringCellValue());
u.setEmail(row.getCell(21).getStringCellValue());
if (StringUtils.isNotBlank(row.getCell(22).getStringCellValue())) {
u.setDonateBloodCount(Integer.valueOf(row.getCell(22).getStringCellValue()));
}
u.setQq(row.getCell(23).getStringCellValue());
u.setWeixin(row.getCell(24).getStringCellValue());
u.setBloodType(row.getCell(25).getStringCellValue());
if (StringUtils.isNotBlank(row.getCell(27).getStringCellValue())) {
u.setHeight(Integer.valueOf(row.getCell(27).getStringCellValue()));
}
if (StringUtils.isNotBlank(row.getCell(28).getStringCellValue())) {
u.setWeight(Integer.valueOf(row.getCell(28).getStringCellValue()));
}
u.setRemark(row.getCell(29).getStringCellValue());
u.setEducation(row.getCell(31).getStringCellValue());
c1.setName(row.getCell(35).getStringCellValue());
c1.setRelation(row.getCell(36).getStringCellValue());
c1.setMobile(row.getCell(37).getStringCellValue());
c1.setQq(row.getCell(38).getStringCellValue());
c1.setMobile(row.getCell(39).getStringCellValue());
c1.setWeixin(row.getCell(40).getStringCellValue());
c1.setAddr(row.getCell(41).getStringCellValue());
c1.setUser(u);
c2.setName(row.getCell(44).getStringCellValue());
c2.setRelation(row.getCell(45).getStringCellValue());
c2.setMobile(row.getCell(46).getStringCellValue());
c2.setQq(row.getCell(47).getStringCellValue());
c2.setMobile(row.getCell(48).getStringCellValue());
c2.setWeixin(row.getCell(49).getStringCellValue());
c2.setAddr(row.getCell(50).getStringCellValue());
c2.setUser(u);
u.getContacts().add(c1);
u.getContacts().add(c2);
b.setBloodCollect(row.getCell(32).getStringCellValue());
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
String d = row.getCell(26).getStringCellValue();
if (d != null) {
b.setUpdateTime(sdf.parse(d));
}
b.setBloodId(row.getCell(1).getStringCellValue());
b.setUser(u);
u.getBlood().add(b);
} else {
view.getModelMap().addAttribute("status", 0);
break;
}
u.setCreateTime(date);
u.setOrigin("3");
userService.save(u);
}
xssfWorkbook.close();
}
return view;
}
@RequestMapping("/user/exportpage")
public ModelAndView userExportPage(HttpServletResponse response, HttpServletRequest request) throws Exception {
ModelAndView view = new ModelAndView();
view.setViewName("user/export");
return view;
}
@RequestMapping("/user/export")
public void export(UserVo userVo, HttpServletResponse response, HttpServletRequest request) throws Exception {
try {
request.setCharacterEncoding("UTF-8");
response.setCharacterEncoding("UTF-8");
response.setContentType("application/x-download");
String fileName = "user.xlsx";
fileName = URLEncoder.encode(fileName, "UTF-8");
response.addHeader("Content-Disposition", "attachment;filename=" + fileName);
XSSFWorkbook wb = new XSSFWorkbook();
XSSFSheet sheet = wb.createSheet("志愿者基本信息模板");
sheet.setMargin(HSSFSheet.TopMargin,( double ) 0.5 ); // 上边距
sheet.setMargin(HSSFSheet.BottomMargin,( double ) 0.5 ); // 下边距
sheet.setMargin(HSSFSheet.LeftMargin,( double ) 0.2 ); // 左边距
sheet.setMargin(HSSFSheet.RightMargin,( double ) 0.0 ); // 右边距
XSSFPrintSetup print = sheet.getPrintSetup();
print.setLandscape(true);
print.setPaperSize(PaperSize.A4_PAPER);
sheet.setDefaultRowHeight((short) (2 * 256));//设置行高
sheet.setColumnWidth(0,3000);//设置列宽
sheet.setColumnWidth(1,3000);
sheet.setColumnWidth(2,3000);
sheet.setColumnWidth(3,3000);
sheet.setColumnWidth(4,3000);
sheet.setColumnWidth(5,3000);
sheet.setColumnWidth(6,3000);
sheet.setColumnWidth(7,3000);
sheet.setColumnWidth(8,3000);
sheet.setColumnWidth(9,3000);
sheet.setColumnWidth(10,3000);
sheet.setColumnWidth(11,3000);
sheet.setColumnWidth(12,3000);
sheet.setColumnWidth(13,3000);
sheet.setColumnWidth(14,3000);
sheet.setColumnWidth(15,3000);
sheet.setColumnWidth(16,3000);
sheet.setColumnWidth(17,3000);
sheet.setColumnWidth(18,3000);
sheet.setColumnWidth(19,3000);
sheet.setColumnWidth(20,3000);
sheet.setColumnWidth(21,3000);
sheet.setColumnWidth(22,3000);
sheet.setColumnWidth(23,3000);
sheet.setColumnWidth(24,3000);
sheet.setColumnWidth(25,3000);
sheet.setColumnWidth(26,3000);
sheet.setColumnWidth(27,3000);
sheet.setColumnWidth(28,3000);
sheet.setColumnWidth(29,3000);
sheet.setColumnWidth(30,3000);
sheet.setColumnWidth(31,3000);
sheet.setColumnWidth(32,3000);
sheet.setColumnWidth(33,3000);
sheet.setColumnWidth(34,3000);
sheet.setColumnWidth(35,3000);
sheet.setColumnWidth(36,3000);
sheet.setColumnWidth(37,3000);
sheet.setColumnWidth(38,3000);
sheet.setColumnWidth(39,3000);
sheet.setColumnWidth(40,3000);
sheet.setColumnWidth(41,3000);
sheet.setColumnWidth(42,3000);
sheet.setColumnWidth(43,3000);
sheet.setColumnWidth(44,3000);
sheet.setColumnWidth(45,3000);
sheet.setColumnWidth(46,3000);
sheet.setColumnWidth(47,3000);
sheet.setColumnWidth(48,3000);
sheet.setColumnWidth(49,3000);
sheet.setColumnWidth(50,3000);
sheet.setColumnWidth(51,3000);
sheet.setColumnWidth(52,3000);
XSSFFont topfont = wb.createFont();
topfont.setFontName("宋体");
topfont.setFontHeightInPoints((short) 11);
topfont.setBold(true);
//topfont.setBoldweight(Font.BOLDWEIGHT_BOLD);
XSSFCellStyle cellTopStyle=wb.createCellStyle();
cellTopStyle.setFillPattern(CellStyle.SOLID_FOREGROUND);
cellTopStyle.setBorderBottom(BorderStyle.THIN); //setBorderBottom(CellStyle.BORDER_THIN);
cellTopStyle.setBorderLeft(BorderStyle.THIN);//setBorderLeft(CellStyle.BORDER_THIN);
cellTopStyle.setBorderRight(BorderStyle.THIN);//setBorderRight(CellStyle.BORDER_THIN);
cellTopStyle.setBorderTop(BorderStyle.THIN);//setBorderTop(CellStyle.BORDER_THIN);
cellTopStyle.setVerticalAlignment(XSSFCellStyle.VERTICAL_CENTER);
cellTopStyle.setFont(topfont);
cellTopStyle.setFillForegroundColor(IndexedColors.WHITE.getIndex());
XSSFRow row = sheet.createRow(0);
row.setHeightInPoints(30);
row.setRowStyle(cellTopStyle);
XSSFCell cell = row.createCell(0);
cell.setCellValue("个人信息");
cell.setCellStyle(cellTopStyle);
cell = row.createCell(29);
cell.setCellValue("最亲近的家属或朋友资料-1");
cell.setCellStyle(cellTopStyle);
cell = row.createCell(38);
cell.setCellValue("最亲近的家属或朋友资料-2");
cell.setCellStyle(cellTopStyle);
cell = row.createCell(47);
cell.setCellValue("录入与审核信息");
cell.setCellStyle(cellTopStyle);
sheet.addMergedRegion(new CellRangeAddress(0,0,0,28));
sheet.addMergedRegion(new CellRangeAddress(0,0,29,37));
sheet.addMergedRegion(new CellRangeAddress(0,0,38,46));
sheet.addMergedRegion(new CellRangeAddress(0,0,47,52));
row = sheet.createRow(1);
row.setHeightInPoints(30);
cell = row.createCell(0);
cell.setCellValue("*姓名");
cell.setCellStyle(cellTopStyle);
XSSFCellStyle cellStyle=wb.createCellStyle();
cellStyle.setWrapText(true);
cellStyle.setFillPattern(CellStyle.SOLID_FOREGROUND);
cellStyle.setBorderBottom(BorderStyle.THIN); //setBorderBottom(CellStyle.BORDER_THIN);
cellStyle.setBorderLeft(BorderStyle.THIN);//setBorderLeft(CellStyle.BORDER_THIN);
cellStyle.setBorderRight(BorderStyle.THIN);//setBorderRight(CellStyle.BORDER_THIN);
cellStyle.setBorderTop(BorderStyle.THIN);//setBorderTop(CellStyle.BORDER_THIN);
cellStyle.setVerticalAlignment(XSSFCellStyle.VERTICAL_CENTER);
cellStyle.setFillForegroundColor(IndexedColors.WHITE.getIndex());
XSSFFont cellfont = wb.createFont();
cellfont.setFontName("宋体");
cellfont.setFontHeightInPoints((short) 10);
cellStyle.setFont(cellfont);
List<User> user = userService.findUserPage(userVo.getName(), userVo.getPaperId(),
userVo.getStart(), userVo.getEnd(), userVo.getBloodId(), userVo.getStartbloodId(),
userVo.getEndbloodId(), userVo.getOrder(), userVo.getSort(), new Hints(0));
XSSFRow rows;
XSSFCell cells;
for (int i = 0; i < user.size(); i++) {
// 第三步:在这个sheet页里创建一行
rows = sheet.createRow(i+2);
rows.setHeightInPoints(70);
// 第四步:在该行创建一个单元格
User data = user.get(i);
cells = rows.createCell(0);
cells.setCellValue(data.getName());
cells.setCellStyle(cellStyle);
}
OutputStream out = response.getOutputStream();
wb.write(out);
out.close();
wb.close();
} catch (UnsupportedEncodingException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
}
}
}
\ No newline at end of file
......@@ -464,10 +464,22 @@ public class RainbowPlanWebController extends BaseController<Object>{
cells = rows.createCell(10);
if (data.getVolunteer()!=null) {
String tel = data.getVolunteer().getConnectTel();
tel = tel==null ? "" : "\n" + tel;
tel = tel==null ? " " + data.getVolunteer().getPhone() : " " + tel;
String addr = data.getVolunteer().getReceiveAddress();
addr = addr==null ? "" : "\n" + addr;
cells.setCellValue(data.getVolunteer().getName() + tel + addr);
Integer helpType = data.getHelpType();
String express = "";
String expressCompany = data.getExpressCompany();
expressCompany = expressCompany==null ? "" : expressCompany;
String expressCode = data.getExpressCode();
expressCode = expressCode==null ? "" : expressCode;
if (helpType==2 || helpType==0) {
express = "\n" + expressCompany + " " + expressCode;
} else if (helpType==1) {
express = "\n自送";
}
cells.setCellValue(data.getVolunteer().getName() + tel + addr + express);
} else {
cells.setCellValue("");
}
......
package com.qiankun.dao;
import java.util.List;
import com.qiankun.dao.core.Hints;
import com.qiankun.dao.core.IDao;
import com.qiankun.entity.User;
......@@ -20,4 +22,9 @@ public interface UserDao extends IDao<User, String> {
Boolean validateUserExistByUserName(String userName);
User findByOpenid(String openid);
User findByPaperId(String paperId);
List<User> findUserPage(String name, String paperId, String start, String end, String bloodId,
String startbloodId, String endbloodId, String order, String sort, Hints hints);
}
package com.qiankun.dao;
import java.util.List;
import org.springframework.stereotype.Repository;
import com.qiankun.dao.core.AbsDao;
......@@ -11,21 +13,23 @@ import com.qiankun.pages.PageListImpl;
@Repository
public class UserDaoImpl extends AbsDao<User, String> implements UserDao {
private static final String FIND = "from User where ";
private static final String FIND_USER_PAGE = " from User where (mobile like ? or paperId like ? or name like ? or userName like ?) ";
private static final String FIND_USER_PAGE = " from User where (mobile like ? or paperId like ? or name like ? or userName like ?) and remove=false ";
// private static final String FIND_LASTUSER_BY_GROUP = " from User where groups = ? order by createTime desc";
private static final String LOGIN = " from User where mobile = ? and pwd = ? and isRemove=false";
private static final String LOGIN = " from User where mobile = ? and pwd = ? and remove=false";
private static final String VALIDATE_PAPERID = " from User where paperId = ?";
private static final String VALIDATE_USERNAME = " from User where userName = ?";
private static final String VALIDATE_PWD = " from User where id = ? and pwd = ? and isRemove=false";
private static final String FIND_BY_OPENID = "from User where openid = ?";
private static final String FIND_BY_PAPERID = "from User where paperId = ? and paperType = ?";
private static final String VALIDATE_PWD = " from User where id = ? and pwd = ? and remove=false ";
private static final String FIND_BY_OPENID = "from User where openid = ? and remove=false ";
private static final String FIND_BY_PAPERID_PAPERTYPE = "from User where paperId = ? and paperType = ? and remove=false ";
private static final String FIND_BY_PAPERID = "from User where paperId = ? ";
private static final String FIND_USER_PAGE_EXPORT = " select user from User user join user.blood blood where remove=false ";
@Override
public Boolean validateUserExistByPaperId(String paperId) {
......@@ -62,34 +66,46 @@ public class UserDaoImpl extends AbsDao<User, String> implements UserDao {
@Override
public IPageList<User> findUserPage(String searchStr, String role, String status,String order, String sort, Hints hints) {
public List<User> findUserPage(String name, String paperId, String start, String end, String bloodId, String startbloodId, String endbloodId, String order, String sort, Hints hints) {
if (order == null){
order = " createTime ";
order = " user.createTime ";
}
if (sort == null){
sort=" desc ";
}
String hql = "";
if (role != null){
hql += " and role = '" +role+ "' ";
if (name != null){
hql += " and user.name = '" +name+ "' ";
}
if (status != null){
hql += " and status = '" +status+ "' ";
if (paperId != null){
hql += " and user.paperId = '" +paperId+ "' ";
}
if (searchStr == null) {
searchStr = "%";
if (bloodId != null){
hql += " and blood.bloodId = '" +bloodId+ "' ";
}
String param = "%" + searchStr + "%";
IPageList<User> users = new PageListImpl<User>();
users.setRecords(find(FIND_USER_PAGE + hql + sortHQL(order, sort), hints, param, param, param, param));
users.setRecordTotal(findCount(" select count(*) " + FIND_USER_PAGE + hql, param, param, param, param));
if (startbloodId != null){
hql += " and blood.bloodId > '" +startbloodId+ "' ";
}
return users;
if (endbloodId != null){
hql += " and blood.bloodId < '" +endbloodId+ "' ";
}
if (start != null){
hql += " and blood.updateTime > '" +start+ "' ";
}
if (end != null){
hql += " and blood.updateTime < '" +end+ "' ";
}
return find(FIND_USER_PAGE_EXPORT + hql + sortHQL(order, sort), hints);
}
......@@ -115,6 +131,43 @@ public class UserDaoImpl extends AbsDao<User, String> implements UserDao {
@Override
public User findByPaperId(String paperId, String paperType) {
return findUnique(FIND_BY_PAPERID,new Hints(),paperId,paperType);
return findUnique(FIND_BY_PAPERID_PAPERTYPE,new Hints(),paperId,paperType);
}
@Override
public User findByPaperId(String paperId) {
return findUnique(FIND_BY_PAPERID,new Hints(),paperId);
}
@Override
public IPageList<User> findUserPage(String searchStr, String role, String status,String order, String sort, Hints hints) {
if (order == null){
order = " createTime ";
}
if (sort == null){
sort=" desc ";
}
String hql = "";
if (role != null){
hql += " and role = '" +role+ "' ";
}
if (status != null){
hql += " and status = '" +status+ "' ";
}
if (searchStr == null) {
searchStr = "%";
}
String param = "%" + searchStr + "%";
IPageList<User> users = new PageListImpl<User>();
users.setRecords(find(FIND_USER_PAGE + hql + sortHQL(order, sort), hints, param, param, param, param));
users.setRecordTotal(findCount(" select count(*) " + FIND_USER_PAGE + hql, param, param, param, param));
return users;
}
}
......@@ -33,12 +33,12 @@ public class Blood {
private String bloodId; //采样编号
private String bloodCollect; //采血者
@Lob
private String bloodAddr; //采血地点
@ManyToOne
private User review; //数据初审者;
private String review; //数据初审者;
@ManyToOne
private User user = new User();
......@@ -71,11 +71,11 @@ public class Blood {
this.bloodAddr = bloodAddr;
}
public User getReview() {
public String getReview() {
return review;
}
public void setReview(User review) {
public void setReview(String review) {
this.review = review;
}
......@@ -102,4 +102,14 @@ public class Blood {
public void setActivity(Activity activity) {
this.activity = activity;
}
public String getBloodCollect() {
return bloodCollect;
}
public void setBloodCollect(String bloodCollect) {
this.bloodCollect = bloodCollect;
}
}
......@@ -62,7 +62,7 @@ public class User {
@Lob
private String remark; //备注
private String origin; //用户来源
private String origin; //用户来源 小程序1 后台新增2 导入3
private String referrals; //推荐人
private String pwd; //密码
......@@ -73,9 +73,13 @@ public class User {
private String avatarImage; //头像
private String cerfificatePath;//证书图片路径
private String marrowCode; //骨髓编号
private Date createTime = new Date();
private Date updateTime = new Date();
private boolean remove = false;
@OneToMany(fetch = FetchType.LAZY, cascade = { CascadeType.ALL}, orphanRemoval = true, mappedBy = "user")
@JsonIgnore
private Set<Contacts> contacts = new HashSet<Contacts>();
......@@ -84,10 +88,6 @@ public class User {
@JsonIgnore
private Set<Blood> blood = new HashSet<Blood>();
@OneToMany(fetch = FetchType.LAZY, cascade = { CascadeType.ALL}, orphanRemoval = true, mappedBy = "review")
@JsonIgnore
private Set<Blood> review = new HashSet<Blood>();
@OneToMany(fetch = FetchType.LAZY, cascade = { CascadeType.ALL}, orphanRemoval = true, mappedBy = "user")
@JsonIgnore
private Set<Points> points = new HashSet<Points>();
......@@ -294,12 +294,7 @@ public class User {
public void setBlood(Set<Blood> blood) {
this.blood = blood;
}
public Set<Blood> getReview() {
return review;
}
public void setReview(Set<Blood> review) {
this.review = review;
}
public String getStatus() {
return status;
}
......@@ -370,4 +365,18 @@ public class User {
public void setCerfificatePath(String cerfificatePath) {
this.cerfificatePath = cerfificatePath;
}
public boolean isRemove() {
return remove;
}
public void setRemove(boolean remove) {
this.remove = remove;
}
public String getMarrowCode() {
return marrowCode;
}
public void setMarrowCode(String marrowCode) {
this.marrowCode = marrowCode;
}
}
package com.qiankun.service;
import java.util.List;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
......@@ -61,4 +63,18 @@ public class UserService {
public User findByPaperId(String paperId, String paperType) {
return userDao.findByPaperId(paperId,paperType);
}
public User findByPaperId(String paperId) {
return userDao.findByPaperId(paperId);
}
public List<User> findUserPage(String name, String paperId, String start, String end, String bloodId,
String startbloodId, String endbloodId, String order, String sort, Hints hints) {
List<User> users = userDao.findUserPage(name, paperId, start, end, bloodId, startbloodId, endbloodId,
order, sort, hints);
return users;
}
}
......@@ -148,6 +148,28 @@ public class UserUtils {
return addTexts;
}
public static String get18Ic(String identifyCard) {
String retId = "";
String id17 = "";
int sum = 0;
int y = 0; // 定义数组加权因子
int[] wf = { 7, 9, 10, 5, 8, 4, 2, 1, 6, 3, 7, 9, 10, 5, 8, 4, 2 }; // 定义数组存放校验码
String[] cc = { "1", "0", "x", "9", "8", "7", "6", "5", "4", "3", "2" }; // 在原15位数身份证的第六位数后面插入19
id17 = identifyCard.substring(0, 6) + "19" + identifyCard.substring(6); // 17位数字和系数相乘,结果相加
for (int i = 0; i < 17; i++) {
sum = sum + Integer.valueOf(id17.substring(i, i + 1)) * wf[i];
} // 计算余数
y = sum % 11; // 通过模获得对应的校验码cc[yy];
retId = id17 + cc[y];
return retId;
}
public static void main(String[] args){
System.out.print(get18Ic("120105850126422"));
}
/*
public static void main(String[] args){
try {
......
package com.qiankun.vo;
import java.util.Date;
public class UserVo {
private String id;
......@@ -36,6 +34,7 @@ public class UserVo {
private Integer weight; //体重
private String remark; //备注
private String origin; //用户来源 小程序1 后台新增2 导入3
private String contactsName1;
private String contactsQQ1;
......@@ -55,6 +54,8 @@ public class UserVo {
private String role; //角色 1.管理员 2.志愿者
private String status; //状态 0.未采血 1.已采血
private String marrowCode; //骨髓编号
private String oldpwd; //原密码
private Boolean changePassword;
private String searchStr;
......@@ -62,6 +63,12 @@ public class UserVo {
private String sort;
private String avatarImage; //头像
private String start;
private String end;
private String bloodId;
private String startbloodId;
private String endbloodId;
public String getId() {
return id;
}
......@@ -367,4 +374,48 @@ public class UserVo {
public void setAvatarImage(String avatarImage) {
this.avatarImage = avatarImage;
}
public String getMarrowCode() {
return marrowCode;
}
public void setMarrowCode(String marrowCode) {
this.marrowCode = marrowCode;
}
public String getOrigin() {
return origin;
}
public void setOrigin(String origin) {
this.origin = origin;
}
public String getStart() {
return start;
}
public void setStart(String start) {
this.start = start;
}
public String getEnd() {
return end;
}
public void setEnd(String end) {
this.end = end;
}
public String getBloodId() {
return bloodId;
}
public void setBloodId(String bloodId) {
this.bloodId = bloodId;
}
public String getStartbloodId() {
return startbloodId;
}
public void setStartbloodId(String startbloodId) {
this.startbloodId = startbloodId;
}
public String getEndbloodId() {
return endbloodId;
}
public void setEndbloodId(String endbloodId) {
this.endbloodId = endbloodId;
}
}
<%@ page language="java" contentType="text/html; charset=UTF-8"
pageEncoding="UTF-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt"%>
<%@ taglib prefix="webpath" uri="/WEB-INF/tlds/path.tld"%>
<%@ taglib prefix="webpage" uri="/WEB-INF/tlds/pageview.tld"%>
<head>
</head>
<div class="main-content">
<div class="breadcrumbs" id="breadcrumbs">
<ul class="breadcrumb">
<li>
<i class="icon-home home-icon"></i>
<a href="#">首页</a>
</li>
<li class="active">用户管理</li>
<li class="active">导出</li>
</ul><!-- .breadcrumb -->
</div>
<div class="page-content">
<div class="row">
<div class="col-xs-12">
<form action="#" id="userImport" name="userImport" method="post" onsubmit="return false" class="form-horizontal dropzone" role="form">
<div class="row">
<div class="col-xs-12">
<h3 class="header smaller lighter blue">导出数据</h3></div>
</div>
<div class="row">
<div class="col-xs-4">
<div class="form-group">
<label class="col-sm-3 control-label no-padding-right" for="form-field-1"> 姓名 </label>
<div class="col-sm-9">
<input type="text" id="name" name="name" value="" class="col-xs-10 col-sm-10" />
</div>
</div>
<div class="form-group">
<label class="col-sm-3 control-label no-padding-right" for="form-field-1"> 证件号 </label>
<div class="col-sm-9">
<input type="text" id="paperId" name="paperId" value="" class="col-xs-10 col-sm-10" />
</div>
</div>
<div class="form-group">
<label class="col-sm-3 control-label no-padding-right" for="form-field-1"> 采样日期</label>
<div class="col-sm-9">
<input type="text" id="day" name="day" value="" class="col-xs-10 col-sm-10" />
</div>
</div>
<div class="form-group">
<div class="col-sm-3" style="padding-right:0">
<select class="col-xs-12 col-sm-12 pull-right" id="bloodIdselect" name="bloodIdselect">
<option value="0">采样编号</option>
<option value="1">采样编号范围</option>
</select>
</div>
<div class="col-sm-9" id="bloodIddiv" style="display:none;">
<input type="text" id="bloodId" name="bloodId" value="" class="col-xs-10 col-sm-10" />
</div>
<div class="col-sm-9" id="bloodIddivrange" style="display:none;">
<input type="text" placeholder="开始" id="startbloodId" name="startbloodId" value="" class="col-xs-5 col-sm-5" />
<input type="text" placeholder="结束" id="endbloodId" name="endbloodId" value="" class="col-xs-5 col-sm-5" />
</div>
</div>
</div>
</div>
<div class="col-md-offset-3 col-md-9">
<button class="btn btn-sm btn-success" type="submit" onclick="user.exportExcel()">
<i class="icon-save bigger-110"></i>
确定
</button>
&nbsp; &nbsp; &nbsp;
<a class="btn btn-sm btn-success" href="javascript:history.go(-1)">
<i class="icon-reply bigger-110"></i>
返回
</a>
</div>
</form>
</div>
</div>
</div>
</div>
<script src="<webpath:path/>/resources/js/user/export.js" type="text/javascript"></script>
<script>
</script>
<%@ page language="java" contentType="text/html; charset=UTF-8"
pageEncoding="UTF-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt"%>
<%@ taglib prefix="webpath" uri="/WEB-INF/tlds/path.tld"%>
<%@ taglib prefix="webpage" uri="/WEB-INF/tlds/pageview.tld"%>
<head>
</head>
<div class="main-content">
<div class="breadcrumbs" id="breadcrumbs">
<ul class="breadcrumb">
<li>
<i class="icon-home home-icon"></i>
<a href="#">首页</a>
</li>
<li class="active">用户管理</li>
<li class="active">导入</li>
</ul><!-- .breadcrumb -->
</div>
<div class="page-content">
<div class="row">
<div class="col-xs-12">
<form action="#" id="userImport" name="userImport" method="post" onsubmit="return false" class="form-horizontal dropzone" role="form">
<div class="row">
<div class="col-xs-12">
<h3 class="header smaller lighter blue">导入数据</h3></div>
</div>
<div class="row">
<div class="col-xs-4">
<div class="form-group">
<label class="col-sm-3 control-label no-padding-right" for="form-field-1"> 数据类型 </label>
<div class="col-sm-9">
<select class="col-xs-10 col-sm-10" id="type" name="type">
<option value="0" >请选择</option>
<option value="1" >志愿者已入库基本信息表</option>
<option value="2" >志愿者基本信息未审核</option>
</select>
</div>
</div>
<div class="form-group">
<label class="col-sm-3 control-label no-padding-right" for="form-field-1"> 选择文件 </label>
<div class="col-sm-9">
<input name="input_file" id="input_file" type="file" />
</div>
</div>
</div>
</div>
<div class="col-md-offset-3 col-md-9">
<button class="btn btn-sm btn-success" type="submit" onclick="user.save()">
<i class="icon-save bigger-110"></i>
确定
</button>
&nbsp; &nbsp; &nbsp;
<a class="btn btn-sm btn-success" href="javascript:history.go(-1)">
<i class="icon-reply bigger-110"></i>
返回
</a>
</div>
</form>
</div>
</div>
</div>
</div>
<script src="<webpath:path/>/resources/js/user/import.js" type="text/javascript"></script>
<script>
</script>
......@@ -37,17 +37,19 @@
新增
</button>
<button class="btn btn-sm btn-success">
<button class="btn btn-sm btn-success" onclick="window.location.href='<webpath:path/>/user/importpage'">
<i class="icon-star-half-full bigger-110"></i>
导入
</button>
<button class="btn btn-sm btn-danger">
<i class="icon-trash bigger-110"></i>
删除
<button class="btn btn-sm btn-success" onclick="window.location.href='<webpath:path/>/user/exportpage'">
<i class="icon-star-half-full bigger-110"></i>
导出
</button>
</div>
<div class="pull-right">
......@@ -79,12 +81,12 @@
<table id="table-data" class="table table-bordered ">
<thead>
<tr class="">
<th class="center">
<!-- <th class="center">
<label>
<input type="checkbox" class="ace">
<span class="lbl"></span>
</label>
</th>
</th> -->
<th>姓名</th>
<th>性别</th>
<th>出生年月</th>
......@@ -107,12 +109,12 @@
<c:forEach var="user" items="${userPage.records}">
<tr class="tr-highlight">
<td class="center" width=10>
<!-- <td class="center" width=10>
<label>
<input type="checkbox" class="ace">
<span class="lbl"></span>
</label>
</td>
</td> -->
<td title="${user.name}">${user.name} </td>
<td title="${user.gender}">${user.gender}</td>
......@@ -158,7 +160,7 @@
</button>
&nbsp;
<button class="btn btn-xs btn-danger">
<button class="btn btn-xs btn-danger" onclick="user.del('${user.id}')">
<i class="icon-trash bigger-120"></i>
</button>
......
var isSubmit = true;
$(document).ready(function(){
laydate.render({
elem: '#day',
range: true,
done: function(value, date, endDate){
console.log(value); //得到日期生成的值,如:2017-08-18
console.log(date); //得到日期时间对象:{year: 2017, month: 8, date: 18, hours: 0, minutes: 0, seconds: 0}
console.log(endDate); //得结束的日期时间对象,开启范围选择(range: true)才会返回。对象成员同上。
user.startDay = date.year + "-" + date.month + "-" + date.date + " 00:00:00" ;
user.endDay = endDate.year + "-" + endDate.month + "-" + endDate.date + " 23:59:59" ;
}
});
$("#bloodIdselect").change(function(){
if ($("#bloodIdselect").val() == "0"){
$("#bloodIddiv").css("display","");
$("#bloodIddivrange").css("display","none");
} else {
$("#bloodIddiv").css("display","none");
$("#bloodIddivrange").css("display","");
}
})
$("#day").val("")
$("#bloodIddiv").css("display","");
$("#bloodIdselect").val(0);
})
var user = {
startDay : "",
endDay : "",
exportExcel : function(){
if (isSubmit){
isSubmit = false;
var url = webPath + "/user/export";
var name = $('#name').val();
var paperId = $('#paperId').val();
var start = user.startDay;
var end = user.endDay;
var bloodId = "";
var startbloodId = "";
var endbloodId = "";
if ($("#bloodIdselect").val() == "0"){
bloodId = $('#bloodId').val();
} else {
startbloodId = $('#startbloodId').val();
endbloodId = $('#endbloodId').val();
}
if(name != "" || paperId != "" || start != "" || end != "" || bloodId != "" || startbloodId != "" || endbloodId != ""){
var param = "?"
if (name != ""){
param = param + "name=" + name ;
}
if (paperId != ""){
if (param == "?"){
param = param + "paperId=" + paperId;
} else {
param = param + "&paperId=" + paperId;
}
}
if (start != ""){
if (param == "?"){
param = param + "start=" + start;
} else {
param = param + "&start=" + start;
}
}
if (end != ""){
if (param == "?"){
param = param + "end=" + end;
} else {
param = param + "&end=" + end;
}
}
if (bloodId != ""){
if (param == "?"){
param = param + "bloodId=" + bloodId;
} else {
param = param + "&bloodId=" + bloodId;
}
}
if (startbloodId != ""){
if (param == "?"){
param = param + "startbloodId=" + startbloodId;
} else {
param = param + "&startbloodId=" + startbloodId;
}
}
if (endbloodId != ""){
if (param == "?"){
param = param + "endbloodId=" + endbloodId;
} else {
param = param + "&endbloodId=" + endbloodId;
}
}
url = url + param;
}
window.open(url);
isSubmit = true;
}
}
}
var isSubmit = true;
$(document).ready(function(){
})
var user = {
save : function(){
if (isSubmit){
isSubmit = false;
var formData = new FormData();
formData.append('file', $('#input_file')[0].files[0]);
formData.append('type', $('#type').val());
$.ajax({
url: '/user/import',
type: 'POST',
cache: false,
data: formData,
processData: false,
contentType: false,
dataType:"json",
beforeSend: function(){
},
success: function(data){
var status=data.status;
if(status==1){//注册成功
bootbox.dialog({
message:"导入成功",
buttons:{
"success":{
"label":"继续添加",
"className":"btn-sm btn-primary",
"callback": function () {
window.location.href = webPath + '/user/list';
}
}
}
});
} else if (status == 0){
isSubmit = true;
bootbox.dialog({
message:"请选择数据类型",
buttons:{
"success":{
"label":"确定",
"className":"btn-sm btn-primary",
"callback": function () {
}
}
}
});
}
}
});
}
}
}
......@@ -164,7 +164,7 @@ $(document).ready(function(){
laydate.render({
elem: '#birthday'
});
$('#birthday').datepicker()
//$('#birthday').datepicker()
$("#nation").select2({
placeholder : "请选择",
......@@ -231,6 +231,7 @@ var user = {
height:$('#height').val(),
weight:$('#weight').val(),
remark:$('#remark').val(),
origin:"2",
contactsName1:$('#contactsName1').val(),
contactsQQ1:$('#contactsQQ1').val(),
contactsRelation1:$('#contactsRelation1').val(),
......@@ -354,6 +355,37 @@ var user = {
url = url + param;
}
window.location.href = url;
},
del : function(id) {
bootbox.confirm({
buttons: {
cancel: {
label: '取消',
className: 'btn-default'
},
confirm: {
label: '确认',
className: 'btn-myStyle'
}
},
message: '请确认是否删除?',
callback: function(result) {
if(result) {
$.ajax({
type: 'GET',
url: webPath + '/api/user/del?id='+id,
dataType:'json',
success: function(data){
window.location.reload();
}
})
} else {
}
},
//title: "bootbox confirm也可以添加标题哦",
});
}
}
......
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