package com.mortals.xhx.modules.information.service.impl;

import com.mortals.framework.exception.AppException;
import com.mortals.framework.service.impl.AbstractCRUDServiceImpl;
import com.mortals.xhx.common.code.NodeTypeEnum;
import com.mortals.xhx.modules.information.dao.InformationDao;
import com.mortals.xhx.modules.information.model.InformationEntity;
import com.mortals.xhx.modules.information.service.InformationService;
import org.apache.commons.collections4.CollectionUtils;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

/**
* <p>Title: 办件信息</p>
* <p>Description: InformationService service接口 </p>
* <p>Copyright: Copyright &reg;  </p>
* @version 1.0.0
*/
@Service("informationService")
public class InformationServiceImpl extends AbstractCRUDServiceImpl<InformationDao, InformationEntity, Long> implements InformationService {

    @Resource
    private InformationDao informationDao;

    @Override
    public void anewPush(Long[] ids) {
        List<InformationEntity> entities = informationDao.get(ids);
        if(CollectionUtils.isNotEmpty(entities)){
            entities.forEach(entity ->{
                if(NodeTypeEnum.蓉易办受理.getCode().equals(entity.getNodeType())
                        || NodeTypeEnum.受理.getCode().equals(entity.getNodeType())){
                    entity.setIsSuccess("1");
                    entity.setIsReport("0");
                }else if(NodeTypeEnum.审查.getCode().equals(entity.getNodeType())
                        || NodeTypeEnum.蓉易办环节.getCode().equals(entity.getNodeType())
                        || NodeTypeEnum.决定.getCode().equals(entity.getNodeType())){
                    entity.setIsSuccess("1");
                    entity.setIsReport("1");
                }
                entity.setFailReason("");
                entity.setFailTimes(0);
            });
            informationDao.insertBatch(entities);
        }
    }
}