Commit 81e85f79 authored by 竹天卫's avatar 竹天卫
parents 325529d7 abeab1b4
package cn.wise.sc.cement.business.controller;
import cn.hutool.core.collection.CollectionUtil;
import cn.hutool.core.date.DateUtil;
import cn.hutool.core.util.StrUtil;
import cn.wise.sc.cement.business.entity.NormProduction;
import cn.wise.sc.cement.business.entity.NormProductionStatistics;
import cn.wise.sc.cement.business.model.BaseResponse;
import cn.wise.sc.cement.business.model.PageQuery;
import cn.wise.sc.cement.business.model.vo.NormProductionVo;
import cn.wise.sc.cement.business.model.vo.ProductionVo;
import cn.wise.sc.cement.business.model.vo.WorkloadStatisticsVo;
import cn.wise.sc.cement.business.service.INonStandardValueService;
import cn.wise.sc.cement.business.service.INormProductionService;
import cn.wise.sc.cement.business.service.IPrecipriceService;
import cn.wise.sc.cement.business.util.PageUtil;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import javax.servlet.http.HttpServletResponse;
import java.util.ArrayList;
import java.util.Date;
import java.util.HashSet;
import java.util.List;
import java.util.Set;
import java.util.stream.Collectors;
/**
* <p>
* 前端控制器
* </p>
*
* @author ztw
* @since 2020-11-02
*/
@RestController
@RequestMapping("/business/preciprice")
public class PrecipriceController {
@Autowired
IPrecipriceService iNormProductionService;
@Autowired
INonStandardValueService inonStandardValueService;
@GetMapping("/ddd")
@ApiOperation("aaa")
public void add(){
iNormProductionService.createPreciprice(1,1,1,1,1);
iNormProductionService.createPreciprice(1,1,20,0,1);
iNormProductionService.createPreciprice(1,1,1,1,1);
iNormProductionService.createPreciprice(1,1,1,1,1);
}
@GetMapping("/statistics")
@ApiOperation("标准产值统计")
public BaseResponse<Page<NormProductionStatistics>> normProductionStatistics(String start, String end, String name, Integer groupId, PageQuery pageQuery) {
Long startTime = null;
Long endTime = null;
if (StrUtil.isNotBlank(start) && StrUtil.isNotBlank(end)) {
startTime = DateUtil.parseDate(start).getTime();
endTime = DateUtil.parseDate(end).getTime();
}
//将list拆分成分页
BaseResponse<List<NormProductionStatistics>> baseResponse = iNormProductionService
.normProductionStatistics(startTime, endTime, name, groupId);
if (baseResponse.getCode() == 200) {
List<NormProductionStatistics> data = baseResponse.getData();
if (data.size() != 0) {
Page<NormProductionStatistics> rts = PageUtil.listConvertToPage(data, pageQuery);
return BaseResponse.okData(rts);
}
}
return BaseResponse.okData(null);
}
@GetMapping("/statistics/detail")
@ApiOperation("标准产值详情")
public BaseResponse<Page<NormProduction.NormProductionDetail>> normProductionDetails(Integer userId, String start,
String end, PageQuery pageQuery) {
Long startTime = null;
Long endTime = null;
if (StrUtil.isNotBlank(start) && StrUtil.isNotBlank(end)) {
startTime = DateUtil.parseDate(start).getTime();
endTime = DateUtil.parseDate(end).getTime();
}
List<NormProduction.NormProductionDetail> data = iNormProductionService.normProductionDetails(userId, startTime, endTime);
List<NormProduction.NormProductionDetail> collect = data
.stream()
.filter(arg -> arg.getUserId().intValue() == userId)
.collect(Collectors.toList());
if (collect.size() != 0) {
Page<NormProduction.NormProductionDetail> rts = PageUtil.listConvertToPage(collect, pageQuery);
return BaseResponse.okData(rts);
}
return BaseResponse.okData(null);
}
@GetMapping("/total/production")
@ApiOperation("总产值统计")
public BaseResponse<Page<ProductionVo>> production(PageQuery pageQuery, String name, String start, String end, Integer groupId) {
Long startTime = null;
Long endTime = null;
if (StrUtil.isNotBlank(start) && StrUtil.isNotBlank(end)) {
startTime = DateUtil.parseDate(start).getTime();
endTime = DateUtil.parseDate(end).getTime();
}
List<ProductionVo> rts = iNormProductionService.production(name, startTime, endTime, groupId);
if (!CollectionUtil.isEmpty(rts)) {
Set<Integer> ids = new HashSet<>();
for (ProductionVo productionVo : rts) {
Integer groupId1 = productionVo.getGroupId();
ids.add(groupId1);
}
List<ProductionVo> newRts = new ArrayList<>();
for (Integer groupId1 : ids) {
ProductionVo finalNormProduction = new ProductionVo();
for (ProductionVo productionVo : rts) {
if (productionVo.getGroupId().intValue() == groupId1) {
finalNormProduction.setUserId(productionVo.getUserId());
finalNormProduction.setUserName(productionVo.getUserName());
finalNormProduction.setAccount(productionVo.getAccount());
finalNormProduction.setPositionId(productionVo.getPositionId());
finalNormProduction.setPosition(productionVo.getPosition());
finalNormProduction.setTime(productionVo.getTime());
finalNormProduction.setGroupId(productionVo.getGroupId());
finalNormProduction.setGroupName(productionVo.getGroupName());
Double newFinalValue = productionVo.getProductionTotalValue() + finalNormProduction.getProductionTotalValue();
finalNormProduction.setProductionTotalValue(newFinalValue);
Double newNonProductionValue = productionVo.getNonProductionValue() + finalNormProduction.getNonProductionValue();
finalNormProduction.setNonProductionValue(newNonProductionValue);
Double newProductionValue = productionVo.getProductionValue() + finalNormProduction.getProductionValue();
finalNormProduction.setProductionValue(newProductionValue);
}
}
newRts.add(finalNormProduction);
}
rts = newRts;
}
return BaseResponse.okData(PageUtil.listConvertToPage(rts, pageQuery));
}
@PostMapping("/export/statistics")
@ApiOperation("导出标准产值列表")
public void exportNormProductionStatistics(String start, String end, String name, Integer groupId, HttpServletResponse response) {
Long startTime = null;
Long endTime = null;
if (StrUtil.isNotBlank(start) && StrUtil.isNotBlank(end)) {
startTime = DateUtil.parseDate(start).getTime();
endTime = DateUtil.parseDate(end).getTime();
}
iNormProductionService.exportNormProductionStatistics(startTime, endTime, name, groupId, response);
}
@PostMapping("/export/statistics/detail")
@ApiOperation("导出个人标准产值详情列表")
public void exportNormProductionDetails(Integer userId, String start,
String end, HttpServletResponse response) {
Long startTime = null;
Long endTime = null;
if (StrUtil.isNotBlank(start) && StrUtil.isNotBlank(end)) {
startTime = DateUtil.parseDate(start).getTime();
endTime = DateUtil.parseDate(end).getTime();
}
iNormProductionService.exportNormProductionDetail(userId, startTime, endTime, response);
}
@PostMapping("/export/total/production")
@ApiOperation("导出总产值")
public void exportProduction(String name, String start, String end, Integer groupId, HttpServletResponse response) {
Long startTime = null;
Long endTime = null;
if (StrUtil.isNotBlank(start) && StrUtil.isNotBlank(end)) {
startTime = DateUtil.parseDate(start).getTime();
endTime = DateUtil.parseDate(end).getTime();
}
iNormProductionService.exportProduction(name, startTime, endTime, groupId, response);
}
@GetMapping("/workload/statistics")
@ApiOperation("工作量统计")
public BaseResponse<List<WorkloadStatisticsVo>> workloadStatistics(String start, String end, Integer userId) {
Date startTime = null;
Date endTime = DateUtil.date();
if (StrUtil.isNotBlank(start) && StrUtil.isNotBlank(end)) {
startTime = DateUtil.parseDate(start);
endTime = DateUtil.parseDate(end);
}
return BaseResponse.okData(iNormProductionService.workloadStatistics(startTime, endTime, userId));
}
}
package cn.wise.sc.cement.business.entity;
import java.math.BigDecimal;
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableId;
import java.time.LocalDateTime;
import java.io.Serializable;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.experimental.Accessors;
/**
* <p>
*
* </p>
*
* @author ztw
* @since 2020-11-02
*/
@Data
@EqualsAndHashCode(callSuper = false)
@Accessors(chain = true)
public class Preciprice implements Serializable {
private static final long serialVersionUID=1L;
@TableId(value = "id", type = IdType.AUTO)
private Integer id;
/**
* 样品名字
*/
private String sampleName;
private Integer sex;
/**
* 用户id
*/
private Integer userId;
/**
* 样品id
*/
private Integer sampleId;
/**
* 检测/处理Id
*/
private Integer targetId;
/**
* 检测:1 处理:0
*/
private Integer type;
/**
* 工值
*/
private BigDecimal preciprice;
/**
* 考核占比
*/
private BigDecimal assessRate;
/**
* 分析占比
*/
private BigDecimal analyseRate;
/**
* 分样占比
*/
private BigDecimal separateRate;
/**
* 报出分析结果
*/
private BigDecimal reportedAnalyseResult;
/**
* 定额工日
*/
private BigDecimal quotaDay;
/**
* 建议系数
*/
private BigDecimal coefficient;
/**
* 考核工值
*/
private BigDecimal assessValue;
/**
* 报结果占比
*/
private BigDecimal reportedResultRate;
/**
* 时间
*/
private long createTime;
/**
* 项目id
*/
private Integer entrustId;
/**
* 项目id
*/
private String entrustName;
/**
* 项目编号
*/
private String entrustCode;
/**
* 账号
*/
private String account;
/**
* 职位
*/
private String position;
/**
* 部门id
*/
private Integer groupId;
private String userName;
/**
* 检测组名
*/
private String groupTeamName;
}
package cn.wise.sc.cement.business.mapper;
import cn.wise.sc.cement.business.entity.Preciprice;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
/**
* <p>
* Mapper 接口
* </p>
*
* @author ztw
* @since 2020-11-02
*/
public interface PrecipriceMapper extends BaseMapper<Preciprice> {
}
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="cn.wise.sc.cement.business.mapper.PrecipriceMapper">
</mapper>
package cn.wise.sc.cement.business.service;
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.model.BaseResponse;
import cn.wise.sc.cement.business.model.PageQuery;
import cn.wise.sc.cement.business.model.vo.NormProductionVo;
import cn.wise.sc.cement.business.model.vo.ProductionVo;
import cn.wise.sc.cement.business.model.vo.WorkloadStatisticsVo;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.IService;
import javax.servlet.http.HttpServletResponse;
import java.util.Date;
import java.util.List;
/**
* <p>
* 服务类
* </p>
*
* @author ztw
* @since 2020-11-02
*/
public interface IPrecipriceService extends IService<Preciprice> {
boolean createPreciprice(final Integer userId, final Integer entrustId,
final Integer targetId, final Integer type,
final Integer sampleId);
/**
* 标准产值统计
*
* @param start 开始时间
* @param end 结束时间
* @param groupId 部门id
* @return BaseResponse
*/
BaseResponse<List<NormProductionStatistics>> normProductionStatistics(Long start, Long end, String name, Integer groupId);
/**
* 标准产值统计 单人详情
*
* @param userId 用户id
* @param start 开始时间
* @param end 结束时间
* @return 详细信息
*/
List<NormProduction.NormProductionDetail> normProductionDetails(Integer userId,
Long start, Long end);
/**
* 总产值统计
*
* @param name 用户
* @param start 开始时间
* @param end 结束时间
* @return 详细信息
*/
List<ProductionVo> production(String name, Long start, Long end, Integer groupId);
/**
* 导出标准统计
* @param start 开始时间
* @param end 结束时间
* @param name 人员名字
* @param groupId 部门id
* @param response 响应体
*/
void exportNormProductionStatistics(Long start, Long end,String name,Integer groupId, HttpServletResponse response);
/**
* 导出个人标准产值详情列表
* @param userId 用户id
* @param startTime 开始时间
* @param endTime 结束时间
* @param response 响应体
*/
void exportNormProductionDetail(Integer userId, Long startTime, Long endTime, HttpServletResponse response);
/**
* 导出产值总统计列表
* @param name 名字检索
* @param startTime 开始时间
* @param endTime 结束时间
* @param response 响应体
*/
void exportProduction(String name, Long startTime, Long endTime,Integer groupId,HttpServletResponse response);
/**
* 统计工作量
* @param startTime 开始时间
* @param endTime 结束时间
* @return 统计对象
*/
List<WorkloadStatisticsVo> workloadStatistics(Date startTime, Date endTime, Integer userId);
}
...@@ -285,6 +285,7 @@ public class NormProductionServiceImpl extends ServiceImpl<NormProductionMapper, ...@@ -285,6 +285,7 @@ public class NormProductionServiceImpl extends ServiceImpl<NormProductionMapper,
continue; continue;
} }
if (sysGroup == null) { if (sysGroup == null) {
log.debug("用户分组未设置!关联用户部门失败!");
continue; continue;
} }
NormProductionStatistics productionStatistics = new NormProductionStatistics(); NormProductionStatistics productionStatistics = new NormProductionStatistics();
......
package cn.wise.sc.cement.business.service.impl; package cn.wise.sc.cement.business.service.impl;
import cn.hutool.core.util.NumberUtil;
import cn.hutool.core.util.StrUtil; import cn.hutool.core.util.StrUtil;
import cn.wise.sc.cement.business.entity.SysUser; import cn.wise.sc.cement.business.entity.SysUser;
import cn.wise.sc.cement.business.model.BaseResponse; import cn.wise.sc.cement.business.model.BaseResponse;
...@@ -21,6 +22,8 @@ import org.slf4j.LoggerFactory; ...@@ -21,6 +22,8 @@ import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import java.math.BigDecimal;
@Service @Service
public class WeiXinService { public class WeiXinService {
...@@ -232,6 +235,8 @@ public class WeiXinService { ...@@ -232,6 +235,8 @@ public class WeiXinService {
} }
public static void main(String[] args) {
BigDecimal bigDecimal = NumberUtil.toBigDecimal(StrUtil.trim("111 "));
}
} }
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