Explorar el Código

update fileUtils

Antiloveg hace 8 años
padre
commit
5541e329bd

+ 3 - 0
schema/2017-03-10.sql

@@ -0,0 +1,3 @@
+ALTER TABLE user
+add aid VARCHAR(36) NULL COMMENT '管理员ID' 
+

+ 26 - 1
src/main/java/com/goafanti/admin/controller/AdminApiController.java

@@ -819,7 +819,7 @@ public class AdminApiController extends BaseApiController {
 	 * @return
 	 */
 	@RequestMapping(value = "/applyCognizance", method = RequestMethod.POST)
-	public Result applyCognizance(String contacts, String comment, String consultant, String uid, Integer year) {
+	public Result applyCognizance(String contacts, String comment, String consultant, String uid, Integer year, Integer state) {
 		Result res = new Result();
 		if (null == year){
 			res.getError().add(buildError(ErrorConstants.DUPLICATE_DATA_ERROR, "申请认定年份不能为空!"));
@@ -833,6 +833,19 @@ public class AdminApiController extends BaseApiController {
 		c.setYear(year);
 		c.setDeletedSign(0);
 		orgCognizanceService.insert(c);
+		
+
+		OrgCognizanceLog log = new OrgCognizanceLog();
+		log.setId(UUID.randomUUID().toString());
+		log.setCid(c.getId());
+		Calendar now = Calendar.getInstance();
+		now.set(Calendar.MILLISECOND, 0);
+		log.setRecordTime(now.getTime());
+		log.setState(state);
+		log.setComment(comment);
+		log.setPrincipal(userService.selectByPrimaryKey(uid).getAid());
+		log.setOperator(TokenManager.getAdminId());
+		orgCognizanceLogService.insert(log);
 		return res;
 	}
 
@@ -898,6 +911,18 @@ public class AdminApiController extends BaseApiController {
 		Result res = new Result();
 		if (null != log.getState()) {
 			cog.setState(log.getState());
+			switch (log.getState()) {
+			case 1:
+				cog.setCreateTime(log.getRecordTime());
+				break;
+			case 2:
+				cog.setAcceptDate(log.getRecordTime());
+				break;
+			case 5:
+				cog.setIssuingDate(log.getRecordTime());
+				break;
+			}
+			cog.setConsultant(null == log.getOperator() ? "" : log.getOperator());
 			log.setId(UUID.randomUUID().toString());
 			log.setCid(cog.getId());
 			if (!StringUtils.isBlank(recordTimeFormattedDate)) {

+ 1 - 1
src/main/java/com/goafanti/common/mapper/OrgCognizanceMapper.xml

@@ -265,7 +265,7 @@
 	c.id as cid, c.serial_number, i.location_province,
 	i.unit_name, c.contacts, c.create_time, 
 	c.comment, c.state, c.certificate_number, 
-	c.issuing_date, c.consultant 
+	c.issuing_date, c.consultant, c.year
 	from user u INNER JOIN org_cognizance c on u.id = c.uid  and deleted_sign = 0
 	LEFT JOIN organization_identity i on i.uid = u.id) x  
 	LEFT JOIN  admin a on a.id = x.consultant

+ 15 - 4
src/main/java/com/goafanti/common/mapper/UserMapper.xml

@@ -11,6 +11,7 @@
     <result column="number" jdbcType="BIGINT" property="number" />
     <result column="lvl" jdbcType="INTEGER" property="lvl" />
     <result column="type" jdbcType="INTEGER" property="type" />
+    <result column="aid" jdbcType="VARCHAR" property="aid" />
   </resultMap>
   
   <resultMap type="com.goafanti.user.bo.UserPageHomeBo" id="UserPageHomeBo">
@@ -36,7 +37,7 @@
   
   
   <sql id="Base_Column_List">
-    id, mobile, password, nickname, email, create_time, number, lvl, type
+    id, mobile, password, nickname, email, create_time, number, lvl, type, aid
   </sql>
   <select id="selectByPrimaryKey" parameterType="java.lang.String" resultMap="BaseResultMap">
     select 
@@ -51,10 +52,10 @@
   <insert id="insert" parameterType="com.goafanti.common.model.User">
     insert into user (id, mobile, password, 
       nickname, email, create_time, 
-      number, lvl, type)
+      number, lvl, type, aid)
     values (#{id,jdbcType=VARCHAR}, #{mobile,jdbcType=VARCHAR}, #{password,jdbcType=VARCHAR}, 
       #{nickname,jdbcType=VARCHAR}, #{email,jdbcType=VARCHAR}, #{createTime,jdbcType=TIMESTAMP}, 
-      #{number,jdbcType=BIGINT}, #{lvl,jdbcType=INTEGER},#{type,jdbcType=INTEGER})
+      #{number,jdbcType=BIGINT}, #{lvl,jdbcType=INTEGER},#{type,jdbcType=INTEGER}, #{aid,jdbcType=VARCHAR})
   </insert>
   <insert id="insertSelective" parameterType="com.goafanti.common.model.User">
     insert into user
@@ -86,6 +87,9 @@
       <if test="type != null">
         type,
       </if>
+      <if test="aid != null">
+        aid,
+      </if>
     </trim>
     <trim prefix="values (" suffix=")" suffixOverrides=",">
       <if test="id != null">
@@ -115,6 +119,9 @@
       <if test="type != null">
         #{type,jdbcType=INTEGER},
       </if>
+      <if test="aid != null">
+        #{aid,jdbcType=VARCHAR},
+      </if>
     </trim>
   </insert>
   <update id="updateByPrimaryKeySelective" parameterType="com.goafanti.common.model.User">
@@ -144,6 +151,9 @@
       <if test="type != null">
         type = #{type,jdbcType=INTEGER}
       </if>
+      <if test="aid != null">
+        aid = #{aid,jdbcType=VARCHAR}
+      </if>
     </set>
     where id = #{id,jdbcType=VARCHAR}
   </update>
@@ -156,7 +166,8 @@
       create_time = #{createTime,jdbcType=TIMESTAMP},
       number = #{number,jdbcType=BIGINT},
       lvl = #{lvl,jdbcType=INTEGER},
-      type = #{type,jdbcType=INTEGER}
+      type = #{type,jdbcType=INTEGER},
+      aid = #{aid,jdbcType=VARCHAR}
     where id = #{id,jdbcType=VARCHAR}
   </update>
   

+ 13 - 0
src/main/java/com/goafanti/common/model/User.java

@@ -63,6 +63,11 @@ public class User extends BaseModel implements AftUser{
 默认0为个人账号,1为组织账号
     */
     private Integer type;
+    
+    /**
+     * 管理员ID
+     */
+    private String aid;
 
     public String getId() {
         return id;
@@ -135,6 +140,14 @@ public class User extends BaseModel implements AftUser{
 	public void setLvl(Integer lvl) {
 		this.lvl = lvl;
 	}
+
+	public String getAid() {
+		return aid;
+	}
+
+	public void setAid(String aid) {
+		this.aid = aid;
+	}
     
     
     

+ 9 - 2
src/main/java/com/goafanti/common/utils/FileUtils.java

@@ -91,10 +91,17 @@ public class FileUtils {
 	 */
 	public static String mosaicFileName(MultipartFile mf, boolean isPrivate, String sign, String path, String uid) {
 		String suffix = mf.getOriginalFilename().substring(mf.getOriginalFilename().lastIndexOf("."));
+		boolean uniq = false;
+		if (sign.indexOf("protocol") != -1 || sign.indexOf("achievement") != -1 || sign.indexOf("honor") != -1){
+			uniq = true;
+		}
 		String fileName = "";
 		if (isPrivate || sign != "") {
-			fileName = path + uid + "/" + sign + suffix;
-
+			if (uniq){
+				fileName = path + uid + "/" + System.nanoTime()+ "_" + sign + suffix;
+			} else {
+				fileName = path + uid + "/" + sign + suffix;
+			}
 		} else {
 			fileName = path + System.nanoTime() + suffix;
 		}

+ 11 - 1
src/main/java/com/goafanti/techservice/cognizance/bo/CognizanceBo.java

@@ -31,6 +31,8 @@ public class CognizanceBo {
 	private Date issuingDate;
 	
 	private String consultant;
+	
+	private Integer year;
 
 	public String getUid() {
 		return uid;
@@ -129,7 +131,15 @@ public class CognizanceBo {
 		this.consultant = consultant;
 	}
 	
-	 public String getCreateTimeFormattedDate(){
+	 public Integer getYear() {
+		return year;
+	}
+
+	public void setYear(Integer year) {
+		this.year = year;
+	}
+
+	public String getCreateTimeFormattedDate(){
 			if (this.createTime == null) {
 				return null;
 			} else {

+ 19 - 17
src/main/java/com/goafanti/techservice/cognizance/controller/CognizanceApiController.java

@@ -27,6 +27,7 @@ import com.goafanti.common.model.OrgActivity;
 import com.goafanti.common.model.OrgActivityCost;
 import com.goafanti.common.model.OrgAnnualReport;
 import com.goafanti.common.model.OrgCognizance;
+import com.goafanti.common.model.OrgCognizanceLog;
 import com.goafanti.common.model.OrgFinance;
 import com.goafanti.common.model.OrgHonorDatum;
 import com.goafanti.common.model.OrgIntellectualProperty;
@@ -54,6 +55,7 @@ import com.goafanti.techservice.cognizance.bo.CognizanceResearchCostBo;
 import com.goafanti.techservice.cognizance.service.OrgActivityCostService;
 import com.goafanti.techservice.cognizance.service.OrgActivityService;
 import com.goafanti.techservice.cognizance.service.OrgAnnualReportService;
+import com.goafanti.techservice.cognizance.service.OrgCognizanceLogService;
 import com.goafanti.techservice.cognizance.service.OrgCognizanceService;
 import com.goafanti.techservice.cognizance.service.OrgFinanceService;
 import com.goafanti.techservice.cognizance.service.OrgHonorDatumService;
@@ -100,6 +102,8 @@ public class CognizanceApiController extends BaseApiController {
 	private OrgCognizanceService            orgCognizanceService;
 	@Resource
 	private OrgAnnualReportService			orgAnnualReportService;
+	@Resource
+	private OrgCognizanceLogService			orgCognizanceLogService;
 
 	/**
 	 * 企业研究开发活动情况表入口
@@ -616,7 +620,7 @@ public class CognizanceApiController extends BaseApiController {
 	}
 
 	/**
-	 * 高企相关材料上传(技术协议除外)
+	 * 高企相关材料上传
 	 * 
 	 * @param req
 	 * @param sign
@@ -629,19 +633,6 @@ public class CognizanceApiController extends BaseApiController {
 		return res;
 	}
 	
-	/**
-	 * 技术协议上传
-	 * @param req
-	 * @param uid
-	 * @param id
-	 * @return
-	 */
-	/*@RequestMapping(value = "/uploadProtocol", method = RequestMethod.POST)
-	public Result uploadProtocolFile(HttpServletRequest req, String uid, String id){
-		Result res = new Result();
-		res.setData(handleProtocolFile(res, "/cognizance/", true , req, uid));
-		return res;
-	}*/
 
 	/**
 	 * 科技成果转化情况列表入口
@@ -927,7 +918,7 @@ public class CognizanceApiController extends BaseApiController {
 	 * @return
 	 */
 	@RequestMapping(value = "/applyCognizance", method = RequestMethod.POST)
-	public Result applyCognizance(String contacts, String comment, String consultant, Integer year){
+	public Result applyCognizance(String contacts, String comment,  Integer year, Integer state){
 		Result res = new Result();
 		if (null == year){
 			res.getError().add(buildError(ErrorConstants.DUPLICATE_DATA_ERROR, "申请认定年份不能为空!"));
@@ -937,10 +928,20 @@ public class CognizanceApiController extends BaseApiController {
 		c.setUid(TokenManager.getUserId());
 		c.setContacts(contacts);
 		c.setComment(comment);
-		c.setConsultant(consultant);
 		c.setDeletedSign(0);
 		c.setYear(year);
 		orgCognizanceService.insert(c);
+		
+		OrgCognizanceLog log = new OrgCognizanceLog();
+		log.setId(UUID.randomUUID().toString());
+		log.setCid(c.getId());
+		Calendar now = Calendar.getInstance();
+		now.set(Calendar.MILLISECOND, 0);
+		log.setRecordTime(now.getTime());
+		log.setState(state);
+		log.setComment(comment);
+		log.setPrincipal(userService.selectByPrimaryKey(TokenManager.getUserId()).getAid());
+		orgCognizanceLogService.insert(log);
 		return res;
 	}
 	
@@ -1100,7 +1101,8 @@ public class CognizanceApiController extends BaseApiController {
 			String uid) {
 		List<MultipartFile> files = getFiles(req);
 		MultipartFile mf = files.get(0);
-		String fileName = FileUtils.mosaicFileName(mf, isPrivate, sign, path, StringUtils.isBlank(uid) ? TokenManager.getUserId() : uid);
+		
+		String fileName = FileUtils.mosaicFileName(mf, isPrivate, sign,  path, StringUtils.isBlank(uid) ? TokenManager.getUserId() : uid);
 		if (!files.isEmpty()) {
 			try {
 				mf.transferTo(toPrivateFile(fileName));

+ 1 - 0
src/main/java/com/goafanti/user/controller/UserRegisterController.java

@@ -82,6 +82,7 @@ public class UserRegisterController extends BaseController {
 			user.setCreateTime(now.getTime());
 			user.setPassword(passwordUtil.getEncryptPwd(user));
 			user.setLvl(0);
+			user.setAid("1");//分配管理员
 			userService.insertRegister(user, contacts, companyName, user.getId());
 		}