init: 导入项目

This commit is contained in:
fengjun committed 2024-07-02 11:40:01 +08:00
commit 4c8e6701f2
7158 files changed
+1199718

No files matched your search

@@ -0,0 +1,91 @@
package com.ag.demo;
import com.ag.dynamicmodule.main.HotApplicationContext;
import com.ag.entity.fee.face.ICondition;
import com.ag.entity.fee.face.IFeeBase;
import com.ag.entity.fee.face.ReqSource;
import com.ag.entity.fee.face.SourceProperty;
import com.ag.util.TimeUtil;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import org.springframework.stereotype.Service;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.util.ArrayList;
import java.util.List;
/**
* Created by yangxh on 2022/1/5.
*/
@Service
public class AutoCalcTest {
private static final String bizType = "MACH";
private static final String itemIds = "001";
private static final String contractId = "ccb1deff1086449d87106a6478f34ca4";
public void execute(org.json.JSONObject param, HttpServletResponse response, HttpServletRequest request){
IFeeBase feeBase = (IFeeBase) HotApplicationContext.getBean("feeController");
ReqSource reqSource = new ReqSource();
generateData(reqSource);
System.out.println(JSON.toJSONString(reqSource));
String res = feeBase.callback(JSON.toJSONString(reqSource));
System.out.println(res);
}
/**
* 箱,票,拼箱比例费用计算(类舱单费)
* @param reqSource
*/
private static void generateData(ReqSource reqSource){
List<SourceProperty> sources = new ArrayList<>();
//票
String mainId = "8f548bf59afa4440b86636c10ba";
SourceProperty bill = new SourceProperty();
sources.add(bill);
bill.setBizId(mainId);
bill.setBizTime(TimeUtil.getDateTime());
bill.setBizType(bizType);
JSONObject billMap = new JSONObject();
billMap.put("BILL_CALC", "1");
billMap.put(ICondition.LIN_ID, "营运人code");
billMap.put(ICondition.CAR_AGE, "车队code");
bill.setProperty(billMap);
//箱1
String bizId = "8f548bf59afa4440b86636c10ba31547";
SourceProperty cntr = new SourceProperty();
sources.add(cntr);
cntr.setBizId(bizId);
cntr.setBizTime(TimeUtil.getDateTime());
cntr.setBizType(bizType);
JSONObject cntrMap = new JSONObject();
cntrMap.put("TRADE_ID", "1");
cntrMap.put("CNTR_SIZE", "40");
cntrMap.put("I_E_ID", "I");
cntrMap.put("TYPE", "1");
cntr.setProperty(cntrMap);
//箱2
String bizId2 = "8f548bf59afa4440b86636c10ba31";
SourceProperty cntr2 = new SourceProperty();
sources.add(cntr2);
cntr2.setBizId(bizId2);
cntr2.setBizTime(TimeUtil.getDateTime());
cntr2.setBizType(bizType);
JSONObject cntrMap2 = new JSONObject();
cntrMap2.put("TRADE_ID", "1");
cntrMap2.put("CNTR_SIZE", "40");
cntrMap2.put("I_E_ID", "I");
cntrMap2.put("TYPE", "2");
cntr2.setProperty(cntrMap2);
reqSource.setSourceProperties(sources);
reqSource.setTenancyId("default");
reqSource.setOperMan("yxh");
reqSource.setContractId(contractId);
// reqSource.setItemId(itemIds);
reqSource.setAccountPointCode(bizType);
}
}
@@ -0,0 +1,68 @@
package com.ag.demo;
import cn.hutool.core.collection.CollUtil;
import com.ag.base.DefaultBussniessImpl;
import com.ag.demo.entity.DbErrInfo;
import com.ag.util.StrUtil;
import com.ag.util.UUIDUtil;
import com.alibaba.fastjson.JSON;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.BufferedReader;
import java.io.File;
import java.io.IOException;
import java.io.InputStreamReader;
import java.nio.file.Files;
import java.util.ArrayList;
import java.util.List;
@Service
public class DbErrInfoService {
@Autowired
private DefaultBussniessImpl bizDao;
public void execute(org.json.JSONObject orgJson, HttpServletResponse response, HttpServletRequest request) throws IOException {
List<String> data = getDataFromTxt();
data.removeIf(info -> !info.trim().startsWith("ORA-"));
List<DbErrInfo> dbs = CollUtil.list(false);
for (String info : data){
if (StrUtil.isEmpty(info)){
continue;
}
String[] arr = info.split(":");
if (arr.length != 2){
continue;
}
DbErrInfo db = new DbErrInfo();
db.setId(UUIDUtil.getUUID());
db.setErrKey(arr[0]);
db.setErrVal(arr[1]);
dbs.add(db);
}
//System.out.println(JSON.toJSONString(dbs));
bizDao.saveAll(dbs);
}
public List<String> getDataFromTxt() throws IOException {
List<String> list = new ArrayList<>();
BufferedReader br = null;
try {
File file = new File("f:\\tmp\\ora.txt");
br = new BufferedReader(new InputStreamReader(Files.newInputStream(file.toPath()), "UTF-8"));
String line;
while (null != (line=br.readLine())) {
list.add(line);
}
} catch (Exception e) {
e.printStackTrace();
} finally {
if (null != br) {
br.close();
}
}
return list;
}
}
@@ -0,0 +1,220 @@
package com.ag.demo;
import cn.hutool.core.collection.CollUtil;
import com.ag.base.BaseService;
import com.ag.base.DefaultBussniessImpl;
import com.ag.demo.entity.Student;
import com.ag.log.OperLogServcie;
import com.ag.log.UserDefineLogService;
import com.ag.log.entity.LogParam;
import com.ag.util.Base64Util;
import com.ag.util.ExcelPoiUtil;
import com.ag.util.UUIDUtil;
import com.alibaba.fastjson.JSON;
import com.opencsv.CSVWriter;
import com.wb.util.WebUtil;
import org.apache.commons.io.FileUtils;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.web.multipart.MultipartFile;
import org.springframework.web.multipart.MultipartHttpServletRequest;
import org.springframework.web.multipart.MultipartResolver;
import org.springframework.web.multipart.commons.CommonsMultipartResolver;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.File;
import java.io.IOException;
import java.net.URLEncoder;
import java.util.Base64;
import java.util.List;
/**
* Created by yangxh on 2021/5/28.
*/
@Service
public class DemoService extends BaseService {
@Autowired
private DefaultBussniessImpl bizDao;
@Autowired
private OperLogServcie logServcie;
@Autowired
private UserDefineLogService userDefineLogService;
public void testRequest(org.json.JSONObject param, HttpServletResponse response, HttpServletRequest request){
try {
WebUtil.send(response, "ok");
} catch (IOException e) {
throw new RuntimeException(e);
}
}
public void save(org.json.JSONObject param, HttpServletResponse response, HttpServletRequest request){
Student stu = JSON.parseObject(param.getString("data"), Student.class);
//Student stu = new ParamUtil<Student>().packPOJO(super.getRequestMap(request), Student.class);
stu.setsId(UUIDUtil.getUUID());
bizDao.save(stu);
try {
LogParam logParam = new LogParam(param, stu.getName(), "tstudent", "C", "data");
logParam.setMenuName("日志示例");
logParam.setPrimaryKeyColName("S_ID");
logParam.setCreateDataId(stu.getsId());
logServcie.saveLogPanel(logParam, response);
/*LogParam logParam = new LogParam(param, stu.getName(), "tstudent", "save~~~~~~~~~~~~~~~~~~");
userDefineLogService.saveLog(logParam);*/
} catch (Exception e) {
e.printStackTrace();
}
}
/**
* 单条数据修改记录日志示例
* @param param
* @param response
* @param request
*/
public void update(org.json.JSONObject param, HttpServletResponse response, HttpServletRequest request){
Student stu = JSON.parseObject(param.getString("data"), Student.class);
//super.setUpdateUser(param, stu);
//Student stu = new ParamUtil<Student>().packPOJO(super.getRequestMap(request), Student.class);
//bizDao.update(stu, "S_ID");
stu = (Student) bizDao.findById(stu, Student.class, "S_ID");
try {
LogParam logParam = new LogParam(param, stu.getName(), "tstudent", "U", "data");
logParam.setUpdate(CollUtil.newArrayList(stu));//包装更新前的原始数据
logParam.setMenuName("日志示例");
logParam.setPrimaryKeyColName("S_ID");//如果主键为ID,可不指定
logServcie.saveLogPanel(logParam, response);
/*logParam = new LogParam(param, stu.getName(), "tstudent", "update~~~~~~~~~~~~~~~~~~");
userDefineLogService.saveLog(logParam);*/
} catch (IOException e) {
e.printStackTrace();
}
}
/**
* 批量修改记录日志示例
* @param param
* @param response
* @param request
*/
public void updateAll(org.json.JSONObject param, HttpServletResponse response, HttpServletRequest request) throws IOException {
List<Student> stus = JSON.parseArray(param.getString("data"), Student.class);
//Student stu = new ParamUtil<Student>().packPOJO(super.getRequestMap(request), Student.class);
bizDao.updateAll(stus, "S_ID");
if (CollUtil.isEmpty(stus)){
return;
}
try {
LogParam logParam = new LogParam(param, stus.get(0).getName(), "tstudent", "U", "data");
logParam.setMenuName("日志示例");
logParam.setPrimaryKeyColName("S_ID");
logServcie.saveLogPanel(logParam, response);
/*logParam = new LogParam(param, stu.getName(), "tstudent", "update~~~~~~~~~~~~~~~~~~");
userDefineLogService.saveLog(logParam);*/
} catch (IOException e) {
e.printStackTrace();
}
List<String> row1 = CollUtil.newArrayList("aa", "bb", "cc", "dd");
List<String> row2 = CollUtil.newArrayList("aa1", "bb1", "cc1", "dd1");
List<List<?>> rows = CollUtil.newArrayList(row1, row2);
ExcelPoiUtil.downloadXlsx(rows, "excelName", false, response);
}
/**
* 批量删除记录日志示例
* @param param
* @param response
* @param request
*/
public void del(org.json.JSONObject param, HttpServletResponse response, HttpServletRequest request){
//Student stu = new ParamUtil<Student>().packPOJO(super.getRequestMap(request), Student.class);
List<Student> stus = JSON.parseArray(param.getString("data"), Student.class);
if (CollUtil.isEmpty(stus)){
return;
}
bizDao.deleteAll(stus, "S_ID");
try {
LogParam logParam = new LogParam(param, stus.get(0).getName(), "tstudent", "D", "data");
logParam.setMenuName("日志示例");
logParam.setPrimaryKeyColName("S_ID");
logServcie.saveLogPanel(logParam, response);
/*logParam = new LogParam(param, stu.getName(), "tstudent", "delete~~~~~~~~~~~~~~~~~~");
userDefineLogService.saveLog(logParam);*/
} catch (IOException e) {
e.printStackTrace();
}
}
public void upload(org.json.JSONObject param, HttpServletResponse response, HttpServletRequest request){
MultipartHttpServletRequest multipartRequest=(MultipartHttpServletRequest)request;
MultipartFile file = multipartRequest.getFile("fileName");//file是页面input的name名
String basePath = "e:/upload";
try {
MultipartResolver resolver = new CommonsMultipartResolver(request.getSession().getServletContext());
if (resolver.isMultipart(request)) {
//随机生成文件名
String randomName = UUIDUtil.getUUID().substring(10);
String uploadFileName = file.getOriginalFilename();
if (StringUtils.isNotBlank(uploadFileName)) {
//截取文件格式名
String suffix = uploadFileName.substring(uploadFileName.indexOf("."));
//重新拼装文件名
String newFileName = randomName + suffix;
String savePath = basePath + "/" + newFileName;
File saveFile = new File(savePath);
File parentFile = saveFile.getParentFile();
if (saveFile.exists()) {
saveFile.delete();
} else {
if (!parentFile.exists()) {
parentFile.mkdirs();
}
}
//复制文件到指定路径
FileUtils.copyInputStreamToFile(file.getInputStream(), saveFile);
}
}
} catch (Exception e) {
e.printStackTrace();
}
}
public void download(org.json.JSONObject param, HttpServletResponse response, HttpServletRequest request) throws IOException {
String[] row1 = new String[]{"aa", "bb", "cc", "dd"};
String[] row2 = new String[]{"aa1", "bb1", "cc1", "dd1"};
List<String[]> rows = CollUtil.newArrayList(row1, row2);
response.reset();
response.setContentType("application/octet-stream");
response.setCharacterEncoding("utf-8");
String fileName = URLEncoder.encode("测试", "UTF-8").replaceAll("\\+", "%20");
response.setHeader("Content-disposition", "attachment;filename="+fileName+".csv");
// response.setHeader("Content-disposition", "attachment;filename=test.csv");
//CsvUtil.writeToCsv(response.getWriter(), rows);
CSVWriter csvWriter = new CSVWriter(response.getWriter());
csvWriter.writeAll(rows);
csvWriter.flush();
}
public static void main(String[] args) {
/*int level = 0, split = 0;
for (int i=0; i<500; i++ ){
split += 20;
level += split;
System.out.println("等级"+(i+1)+"==exp=="+split+"==total exp=="+level);
}*/
String str = "海邦国际 or 1=1";
String encode = Base64Util.encode(str);
System.out.println(encode);
String decode = Base64Util.decode(encode);
System.out.println(decode);
}
}
@@ -0,0 +1,85 @@
package com.ag.demo;
import cn.hutool.core.collection.CollUtil;
import cn.hutool.core.convert.Convert;
import com.ag.util.StrUtil;
import com.alibaba.fastjson.JSON;
import org.apache.pdfbox.multipdf.Splitter;
import org.apache.pdfbox.pdmodel.PDDocument;
import org.apache.pdfbox.text.PDFTextStripper;
import org.junit.Test;
import java.io.File;
import java.io.IOException;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;
public class PdfSplitService {
String sourcePath = "F:\\pdfsplit\\MDB1R981_678692.pdf";
String targetPath = "F:\\pdfsplit\\";
@Test
public void getPdfTextByPages() throws IOException {
PDDocument document = PDDocument.load(new File(sourcePath));
document.setAllSecurityToBeRemoved(true);
PDFTextStripper stripper = new PDFTextStripper();
stripper.setSortByPosition(true);
List<List<String>> txts = CollUtil.list(false);
for(int i = 1; i <= document.getNumberOfPages() ; i++) {
stripper.setStartPage(i);
stripper.setEndPage(i);
String text = stripper.getText(document);
if(!StrUtil.isEmpty(text)){
List<String> rows = CollUtil.list(false);
String[] arrs = text.split("\\r\\n");
for (String row : arrs){
if (!StrUtil.isEmpty(row.trim())){
rows.add(row);
}
}
txts.add(rows);
}
}
Map<String, String> map = new LinkedHashMap<>();
String billNo = "";
for (int i=0; i<txts.size(); i++){
List<String> txt = txts.get(i);
boolean hasNumber = false;
for (String row : txt){
if(StrUtil.isNumeric(row.trim())){
System.out.println(row);
hasNumber = true;
billNo = row.trim();
break;
}
}
if (hasNumber){
map.put(billNo, i+"_"+i);
}else {
map.put(billNo, (i-1)+"_"+i);
}
//System.out.println("page:~~~~~~~~~~~~~~~~"+(i+1));
}
System.out.println(JSON.toJSONString(map));
Splitter splitter = new Splitter();
for (Map.Entry<String, String> entry : map.entrySet()) {
String val = entry.getValue();
int start = Convert.toInt(val.split("_")[0])+1;
int end = Convert.toInt(val.split("_")[1])+1;
splitter.setStartPage(start);
splitter.setEndPage(end);
splitter.setSplitAtPage(end-start+1);
List<PDDocument> pages = splitter.split(document);
for (PDDocument pd : pages) {
String pdfName = targetPath + entry.getKey() + ".pdf";
pd.save(pdfName);
}
}
}
}
@@ -0,0 +1,51 @@
package com.ag.demo;
import com.ag.base.BaseService;
import com.ag.base.DefaultBussniessImpl;
import com.ag.demo.entity.QrcodeInfo;
import com.ag.util.UUIDUtil;
import com.alibaba.fastjson.JSON;
import com.wb.util.WebUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
/**
* Created by yangxh on 2022/3/24.
*/
@Service
public class QRCodeDemo extends BaseService {
@Autowired
private DefaultBussniessImpl bizDao;
public void saveQrInfo(org.json.JSONObject reqParam, HttpServletResponse response, HttpServletRequest request){
QrcodeInfo info = new QrcodeInfo();
info.setId(UUIDUtil.getUUID());
info.setTitle(reqParam.getString("DESCRIPTION"));
info.setContext(reqParam.getString("NOTES"));
info.setKeyword(reqParam.getString("keyword"));
info.setUrl("http://localhost:7002/m?xwl=agtesth/tstudent");
super.setSaveUser(reqParam, info);
bizDao.save(info);
try {
WebUtil.send(response, info.getId());
} catch (IOException e) {
e.printStackTrace();
}
}
public void findQrInfo(org.json.JSONObject reqParam, HttpServletResponse response, HttpServletRequest request){
QrcodeInfo info = new QrcodeInfo();
info.setId(reqParam.getString("id"));
info = (QrcodeInfo)bizDao.findById(info, QrcodeInfo.class, "ID");
try {
WebUtil.send(response, JSON.toJSONString(info));
} catch (IOException e) {
e.printStackTrace();
}
}
}
@@ -0,0 +1,36 @@
package com.ag.demo;
import cloud.tianai.captcha.common.constant.CaptchaTypeConstant;
import cloud.tianai.captcha.generator.ImageCaptchaGenerator;
import cloud.tianai.captcha.generator.common.model.dto.ImageCaptchaInfo;
import cloud.tianai.captcha.generator.impl.MultiImageCaptchaGenerator;
import cloud.tianai.captcha.resource.ImageCaptchaResourceManager;
import cloud.tianai.captcha.resource.impl.DefaultImageCaptchaResourceManager;
import cloud.tianai.captcha.validator.ImageCaptchaValidator;
import cloud.tianai.captcha.validator.impl.BasicCaptchaTrackValidator;
import java.util.Map;
public class TianaiDemo {
public static void main(String[] args) throws InterruptedException {
ImageCaptchaResourceManager imageCaptchaResourceManager = new DefaultImageCaptchaResourceManager();
ImageCaptchaGenerator imageCaptchaGenerator = new MultiImageCaptchaGenerator(imageCaptchaResourceManager).init(true);
/*
生成滑块验证码图片, 可选项
SLIDER (滑块验证码)
ROTATE (旋转验证码)
CONCAT (滑动还原验证码)
WORD_IMAGE_CLICK (文字点选验证码)
更多验证码支持 详见 cloud.tianai.captcha.common.constant.CaptchaTypeConstant
*/
ImageCaptchaInfo imageCaptchaInfo = imageCaptchaGenerator.generateCaptchaImage(CaptchaTypeConstant.SLIDER);
System.out.println(imageCaptchaInfo);
// 负责计算一些数据存到缓存中,用于校验使用
// ImageCaptchaValidator负责校验用户滑动滑块是否正确和生成滑块的一些校验数据; 比如滑块到凹槽的百分比值
ImageCaptchaValidator imageCaptchaValidator = new BasicCaptchaTrackValidator();
// 这个map数据应该存到缓存中,校验的时候需要用到该数据
Map<String, Object> map = imageCaptchaValidator.generateImageCaptchaValidData(imageCaptchaInfo);
}
}
@@ -0,0 +1,22 @@
package com.ag.demo;
import cn.hutool.core.date.DateUtil;
import org.springframework.stereotype.Component;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
/**
* Created by yangxh on 2021/8/24.
*/
@Component
public class TimerDemo {
public void run01(org.json.JSONObject param, HttpServletResponse response, HttpServletRequest request){
System.out.println("run01->"+ DateUtil.date());
}
public void run02(org.json.JSONObject param, HttpServletResponse response, HttpServletRequest request){
System.out.println("run02->"+ DateUtil.date());
}
}
@@ -0,0 +1,46 @@
package com.ag.demo.entity;
import java.io.Serializable;
/**
* 数据库异常信息表(DbErrInfo)实体类
*
* @author makejava
* @since 2023-08-30 09:23:59
*/
public class DbErrInfo implements Serializable {
private static final long serialVersionUID = -86680968759505516L;
private String id;
private String errKey;
private String errVal;
public String getId() {
return id;
}
public void setId(String id) {
this.id = id;
}
public String getErrKey() {
return errKey;
}
public void setErrKey(String errKey) {
this.errKey = errKey;
}
public String getErrVal() {
return errVal;
}
public void setErrVal(String errVal) {
this.errVal = errVal;
}
}
@@ -0,0 +1,82 @@
package com.ag.demo.entity;
import com.ag.base.ISerializable;
import java.util.Date;
public class QrcodeInfo implements ISerializable{
private String id;
private String url;
private String title;
private String context;
private String append;
private String createdBy;
private java.util.Date createdOn;
private String keyword;
public String getId() {
return id;
}
public void setId(String id) {
this.id = id;
}
public String getUrl() {
return url;
}
public void setUrl(String url) {
this.url = url;
}
public String getTitle() {
return title;
}
public void setTitle(String title) {
this.title = title;
}
public String getContext() {
return context;
}
public void setContext(String context) {
this.context = context;
}
public String getAppend() {
return append;
}
public void setAppend(String append) {
this.append = append;
}
public String getCreatedBy() {
return createdBy;
}
public void setCreatedBy(String createdBy) {
this.createdBy = createdBy;
}
public Date getCreatedOn() {
return createdOn;
}
public void setCreatedOn(Date createdOn) {
this.createdOn = createdOn;
}
public String getKeyword() {
return keyword;
}
public void setKeyword(String keyword) {
this.keyword = keyword;
}
}
@@ -0,0 +1,100 @@
package com.ag.demo.entity;
import com.ag.base.ISerializable;
import java.io.Serializable;
import java.math.BigDecimal;
import java.util.Date;
/**
* Created by yangxh on 2021/5/28.
*/
public class Student implements ISerializable {
private String sId;
private String name;
private String sex;
private BigDecimal age;
private String tenancyId;
private String createdBy;
private Date createdOn;
private String updatedBy;
private Date updatedOn;
public String getsId() {
return sId;
}
public void setsId(String sId) {
this.sId = sId;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public String getSex() {
return sex;
}
public void setSex(String sex) {
this.sex = sex;
}
public BigDecimal getAge() {
return age;
}
public void setAge(BigDecimal age) {
this.age = age;
}
public String getTenancyId() {
return tenancyId;
}
@Override
public void setTenancyId(String tenancyId) {
this.tenancyId = tenancyId;
}
public String getCreatedBy() {
return createdBy;
}
@Override
public void setCreatedBy(String createdBy) {
this.createdBy = createdBy;
}
public Date getCreatedOn() {
return createdOn;
}
@Override
public void setCreatedOn(Date createdOn) {
this.createdOn = createdOn;
}
public String getUpdatedBy() {
return updatedBy;
}
@Override
public void setUpdatedBy(String updatedBy) {
this.updatedBy = updatedBy;
}
public Date getUpdatedOn() {
return updatedOn;
}
@Override
public void setUpdatedOn(Date updatedOn) {
this.updatedOn = updatedOn;
}
}
@@ -0,0 +1,86 @@
package com.ag.demo.entity;
import java.io.Serializable;
/**
* 用户密码配置表(UserPwdConfig)实体类
*
* @author makejava
* @since 2023-07-21 14:27:08
*/
public class UserPwdConfig implements Serializable {
private static final long serialVersionUID = 648348505038393449L;
private String id;
/**
* 密码长度
*/
private Integer pwdLength;
/**
* 是否包含数字(0=否,1=是)
*/
private Integer containsNum;
/**
* 是否包含大写字符(0=否,1=是)
*/
private Integer containsUppchar;
/**
* 是否包含小写字符(0=否,1=是)
*/
private Integer containsLowchar;
/**
* 是否包含特殊字符(0=否,1=是)
*/
private Integer containsSpechar;
public String getId() {
return id;
}
public void setId(String id) {
this.id = id;
}
public Integer getPwdLength() {
return pwdLength;
}
public void setPwdLength(Integer pwdLength) {
this.pwdLength = pwdLength;
}
public Integer getContainsNum() {
return containsNum;
}
public void setContainsNum(Integer containsNum) {
this.containsNum = containsNum;
}
public Integer getContainsUppchar() {
return containsUppchar;
}
public void setContainsUppchar(Integer containsUppchar) {
this.containsUppchar = containsUppchar;
}
public Integer getContainsLowchar() {
return containsLowchar;
}
public void setContainsLowchar(Integer containsLowchar) {
this.containsLowchar = containsLowchar;
}
public Integer getContainsSpechar() {
return containsSpechar;
}
public void setContainsSpechar(Integer containsSpechar) {
this.containsSpechar = containsSpechar;
}
}
@@ -0,0 +1,99 @@
package com.ag.demo.entity;
import com.ag.base.ISerializable;
import java.util.Date;
public class WFile implements ISerializable {
private static final long serialVersionUID = 981068428519373366L;
private String id;
/**
* 业务类型
*/
private String tName;
/**
* 业务表主键
*/
private String tId;
/**
* 原始文件名
*/
private String fName;
/**
* 保存路径
*/
private String fPath;
private String createdBy;
private Date createdOn;
private String tenancyId;
public String getId() {
return id;
}
public void setId(String id) {
this.id = id;
}
public String getTName() {
return tName;
}
public void setTName(String tName) {
this.tName = tName;
}
public String getTId() {
return tId;
}
public void setTId(String tId) {
this.tId = tId;
}
public String getFName() {
return fName;
}
public void setFName(String fName) {
this.fName = fName;
}
public String getFPath() {
return fPath;
}
public void setFPath(String fPath) {
this.fPath = fPath;
}
public String getCreatedBy() {
return createdBy;
}
public void setCreatedBy(String createdBy) {
this.createdBy = createdBy;
}
public Date getCreatedOn() {
return createdOn;
}
public void setCreatedOn(Date createdOn) {
this.createdOn = createdOn;
}
public String getTenancyId() {
return tenancyId;
}
public void setTenancyId(String tenancyId) {
this.tenancyId = tenancyId;
}
}
@@ -0,0 +1,12 @@
package com.ag.demo.face;
public interface IParament {
String bizType = "bizType";
String bizId = "bizId";
String fileId = "fileId";
String fileName = "fileId__name";
String tmpPath = "/static";//外部路径
String sysPath = "/upload";//系统路径,webapp下
// String basePath = "d:";
}
@@ -0,0 +1,20 @@
package com.ag.demo.mapper;
import com.ag.demo.pojo.Student;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import org.apache.ibatis.annotations.Mapper;
/**
* @author fengjun
* @description 针对表【student】的数据库操作Mapper
* @createDate 2022-04-15 15:04:30
* @Entity com.ag.demo.pojo.Student
*/
@Mapper
public interface StudentMapper extends BaseMapper<Student> {
}
@@ -0,0 +1,293 @@
package com.ag.demo.pojo;
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import java.io.Serializable;
import java.util.Date;
/**
*
* @TableName student
*/
@TableName(value ="student")
public class Student implements Serializable {
/**
*
*/
@TableId
private String sId;
/**
*
*/
private String name;
/**
*
*/
private String sex;
/**
*
*/
private Integer age;
/**
*
*/
private String cId;
/**
*
*/
private String tId;
/**
*
*/
private String subId;
/**
*
*/
private String createdBy;
/**
*
*/
private Date createdOn;
/**
*
*/
private String updatedBy;
/**
*
*/
private Date updatedOn;
@TableField(exist = false)
private static final long serialVersionUID = 1L;
/**
*
*/
public String getsId() {
return sId;
}
/**
*
*/
public void setsId(String sId) {
this.sId = sId;
}
/**
*
*/
public String getName() {
return name;
}
/**
*
*/
public void setName(String name) {
this.name = name;
}
/**
*
*/
public String getSex() {
return sex;
}
/**
*
*/
public void setSex(String sex) {
this.sex = sex;
}
/**
*
*/
public Integer getAge() {
return age;
}
/**
*
*/
public void setAge(Integer age) {
this.age = age;
}
/**
*
*/
public String getcId() {
return cId;
}
/**
*
*/
public void setcId(String cId) {
this.cId = cId;
}
/**
*
*/
public String gettId() {
return tId;
}
/**
*
*/
public void settId(String tId) {
this.tId = tId;
}
/**
*
*/
public String getSubId() {
return subId;
}
/**
*
*/
public void setSubId(String subId) {
this.subId = subId;
}
/**
*
*/
public String getCreatedBy() {
return createdBy;
}
/**
*
*/
public void setCreatedBy(String createdBy) {
this.createdBy = createdBy;
}
/**
*
*/
public Date getCreatedOn() {
return createdOn;
}
/**
*
*/
public void setCreatedOn(Date createdOn) {
this.createdOn = createdOn;
}
/**
*
*/
public String getUpdatedBy() {
return updatedBy;
}
/**
*
*/
public void setUpdatedBy(String updatedBy) {
this.updatedBy = updatedBy;
}
/**
*
*/
public Date getUpdatedOn() {
return updatedOn;
}
/**
*
*/
public void setUpdatedOn(Date updatedOn) {
this.updatedOn = updatedOn;
}
@Override
public boolean equals(Object that) {
if (this == that) {
return true;
}
if (that == null) {
return false;
}
if (getClass() != that.getClass()) {
return false;
}
Student other = (Student) that;
return (this.getsId() == null ? other.getsId() == null : this.getsId().equals(other.getsId()))
&& (this.getName() == null ? other.getName() == null : this.getName().equals(other.getName()))
&& (this.getSex() == null ? other.getSex() == null : this.getSex().equals(other.getSex()))
&& (this.getAge() == null ? other.getAge() == null : this.getAge().equals(other.getAge()))
&& (this.getcId() == null ? other.getcId() == null : this.getcId().equals(other.getcId()))
&& (this.gettId() == null ? other.gettId() == null : this.gettId().equals(other.gettId()))
&& (this.getSubId() == null ? other.getSubId() == null : this.getSubId().equals(other.getSubId()))
&& (this.getCreatedBy() == null ? other.getCreatedBy() == null : this.getCreatedBy().equals(other.getCreatedBy()))
&& (this.getCreatedOn() == null ? other.getCreatedOn() == null : this.getCreatedOn().equals(other.getCreatedOn()))
&& (this.getUpdatedBy() == null ? other.getUpdatedBy() == null : this.getUpdatedBy().equals(other.getUpdatedBy()))
&& (this.getUpdatedOn() == null ? other.getUpdatedOn() == null : this.getUpdatedOn().equals(other.getUpdatedOn()));
}
@Override
public int hashCode() {
final int prime = 31;
int result = 1;
result = prime * result + ((getsId() == null) ? 0 : getsId().hashCode());
result = prime * result + ((getName() == null) ? 0 : getName().hashCode());
result = prime * result + ((getSex() == null) ? 0 : getSex().hashCode());
result = prime * result + ((getAge() == null) ? 0 : getAge().hashCode());
result = prime * result + ((getcId() == null) ? 0 : getcId().hashCode());
result = prime * result + ((gettId() == null) ? 0 : gettId().hashCode());
result = prime * result + ((getSubId() == null) ? 0 : getSubId().hashCode());
result = prime * result + ((getCreatedBy() == null) ? 0 : getCreatedBy().hashCode());
result = prime * result + ((getCreatedOn() == null) ? 0 : getCreatedOn().hashCode());
result = prime * result + ((getUpdatedBy() == null) ? 0 : getUpdatedBy().hashCode());
result = prime * result + ((getUpdatedOn() == null) ? 0 : getUpdatedOn().hashCode());
return result;
}
@Override
public String toString() {
StringBuilder sb = new StringBuilder();
sb.append(getClass().getSimpleName());
sb.append(" [");
sb.append("Hash = ").append(hashCode());
sb.append(", sId=").append(sId);
sb.append(", name=").append(name);
sb.append(", sex=").append(sex);
sb.append(", age=").append(age);
sb.append(", cId=").append(cId);
sb.append(", tId=").append(tId);
sb.append(", subId=").append(subId);
sb.append(", createdBy=").append(createdBy);
sb.append(", createdOn=").append(createdOn);
sb.append(", updatedBy=").append(updatedBy);
sb.append(", updatedOn=").append(updatedOn);
sb.append(", serialVersionUID=").append(serialVersionUID);
sb.append("]");
return sb.toString();
}
}
@@ -0,0 +1,4 @@
package com.ag.demo.service;
public class ExcelDemoService {
}
@@ -0,0 +1,100 @@
package com.ag.demo.service;
import cn.hutool.core.collection.CollUtil;
import cn.hutool.core.date.DateUtil;
import cn.hutool.core.io.FileUtil;
import cn.hutool.core.lang.Assert;
import com.ag.base.BaseService;
import com.ag.base.DefaultBussniessImpl;
import com.ag.demo.entity.WFile;
import com.ag.demo.face.IParament;
import com.ag.util.StrUtil;
import org.apache.commons.io.IOUtils;
import org.json.JSONObject;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
@Service
public class FileUploadService extends BaseService {
@Autowired
private DefaultBussniessImpl bizDao;
@Transactional
public List<WFile> uploadAg(JSONObject param, HttpServletResponse response, HttpServletRequest request) throws IOException {
Assert.isTrue(!StrUtil.isEmpty(super.getTenancyId(param)), "非法的上传文件请求!");
Map<String, InputStream> inputMap = new HashMap<>();
for(Map.Entry<String, Object> entry : param.entrySet()){
if (entry.getValue() instanceof InputStream && param.has(entry.getKey()+"__name")){
inputMap.put(param.getString(entry.getKey()+"__name"), (InputStream)entry.getValue());
}
}
List<WFile> saveList = CollUtil.list(false);
long time = System.currentTimeMillis();
int index = 0;
for(Map.Entry<String, InputStream> entry : inputMap.entrySet()){
String saveName = time+"_"+index;
WFile wFile = new WFile();
execute(param, wFile, entry.getKey(), entry.getValue(), saveName);
saveList.add(wFile);
index++;
}
bizDao.saveAll(saveList);
return saveList;
//WebUtil.send(response, "1111");
}
private void execute(org.json.JSONObject param, WFile wFile, String oriName, InputStream input,String realName) throws IOException{
super.setSaveUser(param, wFile);
wFile.setFName(oriName);
wFile.setTName(param.getString(IParament.bizType));
wFile.setTId(param.getString(IParament.bizId));
Assert.isTrue(StrUtil.indexOf(oriName, ".") > 0, "文件格式异常!");
//文件类型
String postfix = StrUtil.substringAfterLast(oriName, ".");
Assert.isTrue(!StrUtil.equalsAnyIgnoreCase(postfix, "asp","aspx","php","jsp"), "非法的文件类型");
/*String path = StrUtil.join(IParament.basePath, "/", wFile.getTenancyId(), "/",
DateUtil.year(super.getNow()), "/", DateUtil.month(super.getNow()), "/",
realName, ".", postfix);*/
String path = getSysPath(param, realName, postfix, wFile.getTenancyId());
wFile.setFPath(path);
OutputStream output = FileUtil.getOutputStream(path);
IOUtils.copy(input, output);
output.close();
input.close();
}
private String getSysPath(org.json.JSONObject param, String realName, String postfix, String tenancyId){
String path = "";
if (param.has("pathType") && StrUtil.equals(param.getString("pathType"), "system")){
path = StrUtil.join(IParament.sysPath, "/",
DateUtil.year(super.getNow()), "/", DateUtil.month(super.getNow())+1, "/",
realName, ".", postfix);
}else {
path = StrUtil.join(IParament.tmpPath, "/", tenancyId, "/",
DateUtil.year(super.getNow()), "/", DateUtil.month(super.getNow()), "/",
realName, ".", postfix);
}
return path;
}
/*public static void main(String[] args) throws IOException {
String oriPath = "D:\\ag_note\\中山\\专票资料(最新).txt";
InputStream input = FileUtil.getInputStream(oriPath);
//FileUtil.touch()
OutputStream output = FileUtil.getOutputStream("e:\\ag_note\\中山\\专票资料(最新).txt");
IOUtils.copy(input, output);
output.close();
input.close();
}*/
}
@@ -0,0 +1,50 @@
package com.ag.demo.service;
import cn.hutool.core.collection.CollUtil;
import com.ag.base.DefaultBussniessImpl;
import com.ag.demo.entity.UserPwdConfig;
import com.ag.util.PwdCheckUtil;
import com.ag.util.StrUtil;
import org.json.JSONObject;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.util.Assert;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.util.List;
@Service
public class PwdCheckService {
@Autowired
private DefaultBussniessImpl bizDao;
public void execute(JSONObject param, HttpServletResponse response, HttpServletRequest request){
String pwd = param.getString("pwd");
if (StrUtil.equals(pwd, "******")){
return;
}
List<UserPwdConfig> configList = bizDao.findAll(UserPwdConfig.class);
if (CollUtil.isEmpty(configList)){
return;
}
UserPwdConfig config = configList.get(0);
if (config.getPwdLength() > 0){
Assert.isTrue(pwd.length() >= config.getPwdLength(), "密码长度不得小于"+config.getPwdLength()+"位");
}
if (config.getContainsNum() == 1){
Assert.isTrue(PwdCheckUtil.isContainsNum(pwd), "密码必须包含数字!");
}
if (config.getContainsUppchar() == 1){
Assert.isTrue(PwdCheckUtil.isContainsUppChar(pwd), "密码必须包含大写字符!");
}
if (config.getContainsLowchar() == 1){
Assert.isTrue(PwdCheckUtil.isContainsLowChar(pwd), "密码必须包含小写字符!");
}
if (config.getContainsSpechar() == 1){
Assert.isTrue(PwdCheckUtil.isContainsSpeChar(pwd), "密码必须包含特殊字符!");
}
}
}
@@ -0,0 +1,13 @@
package com.ag.demo.service;
import com.ag.demo.pojo.Student;
import com.baomidou.mybatisplus.extension.service.IService;
/**
* @author fengjun
* @description 针对表【student】的数据库操作Service
* @createDate 2022-04-15 15:04:30
*/
public interface StudentService extends IService<Student> {
}
@@ -0,0 +1,22 @@
package com.ag.demo.service.impl;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.ag.demo.pojo.Student;
import com.ag.demo.service.StudentService;
import com.ag.demo.mapper.StudentMapper;
import org.springframework.stereotype.Service;
/**
* @author fengjun
* @description 针对表【student】的数据库操作Service实现
* @createDate 2022-04-15 15:04:30
*/
@Service
public class StudentServiceImpl extends ServiceImpl<StudentMapper, Student>
implements StudentService{
}