albertshaw 8 years ago
parent
commit
a9920fbb0d

+ 20 - 8
src/main/java/com/goafanti/admin/controller/AdminPatentApiController.java

@@ -5,6 +5,7 @@ import java.text.ParseException;
 import java.util.Arrays;
 import java.util.Calendar;
 import java.util.Date;
+import java.util.HashMap;
 import java.util.List;
 import java.util.Map;
 import java.util.TreeMap;
@@ -52,6 +53,7 @@ import com.goafanti.common.enums.PatentRegistrationFields;
 import com.goafanti.common.enums.PatentReimbursementStatus;
 import com.goafanti.common.model.Admin;
 import com.goafanti.common.model.AftFile;
+import com.goafanti.common.model.DistrictGlossory;
 import com.goafanti.common.model.OrgRatepay;
 import com.goafanti.common.model.OrganizationIdentity;
 import com.goafanti.common.model.PatentCost;
@@ -928,14 +930,14 @@ public class AdminPatentApiController extends CertifyApiController {
 				new String[] { "编号", "申请号/专利号", "省份", "公司名称", "专利名称", "缴费状态", "申请费", "是否请款", "是否报销", "申请日", "缴费截止时间" });
 
 		HSSFSheet sheet = workbook.getSheet(sheetName);
-
+		Map<Integer, DistrictGlossory> districtMap = getProvinces();
 		for (int i = 0; i < fees.size(); i++) {
 			PatentApplicationFeeBo obj = fees.get(i);
 			HSSFRow row = sheet.createRow(i + 2);// 创建所需的行数
 			row.createCell(0).setCellValue(null == obj.getSerialNumber() ? "" : obj.getSerialNumber().toString());
 			row.createCell(1).setCellValue(obj.getPatentNumber());
 			Integer locationProvince = obj.getLocationProvince();
-			row.createCell(2).setCellValue(null == locationProvince ? "" : getProvince(locationProvince));
+			row.createCell(2).setCellValue(null == locationProvince ? "" : getProvince(districtMap, locationProvince));
 			row.createCell(3).setCellValue(obj.getUnitName());
 			row.createCell(4).setCellValue(obj.getPatentName());
 			Integer paymentState = obj.getPaymentState();
@@ -972,14 +974,14 @@ public class AdminPatentApiController extends CertifyApiController {
 				new String[] { "编号", "申请号/专利号", "省份", "公司名称", "专利类型", "专利名称", "专利状态", "缴费状态", "缴费截止日期" });
 
 		HSSFSheet sheet = workbook.getSheet(sheetName);
-
+		Map<Integer, DistrictGlossory> districtMap = getProvinces();
 		for (int i = 0; i < pendings.size(); i++) {
 			PatentPendingBo obj = pendings.get(i);
 			HSSFRow row = sheet.createRow(i + 2);// 创建所需的行数
 			row.createCell(0).setCellValue(null == obj.getSerialNumber() ? "" : obj.getSerialNumber().toString());
 			row.createCell(1).setCellValue(obj.getPatentNumber());
 			Integer locationProvince = obj.getLocationProvince();
-			row.createCell(2).setCellValue(null == locationProvince ? "" : getProvince(locationProvince));
+			row.createCell(2).setCellValue(null == locationProvince ? "" : getProvince(districtMap, locationProvince));
 			row.createCell(3).setCellValue(obj.getUnitName());
 			Integer patentCatagory = obj.getPatentCatagory();
 			if (null != patentCatagory) {
@@ -1018,6 +1020,7 @@ public class AdminPatentApiController extends CertifyApiController {
 		HSSFSheet sheet = workbook.getSheet(sheetName);
 
 		// 将查询出的数据设置到sheet对应的单元格中
+		Map<Integer, DistrictGlossory> districtMap = getProvinces();
 		for (int i = 0; i < composites.size(); i++) {
 			PatentManageListBo obj = composites.get(i);// 遍历每个对象
 			HSSFRow row = sheet.createRow(i + 2);// 创建所需的行数
@@ -1025,7 +1028,7 @@ public class AdminPatentApiController extends CertifyApiController {
 			row.createCell(1).setCellValue(obj.getPatentNumber());
 			row.createCell(2).setCellValue(obj.getOffice());
 			Integer locationProvince = obj.getLocationProvince();
-			row.createCell(3).setCellValue(null == locationProvince ? "" : getProvince(locationProvince));
+			row.createCell(3).setCellValue(null == locationProvince ? "" : getProvince(districtMap, locationProvince));
 			row.createCell(4).setCellValue(obj.getUnitName());
 			row.createCell(5).setCellValue(obj.getPatentName());
 			row.createCell(6).setCellValue(null == obj.getPatentState() ? "" : switchPatState(obj.getPatentState()));
@@ -1251,9 +1254,18 @@ public class AdminPatentApiController extends CertifyApiController {
 		}
 		return status;
 	}
-	
-	private String getProvince(Integer province){
-		return districtGlossoryService.selectByPrimaryKey(province).getName();
+
+	private String getProvince(Map<Integer, DistrictGlossory> districtMap, Integer province) {
+		DistrictGlossory dg = districtMap.get(province);
+		return dg == null ? "未知地区" : dg.getName();
 	}
 
+	private Map<Integer, DistrictGlossory> getProvinces() {
+		List<DistrictGlossory> districts = districtGlossoryService.list(0);
+		Map<Integer, DistrictGlossory> districtMap = new HashMap<>();
+		for (DistrictGlossory dg : districts) {
+			districtMap.put(dg.getId(), dg);
+		}
+		return districtMap;
+	}
 }

+ 18 - 0
src/main/java/com/goafanti/common/controller/PublicController.java

@@ -37,6 +37,7 @@ import com.goafanti.common.utils.PictureUtils;
 import com.goafanti.common.utils.TimeUtils;
 import com.goafanti.common.utils.VerifyCodeUtils;
 import com.goafanti.core.shiro.token.TokenManager;
+import com.goafanti.dataGlossory.service.DistrictGlossoryService;
 import com.goafanti.user.service.UserService;
 
 @Controller
@@ -66,6 +67,9 @@ public class PublicController extends BaseController {
 
 	@Autowired
 	private IndustryCategoryService	industryCategoryService;
+	
+	@Autowired
+	private DistrictGlossoryService	districtGlossoryService;
 
 	/**
 	 * 获取验证码
@@ -359,6 +363,20 @@ public class PublicController extends BaseController {
 		}
 		return new Result().data(industryCategoryService.list(pid));
 	}
+	
+	@RequestMapping(value = "/findDistrict", method = RequestMethod.GET)
+	@ResponseBody
+	public Result findDistrictGlossory(String id) {
+		Integer pid = 0;
+		if (StringUtils.isNumeric(id)) {
+			try {
+				pid = Integer.parseInt(id);
+			} catch (Exception e) {
+				pid = 0;
+			}
+		}
+		return new Result().data(districtGlossoryService.list(pid));
+	}
 
 	@RequestMapping(value = "/clearIndustryCategory", method = RequestMethod.GET)
 	@ResponseBody

+ 4 - 0
src/main/java/com/goafanti/common/dao/DistrictGlossoryMapper.java

@@ -1,5 +1,7 @@
 package com.goafanti.common.dao;
 
+import java.util.List;
+
 import com.goafanti.common.model.DistrictGlossory;
 
 public interface DistrictGlossoryMapper {
@@ -14,4 +16,6 @@ public interface DistrictGlossoryMapper {
     int updateByPrimaryKeySelective(DistrictGlossory record);
 
     int updateByPrimaryKey(DistrictGlossory record);
+    
+    List<DistrictGlossory> findByPid(Integer pid);
 }

+ 7 - 0
src/main/java/com/goafanti/common/mapper/DistrictGlossoryMapper.xml

@@ -79,4 +79,11 @@
       level = #{level,jdbcType=INTEGER}
     where id = #{id,jdbcType=INTEGER}
   </update>
+  
+  <select id="findByPid" parameterType="java.lang.Integer" resultMap="BaseResultMap">
+    select 
+    <include refid="Base_Column_List" />
+    from district_glossory
+    where pid = #{pid,jdbcType=INTEGER}
+  </select>
 </mapper>

+ 3 - 1
src/main/java/com/goafanti/core/cache/serializer/FastJsonRedisSerializer.java

@@ -9,7 +9,9 @@ import com.alibaba.fastjson.serializer.SerializerFeature;
 
 public class FastJsonRedisSerializer implements RedisSerializer<Object> {
 	public FastJsonRedisSerializer() {
-		ParserConfig.getGlobalInstance().addAccept("com.goafanti.common.model.IndustryCategory");
+		ParserConfig pc = ParserConfig.getGlobalInstance();
+		pc.addAccept("com.goafanti.common.model.IndustryCategory");
+		pc.addAccept("com.goafanti.common.model.DistrictGlossory");
 	}
 
 	@Override

+ 4 - 0
src/main/java/com/goafanti/dataGlossory/service/DistrictGlossoryService.java

@@ -1,9 +1,13 @@
 package com.goafanti.dataGlossory.service;
 
+import java.util.List;
+
 import com.goafanti.common.model.DistrictGlossory;
 
 public interface DistrictGlossoryService {
 
 	DistrictGlossory selectByPrimaryKey(Integer province);
+	
+	public List<DistrictGlossory> list(Integer pid);
 
 }

+ 15 - 0
src/main/java/com/goafanti/dataGlossory/service/impl/DistrictGlossoryServiceImpl.java

@@ -1,13 +1,21 @@
 package com.goafanti.dataGlossory.service.impl;
 
+import java.util.List;
+
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
 import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.cache.annotation.Cacheable;
 import org.springframework.stereotype.Service;
 
 import com.goafanti.common.dao.DistrictGlossoryMapper;
 import com.goafanti.common.model.DistrictGlossory;
+import com.goafanti.common.utils.LoggerUtils;
 import com.goafanti.dataGlossory.service.DistrictGlossoryService;
 @Service
 public class DistrictGlossoryServiceImpl implements DistrictGlossoryService {
+	private static final Logger	logger	= LoggerFactory.getLogger(DistrictGlossoryServiceImpl.class);
+	
 	@Autowired
 	private DistrictGlossoryMapper districtGlossoryMapper;
 
@@ -15,4 +23,11 @@ public class DistrictGlossoryServiceImpl implements DistrictGlossoryService {
 	public DistrictGlossory selectByPrimaryKey(Integer id) {
 		return districtGlossoryMapper.selectByPrimaryKey(id);
 	}
+	
+	@Override
+	@Cacheable(value = "DistrictGlossoryCache", key = "'DistrictGlossory:'+#pid")
+	public List<DistrictGlossory> list(Integer pid) {
+		LoggerUtils.debug(logger, "缓存地区列表:[%s]", pid);
+		return districtGlossoryMapper.findByPid(pid);
+	}
 }