Browse Source

修改中间表BUG

Signed-off-by: anderx <312518615@qq.com>
anderx 5 years ago
parent
commit
ddd2d09e57

+ 5 - 0
src/main/java/com/goafanti/common/dao/PersonnelMidMapper.java

@@ -2,6 +2,8 @@ package com.goafanti.common.dao;
 
 import com.goafanti.common.model.PersonnelMid;
 import com.goafanti.common.model.PersonnelMidExample;
+import com.goafanti.personnel.bo.IntpersonnelWelfareBo;
+
 import java.util.List;
 import org.apache.ibatis.annotations.Param;
 
@@ -72,4 +74,7 @@ public interface PersonnelMidMapper {
 	 * @mbg.generated  Thu May 07 14:15:57 CST 2020
 	 */
 	int updateByPrimaryKey(PersonnelMid record);
+
+	void updateByidTime(@Param("m")PersonnelMid m, @Param("type")Integer type);
+
 }

+ 31 - 0
src/main/java/com/goafanti/common/mapper/PersonnelMidMapper.xml

@@ -491,4 +491,35 @@
       welfare_remarks = #{welfareRemarks,jdbcType=VARCHAR}
     where id = #{id,jdbcType=INTEGER}
   </update>
+  
+  <update id="updateByidTime" >
+   
+    update personnel_mid
+    <set>
+    	<if test="type==null">
+      <if test="m.welfareAnnexUrl != null">
+        welfare_annex_url = #{m.welfareAnnexUrl,jdbcType=VARCHAR},
+      </if>
+      <if test="m.welfareAnnexName != null">
+        welfare_annex_name = #{m.welfareAnnexName,jdbcType=VARCHAR},
+      </if>
+       <if test="m.welfareRemarks != null">
+        welfare_remarks = #{welfareRemarks,jdbcType=VARCHAR},
+      </if>
+    	</if>
+      <if test="type==0">
+        insurance_start_time = #{m.insuranceStartTime,jdbcType=TIMESTAMP},
+        insurance_end_time = #{m.insuranceEndTime,jdbcType=TIMESTAMP},
+      </if>
+      <if test="type==1">
+        fund_start_time = #{m.fundStartTime,jdbcType=TIMESTAMP},
+        fund_end_time = #{m.fundEndTime,jdbcType=TIMESTAMP},
+      </if>
+      <if test="type==2">
+        employer_start_time = #{m.employerStartTime,jdbcType=TIMESTAMP},
+        employer_end_time = #{m.employerEndTime,jdbcType=TIMESTAMP},
+      </if>
+    </set>
+    where id = #{m.id,jdbcType=INTEGER}
+  </update>
 </mapper>

+ 10 - 2
src/main/java/com/goafanti/personnel/controller/AdminPersonnelApiController.java

@@ -223,8 +223,16 @@ public class AdminPersonnelApiController extends CertifyApiController {
 			return res;
 		}
 		try {
-			if ( !StringUtils.isBlank(i.getStartTimes()))i.setStartTime(DateUtils.StringToDate(i.getStartTimes(), AFTConstants.YYYYMMDD));
-			if ( !StringUtils.isBlank(i.getEndTimes()))i.setEndTime(DateUtils.StringToDate(i.getEndTimes(), AFTConstants.YYYYMMDD));
+			if ( !StringUtils.isBlank(i.getStartTimes())) {
+				i.setStartTime(DateUtils.StringToDate(i.getStartTimes(), AFTConstants.YYYYMMDD));
+			}else {
+				i.setStartTime(null);
+			}
+			if ( !StringUtils.isBlank(i.getEndTimes())) {
+				i.setEndTime(DateUtils.StringToDate(i.getEndTimes(), AFTConstants.YYYYMMDD));
+			}else {
+				i.setEndTime(null);
+			}
 		} catch (ParseException e) {
 			res.getError().add(buildError(ErrorConstants.PARAM_ERROR, "日期", "日期"));
 			return res;

+ 10 - 16
src/main/java/com/goafanti/personnel/service/impl/PersonnelServiceImpl.java

@@ -432,10 +432,14 @@ public class PersonnelServiceImpl  extends BaseMybatisDao<PersonnelDossierMapper
 				personnelWelfareMapper.insertSelective(i);
 			}
 		}else {
-			personnelWelfareMapper.updateByPrimaryKeySelective(i);
+			personnelWelfareMapper.updateByPrimaryKey(i);
 		}
 		PersonnelMid m=new PersonnelMid();
 		m.setId(i.getPdId());
+		m.setWelfareAnnexUrl(i.getAnnexUrl());
+		m.setWelfareAnnexName(i.getAnnexName());
+		m.setWelfareRemarks(i.getRemarks());
+		PersonnelMid pm=personnelMidMapper.selectByPrimaryKey(i.getPdId());
 		if (i.getType()!=null) {
 			if (i.getType()==0) {
 				m.setInsuranceStartTime(i.getStartTime());
@@ -448,22 +452,12 @@ public class PersonnelServiceImpl  extends BaseMybatisDao<PersonnelDossierMapper
 				m.setEmployerEndTime(i.getEndTime());
 			}
 		}
-		m.setWelfareAnnexUrl(i.getAnnexUrl());
-		m.setWelfareAnnexName(i.getAnnexName());
-		m.setWelfareRemarks(i.getRemarks());
-		if (m.getInsuranceStartTime()!=null||m.getInsuranceEndTime()!=null||
-			m.getFundStartTime()!=null||m.getFundEndTime()!=null||
-			m.getEmployerStartTime()!=null||m.getEmployerEndTime()!=null||
-			m.getWelfareAnnexUrl()!=null|| m.getWelfareRemarks()!=null) {
-			PersonnelMid pm=personnelMidMapper.selectByPrimaryKey(i.getPdId());
-			if (pm==null||pm.getId()==null) {
-				personnelMidMapper.insertSelective(m);
-			}else {
-				personnelMidMapper.updateByPrimaryKeySelective(m);
-				
-			}
+		if (pm==null||pm.getId()==null) {
+			personnelMidMapper.insertSelective(m);
+		}else {
+			personnelMidMapper.updateByidTime(m,i.getType());
+			
 		}
-		
 		return 1;
 	}
 }

+ 1 - 1
src/main/resources/props/config_local.properties

@@ -5,7 +5,7 @@ jdbc.driverClassName=com.mysql.jdbc.Driver
 #jdbc.username=dev
 #jdbc.password=123456
 #测试
-jdbc.url=jdbc:mysql://101.37.32.31:3306/aft20200511?useUnicode=true&characterEncoding=UTF-8&autoReconnect=true&useSSL=false
+jdbc.url=jdbc:mysql://101.37.32.31:3306/aft?useUnicode=true&characterEncoding=UTF-8&autoReconnect=true&useSSL=false
 jdbc.username=root
 jdbc.password=aftdev
 #\u68c0\u6d4b\u6570\u636e\u5e93\u94fe\u63a5\u662f\u5426\u6709\u6548\uff0c\u5fc5\u987b\u914d\u7f6e