@@ -81,5 +81,6 @@ public interface TaskAnnualReportMapper {
*/
int deleteById(Integer id);
+ TaskAnnualReport selectByTidAndYear(@Param("tid") Integer tid, @Param("year") Integer year);
}
@@ -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>
@@ -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;
@@ -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;
+ }
/**