Commit 86e5661d by 唐功亮

1【修改】 增加文件类型和大小判断

2【修改】 厂商认证时的 企业名称重复校验
3【新增】 统一社会信用代码验证
parent 093c66b2
......@@ -45,4 +45,13 @@ public interface TycpdmFirmDao extends BaseMapper<TycpdmFirmEntity> {
String returnFileUrl(Map name);
TycpdmFirmEntity findFirmInfoXT(String username);
@Select("select count(1) from tycpdm_firm where firmName=#{firmname} and logout_flag=1")
int selectByIdFirmNameSC(@Param("firmname") String firmname);
@Select("select count(1) from firm where firm_name=#{firmname} and (logout_flag=2 or logout_flag=0)")
int selectByIdFirmNameXTSC(@Param("firmname")String firmname);
@Select("select count(1) from tycpdm_firm where firmName=#{firmname} and logout_flag=1 and f_id<>#{fId}")
int selectByIdFirmNameBG(@Param("firmname")String firmname, @Param("fId")Integer fId);
}
......@@ -65,6 +65,9 @@ public class TycpdmFirmChangeServiceImpl extends ServiceImpl<TycpdmFirmChangeDao
}
String fileName = file.getOriginalFilename();
String substring = fileName.substring(fileName.lastIndexOf("."));//文件后缀
if (!(substring.equals(".png")||substring.equals(".bmp")||substring.equals(".jpg"))){
throw new RRException("文件类型不正确,支持png,bmp,jpg格式");
}
String uuid = UUID.randomUUID().toString().replaceAll("-", "");
File dest = new File(uploadFileQY + uuid+substring);
try {
......
......@@ -6,6 +6,7 @@ import io.office.common.exception.RRException;
import io.office.modules.manage.dao.*;
import io.office.modules.manage.entity.*;
import io.office.modules.manage.service.TycpdmFirmChangeService;
import io.office.modules.manage.utils.AlgorithmUtils;
import io.office.modules.manage.utils.DESUtils;
import io.office.modules.manage.utils.DateUtils;
import io.office.modules.manage.utils.MD5Util;
......@@ -162,6 +163,8 @@ public class TycpdmFirmServiceImpl extends ServiceImpl<TycpdmFirmDao, TycpdmFirm
if (file.isEmpty()) {
throw new RRException("上传失败,请选择文件");
}
String contentType = file.getContentType();
System.out.println(contentType);
File dir = new File(uploadFileQY);
if (!dir.exists()){
boolean mkdirs = dir.mkdirs();
......@@ -169,6 +172,9 @@ public class TycpdmFirmServiceImpl extends ServiceImpl<TycpdmFirmDao, TycpdmFirm
}
String fileName = file.getOriginalFilename();
String substring = fileName.substring(fileName.lastIndexOf("."));//文件后缀
if (!(substring.equals(".png")||substring.equals(".bmp")||substring.equals(".jpg"))){
throw new RRException("文件类型不正确,支持png,bmp,jpg格式");
}
String uuid = UUID.randomUUID().toString().replaceAll("-", "");
File dest = new File(uploadFileQY + uuid+substring);
try {
......@@ -211,6 +217,14 @@ public class TycpdmFirmServiceImpl extends ServiceImpl<TycpdmFirmDao, TycpdmFirm
String fileName = file.getOriginalFilename();
String substring = fileName.substring(fileName.lastIndexOf("."));//文件后缀
String uuid = UUID.randomUUID().toString().replaceAll("-", "");
if (file.getSize()>3145728){
System.out.println("文件大小:"+file.getSize());
throw new RRException("文件大小不得超过3M");
}
if (!(substring.equals(".png")||substring.equals(".bmp")||substring.equals(".jpg"))){
throw new RRException("文件类型不正确,支持png,bmp,jpg格式");
}
File dest = new File(uploadFileQYOne + uuid+substring);
try {
file.transferTo(dest);
......@@ -305,7 +319,10 @@ public class TycpdmFirmServiceImpl extends ServiceImpl<TycpdmFirmDao, TycpdmFirm
TycpdmFirmEntity tycpdmFirm = new TycpdmFirmEntity();
TycpdmFirmChangeEntity tycpdmFirmChangeEntity = new TycpdmFirmChangeEntity();
Integer status = body.get("status")==null?0:Integer.valueOf(String.valueOf(body.get("status")));
Object certificateCode = body.get("certificatecode");//填统一社会信用代码
if (!AlgorithmUtils.checkUSCC(certificateCode.toString())){
throw new RRException("统一社会信用代码验证失败");
}
//写入死值
body.put("useddesc","企业产品描述信息");
body.put("wishusednum",100);
......@@ -322,9 +339,13 @@ public class TycpdmFirmServiceImpl extends ServiceImpl<TycpdmFirmDao, TycpdmFirm
if (firmname==null||"".equals(tycpdmFirm)){
throw new RRException("企业名称不能为空");
}
int count=tycpdmFirmDao.selectByIdFirmName(firmname,1,userName);
int count=tycpdmFirmDao.selectByIdFirmNameSC(firmname);
int countXT=tycpdmFirmDao.selectByIdFirmNameXTSC(firmname);
if (count>0){
throw new RRException("企业名称已经存在");
throw new RRException("厂商名称已重复");
}
if (countXT>0){
throw new RRException(" 厂商已为系统成员,请使用条码卡账号登录,无需再次实名认证!");
}
Integer fid = body.get("fid")==null?0:Integer.valueOf(String.valueOf(body.get("fid")));
tycpdmFirm.setFId(fid);
......@@ -339,7 +360,18 @@ public class TycpdmFirmServiceImpl extends ServiceImpl<TycpdmFirmDao, TycpdmFirm
TycpdmFirmEntity userName1 = tycpdmFirmDao.findUserName(userName);
Integer logoutFlag = userName1.getLogoutFlag();
if (logoutFlag==null||logoutFlag==-1){
//修改 信息
updateById(tycpdmFirm);
//删除旧文件
if (!tycpdmFirm.getFirmbusinesslicensefile().equals("")||tycpdmFirm.getFirmbusinesslicensefile()!=null){
if (!userName1.getFirmbusinesslicensefile().equals(tycpdmFirm.getFirmbusinesslicensefile())){
File file = new File(userName1.getFirmbusinesslicensefile());
if (file.exists()){
file.delete();
}
}
}
id=fId;
}else if (logoutFlag==0){
throw new RRException("信息已提交,等待管理员审核!");
......@@ -372,10 +404,17 @@ public class TycpdmFirmServiceImpl extends ServiceImpl<TycpdmFirmDao, TycpdmFirm
if (firmname==null||"".equals(tycpdmFirm)){
throw new RRException("企业名称不能为空");
}
int count=tycpdmFirmDao.selectByIdFirmName(firmname,1,userName);
int count=tycpdmFirmDao.selectByIdFirmNameBG(firmname,fId);
if (count>0){
throw new RRException("企业名称已经存在");
}
int countXT=tycpdmFirmDao.selectByIdFirmNameXTSC(firmname);
if (count>0){
throw new RRException("企业名称已经存在");
}
if (countXT>0){
throw new RRException("厂商已为系统成员,请使用条码卡账号登录,无需再次实名认证!");
}
tycpdmFirmChangeEntity.setFId(fId);
if (type==1){
......@@ -393,6 +432,15 @@ public class TycpdmFirmServiceImpl extends ServiceImpl<TycpdmFirmDao, TycpdmFirm
if (logoutFlag==null||logoutFlag==-1){
tycpdmFirmChangeService.updateById(tycpdmFirmChangeEntity);
id= tycpdmFirmChangeEntity.getId();
//删除旧文件
if (!tycpdmFirmChangeEntity.getFirmbusinesslicensefile().equals("")||tycpdmFirmChangeEntity.getFirmbusinesslicensefile()!=null){
if (!tycpdmFirmChangeEntity1.getFirmbusinesslicensefile().equals(tycpdmFirmChangeEntity.getFirmbusinesslicensefile())){
File file = new File(tycpdmFirmChangeEntity1.getFirmbusinesslicensefile());
if (file.exists()){
file.delete();
}
}
}
}else if (logoutFlag==0){
throw new RRException("信息已提交,等待管理员审核!");
}else if (logoutFlag==1){
......@@ -402,6 +450,15 @@ public class TycpdmFirmServiceImpl extends ServiceImpl<TycpdmFirmDao, TycpdmFirm
}else if (logoutFlag==2){
tycpdmFirmChangeService.updateById(tycpdmFirmChangeEntity);
id= tycpdmFirmChangeEntity.getId();
//删除旧文件
if (!tycpdmFirmChangeEntity.getFirmbusinesslicensefile().equals("")||tycpdmFirmChangeEntity.getFirmbusinesslicensefile()!=null){
if (!tycpdmFirmChangeEntity1.getFirmbusinesslicensefile().equals(tycpdmFirmChangeEntity.getFirmbusinesslicensefile())){
File file = new File(tycpdmFirmChangeEntity1.getFirmbusinesslicensefile());
if (file.exists()){
file.delete();
}
}
}
}
}
......@@ -466,7 +523,11 @@ public class TycpdmFirmServiceImpl extends ServiceImpl<TycpdmFirmDao, TycpdmFirm
filePath = tycpdmFirmChangeEntity.getFirmArchivesfile();
}
}
if (filePath==null){
return "不存在";
}
File file = new File(filePath);
if (!file.exists()){
return "不存在";
}
......
package io.office.modules.manage.utils;
//组织机构代码校验
public class AlgorithmUtils {
public static void main(String[] args) {
String test[]= {"91310000729391077Q","51420000MJH200408C","52420000MJH233410E",
"51420000MJH200395N","51420000MJH2003791","53420000MJH2448303",
"52420000MJH233402K","52420000MJH2333813","52420000MJH23339XT",
"51420000MJH200387U"};
for(int i=0;i<10;i++)
{
if(checkUSCC(test[i]))
System.out.println("验证通过");
else
System.out.println("验证失败");
}
}
/*
[函数名]checkUSCC
[功能]校验18位统一社会信用代码正确性
[参数]testUSCC:待校验的统一社会信用代码(要求字母已经保持大写)
[返回值]boolean类型,0(false)表示验证未通过,1(true)表示验证通过
*/
public static boolean checkUSCC(String testUSCC)
{
if(testUSCC.length()!=18)
{
System.out.println("统一社会信用代码长度错误");
return false;
}
int Weight[]= {1,3,9,27,19,26,16,17,20,29,25,13,8,24,10,30,28}; //用于存放权值
int index=0; //用于计算当前判断的统一社会信用代码位数
char testc; //用于存放当前位的统一社会信用代码
int tempSum=0; //用于存放代码字符和加权因子乘积之和
int tempNum=0;
for(index=0;index<=16;index++)
{
testc=testUSCC.charAt(index);
if(index==0)
{
if(testc!='1'&&testc!='5'&&testc!='9'&&testc!='Y')
{
System.out.println("统一社会信用代码中登记管理部门代码错误");
return false;
}
}
if(index==1)
{
if(testc!='1'&&testc!='2'&&testc!='3'&&testc!='9')
{
System.out.println("统一社会信用代码中机构类别代码错误");
return false;
}
}
tempNum=charToNum(testc);
if(tempNum!=-1) //验证代码中是否有错误字符
{
tempSum+=Weight[index]*tempNum;
}
else
{
System.out.println("统一社会信用代码中出现错误字符");
return false;
}
}
tempNum=31-tempSum%31;
if(tempNum==31) tempNum=0;
if(charToNum(testUSCC.charAt(17))==tempNum) //按照GB/T 17710标准对统一社会信用代码前17位计算校验码,并与第18位校验位进行比对
return true;
else
return false;
}
/*
[函数名]charToNum
[功能]按照GB32100-2015标准代码字符集将用于检验的字符变为相应数字
[参数]c:待转换的字符
[返回值]转换完成后对应的数字,若无法找到字符集中字符,返回-1
*/
public static int charToNum(char c)
{
switch (c)
{
case '0':
return 0;
case '1':
return 1;
case '2':
return 2;
case '3':
return 3;
case '4':
return 4;
case '5':
return 5;
case '6':
return 6;
case '7':
return 7;
case '8':
return 8;
case '9':
return 9;
case 'A':
return 10;
case 'B':
return 11;
case 'C':
return 12;
case 'D':
return 13;
case 'E':
return 14;
case 'F':
return 15;
case 'G':
return 16;
case 'H':
return 17;
case 'J':
return 18;
case 'K':
return 19;
case 'L':
return 20;
case 'M':
return 21;
case 'N':
return 22;
case 'P':
return 23;
case 'Q':
return 24;
case 'R':
return 25;
case 'T':
return 26;
case 'U':
return 27;
case 'W':
return 28;
case 'X':
return 29;
case 'Y':
return 30;
default:
return -1;
}
}
}
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