Browse Source

咨询客户详情开发

anderx 1 year ago
parent
commit
6d27f9c394

+ 1 - 0
src/main/java/com/goafanti/common/dao/TaskAnnualReportMapper.java

@@ -81,5 +81,6 @@ public interface TaskAnnualReportMapper {
      */
     int deleteById(Integer id);
 
+    TaskAnnualReport selectByTidAndYear(@Param("tid") Integer tid, @Param("year") Integer year);
 }
 

+ 8 - 0
src/main/java/com/goafanti/common/mapper/TaskAnnualReportMapper.xml

@@ -94,6 +94,7 @@
         </where>
     </select>
 
+
     <!--新增所有列-->
     <insert id="insert" keyProperty="id" useGeneratedKeys="true">
         insert into task_annual_report(uid, tid, year, sales_amount, research_amount, aid, create_time)
@@ -162,5 +163,12 @@
         where id = #{id}
     </delete>
 
+    <select id="selectByTidAndYear" resultMap="TaskAnnualReportMap">
+        select
+        <include refid="TaskAnnualReportAllSql"/>
+        from task_annual_report
+        where tid = #{tid} and year = #{year}
+    </select>
+
 </mapper>
 

+ 3 - 0
src/main/java/com/goafanti/common/model/TaskAnnualReport.java

@@ -1,5 +1,7 @@
 package com.goafanti.common.model;
 
+import com.fasterxml.jackson.annotation.JsonFormat;
+
 import java.io.Serializable;
 import java.math.BigDecimal;
 import java.util.Date;
@@ -101,6 +103,7 @@ public class TaskAnnualReport implements Serializable {
         this.aid = aid;
     }
 
+    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
     public Date getCreateTime() {
         return createTime;
     }

+ 8 - 2
src/main/java/com/goafanti/techproject/service/impl/TaskAnnualReportServiceImpl.java

@@ -61,8 +61,14 @@ public class TaskAnnualReportServiceImpl extends BaseMybatisDao<TaskAnnualReport
         taskAnnualReport.setAid(TokenManager.getAdminId());
         taskAnnualReport.setUid(tOrderNew.getBuyerId());
         taskAnnualReport.setCreateTime(new Date());
-        this.taskAnnualReportMapper.insert(taskAnnualReport);
-        return taskAnnualReport;
+        TaskAnnualReport use = taskAnnualReportMapper.selectByTidAndYear(taskAnnualReport.getTid(), taskAnnualReport.getYear());
+        if (use !=null){
+            taskAnnualReport.setId(use.getId());
+            return update(taskAnnualReport);
+        }else {
+            this.taskAnnualReportMapper.insert(taskAnnualReport);
+            return taskAnnualReport;
+        }
     }
 
     /**