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

统计的导出功能

parent 0e362a24
......@@ -74,12 +74,14 @@ public class DataStatisticsController {
@ApiImplicitParams(value = {
@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 = "clientId", value = "委托单位Id", paramType = "query", dataType = "Integer"),
@ApiImplicitParam(name = "clientName", value = "委托单位名称", paramType = "query", dataType = "String")
})
@GetMapping("/countEntrustStatus")
public BaseResponse countEntrustStatus(Integer cycle, String startDate, String endDate) {
public BaseResponse countEntrustStatus(Integer cycle, String startDate, String endDate, Integer clientId, String clientName) {
try {
return dataStatisticsService.countEntrustStatus(cycle, startDate, endDate);
return dataStatisticsService.countEntrustStatus(cycle, startDate, endDate, clientId, clientName);
} catch (Exception e) {
log.debug("统计概览-委托单进展统计{}", e);
}
......@@ -92,19 +94,30 @@ public class DataStatisticsController {
@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 = "clientId", value = "委托单位Id", paramType = "query", dataType = "Integer"),
@ApiImplicitParam(name = "clientName", value = "委托单位名称", paramType = "query", dataType = "String")
})
@GetMapping("/countEntrustPage")
public BaseResponse countEntrustPage(PageQuery pageQuery, Integer cycle, String startDate, String endDate, String clientName) {
public BaseResponse countEntrustPage(PageQuery pageQuery, Integer cycle, String startDate, String endDate, Integer clientId, String clientName) {
try {
return dataStatisticsService.countEntrustPage(pageQuery, cycle, startDate, endDate, clientName);
return dataStatisticsService.countEntrustPage(pageQuery, cycle, startDate, endDate, clientId, clientName);
} catch (Exception e) {
log.debug("委托单进展统计-列表{}", e);
}
return BaseResponse.errorMsg("失败!");
}
//todo 委托单进展统计-列表导出
@ApiOperation("列表导出-委托单进展统计")
@PostMapping("/exportEntrustList")
public void exportEntrustList(Integer cycle, String startDate,
String endDate, Integer clientId, String clientName, String fileName, HttpServletResponse response) {
try {
dataStatisticsService.exportEntrustList(cycle, startDate, endDate, clientId, clientName, fileName, response);
} catch (Exception e) {
log.debug("列表导出-委托单进展统计{}", e);
}
}
@ApiOperation(value = "统计概览-进行中任务数量统计")
@GetMapping("/countTaskIng")
......@@ -153,8 +166,16 @@ public class DataStatisticsController {
return BaseResponse.errorMsg("失败!");
}
//todo 检测项"检测项统计-列表导出
@ApiOperation("列表导出-检测项统计")
@PostMapping("/exportTeamList")
public void exportTeamList(Integer cycle, String startDate, String endDate, String fileName, HttpServletResponse response) {
try {
dataStatisticsService.exportTeamList(cycle, startDate, endDate, fileName, response);
} catch (Exception e) {
log.debug("检测项统计-列表导出{}", e);
}
}
@ApiOperation(value = "各委托单位项目数量统计")
......
......@@ -601,6 +601,18 @@ public class EntrustController {
return BaseResponse.errorMsg("失败!");
}
@ApiOperation(value = "检测结果查看附件(只显示公开的附件)")
@GetMapping("/getClientEnclosureList")
public BaseResponse getClientEnclosureList(Integer sampleDistributionId) {
try {
return entrustService.getClientEnclosureList(sampleDistributionId);
} catch (Exception e) {
log.debug("检测结果查看附件(只显示公开的附件){}", e);
}
return BaseResponse.errorMsg("失败!");
}
@ApiOperation(value = "样品检测/校核上传附件")
@PostMapping("/uploadEnclosurePF")
public BaseResponse uploadEnclosurePF(SampleHandleEnclosureQuery query) {
......
......@@ -34,6 +34,7 @@ public class SampleDistributionEnclosure implements Serializable {
*/
private Integer sampleDistributionId;
/**
* 处理项表id
*/
......
......@@ -30,12 +30,16 @@ public interface DataStatisticsMapper {
List<DataStatisticsVo> countTeamByOrigin(@Param("params") Map<String, Object> params);
Integer countEntrustSumNum(@Param("params") Map<String, Object> params);
List<DataStatisticsVo> countEntrustStatus(@Param("params") Map<String, Object> params);
List<DataStatisticsVo> countEntrustType(@Param("params") Map<String, Object> params);
IPage<EntrustVo> countEntrustPage(@Param("page") Page page, @Param("params") Map<String, Object> params);
List<Map<String, Object>> exportEntrustList(@Param("params") Map<String, Object> params);
IPage<DataStatisticsVo> countHandlePage(@Param("page") Page page);
Integer countHandleWeek(@Param("userId") Integer userId, @Param("weekType") Integer weekType);
......@@ -50,9 +54,7 @@ public interface DataStatisticsMapper {
IPage<DataStatisticsTeamVo> countTeamPage(@Param("page") Page page, @Param("params") Map<String, Object> params);
List<Map<String, Object>> exportTeamList(@Param("params") Map<String, Object> params);
Integer countEntrustNum(@Param("teamId") Integer teamId);
......
......@@ -50,4 +50,6 @@ public interface EntrustMapper extends BaseMapper<Entrust> {
IPage<SampleReturnHandleVo> getSampleReturnDistributioPage(@Param("page") Page page, @Param("params") Map<String, Object> params);
IPage<EntrustVo> getSampleReturnCheckPage(@Param("page") Page page, @Param("params") Map<String, Object> params);
}
......@@ -21,10 +21,9 @@
<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">
<if test="params.startDate == null and params.endDate == null">
and date(sd.create_time) > date_sub(curdate(),interval 30 day)
</if>
group by name
</select>
......@@ -52,6 +51,26 @@
group by s.origin
</select>
<select id="countEntrustSumNum" resultType="integer">
SELECT count(*)
FROM entrust e
left join client c on c.id = e.client_id
where e.status != 0 and e.project_type is not null
<if test="params.startDate != null and params.startDate != ''">
and DATE(e.create_time) &gt;= #{params.startDate}
</if>
<if test="params.endDate != null and params.endDate != ''">
and DATE(e.create_time) &lt;= #{params.endDate}
</if>
<if test="params.clientId != null">
and e.clientId = #{clientId}
</if>
<if test="params.clientName != null and params.clientName != ''">
and c.name like concat('%', #{params.clientName}, '%')
</if>
</select>
<select id="countEntrustStatus" resultType="cn.wise.sc.cement.business.model.vo.DataStatisticsVo">
SELECT (
......@@ -71,6 +90,7 @@
) as name,
count(*) as value
FROM entrust e
left join client c on c.id = e.client_id
where e.status != 0 and e.project_type is not null
<if test="params.cycle == 1 ">
and YEARWEEK(date_format(e.create_time,'%Y-%m-%d' ) ) = YEARWEEK(now())
......@@ -86,6 +106,12 @@
</if>
<if test="params.endDate != null and params.endDate != ''">
and DATE(e.create_time) &lt;= #{params.endDate}
</if>
<if test="params.clientId != null">
and e.clientId = #{clientId}
</if>
<if test="params.clientName != null and params.clientName != ''">
and c.name like concat('%', #{params.clientName}, '%')
</if>
group by e.status
</select>
......@@ -93,6 +119,7 @@
<select id="countEntrustType" resultType="cn.wise.sc.cement.business.model.vo.DataStatisticsVo">
select e.project_type as name, count(*) as value
from entrust e
left join client c on c.id = e.client_id
where e.status != 0 and e.project_type is not null
<if test="params.cycle == 1 ">
and YEARWEEK(date_format(e.create_time,'%Y-%m-%d' ) ) = YEARWEEK(now())
......@@ -109,6 +136,12 @@
<if test="params.endDate != null and params.endDate != ''">
and DATE(e.create_time) &lt;= #{params.endDate}
</if>
<if test="params.clientId != null">
and e.clientId = #{clientId}
</if>
<if test="params.clientName != null and params.clientName != ''">
and c.name like concat('%', #{params.clientName}, '%')
</if>
group by e.project_type
</select>
......@@ -125,6 +158,7 @@
WHEN 6 THEN '样品检测完成'
WHEN 7 THEN '校核中'
WHEN 8 THEN '校核完成'
WHEN 9 THEN '修改待确认'
ELSE ''
END
) as statusValue
......@@ -133,6 +167,9 @@
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.clientId != null">
and e.clientId = #{clientId}
</if>
<if test="params.clientName != null and params.clientName != ''">
and c.name like concat('%', #{params.clientName}, '%')
</if>
......@@ -145,6 +182,54 @@
order by create_time desc
</select>
<select id="exportEntrustList" resultType="java.util.HashMap">
SELECT
(@i:=@i+1) as 序号,
e.id as entrustId,
IF(ISNULL(e.entrust_code),'',e.entrust_code) as 委托单号,
IF(ISNULL(p.name),'',p.name) as 项目名称,
IF(ISNULL(p.name),'',p.name) as 项目编号,
e.project_type as 项目类型,
IF(ISNULL(su.name),'',su.name) as 委托人,
IF(ISNULL(c.name),'',c.name) as 委托单位,
IF(ISNULL(e.entrust_date),'',e.entrust_date) as 委托日期,
IF(ISNULL(e.sample_num),'',e.sample_num) as 样品数量,
(
CASE e.status
WHEN 0 THEN '未评审'
WHEN 1 THEN '已通过'
WHEN 2 THEN '未通过'
WHEN 3 THEN '样品处理中'
WHEN 4 THEN '样品处理完成'
WHEN 5 THEN '样品检测中'
WHEN 6 THEN '样品检测完成'
WHEN 7 THEN '校核中'
WHEN 8 THEN '校核完成'
WHEN 9 THEN '修改待确认'
ELSE ''
END
) as 状态
from entrust e
left join project p on p.id = e.project_id
left join client c on c.id = e.client_id
left join sys_user su on su.id = e.user_id
,(select @i:=0)aa
where e.status != 0 and e.project_type is not null
<if test="params.clientId != null">
and e.clientId = #{clientId}
</if>
<if test="params.clientName != null and params.clientName != ''">
and c.name like concat('%', #{params.clientName}, '%')
</if>
<if test="params.startDate != null and params.startDate != ''">
and DATE(e.create_time) &gt;= #{params.startDate}
</if>
<if test="params.endDate != null and params.endDate != ''">
and DATE(e.create_time) &lt;= #{params.endDate}
</if>
order by 序号
</select>
<select id="countHandlePage" resultType="cn.wise.sc.cement.business.model.vo.DataStatisticsVo">
SELECT su.id as id, su.name as name, count(*) as value FROM sample_handle sh
......@@ -249,6 +334,31 @@
group by sd.team_id
</select>
<select id="exportTeamList" resultType="java.util.HashMap">
SELECT (@i:=@i+1) as 序号,t.id as id, t.name as 检测项目, count(*) as 检测项数量
FROM sample_distribution sd
left join team t on t.id = sd.team_id
,(select @i:=0)t
where 1=1
<if test="params.cycle == 1 ">
and YEARWEEK(date_format(sd.create_time,'%Y-%m-%d' ) ) = YEARWEEK(now())
</if>
<if test="params.cycle == 2 ">
and DATE_FORMAT( sd.create_time, '%Y%m' ) = DATE_FORMAT( CURDATE( ) ,'%Y%m')
</if>
<if test="params.cycle == 3 ">
and YEAR(sd.create_time) = YEAR( NOW( ) )
</if>
<if test="params.startDate != null and params.startDate != ''">
and DATE(sd.create_time) &gt;= #{params.startDate}
</if>
<if test="params.endDate != null and params.endDate != ''">
and DATE(sd.create_time) &lt;= #{params.endDate}
</if>
group by sd.team_id
order by 序号
</select>
<select id="countEntrustNum" resultType="integer">
select count(*) as entrustNum from (
SELECT sd.entrust_id as id, count(*) as entrustNum FROM sample_distribution sd
......
......@@ -72,7 +72,7 @@
SELECT
(@i:=@i+1) as 序号,
e.id as entrustId,
IF(ISNULL(e.entrust_code),'',e.entrust_code) as 委托号,
IF(ISNULL(e.entrust_code),'',e.entrust_code) as 委托号,
(
CASE e.is_urgent
WHEN 0 THEN '不加急'
......
......@@ -19,9 +19,13 @@
<if test="params.userId != null">
and t.user_id = #{params.userId}
</if>
<if test="params.isPublic != null">
and t.is_public = #{params.isPublic}
</if>
order by t.id ASC
</select>
</mapper>
......@@ -32,9 +32,12 @@ public interface IDataStatisticsService {
BaseResponse<List<DataStatisticsVo>> countTeamByOrigin(Integer cycle, String startDate, String endDate);
BaseResponse<Map<String, Object>> countEntrustStatus(Integer cycle, String startDate, String endDate);
BaseResponse<Map<String, Object>> countEntrustStatus(Integer cycle, String startDate, String endDate, Integer clientId, String clientName);
BaseResponse<IPage<EntrustVo>> countEntrustPage(PageQuery pageQuery, Integer cycle, String startDate, String endDate, String clientName);
BaseResponse<IPage<EntrustVo>> countEntrustPage(PageQuery pageQuery, Integer cycle, String startDate, String endDate, Integer clientId, String clientName);
void exportEntrustList(Integer cycle, String startDate,
String endDate, Integer clientId, String clientName, String fileName, HttpServletResponse response);
BaseResponse<Map<String, Object>> countTaskIng(PageQuery pageQuery);
......@@ -44,6 +47,8 @@ public interface IDataStatisticsService {
BaseResponse<IPage<DataStatisticsTeamVo>> countTeamList(PageQuery pageQuery, Integer cycle, String startDate, String endDate);
void exportTeamList(Integer cycle, String startDate, String endDate, String fileName, HttpServletResponse response);
BaseResponse<List<DataStatisticsVo>> countByClient();
/**
......
......@@ -110,6 +110,8 @@ public interface IEntrustService extends IService<Entrust> {
BaseResponse<List<SampleDistributionEnclosureVo>> getSampleDistributionEnclosureList(Integer sampleDistributionId);
BaseResponse<List<SampleDistributionEnclosureVo>> getClientEnclosureList(Integer sampleDistributionId);
BaseResponse<SampleDistributionEnclosure> uploadEnclosurePF(SampleHandleEnclosureQuery query);
BaseResponse<String> deleteEnclosure(Integer id,Integer type);
......
......@@ -114,48 +114,13 @@ public class DataStatisticsServiceImpl implements IDataStatisticsService {
*/
@Override
public BaseResponse<List<DataStatisticsVo>> countTeamByTime(Integer cycle, String startDate, String endDate){
Map<String, String> dateMap = new HashMap<>();
/* SimpleDateFormat format = new SimpleDateFormat("yyyy-MM");
if(startDate != null || endDate != null){
List<String> dateList = commonService.getMonthBetween(startDate, endDate);
if(dateList != null && dateList.size()>0){
for(int i=0; i<dateList.size(); i++ ){
dateMap.put(dateList.get(i),"0");
}
}
}else{
Date date = new Date();//获取当前时间
Calendar calendar = Calendar.getInstance();
calendar.setTime(date);
for(int i=0; i<12; i++){
date = calendar.getTime();
String dateTime = format.format(date);
dateMap.put(dateTime,"0");
calendar.add(Calendar.MONTH, -1);
}
}*/
Map<String, Object> params = new HashMap<>();
params.put("cycle", cycle);
params.put("startDate", startDate);
params.put("endDate", endDate);
List<DataStatisticsVo> list = dataStatisticsMapper.countTeamByTime(params);
for(DataStatisticsVo vo:list){
if(dateMap.containsKey(vo.getName())){
dateMap.put(vo.getName(), vo.getValue());
}
}
List<DataStatisticsVo> listResult = new ArrayList<>();
for(String key:dateMap.keySet()){
DataStatisticsVo vo = new DataStatisticsVo();
vo.setName(key);
vo.setValue(dateMap.get(key));
listResult.add(vo);
}
return BaseResponse.okData(listResult);
return BaseResponse.okData(list);
}
......@@ -183,21 +148,16 @@ public class DataStatisticsServiceImpl implements IDataStatisticsService {
* @return
*/
@Override
public BaseResponse<Map<String, Object>> countEntrustStatus(Integer cycle, String startDate, String endDate){
public BaseResponse<Map<String, Object>> countEntrustStatus(Integer cycle, String startDate, String endDate,
Integer clientId, String clientName){
Map<String, Object> params = new HashMap<>();
params.put("cycle", cycle);
params.put("startDate", startDate);
params.put("endDate", endDate);
params.put("clientId", clientId);
params.put("clientName", clientName);
Map<String, Object> map = new HashMap<>();
QueryWrapper<Entrust> entrustQw = new QueryWrapper<>();
if(StringUtils.isNotBlank(startDate)){
entrustQw.ge("create_time",startDate);
}
if(StringUtils.isNotBlank(endDate)){
entrustQw.le("create_time",endDate);
}
Integer sum_counts = entrustService.count(entrustQw);
Integer sum_counts = dataStatisticsMapper.countEntrustSumNum(params);
if(sum_counts == null){
map.put("sumCounts", "0");
map.put("statusList", null);
......@@ -220,11 +180,13 @@ public class DataStatisticsServiceImpl implements IDataStatisticsService {
* @return
*/
@Override
public BaseResponse<IPage<EntrustVo>> countEntrustPage(PageQuery pageQuery, Integer cycle, String startDate, String endDate,String clientName){
public BaseResponse<IPage<EntrustVo>> countEntrustPage(PageQuery pageQuery, Integer cycle, String startDate,
String endDate, Integer clientId, String clientName){
Map<String, Object> params = new HashMap<>();
params.put("cycle", cycle);
params.put("startDate", startDate);
params.put("endDate", endDate);
params.put("clientId", clientId);
params.put("clientName", clientName);
Page<EntrustVo> page = new Page<>(pageQuery.getPageNo(), pageQuery.getPageSize());
IPage<EntrustVo> pages = dataStatisticsMapper.countEntrustPage(page, params);
......@@ -273,8 +235,6 @@ public class DataStatisticsServiceImpl implements IDataStatisticsService {
}
}
return BaseResponse.okData(pages);
}
......@@ -290,6 +250,124 @@ public class DataStatisticsServiceImpl implements IDataStatisticsService {
return jsonArray;
}
/**
* 委托单进展统计-列表导出
* @param cycle
* @param startDate
* @param endDate
* @param clientId
* @param clientName
* @param fileName
* @param response
*/
@Override
public void exportEntrustList(Integer cycle, String startDate,
String endDate, Integer clientId, String clientName, String fileName, HttpServletResponse response){
Map<String, Object> params = new HashMap<>();
params.put("cycle", cycle);
params.put("startDate", startDate);
params.put("endDate", endDate);
params.put("clientId", clientId);
params.put("clientName", clientName);
List<Map<String, Object>> list = dataStatisticsMapper.exportEntrustList(params);
if (!CollectionUtils.isEmpty(list)) {
String[] headers = new String[12];
headers[0] = "序号";
headers[1] = "委托单号";
headers[2] = "项目名称";
headers[3] = "项目编号";
headers[4] = "项目类型";
headers[5] = "委托人";
headers[6] = "委托单位";
headers[7] = "委托日期";
headers[8] = "样品数量";
headers[9] = "检测项目";
headers[10] = "产值";
headers[11] = "状态";
List<Object[]> datas = new ArrayList<>(list.size());
for (Map<String, Object> m : list) {
Object[] objects = new Object[headers.length];
String objj = m.get("entrustId").toString();
Integer entrustId = Integer.valueOf(objj);
//只统计主样的信息
List<Sample> sampleList = sampleMapper.getSampleList(entrustId);
//检测项目名称
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();
for (int j = 0; j < headers.length; j++) {
String obj = "";
if(j == 9){
objects[9] = teamMap;
}else if(j == 10){
objects[10] = outputValue;
}else{
obj = m.get(headers[j]).toString();
if (j == 0) {
obj = obj.split("\\.")[0];
}
objects[j] = obj;
}
}
datas.add(objects);
}
ExcelUtil.excelExport(
fileName == null || fileName.trim().length() <= 0 ? "委托单进展统计-列表导出" : fileName, headers,
datas, response);
}
}
/**
* 进行中任务数量统计
......@@ -454,6 +532,70 @@ public class DataStatisticsServiceImpl implements IDataStatisticsService {
return BaseResponse.okData(pages);
}
/**
* 检测项统计-列表导出
* @param cycle
* @param startDate
* @param endDate
* @param fileName
* @param response
*/
@Override
public void exportTeamList(Integer cycle, String startDate, String endDate, String fileName, HttpServletResponse response){
Map<String, Object> params = new HashMap<>();
params.put("cycle", cycle);
params.put("startDate", startDate);
params.put("endDate", endDate);
List<Map<String, Object>> list = dataStatisticsMapper.exportTeamList(params);
if (!CollectionUtils.isEmpty(list)) {
String[] headers = new String[5];
headers[0] = "序号";
headers[1] = "检测项目";
headers[2] = "检测项数量";
headers[3] = "委托数量";
headers[4] = "样品数量";
List<Object[]> datas = new ArrayList<>(list.size());
for (Map<String, Object> m : list) {
Object[] objects = new Object[headers.length];
for (int j = 0; j < headers.length; j++) {
String obj = "";
if(j == 3){
obj = m.get("id").toString();
Integer teamId = Integer.valueOf(obj);
Integer entrustNum = dataStatisticsMapper.countEntrustNum(teamId);
objects[3] = entrustNum;
}else if(j == 4){
obj = m.get("id").toString();
Integer teamId = Integer.valueOf(obj);
Integer sampleNum = dataStatisticsMapper.countSampleNum(teamId);
objects[4] = sampleNum;
}else{
obj = m.get(headers[j]).toString();
if (j == 0) {
obj = obj.split("\\.")[0];
}
objects[j] = obj;
}
}
datas.add(objects);
}
ExcelUtil.excelExport(
fileName == null || fileName.trim().length() <= 0 ? "检测项统计-列表导出" : fileName, headers,
datas, response);
}
}
/**
* 各委托单位项目数量统计
* @return
......
......@@ -1107,7 +1107,7 @@ public class EntrustServiceImpl extends ServiceImpl<EntrustMapper, Entrust> impl
List<SampleDistributionTeamVo> sdtvList = sampleTeamGroupVo2.getSampleDistributionTeamVoList();
sdtvList.add(sampleDistributionTeamVo);
sampleTeamGroupVo2.setSampleDistributionTeamVoList(sdtvList);
sampleTeamGroupVoListed.add(sampleTeamGroupVo2);
// sampleTeamGroupVoListed.add(sampleTeamGroupVo2);
}
}
sampleVo.setSampleTeamGroupVoList(sampleTeamGroupVoListed);
......@@ -3655,6 +3655,59 @@ public class EntrustServiceImpl extends ServiceImpl<EntrustMapper, Entrust> impl
return BaseResponse.okData(list);
}
/**
* 检测结果查看附件 (平行样的样品附件 也都展示在一个检测项下面里面)
* @param sampleDistributionId
* @return
*/
@Override
public BaseResponse<List<SampleDistributionEnclosureVo>> getClientEnclosureList(Integer sampleDistributionId) {
LoginUser loginUser = userService.getLoginUser();
if (loginUser == null) {
return BaseResponse.errorMsg("请登录账号");
}
if(sampleDistributionId == null){
return BaseResponse.errorMsg("参数错误");
}
Map<String, Object> params = new HashMap<>();
params.put("sampleDistributionId", sampleDistributionId);
params.put("isPublic", 1);
List<SampleDistributionEnclosureVo> list = sampleDistributionEnclosureMapper.getList(params);
//如果有平行样
SampleDistribution sampleDistribution = distributionMapper.selectById(sampleDistributionId);
Sample sample = sampleMapper.selectById(sampleDistribution.getSampleId());
List<Sample> otherSampleList = sampleMapper.getOtherSampleList(sampleDistribution.getEntrustId(), sample.getCementCode(),sample.getId());
if(otherSampleList != null && otherSampleList.size()>0){
for(Sample s : otherSampleList){
QueryWrapper<SampleDistribution> sdWrapper = new QueryWrapper<>();
sdWrapper.eq("entrust_id",sampleDistribution.getEntrustId());
sdWrapper.eq("sample_id",s.getId());
sdWrapper.eq("team_group_id",sampleDistribution.getTeamGroupId());
sdWrapper.eq("team_id",sampleDistribution.getTeamId());
List<SampleDistribution> sdList = distributionMapper.selectList(sdWrapper);
if(sdList != null && sdList.size()>0 ){
for(SampleDistribution sd : sdList){
Map<String, Object> params2 = new HashMap<>();
params2.put("sampleDistributionId", sd.getId());
params.put("isPublic", 1);
List<SampleDistributionEnclosureVo> sdevList = sampleDistributionEnclosureMapper.getList(params2);
if(sdevList != null && sdevList.size()>0){
for(SampleDistributionEnclosureVo sdev : sdevList){
list.add(sdev);
}
}
}
}
}
}
return BaseResponse.okData(list);
}
/**
* 样品处理上传附件
*
......
......@@ -5,21 +5,10 @@ import cn.hutool.core.collection.CollectionUtil;
import cn.hutool.core.date.DateTime;
import cn.hutool.core.date.DateUtil;
import cn.hutool.core.util.StrUtil;
import cn.wise.sc.cement.business.entity.Entrust;
import cn.wise.sc.cement.business.entity.Handle;
import cn.wise.sc.cement.business.entity.NonStandardApply;
import cn.wise.sc.cement.business.entity.NonStandardValue;
import cn.wise.sc.cement.business.entity.NormProduction;
import cn.wise.sc.cement.business.entity.NormProductionStatistics;
import cn.wise.sc.cement.business.entity.Preciprice;
import cn.wise.sc.cement.business.entity.Sample;
import cn.wise.sc.cement.business.entity.SampleDistribution;
import cn.wise.sc.cement.business.entity.SysGroup;
import cn.wise.sc.cement.business.entity.SysPost;
import cn.wise.sc.cement.business.entity.SysUser;
import cn.wise.sc.cement.business.entity.TeamGroup;
import cn.wise.sc.cement.business.entity.*;
import cn.wise.sc.cement.business.mapper.EntrustMapper;
import cn.wise.sc.cement.business.mapper.PrecipriceMapper;
import cn.wise.sc.cement.business.mapper.ProjectMapper;
import cn.wise.sc.cement.business.mapper.SampleMapper;
import cn.wise.sc.cement.business.model.BaseResponse;
import cn.wise.sc.cement.business.model.LoginUser;
......@@ -104,6 +93,10 @@ public class PrecipriceServiceImpl extends ServiceImpl<PrecipriceMapper, Precipr
PrecipriceMapper precipriceMapper;
@Resource
private SampleMapper sampleMapper;
@Resource
private EntrustMapper entrustMapper;
@Resource
private ProjectMapper projectMapper;
public PrecipriceServiceImpl(EntrustMapper iEntrustService,
......@@ -621,6 +614,16 @@ public class PrecipriceServiceImpl extends ServiceImpl<PrecipriceMapper, Precipr
rts.setCementCode(sample.getCementCode());
}
}
//增加项目信息
if(preciprice.getEntrustId() != null){
Entrust entrust = entrustMapper.selectById(preciprice.getEntrustId());
if(entrust != null && entrust.getProjectId() != null){
Project project = projectMapper.selectById(entrust.getProjectId());
if(project != null && project.getName() != null){
rts.setProjectName(project.getName());
}
}
}
rts.setAssessId(preciprice.getTargetId());
rts.setWorkTimeCoefficient(preciprice.getPreciprice());
rts.setCheckTime(getDateTimeOfTimestamp(preciprice.getCreateTime()));
......
......@@ -21,10 +21,9 @@
<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">
<if test="params.startDate == null and params.endDate == null">
and date(sd.create_time) > date_sub(curdate(),interval 30 day)
</if>
group by name
</select>
......@@ -52,6 +51,26 @@
group by s.origin
</select>
<select id="countEntrustSumNum" resultType="integer">
SELECT count(*)
FROM entrust e
left join client c on c.id = e.client_id
where e.status != 0 and e.project_type is not null
<if test="params.startDate != null and params.startDate != ''">
and DATE(e.create_time) &gt;= #{params.startDate}
</if>
<if test="params.endDate != null and params.endDate != ''">
and DATE(e.create_time) &lt;= #{params.endDate}
</if>
<if test="params.clientId != null">
and e.clientId = #{clientId}
</if>
<if test="params.clientName != null and params.clientName != ''">
and c.name like concat('%', #{params.clientName}, '%')
</if>
</select>
<select id="countEntrustStatus" resultType="cn.wise.sc.cement.business.model.vo.DataStatisticsVo">
SELECT (
......@@ -71,6 +90,7 @@
) as name,
count(*) as value
FROM entrust e
left join client c on c.id = e.client_id
where e.status != 0 and e.project_type is not null
<if test="params.cycle == 1 ">
and YEARWEEK(date_format(e.create_time,'%Y-%m-%d' ) ) = YEARWEEK(now())
......@@ -86,6 +106,12 @@
</if>
<if test="params.endDate != null and params.endDate != ''">
and DATE(e.create_time) &lt;= #{params.endDate}
</if>
<if test="params.clientId != null">
and e.clientId = #{clientId}
</if>
<if test="params.clientName != null and params.clientName != ''">
and c.name like concat('%', #{params.clientName}, '%')
</if>
group by e.status
</select>
......@@ -93,6 +119,7 @@
<select id="countEntrustType" resultType="cn.wise.sc.cement.business.model.vo.DataStatisticsVo">
select e.project_type as name, count(*) as value
from entrust e
left join client c on c.id = e.client_id
where e.status != 0 and e.project_type is not null
<if test="params.cycle == 1 ">
and YEARWEEK(date_format(e.create_time,'%Y-%m-%d' ) ) = YEARWEEK(now())
......@@ -109,6 +136,12 @@
<if test="params.endDate != null and params.endDate != ''">
and DATE(e.create_time) &lt;= #{params.endDate}
</if>
<if test="params.clientId != null">
and e.clientId = #{clientId}
</if>
<if test="params.clientName != null and params.clientName != ''">
and c.name like concat('%', #{params.clientName}, '%')
</if>
group by e.project_type
</select>
......@@ -125,6 +158,7 @@
WHEN 6 THEN '样品检测完成'
WHEN 7 THEN '校核中'
WHEN 8 THEN '校核完成'
WHEN 9 THEN '修改待确认'
ELSE ''
END
) as statusValue
......@@ -133,6 +167,9 @@
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.clientId != null">
and e.clientId = #{clientId}
</if>
<if test="params.clientName != null and params.clientName != ''">
and c.name like concat('%', #{params.clientName}, '%')
</if>
......@@ -145,6 +182,54 @@
order by create_time desc
</select>
<select id="exportEntrustList" resultType="java.util.HashMap">
SELECT
(@i:=@i+1) as 序号,
e.id as entrustId,
IF(ISNULL(e.entrust_code),'',e.entrust_code) as 委托单号,
IF(ISNULL(p.name),'',p.name) as 项目名称,
IF(ISNULL(p.name),'',p.name) as 项目编号,
e.project_type as 项目类型,
IF(ISNULL(su.name),'',su.name) as 委托人,
IF(ISNULL(c.name),'',c.name) as 委托单位,
IF(ISNULL(e.entrust_date),'',e.entrust_date) as 委托日期,
IF(ISNULL(e.sample_num),'',e.sample_num) as 样品数量,
(
CASE e.status
WHEN 0 THEN '未评审'
WHEN 1 THEN '已通过'
WHEN 2 THEN '未通过'
WHEN 3 THEN '样品处理中'
WHEN 4 THEN '样品处理完成'
WHEN 5 THEN '样品检测中'
WHEN 6 THEN '样品检测完成'
WHEN 7 THEN '校核中'
WHEN 8 THEN '校核完成'
WHEN 9 THEN '修改待确认'
ELSE ''
END
) as 状态
from entrust e
left join project p on p.id = e.project_id
left join client c on c.id = e.client_id
left join sys_user su on su.id = e.user_id
,(select @i:=0)aa
where e.status != 0 and e.project_type is not null
<if test="params.clientId != null">
and e.clientId = #{clientId}
</if>
<if test="params.clientName != null and params.clientName != ''">
and c.name like concat('%', #{params.clientName}, '%')
</if>
<if test="params.startDate != null and params.startDate != ''">
and DATE(e.create_time) &gt;= #{params.startDate}
</if>
<if test="params.endDate != null and params.endDate != ''">
and DATE(e.create_time) &lt;= #{params.endDate}
</if>
order by 序号
</select>
<select id="countHandlePage" resultType="cn.wise.sc.cement.business.model.vo.DataStatisticsVo">
SELECT su.id as id, su.name as name, count(*) as value FROM sample_handle sh
......@@ -249,6 +334,31 @@
group by sd.team_id
</select>
<select id="exportTeamList" resultType="java.util.HashMap">
SELECT (@i:=@i+1) as 序号,t.id as id, t.name as 检测项目, count(*) as 检测项数量
FROM sample_distribution sd
left join team t on t.id = sd.team_id
,(select @i:=0)t
where 1=1
<if test="params.cycle == 1 ">
and YEARWEEK(date_format(sd.create_time,'%Y-%m-%d' ) ) = YEARWEEK(now())
</if>
<if test="params.cycle == 2 ">
and DATE_FORMAT( sd.create_time, '%Y%m' ) = DATE_FORMAT( CURDATE( ) ,'%Y%m')
</if>
<if test="params.cycle == 3 ">
and YEAR(sd.create_time) = YEAR( NOW( ) )
</if>
<if test="params.startDate != null and params.startDate != ''">
and DATE(sd.create_time) &gt;= #{params.startDate}
</if>
<if test="params.endDate != null and params.endDate != ''">
and DATE(sd.create_time) &lt;= #{params.endDate}
</if>
group by sd.team_id
order by 序号
</select>
<select id="countEntrustNum" resultType="integer">
select count(*) as entrustNum from (
SELECT sd.entrust_id as id, count(*) as entrustNum FROM sample_distribution sd
......
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