# PiLotReqDAOImpl.java

    package com.mycim.server.pilot.dao.impl;

    import com.fa.sesa.exception.Assert;
    import com.fa.sesa.exception.Errors;
    import com.mycim.framework.jdbc.JdbcTemplate;
    import com.mycim.framework.utils.lang.BooleanUtils;
    import com.mycim.server.pilot.dao.PiLotReqDAO;
    import com.mycim.valueobject.ems.pilot.*;
    import org.springframework.beans.factory.annotation.Autowired;
    import org.springframework.stereotype.Repository;

    /**
     * @author songpy
     * @version 1.0.0
     * @date 2021/8/26
     **/
    @Repository
    public class PiLotReqDAOImpl implements PiLotReqDAO {
        @Autowired
        JdbcTemplate jdbcTemplate;

        @Override
        public void insertPiLotSetup(PiLotSetup piLotSetup) {
            String sql = "INSERT INTO PI_LOT_SETUP (pi_lot_rrn,pi_lot_id,pi_lot_type,status,enable_flag,eqpt_id,eqpt_rrn," +
                    "wafer_qty,wafer_rule_id,retry_count,create_time,update_time,create_user_rrn,update_user_rrn," +
                    "lock_version,PARALLEL_RUN_TYPE) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)";
            int updateNumber = jdbcTemplate.update(sql, piLotSetup.getPiLotRrn(), piLotSetup.getPiLotId(),
                                                   piLotSetup.getType(), piLotSetup.getStatus(), piLotSetup.getEnableFlag(),
                                                   piLotSetup.getEqptId(), piLotSetup.getEqptRrn(), piLotSetup.getQty(),
                                                   piLotSetup.getRuleId(), piLotSetup.getRetryCount(),
                                                   piLotSetup.getCreateTime(), piLotSetup.getUpdateTime(),
                                                   piLotSetup.getCreateUserRrn(), piLotSetup.getUpdateUserRrn(),
                                                   piLotSetup.getVersion(),piLotSetup.getParallelRunType());
            Assert.state(updateNumber == 1,
                         Errors.create().content("DB update is abnormal and does not match the expected number").build());
        }

        @Override
        public void insertPiLotSetupIdle(PiLotSetup piLotSetup, IdleType idle) {
            String sql = "INSERT INTO PI_LOT_SETUP_IDLE_TIME (PI_LOT_RRN,PI_LOT_ID,MAX_RUN_TIME,IDLE_TIME,RESET_COMMENT," +
                    "SUB_TYPE) VALUES (?,?,?,?,?,?)";
            int updateNumber = jdbcTemplate.update(sql, piLotSetup.getPiLotRrn(), piLotSetup.getPiLotId(),
                                                   idle.getMaxRunTime(), idle.getIdleTime(), idle.getResetComment(),
                                                   idle.getSubType());
            Assert.state(updateNumber == 1,
                         Errors.create().content("DB update is abnormal and does not match the expected number").build());
        }

        @Override
        public void insertPiLotSetupPM(PiLotSetup piLotSetup, PmType pm) {
            String sql = "INSERT INTO PI_LOT_SETUP_PM (PI_LOT_RRN,PI_LOT_ID,BUFFER_TIME,CONSTRAINT_RECIPE_RRN," +
                    "CONSTRAINT_RECIPE_ID) VALUES (?,?,?,?,?)";
            int updateNumber = jdbcTemplate.update(sql, piLotSetup.getPiLotRrn(), piLotSetup.getPiLotId(),
                                                   pm.getBufferTime(), pm.getConstraintRcpRrn(), pm.getConstraintRcpId());
            Assert.state(updateNumber == 1,
                         Errors.create().content("DB update is abnormal and does not match the expected number").build());
        }

        @Override
        public void insertPiLotSetupCount(PiLotSetup piLotSetup, CountType count) {
            String sql = "INSERT INTO PI_LOT_SETUP_COUNT (PI_LOT_RRN,PI_LOT_ID,COUNT_TYPE,COUNT_SPEC,TIME_POINT," +
                    "TRIGGER_RECIPE_RRN,TRIGGER_RECIPE_ID,CONSTRAINT_RECIPE_RRN,CONSTRAINT_RECIPE_ID) VALUES (?, ?, ?, ?," +
                    " ?, ?, ?, ?, ?)";
            int updateNumber = jdbcTemplate.update(sql, piLotSetup.getPiLotRrn(), piLotSetup.getPiLotId(), count.getType(),
                                                   count.getCountSpec(), count.getTimePoint(), count.getTriggerRcpRrn(),
                                                   count.getTriggerRcpId(), count.getConstraintRcpRrn(),
                                                   count.getConstraintRcpId());
            Assert.state(updateNumber == 1,
                         Errors.create().content("DB update is abnormal and does not match the expected number").build());
        }

        @Override
        public void insertPiLotSetupRcpGrp(PiLotSetup piLotSetup, RcpGrpType rcpGrp) {
            String sql = "INSERT INTO PI_LOT_SETUP_RCP_GRP (PI_LOT_RRN,PI_LOT_ID,FROM_RCP_GRP_ID,FROM_RCP_GRP_RRN," +
                    "TO_RCP_GRP_ID,TO_RCP_GRP_RRN) VALUES (?,?,?,?,?,?)";
            int updateNumber = jdbcTemplate.update(sql, piLotSetup.getPiLotRrn(), piLotSetup.getPiLotId(),
                                                   rcpGrp.getFromRcpGrpId(), rcpGrp.getFromRcpGrpRrn(),
                                                   rcpGrp.getToRcpGrpId(), rcpGrp.getToRcpGrpRrn());
            Assert.state(updateNumber == 1,
                         Errors.create().content("DB update is abnormal and does not match the expected number").build());
        }

        @Override
        public void insertPiLotSetupHistory(PiLotSetupH piLotSetupH) {
            String sql = "INSERT INTO PI_LOT_SETUP_H (trans_rrn,trans_id,pi_lot_rrn,pi_lot_id,pi_lot_type,status," +
                    "enable_flag,eqpt_id,eqpt_rrn,wafer_qty,wafer_rule_id,retry_count,trans_user_rrn,trans_time," +
                    "trans_user_id,parallel_run_type) VALUES " + "(?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)";
            int updateNumber = jdbcTemplate.update(sql, piLotSetupH.getTransRrn(), piLotSetupH.getTransId(),
                                                   piLotSetupH.getPiLotRrn(), piLotSetupH.getPiLotId(),
                                                   piLotSetupH.getType(), piLotSetupH.getStatus(),
                                                   piLotSetupH.getEnableFlag(), piLotSetupH.getEqptId(),
                                                   piLotSetupH.getEqptRrn(), piLotSetupH.getQty(), piLotSetupH.getRuleId(),
                                                   piLotSetupH.getRetryCount(), piLotSetupH.getTransUserRrn(),
                                                   piLotSetupH.getTransTime(), piLotSetupH.getTransUserId(),
                                                   piLotSetupH.getParallelRunType());
            Assert.state(updateNumber == 1,
                         Errors.create().content("DB update is abnormal and does not match the expected number").build());
        }

        @Override
        public void updatePiLotSetup(PiLotSetup piLotSetup) {
            String sql = "UPDATE PI_LOT_SETUP " +
                    "SET ENABLE_FLAG= ?,status= ?,WAFER_QTY= ?,RETRY_COUNT=?,UPDATE_TIME=?,UPDATE_USER_RRN=?, PARALLEL_RUN_TYPE=? WHERE " +
                    "PI_LOT_RRN= ?";
            int updateNumber = jdbcTemplate.update(sql, piLotSetup.getEnableFlag(), piLotSetup.getStatus(),
                                                   piLotSetup.getQty(), piLotSetup.getRetryCount(),
                                                   piLotSetup.getUpdateTime(), piLotSetup.getUpdateUserRrn(),
                                                   piLotSetup.getParallelRunType(),
                                                   piLotSetup.getPiLotRrn());
            Assert.state(updateNumber == 1,
                         Errors.create().content("DB update is abnormal and does not match the expected number").build());
        }

        @Override
        public void deletePiLotSetup(Long piLotSetupRrn) {
            String sql = "DELETE FROM PI_LOT_SETUP WHERE PI_LOT_RRN = ? ";
            int updateNumber = jdbcTemplate.update(sql, piLotSetupRrn);
            Assert.state(updateNumber == 1,
                         Errors.create().content("DB update is abnormal and does not match the expected number").build());
        }

        @Override
        public void insertPiLotView(PiLotView piLotView) {
            String sql = "INSERT INTO PI_LOT_VIEW (VIEW_RRN,VIEW_ID,PI_LOT_RRN,PI_LOT_ID,PI_LOT_TYPE,STATUS,EQPT_ID," +
                    "EQPT_RRN,WAFER_QTY,RETRY_COUNT,LOT_ID,LOT_RRN,FLOW_COMPLETE,CAN_SPLIT,START_ROUTE_ID," +
                    "START_ROUTE_RRN," +
                    "START_STEP_ID,START_STEP_RRN,END_ROUTE_ID,END_ROUTE_RRN,END_STEP_ID,END_STEP_RRN,CREATE_TIME," +
                    "UPDATE_TIME,CREATE_USER_RRN,UPDATE_USER_RRN,LOCK_VERSION,PARALLEL_RUN_TYPE) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, " +
                    "?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)";
            int updateNumber = jdbcTemplate.update(sql, piLotView.getViewRrn(), piLotView.getViewId(),
                                                   piLotView.getPiLotRrn(), piLotView.getPiLotId(), piLotView.getType(),
                                                   piLotView.getStatus(), piLotView.getEqptId(), piLotView.getEqptRrn(),
                                                   piLotView.getQty(), piLotView.getRetryCount(), piLotView.getBoundLotId(),
                                                   piLotView.getBoundLotRrn(),
                                                   BooleanUtils.toString(piLotView.getComplete(), "1", "0", "0"),
                                                   BooleanUtils.toString(piLotView.getCanSplit(), "1", "0", "0"),
                                                   piLotView.getStartRoute(), piLotView.getStartRouteRrn(),
                                                   piLotView.getStartStep(), piLotView.getStartStepRrn(),
                                                   piLotView.getEndRoute(), piLotView.getEndRouteRrn(),
                                                   piLotView.getEndStep(), piLotView.getEndStepRrn(),
                                                   piLotView.getCreateTime(), piLotView.getUpdateTime(),
                                                   piLotView.getCreateUserRrn(), piLotView.getUpdateUserRrn(),
                                                   piLotView.getVersion(), piLotView.getParallelRunType());
            Assert.state(updateNumber == 1,
                         Errors.create().content("DB update is abnormal and does not match the expected number").build());
        }

        @Override
        public void insertPiLotViewH(PiLotViewH piLotViewH) {
            String sql = "INSERT INTO PI_LOT_VIEW_H (trans_rrn,trans_id,view_rrn,view_id,pi_lot_rrn,pi_lot_id," +
                    "pi_lot_type,status,eqpt_id,eqpt_rrn,wafer_qty,retry_count,lot_id,lot_rrn,child_lot_id,child_lot_rrn," +
                    "flow_complete,can_split,START_ROUTE_ID,START_ROUTE_RRN,START_STEP_ID,START_STEP_RRN,END_ROUTE_ID," +
                    "END_ROUTE_RRN,END_STEP_ID,END_STEP_RRN,trans_user_rrn,trans_time,trans_user_id,single_lot,PARALLEL_RUN_TYPE,COMMENTS) VALUES (?, ?, ?, ?, " +
                    "?, ?, ?, ?, ?," + " ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)";
            int updateNumber = jdbcTemplate.update(sql, piLotViewH.getTransRrn(), piLotViewH.getTransId(),
                                                   piLotViewH.getViewRrn(), piLotViewH.getViewId(),
                                                   piLotViewH.getPiLotRrn(), piLotViewH.getPiLotId(), piLotViewH.getType(),
                                                   piLotViewH.getStatus(), piLotViewH.getEqptId(), piLotViewH.getEqptRrn(),
                                                   piLotViewH.getQty(), piLotViewH.getRetryCount(),
                                                   piLotViewH.getBoundLotId(), piLotViewH.getBoundLotRrn(),
                                                   piLotViewH.getChildLotId(), piLotViewH.getChildLotRrn(),
                                                   BooleanUtils.toString(piLotViewH.getComplete(), "1", "0", "0"),
                                                   BooleanUtils.toString(piLotViewH.getCanSplit(), "1", "0", "0"),
                                                   piLotViewH.getStartRoute(), piLotViewH.getStartRouteRrn(),
                                                   piLotViewH.getStartStep(), piLotViewH.getStartStepRrn(),
                                                   piLotViewH.getEndRoute(), piLotViewH.getEndRouteRrn(),
                                                   piLotViewH.getEndStep(), piLotViewH.getEndStepRrn(),
                                                   piLotViewH.getTransUserRrn(), piLotViewH.getTransTime(),
                                                   piLotViewH.getTransUserId(), piLotViewH.getSingleLot(),
                                                   piLotViewH.getParallelRunType(), piLotViewH.getComments());
            Assert.state(updateNumber == 1,
                         Errors.create().content("DB update is abnormal and does not match the expected number").build());
        }

        @Override
        public void updatePiLotView(PiLotView piLotView) {
            String sql =
                    "UPDATE PI_LOT_VIEW SET LOT_ID= ?,LOT_RRN= ?,CHILD_LOT_ID=?,CHILD_LOT_RRN=?,STATUS=?,retry_count=?," +
                            "FLOW_COMPLETE= ?,can_split=?,START_ROUTE_ID=?,START_ROUTE_RRN=?,START_STEP_ID=?," +
                            "START_STEP_RRN=?,end_ROUTE_ID=?,end_ROUTE_RRN=?,end_STEP_ID=?,end_STEP_RRN=?," +
                            "UPDATE_TIME=?,UPDATE_USER_RRN=?,SINGLE_LOT=?,PARALLEL_RUN_TYPE=? WHERE VIEW_RRN= ?";
            int updateNumber = jdbcTemplate.update(sql, piLotView.getBoundLotId(), piLotView.getBoundLotRrn(),
                                                   piLotView.getChildLotId(), piLotView.getChildLotRrn(),
                                                   piLotView.getStatus(), piLotView.getRetryCount(),
                                                   BooleanUtils.toString(piLotView.getComplete(), "1", "0", "0"),
                                                   BooleanUtils.toString(piLotView.getCanSplit(), "1", "0", "0"),
                                                   piLotView.getStartRoute(), piLotView.getStartRouteRrn(),
                                                   piLotView.getStartStep(), piLotView.getStartStepRrn(),
                                                   piLotView.getEndRoute(), piLotView.getEndRouteRrn(),
                                                   piLotView.getEndStep(), piLotView.getEndStepRrn(),
                                                   piLotView.getUpdateTime(), piLotView.getUpdateUserRrn(),
                                                   piLotView.getSingleLot(), piLotView.getParallelRunType(),
                                                   piLotView.getViewRrn());
            Assert.state(updateNumber == 1,
                         Errors.create().content("DB update is abnormal and does not match the expected number").build());
        }

        @Override
        public void insertPiLotRcpGrp(PiLotRcpGrp piLotRcpGrp) {
            String sql = "INSERT INTO PI_LOT_RECIPE_GROUP (rcp_grp_rrn,rcp_grp_id,create_time,update_time," +
                    "create_user_rrn,update_user_rrn,lock_version,rcp_grp_desc) VALUES (?, ?, ?, ?, ?, ?, ?, ?)";
            int updateNumber = jdbcTemplate.update(sql, piLotRcpGrp.getRcpGrpRrn(), piLotRcpGrp.getRcpGrpId(),
                                                   piLotRcpGrp.getCreateTime(), piLotRcpGrp.getUpdateTime(),
                                                   piLotRcpGrp.getCreateUserRrn(), piLotRcpGrp.getUpdateUserRrn(),
                                                   piLotRcpGrp.getVersion(), piLotRcpGrp.getRcpGrpDesc());
            Assert.state(updateNumber == 1,
                         Errors.create().content("DB update is abnormal and does not match the expected number").build());
        }

        @Override
        public void updatePiLotRcpGrp(PiLotRcpGrp piLotRcpGrp) {
            String sql = "UPDATE PI_LOT_RECIPE_GROUP SET RCP_GRP_DESC= ? WHERE RCP_GRP_RRN= ?";
            int updateNumber = jdbcTemplate.update(sql, piLotRcpGrp.getRcpGrpDesc(), piLotRcpGrp.getRcpGrpRrn());
            Assert.state(updateNumber == 1,
                         Errors.create().content("DB update is abnormal and does not match the expected number").build());
        }

        @Override
        public void insertPiLotRcpGrpH(PiLotRcpGrpH rcpGrpH) {
            String sql = "INSERT INTO PI_LOT_RECIPE_GROUP_H (trans_rrn,trans_id,rcp_grp_rrn,rcp_grp_id,trans_user_rrn," +
                    "trans_time,rcp_grp_desc) VALUES (?, ?, ?, ?, ?, ?, ?)";
            int updateNumber = jdbcTemplate.update(sql, rcpGrpH.getTransRrn(), rcpGrpH.getTransId(), rcpGrpH.getRcpGrpRrn(),
                                                   rcpGrpH.getRcpGrpId(), rcpGrpH.getTransUserRrn(), rcpGrpH.getTransTime(),
                                                   rcpGrpH.getRcpGrpDesc());
            Assert.state(updateNumber == 1,
                         Errors.create().content("DB update is abnormal and does not match the expected number").build());
        }

        @Override
        public void insertPiLotRcpMapping(PiLotRcpMaping maping) {
            String sql = "INSERT INTO PI_LOT_RECIPE_GROUP_MAPPING (rcp_grp_rrn,rcp_grp_id,recipe_id,recipe_rrn) VALUES " +
                    "(?, ?, ?, ?)";
            int updateNumber = jdbcTemplate.update(sql, maping.getRcpGrpRrn(), maping.getRcpGrpId(), maping.getRcpId(),
                                                   maping.getRcpRrn());
            Assert.state(updateNumber == 1,
                         Errors.create().content("DB update is abnormal and does not match the expected number").build());
        }

        @Override
        public void insertPiLotRcpMappingH(PiLotRcpMapingH mapingH) {
            String sql = "INSERT INTO PI_LOT_RCP_GRP_MAPPING_H (trans_rrn,trans_id,rcp_grp_rrn,rcp_grp_id,recipe_id," +
                    "recipe_rrn,trans_user_rrn,trans_time,trans_user_id) VALUES (?,?,?,?,?,?,?,?,?)";
            int updateNumber = jdbcTemplate.update(sql, mapingH.getTransRrn(), mapingH.getTransId(), mapingH.getRcpGrpRrn(),
                                                   mapingH.getRcpGrpId(), mapingH.getRcpId(), mapingH.getRcpRrn(),
                                                   mapingH.getTransUserRrn(), mapingH.getTransTime(),
                                                   mapingH.getTransUserId());
            Assert.state(updateNumber == 1,
                         Errors.create().content("DB update is abnormal and does not match the expected number").build());
        }

        @Override
        public void deletePiLotRcpMapping(PiLotRcpMaping maping) {
            String sql = "DELETE FROM PI_LOT_RECIPE_GROUP_MAPPING WHERE RCP_GRP_RRN=? AND RECIPE_RRN= ?";
            int updateNumber = jdbcTemplate.update(sql, maping.getRcpGrpRrn(), maping.getRcpRrn());
            Assert.state(updateNumber == 1,
                         Errors.create().content("DB update is abnormal and does not match the expected number").build());
        }

        @Override
        public void insertPiLotSetupIdleHistory(IdleTypeH idleTypeH, PiLotSetup piLotSetup) {
            String sql = "INSERT INTO PI_LOT_SETUP_IDLE_TIME_H (trans_rrn,trans_id,pi_lot_rrn,pi_lot_id,max_run_time," +
                    "idle_time,reset_comment,sub_type,trans_user_rrn,trans_time,trans_user_id) VALUES (?, ?, ?, ?, ?, ?, " +
                    "?, ?, ?, ?, ?)";
            int updateNumber = jdbcTemplate.update(sql, idleTypeH.getTransRrn(), idleTypeH.getTransId(),
                                                   piLotSetup.getPiLotRrn(), piLotSetup.getPiLotId(),
                                                   idleTypeH.getMaxRunTime(), idleTypeH.getIdleTime(),
                                                   idleTypeH.getResetComment(), idleTypeH.getSubType(),
                                                   idleTypeH.getTransUserRrn(), idleTypeH.getTransTime(),
                                                   idleTypeH.getTransUserId());
            Assert.state(updateNumber == 1,
                         Errors.create().content("DB update is abnormal and does not match the expected number").build());
        }

        @Override
        public void insertPiLotSetupPMHistory(PmTypeH pmTypeH, PiLotSetup piLotSetup) {
            String sql = "INSERT INTO PI_LOT_SETUP_PM_H (trans_rrn,trans_id,pi_lot_rrn,pi_lot_id,buffer_time," +
                    "constraint_recipe_rrn,constraint_recipe_id,trans_user_rrn,trans_time,trans_user_id) VALUES (?, ?, ?," +
                    " ?, ?, ?, ?, " + "?, ?, ?)";

            int updateNumber = jdbcTemplate.update(sql, pmTypeH.getTransRrn(), pmTypeH.getTransId(),
                                                   piLotSetup.getPiLotRrn(), piLotSetup.getPiLotId(),
                                                   pmTypeH.getBufferTime(), pmTypeH.getConstraintRcpRrn(),
                                                   pmTypeH.getConstraintRcpId(), pmTypeH.getTransUserRrn(),
                                                   pmTypeH.getTransTime(), pmTypeH.getTransUserId());
            Assert.state(updateNumber == 1,
                         Errors.create().content("DB update is abnormal and does not match the expected number").build());
        }

        @Override
        public void insertPiLotSetupCountHistory(CountTypeH countTypeH, PiLotSetup piLotSetup) {
            String sql = "INSERT INTO PI_LOT_SETUP_COUNT_H (trans_rrn,trans_id,pi_lot_rrn,pi_lot_id,count_type," +
                    "count_spec,time_point,trigger_recipe_rrn,trigger_recipe_id,constraint_recipe_rrn," +
                    "constraint_recipe_id,trans_user_rrn,trans_time,trans_user_id) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, " +
                    "?, ?, ?, ?)";

            int updateNumber = jdbcTemplate.update(sql, countTypeH.getTransRrn(), countTypeH.getTransId(),
                                                   piLotSetup.getPiLotRrn(), piLotSetup.getPiLotId(), countTypeH.getType(),
                                                   countTypeH.getCountSpec(), countTypeH.getTimePoint(),
                                                   countTypeH.getTriggerRcpRrn(), countTypeH.getTriggerRcpId(),
                                                   countTypeH.getConstraintRcpRrn(), countTypeH.getConstraintRcpId(),
                                                   countTypeH.getTransUserRrn(), countTypeH.getTransTime(),
                                                   countTypeH.getTransUserId());
            Assert.state(updateNumber == 1,
                         Errors.create().content("DB update is abnormal and does not match the expected number").build());
        }

        @Override
        public void insertPiLotSetupRcpGrpHistory(RcpGrpTypeH rcpGrpTypeH, PiLotSetup piLotSetup) {
            String sql = "INSERT INTO PI_LOT_SETUP_RCP_GRP_H (trans_rrn,trans_id,pi_lot_rrn,pi_lot_id,from_rcp_grp_id," +
                    "from_rcp_grp_rrn,to_rcp_grp_id,to_rcp_grp_rrn,trans_user_rrn,trans_time,trans_user_id) VALUES (?, ?," +
                    " ?, ?, ?, ?, " + "?, ?, ?, ?, ?)";
            int updateNumber = jdbcTemplate.update(sql, rcpGrpTypeH.getTransRrn(), rcpGrpTypeH.getTransId(),
                                                   piLotSetup.getPiLotRrn(), piLotSetup.getPiLotId(),
                                                   rcpGrpTypeH.getFromRcpGrpId(), rcpGrpTypeH.getFromRcpGrpRrn(),
                                                   rcpGrpTypeH.getToRcpGrpId(), rcpGrpTypeH.getToRcpGrpRrn(),
                                                   rcpGrpTypeH.getTransUserRrn(), rcpGrpTypeH.getTransTime(),
                                                   rcpGrpTypeH.getTransUserId());
            Assert.state(updateNumber == 1,
                         Errors.create().content("DB update is abnormal and does not match the expected number").build());
        }

        @Override
        public void updatePiLotSetupIdle(PiLotSetup piLotSetup, IdleType idle) {
            String sql = "UPDATE PI_LOT_SETUP_IDLE_TIME SET MAX_RUN_TIME=?,IDLE_TIME=?,RESET_COMMENT=?,SUB_TYPe=? WHERE " +
                    "PI_LOT_RRN= ?";
            int updateNumber = jdbcTemplate.update(sql, idle.getMaxRunTime(), idle.getIdleTime(), idle.getResetComment(),
                                                   idle.getSubType(), piLotSetup.getPiLotRrn());
            Assert.state(updateNumber == 1,
                         Errors.create().content("DB update is abnormal and does not match the expected number").build());
        }

        @Override
        public void updatePiLotSetupPM(PiLotSetup piLotSetup, PmType pm) {
            String sql = "UPDATE PI_LOT_SETUP_PM SET BUFFER_TIME=?,CONSTRAINT_RECIPE_RRN=?,CONSTRAINT_RECIPE_ID=? WHERE " +
                    "PI_LOT_RRN= ?";
            int updateNumber = jdbcTemplate.update(sql, pm.getBufferTime(), pm.getConstraintRcpRrn(),
                                                   pm.getConstraintRcpId(), piLotSetup.getPiLotRrn());
            Assert.state(updateNumber == 1,
                         Errors.create().content("DB update is abnormal and does not match the expected number").build());
        }

        @Override
        public void updatePiLotSetupCount(PiLotSetup piLotSetup, CountType count) {
            String sql = "UPDATE PI_LOT_SETUP_COUNT SET COUNT_TYPE=?,COUNT_SPEC=?,TIME_POINT=?,TRIGGER_RECIPE_RRN=?," +
                    "TRIGGER_RECIPE_ID=?,CONSTRAINT_RECIPE_RRN=?,CONSTRAINT_RECIPE_ID=? WHERE PI_LOT_RRN= ?";
            int updateNumber = jdbcTemplate.update(sql, count.getType(), count.getCountSpec(), count.getTimePoint(),
                                                   count.getTriggerRcpRrn(), count.getTriggerRcpId(),
                                                   count.getConstraintRcpRrn(), count.getConstraintRcpId(),
                                                   piLotSetup.getPiLotRrn());
            Assert.state(updateNumber == 1,
                         Errors.create().content("DB update is abnormal and does not match the expected number").build());
        }

        @Override
        public void updatePiLotSetupRcpGrp(PiLotSetup piLotSetup, RcpGrpType rcpGrp) {
            String sql = "UPDATE PI_LOT_SETUP_RCP_GRP SET FROM_RCP_GRP_ID= ?,FROM_RCP_GRP_RRN= ?,TO_RCP_GRP_ID= ?," +
                    "TO_RCP_GRP_RRN= ? WHERE PI_LOT_RRN= ?";
            int updateNumber = jdbcTemplate.update(sql, rcpGrp.getFromRcpGrpId(), rcpGrp.getFromRcpGrpRrn(),
                                                   rcpGrp.getToRcpGrpId(), rcpGrp.getToRcpGrpRrn(),
                                                   piLotSetup.getPiLotRrn());
            Assert.state(updateNumber == 1,
                         Errors.create().content("DB update is abnormal and does not match the expected number").build());
        }

    }