1.实现生成周次的时间变化规则
<insert id="insertEQC02" parameterType="cn.midas.erp.eqqc.contract.data.entity.EQQC08">
insert into teqqc02(id,INTERNAL_CODE,plan_id,PLAN_TYPE,duty_dept_id,duty_dept_name,CHECK_STANDARD_ID,PLAN_SOURCE,
plan_date_start,plan_date_end,DEVICE_TYPE,CLASS_FIRST,DEVICE_UNIT,DEVICE_AREA
)
select (t1.PLAN_ID||t1.PLAN_TYPE||t1.DUTY_DEPT_ID||t2.CHECK_STANDARD_ID||to_char(sysdate,'yyyyMMdd')) as ID,
(select dbms_random.string('A',20) from dual)||t1.PLAN_ID as INTERNAL_CODE,
t1.plan_id,t1.PLAN_TYPE ,t1.duty_dept_id,t1.duty_dept_name,t2.CHECK_STANDARD_ID,'10' as PLAN_SOURCE ,
(SELECT TRUNC(TO_DATE(to_char(sysdate,'yyyy-MM-dd'),'yyyy-MM-dd'),'IW')+7 FROM DUAL) as plan_date_start,
(SELECT TRUNC(TO_DATE(to_char(sysdate,'yyyy-MM-dd'),'YYYY-MM-DD'),'IW') + 11 FROM DUAL) as plan_date_end,
t2.DEVICE_TYPE,
t2.CLASS_FIRST,
subStr(t2.DEVICE_ID,0,2),
subStr(t2.DEVICE_ID,0,4)
from teqqc08 t1,teqqc10 t2 where t1.plan_id=t2.plan_id
and t1.PLAN_TYPE='ZJ' and t1.AUDIT_STATUS='10'
<if test="planId neq null and planId neq ''">
and t1.plan_id = #{planId}
</if>
</insert>
2.实现月次的时间变化鬼贼
insert into teqqc02(id,INTERNAL_CODE,plan_id,PLAN_TYPE,duty_dept_id,duty_dept_name,CHECK_STANDARD_ID,PLAN_SOURCE,
plan_date_start,plan_date_end,DEVICE_TYPE,CLASS_FIRST,DEVICE_UNIT,DEVICE_AREA
)
select (t1.PLAN_ID||t1.PLAN_TYPE||t1.DUTY_DEPT_ID||t2.CHECK_STANDARD_ID||to_char(sysdate,'yyyyMMdd')) as ID,
(select dbms_random.string('A',20) from dual)||t1.PLAN_ID as INTERNAL_CODE,
t1.plan_id,t1.PLAN_TYPE ,t1.duty_dept_id,t1.duty_dept_name,t2.CHECK_STANDARD_ID,'10' as PLAN_SOURCE ,
(SELECT trunc(sysdate,'MM') FROM DUAL) as plan_date_start,
(SELECT TO_DATE(to_char(last_day(sysdate),'yyyy-MM-dd'),'YYYY-MM-DD') FROM DUAL) as plan_date_end,
t2.DEVICE_TYPE,
t2.CLASS_FIRST,
subStr(t2.DEVICE_ID,0,2),
subStr(t2.DEVICE_ID,0,4)
from teqqc08 t1,teqqc10 t2 where t1.plan_id=t2.plan_id
and t1.PLAN_TYPE='YJ' and t1.AUDIT_STATUS='10'
<if test="planId neq null and planId neq ''">
and t1.plan_id = #{planId}
</if>