必须保证有唯一索引,可以是主键索引或者组合索引
<insert id="insertOrUpdate" parameterType="java.util.List">
INSERT INTO indicators_template_detail_rep(
id,indicators_name,indicators_id,dimension_name,dimension_id,
index1, index2, index3, index4, index5, index6, index7,unit, statistical_cycle_name,
statistical_type, stat_caliber, cal_logic,unit_id, statistical_cycle_id, statistical_type_id,
cal_Logic_Id,response_dept_id,source_dept_name,response_dept_name, indicators_full_name,template_id
) VALUES
<foreach collection="list" item="item" separator=",">
(
#{item.id},#{item.indicatorsName},#{item.indicatorsId},#{item.dimensionName},#{item.dimensionId} ,
#{item.index1} ,#{item.index2},#{item.index3},#{item.index4},#{item.index5},#{item.index6},#{item.index7},#{item.unit},#{item.statisticalCycleName},
#{item.statisticalType},#{item.statCaliber},#{item.calLogic},#{item.unitId},#{item.statisticalCycleId},#{item.statisticalTypeId},
#{item.calLogicId},#{item.responseDeptId},#{item.sourceDeptName},#{item.responseDeptName},#{item.indicatorsFullName},#{item.templateId}
)
</foreach>
ON DUPLICATE KEY UPDATE
is_deleted=0,
indicators_name=VALUES(indicators_name),
indicators_id=VALUES(indicators_id),
dimension_name=VALUES(dimension_name),
dimension_id=VALUES(dimension_id),
index1=VALUES(index1),
index2=VALUES(index2),
index3=VALUES(index3),
index4=VALUES(index4),
index5=VALUES(index5),
index6=VALUES(index6),
index7=VALUES(index7),
unit=VALUES(unit),
statistical_cycle_name=VALUES(statistical_cycle_name),
statistical_type=VALUES(statistical_type),
stat_caliber=VALUES(stat_caliber),
cal_logic=VALUES(cal_logic),
unit_id=VALUES(unit_id),
statistical_cycle_id=VALUES(statistical_cycle_id),
statistical_type_id=VALUES(statistical_type_id),
cal_Logic_Id=VALUES(cal_Logic_Id),
response_dept_id=VALUES(response_dept_id),
source_dept_name=VALUES(source_dept_name),
response_dept_name=VALUES(response_dept_name),
indicators_full_name=VALUES(indicators_full_name)
</insert>