Commit d9b7542f authored by 竹天卫's avatar 竹天卫

统计分析优化

parent d8fc0bbe
......@@ -70,7 +70,7 @@ public class DataStatisticsController {
return BaseResponse.errorMsg("失败!");
}
@ApiOperation(value = "统计概览-项目进展统计")
@ApiOperation(value = "统计概览-委托单进展统计")
@ApiImplicitParams(value = {
@ApiImplicitParam(name = "cycle", value = "统计周期1:本周 2:本月 3:本年", paramType = "query", dataType = "Integer"),
@ApiImplicitParam(name = "startDate", value = "开始日期", paramType = "query", dataType = "String"),
......@@ -81,29 +81,34 @@ public class DataStatisticsController {
try {
return dataStatisticsService.countEntrustStatus(cycle, startDate, endDate);
} catch (Exception e) {
log.debug("统计概览-项目进展统计{}", e);
log.debug("统计概览-委托单进展统计{}", e);
}
return BaseResponse.errorMsg("失败!");
}
@ApiOperation(value = "项目进展统计-列表")
@ApiOperation(value = "委托单进展统计-列表")
@ApiImplicitParams(value = {
@ApiImplicitParam(name = "type", value = "类型1:按时间 2:按地区", paramType = "query", dataType = "Integer"),
@ApiImplicitParam(name = "cycle", value = "统计周期1:本周 2:本月 3:本年", paramType = "query", dataType = "Integer"),
@ApiImplicitParam(name = "startDate", value = "开始日期", paramType = "query", dataType = "String"),
@ApiImplicitParam(name = "endDate", value = "结束日期", paramType = "query", dataType = "String")
@ApiImplicitParam(name = "endDate", value = "结束日期", paramType = "query", dataType = "String"),
@ApiImplicitParam(name = "clientName", value = "委托单位名称", paramType = "query", dataType = "String")
})
@GetMapping("/countEntrustPage")
public BaseResponse countEntrustPage(PageQuery pageQuery) {
public BaseResponse countEntrustPage(PageQuery pageQuery, Integer cycle, String startDate, String endDate, String clientName) {
try {
return dataStatisticsService.countEntrustPage(pageQuery);
return dataStatisticsService.countEntrustPage(pageQuery, cycle, startDate, endDate, clientName);
} catch (Exception e) {
log.debug("项目进展统计-列表{}", e);
log.debug("委托单进展统计-列表{}", e);
}
return BaseResponse.errorMsg("失败!");
}
//todo 委托单进展统计-列表导出
@ApiOperation(value = "统计概览-进行中任务数量统计")
@GetMapping("/countTaskIng")
public BaseResponse countTaskIng(PageQuery pageQuery) {
......
......@@ -389,7 +389,7 @@ public class EntrustController {
return BaseResponse.errorMsg("失败!");
}
@ApiOperation(value = "详情-检测任务信息")
@ApiOperation(value = "详情-检测任务信息(检测结果)")
@GetMapping("/getSampleCheckDtail/{id}")
public BaseResponse getSampleCheckDtail(@PathVariable Integer id) {
try {
......
......@@ -38,8 +38,12 @@ public interface DataStatisticsMapper {
IPage<DataStatisticsVo> countHandlePage(@Param("page") Page page);
Integer countHandleWeek(@Param("userId") Integer userId, @Param("weekType") Integer weekType);
IPage<DataStatisticsVo> countDistributionPage(@Param("page") Page page);
Integer countDistributionWeek(@Param("userId") Integer userId, @Param("weekType") Integer weekType);
List<DataStatisticsVo> countTeamIng();
List<DataStatisticsVo> countTeam(@Param("params") Map<String, Object> params);
......
......@@ -3,7 +3,7 @@
<mapper namespace="cn.wise.sc.cement.business.mapper.DataStatisticsMapper">
<select id="countTeamByTime" resultType="cn.wise.sc.cement.business.model.vo.DataStatisticsVo">
SELECT DATE_FORMAT(sd.create_time,'%Y-%m') as name, count(sd.id) as value
SELECT DATE_FORMAT(sd.create_time,'%Y-%m-%d') as name, count(sd.id) as value
FROM sample_distribution sd
where sd.finish_time is not null
<if test="params.cycle == 1 ">
......@@ -21,9 +21,14 @@
<if test="params.endDate != null and params.endDate != ''">
and DATE(sd.create_time) &lt;= #{params.endDate}
</if>
<if test="params.endDate = null and params.endDate = null">
and date(sd.create_time) > date_sub(curdate(),interval 30 day)
</if>
group by name
</select>
<select id="countTeamByOrigin" resultType="cn.wise.sc.cement.business.model.vo.DataStatisticsVo">
SELECT s.origin as name, count(sd.id) as value
FROM sample_distribution sd
......@@ -60,6 +65,7 @@
WHEN 6 THEN '样品检测完成'
WHEN 7 THEN '校核中'
WHEN 8 THEN '校核完成'
WHEN 9 THEN '修改待确认'
ELSE ''
END
) as name,
......@@ -107,7 +113,7 @@
</select>
<select id="countEntrustPage" resultType="cn.wise.sc.cement.business.model.vo.EntrustVo">
select e.*, c.name as clientName, su.name as userName,
select e.*, p.name as projectName, p.code as projectCode, c.name as clientName, su.name as userName,
(
CASE e.status
WHEN 0 THEN '未评审'
......@@ -127,32 +133,69 @@
left join client c on c.id = e.client_id
left join sys_user su on su.id = e.user_id
where e.status != 0 and e.project_type is not null
<if test="params.clientName != null and params.clientName != ''">
and c.name like concat('%', #{params.clientName}, '%')
</if>
order by create_time desc
</select>
<select id="countHandlePage" resultType="cn.wise.sc.cement.business.model.vo.DataStatisticsVo">
SELECT su.name as name, count(*) as value FROM sample_handle sh
SELECT su.id as id, su.name as name, count(*) as value FROM sample_handle sh
left join sys_user su on su.id = sh.user_id
where sh.status != 2
where sh.status = 1 or sh.status = 5
group by sh.user_id
</select>
<select id="countHandleWeek" resultType="integer">
SELECT count(*)
FROM sample_handle sh
left join sys_user su on su.id = sh.user_id
where (sh.status =2 or sh.status =4)
<if test="userId != null ">
and sh.user_id = #{userId}
</if>
<if test="weekType == 1 ">
and YEARWEEK(date_format(sh.create_time,'%Y-%m-%d' ) ) = YEARWEEK(now())-1
</if>
<if test="weekType == 2 ">
and YEARWEEK(date_format(sh.create_time,'%Y-%m-%d' ) ) = YEARWEEK(now())
</if>
group by sh.user_id
</select>
<select id="countDistributionPage" resultType="cn.wise.sc.cement.business.model.vo.DataStatisticsVo">
SELECT su.name as name, count(*) as value FROM sample_distribution sd
SELECT su.id as id, su.name as name, count(*) as value FROM sample_distribution sd
left join sys_user su on su.id = sd.user_id
where sd.status = 1 or sd.status = 5
group by sd.user_id
</select>
<select id="countDistributionWeek" resultType="integer">
SELECT count(*)
FROM sample_distribution sd
left join sys_user su on su.id = sd.user_id
where sd.status != 2
where (sd.status =2 or sd.status =4)
<if test="userId != null ">
and sd.user_id = #{userId}
</if>
<if test="weekType == 1 ">
and YEARWEEK(date_format(sd.create_time,'%Y-%m-%d' ) ) = YEARWEEK(now())-1
</if>
<if test="weekType == 2 ">
and YEARWEEK(date_format(sd.create_time,'%Y-%m-%d' ) ) = YEARWEEK(now())
</if>
group by sd.user_id
</select>
<select id="countTeamIng" resultType="cn.wise.sc.cement.business.model.vo.DataStatisticsVo">
SELECT t.name as name, count(*) as value FROM sample_distribution sd
left join team t on t.id = sd.team_id
where sd.status != 2
where sd.status = 1 or sd.status = 5
group by sd.team_id
</select>
......
......@@ -439,6 +439,7 @@
<select id="getSampleReturnCheckPage" resultType="cn.wise.sc.cement.business.model.vo.EntrustVo">
select e.id as id, e.entrust_code as entrustCode, e.sample_num as sampleNum,e.entrust_date as entrustDate,
e.project_type as projectType, t.remark as opinion,
e.status,
(
CASE e.status
......@@ -492,7 +493,6 @@
<if test="params.isUrgent != null">
and e.is_urgent = #{params.isUrgent}
</if>
GROUP BY e.id
order by e.update_time desc
</select>
</mapper>
......@@ -13,10 +13,18 @@ import lombok.Data;
@ApiModel("数据统计-展示类")
public class DataStatisticsVo {
@ApiModelProperty("id标识")
private Integer id;
@ApiModelProperty("名称")
private String name;
@ApiModelProperty("值")
private String value;
@ApiModelProperty("周涨幅")
private String weekUp;
}
......@@ -5,6 +5,7 @@ import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import java.math.BigDecimal;
import java.time.LocalDate;
import java.time.LocalDateTime;
import java.util.List;
......@@ -123,7 +124,7 @@ public class EntrustVo {
@ApiModelProperty("任务接受时间")
private LocalDateTime acceptTime;
@ApiModelProperty("评审意见")
@ApiModelProperty("评审意见/退回原因")
private String opinion;
@ApiModelProperty("文件名")
......@@ -136,6 +137,11 @@ public class EntrustVo {
private String enclosureUrl;
@ApiModelProperty("产值(所有样品产值)")
private BigDecimal outputValue;
......
......@@ -37,6 +37,9 @@ public class SampleDistributionTeamVo {
@ApiModelProperty(" 状态值(0未接受,1接受,2待校核,3退回,4校核通过,5校核退回)")
private String statusValue;
@ApiModelProperty("最终结果")
private String lastResult;
@ApiModelProperty("检测设备列表")
List<SampleDistributionEquipmentVo> sampleDistributionEquipmentList;
......
......@@ -34,7 +34,7 @@ public interface IDataStatisticsService {
BaseResponse<Map<String, Object>> countEntrustStatus(Integer cycle, String startDate, String endDate);
BaseResponse<IPage<EntrustVo>> countEntrustPage(PageQuery pageQuery);
BaseResponse<IPage<EntrustVo>> countEntrustPage(PageQuery pageQuery, Integer cycle, String startDate, String endDate, String clientName);
BaseResponse<Map<String, Object>> countTaskIng(PageQuery pageQuery);
......
......@@ -298,18 +298,18 @@ public class EntrustServiceImpl extends ServiceImpl<EntrustMapper, Entrust> impl
BeanUtils.copyProperties(sampleTmpQuery, sampleTmp);
String teamIds = sampleTmpQuery.getTeamIds(); //选择的检测项id集合
BigDecimal charge = new BigDecimal("0.00");
if (teamIds != null) {
String[] teamIdS = teamIds.split("、");
List<String> teamNameList = new ArrayList<>();
for (String teamId : teamIdS) {
Team team = teamMapper.selectById(Integer.valueOf(teamId));
if (team != null) {
if(!teamNameList.contains(teamId)){
charge = charge.compareTo(BigDecimal.ZERO) == 0 ? team.getCharge() : (charge.add(team.getCharge()));
teamNameList.add(team.getName());
if (teamIds != null) {
String[] teamIdS = teamIds.split("、");
List<String> teamNameList = new ArrayList<>();
for (String teamId : teamIdS) {
Team team = teamMapper.selectById(Integer.valueOf(teamId));
if (team != null) {
if(!teamNameList.contains(teamId)){
charge = charge.compareTo(BigDecimal.ZERO) == 0 ? team.getCharge() : (charge.add(team.getCharge()));
teamNameList.add(team.getName());
}
}
}
}
//选择Mg必须选择Ca;选择Al必须选择Fe
if(teamNameList.contains("MgO")){
if(!teamNameList.contains("CaO")){
......@@ -558,6 +558,7 @@ public class EntrustServiceImpl extends ServiceImpl<EntrustMapper, Entrust> impl
System.out.println(content);
weiXinService.sendTextMessage(userIds, content);
}else if(approvalIdList.contains(loginUser.getId())){
//如果是评审人员修改
SysUser createUser = userService.getById(entrust.getUserId());
if(createUser == null){
return BaseResponse.errorMsg("委托人信息错误");
......@@ -1060,7 +1061,8 @@ public class EntrustServiceImpl extends ServiceImpl<EntrustMapper, Entrust> impl
if (entrust == null) {
return BaseResponse.errorMsg("信息错误");
}
List<Sample> sampleList = sampleMapper.getSampleCheckList(id);
//只看主样 对应的最终结果值
List<Sample> sampleList = sampleMapper.getCheckSampleList(id);
List<SampleVo> sampleVoList = new ArrayList<>();
if (sampleList != null && sampleList.size() > 0) {
......@@ -1069,12 +1071,21 @@ public class EntrustServiceImpl extends ServiceImpl<EntrustMapper, Entrust> impl
BeanUtils.copyProperties(sample, sampleVo);
List<SampleDistributionTeamVo> sampleDistributionTeamVoList =
distributionMapper.getDistributionTeamList(sample.getId(), null);
if (sampleDistributionTeamVoList != null && sampleDistributionTeamVoList.size() > 0) {
//已经派发过的列表
List<SampleTeamGroupVo> sampleTeamGroupVoListed = new ArrayList<>();
List<Integer> teamGroupIdList = new ArrayList<>();
for(SampleDistributionTeamVo sampleDistributionTeamVo : sampleDistributionTeamVoList){
SampleDistribution sampleDistribution = distributionMapper.selectById(sampleDistributionTeamVo.getDistributionId());
//该检测项的误差结果值和最终结果值
if(sampleDistribution.getCheckId() != null){
SampleDistributionCheck disCheck = sampleDistributionCheckMapper.selectById(sampleDistribution.getCheckId());
sampleDistributionTeamVo.setLastResult(disCheck.getLastResult());
}else{
sampleDistributionTeamVo.setLastResult(sampleDistribution.getDistributionResult());
}
TeamGroup teamGroup = teamGroupMapper.selectById(sampleDistribution.getTeamGroupId());
if(!teamGroupIdList.contains(sampleDistribution.getTeamGroupId())){
teamGroupIdList.add(sampleDistribution.getTeamGroupId());
......@@ -1514,6 +1525,7 @@ public class EntrustServiceImpl extends ServiceImpl<EntrustMapper, Entrust> impl
.setIsHandle(0)//样品处理未完成状态
.setIsDistribution(0)//任务派发未完成状态
.setIsCheck(0)//样品校核未完成状态
.setOutputValue(sample.getCharge()) //产值不用评审人员修改
.setParallelCode(maxCementCode);
sampleList.add(sample);
}
......@@ -2069,7 +2081,7 @@ public class EntrustServiceImpl extends ServiceImpl<EntrustMapper, Entrust> impl
List<Integer> userIdList = new ArrayList<>();
if (query.getSampleDistributionQueryList() != null && query.getSampleDistributionQueryList().size() > 0) {
List<SampleDistributionQuery> sampleDistributionQueryList = query.getSampleDistributionQueryList();
List<SampleDistribution> sampleDistributionList = new ArrayList<>();
// List<SampleDistribution> sampleDistributionList = new ArrayList<>();
//判断改委托单的所有样品检测项对应的处理项对应的处理人,然后按照检测项存入检测项表,以便校核的时候可以校核结果
//只显示主样,因为样品处理只显示主样
......@@ -2104,7 +2116,8 @@ public class EntrustServiceImpl extends ServiceImpl<EntrustMapper, Entrust> impl
.setStatus(2) //直接进入待校核状态
.setAcceptTime(sampleHandle.getAcceptTime())
.setFinishTime(sampleHandle.getFinishTime());
sampleDistributionList.add(sampleDistribution);
distributionService.save(sampleDistribution);
// sampleDistributionList.add(sampleDistribution);
//将样品处理的附件复制到样品检测的附件表中 如果校核附件有重复,可以去掉这个逻辑
Map<String, Object> params = new HashMap<>();
......@@ -2167,7 +2180,8 @@ public class EntrustServiceImpl extends ServiceImpl<EntrustMapper, Entrust> impl
.setCreateTime(LocalDateTime.now())
.setStatus(1) //直接接收检测任务
.setAcceptTime(LocalDateTime.now());
sampleDistributionList.add(sampleDistribution);
distributionService.save(sampleDistribution);
// sampleDistributionList.add(sampleDistribution);
//获取产值信息
QueryWrapper<NormProduction> queryWrapper = new QueryWrapper<>();
......@@ -2201,7 +2215,9 @@ public class EntrustServiceImpl extends ServiceImpl<EntrustMapper, Entrust> impl
sample.setStatus(1); //样品状态改成已领用状态
sampleList.add(sample);
}
distributionService.saveBatch(sampleDistributionList);
// distributionService.saveBatch(sampleDistributionList);
sampleService.updateBatchById(sampleList);
}
entrust.setStatus(5).setIsDistribution(1);
......
......@@ -3,7 +3,7 @@
<mapper namespace="cn.wise.sc.cement.business.mapper.DataStatisticsMapper">
<select id="countTeamByTime" resultType="cn.wise.sc.cement.business.model.vo.DataStatisticsVo">
SELECT DATE_FORMAT(sd.create_time,'%Y-%m') as name, count(sd.id) as value
SELECT DATE_FORMAT(sd.create_time,'%Y-%m-%d') as name, count(sd.id) as value
FROM sample_distribution sd
where sd.finish_time is not null
<if test="params.cycle == 1 ">
......@@ -21,9 +21,14 @@
<if test="params.endDate != null and params.endDate != ''">
and DATE(sd.create_time) &lt;= #{params.endDate}
</if>
<if test="params.endDate = null and params.endDate = null">
and date(sd.create_time) > date_sub(curdate(),interval 30 day)
</if>
group by name
</select>
<select id="countTeamByOrigin" resultType="cn.wise.sc.cement.business.model.vo.DataStatisticsVo">
SELECT s.origin as name, count(sd.id) as value
FROM sample_distribution sd
......@@ -60,6 +65,7 @@
WHEN 6 THEN '样品检测完成'
WHEN 7 THEN '校核中'
WHEN 8 THEN '校核完成'
WHEN 9 THEN '修改待确认'
ELSE ''
END
) as name,
......@@ -107,7 +113,7 @@
</select>
<select id="countEntrustPage" resultType="cn.wise.sc.cement.business.model.vo.EntrustVo">
select e.*, c.name as clientName, su.name as userName,
select e.*, p.name as projectName, p.code as projectCode, c.name as clientName, su.name as userName,
(
CASE e.status
WHEN 0 THEN '未评审'
......@@ -127,32 +133,54 @@
left join client c on c.id = e.client_id
left join sys_user su on su.id = e.user_id
where e.status != 0 and e.project_type is not null
<if test="params.clientName != null and params.clientName != ''">
and c.name like concat('%', #{params.clientName}, '%')
</if>
order by create_time desc
</select>
<select id="countHandlePage" resultType="cn.wise.sc.cement.business.model.vo.DataStatisticsVo">
SELECT su.name as name, count(*) as value FROM sample_handle sh
SELECT su.id as id, su.name as name, count(*) as value FROM sample_handle sh
left join sys_user su on su.id = sh.user_id
where sh.status != 2
where sh.status = 1 or sh.status = 5
group by sh.user_id
</select>
<select id="countHandleWeek" resultType="integer">
SELECT count(*)
FROM sample_handle sh
left join sys_user su on su.id = sh.user_id
where (sh.status =2 or sh.status =4)
<if test="userId != null ">
and sh.user_id = #{userId}
</if>
<if test="weekType == 1 ">
and YEARWEEK(date_format(sh.create_time,'%Y-%m-%d' ) ) = YEARWEEK(now())-1
</if>
<if test="weekType == 2 ">
and YEARWEEK(date_format(sh.create_time,'%Y-%m-%d' ) ) = YEARWEEK(now())
</if>
group by sh.user_id
</select>
<select id="countDistributionPage" resultType="cn.wise.sc.cement.business.model.vo.DataStatisticsVo">
SELECT su.name as name, count(*) as value FROM sample_distribution sd
left join sys_user su on su.id = sd.user_id
where sd.status != 2
where sd.status = 1 or sd.status = 5
group by sd.user_id
</select>
<select id="countTeamIng" resultType="cn.wise.sc.cement.business.model.vo.DataStatisticsVo">
SELECT t.name as name, count(*) as value FROM sample_distribution sd
left join team t on t.id = sd.team_id
where sd.status != 2
where sd.status = 1 or sd.status = 5
group by sd.team_id
</select>
......
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