+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see .
+ */
+
+package com.elink.esua.epdc.modules.item.controller;
+
+import com.elink.esua.epdc.commons.tools.page.PageData;
+import com.elink.esua.epdc.commons.tools.utils.ExcelUtils;
+import com.elink.esua.epdc.commons.tools.utils.Result;
+import com.elink.esua.epdc.commons.tools.validator.AssertUtils;
+import com.elink.esua.epdc.commons.tools.validator.ValidatorUtils;
+import com.elink.esua.epdc.commons.tools.validator.group.AddGroup;
+import com.elink.esua.epdc.commons.tools.validator.group.UpdateGroup;
+import com.elink.esua.epdc.commons.tools.validator.group.DefaultGroup;
+import com.elink.esua.epdc.dto.ItemFusingDelayRecordDTO;
+import com.elink.esua.epdc.dto.item.form.ItemFusingDelayInsertDTO;
+import com.elink.esua.epdc.modules.item.excel.ItemFusingDelayRecordExcel;
+import com.elink.esua.epdc.modules.item.service.ItemFusingDelayRecordService;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.web.bind.annotation.*;
+
+import javax.servlet.http.HttpServletResponse;
+import java.util.List;
+import java.util.Map;
+
+
+/**
+ * 项目熔断/延期表
+ *
+ * @author elink elink@elink-cn.com
+ * @since v1.0.0 2022-01-05
+ */
+@RestController
+@RequestMapping("itemfusingdelayrecord")
+public class ItemFusingDelayRecordController {
+
+ @Autowired
+ private ItemFusingDelayRecordService itemFusingDelayRecordService;
+
+ @GetMapping("page")
+ public Result> page(@RequestParam Map params){
+ PageData page = itemFusingDelayRecordService.getPhrasePage(params);
+ return new Result>().ok(page);
+ }
+
+ @GetMapping("{id}")
+ public Result get(@PathVariable("id") String id){
+ ItemFusingDelayRecordDTO data = itemFusingDelayRecordService.get(id);
+ return new Result().ok(data);
+ }
+
+ @PostMapping
+ public Result save(@RequestBody ItemFusingDelayRecordDTO dto){
+ //效验数据
+ ValidatorUtils.validateEntity(dto, AddGroup.class, DefaultGroup.class);
+ itemFusingDelayRecordService.save(dto);
+ return new Result();
+ }
+
+ @PostMapping("submitApply")
+ public Result submitApply(@RequestBody ItemFusingDelayRecordDTO dto){
+ //效验数据
+ ValidatorUtils.validateEntity(dto, AddGroup.class, DefaultGroup.class);
+ itemFusingDelayRecordService.save(dto);
+ return new Result();
+ }
+
+ @PutMapping("checkApply")
+ public Result checkApply(@RequestBody ItemFusingDelayRecordDTO dto){
+ //效验数据
+ ValidatorUtils.validateEntity(dto, AddGroup.class, DefaultGroup.class);
+ itemFusingDelayRecordService.update(dto);
+ return new Result();
+ }
+
+ @GetMapping("getPageList/{itemId}")
+ public Result> getPageList(@PathVariable("itemId") String itemId){
+ List list = itemFusingDelayRecordService.getPageList(itemId);
+ return new Result>().ok(list);
+ }
+
+ @PutMapping
+ public Result update(@RequestBody ItemFusingDelayRecordDTO dto){
+ //效验数据
+ ValidatorUtils.validateEntity(dto, UpdateGroup.class, DefaultGroup.class);
+ itemFusingDelayRecordService.update(dto);
+ return new Result();
+ }
+
+ @DeleteMapping
+ public Result delete(@RequestBody String[] ids){
+ //效验数据
+ AssertUtils.isArrayEmpty(ids, "id");
+ itemFusingDelayRecordService.delete(ids);
+ return new Result();
+ }
+
+ @GetMapping("export")
+ public void export(@RequestParam Map params, HttpServletResponse response) throws Exception {
+ List list = itemFusingDelayRecordService.list(params);
+ ExcelUtils.exportExcelToTarget(response, null, list, ItemFusingDelayRecordExcel.class);
+ }
+
+}
diff --git a/esua-epdc/epdc-module/epdc-events/epdc-events-server/src/main/java/com/elink/esua/epdc/modules/item/dao/ItemFusingDelayRecordDao.java b/esua-epdc/epdc-module/epdc-events/epdc-events-server/src/main/java/com/elink/esua/epdc/modules/item/dao/ItemFusingDelayRecordDao.java
new file mode 100644
index 000000000..af7b936fc
--- /dev/null
+++ b/esua-epdc/epdc-module/epdc-events/epdc-events-server/src/main/java/com/elink/esua/epdc/modules/item/dao/ItemFusingDelayRecordDao.java
@@ -0,0 +1,46 @@
+/**
+ * Copyright 2018 人人开源 https://www.renren.io
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see .
+ */
+
+package com.elink.esua.epdc.modules.item.dao;
+
+import com.elink.esua.epdc.commons.mybatis.dao.BaseDao;
+import com.elink.esua.epdc.dto.ItemFusingDelayRecordDTO;
+import com.elink.esua.epdc.modules.item.entity.ItemFusingDelayRecordEntity;
+import org.apache.ibatis.annotations.Mapper;
+import org.apache.ibatis.annotations.Param;
+
+import java.util.List;
+import java.util.Map;
+
+/**
+ * 项目熔断/延期表
+ *
+ * @author elink elink@elink-cn.com
+ * @since v1.0.0 2022-01-05
+ */
+@Mapper
+public interface ItemFusingDelayRecordDao extends BaseDao {
+
+ /**
+ * 条件查询
+ * @param params
+ * @return
+ */
+ List getPhrasePage(Map params);
+
+ List getPageList(@Param("itemId") String itemId);
+}
diff --git a/esua-epdc/epdc-module/epdc-events/epdc-events-server/src/main/java/com/elink/esua/epdc/modules/item/entity/ItemFusingDelayRecordEntity.java b/esua-epdc/epdc-module/epdc-events/epdc-events-server/src/main/java/com/elink/esua/epdc/modules/item/entity/ItemFusingDelayRecordEntity.java
new file mode 100644
index 000000000..0ef890310
--- /dev/null
+++ b/esua-epdc/epdc-module/epdc-events/epdc-events-server/src/main/java/com/elink/esua/epdc/modules/item/entity/ItemFusingDelayRecordEntity.java
@@ -0,0 +1,71 @@
+/**
+ * Copyright 2018 人人开源 https://www.renren.io
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see .
+ */
+
+package com.elink.esua.epdc.modules.item.entity;
+
+import com.baomidou.mybatisplus.annotation.TableName;
+
+import com.elink.esua.epdc.commons.mybatis.entity.BaseEpdcEntity;
+import lombok.Data;
+import lombok.EqualsAndHashCode;
+
+import java.util.Date;
+
+/**
+ * 项目熔断/延期表
+ *
+ * @author elink elink@elink-cn.com
+ * @since v1.0.0 2022-01-05
+ */
+@Data
+@EqualsAndHashCode(callSuper=false)
+@TableName("epdc_item_fusing_delay_record")
+public class ItemFusingDelayRecordEntity extends BaseEpdcEntity {
+
+ private static final long serialVersionUID = 1L;
+
+ /**
+ * 项目ID
+ */
+ private String itemId;
+
+ /**
+ * 申请状态:1-延期,2-熔断
+ */
+ private Integer state;
+
+ /**
+ * 申请理由
+ */
+ private String reason;
+
+ /**
+ * 审核状态:1-审核通过,2-驳回
+ */
+ private Integer handleState;
+
+ /**
+ * 审批理由
+ */
+ private String handleReason;
+
+ /**
+ * 延期时间
+ */
+ private Date delayTime;
+
+}
diff --git a/esua-epdc/epdc-module/epdc-events/epdc-events-server/src/main/java/com/elink/esua/epdc/modules/item/excel/ItemFusingDelayRecordExcel.java b/esua-epdc/epdc-module/epdc-events/epdc-events-server/src/main/java/com/elink/esua/epdc/modules/item/excel/ItemFusingDelayRecordExcel.java
new file mode 100644
index 000000000..5e748b6f3
--- /dev/null
+++ b/esua-epdc/epdc-module/epdc-events/epdc-events-server/src/main/java/com/elink/esua/epdc/modules/item/excel/ItemFusingDelayRecordExcel.java
@@ -0,0 +1,74 @@
+/**
+ * Copyright 2018 人人开源 https://www.renren.io
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see .
+ */
+
+package com.elink.esua.epdc.modules.item.excel;
+
+import cn.afterturn.easypoi.excel.annotation.Excel;
+import lombok.Data;
+
+import java.util.Date;
+
+/**
+ * 项目熔断/延期表
+ *
+ * @author elink elink@elink-cn.com
+ * @since v1.0.0 2022-01-05
+ */
+@Data
+public class ItemFusingDelayRecordExcel {
+
+ @Excel(name = "主键")
+ private String id;
+
+ @Excel(name = "项目ID")
+ private String itemId;
+
+ @Excel(name = "申请状态:1-延期,2-熔断")
+ private Integer state;
+
+ @Excel(name = "申请理由")
+ private String reason;
+
+ @Excel(name = "审核状态:1-审核通过,2-驳回")
+ private Integer handleState;
+
+ @Excel(name = "审批理由")
+ private String handleReason;
+
+ @Excel(name = "延期时间")
+ private Date delayTime;
+
+ @Excel(name = "乐观锁")
+ private Integer revision;
+
+ @Excel(name = "创建人")
+ private String createdBy;
+
+ @Excel(name = "创建时间")
+ private Date createdTime;
+
+ @Excel(name = "更新人")
+ private String updatedBy;
+
+ @Excel(name = "更新时间")
+ private Date updatedTime;
+
+ @Excel(name = "删除标记")
+ private String delFlag;
+
+
+}
diff --git a/esua-epdc/epdc-module/epdc-events/epdc-events-server/src/main/java/com/elink/esua/epdc/modules/item/redis/ItemFusingDelayRecordRedis.java b/esua-epdc/epdc-module/epdc-events/epdc-events-server/src/main/java/com/elink/esua/epdc/modules/item/redis/ItemFusingDelayRecordRedis.java
new file mode 100644
index 000000000..e99e0f361
--- /dev/null
+++ b/esua-epdc/epdc-module/epdc-events/epdc-events-server/src/main/java/com/elink/esua/epdc/modules/item/redis/ItemFusingDelayRecordRedis.java
@@ -0,0 +1,47 @@
+/**
+ * Copyright 2018 人人开源 https://www.renren.io
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see .
+ */
+
+package com.elink.esua.epdc.modules.item.redis;
+
+import com.elink.esua.epdc.commons.tools.redis.RedisUtils;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Component;
+
+/**
+ * 项目熔断/延期表
+ *
+ * @author elink elink@elink-cn.com
+ * @since v1.0.0 2022-01-05
+ */
+@Component
+public class ItemFusingDelayRecordRedis {
+ @Autowired
+ private RedisUtils redisUtils;
+
+ public void delete(Object[] ids) {
+
+ }
+
+ public void set(){
+
+ }
+
+ public String get(String id){
+ return null;
+ }
+
+}
diff --git a/esua-epdc/epdc-module/epdc-events/epdc-events-server/src/main/java/com/elink/esua/epdc/modules/item/service/ItemFusingDelayRecordService.java b/esua-epdc/epdc-module/epdc-events/epdc-events-server/src/main/java/com/elink/esua/epdc/modules/item/service/ItemFusingDelayRecordService.java
new file mode 100644
index 000000000..3e1f12be8
--- /dev/null
+++ b/esua-epdc/epdc-module/epdc-events/epdc-events-server/src/main/java/com/elink/esua/epdc/modules/item/service/ItemFusingDelayRecordService.java
@@ -0,0 +1,104 @@
+/**
+ * Copyright 2018 人人开源 https://www.renren.io
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see .
+ */
+
+package com.elink.esua.epdc.modules.item.service.impl;
+
+import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
+import com.baomidou.mybatisplus.core.metadata.IPage;
+import com.elink.esua.epdc.commons.mybatis.service.impl.BaseServiceImpl;
+import com.elink.esua.epdc.commons.tools.page.PageData;
+import com.elink.esua.epdc.commons.tools.utils.ConvertUtils;
+import com.elink.esua.epdc.commons.tools.constant.FieldConstant;
+import com.elink.esua.epdc.dto.ItemFusingDelayRecordDTO;
+import com.elink.esua.epdc.modules.item.dao.ItemFusingDelayRecordDao;
+import com.elink.esua.epdc.modules.item.entity.ItemFusingDelayRecordEntity;
+import com.elink.esua.epdc.modules.item.redis.ItemFusingDelayRecordRedis;
+import com.elink.esua.epdc.modules.item.service.ItemFusingDelayRecordService;
+import org.apache.commons.lang3.StringUtils;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Service;
+import org.springframework.transaction.annotation.Transactional;
+
+import java.util.Arrays;
+import java.util.List;
+import java.util.Map;
+
+/**
+ * 项目熔断/延期表
+ *
+ * @author elink elink@elink-cn.com
+ * @since v1.0.0 2022-01-05
+ */
+@Service
+public class ItemFusingDelayRecordServiceImpl extends BaseServiceImpl implements ItemFusingDelayRecordService {
+
+ @Autowired
+ private ItemFusingDelayRecordRedis itemFusingDelayRecordRedis;
+
+ @Override
+ public PageData page(Map params) {
+ IPage page = baseDao.selectPage(
+ getPage(params, FieldConstant.CREATED_TIME, false),
+ getWrapper(params)
+ );
+ return getPageData(page, ItemFusingDelayRecordDTO.class);
+ }
+
+ @Override
+ public List list(Map params) {
+ List entityList = baseDao.selectList(getWrapper(params));
+
+ return ConvertUtils.sourceToTarget(entityList, ItemFusingDelayRecordDTO.class);
+ }
+
+ /**
+ * 条件查询
+ * @param params
+ * @return
+ */
+ @Override
+ public PageData getPhrasePage(Map params) {
+ IPage page = getPage(params);
+ List list = baseDao.getPhrasePage(params);
+ return new PageData<>(list, page.getTotal());
+ }
+
+ @Override
+ public List getPageList(String itemId) {
+ List list = baseDao.getPageList(itemId);
+ return list;
+ }
+
+ private QueryWrapper getWrapper(Map params){
+ String id = (String)params.get(FieldConstant.ID_HUMP);
+
+ QueryWrapper wrapper = new QueryWrapper<>();
+ wrapper.eq(StringUtils.isNotBlank(id), FieldConstant.ID, id);
+
+ return wrapper;
+ }
+
+ @Override
+ public ItemFusingDelayRecordDTO get(String id) {
+ ItemFusingDelayRecordEntity entity = baseDao.selectById(id);
+ return ConvertUtils.sourceToTarget(entity, ItemFusingDelayRecordDTO.class);
+ }
+
+ @Override
+ @Transactional(rollbackFor = Exception.class)
+ public void save(ItemFusingDelayRecordDTO dto) {
+ ItemFusingDelayRecordEntity entity = ConvertUtils.sourceToTarget(dto, ItemFusingDelayRecordEntity.class);
+ insert(entity);
+ }
+
+ @Override
+ @Transactional(rollbackFor = Exception.class)
+ public void update(ItemFusingDelayRecordDTO dto) {
+ ItemFusingDelayRecordEntity entity = ConvertUtils.sourceToTarget(dto, ItemFusingDelayRecordEntity.class);
+ updateById(entity);
+ }
+
+ @Override
+ @Transactional(rollbackFor = Exception.class)
+ public void delete(String[] ids) {
+ // 逻辑删除(@TableLogic 注解)
+ baseDao.deleteBatchIds(Arrays.asList(ids));
+ }
+
+}
diff --git a/esua-epdc/epdc-module/epdc-events/epdc-events-server/src/main/resources/mapper/item/ItemDao.xml b/esua-epdc/epdc-module/epdc-events/epdc-events-server/src/main/resources/mapper/item/ItemDao.xml
index 55e700d30..b892ffca1 100755
--- a/esua-epdc/epdc-module/epdc-events/epdc-events-server/src/main/resources/mapper/item/ItemDao.xml
+++ b/esua-epdc/epdc-module/epdc-events/epdc-events-server/src/main/resources/mapper/item/ItemDao.xml
@@ -493,11 +493,11 @@
eve.OPPOSE_NUM,
eve.COMMENT_NUM,
eve.BROWSE_NUM,
- ( eve.APPROVE_NUM + eve.OPPOSE_NUM + eve.COMMENT_NUM + eve.BROWSE_NUM ) AS participantsNum
- FROM
- epdc_item item
- LEFT JOIN epdc_events eve ON item.EVENT_ID = eve.ID
- AND eve.DEL_FLAG = '0'
+ ( eve.APPROVE_NUM + eve.OPPOSE_NUM + eve.COMMENT_NUM + eve.BROWSE_NUM ) AS participantsNum,
+ (case when d.ID is not null then '1' else '0' end) as isDelay
+ FROM epdc_item item
+ LEFT JOIN epdc_events eve ON item.EVENT_ID = eve.ID AND eve.DEL_FLAG = '0'
+ left join epdc_item_fusing_delay_record d on d.ITEM_ID = item.ID and d.DEL_FLAG = '0'
WHERE
item.DEL_FLAG = '0'
@@ -511,19 +511,19 @@
AND item.ITEM_CONTENT like concat('%', trim(#{keyword}), '%')
AND item.ID IN (
- SELECT
- temp.ITEM_ID
- FROM
+ SELECT
+ temp.ITEM_ID
+ FROM
( SELECT dept.ITEM_ID FROM epdc_item_dept dept WHERE dept.DEL_FLAG = '0'
-
- AND dept.DEPT_ID IN
-
- #{deptId}
-
-
-
- AND dept.DEPT_ID = #{districtDeptId}
-
+
+ AND dept.DEPT_ID IN
+
+ #{deptId}
+
+
+
+ AND dept.DEPT_ID = #{districtDeptId}
+
) temp
)
diff --git a/esua-epdc/epdc-module/epdc-events/epdc-events-server/src/main/resources/mapper/item/ItemFusingDelayRecordDao.xml b/esua-epdc/epdc-module/epdc-events/epdc-events-server/src/main/resources/mapper/item/ItemFusingDelayRecordDao.xml
new file mode 100644
index 000000000..476cedf69
--- /dev/null
+++ b/esua-epdc/epdc-module/epdc-events/epdc-events-server/src/main/resources/mapper/item/ItemFusingDelayRecordDao.xml
@@ -0,0 +1,75 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/esua-epdc/kettle-Code/governanceRankingMonth/blow_whistle/同步到中间表/吹哨-项目-月-基础数据.ktr b/esua-epdc/kettle-Code/governanceRankingMonth/blow_whistle/同步到中间表/吹哨-项目-月-基础数据.ktr
index eff42ea32..bb29edf80 100644
--- a/esua-epdc/kettle-Code/governanceRankingMonth/blow_whistle/同步到中间表/吹哨-项目-月-基础数据.ktr
+++ b/esua-epdc/kettle-Code/governanceRankingMonth/blow_whistle/同步到中间表/吹哨-项目-月-基础数据.ktr
@@ -613,10 +613,10 @@
esua_epdc_analysis
- SELECT
+ SELECT
MD5(UUID()) as ID,
a.GRID_ID,
- COUNT(1) ITEM_NUM,
+ COUNT(1) ITEM_NUM,
SUM(a.respondItemNumber) FINISH_IN_TIME_NUM, -- 记录有几条及时转项目数
SUM(a.timeoutItemNumber) TIMEOUT_FINISH_NUM,
LEFT(date_sub(NOW(), interval 1 MONTH),7) 'YEAR_MONTH',
@@ -627,32 +627,35 @@
now() as UPDATED_TIME,
'0' as DEL_FLAG
FROM(
-SELECT
- mi.GRID_ID,
- CASE
- -- 已结案的项目时间 减去 项目的创建时间 小于等于 有效时间
- WHEN TIMESTAMPDIFF(HOUR, mi.CREATED_TIME, ifnull(mhp.CREATED_TIME,mhp2.CREATED_TIME)) <= t.VALID_CLOSE_TIME -- 未超过有效结案时间(小时数)
- THEN '1'
- ELSE '0' -- 0 不做处理
- END AS respondItemNumber, -- '及时转项目数'
-
- CASE
- WHEN TIMESTAMPDIFF(HOUR, mi.CREATED_TIME, ifnull(mhp.CREATED_TIME,mhp2.CREATED_TIME)) > t.VALID_CLOSE_TIME -- 未超过有效结案时间(小时数)
- THEN '1'
- ELSE '0' -- 0 不做处理
- END AS timeoutItemNumber -- 最终转项目数
-FROM meta_epdc_item mi
-LEFT JOIN meta_epdc_item_handle_process mhp ON mi.id = mhp.ITEM_ID AND mhp.STATE = 15 AND mhp.DEL_FLAG = 0
-LEFT JOIN meta_epdc_item_handle_process mhp2 ON mi.id = mhp2.ITEM_ID AND mhp2.STATE = 10 AND mhp2.DEL_FLAG = 0
-LEFT JOIN meta_epdc_category c ON mi.CATEGORY_CODE = c.CATEGORY_CODE AND mi.DEL_FLAG = '0'
-LEFT JOIN meta_epdc_kpi_time_limit_item t ON c.id = t.CATEGORY_ID
-WHERE (LEFT(mi.CREATED_TIME, 7) = LEFT(date_sub(NOW(), interval 1 MONTH),7)
- OR LEFT(mhp.CREATED_TIME, 7) = LEFT(date_sub(NOW(), interval 1 MONTH),7)
- OR LEFT(mhp2.CREATED_TIME, 7) = LEFT(date_sub(NOW(), interval 1 MONTH),7))
-and mi.event_id is not null
+ SELECT
+ mi.GRID_ID,
+ CASE
+ -- 已结案的项目时间 减去 项目的创建时间 小于等于 有效时间
+ WHEN ((TIMESTAMPDIFF(HOUR, mi.CREATED_TIME, ifnull(mhp.CREATED_TIME,mhp2.CREATED_TIME)) <= t.VALID_CLOSE_TIME)
+ or (DATE_FORMAT(mhp.CREATED_TIME,'%Y-%m-%d') <= DATE_FORMAT(d.DELAY_TIME,'%Y-%m-%d') and d.HANDLE_STATE = 1 )) -- 未超过有效结案时间(小时数)
+ THEN '1'
+ ELSE '0' -- 0 不做处理
+ END AS respondItemNumber, -- '及时转项目数'
- )a
- GROUP BY a.GRID_ID
+ CASE
+ WHEN TIMESTAMPDIFF(HOUR, mi.CREATED_TIME, ifnull(mhp.CREATED_TIME,mhp2.CREATED_TIME)) > t.VALID_CLOSE_TIME -- 未超过有效结案时间(小时数)
+ THEN '1'
+ ELSE '0' -- 0 不做处理
+ END AS timeoutItemNumber -- 最终转项目数
+ FROM meta_epdc_item mi
+ LEFT JOIN meta_epdc_item_handle_process mhp ON mi.id = mhp.ITEM_ID AND mhp.STATE = 15 AND mhp.DEL_FLAG = 0
+ LEFT JOIN meta_epdc_item_handle_process mhp2 ON mi.id = mhp2.ITEM_ID AND mhp2.STATE = 10 AND mhp2.DEL_FLAG = 0
+ LEFT JOIN meta_epdc_category c ON mi.CATEGORY_CODE = c.CATEGORY_CODE AND mi.DEL_FLAG = '0'
+ LEFT JOIN meta_epdc_kpi_time_limit_item t ON c.id = t.CATEGORY_ID
+ left join esua_epdc_events.epdc_item_fusing_delay_record d on d.ITEM_ID = mi.ID and d.DEL_FLAG = '0'
+ WHERE ((LEFT(mi.CREATED_TIME, 7) = LEFT(date_sub(NOW(), interval 1 MONTH),7)
+ OR LEFT(mhp.CREATED_TIME, 7) = LEFT(date_sub(NOW(), interval 1 MONTH),7)
+ OR LEFT(mhp2.CREATED_TIME, 7) = LEFT(date_sub(NOW(), interval 1 MONTH),7))
+ and mi.event_id is not null
+ )
+ and (d.STATE = 1 or d.STATE is null)
+ ) a
+ GROUP BY a.GRID_ID 0N