Commit e0e8635d authored by 李秀明's avatar 李秀明

fix(patrol): 巡检接口查询数据错误

parent d968c366
package com.yeejoin.equipmanage.controller;
import com.alibaba.fastjson.JSON;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.yeejoin.amos.boot.biz.common.bo.ReginParams;
import com.yeejoin.amos.boot.biz.common.utils.RedisKey;
import com.yeejoin.amos.boot.biz.common.utils.RedisUtils;
import com.yeejoin.equipmanage.common.utils.CommonResponseUtil;
import com.yeejoin.equipmanage.common.utils.DateUtils;
import com.yeejoin.equipmanage.config.PersonIdentify;
......@@ -18,6 +21,7 @@ import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import org.typroject.tyboot.core.foundation.context.RequestContext;
import org.typroject.tyboot.core.foundation.enumeration.UserType;
import org.typroject.tyboot.core.foundation.utils.ValidationUtil;
import org.typroject.tyboot.core.restful.doc.TycloudOperation;
......@@ -41,6 +45,9 @@ public class EmergencyController extends AbstractBaseController {
@Autowired
IEmergencyService iEmergencyService;
@Autowired
RedisUtils redisUtils;
/**
* 通过bizOrgCode过滤
*/
......@@ -49,7 +56,7 @@ public class EmergencyController extends AbstractBaseController {
@GetMapping(value = "/system/state")
public ResponseModel getSystemState() {
ReginParams reginParams = getSelectedOrgInfo();
String bizOrgCode = reginParams.getPersonIdentity().getBizOrgCode();
String bizOrgCode = reginParams.getPersonIdentity().getCompanyBizOrgCode();
return CommonResponseUtil.success(iEmergencyService.getSystemState(bizOrgCode));
}
......
......@@ -137,7 +137,7 @@ public class CheckController extends AbstractBaseController {
ReginParams reginParams = getSelectedOrgInfo();
param.setOrderBy("checkDate desc");
param.setBizOrgCode(ObjectUtils.isEmpty(param.getBizOrgCode()) ?
"3".equals(param.getIsOK()) ? null : reginParams.getPersonIdentity().getBizOrgCode()
"3".equals(param.getIsOK()) ? null : reginParams.getPersonIdentity().getCompanyBizOrgCode()
: param.getBizOrgCode());
if(commonPageable !=null){
param.setPageNumber(commonPageable.getPageNumber()-1);
......
......@@ -43,6 +43,10 @@ public class ControlScreenController extends AbstractBaseController {
@RequestParam(required = false) String companyCode,
@RequestParam(required = false) String bizOrgCode
) {
if (StringUtils.isEmpty(bizOrgCode)) {
ReginParams reginParams = getSelectedOrgInfo();
bizOrgCode = reginParams.getPersonIdentity().getCompanyBizOrgCode();
}
return CommonResponseUtil.success(iPlanTaskService.getStatics(companyCode, bizOrgCode));
}
......
......@@ -23,6 +23,8 @@ public interface CheckMapper extends BaseMapper {
long getCheckInfoCount(CheckInfoPageParam param);
long getCheckInfoCountNew(CheckInfoPageParam param);
List<Map> queryUnqualifiedInputItem(@Param(value="checkId") int checkId);
List<Map> queryCheckPointInputItem(@Param(value="planTaskId") int planTaskId, @Param(value="pointId") int pointId);
......
......@@ -159,7 +159,7 @@ public class CheckServiceImpl implements ICheckService {
}
public Page<CheckInfoVo> getCheckInfoNew(String toke,String product,String appKey,CheckInfoPageParam param) {
long total = checkMapper.getCheckInfoCount(param);
long total = checkMapper.getCheckInfoCountNew(param);
List<CheckInfoVo> content = Lists.newArrayList();
if (total == 0) {
return new PageImpl<>(content, param, total);
......
......@@ -118,6 +118,55 @@
</trim>
</select>
<select id="getCheckInfoCountNew" resultType="long">
SELECT
COUNT(1)
FROM
`p_check` `a`
LEFT JOIN `p_point` `b` ON `a`.`point_id` = `b`.`id`
LEFT JOIN `p_route` `d` ON `a`.`route_id` = `d`.`id`
LEFT JOIN `p_plan` `e` ON `a`.`plan_id` = `e`.`id`
LEFT JOIN wl_warehouse_structure wws on wws.id = b.risk_source_id
<if test="dangerId != null and dangerId != ''">
LEFT JOIN ( SELECT check_id, GROUP_CONCAT( latent_danger_id ) dangerIds FROM p_latent_danger_patrol GROUP BY check_id ) t ON t.check_id = a.id
</if>
<trim prefix="WHERE" prefixOverrides="AND ">
<if test="beginDate!=null and beginDate!= ''">and a.check_time &gt;= #{beginDate} </if>
<if test="endDate!=null and endDate!= ''">and a.check_time &lt;= #{endDate}</if>
<if test="userName!=null and userName!=''">and a.user_name like concat(concat("%",#{userName}),"%")</if>
<if test="pointName!=null and pointName!= ''">and b.name like concat(concat("%",#{pointName}),"%")</if>
<if test="pointNo!=null and pointNo!=''">and b.point_no like concat('%',#{pointNo},'%')</if>
<if test="isFixed!=null and isFixed!=''">and b.is_fixed = #{isFixed}</if>
<if test="isOK!=null and isOK!=''">and a.is_OK = #{isOK}</if>
<if test="planId!=null and planId!='' ">and a.plan_Id = #{planId}</if>
<if test="planTaskId!=null and planTaskId!=''">and a.plan_task_id = #{planTaskId}</if>
<if test="userId!=null and userId!=''">and find_in_set(#{userId}, a.user_id) > 0</if>
<if test="routeId!=null and routeId!=''">and a.route_Id = #{routeId}</if>
<if test="catalogId!=null and catalogId!=''">and b.Catalog_Id = #{catalogId}</if>
<if test="orgCode!=null and orgCode!=''">and (a.org_Code like concat (#{orgCode},"-%")or a.org_Code= #{orgCode})</if>
<if test="pointId!=null and pointId!=''">and a.point_id = #{pointId}</if>
<if test="checkTime!=null and checkTime!=''">and TO_DAYS(a.check_time) = TO_DAYS('${checkTime}')</if>
<if test="departmentId!=null and departmentId!='-1'"> and find_in_set(#{departmentId}, a.dep_id) > 0</if>
<if test="checkType == '计划检查'">and a.plan_task_id &gt; 0</if>
<if test="checkType == '无计划检查'">and a.plan_task_id &lt;= 0</if>
<choose>
<when test="finishStatus == 0">and (`a`.`plan_task_detail_id` = 0 OR `a`.`plan_task_detail_id` is null)</when>
<when test="finishStatus == 1">and (`a`.`plan_task_detail_id` != 0 AND `a`.`is_ok` != 3)</when>
<when test="finishStatus == 2">and `a`.`is_ok` = 3</when>
</choose>
<if test="dangerId != null and dangerId != ''">
and FIND_IN_SET(#{dangerId}, t.dangerIds)
</if>
<if test="bizOrgCode != null and bizOrgCode != ''">
and a.org_code LIKE CONCAT(#{bizOrgCode},'%')
</if>
<if test="searchDay != null and searchDay != ''">
and date_format(a.check_time, '%Y-%m-%d') = curdate()
</if>
<if test="isExecute!=null and isExecute!='' and isExecute == '3'">and a.is_OK != #{isExecute}</if>
</trim>
</select>
<select id="getCheckInfo" resultMap="checkInfoMap">
SELECT
a.id,
......@@ -220,50 +269,32 @@
a.dep_name department_name,
a.dep_id departmentId,
wws.name address,
date_format(
`a`.`check_time`,
'%Y-%m-%d %H:%i:%s'
) AS `checkDate`,
date_format(
`a`.`upload_time`,
'%Y-%m-%d %H:%i:%s'
) AS `upload_time`,
date_format(`a`.`check_time`, '%Y-%m-%d %H:%i:%s') AS `checkDate`,
date_format(`a`.`upload_time`, '%Y-%m-%d %H:%i:%s') AS `upload_time`,
(
CASE
WHEN `a`.`plan_task_detail_id` = 0 OR `a`.`plan_task_detail_id` is null
THEN '计划外完成'
WHEN `a`.`plan_task_detail_id` != 0 AND `a`.`is_ok` != 3
THEN '按时完成'
WHEN `a`.`is_ok` = 3
THEN '未执行'
WHEN `a`.`plan_task_detail_id` = 0 OR `a`.`plan_task_detail_id` is null THEN '计划外完成'
WHEN `a`.`plan_task_detail_id` != 0 AND `a`.`is_ok` != 3 THEN '按时完成'
WHEN `a`.`is_ok` = 3 THEN '未执行'
END
) AS `Finish_Status`,
(
CASE
WHEN `a`.`is_ok` = 1
THEN '合格'
WHEN `a`.`is_ok` = 2
THEN '不合格'
WHEN `a`.`is_ok` = 3
THEN '漏检'
WHEN `a`.`is_ok` = 1 THEN '合格'
WHEN `a`.`is_ok` = 2 THEN '不合格'
WHEN `a`.`is_ok` = 3 THEN '漏检'
END
) as is_ok,
a.score,
a.`route_name`,
(
CASE
WHEN a.check_mode = 'QR'
THEN '二维码巡检'
WHEN a.check_mode = 'MOBILE'
THEN '移动点巡检'
WHEN a.check_mode = 'NFC'
THEN 'NFC巡检'
WHEN a.check_mode = 'WEB'
THEN '录入检查点巡检'
WHEN a.check_mode = 'WEB_OUT'
THEN '外来检查'
ELSE
'系统自检'
WHEN a.check_mode = 'QR' THEN '二维码巡检'
WHEN a.check_mode = 'MOBILE' THEN '移动点巡检'
WHEN a.check_mode = 'NFC' THEN 'NFC巡检'
WHEN a.check_mode = 'WEB' THEN '录入检查点巡检'
WHEN a.check_mode = 'WEB_OUT' THEN '外来检查'
ELSE '系统自检'
END
) as check_mode,
a.`plan_name` AS `plan_name`,
......@@ -284,10 +315,8 @@
LEFT JOIN ( SELECT check_id, GROUP_CONCAT( latent_danger_id ) dangerIds FROM p_latent_danger_patrol GROUP BY check_id ) t ON t.check_id = a.id
</if>
<trim prefix="WHERE" prefixOverrides="AND ">
<!-- <if test="beginDate!=null and endDate!=null">and a.check_time BETWEEN #{beginDate} and #{endDate}</if>-->
<if test="beginDate!=null and beginDate!= ''">and a.check_time >= #{beginDate} </if>
<if test="endDate!=null and endDate!= ''">and #{endDate} >= a.check_time</if>
<!-- <if test="endDate!=null"> and #{endDate} <![CDATA[>=]]> a.check_time </if> -->
<if test="beginDate!=null and beginDate!= ''">and a.check_time &gt;= #{beginDate} </if>
<if test="endDate!=null and endDate!= ''">and a.check_time &lt;= #{endDate}</if>
<if test="userName!=null and userName!=''">and a.user_name like concat(concat("%",#{userName}),"%")</if>
<if test="pointName!=null and pointName!= ''">and b.name like concat(concat("%",#{pointName}),"%")</if>
<if test="pointNo!=null and pointNo!=''">and b.point_no like concat('%',#{pointNo},'%')</if>
......@@ -305,9 +334,7 @@
<if test="checkType == '计划检查'">and a.plan_task_id &gt; 0</if>
<if test="checkType == '无计划检查'">and a.plan_task_id &lt;= 0</if>
<choose>
<when test="finishStatus == 0">and (`a`.`plan_task_detail_id` = 0 OR `a`.`plan_task_detail_id` is
null)
</when>
<when test="finishStatus == 0">and (`a`.`plan_task_detail_id` = 0 OR `a`.`plan_task_detail_id` is null)</when>
<when test="finishStatus == 1">and (`a`.`plan_task_detail_id` != 0 AND `a`.`is_ok` != 3)</when>
<when test="finishStatus == 2">and `a`.`is_ok` = 3</when>
</choose>
......@@ -318,17 +345,15 @@
and a.org_code LIKE CONCAT(#{bizOrgCode},'%')
</if>
<if test="searchDay != null and searchDay != ''">
and date_format(
a.check_time,
'%Y-%m-%d'
) = curdate()
and date_format(a.check_time, '%Y-%m-%d') = curdate()
</if>
<if test="isExecute!=null and isExecute!='' and isExecute == '3'">and a.is_OK != #{isExecute}</if>
</trim>
order by ${orderBy}
order by
${orderBy}
<choose>
<when test="pageSize==-1"></when>
<when test="pageSize!=-1">limit #{offset},#{pageSize}</when>
<when test="pageSize!=-1">limit #{offset}, #{pageSize}</when>
</choose>
</select>
......
......@@ -1371,7 +1371,9 @@
<if test="bizOrgCode != null and bizOrgCode != ''">
AND org_code LIKE CONCAT(#{bizOrgCode}, '%')
</if>
UNION ALL
SELECT
'1' AS `key`,
ifnull( sum( `p_plan_task`.`finish_num` ), 0 ) AS `value`,
......@@ -1385,7 +1387,9 @@
<if test="bizOrgCode != null and bizOrgCode != ''">
AND org_code LIKE CONCAT(#{bizOrgCode}, '%')
</if>
UNION ALL
SELECT
'2' AS `key`,
count(1) AS `value`,
......@@ -1400,14 +1404,18 @@
<if test="bizOrgCode != null and bizOrgCode != ''">
AND org_code LIKE CONCAT(#{bizOrgCode}, '%')
</if>
UNION ALL
SELECT
'3' AS `key`,
'' AS `value`,
'%' AS unit,
'合格占比' AS `name`,
'xfxchgzb' AS code
UNION ALL
SELECT
'4' AS `key`,
count(1) AS `value`,
......@@ -1422,7 +1430,9 @@
<if test="bizOrgCode != null and bizOrgCode != ''">
AND org_code LIKE CONCAT(#{bizOrgCode}, '%')
</if>
UNION ALL
SELECT
'5' AS `key`,
count(1) AS `value`,
......@@ -1437,7 +1447,9 @@
<if test="bizOrgCode != null and bizOrgCode != ''">
AND org_code LIKE CONCAT(#{bizOrgCode}, '%')
</if>
UNION ALL
SELECT
'6' AS `key`,
'' AS `value`,
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment