Browse Source

Merge remote-tracking branch 'origin/master'

zhengqiang 4 years ago
parent
commit
55d18af122

+ 8 - 0
picc-admin-server/src/main/java/com/jpsoft/picc/modules/base/controller/StudentInsuranceController.java

@@ -8,12 +8,14 @@ import com.jpsoft.picc.modules.base.entity.InsuranceJobs;
 import com.jpsoft.picc.modules.base.service.InsuranceDefinitionLimitService;
 import com.jpsoft.picc.modules.base.service.InsuranceDefinitionService;
 import com.jpsoft.picc.modules.base.service.InsuranceJobsService;
+import com.jpsoft.picc.modules.base.service.TemplateMessageService;
 import com.jpsoft.picc.modules.business.entity.StudentApplication;
 import com.jpsoft.picc.modules.business.entity.StudentApplicationRecord;
 import com.jpsoft.picc.modules.business.service.StudentApplicationRecordService;
 import com.jpsoft.picc.modules.business.service.StudentApplicationService;
 import com.jpsoft.picc.modules.common.config.OSSConfig;
 import com.jpsoft.picc.modules.common.config.PdfConfig;
+import com.jpsoft.picc.modules.common.constant.PolicyStatus;
 import com.jpsoft.picc.modules.common.constant.StudentPolicyStatus;
 import com.jpsoft.picc.modules.common.dto.MessageResult;
 import com.jpsoft.picc.modules.common.dto.Sort;
@@ -58,6 +60,8 @@ public class StudentInsuranceController {
     private OSSConfig ossConfig;
     @Autowired
     private PdfConfig pdfConfig;
+    @Autowired
+    private TemplateMessageService templateMessageService;
 
     @ApiOperation(value="获取保险信息")
     @PostMapping("detail")
@@ -503,6 +507,8 @@ public class StudentInsuranceController {
             studentApplicationRecord.setCreateTime(new Date());
             studentApplicationRecordService.insert(studentApplicationRecord);
 
+            templateMessageService.sendTemplateStudentMessage(studentApplication.getId(), 20);
+
             msgResult.setResult(true);
         }
         catch(Exception ex){
@@ -562,6 +568,8 @@ public class StudentInsuranceController {
                 msgResult.setData(map);
                 msgResult.setResult(true);
                 msgResult.setMessage("成功");
+
+                templateMessageService.sendTemplateStudentMessage(studentApplication.getId(), 81);
             } else {
                 msgResult.setResult(false);
                 msgResult.setMessage("数据库添加失败");

+ 1 - 1
picc-admin-server/src/main/java/com/jpsoft/picc/modules/business/controller/StudentApplicationController.java

@@ -655,7 +655,7 @@ public class StudentApplicationController {
             }
 
             //发送微信通知
-            //templateMessageService.sendTemplateMessage(applicationId, srcStudentPolicyStatus, destStudentPolicyStatus);
+            templateMessageService.sendTemplateStudentMessage(studentApplication.getId(), 30);
 
             msgResult.setResult(true);
             msgResult.setData(affectCount1);

+ 3 - 0
picc-common/src/main/java/com/jpsoft/picc/modules/base/entity/InsuranceDefinition.java

@@ -61,4 +61,7 @@ public class InsuranceDefinition {
 	private String responsibilityAttach;
 	@ApiModelProperty(value = "是否拥有附加险")
 	private Boolean haveAttach;
+
+	@ApiModelProperty(value = "是否显示")
+	private Boolean isShow;
 }

+ 2 - 0
picc-common/src/main/java/com/jpsoft/picc/modules/base/service/TemplateMessageService.java

@@ -18,4 +18,6 @@ public interface TemplateMessageService {
 
 	boolean sendTemplateMessage(String policyId, PolicyStatus srcPolicyStatus,PolicyStatus destPolicyStatus);
 	boolean sendTemplateExpiredMessage(String insuranceApplicationId,PolicyStatus destPolicyStatus);
+
+	boolean sendTemplateStudentMessage(String sApplicationId,int policyStatus);
 }

+ 103 - 0
picc-common/src/main/java/com/jpsoft/picc/modules/base/service/impl/TemplateMessageServiceImpl.java

@@ -13,8 +13,10 @@ import com.jpsoft.picc.modules.base.entity.CompanyUser;
 import com.jpsoft.picc.modules.base.entity.Message;
 import com.jpsoft.picc.modules.business.dao.InsuranceApplicationDAO;
 import com.jpsoft.picc.modules.business.dao.InsurancePolicyDAO;
+import com.jpsoft.picc.modules.business.dao.StudentApplicationDAO;
 import com.jpsoft.picc.modules.business.entity.InsuranceApplication;
 import com.jpsoft.picc.modules.business.entity.InsurancePolicy;
+import com.jpsoft.picc.modules.business.entity.StudentApplication;
 import com.jpsoft.picc.modules.common.config.WeixinConfig;
 import com.jpsoft.picc.modules.common.constant.PolicyStatus;
 import com.jpsoft.picc.modules.common.utils.JsonUtil;
@@ -65,6 +67,9 @@ public class TemplateMessageServiceImpl implements TemplateMessageService {
 	@Autowired
 	private UserDAO userDAO;
 
+	@Autowired
+	private StudentApplicationDAO studentApplicationDAO;
+
 	@Override
 	public TemplateMessage get(String id) {
 		// TODO Auto-generated method stub
@@ -392,4 +397,102 @@ public class TemplateMessageServiceImpl implements TemplateMessageService {
 
 		messageDAO.insert(message);
 	}
+
+
+	@Override
+	public boolean sendTemplateStudentMessage(String sApplicationId,int policyStatus) {
+		boolean result = false;
+
+		try {
+			StudentApplication studentApplication = studentApplicationDAO.get(sApplicationId);
+
+			List<TemplateMessage> templateMessageList = templateMessageDAO.findByPolicyStatus(policyStatus);
+
+			for (TemplateMessage templateMessage : templateMessageList) {
+				if (templateMessage==null){
+					throw new Exception("对应模板消息不存在!");
+				}
+				List<Map> targetList = new ArrayList<>();
+
+				if (templateMessage.getTarget().equals("JZRCCS") || templateMessage.getTarget().equals("PICC")) {
+					List<User> userList = userDAO.findByRoleName(templateMessage.getTarget());
+
+					for (User user : userList) {
+						Map<String, Object> userMap = new HashMap<>();
+						userMap.put("userId", user.getId());
+						userMap.put("openId", user.getOpenId());
+						userMap.put("target", templateMessage.getTarget());
+
+						targetList.add(userMap);
+					}
+				}
+
+				for (Map map : targetList) {
+					String userId = (String) map.get("userId");
+					String openId = (String) map.get("openId");
+					String target = (String) map.get("target");
+
+					sendStudentMessage(userId, openId,templateMessage, studentApplication);
+				}
+			}
+
+			result = true;
+		}
+		catch (Exception ex){
+			log.error(ex.getMessage(),ex);
+			result = false;
+		}
+
+		return result;
+	}
+
+	/**
+	 *
+	 * @param userId 接收消息用户编号
+	 * @param openId 接收消息用户微信openId
+	 * @param templateMessage 模板消息
+	 */
+	private void sendStudentMessage(String userId,String openId,
+									TemplateMessage templateMessage,
+									StudentApplication studentApplication){
+		String content = templateMessage.getContent();
+
+		Map<String,Object> contentVars = new HashMap<>();
+		contentVars.put("userName", studentApplication.getInsuredName());
+		contentVars.put("companyName", studentApplication.getInsuredName());
+
+
+		content = VelocityHelper.format(content,contentVars);
+
+		SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
+
+		Map<String,Object> jsonVars = new HashMap<>();
+
+		jsonVars.put("content",content);
+		jsonVars.put("time", DateTime.now().toString("yyyy-MM-dd HH:mm"));
+		jsonVars.put("companyName",studentApplication.getInsuredName());  //增加显示被保险人企业名称
+		jsonVars.put("type", "学平险");
+
+		String json = VelocityHelper.format(templateMessage.getJson(),jsonVars);
+		JSONObject jsonObject = new JSONObject(json);
+
+		if (StringUtils.isNotEmpty(openId)) {
+			//发送微信模板消息
+			new Thread(() -> WeixinUtil.sendTemplateMessage(weixinConfig,
+					openId, templateMessage.getCode(), jsonObject)
+			).start();
+		}
+
+		//写站内消息
+		Message message = new Message();
+		message.setId(UUID.randomUUID().toString());
+		message.setTitle(templateMessage.getTitle());
+		message.setContent(content);
+		message.setRecipientId(userId);
+		message.setStatus(false);
+		message.setDelFlag(false);
+		message.setCreateTime(new Date());
+
+		messageDAO.insert(message);
+	}
 }

+ 2 - 2
picc-common/src/main/java/com/jpsoft/picc/modules/common/utils/ItextPDFUtil.java

@@ -271,7 +271,7 @@ public class ItextPDFUtil {
         table.addCell(PdfTable.createCell("投保人数", textfont, Element.ALIGN_CENTER,1,1,BaseColor.WHITE,false));
         table.addCell(PdfTable.createCell(String.valueOf(list.size()), textfont, Element.ALIGN_CENTER,1,1,BaseColor.WHITE,false));
         table.addCell(PdfTable.createCell("联系电话", textfont, Element.ALIGN_CENTER,1,1,BaseColor.WHITE,false));
-        table.addCell(PdfTable.createCell(insuranceApplication.getInsuredTel(), textfont, Element.ALIGN_CENTER,1,1,BaseColor.WHITE,false));
+        table.addCell(PdfTable.createCell(insuranceApplication.getTel(), textfont, Element.ALIGN_CENTER,1,1,BaseColor.WHITE,false));
 
         table.addCell(PdfTable.createCell("联系地址", textfont, Element.ALIGN_CENTER,1,1,BaseColor.WHITE,false));
         table.addCell(PdfTable.createCell(insuranceApplication.getCompanyAddress(), textfont, Element.ALIGN_CENTER,3,1,BaseColor.WHITE,false));
@@ -1096,7 +1096,7 @@ public class ItextPDFUtil {
             companyName = companyName.substring(0,6);
         }
 
-        BaseFont font = BaseFont.createFont("C:/WINDOWS/Fonts/SIMSUN.TTC,1", "Identity-H", true);// 使用系统字体
+        BaseFont font = BaseFont.createFont("STSong-Light", "UniGB-UCS2-H", BaseFont.NOT_EMBEDDED);
         int pageSize = reader.getNumberOfPages();// 原pdf文件的总页数
         for (int i = 1; i <= pageSize; i++) {
             //左边start===============================================

+ 8 - 2
picc-common/src/main/resources/mapper/base/InsuranceDefinition.xml

@@ -23,6 +23,7 @@
         <result property="responsibility" column="responsibility_"/>
         <result property="responsibilityAttach" column="responsibility_attach"/>
         <result property="haveAttach" column="have_attach"/>
+        <result property="isShow" column="is_show"/>
     </resultMap>
     <insert id="insert" parameterType="com.jpsoft.picc.modules.base.entity.InsuranceDefinition">
         <!--
@@ -34,7 +35,8 @@
 		insert into base_insurance_definition
 	    (id_,name_,insurance_description,clause_,status_,del_flag,create_by,create_time,
 	    update_by,update_time,cut_off_time,notice_,advance_submit_days,
-	    letter_ ,special_statement ,exemption_instructions ,responsibility_ ,responsibility_attach ,have_attach
+	    letter_ ,special_statement ,exemption_instructions ,responsibility_ ,responsibility_attach ,have_attach,
+	    is_show
 	    )
 		values
 		(
@@ -57,6 +59,7 @@
 			,#{responsibility,jdbcType= VARCHAR }
 			,#{responsibilityAttach,jdbcType= VARCHAR }
 			,#{haveAttach,jdbcType= NUMERIC }
+			,#{isShow,jdbcType= NUMERIC }
 		)
 	]]>
     </insert>
@@ -120,6 +123,9 @@
             <if test="haveAttach!=null">
                 have_attach =#{haveAttach,jdbcType= NUMERIC },
             </if>
+            <if test="isShow!=null">
+                is_show =#{isShow,jdbcType= NUMERIC },
+            </if>
         </set>
         where id_=#{id}
     </update>
@@ -130,7 +136,7 @@
         select count(*) from base_insurance_definition where id_=#{0}
     </select>
     <select id="list" resultMap="InsuranceDefinitionMap">
-        select * from base_insurance_definition where del_flag=0
+        select * from base_insurance_definition where del_flag=0 and is_show=1
     </select>
     <select id="search" parameterType="hashmap" resultMap="InsuranceDefinitionMap">
         <![CDATA[