فهرست منبع

Merge remote-tracking branch 'origin/master'

yanliming 4 سال پیش
والد
کامیت
793a2a16f8

+ 1 - 1
common/src/main/java/com/jpsoft/enterprise/modules/base/dto/CompanyInfoDetailDTO.java

@@ -14,7 +14,7 @@ public class CompanyInfoDetailDTO {
 
     private String id;
 
-    private String name;
+    private String companyName;
 
     private String logoUrl;
 

+ 1 - 1
common/src/main/java/com/jpsoft/enterprise/modules/base/dto/CompanyInfoListDTO.java

@@ -13,7 +13,7 @@ public class CompanyInfoListDTO {
 
     private String logoUrl;
 
-    private String name;
+    private String companyName;
 
     private String regionName;
 

+ 1 - 1
common/src/main/java/com/jpsoft/enterprise/modules/base/entity/CompanyInfo.java

@@ -20,7 +20,7 @@ public class CompanyInfo {
     @ApiModelProperty(value = "")
     private String id;
     @ApiModelProperty(value = "公司名称")
-    private String name;
+    private String companyName;
     @ApiModelProperty(value = "公司类型(1:企联会员,2:分会企业)")
     private String type;
     @ApiModelProperty(value = "logo地址")

+ 28 - 23
common/src/main/java/com/jpsoft/enterprise/modules/base/entity/PersonInfo.java

@@ -4,6 +4,7 @@ import java.io.Serializable;
 import java.util.Date;
 import java.text.SimpleDateFormat;
 import java.math.BigDecimal;
+
 import org.springframework.format.annotation.DateTimeFormat;
 import com.fasterxml.jackson.annotation.JsonFormat;
 import io.swagger.annotations.ApiModelProperty;
@@ -11,47 +12,51 @@ import io.swagger.annotations.ApiModel;
 import lombok.Data;
 
 /**
-  描述:base_person_info的实体类
+ * 描述:base_person_info的实体类
  */
 @Data
 @ApiModel(value = "base_person_info的实体类")
 public class PersonInfo {
-        @ApiModelProperty(value = "")
+    @ApiModelProperty(value = "")
     private String id;
-        @ApiModelProperty(value = "姓名")
-    private String name;
-        @ApiModelProperty(value = "用户名称")
+    @ApiModelProperty(value = "姓名")
+    private String personName;
+    @ApiModelProperty(value = "用户名称")
     private String userName;
-        @ApiModelProperty(value = "密码")
+    @ApiModelProperty(value = "密码")
     private String password;
-        @ApiModelProperty(value = "openId")
+    @ApiModelProperty(value = "openId")
     private String openId;
-        @ApiModelProperty(value = "身份证号码")
+    @ApiModelProperty(value = "身份证号码")
     private String idCard;
-        @ApiModelProperty(value = "人脸照片")
+    @ApiModelProperty(value = "人脸照片")
     private String faceImageUrl;
-        @ApiModelProperty(value = "对应公司id")
+    @ApiModelProperty(value = "对应公司id")
     private String companyId;
-        @ApiModelProperty(value = "注册类型(1:法人,2:企业联系人)")
+    @ApiModelProperty(value = "注册类型(1:法人,2:企业联系人)")
     private String registerType;
-        @ApiModelProperty(value = "手机号码")
+    @ApiModelProperty(value = "手机号码")
     private String phone;
-        @ApiModelProperty(value = "身份证照片")
+    @ApiModelProperty(value = "身份证照片")
     private String idCardUrl;
-        @ApiModelProperty(value = "创建人")
+    @ApiModelProperty(value = "创建人")
     private String createBy;
-        @DateTimeFormat(pattern="yyyy-MM-dd HH:mm")
-    @JsonFormat(pattern = "yyyy-MM-dd HH:mm",timezone ="GMT+8")
-	    @ApiModelProperty(value = "创建时间")
+    @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm")
+    @JsonFormat(pattern = "yyyy-MM-dd HH:mm", timezone = "GMT+8")
+    @ApiModelProperty(value = "创建时间")
     private Date createTime;
-        @ApiModelProperty(value = "更新人")
+    @ApiModelProperty(value = "更新人")
     private String updateBy;
-        @DateTimeFormat(pattern="yyyy-MM-dd HH:mm")
-    @JsonFormat(pattern = "yyyy-MM-dd HH:mm",timezone ="GMT+8")
-	    @ApiModelProperty(value = "更新时间")
+    @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm")
+    @JsonFormat(pattern = "yyyy-MM-dd HH:mm", timezone = "GMT+8")
+    @ApiModelProperty(value = "更新时间")
     private Date updateTime;
-        @ApiModelProperty(value = "是否删除")
+    @ApiModelProperty(value = "是否删除")
     private Boolean delFlag;
-        @ApiModelProperty(value = "备注")
+    @ApiModelProperty(value = "备注")
     private String remark;
+    @ApiModelProperty(value = "注册类型名称")
+    private String registerTypeName;
+
+
 }

+ 34 - 4
common/src/main/java/com/jpsoft/enterprise/modules/common/utils/StringUtils.java

@@ -4,10 +4,7 @@ import java.io.UnsupportedEncodingException;
 import java.net.URLEncoder;
 import java.text.MessageFormat;
 import java.text.SimpleDateFormat;
-import java.util.Date;
-import java.util.Locale;
-import java.util.Random;
-import java.util.UUID;
+import java.util.*;
 
 /**
  * 字符串工具类,继承lang3字符串工具类
@@ -176,6 +173,39 @@ public final class StringUtils extends org.apache.commons.lang3.StringUtils {
 		return sb.toString();
 	}
 
+	/**
+	 * 验证企业社会信用代码
+	 * @param businessCode
+	 * @return
+	 */
+	public static boolean isValid(String businessCode) {
+		if ((businessCode.equals("")) || businessCode.length() != 18) {
+			return false;
+		}
+		String baseCode = "0123456789ABCDEFGHJKLMNPQRTUWXY";
+		char[] baseCodeArray = baseCode.toCharArray();
+		Map<Character, Integer> codes = new HashMap<Character, Integer>();
+		for (int i = 0; i < baseCode.length(); i++) {
+			codes.put(baseCodeArray[i], i);
+		}
+		char[] businessCodeArray = businessCode.toCharArray();
+		Character check = businessCodeArray[17];
+		if (baseCode.indexOf(check) == -1) {
+			return false;
+		}
+		int[] wi = { 1, 3, 9, 27, 19, 26, 16, 17, 20, 29, 25, 13, 8, 24, 10, 30, 28 };
+		int sum = 0;
+		for (int i = 0; i < 17; i++) {
+			Character key = businessCodeArray[i];
+			if (baseCode.indexOf(key) == -1) {
+				return false;
+			}
+			sum += (codes.get(key) * wi[i]);
+		}
+		int value = 31 - sum % 31;
+		return value == codes.get(check);
+	}
+
 	/*public static void main(String[] args) {
 		System.out.println(random(32, RandomType.INT));
 	}*/

+ 5 - 5
common/src/main/resources/mapper/base/CompanyInfo.xml

@@ -5,7 +5,7 @@
 <mapper namespace="com.jpsoft.enterprise.modules.base.dao.CompanyInfoDAO">
 	<resultMap id="CompanyInfoMap" type="com.jpsoft.enterprise.modules.base.entity.CompanyInfo">
 		<id property="id" column="id_" />
-			<result property="name" column="name_" />
+			<result property="companyName" column="company_name" />
 			<result property="type" column="type_" />
 			<result property="logoUrl" column="logo_url"/>
 			<result property="creditCode" column="credit_code" />
@@ -30,11 +30,11 @@
 	-->
 	<![CDATA[
 		insert into base_company_info
-	    (id_,name_,type_,logo_url,credit_code,address_,business_license_url,scale_,industry_,region_,company_introduction,enterpriser_introduction,create_by,create_time,update_by,update_time,del_flag)
+	    (id_,company_name,type_,logo_url,credit_code,address_,business_license_url,scale_,industry_,region_,company_introduction,enterpriser_introduction,create_by,create_time,update_by,update_time,del_flag)
 		values
 		(
 #{id,jdbcType=VARCHAR}
-,#{name,jdbcType=VARCHAR}
+,#{companyName,jdbcType=VARCHAR}
 ,#{type,jdbcType=VARCHAR}
 ,#{logoUrl,jdbcType=VARCHAR}
 ,#{creditCode,jdbcType=VARCHAR}
@@ -59,8 +59,8 @@
 	<update id="update" parameterType="com.jpsoft.enterprise.modules.base.entity.CompanyInfo">
 		update base_company_info
 		<set>
-				<if test="name!=null">
-		name_=#{name,jdbcType=VARCHAR},
+				<if test="companyName!=null">
+		company_name=#{companyName,jdbcType=VARCHAR},
 		</if>
 				<if test="type!=null">
 		type_=#{type,jdbcType=VARCHAR},

+ 7 - 7
common/src/main/resources/mapper/base/PersonInfo.xml

@@ -5,7 +5,7 @@
 <mapper namespace="com.jpsoft.enterprise.modules.base.dao.PersonInfoDAO">
 	<resultMap id="PersonInfoMap" type="com.jpsoft.enterprise.modules.base.entity.PersonInfo">
 		<id property="id" column="id_" />
-			<result property="name" column="name_" />
+			<result property="personName" column="person_name" />
 			<result property="userName" column="user_name" />
 			<result property="password" column="password_" />
 			<result property="openId" column="open_id" />
@@ -21,6 +21,7 @@
 			<result property="updateTime" column="update_time" />
 			<result property="delFlag" column="del_flag" />
 			<result property="remark" column="remark_" />
+			<result property="registerTypeName" column="register_type_name"/>
 			</resultMap>
 	<insert id="insert" parameterType="com.jpsoft.enterprise.modules.base.entity.PersonInfo">
 	<!--
@@ -30,11 +31,11 @@
 	-->
 	<![CDATA[
 		insert into base_person_info
-	    (id_,name_,user_name,password_,open_id,id_card,face_image_url,company_id,register_type,phone_,id_card_url,create_by,create_time,update_by,update_time,del_flag,remark_)
+	    (id_,person_name,user_name,password_,open_id,id_card,face_image_url,company_id,register_type,phone_,id_card_url,create_by,create_time,update_by,update_time,del_flag,remark_)
 		values
 		(
 #{id,jdbcType=VARCHAR}
-,#{name,jdbcType=VARCHAR}
+,#{personName,jdbcType=VARCHAR}
 ,#{userName,jdbcType=VARCHAR}
 ,#{password,jdbcType=VARCHAR}
 ,#{openId,jdbcType=VARCHAR}
@@ -59,8 +60,8 @@
 	<update id="update" parameterType="com.jpsoft.enterprise.modules.base.entity.PersonInfo">
 		update base_person_info
 		<set>
-				<if test="name!=null">
-		name_=#{name,jdbcType=VARCHAR},
+				<if test="personName!=null">
+		person_name=#{personName,jdbcType=VARCHAR},
 		</if>
 				<if test="userName!=null">
 		user_name=#{userName,jdbcType=VARCHAR},
@@ -111,8 +112,7 @@
 	where id_=#{id}
 	</update>
 	<select id="get" parameterType="string" resultMap="PersonInfoMap">
-		select
-id_,name_,user_name,password_,open_id,id_card,face_image_url,company_id,register_type,phone_,id_card_url,create_by,create_time,update_by,update_time,del_flag,remark_		from base_person_info where id_=#{0}
+		select * from base_person_info where id_=#{0}
 	</select>
 	<select id="exist" parameterType="string" resultType="int">
 		select count(*) from base_person_info where id_=#{0}

+ 199 - 4
web/src/main/java/com/jpsoft/enterprise/modules/mobile/controller/PersonInfoApiController.java

@@ -2,15 +2,20 @@ package com.jpsoft.enterprise.modules.mobile.controller;
 
 import cn.hutool.core.date.DateTime;
 import cn.hutool.core.date.DateUtil;
+import com.jpsoft.enterprise.config.OSSConfig;
+import com.jpsoft.enterprise.modules.base.dto.CompanyInfoDetailDTO;
+import com.jpsoft.enterprise.modules.base.entity.CompanyInfo;
 import com.jpsoft.enterprise.modules.base.entity.PersonInfo;
 import com.jpsoft.enterprise.modules.base.service.MessageReceiverService;
+import com.jpsoft.enterprise.modules.base.service.CompanyInfoService;
 import com.jpsoft.enterprise.modules.base.service.PersonInfoService;
 import com.jpsoft.enterprise.modules.common.dto.MessageResult;
-import com.jpsoft.enterprise.modules.common.utils.AESUtil;
-import com.jpsoft.enterprise.modules.common.utils.JwtUtil;
-import com.jpsoft.enterprise.modules.common.utils.SMSUtil;
+import com.jpsoft.enterprise.modules.common.utils.*;
+import com.jpsoft.enterprise.modules.sys.entity.DataDictionary;
+import com.jpsoft.enterprise.modules.sys.service.DataDictionaryService;
 import io.swagger.annotations.ApiImplicitParam;
 import io.swagger.annotations.ApiImplicitParams;
+import io.swagger.annotations.ApiModelProperty;
 import io.swagger.annotations.ApiOperation;
 import lombok.extern.slf4j.Slf4j;
 import net.sf.json.JSONObject;
@@ -19,8 +24,11 @@ import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.beans.factory.annotation.Value;
 import org.springframework.data.redis.core.ValueOperations;
 import org.springframework.web.bind.annotation.*;
+import org.springframework.web.multipart.MultipartFile;
+import sun.misc.BASE64Decoder;
 import sun.security.provider.MD5;
 
+import java.io.ByteArrayInputStream;
 import java.util.Date;
 import java.util.HashMap;
 import java.util.Map;
@@ -38,15 +46,24 @@ public class PersonInfoApiController {
     @Value("${jwt.secret}")
     private String jwtSecret;
 
+    @Autowired
+    private OSSConfig ossConfig;
+
     @Autowired
     private PersonInfoService personInfoService;
 
     @Autowired
     private ValueOperations<String, Object> valueOperations;
 
+    @Autowired
+    private CompanyInfoService companyInfoService;
+
     @Autowired
     private MessageReceiverService messageReceiverService;
 
+    @Autowired
+    private DataDictionaryService dataDictionaryService;
+
 
 
 
@@ -254,8 +271,17 @@ public class PersonInfoApiController {
             PersonInfo personInfo = personInfoService.findByOpenId(openId);
            if (personInfo != null){
                String token = JwtUtil.createToken(jwtSecret, personInfo.getId() + "", DateUtil.offsetHour(new Date(),6));
+               String registerTypeName = dataDictionaryService.findNameByCatalogNameAndValue("注册用户类型",personInfo.getRegisterType());
+               personInfo.setRegisterTypeName(registerTypeName);
                dataMap.put("personInfo", personInfo);
                dataMap.put("token", token);
+               CompanyInfoDetailDTO companyInfoDetailDTO = new CompanyInfoDetailDTO();
+               CompanyInfo companyInfo = companyInfoService.get(personInfo.getCompanyId());
+               companyInfoDetailDTO.setCompanyName(companyInfo.getCompanyName());
+               companyInfoDetailDTO.setId(companyInfo.getId());
+               companyInfoDetailDTO.setLogoUrl(companyInfo.getLogoUrl());
+
+               dataMap.put("companyInfo",companyInfoDetailDTO);
 
                int messageNum = messageReceiverService.countByReadStatus(personInfo.getId(),false);
 
@@ -275,7 +301,7 @@ public class PersonInfoApiController {
         return messageResult;
     }
 
-    @PostMapping("resetPassword ")
+    @PostMapping("resetPassword")
     @ApiOperation(value = "重置密码")
     @ApiImplicitParams({
             @ApiImplicitParam(name = "token", value = "令牌", required = true, paramType = "form"),
@@ -353,5 +379,174 @@ public class PersonInfoApiController {
     }
 
 
+    @PostMapping("basicInformation")
+    @ApiOperation(value = "企业基础信息")
+    @ApiImplicitParams({
+            @ApiImplicitParam(name = "token", value = "令牌", required = true, paramType = "form"),
+            @ApiImplicitParam(name = "subject", value = "目标(不传)", paramType = "form")
+    })
+    public MessageResult<Map> basicInformation(String token, @RequestAttribute String subject) {
+
+        MessageResult<Map> messageResult = new MessageResult<>();
+
+        try {
+
+            Map<String, Object> dataMap = new HashMap<String, Object>();
+            PersonInfo personInfo = personInfoService.get(subject);
+            if (personInfo == null){
+                throw new Exception("用户不存在");
+            }
+            CompanyInfo companyInfo = companyInfoService.get(personInfo.getCompanyId());
+
+            if (companyInfo == null){
+                throw new Exception("企业不存在");
+            }
+
+            dataMap.put("companyInfo",companyInfo);
+            dataMap.put("personInfo",personInfo);
+            messageResult.setData(dataMap);
+            messageResult.setResult(true);
+            messageResult.setCode(200);
+        } catch (Exception ex) {
+            log.error(ex.getMessage(),ex);
+            messageResult.setCode(400);
+            messageResult.setResult(false);
+            messageResult.setMessage(ex.getMessage());
+        }
+
+        return messageResult;
+    }
+
+
+    @PostMapping("updateBasicInformation")
+    @ApiOperation(value = "更新企业基础信息")
+    @ApiImplicitParams({
+            @ApiImplicitParam(name = "token", value = "令牌", required = true, paramType = "form"),
+            @ApiImplicitParam(name = "subject", value = "目标(不传)", paramType = "form"),
+            @ApiImplicitParam(name = "creditCode", value = "社会信用代码", required = true, paramType = "form"),
+            @ApiImplicitParam(name = "companyName", value = "企业名称", required = true, paramType = "form"),
+            @ApiImplicitParam(name = "registerType", value = "注册用户类型", required = true, paramType = "form"),
+            @ApiImplicitParam(name = "region", value = "企业所在区域", required = true, paramType = "form"),
+            @ApiImplicitParam(name = "idCard", value = "身份证号码", required = true, paramType = "form"),
+            @ApiImplicitParam(name = "personName", value = "真实姓名", required = true, paramType = "form"),
+            @ApiImplicitParam(name = "phone", value = "手机号码", required = true, paramType = "form"),
+            @ApiImplicitParam(name = "idCardUrl", value = "身份证人脸面", required = false, paramType = "form"),
+            @ApiImplicitParam(name = "businessLicenseUrl", value = "营业执照照片", required = false, paramType = "form"),
+            @ApiImplicitParam(name = "type", value = "企业类型", required = false, paramType = "form"),
+            @ApiImplicitParam(name = "scale", value = "企业规模", required = false, paramType = "form"),
+            @ApiImplicitParam(name = "industry", value = "所属行业", required = false, paramType = "form"),
+            @ApiImplicitParam(name = "address", value = "公司地址", required = false, paramType = "form"),
+            @ApiImplicitParam(name = "companyIntroduction", value = "公司介绍", required = false, paramType = "form"),
+            @ApiImplicitParam(name = "enterpriserIntroduction", value = "企业家介绍", required = false, paramType = "form"),
+    })
+    public MessageResult<Map> updateBasicInformation(String token, @RequestAttribute String subject,String creditCode,String companyName,String registerType,String region,String idCard,String personName,String phone,String idCardUrl,String businessLicenseUrl,String type,String scale,String industry,String address,String companyIntroduction,String enterpriserIntroduction) {
+
+        MessageResult<Map> messageResult = new MessageResult<>();
+
+        try {
+
+            Map<String, Object> dataMap = new HashMap<String, Object>();
+            PersonInfo personInfo = personInfoService.get(subject);
+            if (personInfo == null){
+                throw new Exception("用户不存在");
+            }
+            CompanyInfo companyInfo = companyInfoService.get(personInfo.getCompanyId());
+
+            if (companyInfo == null){
+                throw new Exception("企业不存在");
+            }
+
+            if (!com.jpsoft.enterprise.modules.common.utils.StringUtils.isValid(creditCode)){
+                throw new Exception("社会信用代码错误");
+            }
+
+            if (!new CheckIdCard(idCard).validate()){
+                throw new Exception("身份证号码错误");
+            }
+
+            companyInfo.setCreditCode(creditCode);
+            companyInfo.setCompanyName(companyName);
+            companyInfo.setRegion(region);
+            if (StringUtils.isNotBlank(businessLicenseUrl)){
+                companyInfo.setBusinessLicenseUrl(businessLicenseUrl);
+            }
+            companyInfo.setType(type);
+            companyInfo.setScale(scale);
+            companyInfo.setIndustry(industry);
+            companyInfo.setAddress(address);
+            companyInfo.setCompanyIntroduction(companyIntroduction);
+            companyInfo.setEnterpriserIntroduction(enterpriserIntroduction);
+            companyInfoService.update(companyInfo);
+            //更新用户
+            personInfo.setRegisterType(registerType);
+            personInfo.setIdCard(idCard);
+            personInfo.setPersonName(personName);
+            personInfo.setPhone(phone);
+            if (StringUtils.isNotBlank(idCardUrl)){
+                personInfo.setIdCardUrl(idCardUrl);
+            }
+            personInfoService.update(personInfo);
+
+            messageResult.setData(dataMap);
+            messageResult.setResult(true);
+            messageResult.setCode(200);
+        } catch (Exception ex) {
+            log.error(ex.getMessage(),ex);
+            messageResult.setCode(400);
+            messageResult.setResult(false);
+            messageResult.setMessage(ex.getMessage());
+        }
+
+        return messageResult;
+    }
+
+    @PostMapping("uploadBase64")
+    @ResponseBody
+    @ApiOperation(value = "员工照片上传")
+    @ApiImplicitParams({
+            @ApiImplicitParam(name = "photoName", value = "照片名称", required = true, paramType = "form"),
+            @ApiImplicitParam(name = "photoBase64Data", value = "员工照片base64编码", required = true, paramType = "form")
+    })
+    public MessageResult<String> uploadBase64(String photoName, String photoBase64Data) {
+        MessageResult<String> messageResult = new MessageResult<>();
+
+
+        try {
+
+
+
+            BASE64Decoder decoder = new BASE64Decoder();
+
+            String[] arr = photoBase64Data.split(",");
+
+            byte[] imgData = decoder.decodeBuffer(arr[1]);
+
+            for (int i = 0; i < imgData.length; ++i) {
+                if (imgData[i] < 0) {// 调整异常数据
+                    imgData[i] += 256;
+                }
+            }
+
+            ByteArrayInputStream inputStream = new ByteArrayInputStream(imgData);
+
+            if (StringUtils.isEmpty(photoName)) {
+                photoName = "1.jpg";
+            }
+
+            String retFileUrl = OSSUtil.upload(ossConfig, "/person", photoName, inputStream);
+
+            messageResult.setResult(true);
+            messageResult.setData(retFileUrl);
+            messageResult.setCode(200);
+
+        } catch (Exception e) {
+            log.error(e.getMessage(), e);
+            messageResult.setCode(400);
+            messageResult.setResult(false);
+            messageResult.setMessage(e.getMessage());
+
+        }
+        return messageResult;
+    }
 
 }