Browse Source

CQC 报表代码迭代

thing_master
xiachao 2 years ago
parent
commit
dd1ae3d9ef
  1. 25
      modules/cqc-service/src/main/java/com/thing/cqc/cqcCarbonReport/controller/CqcCarbonReportController.java
  2. 20
      modules/cqc-service/src/main/java/com/thing/cqc/cqcCarbonReport/dto/CqcCarbonReportCountInfo.java
  3. 14
      modules/cqc-service/src/main/java/com/thing/cqc/cqcCarbonReport/dto/CqcCarbonReportCountParam.java
  4. 8
      modules/cqc-service/src/main/java/com/thing/cqc/cqcCarbonReport/mapper/CqcCarbonReportMapper.java
  5. 3
      modules/cqc-service/src/main/java/com/thing/cqc/cqcCarbonReport/service/CqcCarbonReportService.java
  6. 39
      modules/cqc-service/src/main/java/com/thing/cqc/cqcCarbonReport/service/impl/CqcCarbonReportServiceImpl.java
  7. 10
      modules/cqc-service/src/main/resources/mapper/CqcCarbonReportMapper.xml

25
modules/cqc-service/src/main/java/com/thing/cqc/cqcCarbonReport/controller/CqcCarbonReportController.java

@ -9,6 +9,8 @@ import com.thing.common.core.validator.group.DefaultGroup;
import com.thing.common.core.validator.group.UpdateGroup;
import com.thing.common.core.web.response.PageData;
import com.thing.common.core.web.response.Result;
import com.thing.common.orm.utils.IdGenerator;
import com.thing.cqc.cqcCarbonReport.dto.CqcCarbonReportCountInfo;
import com.thing.cqc.cqcCarbonReport.dto.CqcCarbonReportDTO;
import com.thing.cqc.cqcCarbonReport.service.CqcCarbonReportService;
import com.thing.cqc.rpcService.service.CqcRpcService;
@ -37,21 +39,33 @@ public class CqcCarbonReportController {
private final CqcCarbonReportService cqcCarbonReportService;
private final CqcRpcService cqcRpcService;
@GetMapping("page")
@Operation(summary="分页")
@Parameters({
@Parameter(name = Constant.PAGE, description = "当前页码,从1开始", required = true) ,
@Parameter(name = Constant.LIMIT, description = "每页显示记录数", required = true) ,
@Parameter(name = Constant.ORDER_FIELD, description = "排序字段") ,
@Parameter(name = Constant.ORDER, description = "排序方式,可选值(asc、desc)")
@Parameter(name = Constant.ORDER, description = "排序方式,可选值(asc、desc)"),
@Parameter(name = "status", description = "审核状态"),
@Parameter(name = "enterpriseNameCn", description = "企业名称"),
@Parameter(name = "productNameCn", description = "产品名称"),
@Parameter(name = "deptId", description = "认证机构")
})
public Result<PageData<CqcCarbonReportDTO>> page(@Parameter(hidden = true) @RequestParam Map<String, Object> params){
PageData<CqcCarbonReportDTO> page = cqcCarbonReportService.getPageData(params, CqcCarbonReportDTO.class);
return new Result<PageData<CqcCarbonReportDTO>>().ok(page);
}
@GetMapping("count")
public Result<CqcCarbonReportCountInfo> count(){
CqcCarbonReportCountInfo data = cqcCarbonReportService.countByStatus();
return new Result<CqcCarbonReportCountInfo>().ok(data);
}
@GetMapping("{id}")
public Result<CqcCarbonReportDTO> get(@PathVariable("id") Long id){
CqcCarbonReportDTO data = cqcCarbonReportService.getByIdAs(id, CqcCarbonReportDTO.class);
@ -63,12 +77,13 @@ public class CqcCarbonReportController {
public Result<Object> save(@RequestBody CqcCarbonReportDTO dto){
//效验数据
ValidatorUtils.validateEntity(dto, AddGroup.class, DefaultGroup.class);
dto.setId(IdGenerator.nextId());
dto.setApplyNo(String.valueOf(UUID.randomUUID()));
dto.setCreateDate(System.currentTimeMillis());
dto.setCompanyId(UserContext.getCompanyId());
dto.setTenantCode(UserContext.getTenantCode());
cqcCarbonReportService.saveDto(dto);
return new Result<Object>().ok(dto.getApplyNo());
return new Result<Object>().ok(dto);
}
@PutMapping
@ -77,7 +92,7 @@ public class CqcCarbonReportController {
//效验数据
ValidatorUtils.validateEntity(dto, UpdateGroup.class, DefaultGroup.class);
cqcCarbonReportService.updateDto(dto);
return new Result<Object>().ok(dto.getApplyNo());
return new Result<Object>().ok(dto);
}
@DeleteMapping

20
modules/cqc-service/src/main/java/com/thing/cqc/cqcCarbonReport/dto/CqcCarbonReportCountInfo.java

@ -0,0 +1,20 @@
package com.thing.cqc.cqcCarbonReport.dto;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;
@Data
@Schema(description = "状态统计")
public class CqcCarbonReportCountInfo {
@Schema(description = "待提交")
private Long pendingSubmitted;
@Schema(description = "待发证")
private Long pendingCertification;
@Schema(description = "已发证")
private Long issued;
}

14
modules/cqc-service/src/main/java/com/thing/cqc/cqcCarbonReport/dto/CqcCarbonReportCountParam.java

@ -0,0 +1,14 @@
package com.thing.cqc.cqcCarbonReport.dto;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;
@Data
@Schema(description = "状态统计")
public class CqcCarbonReportCountParam {
private String status;
private Long count;
}

8
modules/cqc-service/src/main/java/com/thing/cqc/cqcCarbonReport/mapper/CqcCarbonReportMapper.java

@ -1,9 +1,14 @@
package com.thing.cqc.cqcCarbonReport.mapper;
import com.thing.common.orm.mapper.PowerBaseMapper;
import com.thing.cqc.cqcCarbonReport.dto.CqcCarbonReportCountInfo;
import com.thing.cqc.cqcCarbonReport.dto.CqcCarbonReportCountParam;
import com.thing.cqc.cqcCarbonReport.entity.CqcCarbonReportEntity;
import org.apache.ibatis.annotations.Mapper;
import java.util.List;
import java.util.Map;
/**
* 申请表基础数据
*
@ -12,5 +17,6 @@ import org.apache.ibatis.annotations.Mapper;
*/
@Mapper
public interface CqcCarbonReportMapper extends PowerBaseMapper<CqcCarbonReportEntity> {
List<CqcCarbonReportCountParam> countByStatus();
}

3
modules/cqc-service/src/main/java/com/thing/cqc/cqcCarbonReport/service/CqcCarbonReportService.java

@ -2,6 +2,7 @@ package com.thing.cqc.cqcCarbonReport.service;
import com.thing.common.core.web.response.Result;
import com.thing.common.orm.service.IBaseService;
import com.thing.cqc.cqcCarbonReport.dto.CqcCarbonReportCountInfo;
import com.thing.cqc.cqcCarbonReport.entity.CqcCarbonReportEntity;
/**
@ -13,4 +14,6 @@ import com.thing.cqc.cqcCarbonReport.entity.CqcCarbonReportEntity;
public interface CqcCarbonReportService extends IBaseService<CqcCarbonReportEntity> {
Result<String> uploadReport(Long id);
CqcCarbonReportCountInfo countByStatus();
}

39
modules/cqc-service/src/main/java/com/thing/cqc/cqcCarbonReport/service/impl/CqcCarbonReportServiceImpl.java

@ -1,6 +1,7 @@
package com.thing.cqc.cqcCarbonReport.service.impl;
import com.alibaba.fastjson.JSONObject;
import com.mybatisflex.core.query.QueryColumn;
import com.mybatisflex.core.query.QueryWrapper;
import com.thing.common.core.web.response.Result;
import com.thing.common.orm.service.impl.BaseServiceImpl;
@ -21,16 +22,20 @@ import com.thing.cqc.cqcCarbonMake.entity.CqcCarbonMakeEntity;
import com.thing.cqc.cqcCarbonMake.service.CqcCarbonMakeService;
import com.thing.cqc.cqcCarbonRaw.dto.CqcCarbonRawDTO;
import com.thing.cqc.cqcCarbonRaw.service.CqcCarbonRawService;
import com.thing.cqc.cqcCarbonReport.dto.CqcCarbonReportCountInfo;
import com.thing.cqc.cqcCarbonReport.dto.CqcCarbonReportCountParam;
import com.thing.cqc.cqcCarbonReport.dto.CqcCarbonReportDTO;
import com.thing.cqc.cqcCarbonReport.mapper.CqcCarbonReportMapper;
import com.thing.cqc.cqcCarbonReport.entity.CqcCarbonReportEntity;
import com.thing.cqc.cqcCarbonReport.service.CqcCarbonReportService;
import com.thing.cqc.rpcService.service.CqcRpcService;
import com.thing.sys.security.context.UserContext;
import org.apache.commons.collections4.MapUtils;
import org.apache.commons.lang3.ObjectUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.List;
import java.util.Map;
/**
@ -65,6 +70,16 @@ public class CqcCarbonReportServiceImpl extends BaseServiceImpl<CqcCarbonReportM
if(!tenantCode.equals(1001L)){
wrapper.eq(CqcCarbonReportEntity::getTenantCode,tenantCode);
}
String status = MapUtils.getString(params,"params");
wrapper.eq("status",status,ObjectUtils.isNotEmpty(status));
String enterpriseNameCn = MapUtils.getString(params,"enterpriseNameCn");
String productNameCn = MapUtils.getString(params,"productNameCn");
String deptId = MapUtils.getString(params,"deptId");
QueryColumn enterprise_name_cn = new QueryColumn("enterprise_name_cn");
QueryColumn product_name_cn = new QueryColumn("product_name_cn");
QueryColumn dept_id = new QueryColumn("dept_id");
wrapper.and(enterprise_name_cn.like(enterpriseNameCn,ObjectUtils.isNotEmpty(enterpriseNameCn)).or(product_name_cn.like(productNameCn,ObjectUtils.isNotEmpty(productNameCn)))
.or(dept_id.like(deptId,ObjectUtils.isNotEmpty(deptId))));
return wrapper;
}
@ -72,9 +87,6 @@ public class CqcCarbonReportServiceImpl extends BaseServiceImpl<CqcCarbonReportM
@Override
public Result<String> uploadReport(Long id) {
Result<String> result = new Result<>();
CqcCarbonReportDTO reportDTO = this.getByIdAs(id,CqcCarbonReportDTO.class);
String applyNo = reportDTO.getApplyNo();
if(ObjectUtils.isNotEmpty(reportDTO.getApplyNo())){
@ -106,4 +118,25 @@ public class CqcCarbonReportServiceImpl extends BaseServiceImpl<CqcCarbonReportM
}
return result;
}
@Override
public CqcCarbonReportCountInfo countByStatus() {
CqcCarbonReportCountInfo cqcCarbonReportCountInfo = new CqcCarbonReportCountInfo();
List<CqcCarbonReportCountParam> list = mapper.countByStatus();
list.forEach(temp->{
if(temp.getStatus().equals("1")){
cqcCarbonReportCountInfo.setPendingSubmitted(temp.getCount()==null?0:temp.getCount());
}
if(temp.getStatus().equals("2")){
cqcCarbonReportCountInfo.setPendingCertification(temp.getCount()==null?0:temp.getCount());
}
if(temp.getStatus().equals("3")){
cqcCarbonReportCountInfo.setIssued(temp.getCount()==null?0:temp.getCount());
}
});
return cqcCarbonReportCountInfo;
}
}

10
modules/cqc-service/src/main/resources/mapper/CqcCarbonReportMapper.xml

@ -3,4 +3,14 @@
<mapper namespace="com.thing.cqc.cqcCarbonReport.mapper.CqcCarbonReportMapper">
<select id="countByStatus" resultType="com.thing.cqc.cqcCarbonReport.dto.CqcCarbonReportCountParam">
SELECT
status,"count"(status) as count
FROM
cqc_carbon_report
GROUP BY status;
</select>
</mapper>
Loading…
Cancel
Save