dfc2c0c0 康伟

kangwei: 联调风险库

         bug:安全标准化创优,应填计算
1 个父辈 1cf23567
......@@ -432,6 +432,20 @@ public class JSUtils {
System.out.println(quoteEach(str,",") );
}
/***
* 获取当前日期
* @return
*/
public static String getCurrentDate() {
// 创建一个Calendar实例,并设置为当前日期和时间
Calendar calendar = Calendar.getInstance();
// 设置日期格式
SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd");
// 获取当前日期
String currentDate = dateFormat.format(calendar.getTime());
return currentDate;
}
/* ScriptEngine se = new ScriptEngineManager().getEngineByName("JavaScript");
Object eval = null;
try {
......
......@@ -56,7 +56,7 @@ public class MaterialAcceptanceForm {
@Excel(name = "收货人员签字", width = 15)
@ApiModelProperty(value = "收货人员签字")
private String receiverSign;
@Excel(name = "确认状态 0 未确认、1 部分确认、2全部确认", width = 15)
@Excel(name = "确认状态 0 未确认、1 收货签字、2 送货方签字 、9 全部确认", width = 15)
@ApiModelProperty(value = "确认状态 0 未确认、1 收货签字、2 送货方签字 、9 全部确认")
@Dict( dicCode="purchase_confirm_status")
private String confirmStatus;
......
package com.skua.modules.safe.controller;
import java.io.File;
import java.text.SimpleDateFormat;
import java.time.LocalDate;
import java.util.*;
import java.io.IOException;
import java.io.UnsupportedEncodingException;
......@@ -12,6 +14,7 @@ import com.skua.core.api.vo.Result;
import com.skua.core.aspect.annotation.AutoLog;
import com.skua.core.query.QueryGenerator;
import com.skua.core.util.ConvertUtils;
import com.skua.core.util.DateUtils;
import com.skua.modules.safe.entity.DangerLevelManage;
import com.skua.modules.safe.entity.DangerLevelManageShare;
import com.skua.modules.safe.service.IDangerLevelManageService;
......@@ -23,8 +26,10 @@ import com.skua.modules.system.datestandard.entity.SysStructDict;
import com.skua.modules.system.entity.SysDepart;
import com.skua.modules.system.service.ISysConfigService;
import com.skua.modules.system.service.ISysDepartService;
import com.skua.tool.util.JSUtils;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.StringUtils;
import org.jeecgframework.poi.excel.ExcelImportUtil;
import org.jeecgframework.poi.excel.def.NormalExcelConstants;
import org.jeecgframework.poi.excel.entity.ExportParams;
......@@ -81,7 +86,16 @@ public class DangerLevelManageController {
Result<IPage<DangerLevelManage>> result = new Result<IPage<DangerLevelManage>>();
QueryWrapper<DangerLevelManage> queryWrapper = QueryGenerator.initQueryWrapper(dangerLevelManage, req.getParameterMap());
Page<DangerLevelManage> page = new Page<DangerLevelManage>(pageNo, pageSize);
IPage<DangerLevelManage> pageList = dangerLevelManageService.queryPage(page, queryWrapper);
String startTime = req.getParameter("startTime");
String endTime = req.getParameter("endTime");
if(StringUtils.isEmpty(startTime)){
LocalDate firstDayOfYear = LocalDate.now().withDayOfYear(1);//获取几年第一天
startTime = firstDayOfYear.toString();
}
if(StringUtils.isEmpty(endTime)){
endTime = JSUtils.getCurrentDate();
}
IPage<DangerLevelManage> pageList = dangerLevelManageService.queryPage(page, queryWrapper,startTime,endTime);
result.setSuccess(true);
result.setResult(pageList);
return result;
......
......@@ -99,10 +99,9 @@ public class SafetyStandardOptimizeController {
@AutoLog(value = "安全标准化优化-统计数量")
@ApiOperation(value="安全标准化优化-统计数量", notes="安全标准化优化-统计数量")
@GetMapping(value = "/statisticsCount")
public Result<Map<String,String>> statisticsCount( StatisticsSearchVO statisticsSearchVO) {
Result<Map<String,String>> result = new Result<>();
public Result<Map<String,Object>> statisticsCount( StatisticsSearchVO statisticsSearchVO) {
Result<Map<String,Object>> result = new Result<>();
Map<String,String> dataMap = new HashMap<>();
String departIds = null;
if(StringUtils.isNotEmpty(statisticsSearchVO.getDepartId())){
departIds = departService.getChildDepartId(statisticsSearchVO.getDepartId());
......@@ -110,8 +109,8 @@ public class SafetyStandardOptimizeController {
departIds = BaseContextHandler.getDeparts();
}
statisticsSearchVO.setDepartIds( JSUtils.quoteEach(departIds,","));
List<StatisticsSearchVO> dataList = safetyStandardOptimizeService.statistics(statisticsSearchVO);
Integer wantNum = 0 ;
Map<String,Object> dataMap = safetyStandardOptimizeService.statisticsCount(statisticsSearchVO);
/*Integer wantNum = 0 ;
String finishNum = "0";
String finishNumExpression = "0";
if(dataList != null && !dataList.isEmpty()) {
......@@ -122,7 +121,7 @@ public class SafetyStandardOptimizeController {
finishNum = JSUtils.executeExpression(finishNumExpression,"0");
}
dataMap.put("wantNum",wantNum+"");
dataMap.put("finishNum",finishNum);
dataMap.put("finishNum",finishNum);*/
result.setSuccess(true);
result.setResult(dataMap);
......
......@@ -24,7 +24,7 @@ import org.jeecgframework.poi.excel.annotation.Excel;
@Accessors(chain = true)
@ApiModel(value="danger_inspect_item对象", description="风险检查项")
public class DangerInspectItem implements Serializable{
/**id*/
@TableId(type = IdType.ID_WORKER_STR)
@ApiModelProperty(value = "id")
......@@ -47,6 +47,12 @@ public class DangerInspectItem implements Serializable{
@Excel(name = "选项类型(0:选择,1 是否 2 文本)", width = 15)
@ApiModelProperty(value = "选项类型(0:选择,1 是否 2 文本)")
private String itemType;
/**选项状态(0:异常,1正常)*/
@Excel(name = "隐患后果", width = 15)
@ApiModelProperty(value = "隐患后果")
private String dangerResult;
/**选项状态(0:异常,1正常)*/
@Excel(name = "选项状态(0:异常,1正常)", width = 15)
@ApiModelProperty(value = "选项状态(0:异常,1正常)")
......
......@@ -25,7 +25,11 @@ public interface DangerLevelManageMapper extends BaseMapper<DangerLevelManage> {
@Select("SELECT t.*,ifnull(aaa.inspect_content,'') inspect_content, ifnull(bbb.inspection_num,0) inspection_num, ifnull(ccc.rectification_num,0) 'rectification_num' " +
" FROM danger_level_manage t" +
" left join (select danger_id ,GROUP_CONCAT(inspect_name SEPARATOR '@') 'inspect_content' from danger_inspect_info group by danger_id)aaa on aaa.danger_id = t.id " +
" left join (select danger_id, count(id) 'inspection_num' from danger_inspection_record group by danger_id)bbb on bbb.danger_id = t.id " +
" left join (select danger_id, count(id) 'rectification_num' from ajh_rectification_info group by danger_id)ccc on ccc.danger_id = t.id ${ew.customSqlSegment}")
List<DangerLevelManage> getListByWrapper(Page page,@Param("ew") QueryWrapper<DangerLevelManage> queryWrapper);
" left join (select danger_id, count(id) 'inspection_num' from danger_inspection_record " +
" where DATE_FORMAT(report_date,'%Y-%m-%d') >= #{startTime} and DATE_FORMAT(report_date,'%Y-%m-%d') <= #{endTime} "+
" group by danger_id)bbb on bbb.danger_id = t.id " +
" left join (select danger_id, count(id) 'rectification_num' from ajh_rectification_info" +
" where DATE_FORMAT(rec_ord_report_date,'%Y-%m-%d') >= #{startTime} and DATE_FORMAT(rec_ord_report_date,'%Y-%m-%d') <= #{endTime} "+
" group by danger_id)ccc on ccc.danger_id = t.id ${ew.customSqlSegment}")
List<DangerLevelManage> getListByWrapper(Page page,@Param("ew") QueryWrapper<DangerLevelManage> queryWrapper,@Param("startTime") String startTime,@Param("endTime") String endTime);
}
......
......@@ -14,8 +14,15 @@ import com.baomidou.mybatisplus.core.mapper.BaseMapper;
public interface SafetyStandardOptimizeMapper extends BaseMapper<SafetyStandardOptimize> {
/***
* 统计
* 统计列表
* @return
*/
List<StatisticsSearchVO> statistics(StatisticsSearchVO statisticsSearchVO);
/***
* 统计数量
* @param statisticsSearchVO
* @return
*/
Map<String,Object> statisticsCount(StatisticsSearchVO statisticsSearchVO);
}
......
......@@ -17,8 +17,24 @@
<select id="queryByList" resultType="com.skua.modules.safe.entity.DangerLevelManage">
select ifnull(aaa.inspect_content,'') inspect_content, ifnull(bbb.inspection_num,0) inspection_num, ifnull(ccc.rectification_num,0) 'rectification_num', t.* from danger_level_manage t
left join (select danger_id ,GROUP_CONCAT(inspect_name SEPARATOR '@') 'inspect_content' from danger_inspect_info group by danger_id)aaa on aaa.danger_id = t.id
left join (select danger_id, count(id) 'inspection_num' from danger_inspection_record group by danger_id)bbb on bbb.danger_id = t.id
left join (select danger_id, count(id) 'rectification_num' from ajh_rectification_info group by danger_id)ccc on ccc.danger_id = t.id
left join (select danger_id, count(id) 'inspection_num' from danger_inspection_record
where 1=1
<if test="startTime != null and startTime !=''">
and DATE_FORMAT(report_date,'%Y-%m-%d') &gt;= #{startTime}
</if>
<if test="endTime != null and endTime !=''">
and DATE_FORMAT(report_date,'%Y-%m-%d') &lt;= #{endTime}
</if>
group by danger_id)bbb on bbb.danger_id = t.id
left join (select danger_id, count(id) 'rectification_num' from ajh_rectification_info
where 1=1
<if test="startTime != null and startTime !=''">
and DATE_FORMAT(rec_ord_report_date,'%Y-%m-%d') &gt;= #{startTime}
</if>
<if test="endTime != null and endTime !=''">
and DATE_FORMAT(rec_ord_report_date,'%Y-%m-%d') &lt;= #{endTime}
</if>
group by danger_id)ccc on ccc.danger_id = t.id
<where>
<if test="param.departId != null and param.departId != ''"> and t.depart_id = #{param.departId}</if>
<if test="param.dangerType != null and param.dangerType != ''"> and t.danger_type = #{param.dangerType}</if>
......
......@@ -3,7 +3,7 @@
<mapper namespace="com.skua.modules.safe.mapper.SafetyStandardOptimizeMapper">
<select id="statistics" resultType="com.skua.modules.safe.vo.StatisticsSearchVO" >
select d.id depart_id, d.depart_name,#{wantNum} 'wantNum', ifnull(aaa.report_num , 0 )finishNum
select d.id depart_id, d.depart_name, ifnull(aaa.report_num , 0 )finishNum
from sys_depart d
left join (select so.depart_id , count(so.id) report_num from safety_standard_optimize so
where DATE_FORMAT( so.create_time, '%Y-%m-%d' ) &gt;= #{startDate} AND DATE_FORMAT( so.create_time, '%Y-%m-%d' ) &lt;= #{endDate}
......@@ -14,4 +14,20 @@
</if>
and d.depart_type = 1
</select>
<select id="statisticsCount" resultType="java.util.Map" >
select (count(aaa.depart_id) * aaa.wantNum ) 'wantNum', sum(aaa.finishNum) 'finishNum' from (
select d.id depart_id, d.depart_name,#{wantNum} 'wantNum', ifnull(aaa.report_num , 0 )finishNum
from sys_depart d
left join (select so.depart_id , count(so.id) report_num from safety_standard_optimize so
where DATE_FORMAT( so.create_time, '%Y-%m-%d' ) &gt;= #{startDate} AND DATE_FORMAT( so.create_time, '%Y-%m-%d' ) &lt;= #{endDate}
GROUP BY so.depart_id ) aaa on aaa.depart_id = d.id
where d.id in(${departIds})
<if test="departName != null ">
and d.depart_name like CONCAT('%',#{departName},'%')
</if>
and d.depart_type = 1
)aaa
</select>
</mapper>
......
......@@ -25,5 +25,5 @@ public interface IDangerLevelManageService extends IService<DangerLevelManage> {
* @param queryWrapper
* @return
*/
public IPage<DangerLevelManage> queryPage(Page<DangerLevelManage> page, QueryWrapper<DangerLevelManage> queryWrapper) ;
public IPage<DangerLevelManage> queryPage(Page<DangerLevelManage> page, QueryWrapper<DangerLevelManage> queryWrapper ,String startTime,String endTime) ;
}
......
......@@ -13,8 +13,15 @@ import java.util.Map;
public interface ISafetyStandardOptimizeService extends IService<SafetyStandardOptimize> {
/***
* 统计
* 统计列表
* @return
*/
List<StatisticsSearchVO > statistics(StatisticsSearchVO statisticsSearchVO);
/***
* 统计数量
* @param statisticsSearchVO
* @return
*/
Map<String,Object> statisticsCount(StatisticsSearchVO statisticsSearchVO);
}
......
......@@ -35,8 +35,8 @@ public class DangerLevelManageServiceImpl extends ServiceImpl<DangerLevelManageM
* @param queryWrapper
* @return
*/
public IPage<DangerLevelManage> queryPage(Page<DangerLevelManage> page, QueryWrapper<DangerLevelManage> queryWrapper) {
List<DangerLevelManage> list = this.baseMapper.getListByWrapper(page, queryWrapper);
public IPage<DangerLevelManage> queryPage(Page<DangerLevelManage> page, QueryWrapper<DangerLevelManage> queryWrapper ,String startTime,String endTime) {
List<DangerLevelManage> list = this.baseMapper.getListByWrapper(page, queryWrapper,startTime, endTime);
page.setRecords(list);
return page;
}
......
......@@ -23,6 +23,14 @@ public class SafetyStandardOptimizeServiceImpl extends ServiceImpl<SafetyStandar
* @return
*/
public List<StatisticsSearchVO> statistics(StatisticsSearchVO statisticsSearchVO){
return this.baseMapper.statistics(statisticsSearchVO);
}
/***
* 统计数量
* @param statisticsSearchVO
* @return
*/
public Map<String,Object> statisticsCount(StatisticsSearchVO statisticsSearchVO){
//计算两个时间相间的季度 = 应填写数量
List<String> monthList = DateUtils.getMonthsBetween(statisticsSearchVO.getStartDate(), statisticsSearchVO.getEndDate());
double d = monthList.size() / 3d;
......@@ -33,6 +41,6 @@ public class SafetyStandardOptimizeServiceImpl extends ServiceImpl<SafetyStandar
wantNum = (int)d +1;
}
statisticsSearchVO.setWantNum(wantNum );
return this.baseMapper.statistics(statisticsSearchVO);
return this.baseMapper.statisticsCount(statisticsSearchVO);
}
}
......
支持 Markdown 格式
你添加了 0 到此讨论。请谨慎行事。
Finish editing this message first!