Antiloveg 8 years ago
parent
commit
ca2a616ef1

+ 0 - 5
src/main/java/com/goafanti/admin/controller/AdminApiController.java

@@ -2729,11 +2729,6 @@ public class AdminApiController extends CertifyApiController {
 	public Result centerDetail(String pageNo, String pageSize, String cid) {
 		Result res = new Result();
 
-		if (StringUtils.isBlank(cid)) {
-			res.getError().add(buildError(ErrorConstants.PARAM_EMPTY_ERROR, "", "技术中心ID"));
-			return res;
-		}
-
 		Integer pNo = 1;
 		Integer pSize = 10;
 		if (StringUtils.isNumeric(pageSize)) {

+ 37 - 0
src/main/java/com/goafanti/admin/controller/AdminPatentApiController.java

@@ -99,6 +99,43 @@ public class AdminPatentApiController extends CertifyApiController {
 	private String							secretKey	= null;
 
 	/**
+	 * 专利批量流转
+	 * 
+	 * @return
+	 */
+	@RequestMapping(value = "/circulation", method = RequestMethod.POST)
+	public Result circulation(@RequestParam(name = "ids[]", required = true) String[] ids, @Valid InputPatentInfo pi,
+			BindingResult bindingResult, String recordTimeFormattedDate) {
+		Result res = new Result();
+		if (bindingResult.hasErrors()) {
+			res.getError().add(buildErrorByMsg(bindingResult.getFieldError().getDefaultMessage(),
+					PatentInfoFields.getFieldDesc(bindingResult.getFieldError().getField())));
+			return res;
+		}
+
+		if (null == pi.getState()) {
+			res.getError().add(buildError(ErrorConstants.PARAM_EMPTY_ERROR, "找不到流转状态", "流转状态"));
+			return res;
+		}
+
+		if (null == pi.getPrincipal()) {
+			res.getError().add(buildError(ErrorConstants.PARAM_EMPTY_ERROR, "找不到负责人", "负责人"));
+			return res;
+		}
+		
+		if (null == recordTimeFormattedDate) {
+			res.getError().add(buildError(ErrorConstants.PARAM_EMPTY_ERROR, "找不到记录流转时间", "记录流转时间"));
+			return res;
+		}
+		
+		PatentLog pl = new PatentLog();
+		BeanUtils.copyProperties(pi, pl);
+		
+		res.setData(patentInfoService.batchCirculation(ids,recordTimeFormattedDate, pl));
+		return res;
+	}
+
+	/**
 	 * 专利列表
 	 * 
 	 * @throws ParseException

+ 2 - 0
src/main/java/com/goafanti/common/dao/PatentInfoMapper.java

@@ -31,5 +31,7 @@ public interface PatentInfoMapper {
 	int batchDeleteByPrimaryKey(List<String> id);
 
 	PatentInfoDetailBo selectPatentInfoDetail(String id);
+
+	List<PatentInfo> selectByPrimaryKeys(String[] ids);
 	
 }

+ 2 - 0
src/main/java/com/goafanti/common/dao/PatentLogMapper.java

@@ -19,4 +19,6 @@ public interface PatentLogMapper {
 
 	List<PatentLog> selectProcessByPid(String pid);
 
+	int batchInsert(List<PatentLog> p);
+
 }

+ 10 - 0
src/main/java/com/goafanti/common/mapper/PatentInfoMapper.xml

@@ -940,5 +940,15 @@
 		from patent_info p LEFT JOIN organization_identity o on p.uid = o.uid
 		where p.deleted_sign =0 and p.id = #{id,jdbcType=VARCHAR}
 	</select>
+	
+	<select id="selectByPrimaryKeys" parameterType="java.util.List" >
+	select 
+		<include refid="Base_Column_List" /> 
+	from patent_info where id in 
+		<foreach item="item" index="index" collection="list" open="("
+				separator="," close=")">
+				#{item}
+		</foreach>
+	</select>
 
 </mapper>

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

@@ -121,6 +121,17 @@
 		from patent_log p LEFT JOIN admin a 
 		on a.id = p.operator ) m LEFT JOIN admin b on m.pri = b. id
     where pid = #{pid,jdbcType=VARCHAR} order by m.record_time desc
-    
   </select>
+  
+   <insert id="batchInsert" parameterType="com.goafanti.common.model.PatentLog">
+    insert into patent_log (id, pid, record_time, state, principal, operator, comment)
+    values 
+    <foreach item="item" index="index" collection="list" separator=",">
+      (
+      	#{item.id,jdbcType=VARCHAR}, #{item.pid,jdbcType=VARCHAR}, #{item.recordTime,jdbcType=TIMESTAMP},
+      	#{item.state,jdbcType=INTEGER}, #{item.principal,jdbcType=VARCHAR}, #{item.operator,jdbcType=VARCHAR},
+      	#{item.comment,jdbcType=VARCHAR}
+      )
+    </foreach>
+  </insert>
 </mapper>

+ 2 - 0
src/main/java/com/goafanti/patent/service/PatentInfoService.java

@@ -42,4 +42,6 @@ public interface PatentInfoService {
 
 	PatentInfoDetailBo selectPatentInfoDetail(String pid);
 
+	int batchCirculation(String[] ids, String recordTimeFormattedDate, PatentLog pl);
+
 }

+ 30 - 5
src/main/java/com/goafanti/patent/service/impl/PatentInfoServiceImpl.java

@@ -1,6 +1,7 @@
 package com.goafanti.patent.service.impl;
 
 import java.text.ParseException;
+import java.util.ArrayList;
 import java.util.Calendar;
 import java.util.Date;
 import java.util.HashMap;
@@ -8,6 +9,7 @@ import java.util.List;
 import java.util.Map;
 import java.util.UUID;
 
+import org.springframework.beans.BeanUtils;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
 
@@ -58,7 +60,6 @@ public class PatentInfoServiceImpl extends BaseMybatisDao<PatentInfoMapper> impl
 	OrgIntellectualPropertyMapper	orgIntellectualPropertyMapper;
 	@Autowired
 	NoticeMapper					noticeMapper;
-	
 
 	@Override
 	public PatentInfo insert(PatentInfo patentInfo) {
@@ -459,6 +460,30 @@ public class PatentInfoServiceImpl extends BaseMybatisDao<PatentInfoMapper> impl
 		return patentInfoMapper.selectPatentInfoDetail(id);
 	}
 
+	@Override
+	public int batchCirculation(String[] ids, String recordTimeFormattedDate, PatentLog pl) {
+		Date recordTime = null;
+		try {
+			recordTime = DateUtils.parseDate(recordTimeFormattedDate, AFTConstants.YYYYMMDDHHMMSS);
+		} catch (ParseException e) {
+		}
+		pl.setRecordTime(recordTime);
+		List<PatentLog> p = new ArrayList<PatentLog>();
+		List<PatentInfo> list = patentInfoMapper.selectByPrimaryKeys(ids);
+		if (null != list && list.size() > 0){
+			for (PatentInfo patentInfo : list){
+				PatentLog patentLog = new PatentLog();
+				patentLog.setId(UUID.randomUUID().toString());
+				patentLog.setPid(patentInfo.getId());
+				patentLog.setOperator(TokenManager.getAdminId());;
+				BeanUtils.copyProperties(pl, patentLog);
+				p.add(patentLog);
+				createNotice(patentInfo, patentLog);
+			}
+		}
+		return patentLogMapper.batchInsert(p);
+	}
+	
 	private void createNotice(PatentInfo p, PatentLog l) {
 		PatentInfo info = patentInfoMapper.selectByPrimaryKey(p.getId());
 
@@ -468,15 +493,15 @@ public class PatentInfoServiceImpl extends BaseMybatisDao<PatentInfoMapper> impl
 		n.setId(UUID.randomUUID().toString());
 		n.setCreateTime(now.getTime());
 		n.setReaded(NoticeReadStatus.UNREAD.getCode());
-		
+
 		User u = userMapper.selectByPrimaryKey(p.getUid());
-		if (null != u){
+		if (null != u) {
 			n.setPid(u.getAid());
 		}
-		
+
 		n.setUid(p.getUid());
 		n.setRid(p.getId());
-		
+
 		n.setAid(l.getPrincipal());
 		n.setContent("编号" + info.getSerialNumber() + "  " + PatentInfoStatus.getStatus(l.getState()).getDesc());
 		n.setNoticeType(NoticeStatus.PATENTINFO.getCode());