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

统计分析优化

parent d8fc0bbe
...@@ -70,7 +70,7 @@ public class DataStatisticsController { ...@@ -70,7 +70,7 @@ public class DataStatisticsController {
return BaseResponse.errorMsg("失败!"); return BaseResponse.errorMsg("失败!");
} }
@ApiOperation(value = "统计概览-项目进展统计") @ApiOperation(value = "统计概览-委托单进展统计")
@ApiImplicitParams(value = { @ApiImplicitParams(value = {
@ApiImplicitParam(name = "cycle", value = "统计周期1:本周 2:本月 3:本年", 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 = "startDate", value = "开始日期", paramType = "query", dataType = "String"),
...@@ -81,29 +81,34 @@ public class DataStatisticsController { ...@@ -81,29 +81,34 @@ public class DataStatisticsController {
try { try {
return dataStatisticsService.countEntrustStatus(cycle, startDate, endDate); return dataStatisticsService.countEntrustStatus(cycle, startDate, endDate);
} catch (Exception e) { } catch (Exception e) {
log.debug("统计概览-项目进展统计{}", e); log.debug("统计概览-委托单进展统计{}", e);
} }
return BaseResponse.errorMsg("失败!"); return BaseResponse.errorMsg("失败!");
} }
@ApiOperation(value = "项目进展统计-列表") @ApiOperation(value = "委托单进展统计-列表")
@ApiImplicitParams(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 = "cycle", value = "统计周期1:本周 2:本月 3:本年", paramType = "query", dataType = "Integer"),
@ApiImplicitParam(name = "startDate", value = "开始日期", paramType = "query", dataType = "String"), @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") @GetMapping("/countEntrustPage")
public BaseResponse countEntrustPage(PageQuery pageQuery) { public BaseResponse countEntrustPage(PageQuery pageQuery, Integer cycle, String startDate, String endDate, String clientName) {
try { try {
return dataStatisticsService.countEntrustPage(pageQuery); return dataStatisticsService.countEntrustPage(pageQuery, cycle, startDate, endDate, clientName);
} catch (Exception e) { } catch (Exception e) {
log.debug("项目进展统计-列表{}", e); log.debug("委托单进展统计-列表{}", e);
} }
return BaseResponse.errorMsg("失败!"); return BaseResponse.errorMsg("失败!");
} }
//todo 委托单进展统计-列表导出
@ApiOperation(value = "统计概览-进行中任务数量统计") @ApiOperation(value = "统计概览-进行中任务数量统计")
@GetMapping("/countTaskIng") @GetMapping("/countTaskIng")
public BaseResponse countTaskIng(PageQuery pageQuery) { public BaseResponse countTaskIng(PageQuery pageQuery) {
......
...@@ -389,7 +389,7 @@ public class EntrustController { ...@@ -389,7 +389,7 @@ public class EntrustController {
return BaseResponse.errorMsg("失败!"); return BaseResponse.errorMsg("失败!");
} }
@ApiOperation(value = "详情-检测任务信息") @ApiOperation(value = "详情-检测任务信息(检测结果)")
@GetMapping("/getSampleCheckDtail/{id}") @GetMapping("/getSampleCheckDtail/{id}")
public BaseResponse getSampleCheckDtail(@PathVariable Integer id) { public BaseResponse getSampleCheckDtail(@PathVariable Integer id) {
try { try {
......
...@@ -38,8 +38,12 @@ public interface DataStatisticsMapper { ...@@ -38,8 +38,12 @@ public interface DataStatisticsMapper {
IPage<DataStatisticsVo> countHandlePage(@Param("page") Page page); IPage<DataStatisticsVo> countHandlePage(@Param("page") Page page);
Integer countHandleWeek(@Param("userId") Integer userId, @Param("weekType") Integer weekType);
IPage<DataStatisticsVo> countDistributionPage(@Param("page") Page page); IPage<DataStatisticsVo> countDistributionPage(@Param("page") Page page);
Integer countDistributionWeek(@Param("userId") Integer userId, @Param("weekType") Integer weekType);
List<DataStatisticsVo> countTeamIng(); List<DataStatisticsVo> countTeamIng();
List<DataStatisticsVo> countTeam(@Param("params") Map<String, Object> params); List<DataStatisticsVo> countTeam(@Param("params") Map<String, Object> params);
......
...@@ -3,7 +3,7 @@ ...@@ -3,7 +3,7 @@
<mapper namespace="cn.wise.sc.cement.business.mapper.DataStatisticsMapper"> <mapper namespace="cn.wise.sc.cement.business.mapper.DataStatisticsMapper">
<select id="countTeamByTime" resultType="cn.wise.sc.cement.business.model.vo.DataStatisticsVo"> <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 FROM sample_distribution sd
where sd.finish_time is not null where sd.finish_time is not null
<if test="params.cycle == 1 "> <if test="params.cycle == 1 ">
...@@ -21,9 +21,14 @@ ...@@ -21,9 +21,14 @@
<if test="params.endDate != null and params.endDate != ''"> <if test="params.endDate != null and params.endDate != ''">
and DATE(sd.create_time) &lt;= #{params.endDate} and DATE(sd.create_time) &lt;= #{params.endDate}
</if> </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 group by name
</select> </select>
<select id="countTeamByOrigin" resultType="cn.wise.sc.cement.business.model.vo.DataStatisticsVo"> <select id="countTeamByOrigin" resultType="cn.wise.sc.cement.business.model.vo.DataStatisticsVo">
SELECT s.origin as name, count(sd.id) as value SELECT s.origin as name, count(sd.id) as value
FROM sample_distribution sd FROM sample_distribution sd
...@@ -60,6 +65,7 @@ ...@@ -60,6 +65,7 @@
WHEN 6 THEN '样品检测完成' WHEN 6 THEN '样品检测完成'
WHEN 7 THEN '校核中' WHEN 7 THEN '校核中'
WHEN 8 THEN '校核完成' WHEN 8 THEN '校核完成'
WHEN 9 THEN '修改待确认'
ELSE '' ELSE ''
END END
) as name, ) as name,
...@@ -107,7 +113,7 @@ ...@@ -107,7 +113,7 @@
</select> </select>
<select id="countEntrustPage" resultType="cn.wise.sc.cement.business.model.vo.EntrustVo"> <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 CASE e.status
WHEN 0 THEN '未评审' WHEN 0 THEN '未评审'
...@@ -127,32 +133,69 @@ ...@@ -127,32 +133,69 @@
left join client c on c.id = e.client_id left join client c on c.id = e.client_id
left join sys_user su on su.id = e.user_id left join sys_user su on su.id = e.user_id
where e.status != 0 and e.project_type is not null 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 order by create_time desc
</select> </select>
<select id="countHandlePage" resultType="cn.wise.sc.cement.business.model.vo.DataStatisticsVo"> <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 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 group by sh.user_id
</select> </select>
<select id="countDistributionPage" resultType="cn.wise.sc.cement.business.model.vo.DataStatisticsVo"> <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 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 group by sd.user_id
</select> </select>
<select id="countTeamIng" resultType="cn.wise.sc.cement.business.model.vo.DataStatisticsVo"> <select id="countTeamIng" resultType="cn.wise.sc.cement.business.model.vo.DataStatisticsVo">
SELECT t.name as name, count(*) as value FROM sample_distribution sd SELECT t.name as name, count(*) as value FROM sample_distribution sd
left join team t on t.id = sd.team_id 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 group by sd.team_id
</select> </select>
......
...@@ -439,6 +439,7 @@ ...@@ -439,6 +439,7 @@
<select id="getSampleReturnCheckPage" resultType="cn.wise.sc.cement.business.model.vo.EntrustVo"> <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, 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, e.status,
( (
CASE e.status CASE e.status
...@@ -492,7 +493,6 @@ ...@@ -492,7 +493,6 @@
<if test="params.isUrgent != null"> <if test="params.isUrgent != null">
and e.is_urgent = #{params.isUrgent} and e.is_urgent = #{params.isUrgent}
</if> </if>
GROUP BY e.id
order by e.update_time desc order by e.update_time desc
</select> </select>
</mapper> </mapper>
...@@ -13,10 +13,18 @@ import lombok.Data; ...@@ -13,10 +13,18 @@ import lombok.Data;
@ApiModel("数据统计-展示类") @ApiModel("数据统计-展示类")
public class DataStatisticsVo { public class DataStatisticsVo {
@ApiModelProperty("id标识")
private Integer id;
@ApiModelProperty("名称") @ApiModelProperty("名称")
private String name; private String name;
@ApiModelProperty("值") @ApiModelProperty("值")
private String value; private String value;
@ApiModelProperty("周涨幅")
private String weekUp;
} }
...@@ -5,6 +5,7 @@ import io.swagger.annotations.ApiModel; ...@@ -5,6 +5,7 @@ import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty; import io.swagger.annotations.ApiModelProperty;
import lombok.Data; import lombok.Data;
import java.math.BigDecimal;
import java.time.LocalDate; import java.time.LocalDate;
import java.time.LocalDateTime; import java.time.LocalDateTime;
import java.util.List; import java.util.List;
...@@ -123,7 +124,7 @@ public class EntrustVo { ...@@ -123,7 +124,7 @@ public class EntrustVo {
@ApiModelProperty("任务接受时间") @ApiModelProperty("任务接受时间")
private LocalDateTime acceptTime; private LocalDateTime acceptTime;
@ApiModelProperty("评审意见") @ApiModelProperty("评审意见/退回原因")
private String opinion; private String opinion;
@ApiModelProperty("文件名") @ApiModelProperty("文件名")
...@@ -136,6 +137,11 @@ public class EntrustVo { ...@@ -136,6 +137,11 @@ public class EntrustVo {
private String enclosureUrl; private String enclosureUrl;
@ApiModelProperty("产值(所有样品产值)")
private BigDecimal outputValue;
......
...@@ -37,6 +37,9 @@ public class SampleDistributionTeamVo { ...@@ -37,6 +37,9 @@ public class SampleDistributionTeamVo {
@ApiModelProperty(" 状态值(0未接受,1接受,2待校核,3退回,4校核通过,5校核退回)") @ApiModelProperty(" 状态值(0未接受,1接受,2待校核,3退回,4校核通过,5校核退回)")
private String statusValue; private String statusValue;
@ApiModelProperty("最终结果")
private String lastResult;
@ApiModelProperty("检测设备列表") @ApiModelProperty("检测设备列表")
List<SampleDistributionEquipmentVo> sampleDistributionEquipmentList; List<SampleDistributionEquipmentVo> sampleDistributionEquipmentList;
......
...@@ -34,7 +34,7 @@ public interface IDataStatisticsService { ...@@ -34,7 +34,7 @@ public interface IDataStatisticsService {
BaseResponse<Map<String, Object>> countEntrustStatus(Integer cycle, String startDate, String endDate); 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); BaseResponse<Map<String, Object>> countTaskIng(PageQuery pageQuery);
......
...@@ -14,6 +14,7 @@ import cn.wise.sc.cement.business.util.ExcelUtil; ...@@ -14,6 +14,7 @@ import cn.wise.sc.cement.business.util.ExcelUtil;
import cn.wise.sc.cement.business.util.RedisUtil; import cn.wise.sc.cement.business.util.RedisUtil;
import com.alibaba.fastjson.JSON; import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONArray; import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage; import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.core.toolkit.CollectionUtils; import com.baomidou.mybatisplus.core.toolkit.CollectionUtils;
...@@ -32,6 +33,7 @@ import org.springframework.transaction.annotation.Transactional; ...@@ -32,6 +33,7 @@ import org.springframework.transaction.annotation.Transactional;
import javax.annotation.Resource; import javax.annotation.Resource;
import javax.servlet.http.HttpServletResponse; import javax.servlet.http.HttpServletResponse;
import java.math.BigDecimal; import java.math.BigDecimal;
import java.text.NumberFormat;
import java.text.ParseException; import java.text.ParseException;
import java.text.SimpleDateFormat; import java.text.SimpleDateFormat;
import java.time.LocalDate; import java.time.LocalDate;
...@@ -62,11 +64,13 @@ public class DataStatisticsServiceImpl implements IDataStatisticsService { ...@@ -62,11 +64,13 @@ public class DataStatisticsServiceImpl implements IDataStatisticsService {
@Autowired @Autowired
private IEntrustService entrustService; private IEntrustService entrustService;
@Autowired @Autowired
private CommonServiceImpl commonService;
@Autowired
private ISampleHandleService sampleHandleService; private ISampleHandleService sampleHandleService;
@Autowired @Autowired
private ISampleDistributionService sampleDistributionService; private ISampleDistributionService sampleDistributionService;
@Resource
private TeamMapper teamMapper;
@Resource
private SampleMapper sampleMapper;
/** /**
...@@ -111,9 +115,7 @@ public class DataStatisticsServiceImpl implements IDataStatisticsService { ...@@ -111,9 +115,7 @@ public class DataStatisticsServiceImpl implements IDataStatisticsService {
@Override @Override
public BaseResponse<List<DataStatisticsVo>> countTeamByTime(Integer cycle, String startDate, String endDate){ public BaseResponse<List<DataStatisticsVo>> countTeamByTime(Integer cycle, String startDate, String endDate){
Map<String, String> dateMap = new HashMap<>(); Map<String, String> dateMap = new HashMap<>();
/* SimpleDateFormat format = new SimpleDateFormat("yyyy-MM");
SimpleDateFormat format = new SimpleDateFormat("yyyy-MM");
if(startDate != null || endDate != null){ if(startDate != null || endDate != null){
List<String> dateList = commonService.getMonthBetween(startDate, endDate); List<String> dateList = commonService.getMonthBetween(startDate, endDate);
if(dateList != null && dateList.size()>0){ if(dateList != null && dateList.size()>0){
...@@ -133,7 +135,7 @@ public class DataStatisticsServiceImpl implements IDataStatisticsService { ...@@ -133,7 +135,7 @@ public class DataStatisticsServiceImpl implements IDataStatisticsService {
dateMap.put(dateTime,"0"); dateMap.put(dateTime,"0");
calendar.add(Calendar.MONTH, -1); calendar.add(Calendar.MONTH, -1);
} }
} }*/
Map<String, Object> params = new HashMap<>(); Map<String, Object> params = new HashMap<>();
params.put("cycle", cycle); params.put("cycle", cycle);
...@@ -156,22 +158,6 @@ public class DataStatisticsServiceImpl implements IDataStatisticsService { ...@@ -156,22 +158,6 @@ public class DataStatisticsServiceImpl implements IDataStatisticsService {
return BaseResponse.okData(listResult); return BaseResponse.okData(listResult);
} }
/**
* 检测项统计-列表
* @param cycle
* @param startDate
* @param endDate
* @return
*/
/*public BaseResponse<List<Object>> countTeamByTime(Integer cycle, String startDate, String endDate){
}*/
...@@ -193,7 +179,7 @@ public class DataStatisticsServiceImpl implements IDataStatisticsService { ...@@ -193,7 +179,7 @@ public class DataStatisticsServiceImpl implements IDataStatisticsService {
} }
/** /**
* 项目进展统计 * 委托单进展统计
* @return * @return
*/ */
@Override @Override
...@@ -220,18 +206,83 @@ public class DataStatisticsServiceImpl implements IDataStatisticsService { ...@@ -220,18 +206,83 @@ public class DataStatisticsServiceImpl implements IDataStatisticsService {
return BaseResponse.okData(map); return BaseResponse.okData(map);
} }
/** /**
* 项目进展统计-列表 * 委托单进展统计-列表
* @param pageQuery * @param pageQuery
* @return * @return
*/ */
@Override @Override
public BaseResponse<IPage<EntrustVo>> countEntrustPage(PageQuery pageQuery){ public BaseResponse<IPage<EntrustVo>> countEntrustPage(PageQuery pageQuery, Integer cycle, String startDate, String endDate,String clientName){
Map<String, Object> params = new HashMap<>();
params.put("cycle", cycle);
params.put("startDate", startDate);
params.put("endDate", endDate);
params.put("clientName", clientName);
Page<EntrustVo> page = new Page<>(pageQuery.getPageNo(), pageQuery.getPageSize()); Page<EntrustVo> page = new Page<>(pageQuery.getPageNo(), pageQuery.getPageSize());
IPage<EntrustVo> pages = dataStatisticsMapper.countEntrustPage(page); IPage<EntrustVo> pages = dataStatisticsMapper.countEntrustPage(page);
List<EntrustVo> list = pages.getRecords();
if (list != null && list.size() > 0) {
for (EntrustVo entrustVo : list) {
//只统计主样的信息
List<Sample> sampleList = sampleMapper.getSampleList(entrustVo.getId());
//检测项目名称
List<Integer> teamIdList = new ArrayList<>();
Map<String, Integer> teamMap = new HashMap<>();
//所有样品主样的产值
BigDecimal outputValue = new BigDecimal("0.00");
if (sampleList != null && sampleList.size() > 0) {
//样品名称 列表中的拼接
for (Sample sample : sampleList) {
if(sample.getOutputValue() != null){
outputValue = outputValue.compareTo(BigDecimal.ZERO) == 0 ?
sample.getOutputValue() : (outputValue.add(sample.getOutputValue()));
}
String teamIds = sample.getTeamIds();
String checkTeam = "";
if (teamIds != null) {
String[] teamIdS = teamIds.split("、");
for (String teamId : teamIdS) {
Team team = teamMapper.selectById(Integer.valueOf(teamId));
if (team != null) {
if(!teamIdList.contains(team.getId())){
teamMap.put(team.getName(), 1);
teamIdList.add(team.getId());
}else{
teamMap.put(team.getName(), teamMap.get(team.getName())+1);
}
checkTeam = checkTeam.equals("") ? team.getName() : (checkTeam + "、" + team.getName());
}
}
}
}
}
JSONArray checkElementArray = mapToJSONArray(teamMap);
String teamString = JSON.toJSON(checkElementArray).toString();
entrustVo.setCheckTeam(teamString);
entrustVo.setOutputValue(outputValue);
}
}
return BaseResponse.okData(pages); return BaseResponse.okData(pages);
} }
//Map转json数组
public JSONArray mapToJSONArray( Map<String, Integer> map){
JSONArray jsonArray = new JSONArray();
for(Map.Entry<String,Integer> entry : map.entrySet()){
JSONObject jsonObject = new JSONObject();
jsonObject.put("name",entry.getKey());
jsonObject.put("value",entry.getValue());
jsonArray.add(jsonObject);
}
return jsonArray;
}
/** /**
...@@ -241,21 +292,108 @@ public class DataStatisticsServiceImpl implements IDataStatisticsService { ...@@ -241,21 +292,108 @@ public class DataStatisticsServiceImpl implements IDataStatisticsService {
@Override @Override
public BaseResponse<Map<String, Object>> countTaskIng(PageQuery pageQuery){ public BaseResponse<Map<String, Object>> countTaskIng(PageQuery pageQuery){
Map<String, Object> map = new HashMap<>(); Map<String, Object> map = new HashMap<>();
//样品处理任务数量
QueryWrapper<SampleHandle> handleQw = new QueryWrapper<>(); QueryWrapper<SampleHandle> handleQw = new QueryWrapper<>();
handleQw.eq("status",0).or().eq("status",1); handleQw.eq("status",0).or().eq("status",1);
Integer handle_counts = sampleHandleService.count(handleQw); Integer handle_counts = sampleHandleService.count(handleQw);
map.put("handleCounts", handle_counts); map.put("handleCounts", handle_counts);
//样品检测任务数量
QueryWrapper<SampleDistribution> distributionQw = new QueryWrapper<>(); QueryWrapper<SampleDistribution> distributionQw = new QueryWrapper<>();
distributionQw.eq("status",0).or().eq("status",1); distributionQw.eq("status",0).or().eq("status",1);
Integer distribution_counts = sampleDistributionService.count(distributionQw); Integer distribution_counts = sampleDistributionService.count(distributionQw);
map.put("distributionCounts", distribution_counts); map.put("distributionCounts", distribution_counts);
Page<EntrustVo> page = new Page<>(pageQuery.getPageNo(), pageQuery.getPageSize());
IPage<DataStatisticsVo> pagesHandle = dataStatisticsMapper.countHandlePage(page); //样品处理按人分组统计任务数量
Page<EntrustVo> pageHan = new Page<>(pageQuery.getPageNo(), pageQuery.getPageSize());
IPage<DataStatisticsVo> pagesHandle = dataStatisticsMapper.countHandlePage(pageHan);
List<DataStatisticsVo> listHandle = pagesHandle.getRecords();
List<DataStatisticsVo> handleList = new ArrayList<>();
if (listHandle != null && listHandle.size() > 0) {
for (DataStatisticsVo dataStatisticsVo : listHandle) {
//weekType 1上周数据 2本周数据
Integer upWeekNums = dataStatisticsMapper.countHandleWeek(dataStatisticsVo.getId(), 1);
upWeekNums = upWeekNums==null ? 0 : upWeekNums;
Integer thisweekNums = dataStatisticsMapper.countHandleWeek(dataStatisticsVo.getId(), 2);
thisweekNums = thisweekNums==null ? 0 : thisweekNums;
// 创建一个数值格式化对象 ↑↓
NumberFormat numberFormat = NumberFormat.getInstance();
// 设置精确到小数点后2位
numberFormat.setMaximumFractionDigits(2);
String resultNum = "";
if(thisweekNums > upWeekNums){
if(upWeekNums ==0){
resultNum = "100%↑";
}else{
Integer errorNums = thisweekNums - upWeekNums;
resultNum = numberFormat.format((float)errorNums/(float)thisweekNums*100) + "%↑";
}
}else if(upWeekNums > thisweekNums){
if(thisweekNums ==0){
resultNum = "100%↓";
}else{
Integer errorNums = upWeekNums - thisweekNums ;
resultNum = numberFormat.format((float)errorNums/(float)upWeekNums*100) + "%↓";
}
}else if(thisweekNums == thisweekNums){
resultNum = "0%";
}
dataStatisticsVo.setWeekUp(resultNum);
handleList.add(dataStatisticsVo);
}
}
pagesHandle.setRecords(handleList);
map.put("pagesHandle", pagesHandle); map.put("pagesHandle", pagesHandle);
IPage<DataStatisticsVo> pagesDistribution = dataStatisticsMapper.countDistributionPage(page);
//样品检测按人分组统计任务数量
Page<EntrustVo> pageDis = new Page<>(pageQuery.getPageNo(), pageQuery.getPageSize());
IPage<DataStatisticsVo> pagesDistribution = dataStatisticsMapper.countDistributionPage(pageDis);
List<DataStatisticsVo> listDistribution = pagesDistribution.getRecords();
List<DataStatisticsVo> distributionList = new ArrayList<>();
if (listDistribution != null && listDistribution.size() > 0) {
for (DataStatisticsVo dataStatisticsVo : listDistribution) {
//weekType 1上周数据 2本周数据
Integer upWeekNums = dataStatisticsMapper.countDistributionWeek(dataStatisticsVo.getId(), 1);
upWeekNums = upWeekNums==null ? 0 : upWeekNums;
Integer thisweekNums = dataStatisticsMapper.countDistributionWeek(dataStatisticsVo.getId(), 2);
thisweekNums = thisweekNums==null ? 0 : thisweekNums;
// 创建一个数值格式化对象 ↑↓
NumberFormat numberFormat = NumberFormat.getInstance();
// 设置精确到小数点后2位
numberFormat.setMaximumFractionDigits(2);
String resultNum = "";
if(thisweekNums > upWeekNums){
if(upWeekNums ==0){
resultNum = "100%↑";
}else{
Integer errorNums = thisweekNums - upWeekNums;
resultNum = numberFormat.format((float)errorNums/(float)thisweekNums*100) + "%↑";
}
}else if(upWeekNums > thisweekNums){
if(thisweekNums ==0){
resultNum = "100%↓";
}else{
Integer errorNums = upWeekNums - thisweekNums ;
resultNum = numberFormat.format((float)errorNums/(float)upWeekNums*100) + "%↓";
}
}else if(thisweekNums == thisweekNums){
resultNum = "0%";
}
dataStatisticsVo.setWeekUp(resultNum);
distributionList.add(dataStatisticsVo);
}
}
pagesDistribution.setRecords(distributionList);
map.put("pagesDistribution", pagesDistribution); map.put("pagesDistribution", pagesDistribution);
return BaseResponse.okData(map); return BaseResponse.okData(map);
......
...@@ -298,18 +298,18 @@ public class EntrustServiceImpl extends ServiceImpl<EntrustMapper, Entrust> impl ...@@ -298,18 +298,18 @@ public class EntrustServiceImpl extends ServiceImpl<EntrustMapper, Entrust> impl
BeanUtils.copyProperties(sampleTmpQuery, sampleTmp); BeanUtils.copyProperties(sampleTmpQuery, sampleTmp);
String teamIds = sampleTmpQuery.getTeamIds(); //选择的检测项id集合 String teamIds = sampleTmpQuery.getTeamIds(); //选择的检测项id集合
BigDecimal charge = new BigDecimal("0.00"); BigDecimal charge = new BigDecimal("0.00");
if (teamIds != null) { if (teamIds != null) {
String[] teamIdS = teamIds.split("、"); String[] teamIdS = teamIds.split("、");
List<String> teamNameList = new ArrayList<>(); List<String> teamNameList = new ArrayList<>();
for (String teamId : teamIdS) { for (String teamId : teamIdS) {
Team team = teamMapper.selectById(Integer.valueOf(teamId)); Team team = teamMapper.selectById(Integer.valueOf(teamId));
if (team != null) { if (team != null) {
if(!teamNameList.contains(teamId)){ if(!teamNameList.contains(teamId)){
charge = charge.compareTo(BigDecimal.ZERO) == 0 ? team.getCharge() : (charge.add(team.getCharge())); charge = charge.compareTo(BigDecimal.ZERO) == 0 ? team.getCharge() : (charge.add(team.getCharge()));
teamNameList.add(team.getName()); teamNameList.add(team.getName());
}
} }
} }
}
//选择Mg必须选择Ca;选择Al必须选择Fe //选择Mg必须选择Ca;选择Al必须选择Fe
if(teamNameList.contains("MgO")){ if(teamNameList.contains("MgO")){
if(!teamNameList.contains("CaO")){ if(!teamNameList.contains("CaO")){
...@@ -558,6 +558,7 @@ public class EntrustServiceImpl extends ServiceImpl<EntrustMapper, Entrust> impl ...@@ -558,6 +558,7 @@ public class EntrustServiceImpl extends ServiceImpl<EntrustMapper, Entrust> impl
System.out.println(content); System.out.println(content);
weiXinService.sendTextMessage(userIds, content); weiXinService.sendTextMessage(userIds, content);
}else if(approvalIdList.contains(loginUser.getId())){ }else if(approvalIdList.contains(loginUser.getId())){
//如果是评审人员修改
SysUser createUser = userService.getById(entrust.getUserId()); SysUser createUser = userService.getById(entrust.getUserId());
if(createUser == null){ if(createUser == null){
return BaseResponse.errorMsg("委托人信息错误"); return BaseResponse.errorMsg("委托人信息错误");
...@@ -1060,7 +1061,8 @@ public class EntrustServiceImpl extends ServiceImpl<EntrustMapper, Entrust> impl ...@@ -1060,7 +1061,8 @@ public class EntrustServiceImpl extends ServiceImpl<EntrustMapper, Entrust> impl
if (entrust == null) { if (entrust == null) {
return BaseResponse.errorMsg("信息错误"); return BaseResponse.errorMsg("信息错误");
} }
List<Sample> sampleList = sampleMapper.getSampleCheckList(id); //只看主样 对应的最终结果值
List<Sample> sampleList = sampleMapper.getCheckSampleList(id);
List<SampleVo> sampleVoList = new ArrayList<>(); List<SampleVo> sampleVoList = new ArrayList<>();
if (sampleList != null && sampleList.size() > 0) { if (sampleList != null && sampleList.size() > 0) {
...@@ -1069,12 +1071,21 @@ public class EntrustServiceImpl extends ServiceImpl<EntrustMapper, Entrust> impl ...@@ -1069,12 +1071,21 @@ public class EntrustServiceImpl extends ServiceImpl<EntrustMapper, Entrust> impl
BeanUtils.copyProperties(sample, sampleVo); BeanUtils.copyProperties(sample, sampleVo);
List<SampleDistributionTeamVo> sampleDistributionTeamVoList = List<SampleDistributionTeamVo> sampleDistributionTeamVoList =
distributionMapper.getDistributionTeamList(sample.getId(), null); distributionMapper.getDistributionTeamList(sample.getId(), null);
if (sampleDistributionTeamVoList != null && sampleDistributionTeamVoList.size() > 0) { if (sampleDistributionTeamVoList != null && sampleDistributionTeamVoList.size() > 0) {
//已经派发过的列表 //已经派发过的列表
List<SampleTeamGroupVo> sampleTeamGroupVoListed = new ArrayList<>(); List<SampleTeamGroupVo> sampleTeamGroupVoListed = new ArrayList<>();
List<Integer> teamGroupIdList = new ArrayList<>(); List<Integer> teamGroupIdList = new ArrayList<>();
for(SampleDistributionTeamVo sampleDistributionTeamVo : sampleDistributionTeamVoList){ for(SampleDistributionTeamVo sampleDistributionTeamVo : sampleDistributionTeamVoList){
SampleDistribution sampleDistribution = distributionMapper.selectById(sampleDistributionTeamVo.getDistributionId()); 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()); TeamGroup teamGroup = teamGroupMapper.selectById(sampleDistribution.getTeamGroupId());
if(!teamGroupIdList.contains(sampleDistribution.getTeamGroupId())){ if(!teamGroupIdList.contains(sampleDistribution.getTeamGroupId())){
teamGroupIdList.add(sampleDistribution.getTeamGroupId()); teamGroupIdList.add(sampleDistribution.getTeamGroupId());
...@@ -1514,6 +1525,7 @@ public class EntrustServiceImpl extends ServiceImpl<EntrustMapper, Entrust> impl ...@@ -1514,6 +1525,7 @@ public class EntrustServiceImpl extends ServiceImpl<EntrustMapper, Entrust> impl
.setIsHandle(0)//样品处理未完成状态 .setIsHandle(0)//样品处理未完成状态
.setIsDistribution(0)//任务派发未完成状态 .setIsDistribution(0)//任务派发未完成状态
.setIsCheck(0)//样品校核未完成状态 .setIsCheck(0)//样品校核未完成状态
.setOutputValue(sample.getCharge()) //产值不用评审人员修改
.setParallelCode(maxCementCode); .setParallelCode(maxCementCode);
sampleList.add(sample); sampleList.add(sample);
} }
...@@ -2069,7 +2081,7 @@ public class EntrustServiceImpl extends ServiceImpl<EntrustMapper, Entrust> impl ...@@ -2069,7 +2081,7 @@ public class EntrustServiceImpl extends ServiceImpl<EntrustMapper, Entrust> impl
List<Integer> userIdList = new ArrayList<>(); List<Integer> userIdList = new ArrayList<>();
if (query.getSampleDistributionQueryList() != null && query.getSampleDistributionQueryList().size() > 0) { if (query.getSampleDistributionQueryList() != null && query.getSampleDistributionQueryList().size() > 0) {
List<SampleDistributionQuery> sampleDistributionQueryList = query.getSampleDistributionQueryList(); 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 ...@@ -2104,7 +2116,8 @@ public class EntrustServiceImpl extends ServiceImpl<EntrustMapper, Entrust> impl
.setStatus(2) //直接进入待校核状态 .setStatus(2) //直接进入待校核状态
.setAcceptTime(sampleHandle.getAcceptTime()) .setAcceptTime(sampleHandle.getAcceptTime())
.setFinishTime(sampleHandle.getFinishTime()); .setFinishTime(sampleHandle.getFinishTime());
sampleDistributionList.add(sampleDistribution); distributionService.save(sampleDistribution);
// sampleDistributionList.add(sampleDistribution);
//将样品处理的附件复制到样品检测的附件表中 如果校核附件有重复,可以去掉这个逻辑 //将样品处理的附件复制到样品检测的附件表中 如果校核附件有重复,可以去掉这个逻辑
Map<String, Object> params = new HashMap<>(); Map<String, Object> params = new HashMap<>();
...@@ -2167,7 +2180,8 @@ public class EntrustServiceImpl extends ServiceImpl<EntrustMapper, Entrust> impl ...@@ -2167,7 +2180,8 @@ public class EntrustServiceImpl extends ServiceImpl<EntrustMapper, Entrust> impl
.setCreateTime(LocalDateTime.now()) .setCreateTime(LocalDateTime.now())
.setStatus(1) //直接接收检测任务 .setStatus(1) //直接接收检测任务
.setAcceptTime(LocalDateTime.now()); .setAcceptTime(LocalDateTime.now());
sampleDistributionList.add(sampleDistribution); distributionService.save(sampleDistribution);
// sampleDistributionList.add(sampleDistribution);
//获取产值信息 //获取产值信息
QueryWrapper<NormProduction> queryWrapper = new QueryWrapper<>(); QueryWrapper<NormProduction> queryWrapper = new QueryWrapper<>();
...@@ -2201,7 +2215,9 @@ public class EntrustServiceImpl extends ServiceImpl<EntrustMapper, Entrust> impl ...@@ -2201,7 +2215,9 @@ public class EntrustServiceImpl extends ServiceImpl<EntrustMapper, Entrust> impl
sample.setStatus(1); //样品状态改成已领用状态 sample.setStatus(1); //样品状态改成已领用状态
sampleList.add(sample); sampleList.add(sample);
} }
distributionService.saveBatch(sampleDistributionList); // distributionService.saveBatch(sampleDistributionList);
sampleService.updateBatchById(sampleList); sampleService.updateBatchById(sampleList);
} }
entrust.setStatus(5).setIsDistribution(1); entrust.setStatus(5).setIsDistribution(1);
......
...@@ -3,7 +3,7 @@ ...@@ -3,7 +3,7 @@
<mapper namespace="cn.wise.sc.cement.business.mapper.DataStatisticsMapper"> <mapper namespace="cn.wise.sc.cement.business.mapper.DataStatisticsMapper">
<select id="countTeamByTime" resultType="cn.wise.sc.cement.business.model.vo.DataStatisticsVo"> <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 FROM sample_distribution sd
where sd.finish_time is not null where sd.finish_time is not null
<if test="params.cycle == 1 "> <if test="params.cycle == 1 ">
...@@ -21,9 +21,14 @@ ...@@ -21,9 +21,14 @@
<if test="params.endDate != null and params.endDate != ''"> <if test="params.endDate != null and params.endDate != ''">
and DATE(sd.create_time) &lt;= #{params.endDate} and DATE(sd.create_time) &lt;= #{params.endDate}
</if> </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 group by name
</select> </select>
<select id="countTeamByOrigin" resultType="cn.wise.sc.cement.business.model.vo.DataStatisticsVo"> <select id="countTeamByOrigin" resultType="cn.wise.sc.cement.business.model.vo.DataStatisticsVo">
SELECT s.origin as name, count(sd.id) as value SELECT s.origin as name, count(sd.id) as value
FROM sample_distribution sd FROM sample_distribution sd
...@@ -60,6 +65,7 @@ ...@@ -60,6 +65,7 @@
WHEN 6 THEN '样品检测完成' WHEN 6 THEN '样品检测完成'
WHEN 7 THEN '校核中' WHEN 7 THEN '校核中'
WHEN 8 THEN '校核完成' WHEN 8 THEN '校核完成'
WHEN 9 THEN '修改待确认'
ELSE '' ELSE ''
END END
) as name, ) as name,
...@@ -107,7 +113,7 @@ ...@@ -107,7 +113,7 @@
</select> </select>
<select id="countEntrustPage" resultType="cn.wise.sc.cement.business.model.vo.EntrustVo"> <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 CASE e.status
WHEN 0 THEN '未评审' WHEN 0 THEN '未评审'
...@@ -127,32 +133,54 @@ ...@@ -127,32 +133,54 @@
left join client c on c.id = e.client_id left join client c on c.id = e.client_id
left join sys_user su on su.id = e.user_id left join sys_user su on su.id = e.user_id
where e.status != 0 and e.project_type is not null 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 order by create_time desc
</select> </select>
<select id="countHandlePage" resultType="cn.wise.sc.cement.business.model.vo.DataStatisticsVo"> <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 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 group by sh.user_id
</select> </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 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.name as name, count(*) as value FROM sample_distribution sd
left join sys_user su on su.id = sd.user_id 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 group by sd.user_id
</select> </select>
<select id="countTeamIng" resultType="cn.wise.sc.cement.business.model.vo.DataStatisticsVo"> <select id="countTeamIng" resultType="cn.wise.sc.cement.business.model.vo.DataStatisticsVo">
SELECT t.name as name, count(*) as value FROM sample_distribution sd SELECT t.name as name, count(*) as value FROM sample_distribution sd
left join team t on t.id = sd.team_id 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 group by sd.team_id
</select> </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