Commit f44e6cc3 authored by mengbali153's avatar mengbali153

Merge remote-tracking branch 'origin/master' into master

# Conflicts:
#	cement-business/src/main/java/cn/wise/sc/cement/business/controller/NormProductionController.java
#	cement-business/src/main/java/cn/wise/sc/cement/business/controller/ReportController.java
#	cement-business/src/main/java/cn/wise/sc/cement/business/controller/WeiXinController.java
#	cement-business/src/main/java/cn/wise/sc/cement/business/model/IndustrialReport.java
#	cement-business/src/main/java/cn/wise/sc/cement/business/model/SixElementReport.java
#	cement-business/src/main/java/cn/wise/sc/cement/business/model/query/CheckCountSampleQuery.java
#	cement-business/src/main/java/cn/wise/sc/cement/business/service/INormProductionService.java
#	cement-business/src/main/java/cn/wise/sc/cement/business/service/impl/CommonServiceImpl.java
#	cement-business/src/main/java/cn/wise/sc/cement/business/service/impl/EntrustServiceImpl.java
#	cement-business/src/main/java/cn/wise/sc/cement/business/service/impl/NormProductionServiceImpl.java
#	cement-business/src/main/java/cn/wise/sc/cement/business/service/impl/QualityApplyServiceImpl.java
#	cement-business/src/main/java/cn/wise/sc/cement/business/service/impl/WeiXinService.java
#	cement-business/src/main/java/cn/wise/sc/cement/business/util/CheckCountUtil.java
#	cement-business/src/main/java/cn/wise/sc/cement/business/util/weixin/Global.java
#	cement-business/src/main/java/cn/wise/sc/cement/business/util/weixin/WeixinInterfaceUtil.java
parents 1baf88a6 6a2b08fd
......@@ -43,199 +43,200 @@ import java.util.Set;
@RequestMapping("/business/norm/production")
public class NormProductionController {
final
INormProductionService iNormProductionService;
public NormProductionController(INormProductionService iNormProductionService) {
this.iNormProductionService = iNormProductionService;
}
@PostMapping("/create")
@ApiOperation("新增标准产值配置")
public BaseResponse<NormProduction> addObj(@RequestBody NormProduction normProduction) {
return iNormProductionService.addObj(normProduction);
}
@GetMapping("/page")
@ApiOperation("分页查询")
public BaseResponse<IPage<NormProductionVo>> page(PageQuery pageQuery) {
return iNormProductionService.getPage(pageQuery);
}
@PutMapping("/edit")
@ApiOperation("编辑标注产值配置")
public BaseResponse<Boolean> edit(@RequestBody NormProduction production) {
return iNormProductionService.edit(production);
}
@GetMapping("/{id}")
@ApiOperation("根据id获取标准产值配置")
public BaseResponse<NormProduction> getById(@PathVariable("id") Integer id) {
if (id == null || id <= 0) {
return BaseResponse.errorMsg("id不能为空!");
}
NormProduction rts = iNormProductionService.getById(id);
if (rts != null) {
return BaseResponse.okData(rts);
} else {
return BaseResponse.errorMsg("没找着符合要求的信息!");
}
}
@PutMapping("/status/{id}")
@ApiOperation("启用/禁用")
public BaseResponse<Integer> activeOrForbidden(@PathVariable("id") Integer id) {
if (id == null || id <= 0) {
return BaseResponse.errorMsg("编号id不能为空!");
}
return iNormProductionService.activeOrForbidden(id);
}
@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.errorMsg("没有找到相关数据!");
}
@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);
if (data.size() != 0) {
Page<NormProduction.NormProductionDetail> rts = PageUtil.listConvertToPage(data, pageQuery);
return BaseResponse.okData(rts);
}
return BaseResponse.errorMsg("没有找到相关数据!");
}
@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 (!rts.isEmpty()) {
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) {
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));
}
final
INormProductionService iNormProductionService;
public NormProductionController(INormProductionService iNormProductionService) {
this.iNormProductionService = iNormProductionService;
}
@PostMapping("/create")
@ApiOperation("新增标准产值配置")
public BaseResponse<NormProduction> addObj(@RequestBody NormProduction normProduction) {
return iNormProductionService.addObj(normProduction);
}
@GetMapping("/page")
@ApiOperation("分页查询")
public BaseResponse<IPage<NormProductionVo>> page(PageQuery pageQuery) {
return iNormProductionService.getPage(pageQuery);
}
@PutMapping("/edit")
@ApiOperation("编辑标注产值配置")
public BaseResponse<Boolean> edit(@RequestBody NormProduction production) {
return iNormProductionService.edit(production);
}
@GetMapping("/{id}")
@ApiOperation("根据id获取标准产值配置")
public BaseResponse<NormProduction> getById(@PathVariable("id") Integer id) {
if (id == null || id <= 0) {
return BaseResponse.errorMsg("id不能为空!");
}
NormProduction rts = iNormProductionService.getById(id);
if (rts != null) {
return BaseResponse.okData(rts);
} else {
return BaseResponse.errorMsg("没找着符合要求的信息!");
}
}
@PutMapping("/status/{id}")
@ApiOperation("启用/禁用")
public BaseResponse<Integer> activeOrForbidden(@PathVariable("id") Integer id) {
if (id == null || id <= 0) {
return BaseResponse.errorMsg("编号id不能为空!");
}
return iNormProductionService.activeOrForbidden(id);
}
@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.errorMsg("没有找到相关数据!");
}
@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);
if (data.size() != 0) {
Page<NormProduction.NormProductionDetail> rts = PageUtil.listConvertToPage(data, pageQuery);
return BaseResponse.okData(rts);
}
return BaseResponse.errorMsg("没有找到相关数据!");
}
@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 (!rts.isEmpty()) {
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));
}
}
......@@ -25,7 +25,6 @@ import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import javax.servlet.http.HttpServletResponse;
import java.util.HashMap;
import java.util.List;
......@@ -45,153 +44,154 @@ import java.util.stream.Collectors;
@RequestMapping("/business/report")
public class ReportController {
final
IEntrustService iEntrustService;
public ReportController(IEntrustService iEntrustService) {
this.iEntrustService = iEntrustService;
}
@ApiOperation(value = "报告分页列表")
@ApiImplicitParams(value = {
@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 = "projectName", value = "项目名称", paramType = "query", dataType = "String"),
@ApiImplicitParam(name = "projectCode", value = "项目编号", paramType = "query", dataType = "String")
})
@GetMapping("/getPage")
public BaseResponse<IPage<EntrustVo>> page(PageQuery pageQuery, String startDate, String endDate,
Integer clientId, String projectName, String projectCode) {
return iEntrustService.getReportPage(pageQuery, startDate, endDate, clientId, projectName, projectCode);
}
@ApiOperation(value = "置顶取消置顶 (createTime = updateTime显示置顶,否则显示取消置顶)")
@PostMapping("/setTopping")
public BaseResponse<String> setTopping(Integer id) {
try {
return iEntrustService.setTopping(id);
} catch (Exception e) {
log.debug("置顶取消置顶 {}", e.getMessage());
}
return BaseResponse.errorMsg("失败!");
}
@DeleteMapping("/{id}")
@ApiOperation("删除报告")
public BaseResponse<Boolean> deleteById(@PathVariable("id") Integer id) {
return iEntrustService.deleteById(id);
}
@PostMapping("/{entrustId}")
@ApiOperation("导出报告封面和首页")
public void getReportDetail(@PathVariable("entrustId") Integer entrustId,
HttpServletResponse response) {
//首页及封面导出
ReportDetailVo rts = iEntrustService.getReportDetail(entrustId);
if (rts == null) {
return;
}
Map<String, Object> beanParams = new HashMap<>(10);
beanParams.put("sendName", rts.getSendName());
beanParams.put("sender", rts.getSender());
beanParams.put("sendDate", rts.getSendDate());
beanParams.put("sampleNum", rts.getSampleNum());
beanParams.put("sampleNames", set2String(rts.getSampleNames()));
beanParams.put("teamNames", set2String(rts.getTeamNames()));
beanParams.put("methodNames", set2StringN(rts.getMethodNames()));
beanParams.put("equipmentNames", set2StringN(rts.getEquipmentNames()));
beanParams.put("projectName", rts.getProjectName());
beanParams.put("printDate", rts.getPrintDate());
//六元素导出
List<SixElementReport> list = iEntrustService.getSampleSixElementCheck(entrustId);
list.forEach(this::initMapStr2AlongPro);
List<SixElementReport> al2o3AndTio2List = list.stream()
.filter(arg -> !"-".equals(arg.getAl2o3AndTio2()))
.collect(Collectors.toList());
List<SixElementReport> al2o3SplitTio2List = list.stream()
.filter(arg -> "-".equals(arg.getAl2o3AndTio2()))
.collect(Collectors.toList());
beanParams.put("list1", al2o3AndTio2List);
beanParams.put("list2", al2o3SplitTio2List);
//化学工业导出
List<IndustrialReport> list1 = iEntrustService.getSampleIndustrialCheck(entrustId);
list1.forEach(this::initMapStr2AlongPro);
beanParams.put("list3", list1);
WordUtil.writeWordReport(rts.getProjectName() + "(报告)", "report.ftl",
beanParams, response, FileExt.EXCL);
}
/**
* 将样品六元素检测Map转换成单独属性
*
* @param sixElement 带转换的六元素检测结果
* @return 已转换结果
*/
private void initMapStr2AlongPro(SixElementReport sixElement) {
String countResult = sixElement.getCountResult();
HashMap<String, String> countResultMap = JSON.parseObject(countResult, HashMap.class);
sixElement.setAl2o3("-");
sixElement.setTio2("-");
sixElement.setAl2o3AndTio2("-");
//判断检测结果中六元素Al2O3是否包含TiO2
if (countResultMap.containsKey(SixElementKey.Al2O3AndTiO2.getKey())) {
sixElement.setAl2o3AndTio2(countResultMap.get(SixElementKey.Al2O3AndTiO2.getKey()));
} else {
sixElement.setAl2o3(countResultMap.getOrDefault(SixElementKey.Al2O3.getKey(), "0"));
sixElement.setTio2(countResultMap.getOrDefault(SixElementKey.TiO2.getKey(), "0"));
}
sixElement.setCao(countResultMap.getOrDefault(SixElementKey.CaO.getKey(), "0"));
sixElement.setCl(countResultMap.getOrDefault(SixElementKey.Cl.getKey(), "0"));
sixElement.setFe2o3(countResultMap.getOrDefault(SixElementKey.Fe2O3.getKey(), "0"));
sixElement.setLoi(countResultMap.getOrDefault(SixElementKey.LOI.getKey(), "0"));
sixElement.setMgo(countResultMap.getOrDefault(SixElementKey.MgO.getKey(), "0"));
sixElement.setSio2(countResultMap.getOrDefault(SixElementKey.SiO2.getKey(), "0"));
sixElement.setSo3(countResultMap.getOrDefault(SixElementKey.SO3.getKey(), "0"));
}
private void initMapStr2AlongPro(IndustrialReport industrialReport) {
String countResult = industrialReport.getCountResult();
HashMap<String, String> countResultMap = JSON.parseObject(countResult, HashMap.class);
industrialReport.setAad(countResultMap.getOrDefault(IndustrialElementKey.Aad.getKey(), "0"));
industrialReport.setJz(countResultMap.getOrDefault(IndustrialElementKey.JZ.getKey(), "0"));
industrialReport.setMad(countResultMap.getOrDefault(IndustrialElementKey.Mad.getKey(), "0"));
industrialReport.setMjkg(countResultMap.getOrDefault(IndustrialElementKey.QnetAdMJkg.getKey(), "0"));
industrialReport.setStad(countResultMap.getOrDefault(IndustrialElementKey.StAd.getKey(), "0"));
industrialReport.setVad(countResultMap.getOrDefault(IndustrialElementKey.Vad.getKey(), "0"));
}
private String set2String(Set<String> source) {
if (source.size() == 0) {
return "";
}
StringBuilder strBuilder = new StringBuilder();
for (String target : source) {
strBuilder.append("、").append(target);
}
return strBuilder.replace(0, 1, "").toString();
}
private String set2StringN(Set<String> source) {
if (source.size() == 0) {
return "";
}
StringBuilder strBuilder = new StringBuilder();
for (String target : source) {
strBuilder.append("&#10;").append(target);
}
return strBuilder.replace(0, 5, "").toString();
}
final
IEntrustService iEntrustService;
public ReportController(IEntrustService iEntrustService) {
this.iEntrustService = iEntrustService;
}
@ApiOperation(value = "报告分页列表")
@ApiImplicitParams(value = {
@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 = "projectName", value = "项目名称", paramType = "query", dataType = "String"),
@ApiImplicitParam(name = "projectCode", value = "项目编号", paramType = "query", dataType = "String")
})
@GetMapping("/getPage")
public BaseResponse<IPage<EntrustVo>> page(PageQuery pageQuery, String startDate, String endDate,
Integer clientId, String projectName, String projectCode) {
return iEntrustService.getReportPage(pageQuery, startDate, endDate, clientId, projectName, projectCode);
}
@ApiOperation(value = "置顶取消置顶 (createTime = updateTime显示置顶,否则显示取消置顶)")
@PostMapping("/setTopping")
public BaseResponse<String> setTopping(Integer id) {
try {
return iEntrustService.setTopping(id);
} catch (Exception e) {
log.debug("置顶取消置顶 {}", e.getMessage());
}
return BaseResponse.errorMsg("失败!");
}
@DeleteMapping("/{id}")
@ApiOperation("删除报告")
public BaseResponse<Boolean> deleteById(@PathVariable("id") Integer id) {
return iEntrustService.deleteById(id);
}
@PostMapping("/{entrustId}")
@ApiOperation("导出报告封面和首页")
public void getReportDetail(@PathVariable("entrustId") Integer entrustId,
HttpServletResponse response) {
//首页及封面导出
ReportDetailVo rts = iEntrustService.getReportDetail(entrustId);
if (rts == null){
return;
}
Map<String, Object> beanParams = new HashMap<>(10);
beanParams.put("sendName", rts.getSendName());
beanParams.put("sender", rts.getSender());
beanParams.put("sendDate", rts.getSendDate());
beanParams.put("sampleNum", rts.getSampleNum());
beanParams.put("sampleNames", set2String(rts.getSampleNames()));
beanParams.put("teamNames", set2String(rts.getTeamNames()));
beanParams.put("methodNames", set2StringN(rts.getMethodNames()));
beanParams.put("equipmentNames", set2StringN(rts.getEquipmentNames()));
beanParams.put("projectName", rts.getProjectName());
beanParams.put("printDate", rts.getPrintDate());
//六元素导出
List<SixElementReport> list = iEntrustService.getSampleSixElementCheck(entrustId);
list.forEach(this::initMapStr2AlongPro);
List<SixElementReport> al2o3AndTio2List = list.stream()
.filter(arg -> !"-".equals(arg.getAl2o3AndTio2()))
.collect(Collectors.toList());
List<SixElementReport> al2o3SplitTio2List = list.stream()
.filter(arg -> "-".equals(arg.getAl2o3AndTio2()))
.collect(Collectors.toList());
beanParams.put("list1", al2o3AndTio2List);
beanParams.put("list2", al2o3SplitTio2List);
//化学工业导出
List<IndustrialReport> list1 = iEntrustService.getSampleIndustrialCheck(entrustId);
list1.forEach(this::initMapStr2AlongPro);
beanParams.put("list3",list1);
WordUtil.writeWordReport(rts.getProjectName() + "(报告)", "report.ftl",
beanParams, response, FileExt.EXCL);
}
/**
* 将样品六元素检测Map转换成单独属性
*
* @param sixElement 带转换的六元素检测结果
* @return 已转换结果
*/
private void initMapStr2AlongPro(SixElementReport sixElement) {
String countResult = sixElement.getCountResults();
HashMap<String, String> countResultMap = JSON.parseObject(countResult, HashMap.class);
sixElement.setAl2o3("-");
sixElement.setTio2("-");
sixElement.setAl2o3AndTio2("-");
//判断检测结果中六元素Al2O3是否包含TiO2
if (countResultMap.containsKey(SixElementKey.Al2O3AndTiO2.getKey())) {
sixElement.setAl2o3AndTio2(countResultMap.get(SixElementKey.Al2O3AndTiO2.getKey()));
} else {
sixElement.setAl2o3(countResultMap.getOrDefault(SixElementKey.Al2O3.getKey(), "0"));
sixElement.setTio2(countResultMap.getOrDefault(SixElementKey.TiO2.getKey(), "0"));
}
sixElement.setCao(countResultMap.getOrDefault(SixElementKey.CaO.getKey(), "0"));
sixElement.setCl(countResultMap.getOrDefault(SixElementKey.Cl.getKey(), "0"));
sixElement.setFe2o3(countResultMap.getOrDefault(SixElementKey.Fe2O3.getKey(), "0"));
sixElement.setLoi(countResultMap.getOrDefault(SixElementKey.LOI.getKey(), "0"));
sixElement.setMgo(countResultMap.getOrDefault(SixElementKey.MgO.getKey(), "0"));
sixElement.setSio2(countResultMap.getOrDefault(SixElementKey.SiO2.getKey(), "0"));
sixElement.setSo3(countResultMap.getOrDefault(SixElementKey.SO3.getKey(), "0"));
}
private void initMapStr2AlongPro(IndustrialReport industrialReport){
String countResult = industrialReport.getCountResults();
HashMap<String, String> countResultMap = JSON.parseObject(countResult, HashMap.class);
industrialReport.setAad(countResultMap.getOrDefault(IndustrialElementKey.Aad.getKey(),"0"));
industrialReport.setJz(countResultMap.getOrDefault(IndustrialElementKey.JZ.getKey(),"0"));
industrialReport.setMad(countResultMap.getOrDefault(IndustrialElementKey.Mad.getKey(),"0"));
industrialReport.setMjkg(countResultMap.getOrDefault(IndustrialElementKey.QnetAdMJkg.getKey(),"0"));
industrialReport.setStad(countResultMap.getOrDefault(IndustrialElementKey.StAd.getKey(),"0"));
industrialReport.setVad(countResultMap.getOrDefault(IndustrialElementKey.Vad.getKey(),"0"));
}
private String set2String(Set<String> source) {
if (source.size() == 0) {
return "";
}
StringBuilder strBuilder = new StringBuilder();
for (String target : source) {
strBuilder.append("、").append(target);
}
return strBuilder.replace(0, 1, "").toString();
}
private String set2StringN(Set<String> source) {
if (source.size() == 0) {
return "";
}
StringBuilder strBuilder = new StringBuilder();
for (String target : source) {
strBuilder.append("&#10;").append(target);
}
return strBuilder.replace(0, 5, "").toString();
}
}
package cn.wise.sc.cement.business.controller;
import cn.hutool.core.util.StrUtil;
import cn.wise.sc.cement.business.model.BaseResponse;
import cn.wise.sc.cement.business.service.impl.WeiXinService;
import cn.wise.sc.cement.business.wrapper.WrapMapper;
import cn.wise.sc.cement.business.wrapper.Wrapper;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.apache.commons.lang3.StringUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
......@@ -13,73 +13,116 @@ import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import javax.servlet.http.HttpServletRequest;
import java.security.MessageDigest;
import java.security.NoSuchAlgorithmException;
import java.util.Date;
import java.util.HashMap;
import java.util.Map;
@Api(tags = "微信接口")
@RestController
@RequestMapping("/tcdri/weixin")
public class WeiXinController {
private static final Logger log = LoggerFactory.getLogger("WeiXinController");
@Autowired
private WeiXinService weiXinService;
@ApiOperation(value = "获取登录token-小程序端")
@GetMapping("/getToken")
public BaseResponse getToken(String code) {
try {
return weiXinService.getToken(code, "APP");
} catch (Exception e) {
log.debug("获取登录token{}", e);
}
return BaseResponse.errorMsg("失败!");
}
@ApiOperation(value = "获取登录token-管理端")
@GetMapping("/getPCToken")
public BaseResponse getPCToken(String code) {
try {
return weiXinService.getToken(code, "PC");
} catch (Exception e) {
log.debug("获取登录token{}", e);
}
return BaseResponse.errorMsg("失败!");
}
@ApiOperation(value = "获取accessToken信息-小程序端")
@GetMapping("/getAccessToken")
public BaseResponse getAccessToken() {
try {
String accessToken = weiXinService.getAccessToken();
return BaseResponse.okData(accessToken);
} catch (Exception e) {
log.debug("获取accessToken信息-小程序端{}", e);
}
return BaseResponse.errorMsg("失败!");
}
@ApiOperation(value = "获取accessToken信息-管理端")
@GetMapping("/getPCAccessToken")
public BaseResponse getPCAccessToken() {
try {
String accessToken = weiXinService.getPCAccessToken();
return BaseResponse.okData(accessToken);
} catch (Exception e) {
log.debug("获取accessToken信息-管理端{}", e);
}
return BaseResponse.errorMsg("失败!");
}
@ApiOperation(value = "当前登录用户")
@GetMapping("/getLoginUser")
public BaseResponse getLoginUser() {
try {
return weiXinService.getLoginUser();
} catch (Exception e) {
log.debug("当前登录用户{}", e);
}
return BaseResponse.errorMsg("失败!");
}
private static final Logger log = LoggerFactory.getLogger("WeiXinController");
@Autowired
private WeiXinService weiXinService;
@ApiOperation(value = "获取登录token-小程序端")
@GetMapping("/getToken")
public BaseResponse getToken(String code) {
log.debug("============================================");
log.debug("code: {}", code);
log.debug("=============================================");
try {
return weiXinService.getToken(code, "APP");
} catch (Exception e) {
log.debug("获取登录token{}", e);
}
return BaseResponse.errorMsg("失败!");
}
@ApiOperation(value = "获取登录token-管理端")
@GetMapping("/getPCToken")
public BaseResponse getPCToken(String code) {
try {
return weiXinService.getToken(code, "PC");
} catch (Exception e) {
log.debug("获取登录token{}", e);
}
return BaseResponse.errorMsg("失败!");
}
@ApiOperation(value = "当前登录用户")
@GetMapping("/getLoginUser")
public BaseResponse getLoginUser() {
try {
return weiXinService.getLoginUser();
} catch (Exception e) {
log.debug("当前登录用户{}", e);
}
return BaseResponse.errorMsg("失败!");
}
@GetMapping("/jsapiTicket")
@ApiOperation("获取jsapi_ticket")
public BaseResponse<Map> getAccessToken() {
String accessToken = weiXinService.getJsapiTicket();
Map<String, String> rts = new HashMap<>(5);
rts.put("jsapi_ticket", accessToken);
rts.put("timestamp", (new Date()).getTime() / 1000 + "");
rts.put("noncestr", "Wm3WZYTPz0wzccnW");
rts.put("app_id", "ww348f91b2573c1867");
rts.put("jsApiList","['scanQRCode']");
return BaseResponse.okData(rts);
}
@GetMapping("/signature")
@ApiOperation("获取accessToken")
public BaseResponse<String> signature(String param) {
MessageDigest md;
String tmpStr = null;
try {
md = MessageDigest.getInstance("SHA-1");
byte[] digest = md.digest(param.getBytes());
tmpStr = byteToStr(digest);
} catch (NoSuchAlgorithmException e) {
e.printStackTrace();
}
return BaseResponse.okData(StrUtil.swapCase(tmpStr));
}
/**
* 将字节数组转换为十六进制字符串
*
* @param byteArray
* @return
*/
private static String byteToStr(byte[] byteArray) {
String strDigest = "";
for (int i = 0; i < byteArray.length; i++) {
strDigest += byteToHexStr(byteArray[i]);
}
return strDigest;
}
/**
* 将字节转换为十六进制字符串
*
* @param mByte
* @return
*/
private static String byteToHexStr(byte mByte) {
char[] Digit = {'0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'A', 'B', 'C', 'D', 'E', 'F'};
char[] tempArr = new char[2];
tempArr[0] = Digit[(mByte >>> 4) & 0X0F];
tempArr[1] = Digit[mByte & 0X0F];
String s = new String(tempArr);
return s;
}
}
......@@ -4,7 +4,7 @@
<select id="getSampleSixElementCheck" resultType="cn.wise.sc.cement.business.model.SixElementReport">
SELECT * FROM (SELECT count_result,entrust_id,team_group_name,sct.sample_id FROM sample_check sc
SELECT * FROM (SELECT count_results,entrust_id,team_group_name,sct.sample_id FROM sample_check sc
LEFT JOIN
(SELECT check_id,sample_id FROM sample_check_team) sct
ON sct.check_id = sc.id
......@@ -14,12 +14,12 @@
(SELECT cement_code,sample_code,sample_form,`name` as sample_name,weight,id
FROM sample) s
ON s.id = sscct.sample_id AND entrust_id = #{entrustId}
WHERE count_result IS NOT NULL;
WHERE count_results IS NOT NULL;
</select>
<select id="getSampleIndustrialCheck" resultType="cn.wise.sc.cement.business.model.IndustrialReport">
SELECT * FROM (SELECT count_result,entrust_id,team_group_name,sct.sample_id FROM sample_check sc
SELECT * FROM (SELECT count_results,entrust_id,team_group_name,sct.sample_id FROM sample_check sc
LEFT JOIN
(SELECT check_id,sample_id FROM sample_check_team) sct
ON sct.check_id = sc.id
......@@ -29,7 +29,6 @@
(SELECT cement_code,sample_code,sample_form,`name` as sample_name,weight,id
FROM sample) s
ON s.id = sscct.sample_id AND entrust_id = #{entrustId}
WHERE count_result IS NOT NULL;
WHERE count_results IS NOT NULL;
</select>
</mapper>
package cn.wise.sc.cement.business.model;
import lombok.Data;
import java.io.Serializable;
/**
......@@ -12,45 +11,45 @@ import java.io.Serializable;
@Data
public class IndustrialReport implements Serializable {
private static final long serialVersionUID = 42L;
/**
* 样品名称
*/
private String sampleName;
/**
* 来样状态
*/
private String sampleForm;
/**
* 来样编号
*/
private String sampleCode;
/**
* 样品重量
*/
private String weight;
/**
* 本所编号
*/
private String cementCode;
/**
* 校核数据
*/
private String countResult;
//下面是工业特性得检测项
private String mad;
private String aad;
private String vad;
private String mjkg;
private String jz;
private String qnetstad;
private String stad;
private static final long serialVersionUID = 42L;
/**
* 样品名称
*/
private String sampleName;
/**
* 来样状态
*/
private String sampleForm;
/**
* 来样编号
*/
private String sampleCode;
/**
* 样品重量
*/
private String weight;
/**
* 本所编号
*/
private String cementCode;
/**
* 校核数据
*/
private String countResults;
//下面是工业特性得检测项
private String mad;
private String aad;
private String vad;
private String mjkg;
private String jz;
private String qnetstad;
private String stad;
}
package cn.wise.sc.cement.business.model;
/**
* @author: Seven.wk
* @description: 数据返回类
* @create: 2018/07/04
*/
public class ResultVO<T> {
private Integer code;
private String message;
private T data;
public ResultVO() {
}
public ResultVO(Integer code, String message) {
this.code = code;
this.message = message;
}
public ResultVO(Integer code, String message, T data) {
this.code = code;
this.message = message;
this.data = data;
}
public Integer getCode() {
return code;
}
public void setCode(Integer code) {
this.code = code;
}
public String getMessage() {
return message;
}
public void setMessage(String message) {
this.message = message;
}
public T getData() {
return data;
}
public void setData(T data) {
this.data = data;
}
}
......@@ -12,54 +12,54 @@ import java.io.Serializable;
@Data
public class SixElementReport implements Serializable {
private static final long serialVersionUID = 42L;
private static final long serialVersionUID = 42L;
/**
* 样品名称
*/
private String sampleName;
/**
* 样品名称
*/
private String sampleName;
/**
* 来样状态
*/
private String sampleForm;
/**
* 来样状态
*/
private String sampleForm;
/**
* 来样编号
*/
private String sampleCode;
/**
* 来样编号
*/
private String sampleCode;
/**
* 样品重量
*/
private String weight;
/**
* 样品重量
*/
private String weight;
/**
* 本所编号
*/
private String cementCode;
/**
* 本所编号
*/
private String cementCode;
/**
* 校核数据
*/
private String countResult;
/**
* 校核数据
*/
private String countResults;
//下面为六元素
//下面为六元素
private String loi = "";
private String sio2 = "";
private String fe2o3 = "";
private String cao = "";
private String mgo = "";
private String so3 = "";
private String cl = "";
private String loi ="";
private String sio2 ="";
private String fe2o3 ="";
private String cao ="";
private String mgo ="";
private String so3 ="";
private String cl="";
//情况一:Al2O3(含TiO3)
//情况一:Al2O3(含TiO3)
private String al2o3AndTio2 = "";
private String al2o3AndTio2 ="";
//情况二:Al2O3和TiO3单独分开
//情况二:Al2O3和TiO3单独分开
private String al2o3 = "";
private String tio2 = "";
private String al2o3 ="";
private String tio2 ="";
}
......@@ -24,106 +24,102 @@ import java.util.List;
*/
public interface INormProductionService extends IService<NormProduction> {
/**
* 创建新的标准产值配置
*
* @param normProduction 标准产值
* @return BaseResponse
*/
BaseResponse<NormProduction> addObj(NormProduction normProduction);
/**
* 创建新的标准产值配置
*
* @param normProduction 标准产值
* @return BaseResponse
*/
BaseResponse<NormProduction> addObj(NormProduction normProduction);
/**
* 分页查询
*
* @param pageQuery 分页条件
* @return 数据
*/
BaseResponse<IPage<NormProductionVo>> getPage(PageQuery pageQuery);
/**
* 分页查询
*
* @param pageQuery 分页条件
* @return 数据
*/
BaseResponse<IPage<NormProductionVo>> getPage(PageQuery pageQuery);
/**
* 编辑标准产值
*
* @param production 标准产值
* @return bool
*/
BaseResponse<Boolean> edit(NormProduction production);
/**
* 编辑标准产值
*
* @param production 标准产值
* @return bool
*/
BaseResponse<Boolean> edit(NormProduction production);
/**
* 启用禁用标准产值
*
* @param id id
* @return bool
*/
BaseResponse<Integer> activeOrForbidden(Integer id);
/**
* 启用禁用标准产值
*
* @param id id
* @return bool
*/
BaseResponse<Integer> activeOrForbidden(Integer id);
/**
* 标准产值统计
*
* @param start 开始时间
* @param end 结束时间
* @param groupId 部门id
* @return BaseResponse
*/
BaseResponse<List<NormProductionStatistics>> normProductionStatistics(Long start, Long end, String name, Integer groupId);
/**
* 标准产值统计
*
* @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 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 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 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 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 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);
/**
* 统计工作量
* @param startTime 开始时间
* @param endTime 结束时间
* @return 统计对象
*/
List<WorkloadStatisticsVo> workloadStatistics(Date startTime, Date endTime,Integer userId);
}
package cn.wise.sc.cement.business.service.impl;
import cn.wise.sc.cement.business.entity.EntityEnclosure;
import cn.wise.sc.cement.business.entity.TeamGroup;
import cn.wise.sc.cement.business.mapper.EntityEnclosureMapper;
......@@ -9,7 +11,9 @@ import cn.wise.sc.cement.business.model.BaseResponse;
import cn.wise.sc.cement.business.model.query.EnclosureQuery;
import cn.wise.sc.cement.business.service.IEntityEnclosureService;
import cn.wise.sc.cement.business.util.CheckCountUtil;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import io.swagger.models.auth.In;
import org.springframework.beans.factory.annotation.Autowired;
......@@ -34,44 +38,41 @@ public class CommonServiceImpl {
/**
* 生成编号
*
* @param prefix 编号前缀: 申请编号SQ
* @param counts 当天申请数量 生成的编号+1
* @return
*/
public String createNo(String prefix, int counts) {
public String createNo(String prefix, int counts){
SimpleDateFormat sdf = new SimpleDateFormat("yyyyMMdd");//注意月份是MM
String date = sdf.format(new Date());
int nextNo = counts + 1;
String tailNo = counts == 0 ? "00" + nextNo : (counts < 10 ? "00" + nextNo : (counts < 100 ? "0" + nextNo : String.valueOf(nextNo)));
String applyNo = prefix + date + tailNo;
int nextNo = counts+1;
String tailNo = counts==0?"00"+nextNo:(counts<10?"00"+nextNo:(counts<100?"0"+nextNo:String.valueOf(nextNo)));
String applyNo = prefix+date+tailNo;
return applyNo;
}
/**
* 生成平行样编号
*
* @param cementCode
* @return
*/
public String createParallelCode(String cementCode) {
public String createParallelCode(String cementCode){
String[] cementCodes = cementCode.split("-");
Integer counts = Integer.parseInt(cementCodes[1]) + 1;
String tailNo = counts < 10 ? ("000" + counts) :
counts < 100 ? ("00" + counts) :
counts < 1000 ? ("0" + counts) :
Integer counts = Integer.parseInt(cementCodes[1])+1;
String tailNo = counts<10?("000"+counts):
counts<100?("00"+counts):
counts<1000?("0"+counts):
String.valueOf(counts);
String resultCode = cementCodes[0] + "-" + tailNo;
String resultCode = cementCodes[0]+"-"+tailNo;
return resultCode;
}
/**
* 获取本所编号的Integer类型
*
* @param cementCode
* @return
*/
public Integer getIntegerCode(String cementCode) {
public Integer getIntegerCode(String cementCode){
String[] cementCodes = cementCode.split("-");
Integer counts = Integer.parseInt(cementCodes[1]);
return counts;
......@@ -79,11 +80,10 @@ public class CommonServiceImpl {
/**
* 获取本所编号年份的Integer类型
*
* @param cementCode
* @return
*/
public String getIntegerYear(String cementCode) {
public String getIntegerYear(String cementCode){
String[] cementCodes = cementCode.split("-");
String counts = cementCodes[0];
return counts;
......@@ -91,40 +91,39 @@ public class CommonServiceImpl {
/**
* Integer补0 转String
*
* @param counts
* @return
*/
public String getCementCode(Integer counts) {
String tailNo = counts < 10 ? ("000" + counts) :
counts < 100 ? ("00" + counts) :
counts < 1000 ? ("0" + counts) :
String.valueOf(counts);
public String getCementCode(Integer counts){
String tailNo = counts<10?("000"+counts):
counts<100?("00"+counts):
counts<1000?("0"+counts):
String.valueOf(counts);
return tailNo;
}
/**
* 保存附件信息
*
* @param entityType 实体类型(0:用户(头像),1:合同附件,3设备校核附件,4标样材料)
* @param entityId 关联实体类id
* @param entityType 实体类型(0:用户(头像),1:合同附件,3设备校核附件,4标样材料)
* @param entityId 关联实体类id
* @param enclosureQueryList 上传的附件列表
*/
public Boolean saveEntityEnclosure(Integer entityType, Integer entityId, List<EnclosureQuery> enclosureQueryList) {
public Boolean saveEntityEnclosure(Integer entityType, Integer entityId, List<EnclosureQuery> enclosureQueryList ){
Boolean ref = false;
QueryWrapper<EntityEnclosure> wrapper = new QueryWrapper<>();
wrapper.eq("entity_type", entityType);
wrapper.eq("entity_id", entityId);
List<EntityEnclosure> entityEnclosureList = entityEnclosureMapper.selectList(wrapper);
if (entityEnclosureList != null && entityEnclosureList.size() > 0) {
for (EntityEnclosure eeOld : entityEnclosureList) {
if(entityEnclosureList != null && entityEnclosureList.size()>0){
for(EntityEnclosure eeOld : entityEnclosureList){
eeOld.setIsDeleted(0);
entityEnclosureMapper.updateById(eeOld);
}
}
if (enclosureQueryList != null && enclosureQueryList.size() > 0) {
if(enclosureQueryList != null && enclosureQueryList.size()>0){
List<EntityEnclosure> eeList = new ArrayList<>();
for (int i = 0; i < enclosureQueryList.size(); i++) {
for(int i = 0; i < enclosureQueryList.size(); i++){
EnclosureQuery enclosureDto = enclosureQueryList.get(i);
EntityEnclosure ee = new EntityEnclosure();
ee.setEntityId(entityId);
......@@ -145,12 +144,11 @@ public class CommonServiceImpl {
/**
* 根据实体类型 和实体类id获取附件列表
*
* @param entityType 实体类型(0:用户(头像),1:合同附件,3设备校核附件,4标样材料)
* @param entityId 关联实体类id
* @param entityType 实体类型(0:用户(头像),1:合同附件,3设备校核附件,4标样材料)
* @param entityId 关联实体类id
* @return
*/
public List<EntityEnclosure> getEnclosureList(Integer entityType, Integer entityId) {
public List<EntityEnclosure> getEnclosureList(Integer entityType, Integer entityId){
QueryWrapper<EntityEnclosure> wrapper = new QueryWrapper<>();
wrapper.eq("entity_type", entityType);
wrapper.eq("entity_id", entityId);
......@@ -158,84 +156,98 @@ public class CommonServiceImpl {
return entityEnclosureList;
}
//Map转json数组
public JSONArray mapToJSONArray( Map<String, String> map){
JSONArray jsonArray = new JSONArray();
for(Map.Entry<String,String> entry : map.entrySet()){
JSONObject jsonObject = new JSONObject();
jsonObject.put("name",entry.getKey());
jsonObject.put("value",entry.getValue());
jsonArray.add(jsonObject);
}
return jsonArray;
}
/**
*
* @param checkResutlList 检测组id集合
* @param resultMap 输入集合
* @param resultMap 输入集合
* @return
*/
public Map<String, String> checkCount(List<String> checkResutlList, Map<String, Object> resultMap) {
public Map<String, String> checkCount(List<String> checkResutlList, Map<String, String> resultMap ){
// List<String> checkResutlList = teamMapper.getByGroup(teamGroupId);
//定义输出集合
Map<String, String> countMap = new HashMap<>();
//输出检测项第一次循环
for (String name : checkResutlList) {
if (name.equals("L.O.I")) {
countMap.put(name, CheckCountUtil.checkCount(name, resultMap));
} else if (name.equals("SiO2")) {
countMap.put(name, CheckCountUtil.checkCount(name, resultMap));
} else if (name.equals("Al2O3+TiO2")) {
countMap.put(name, CheckCountUtil.checkCount(name, resultMap));
} else if (name.equals("Al2O3")) {
countMap.put(name, CheckCountUtil.checkCount(name, resultMap));
} else if (name.equals("Fe2O3")) {
countMap.put(name, CheckCountUtil.checkCount(name, resultMap));
} else if (name.equals("CaO")) {
countMap.put(name, CheckCountUtil.checkCount(name, resultMap));
} else if (name.equals("MgO")) {
countMap.put(name, CheckCountUtil.checkCount(name, resultMap));
} else if (name.equals("TiO2")) {
countMap.put(name, CheckCountUtil.checkCount(name, resultMap));
} else if (name.equals("重量法_SO3")) {
countMap.put(name, CheckCountUtil.checkCount(name, resultMap));
} else if (name.equals("K2O")) {
countMap.put(name, CheckCountUtil.checkCount(name, resultMap));
} else if (name.equals("Na2O")) {
countMap.put(name, CheckCountUtil.checkCount(name, resultMap));
} else if (name.equals("MnO")) {
countMap.put(name, CheckCountUtil.checkCount(name, resultMap));
} else if (name.equals("Cl")) {
for(String name : checkResutlList){
if(name.equals("L.O.I")){
countMap.put(name,CheckCountUtil.checkCount(name,resultMap));
}else if(name.equals("SiO2")){
countMap.put(name,CheckCountUtil.checkCount(name,resultMap));
}else if(name.equals("Al2O3+TiO2")){
countMap.put(name,CheckCountUtil.checkCount(name,resultMap));
}else if(name.equals("Al2O3")){
countMap.put(name,CheckCountUtil.checkCount(name,resultMap));
}else if(name.equals("Fe2O3")){
countMap.put(name,CheckCountUtil.checkCount(name,resultMap));
}else if(name.equals("CaO")){
countMap.put(name,CheckCountUtil.checkCount(name,resultMap));
}else if(name.equals("MgO")){
countMap.put(name,CheckCountUtil.checkCount(name,resultMap));
}else if(name.equals("TiO2")){
countMap.put(name,CheckCountUtil.checkCount(name,resultMap));
}else if(name.equals("重量法_SO3")){
countMap.put(name,CheckCountUtil.checkCount(name,resultMap));
}else if(name.equals("K2O")){
countMap.put(name,CheckCountUtil.checkCount(name,resultMap));
}else if(name.equals("Na2O")){
countMap.put(name,CheckCountUtil.checkCount(name,resultMap));
}else if(name.equals("MnO")){
countMap.put(name,CheckCountUtil.checkCount(name,resultMap));
}else if(name.equals("Cl")){
countMap.put(name,CheckCountUtil.checkCount(name,resultMap));
}else if(name.equals("Mad1")){
countMap.put(name,CheckCountUtil.checkCount(name,resultMap));
}else if(name.equals("Mad2")){
countMap.put(name,CheckCountUtil.checkCount(name,resultMap));
}else if(name.equals("Aad1")){
countMap.put(name,CheckCountUtil.checkCount(name,resultMap));
}else if(name.equals("Aad2")) {
countMap.put(name, CheckCountUtil.checkCount(name, resultMap));
} else if (name.equals("Mad1")) {
}else if(name.equals("焦渣")){
countMap.put(name, CheckCountUtil.checkCount(name, resultMap));
} else if (name.equals("Mad2")) {
}else if(name.equals("St,ad")){
countMap.put(name, CheckCountUtil.checkCount(name, resultMap));
} else if (name.equals("Aad1")) {
countMap.put(name, CheckCountUtil.checkCount(name, resultMap));
} else if (name.equals("Aad2")) {
countMap.put(name, CheckCountUtil.checkCount(name, resultMap));
} else if (name.equals("焦渣")) {
countMap.put(name, CheckCountUtil.checkCount(name, resultMap));
} else if (name.equals("St,ad")) {
countMap.put(name, CheckCountUtil.checkCount(name, resultMap));
} else if (name.equals("易磨性等级")) {
}else if(name.equals("易磨性等级")){
countMap.put(name, CheckCountUtil.countYMXGrade(resultMap));
} else if (name.equals("易磨性校验码")) {
}else if(name.equals("易磨性校验码")){
countMap.put(name, CheckCountUtil.countYMXCode(resultMap));
}
}
//输出检测项第二次循环
for (String name : checkResutlList) {
if (name.equals("SO3")) {
for(String name : checkResutlList){
if(name.equals("SO3")){
String countSO3 = CheckCountUtil.countSO3(resultMap, countMap);
countMap.put(name, countSO3);
} else if (name.equals("KH")) {
}else if(name.equals("KH")){
String countKH = CheckCountUtil.countKH(countMap);
countMap.put(name, countKH);
} else if (name.equals("SM")) {
}else if(name.equals("SM")){
String countSM = CheckCountUtil.countSM(countMap);
countMap.put(name, countSM);
} else if (name.equals("AM")) {
}else if(name.equals("AM")){
String countAM = CheckCountUtil.countAM(countMap);
countMap.put(name, countAM);
} else if (name.equals("易烧性等级")) {
String burnupLevel = CheckCountUtil.countBurnupLevel(resultMap, countMap);
}else if(name.equals("易烧性等级")){
String burnupLevel = CheckCountUtil.countBurnupLevel(resultMap,countMap);
countMap.put(name, burnupLevel);
} else if (name.equals("报出_Mad")) {
}else if(name.equals("报出_Mad")){
String countBCMad = CheckCountUtil.countBCMad(countMap);
countMap.put(name, countBCMad);
} else if (name.equals("报出_Aad")) {
}else if(name.equals("报出_Aad")){
String countBCAad = CheckCountUtil.countBCAad(countMap);
countMap.put(name, countBCAad);
}
......@@ -243,26 +255,26 @@ public class CommonServiceImpl {
}
//输出检测项第三次循环
for (String name : checkResutlList) {
if (name.equals("合量")) {
for(String name : checkResutlList){
if(name.equals("合量")){
String countHL = CheckCountUtil.countHL(countMap);
countMap.put(name, countHL);
} else if (name.equals("Mad")) {
}else if(name.equals("Mad")){
String countMad = CheckCountUtil.countMad(countMap);
countMap.put(name, countMad);
} else if (name.equals("Aad")) {
}else if(name.equals("Aad")){
String countAad = CheckCountUtil.countAad(countMap);
countMap.put(name, countAad);
} else if (name.equals("Vad1")) {
}else if(name.equals("Vad1")){
String countVad1 = CheckCountUtil.countVad1(resultMap, countMap);
countMap.put(name, countVad1);
} else if (name.equals("Vad2")) {
}else if(name.equals("Vad2")) {
String countVad2 = CheckCountUtil.countVad2(resultMap, countMap);
countMap.put(name, countVad2);
} else if (name.equals("Mad判断")) {
}else if(name.equals("Mad判断")) {
String countMadPD = CheckCountUtil.countMadPD(countMap);
countMap.put(name, countMadPD);
} else if (name.equals("Ad")) {
}else if(name.equals("Ad")) {
String countAd = CheckCountUtil.countAd(countMap);
countMap.put(name, countAd);
}
......@@ -270,14 +282,14 @@ public class CommonServiceImpl {
}
//输出检测项第四次循环
for (String name : checkResutlList) {
if (name.equals("报出_Vad")) {
for(String name : checkResutlList){
if(name.equals("报出_Vad")){
String countBCVad = CheckCountUtil.countBCVad(countMap);
countMap.put(name, countBCVad);
} else if (name.equals("Ad系数0.1或0")) {
}else if(name.equals("Ad系数0.1或0")) {
String countAdXS = CheckCountUtil.countAdXS(countMap);
countMap.put(name, countAdXS);
} else if (name.equals("Vdaf系数0.8~0.95")) {
}else if(name.equals("Vdaf系数0.8~0.95")) {
String countVdafXS = CheckCountUtil.countVdafXS(countMap);
countMap.put(name, countVdafXS);
}
......@@ -285,33 +297,33 @@ public class CommonServiceImpl {
}
//输出检测项第五次循环
for (String name : checkResutlList) {
if (name.equals("Vad")) {
for(String name : checkResutlList){
if(name.equals("Vad")){
String countVad = CheckCountUtil.countVad(countMap);
countMap.put(name, countVad);
}
}
//输出检测项第六次循环
for (String name : checkResutlList) {
if (name.equals("Vdaf")) {
for(String name : checkResutlList){
if(name.equals("Vdaf")){
String countVdaf = CheckCountUtil.countVdaf(countMap);
countMap.put(name, countVdaf);
}
}
//输出检测项第七次循环
for (String name : checkResutlList) {
if (name.equals("K1,")) {
for(String name : checkResutlList){
if(name.equals("K1,")){
String countK1_ = CheckCountUtil.countK1_(countMap);
countMap.put(name, countK1_);
} else if (name.equals("K")) {
}else if(name.equals("K")) {
String countK = CheckCountUtil.countK(resultMap, countMap);
countMap.put(name, countK);
} else if (name.equals("Vdaf判断")) {
}else if(name.equals("Vdaf判断")) {
String countVdafPD = CheckCountUtil.countVdafPD(countMap);
countMap.put(name, countVdafPD);
} else if (name.equals("V,daf")) {
}else if(name.equals("V,daf")) {
String countV_daf = CheckCountUtil.countV_daf(countMap);
countMap.put(name, countV_daf);
}
......@@ -319,25 +331,47 @@ public class CommonServiceImpl {
}
//输出检测项第八次循环
for (String name : checkResutlList) {
if (name.equals("40Mad 0或1")) {
for(String name : checkResutlList){
if(name.equals("40Mad 0或1")){
String count40Mad0Or1 = CheckCountUtil.count40Mad0Or1(countMap);
countMap.put(name, count40Mad0Or1);
} else if (name.equals("K0,")) {
}else if(name.equals("K0,")) {
String countK0_ = CheckCountUtil.countK0_(countMap);
countMap.put(name, countK0_);
}
}
//输出检测项第九次循环
for (String name : checkResutlList) {
if (name.equals("Qnet,ad MJ/kg")) {
for(String name : checkResutlList){
if(name.equals("Qnet,ad MJ/kg")){
String countQnet_adMJ_kg = CheckCountUtil.countQnet_adMJ_kg(resultMap, countMap);
countMap.put(name, countQnet_adMJ_kg);
}
}
return countMap;
}
}
......@@ -50,875 +50,882 @@ import java.util.stream.Collectors;
@Service
public class NormProductionServiceImpl extends ServiceImpl<NormProductionMapper, NormProduction> implements INormProductionService {
final public Map<String, NormProduction> normProductionCache = new HashMap<>();
final
ISampleDistributionService iSampleDistributionService;
final
ISampleHandleService iSampleHandleService;
final
ISysUserService iSysUserService;
final
ISysGroupService iSysGroupService;
final
ISampleCheckTeamService iSampleCheckTeamService;
final
ITeamGroupService iTeamGroupService;
final
IHandleService iHandleService;
final
ISysPostService iSysPostService;
final
INonStandardValueService iNonStandardValueService;
final
INonStandardApplyService iNonStandardApplyService;
public NormProductionServiceImpl(ISampleDistributionService iSampleDistributionService,
ISampleHandleService iSampleHandleService,
ISysUserService iSysUserService,
ISysGroupService iSysGroupService,
ISampleCheckTeamService iSampleCheckTeamService,
ITeamGroupService iTeamGroupService, IHandleService iHandleService,
ISysPostService iSysPostService,
INonStandardValueService iNonStandardValueService,
INonStandardApplyService iNonStandardApplyService) {
this.iSampleDistributionService = iSampleDistributionService;
this.iSampleHandleService = iSampleHandleService;
this.iSysUserService = iSysUserService;
this.iSysGroupService = iSysGroupService;
this.iSampleCheckTeamService = iSampleCheckTeamService;
this.iTeamGroupService = iTeamGroupService;
this.iHandleService = iHandleService;
this.iSysPostService = iSysPostService;
this.iNonStandardValueService = iNonStandardValueService;
this.iNonStandardApplyService = iNonStandardApplyService;
}
@Override
public BaseResponse<NormProduction> addObj(NormProduction normProduction) {
//判断配置项目是否已存在
QueryWrapper<NormProduction> qw = new QueryWrapper<>();
qw.eq("assess_id", normProduction.getAssessId());
qw.eq("type", normProduction.getType());
qw.eq("status", 1);
int count = this.count(qw);
if (count != 0) {
return BaseResponse.errorMsg("当前标准产值已存在!");
}
//判断比例是否为总值100%
if (normProduction.getAnalyseRate()
+ normProduction.getAssessRate()
+ normProduction.getSeparateRate()
+ normProduction.getReportedResultRate() != 1) {
return BaseResponse.errorMsg("百分比总和不等于1");
}
//状态为1
normProduction.setStatus(1);
boolean save = this.save(normProduction);
if (save) {
return BaseResponse.okData(normProduction);
} else {
return BaseResponse.errorMsg("失败!除检测组id之外其他字段必填!");
}
}
@Override
public BaseResponse<IPage<NormProductionVo>> getPage(PageQuery pageQuery) {
IPage<NormProduction> page = new Page<>(pageQuery.getPageNo(), pageQuery.getPageSize());
IPage<NormProduction> productionIPage = this.page(page);
//关联名字
List<NormProduction> normProductions = productionIPage.getRecords();
List<Integer> npTeamGroupIds = new ArrayList<>(normProductions.size());
List<Integer> npHandleIds = new ArrayList<>(normProductions.size());
normProductions.forEach(arg -> {
if (arg.getType() == 1) {
npTeamGroupIds.add(arg.getAssessId());
} else {
npHandleIds.add(arg.getAssessId());
}
});
if (npTeamGroupIds.size() == 0 && npHandleIds.size() == 0) {
return BaseResponse.errorMsg("没找着相关数据!关联检测组失败!");
}
List<Handle> handles = new ArrayList<>();
if (npHandleIds.size() != 0) {
handles = iHandleService.listByIds(npHandleIds);
}
List<TeamGroup> teamGroups = new ArrayList<>();
if (npTeamGroupIds.size() != 0) {
teamGroups = iTeamGroupService.listByIds(npTeamGroupIds);
}
IPage<NormProductionVo> rts = new Page<>(pageQuery.getPageNo(), pageQuery.getPageSize());
List<NormProductionVo> records = new ArrayList<>(pageQuery.getPageSize());
rts.setTotal(productionIPage.getTotal());
rts.setCurrent(productionIPage.getCurrent());
rts.setPages(productionIPage.getPages());
rts.setSize(productionIPage.getSize());
List<TeamGroup> finalTeamGroups = teamGroups;
List<Handle> finalHandles = handles;
normProductions.forEach(arg -> {
NormProductionVo normProductionVo = new NormProductionVo();
BeanUtil.copyProperties(arg, normProductionVo);
normProductionVo.setAssessName("/");
if (arg.getType() == 1) {
finalTeamGroups.stream()
.filter(opt -> opt.getId().intValue() == arg.getAssessId())
.findFirst()
.ifPresent(opt -> normProductionVo.setAssessName(opt.getName()));
} else {
finalHandles.stream()
.filter(opt -> opt.getId().intValue() == arg.getAssessId())
.findFirst()
.ifPresent(opt -> normProductionVo.setAssessName(opt.getName()));
}
records.add(normProductionVo);
});
rts.setRecords(records);
return BaseResponse.okData(rts);
}
@Override
public BaseResponse<Boolean> edit(NormProduction production) {
if (production.getId() == null || production.getId() <= 0) {
return BaseResponse.errorMsg("编号id是必须的!");
}
//判断比例是否为总值100%
if (production.getAnalyseRate()
+ production.getAssessRate()
+ production.getSeparateRate()
+ production.getReportedResultRate() != 1) {
return BaseResponse.errorMsg("百分比总和不等于1");
}
//判断配置项目是否已存在
QueryWrapper<NormProduction> qw = new QueryWrapper<>();
qw.eq("assess_id", production.getAssessId());
qw.eq("type", production.getType());
qw.eq("status", 1);
NormProduction one = this.getOne(qw);
if (one != null && one.getId().intValue() != production.getId()) {
return BaseResponse.errorMsg("当前标准产值已存在!");
}
boolean b = this.updateById(production);
if (b) {
return BaseResponse.okData(true);
} else {
return BaseResponse.errorMsg("修改失败!");
}
}
@Override
public BaseResponse<Integer> activeOrForbidden(Integer id) {
NormProduction normProduction = this.getById(id);
Integer status = normProduction.getStatus();
if (status == 1) {
normProduction.setStatus(0);
this.updateById(normProduction);
return BaseResponse.okData(0);
} else {
normProduction.setStatus(1);
this.updateById(normProduction);
return BaseResponse.okData(1);
}
}
@Override
public BaseResponse<List<NormProductionStatistics>> normProductionStatistics(Long start, Long end, String name, Integer groupId) {
//统计分样处理的详情
List<NormProduction.NormProductionDetail> normProductionDetails =
normProductionDetails(null, start, end);
if (normProductionDetails.size() == 0) {
BaseResponse<List<NormProductionStatistics>> rts = BaseResponse.errorMsg("没找到相关数据!");
rts.setData(new ArrayList<>());
return rts;
}
Map<Integer, BigDecimal> coefficientMap = new HashMap<>(normProductionDetails.size());
normProductionDetails
.forEach(arg -> {
Integer userId = arg.getUserId();
//不存在 添加
if (!coefficientMap.containsKey(userId)) {
coefficientMap.put(userId, arg.getWorkTimeCoefficient());
} else {
BigDecimal bigDecimal = coefficientMap.get(userId);
BigDecimal newWorkTime = arg.getWorkTimeCoefficient().add(bigDecimal);
coefficientMap.put(userId, newWorkTime);
}
});
List<NormProductionStatistics> rts = new ArrayList<>();
Set<Integer> userIds = coefficientMap.keySet();
QueryWrapper<SysUser> qw = new QueryWrapper<>();
qw.in("id", userIds);
List<SysUser> users = iSysUserService.list(qw);
List<SysPost> sysPosts = iSysPostService.list();
List<SysGroup> sysGroups = iSysGroupService.list();
for (Integer userId : coefficientMap.keySet()) {
SysUser sysUser = users.stream()
.filter(arg -> arg.getId().intValue() == userId)
.findFirst().orElse(null);
SysGroup sysGroup = sysGroups.stream().filter(arg -> arg.getId().intValue() == userId)
.findFirst().orElse(null);
if (sysUser == null) {
continue;
}
if (sysGroup == null) {
continue;
}
NormProductionStatistics productionStatistics = new NormProductionStatistics();
productionStatistics.setAccount(sysUser.getUsername());
productionStatistics.setCoefficient(coefficientMap.get(userId).doubleValue());
productionStatistics.setTime("/");
productionStatistics.setCount(normProductionDetails.stream()
.filter(arg -> arg.getUserId().intValue() == sysUser.getId())
.count());
productionStatistics.setPosition(sysUser.getQualifications());
if (start != null && end != null) {
DateTime startTime = DateUtil.date(start);
DateTime endTime = DateUtil.date(end);
productionStatistics.setTime(startTime.toDateStr() + "-" + endTime.toDateStr());
}
productionStatistics.setSex(sysUser.getSex() == 0 ? "女" : "男");
productionStatistics.setUserId(sysUser.getId() + "");
productionStatistics.setUserName(sysUser.getName());
productionStatistics.setGroupId(sysUser.getGroupId());
productionStatistics.setGroupName(sysGroup.getName());
SysPost sysPost = sysPosts.stream()
.filter(arg -> arg.getId().intValue() == sysUser.getPostId()).
findFirst().orElse(null);
SysGroup sysGroup1 = sysGroups.stream()
.filter(arg -> arg.getId().intValue() == sysGroup.getId()).
findFirst().orElse(null);
productionStatistics.setPosition(sysPost == null ? "职务一" : sysPost.getName());
productionStatistics.setGroupName(sysGroup == null ? "部门名" : sysGroup.getName());
rts.add(productionStatistics);
}
//过滤名字
if (StrUtil.isNotBlank(name)) {
List<NormProductionStatistics> collect = rts.stream().filter(arg -> arg.getUserName().contains(name)).collect(Collectors.toList());
return BaseResponse.okData(collect);
}
//过滤部门id
if (groupId != null) {
List<NormProductionStatistics> collect = rts.stream().filter(arg -> arg.getGroupId().equals(groupId)).collect(Collectors.toList());
return BaseResponse.okData(collect);
}
return BaseResponse.okData(rts);
}
@Override
public List<NormProduction.NormProductionDetail> normProductionDetails(
Integer userId, Long start, Long end) {
/*
* 计算的地方: 分样派发和分样处理表
* userId == null,计算所有人数据。
* userId != null,计算单人时间线的数据。
* 当start==0&&end==0时计算历史所有数据
*
* 过程:
* 1.获取分样派发表数据,然后获取标准产值配置,它的检测组相同。
* 3.每条记录*标准产值计算出来的结果。==>得出详情信息。
* 处理项目:
* 1.获取处理派发表数据,获取标准产值配置,查询处理项。
* */
//获取标准产值数据
QueryWrapper<SampleDistribution> qwDis = new QueryWrapper<>();
QueryWrapper<SampleHandle> qwHan = new QueryWrapper<>();
QueryWrapper<SampleCheckTeam> qwCT = new QueryWrapper<>();
Map<String, Object> params = new HashMap<>(2);
if (userId != null && userId > 0) {
qwDis.eq("user_id", userId);
qwHan.eq("user_id", userId);
qwCT.eq("user_id", userId);
params.put("user_id", userId);
}
if (start != null && end != null) {
DateTime startTime = DateUtil.date(start);
DateTime endTime = DateUtil.date(end);
qwDis.between("finish_time", startTime, endTime);
qwHan.between("finish_time", startTime, endTime);
qwCT.between("finish_time", startTime, endTime);
params.put("start_time", DateUtil.format(startTime, "yyyy-MM-dd"));
params.put("end_time", DateUtil.format(endTime, "yyyy-MM-dd"));
}
//计算分析任务单产值
List<NormProduction.NormProductionDetail> sampleDistributionDetail = calculateSampleDistributionOptimize(params);
//计算处理任务单产值
List<NormProduction.NormProductionDetail> sampleHandleDetail = calculateSampleHandle(qwHan);
//todo 计算校核任务单产值
final public Map<String, NormProduction> normProductionCache = new HashMap<>();
final
ISampleDistributionService iSampleDistributionService;
final
ISampleHandleService iSampleHandleService;
final
ISysUserService iSysUserService;
final
ISysGroupService iSysGroupService;
final
ISampleCheckTeamService iSampleCheckTeamService;
final
ITeamGroupService iTeamGroupService;
final
IHandleService iHandleService;
final
ISysPostService iSysPostService;
final
INonStandardValueService iNonStandardValueService;
final
INonStandardApplyService iNonStandardApplyService;
public NormProductionServiceImpl(ISampleDistributionService iSampleDistributionService,
ISampleHandleService iSampleHandleService,
ISysUserService iSysUserService,
ISysGroupService iSysGroupService,
ISampleCheckTeamService iSampleCheckTeamService,
ITeamGroupService iTeamGroupService, IHandleService iHandleService,
ISysPostService iSysPostService,
INonStandardValueService iNonStandardValueService,
INonStandardApplyService iNonStandardApplyService) {
this.iSampleDistributionService = iSampleDistributionService;
this.iSampleHandleService = iSampleHandleService;
this.iSysUserService = iSysUserService;
this.iSysGroupService = iSysGroupService;
this.iSampleCheckTeamService = iSampleCheckTeamService;
this.iTeamGroupService = iTeamGroupService;
this.iHandleService = iHandleService;
this.iSysPostService = iSysPostService;
this.iNonStandardValueService = iNonStandardValueService;
this.iNonStandardApplyService = iNonStandardApplyService;
}
@Override
public BaseResponse<NormProduction> addObj(NormProduction normProduction) {
//判断配置项目是否已存在
QueryWrapper<NormProduction> qw = new QueryWrapper<>();
qw.eq("assess_id", normProduction.getAssessId());
qw.eq("type", normProduction.getType());
qw.eq("status", 1);
int count = this.count(qw);
if (count != 0) {
return BaseResponse.errorMsg("当前标准产值已存在!");
}
//判断比例是否为总值100%
if (normProduction.getAnalyseRate()
+ normProduction.getAssessRate()
+ normProduction.getSeparateRate()
+ normProduction.getReportedResultRate() != 1) {
return BaseResponse.errorMsg("百分比总和不等于1");
}
//状态为1
normProduction.setStatus(1);
boolean save = this.save(normProduction);
if (save) {
return BaseResponse.okData(normProduction);
} else {
return BaseResponse.errorMsg("失败!除检测组id之外其他字段必填!");
}
}
@Override
public BaseResponse<IPage<NormProductionVo>> getPage(PageQuery pageQuery) {
IPage<NormProduction> page = new Page<>(pageQuery.getPageNo(), pageQuery.getPageSize());
IPage<NormProduction> productionIPage = this.page(page);
//关联名字
List<NormProduction> normProductions = productionIPage.getRecords();
List<Integer> npTeamGroupIds = new ArrayList<>(normProductions.size());
List<Integer> npHandleIds = new ArrayList<>(normProductions.size());
normProductions.forEach(arg -> {
if (arg.getType() == 1) {
npTeamGroupIds.add(arg.getAssessId());
} else {
npHandleIds.add(arg.getAssessId());
}
});
if (npTeamGroupIds.size() == 0 && npHandleIds.size() == 0) {
return BaseResponse.errorMsg("没找着相关数据!关联检测组失败!");
}
List<Handle> handles = new ArrayList<>();
if (npHandleIds.size() != 0) {
handles = iHandleService.listByIds(npHandleIds);
}
List<TeamGroup> teamGroups = new ArrayList<>();
if (npTeamGroupIds.size() != 0) {
teamGroups = iTeamGroupService.listByIds(npTeamGroupIds);
}
IPage<NormProductionVo> rts = new Page<>(pageQuery.getPageNo(), pageQuery.getPageSize());
List<NormProductionVo> records = new ArrayList<>(pageQuery.getPageSize());
rts.setTotal(productionIPage.getTotal());
rts.setCurrent(productionIPage.getCurrent());
rts.setPages(productionIPage.getPages());
rts.setSize(productionIPage.getSize());
List<TeamGroup> finalTeamGroups = teamGroups;
List<Handle> finalHandles = handles;
normProductions.forEach(arg -> {
NormProductionVo normProductionVo = new NormProductionVo();
BeanUtil.copyProperties(arg, normProductionVo);
normProductionVo.setAssessName("/");
if (arg.getType() == 1) {
finalTeamGroups.stream()
.filter(opt -> opt.getId().intValue() == arg.getAssessId())
.findFirst()
.ifPresent(opt -> normProductionVo.setAssessName(opt.getName()));
} else {
finalHandles.stream()
.filter(opt -> opt.getId().intValue() == arg.getAssessId())
.findFirst()
.ifPresent(opt -> normProductionVo.setAssessName(opt.getName()));
}
records.add(normProductionVo);
});
rts.setRecords(records);
return BaseResponse.okData(rts);
}
@Override
public BaseResponse<Boolean> edit(NormProduction production) {
if (production.getId() == null || production.getId() <= 0) {
return BaseResponse.errorMsg("编号id是必须的!");
}
//判断比例是否为总值100%
if (production.getAnalyseRate()
+ production.getAssessRate()
+ production.getSeparateRate()
+ production.getReportedResultRate() != 1) {
return BaseResponse.errorMsg("百分比总和不等于1");
}
//判断配置项目是否已存在
QueryWrapper<NormProduction> qw = new QueryWrapper<>();
qw.eq("assess_id", production.getAssessId());
qw.eq("type", production.getType());
qw.eq("status", 1);
NormProduction one = this.getOne(qw);
if (one != null && one.getId().intValue() != production.getId()) {
return BaseResponse.errorMsg("当前标准产值已存在!");
}
boolean b = this.updateById(production);
if (b) {
return BaseResponse.okData(true);
} else {
return BaseResponse.errorMsg("修改失败!");
}
}
@Override
public BaseResponse<Integer> activeOrForbidden(Integer id) {
NormProduction normProduction = this.getById(id);
Integer status = normProduction.getStatus();
if (status == 1) {
normProduction.setStatus(0);
this.updateById(normProduction);
return BaseResponse.okData(0);
} else {
normProduction.setStatus(1);
this.updateById(normProduction);
return BaseResponse.okData(1);
}
}
@Override
public BaseResponse<List<NormProductionStatistics>> normProductionStatistics(Long start, Long end, String name, Integer groupId) {
//统计分样处理的详情
List<NormProduction.NormProductionDetail> normProductionDetails =
normProductionDetails(null, start, end);
if (normProductionDetails.size() == 0) {
BaseResponse<List<NormProductionStatistics>> rts = BaseResponse.errorMsg("没找到相关数据!");
rts.setData(new ArrayList<>());
return rts;
}
Map<Integer, BigDecimal> coefficientMap = new HashMap<>(normProductionDetails.size());
normProductionDetails
.forEach(arg -> {
Integer userId = arg.getUserId();
//不存在 添加
if (!coefficientMap.containsKey(userId)) {
coefficientMap.put(userId, arg.getWorkTimeCoefficient());
} else {
BigDecimal bigDecimal = coefficientMap.get(userId);
BigDecimal newWorkTime = arg.getWorkTimeCoefficient().add(bigDecimal);
coefficientMap.put(userId, newWorkTime);
}
});
List<NormProductionStatistics> rts = new ArrayList<>();
Set<Integer> userIds = coefficientMap.keySet();
QueryWrapper<SysUser> qw = new QueryWrapper<>();
qw.in("id", userIds);
List<SysUser> users = iSysUserService.list(qw);
List<SysPost> sysPosts = iSysPostService.list();
List<SysGroup> sysGroups = iSysGroupService.list();
for (Integer userId : coefficientMap.keySet()) {
SysUser sysUser = users.stream()
.filter(arg -> arg.getId().intValue() == userId)
.findFirst().orElse(null);
SysGroup sysGroup = sysGroups.stream().filter(arg -> arg.getId().intValue() == userId)
.findFirst().orElse(null);
if (sysUser == null) {
continue;
}
if (sysGroup == null) {
continue;
}
NormProductionStatistics productionStatistics = new NormProductionStatistics();
productionStatistics.setAccount(sysUser.getUsername());
productionStatistics.setCoefficient(coefficientMap.get(userId).doubleValue());
productionStatistics.setTime("/");
productionStatistics.setCount(normProductionDetails.stream()
.filter(arg -> arg.getUserId().intValue() == sysUser.getId())
.count());
productionStatistics.setPosition(sysUser.getQualifications());
if (start != null && end != null) {
DateTime startTime = DateUtil.date(start);
DateTime endTime = DateUtil.date(end);
productionStatistics.setTime(startTime.toDateStr() + "-" + endTime.toDateStr());
}
productionStatistics.setSex(sysUser.getSex() == 0 ? "女" : "男");
productionStatistics.setUserId(sysUser.getId() + "");
productionStatistics.setUserName(sysUser.getName());
productionStatistics.setGroupId(sysUser.getGroupId());
productionStatistics.setGroupName(sysGroup.getName());
SysPost sysPost = sysPosts.stream()
.filter(arg -> arg.getId().intValue() == sysUser.getPostId()).
findFirst().orElse(null);
SysGroup sysGroup1 = sysGroups.stream()
.filter(arg -> arg.getId().intValue() == sysGroup.getId()).
findFirst().orElse(null);
productionStatistics.setPosition(sysPost == null ? "职务一" : sysPost.getName());
productionStatistics.setGroupName(sysGroup == null ? "部门名" : sysGroup.getName());
rts.add(productionStatistics);
}
//过滤名字
if (StrUtil.isNotBlank(name)) {
List<NormProductionStatistics> collect = rts.stream().filter(arg -> arg.getUserName().contains(name)).collect(Collectors.toList());
return BaseResponse.okData(collect);
}
//过滤部门id
if (groupId != null) {
List<NormProductionStatistics> collect = rts.stream().filter(arg -> arg.getGroupId().equals(groupId)).collect(Collectors.toList());
return BaseResponse.okData(collect);
}
return BaseResponse.okData(rts);
}
@Override
public List<NormProduction.NormProductionDetail> normProductionDetails(
Integer userId, Long start, Long end) {
/*
* 计算的地方: 分样派发和分样处理表
* userId == null,计算所有人数据。
* userId != null,计算单人时间线的数据。
* 当start==0&&end==0时计算历史所有数据
*
* 过程:
* 1.获取分样派发表数据,然后获取标准产值配置,它的检测组相同。
* 3.每条记录*标准产值计算出来的结果。==>得出详情信息。
* 处理项目:
* 1.获取处理派发表数据,获取标准产值配置,查询处理项。
* */
//获取标准产值数据
QueryWrapper<SampleDistribution> qwDis = new QueryWrapper<>();
QueryWrapper<SampleHandle> qwHan = new QueryWrapper<>();
QueryWrapper<SampleCheckTeam> qwCT = new QueryWrapper<>();
Map<String, Object> params = new HashMap<>(2);
if (userId != null && userId > 0) {
qwDis.eq("user_id", userId);
qwHan.eq("user_id", userId);
qwCT.eq("user_id", userId);
params.put("user_id", userId);
}
if (start != null && end != null) {
DateTime startTime = DateUtil.date(start);
DateTime endTime = DateUtil.date(end);
qwDis.between("finish_time", startTime, endTime);
qwHan.between("finish_time", startTime, endTime);
qwCT.between("finish_time", startTime, endTime);
params.put("start_time", DateUtil.format(startTime, "yyyy-MM-dd"));
params.put("end_time", DateUtil.format(endTime, "yyyy-MM-dd"));
}
//计算分析任务单产值
List<NormProduction.NormProductionDetail> sampleDistributionDetail = calculateSampleDistributionOptimize(params);
//计算处理任务单产值
List<NormProduction.NormProductionDetail> sampleHandleDetail = calculateSampleHandle(qwHan);
//todo 计算校核任务单产值
// List<NormProduction.NormProductionDetail> sampleCheckTeamDetail = calculateSampleCheck(qwCT);
//todo 计算报出结果产值
List<NormProduction.NormProductionDetail> rts = new ArrayList<>(
sampleDistributionDetail.size()
+ sampleHandleDetail.size());
rts.addAll(sampleDistributionDetail);
rts.addAll(sampleHandleDetail);
//关联用户名字
List<Integer> userIds = rts.stream()
.map(NormProduction.NormProductionDetail::getUserId)
.collect(Collectors.toList());
if (userIds.size() == 0) {
return new ArrayList<>();
}
List<SysUser> users = iSysUserService.listByIds(userIds);
rts.forEach(arg -> users.stream()
.filter(opt -> opt.getId().intValue() == arg.getUserId())
.findFirst()
.ifPresent(sysUser -> arg.setUserName(sysUser.getName())));
return rts;
}
@Override
public List<ProductionVo> production(String name, Long start, Long end, Integer groupId) {
Date startDate = null;
Date endDate = new Date();
if (start != null && start != 0) {
startDate = DateUtil.date(start);
}
if (end != null && end != 0) {
endDate = DateUtil.date(end);
}
//非标准产值
List<NonStandardValue> nonStandardValues = iNonStandardValueService.nonValue(startDate, endDate, groupId).getData();
//标准产值
List<NormProductionStatistics> productionStatistics = this.normProductionStatistics(start, end, name, groupId).getData();
//以userId找关系
Set<String> userIds = new HashSet<>();
nonStandardValues.forEach(arg -> userIds.add(arg.getUserId() + ""));
productionStatistics.forEach(arg -> userIds.add(arg.getUserId()));
List<ProductionVo> rts = new ArrayList<>(userIds.size());
userIds.forEach(arg -> {
ProductionVo productionVo = new ProductionVo();
productionVo.setUserId(arg);
//找到标准准产值里面的数据
productionStatistics.forEach(opt -> {
if (opt.getUserId().equals(arg)) {
productionVo.setProductionValue(opt.getCoefficient());
productionVo.setUserName(opt.getUserName());
productionVo.setPosition(opt.getPosition());
productionVo.setAccount(opt.getAccount());
productionVo.setGroupId(opt.getGroupId());
productionVo.setGroupName(opt.getGroupName());
}
});
//找到标准产值里面的数据
nonStandardValues.forEach(opt -> {
if (arg.equals(opt.getUserId() + "")) {
productionVo.setNonProductionValue(opt.getFinalValue());
}
});
rts.add(productionVo);
});
//处理非标准产值没有用名职位信息
QueryWrapper<SysUser> qw = new QueryWrapper<>();
qw.in("id", userIds);
List<SysUser> users = iSysUserService.list(qw);
List<SysPost> sysPosts = iSysPostService.list();
List<SysGroup> sysGroups = iSysGroupService.list();
Date finalStartDate = startDate;
Date finalEndDate = endDate;
rts.forEach(arg -> {
arg.setTime(finalStartDate == null ? "/" : DateUtil.format(finalStartDate, "yyyy-MM-dd") + "--" + DateUtil.format(finalEndDate, "yyyy-MM-dd"));
if (StrUtil.isBlank(arg.getUserName())) {
//关联用户信息
users.stream().filter(opt -> arg.getUserId().equals(opt.getId() + "")).findFirst()
.ifPresent(opt -> {
arg.setUserName(opt.getName());
arg.setAccount(opt.getUsername());
arg.setPositionId(opt.getPostId());
arg.setGroupId(opt.getGroupId());
});
//关联职务
sysPosts.stream().filter(opt -> arg.getPositionId().intValue() == opt.getId())
.findFirst()
.ifPresent(opt -> arg.setPosition(opt.getName()));
sysGroups.stream().filter(opt -> arg.getGroupId().intValue() == opt.getId())
.findFirst()
.ifPresent(opt -> arg.setGroupName(opt.getName()));
}
arg.setProductionTotalValue(arg.getNonProductionValue() + arg.getProductionValue());
});
//过滤名字
if (StrUtil.isNotBlank(name)) {
return rts.stream().filter(arg -> arg.getUserName().contains(name))
.collect(Collectors.toList());
}
//过滤部门id
if (groupId != null) {
return rts.stream().filter(arg -> arg.getGroupId().equals(groupId))
.collect(Collectors.toList());
}
return rts;
}
@Override
public void exportNormProductionStatistics(Long start, Long end, String name, Integer groupId, HttpServletResponse response) {
BaseResponse<List<NormProductionStatistics>> listBaseResponse = normProductionStatistics(start, end, name, groupId);
if (listBaseResponse.getCode() == 200) {
List<NormProductionStatistics> data = listBaseResponse.getData();
if (CollectionUtil.isNotEmpty(data)) {
String[] headers = new String[10];
headers[0] = "用户编号";
headers[1] = "用户名";
headers[2] = "账号";
headers[3] = "性别";
headers[4] = "职务";
headers[5] = "统计时间";
headers[6] = "检测项目数";
headers[7] = "产值绩效";
headers[8] = "部门id";
headers[9] = "部门名";
List<Object[]> exportData = new ArrayList<>(data.size());
for (NormProductionStatistics productionStatistics : data) {
Object[] objs = new Object[10];
objs[0] = productionStatistics.getUserId();
objs[1] = productionStatistics.getUserName();
objs[2] = productionStatistics.getAccount();
objs[3] = productionStatistics.getSex();
objs[4] = productionStatistics.getPosition();
objs[5] = productionStatistics.getTime();
objs[6] = productionStatistics.getCount();
objs[7] = productionStatistics.getCoefficient();
objs[8] = productionStatistics.getGroupId();
objs[9] = productionStatistics.getGroupName();
exportData.add(objs);
}
ExcelUtil.excelExport(
"标准产值统计", headers,
exportData, response);
}
}
}
@Override
public void exportNormProductionDetail(Integer userId, Long startTime, Long endTime, HttpServletResponse response) {
List<NormProduction.NormProductionDetail> normProductionDetails = normProductionDetails(userId, startTime, endTime);
if (CollectionUtil.isNotEmpty(normProductionDetails)) {
String[] headers = new String[13];
headers[0] = "序号";
headers[1] = "名字";
headers[2] = "检测项目";
headers[3] = "所属项目";
headers[4] = "项目编号";
headers[5] = "检测时间";
headers[6] = "分析占比";
headers[7] = "分样占比";
headers[8] = "校核占比";
headers[9] = "报结果占比";
headers[10] = "合计";
List<Object[]> exportData = new ArrayList<>(normProductionDetails.size());
int count = 0;
DateTimeFormatter timeFormatter = DateTimeFormatter.ofPattern("yyyy年MM月dd日 hh:mm:ss");
for (NormProduction.NormProductionDetail target : normProductionDetails) {
Object[] objs = new Object[13];
objs[0] = count++;
objs[1] = target.getUserName();
objs[2] = target.getGroupTeamName();
objs[3] = target.getProjectName();
objs[4] = target.getEntrustCode();
objs[5] = target.getCheckTime() == null ? "/" : target.getCheckTime().format(timeFormatter);
objs[6] = target.getAnalyseRate();
objs[7] = target.getSeparateRate();
objs[8] = target.getAssessRate();
objs[9] = target.getReportedResultRate();
objs[10] = target.getWorkTimeCoefficient();
exportData.add(objs);
}
ExcelUtil.excelExport("标准产值详情—" + normProductionDetails.get(0).getUserName(), headers, exportData, response);
}
}
@Override
public void exportProduction(String name, Long startTime, Long endTime, Integer groupId, HttpServletResponse response) {
List<ProductionVo> data = production(name, startTime, endTime, groupId);
if (CollectionUtil.isNotEmpty(data)) {
String[] headers = new String[10];
headers[0] = "序号";
headers[1] = "姓名";
headers[2] = "账户";
headers[3] = "职务";
headers[4] = "统计时间";
headers[5] = "标准产值";
headers[6] = "非标准产值";
headers[7] = "产值统计";
headers[8] = "部门id";
headers[9] = "部门名";
List<Object[]> exportData = new ArrayList<>(data.size());
int count = 0;
for (ProductionVo target : data) {
Object[] objs = new Object[10];
objs[0] = count++;
objs[1] = target.getUserName();
objs[2] = target.getAccount();
objs[3] = target.getPosition();
objs[4] = target.getTime();
objs[5] = target.getProductionValue();
objs[6] = target.getNonProductionValue();
objs[7] = target.getProductionTotalValue();
objs[8] = target.getGroupId();
objs[9] = target.getGroupName();
exportData.add(objs);
}
ExcelUtil.excelExport("产值统计", headers, exportData, response);
}
}
@Override
public List<WorkloadStatisticsVo> workloadStatistics(Date startTime, Date endTime) {
long start = getDefaultStart(startTime == null ? 0 : startTime.getTime());
long end = getDefaultEnd(endTime.getTime());
Map<String, Integer> map1 = initMonthMoneyMap(start, end);
Map<String, Integer> map2 = initMonthMoneyMap(start, end);
QueryWrapper<SampleDistribution> qw = new QueryWrapper<>();
if (startTime != null) {
qw.ge("finish_time", DateUtil.format(DateUtil.date(start), "yyyy-MM-dd"));
}
qw.le("finish_time", DateUtil.format(DateUtil.date(end), "yyyy-MM-dd"));
qw.eq("status", 2);
List<SampleDistribution> sampleDistributions = iSampleDistributionService.list(qw);
//脾气比能力大 蠢货
QueryWrapper<NonStandardApply> qwA = new QueryWrapper<>();
if (startTime != null) {
qwA.ge("start_time", DateUtil.format(DateUtil.date(start), "yyyy-MM-dd"));
}
qwA.le("start_time", DateUtil.format(DateUtil.date(end), "yyyy-MM-dd"));
qwA.eq("status", 2);
List<NonStandardApply> nonStandardApplies = iNonStandardApplyService.list(qwA);
for (SampleDistribution sampleDistribution : sampleDistributions) {
addCount(sampleDistribution.getFinishTime(), map1);
}
for (NonStandardApply nonStandardApply : nonStandardApplies) {
addCount(nonStandardApply.getStartTime(), map2);
}
WorkloadStatisticsVo workloadStatisticsVo = new WorkloadStatisticsVo();
workloadStatisticsVo.setType(0);
workloadStatisticsVo.setMap(map1);
WorkloadStatisticsVo workloadStatisticsVo2 = new WorkloadStatisticsVo();
workloadStatisticsVo2.setType(1);
workloadStatisticsVo2.setMap(map2);
List<WorkloadStatisticsVo> rts = new ArrayList<>(2);
rts.add(workloadStatisticsVo);
rts.add(workloadStatisticsVo2);
return rts;
}
private void addCount(LocalDateTime date, Map<String, Integer> map) {
Date nextDate = DateUtil.endOfMonth(asDate(date));
map.put(nextDate.getMonth() + 1 + "", map.get(nextDate.getMonth() + 1 + "") + 1);
}
private void addCount(LocalDate date, Map<String, Integer> map) {
Date nextDate = DateUtil.endOfMonth(asDate(date));
map.put(nextDate.getMonth() + 1 + "", map.get(nextDate.getMonth() + 1 + "") + 1);
}
private static Date asDate(LocalDate localDate) {
return Date.from(localDate.atStartOfDay().atZone(ZoneId.systemDefault()).toInstant());
}
private static Date asDate(LocalDateTime localDateTime) {
return Date.from(localDateTime.atZone(ZoneId.systemDefault()).toInstant());
}
private Map<String, Integer> initMonthMoneyMap(long start, long end) {
Map<String, Integer> map = new LinkedHashMap();
for (long i = start; i <= end; i = DateUtil.offsetMonth(DateUtil.date(i), 1).getTime()) {
map.put(DateUtil.endOfMonth(DateUtil.date(i)).getMonth() + 1 + "", 0);
}
return map;
}
private static long getDefaultStart(long start) {
//如果没传时间进来 默认开始时间是今天开始时间
if (start == 0) {
start = System.currentTimeMillis();
start = DateUtil.beginOfYear(DateUtil.date(start)).getTime();
}
return start;
}
private static long getDefaultEnd(long end) {
//如果没传时间进来 默认开始时间是今天开始时间
if (end == 0) {
end = System.currentTimeMillis();
end = DateUtil.endOfYear(DateUtil.date(end)).getTime();
}
return end;
}
/**
* 计算处理派发单每条数据的标准产值
*
* @param qwHan 统计条件
* @return 处理任务详情
*/
private List<NormProduction.NormProductionDetail> calculateSampleHandle(QueryWrapper<SampleHandle> qwHan) {
//计算处理的绩效
List<SampleHandle> sampleHandles = iSampleHandleService.list(qwHan);
List<EntrustSample> entrustSamples = iSampleHandleService.getEntrustSample();
List<NormProduction.NormProductionDetail> rts = new ArrayList<>(sampleHandles.size());
List<Integer> handleIds = new ArrayList<>();
sampleHandles.forEach(arg -> {
String idsStr = arg.getContent();
String[] split = idsStr.split("、");
try {
for (String idStr : split) {
handleIds.add(Integer.parseInt(idStr));
}
} catch (NumberFormatException ex) {
throw new RuntimeException("处理项目的id传的有问题呀!");
}
});
if (handleIds.size() == 0) {
return new ArrayList<>();
}
List<Handle> handles = iHandleService.listByIds(handleIds);
//获取每一次派发单的数据
for (SampleHandle sampleHandle : sampleHandles) {
//判断是否已经配置了
EntrustSample entrustSample = entrustSamples.stream()
.filter(arg -> arg.getDistributionId().intValue() == sampleHandle.getId())
.findFirst().orElse(null);
if (entrustSample == null) {
continue;
}
//处理项是多个处理ids 、分割
String content = sampleHandle.getContent();
String[] split = content.split("、");
List<Integer> ids = new ArrayList<>(split.length);
try {
for (String idStr : split) {
ids.add(Integer.parseInt(idStr));
}
} catch (NumberFormatException ex) {
throw new RuntimeException("处理项目的id传的有问题呀!");
}
for (Integer handleId : ids) {
String key = handleId + ":" + "0";
//判断缓存是否存在
if (!normProductionCache.containsKey(key)) {
//初始化
initNormProductionCache();
}
NormProduction normProduction = normProductionCache.get(key);
Handle handle = handles.stream()
.filter(arg -> arg.getId().intValue() == handleId)
.findFirst().orElse(null);
if (normProduction == null || handle == null) {
//如果没有配置 标准产值设置 跳过不计算
continue;
}
NormProduction.NormProductionDetail productionDetail =
initNormProductionDetail(entrustSample, normProduction, normProduction.getAnalyseRate());
productionDetail.setUserId(sampleHandle.getUserId());
productionDetail.setCheckTime(sampleHandle.getAcceptTime());
productionDetail.setDistributionId(sampleHandle.getId());
productionDetail.setAssessId(handleId);
productionDetail.setGroupTeamName(handle.getName());
rts.add(productionDetail);
}
}
return rts;
}
/**
* 计算分析派发单每条数据的标准产值
*
* @param param 统计条件
* @return 分析任务详情
*/
private List<NormProduction.NormProductionDetail> calculateSampleDistributionOptimize
(Map<String, Object> param) {
List<EntrustSample> entrustSamples = iSampleDistributionService.getSampleDistribution(param);
List<NormProduction.NormProductionDetail> rts = new ArrayList<>(entrustSamples.size());
List<Integer> groupTeamIds = entrustSamples.stream().map(EntrustSample::getTeamGroupId).collect(Collectors.toList());
if (groupTeamIds.size() == 0) {
return new ArrayList<>();
}
List<TeamGroup> teamGroups = iTeamGroupService.listByIds(groupTeamIds);
for (EntrustSample entrustSample : entrustSamples) {
TeamGroup teamGroup = teamGroups.stream()
.filter(arg -> arg.getId().intValue() == entrustSample.getTeamGroupId())
.findFirst().orElse(null);
if (entrustSample == null || teamGroup == null) {
continue;
}
String key = entrustSample.getTeamGroupId() + ":" + "1";
//判断缓存是否存在
if (!normProductionCache.containsKey(key)) {
//初始化
initNormProductionCache();
}
NormProduction normProduction = normProductionCache.get(key);
if (normProduction == null) {
//如果没有配置 标准产值设置 跳过不计算
continue;
}
NormProduction.NormProductionDetail productionDetail =
initNormProductionDetail(entrustSample, normProduction, normProduction.getAnalyseRate());
productionDetail.setUserId(entrustSample.getUserId());
productionDetail.setCheckTime(entrustSample.getFinishTime());
productionDetail.setDistributionId(entrustSample.getDistributionId());
productionDetail.setAssessId(entrustSample.getTeamGroupId());
productionDetail.setGroupTeamName(teamGroup.getName());
rts.add(productionDetail);
}
return rts;
}
/**
* 计算分析派发单每条数据的标准产值
*
* @param qwDis 统计条件
* @return 分析任务详情
* @Deprecated 已废弃, 有替代方法
* @see NormProductionServiceImpl#calculateSampleDistributionOptimize
*/
@Deprecated
private List<NormProduction.NormProductionDetail> calculateSampleDistribution
(QueryWrapper<SampleDistribution> qwDis) {
List<SampleDistribution> distributions = iSampleDistributionService.list(qwDis);
List<EntrustSample> entrustSamples = iSampleDistributionService.getEntrustSample();
List<NormProduction.NormProductionDetail> rts = new ArrayList<>(distributions.size());
List<Integer> groupTeamIds = distributions.stream().map(SampleDistribution::getTeamGroupId).collect(Collectors.toList());
if (groupTeamIds.size() == 0) {
return new ArrayList<>();
}
List<TeamGroup> teamGroups = iTeamGroupService.listByIds(groupTeamIds);
//获取每一次派发单的数据
for (SampleDistribution distribution : distributions) {
//判断是否已经配置了
EntrustSample entrustSample = entrustSamples.stream()
.filter(arg -> arg.getDistributionId().intValue() == distribution.getId())
.findFirst().orElse(null);
TeamGroup teamGroup = teamGroups.stream()
.filter(arg -> arg.getId().intValue() == distribution.getTeamGroupId())
.findFirst().orElse(null);
if (entrustSample == null || teamGroup == null) {
continue;
}
String key = distribution.getTeamGroupId() + ":" + "1";
//判断缓存是否存在
if (!normProductionCache.containsKey(key)) {
//初始化
initNormProductionCache();
}
NormProduction normProduction = normProductionCache.get(key);
if (normProduction == null) {
//如果没有配置 标准产值设置 跳过不计算
continue;
}
NormProduction.NormProductionDetail productionDetail =
initNormProductionDetail(entrustSample, normProduction, normProduction.getAnalyseRate());
productionDetail.setUserId(distribution.getUserId());
productionDetail.setCheckTime(distribution.getAcceptTime());
productionDetail.setDistributionId(distribution.getId());
productionDetail.setAssessId(distribution.getTeamGroupId());
productionDetail.setGroupTeamName(teamGroup.getName());
rts.add(productionDetail);
}
return rts;
}
/**
* 初始化产值明细
*
* @param entrustSample 分样任务
* @param normProduction 标准产值配置表
* @return 标准产值明细
*/
private NormProduction.NormProductionDetail initNormProductionDetail(
EntrustSample entrustSample, NormProduction normProduction, Double rate) {
NormProduction.NormProductionDetail productionDetail =
new NormProduction.NormProductionDetail();
productionDetail.setAnalyseRate(normProduction.getAnalyseRate());
productionDetail.setAssessRate(normProduction.getAssessRate());
productionDetail.setSeparateRate(normProduction.getSeparateRate());
productionDetail.setReportedResultRate(normProduction.getReportedResultRate());
productionDetail.setAssessId(normProduction.getAssessId());
productionDetail.setEntrustId(entrustSample.getEntrustId());
productionDetail.setProjectName(entrustSample.getProjectName());
productionDetail.setSampleName(entrustSample.getSampleName());
productionDetail.setSampleId(entrustSample.getSampleId());
productionDetail.setEntrustCode(entrustSample.getEntrustCode());
productionDetail.setWorkTimeCoefficient(calculateWorkTimeCoefficient(normProduction,
rate));
return productionDetail;
}
/**
* 初始化标准产值缓存
*/
private void initNormProductionCache() {
QueryWrapper<NormProduction> qw = new QueryWrapper<>();
qw.eq("status", 1);
List<NormProduction> list = this.list(qw);
for (NormProduction normProduction : list) {
String key = normProduction.getAssessId() + ":" + normProduction.getType();
normProductionCache.put(key, normProduction);
}
}
/**
* 计算标准产值的工时标准系数 plan
* 额定工日*建议系数/报出对应分析结果*考核工值*分析占比
*
* @param normProduction 标准产值配置对象 如:六元素
* @param rate 具体的操作占比 如:统计分析 85%
* @return BigDecimal
*/
private BigDecimal calculateWorkTimeCoefficient(NormProduction normProduction, Double rate) {
//计算出工时标准系数:
//额定工日*建议系数/报出对应分析结果*考核工值*分析占比
BigDecimal quotaDayBig = BigDecimal.valueOf(normProduction.getQuotaDay());
BigDecimal coefficientBig = BigDecimal.valueOf(normProduction.getCoefficient());
BigDecimal reportedAnalyseRtsBig = BigDecimal.valueOf(normProduction.getReportedAnalyseResult());
BigDecimal assessValueBig = BigDecimal.valueOf(normProduction.getAssessValue());
BigDecimal analyseRateBig = BigDecimal.valueOf(rate);
return quotaDayBig.multiply(coefficientBig)
.divide(reportedAnalyseRtsBig, 6, RoundingMode.HALF_DOWN)
.multiply(assessValueBig).multiply(analyseRateBig)
.setScale(6, RoundingMode.HALF_DOWN);
}
//todo 计算报出结果产值
List<NormProduction.NormProductionDetail> rts = new ArrayList<>(
sampleDistributionDetail.size()
+ sampleHandleDetail.size());
rts.addAll(sampleDistributionDetail);
rts.addAll(sampleHandleDetail);
//关联用户名字
List<Integer> userIds = rts.stream()
.map(NormProduction.NormProductionDetail::getUserId)
.collect(Collectors.toList());
if (userIds.size() == 0) {
return new ArrayList<>();
}
List<SysUser> users = iSysUserService.listByIds(userIds);
rts.forEach(arg -> users.stream()
.filter(opt -> opt.getId().intValue() == arg.getUserId())
.findFirst()
.ifPresent(sysUser -> arg.setUserName(sysUser.getName())));
return rts;
}
@Override
public List<ProductionVo> production(String name, Long start, Long end, Integer groupId) {
Date startDate = null;
Date endDate = new Date();
if (start != null && start != 0) {
startDate = DateUtil.date(start);
}
if (end != null && end != 0) {
endDate = DateUtil.date(end);
}
//非标准产值
List<NonStandardValue> nonStandardValues = iNonStandardValueService.nonValue(startDate, endDate, groupId).getData();
//标准产值
List<NormProductionStatistics> productionStatistics = this.normProductionStatistics(start, end, name, groupId).getData();
//以userId找关系
Set<String> userIds = new HashSet<>();
nonStandardValues.forEach(arg -> userIds.add(arg.getUserId() + ""));
productionStatistics.forEach(arg -> userIds.add(arg.getUserId()));
List<ProductionVo> rts = new ArrayList<>(userIds.size());
userIds.forEach(arg -> {
ProductionVo productionVo = new ProductionVo();
productionVo.setUserId(arg);
//找到标准准产值里面的数据
productionStatistics.forEach(opt -> {
if (opt.getUserId().equals(arg)) {
productionVo.setProductionValue(opt.getCoefficient());
productionVo.setUserName(opt.getUserName());
productionVo.setPosition(opt.getPosition());
productionVo.setAccount(opt.getAccount());
productionVo.setGroupId(opt.getGroupId());
productionVo.setGroupName(opt.getGroupName());
}
});
//找到标准产值里面的数据
nonStandardValues.forEach(opt -> {
if (arg.equals(opt.getUserId() + "")) {
productionVo.setNonProductionValue(opt.getFinalValue());
}
});
rts.add(productionVo);
});
//处理非标准产值没有用名职位信息
QueryWrapper<SysUser> qw = new QueryWrapper<>();
qw.in("id", userIds);
List<SysUser> users = iSysUserService.list(qw);
List<SysPost> sysPosts = iSysPostService.list();
List<SysGroup> sysGroups = iSysGroupService.list();
Date finalStartDate = startDate;
Date finalEndDate = endDate;
rts.forEach(arg -> {
arg.setTime(finalStartDate == null ? "/" : DateUtil.format(finalStartDate, "yyyy-MM-dd") + "--" + DateUtil.format(finalEndDate, "yyyy-MM-dd"));
if (StrUtil.isBlank(arg.getUserName())) {
//关联用户信息
users.stream().filter(opt -> arg.getUserId().equals(opt.getId() + "")).findFirst()
.ifPresent(opt -> {
arg.setUserName(opt.getName());
arg.setAccount(opt.getUsername());
arg.setPositionId(opt.getPostId());
arg.setGroupId(opt.getGroupId());
});
//关联职务
sysPosts.stream().filter(opt -> arg.getPositionId().intValue() == opt.getId())
.findFirst()
.ifPresent(opt -> arg.setPosition(opt.getName()));
sysGroups.stream().filter(opt -> arg.getGroupId().intValue() == opt.getId())
.findFirst()
.ifPresent(opt -> arg.setGroupName(opt.getName()));
}
arg.setProductionTotalValue(arg.getNonProductionValue() + arg.getProductionValue());
});
//过滤名字
if (StrUtil.isNotBlank(name)) {
return rts.stream().filter(arg -> arg.getUserName().contains(name))
.collect(Collectors.toList());
}
//过滤部门id
if (groupId != null) {
return rts.stream().filter(arg -> arg.getGroupId().equals(groupId))
.collect(Collectors.toList());
}
return rts;
}
@Override
public void exportNormProductionStatistics(Long start, Long end, String name, Integer groupId, HttpServletResponse response) {
BaseResponse<List<NormProductionStatistics>> listBaseResponse = normProductionStatistics(start, end, name, groupId);
if (listBaseResponse.getCode() == 200) {
List<NormProductionStatistics> data = listBaseResponse.getData();
if (CollectionUtil.isNotEmpty(data)) {
String[] headers = new String[10];
headers[0] = "用户编号";
headers[1] = "用户名";
headers[2] = "账号";
headers[3] = "性别";
headers[4] = "职务";
headers[5] = "统计时间";
headers[6] = "检测项目数";
headers[7] = "产值绩效";
headers[8] = "部门id";
headers[9] = "部门名";
List<Object[]> exportData = new ArrayList<>(data.size());
for (NormProductionStatistics productionStatistics : data) {
Object[] objs = new Object[10];
objs[0] = productionStatistics.getUserId();
objs[1] = productionStatistics.getUserName();
objs[2] = productionStatistics.getAccount();
objs[3] = productionStatistics.getSex();
objs[4] = productionStatistics.getPosition();
objs[5] = productionStatistics.getTime();
objs[6] = productionStatistics.getCount();
objs[7] = productionStatistics.getCoefficient();
objs[8] = productionStatistics.getGroupId();
objs[9] = productionStatistics.getGroupName();
exportData.add(objs);
}
ExcelUtil.excelExport(
"标准产值统计", headers,
exportData, response);
}
}
}
@Override
public void exportNormProductionDetail(Integer userId, Long startTime, Long endTime, HttpServletResponse response) {
List<NormProduction.NormProductionDetail> normProductionDetails = normProductionDetails(userId, startTime, endTime);
if (CollectionUtil.isNotEmpty(normProductionDetails)) {
String[] headers = new String[13];
headers[0] = "序号";
headers[1] = "名字";
headers[2] = "检测项目";
headers[3] = "所属项目";
headers[4] = "项目编号";
headers[5] = "检测时间";
headers[6] = "分析占比";
headers[7] = "分样占比";
headers[8] = "校核占比";
headers[9] = "报结果占比";
headers[10] = "合计";
List<Object[]> exportData = new ArrayList<>(normProductionDetails.size());
int count = 0;
DateTimeFormatter timeFormatter = DateTimeFormatter.ofPattern("yyyy年MM月dd日 hh:mm:ss");
for (NormProduction.NormProductionDetail target : normProductionDetails) {
Object[] objs = new Object[13];
objs[0] = count++;
objs[1] = target.getUserName();
objs[2] = target.getGroupTeamName();
objs[3] = target.getProjectName();
objs[4] = target.getEntrustCode();
objs[5] = target.getCheckTime() == null ? "/" : target.getCheckTime().format(timeFormatter);
objs[6] = target.getAnalyseRate();
objs[7] = target.getSeparateRate();
objs[8] = target.getAssessRate();
objs[9] = target.getReportedResultRate();
objs[10] = target.getWorkTimeCoefficient();
exportData.add(objs);
}
ExcelUtil.excelExport("标准产值详情—" + normProductionDetails.get(0).getUserName(), headers, exportData, response);
}
}
@Override
public void exportProduction(String name, Long startTime, Long endTime, Integer groupId, HttpServletResponse response) {
List<ProductionVo> data = production(name, startTime, endTime, groupId);
if (CollectionUtil.isNotEmpty(data)) {
String[] headers = new String[10];
headers[0] = "序号";
headers[1] = "姓名";
headers[2] = "账户";
headers[3] = "职务";
headers[4] = "统计时间";
headers[5] = "标准产值";
headers[6] = "非标准产值";
headers[7] = "产值统计";
headers[8] = "部门id";
headers[9] = "部门名";
List<Object[]> exportData = new ArrayList<>(data.size());
int count = 0;
for (ProductionVo target : data) {
Object[] objs = new Object[10];
objs[0] = count++;
objs[1] = target.getUserName();
objs[2] = target.getAccount();
objs[3] = target.getPosition();
objs[4] = target.getTime();
objs[5] = target.getProductionValue();
objs[6] = target.getNonProductionValue();
objs[7] = target.getProductionTotalValue();
objs[8] = target.getGroupId();
objs[9] = target.getGroupName();
exportData.add(objs);
}
ExcelUtil.excelExport("产值统计", headers, exportData, response);
}
}
@Override
public List<WorkloadStatisticsVo> workloadStatistics(Date startTime, Date endTime, Integer userId) {
long start = getDefaultStart(startTime == null ? 0 : startTime.getTime());
long end = getDefaultEnd(endTime.getTime());
Map<String, Integer> map1 = initMonthMoneyMap(start, end);
Map<String, Integer> map2 = initMonthMoneyMap(start, end);
QueryWrapper<SampleDistribution> qw = new QueryWrapper<>();
if (startTime != null) {
qw.ge("finish_time", DateUtil.format(DateUtil.date(start), "yyyy-MM-dd"));
}
if (userId != null && userId != 0) {
qw.eq("user_id", userId);
}
qw.le("finish_time", DateUtil.format(DateUtil.date(end), "yyyy-MM-dd"));
qw.eq("status", 2);
List<SampleDistribution> sampleDistributions = iSampleDistributionService.list(qw);
QueryWrapper<NonStandardApply> qwA = new QueryWrapper<>();
if (startTime != null) {
qwA.ge("start_time", DateUtil.format(DateUtil.date(start), "yyyy-MM-dd"));
}
if (userId != null && userId != 0) {
qwA.eq("user_id", userId);
}
qwA.le("start_time", DateUtil.format(DateUtil.date(end), "yyyy-MM-dd"));
qwA.eq("status", 2);
List<NonStandardApply> nonStandardApplies = iNonStandardApplyService.list(qwA);
for (SampleDistribution sampleDistribution : sampleDistributions) {
addCount(sampleDistribution.getFinishTime(), map1);
}
for (NonStandardApply nonStandardApply : nonStandardApplies) {
addCount(nonStandardApply.getStartTime(), map2);
}
WorkloadStatisticsVo workloadStatisticsVo = new WorkloadStatisticsVo();
workloadStatisticsVo.setType(0);
workloadStatisticsVo.setMap(map1);
WorkloadStatisticsVo workloadStatisticsVo2 = new WorkloadStatisticsVo();
workloadStatisticsVo2.setType(1);
workloadStatisticsVo2.setMap(map2);
List<WorkloadStatisticsVo> rts = new ArrayList<>(2);
rts.add(workloadStatisticsVo);
rts.add(workloadStatisticsVo2);
return rts;
}
private void addCount(LocalDateTime date, Map<String, Integer> map) {
Date nextDate = DateUtil.endOfMonth(asDate(date));
map.put(nextDate.getMonth() + 1 + "", map.get(nextDate.getMonth() + 1 + "") + 1);
}
private void addCount(LocalDate date, Map<String, Integer> map) {
Date nextDate = DateUtil.endOfMonth(asDate(date));
map.put(nextDate.getMonth() + 1 + "", map.get(nextDate.getMonth() + 1 + "") + 1);
}
private static Date asDate(LocalDate localDate) {
return Date.from(localDate.atStartOfDay().atZone(ZoneId.systemDefault()).toInstant());
}
private static Date asDate(LocalDateTime localDateTime) {
return Date.from(localDateTime.atZone(ZoneId.systemDefault()).toInstant());
}
private Map<String, Integer> initMonthMoneyMap(long start, long end) {
Map<String, Integer> map = new LinkedHashMap();
for (long i = start; i <= end; i = DateUtil.offsetMonth(DateUtil.date(i), 1).getTime()) {
map.put(DateUtil.endOfMonth(DateUtil.date(i)).getMonth() + 1 + "", 0);
}
return map;
}
private static long getDefaultStart(long start) {
//如果没传时间进来 默认开始时间是今天开始时间
if (start == 0) {
start = System.currentTimeMillis();
start = DateUtil.beginOfYear(DateUtil.date(start)).getTime();
}
return start;
}
private static long getDefaultEnd(long end) {
//如果没传时间进来 默认开始时间是今天开始时间
if (end == 0) {
end = System.currentTimeMillis();
end = DateUtil.endOfYear(DateUtil.date(end)).getTime();
}
return end;
}
/**
* 计算处理派发单每条数据的标准产值
*
* @param qwHan 统计条件
* @return 处理任务详情
*/
private List<NormProduction.NormProductionDetail> calculateSampleHandle(QueryWrapper<SampleHandle> qwHan) {
//计算处理的绩效
List<SampleHandle> sampleHandles = iSampleHandleService.list(qwHan);
List<EntrustSample> entrustSamples = iSampleHandleService.getEntrustSample();
List<NormProduction.NormProductionDetail> rts = new ArrayList<>(sampleHandles.size());
List<Integer> handleIds = new ArrayList<>();
sampleHandles.forEach(arg -> {
String idsStr = arg.getContent();
String[] split = idsStr.split("、");
try {
for (String idStr : split) {
handleIds.add(Integer.parseInt(idStr));
}
} catch (NumberFormatException ex) {
throw new RuntimeException("处理项目的id传的有问题呀!");
}
});
if (handleIds.size() == 0) {
return new ArrayList<>();
}
List<Handle> handles = iHandleService.listByIds(handleIds);
//获取每一次派发单的数据
for (SampleHandle sampleHandle : sampleHandles) {
//判断是否已经配置了
EntrustSample entrustSample = entrustSamples.stream()
.filter(arg -> arg.getDistributionId().intValue() == sampleHandle.getId())
.findFirst().orElse(null);
if (entrustSample == null) {
continue;
}
//处理项是多个处理ids 、分割
String content = sampleHandle.getContent();
String[] split = content.split("、");
List<Integer> ids = new ArrayList<>(split.length);
try {
for (String idStr : split) {
ids.add(Integer.parseInt(idStr));
}
} catch (NumberFormatException ex) {
throw new RuntimeException("处理项目的id传的有问题呀!");
}
for (Integer handleId : ids) {
String key = handleId + ":" + "0";
//判断缓存是否存在
if (!normProductionCache.containsKey(key)) {
//初始化
initNormProductionCache();
}
NormProduction normProduction = normProductionCache.get(key);
Handle handle = handles.stream()
.filter(arg -> arg.getId().intValue() == handleId)
.findFirst().orElse(null);
if (normProduction == null || handle == null) {
//如果没有配置 标准产值设置 跳过不计算
continue;
}
NormProduction.NormProductionDetail productionDetail =
initNormProductionDetail(entrustSample, normProduction, normProduction.getAnalyseRate());
productionDetail.setUserId(sampleHandle.getUserId());
productionDetail.setCheckTime(sampleHandle.getAcceptTime());
productionDetail.setDistributionId(sampleHandle.getId());
productionDetail.setAssessId(handleId);
productionDetail.setGroupTeamName(handle.getName());
rts.add(productionDetail);
}
}
return rts;
}
/**
* 计算分析派发单每条数据的标准产值
*
* @param param 统计条件
* @return 分析任务详情
*/
private List<NormProduction.NormProductionDetail> calculateSampleDistributionOptimize
(Map<String, Object> param) {
List<EntrustSample> entrustSamples = iSampleDistributionService.getSampleDistribution(param);
List<NormProduction.NormProductionDetail> rts = new ArrayList<>(entrustSamples.size());
List<Integer> groupTeamIds = entrustSamples.stream().map(EntrustSample::getTeamGroupId).collect(Collectors.toList());
if (groupTeamIds.size() == 0) {
return new ArrayList<>();
}
List<TeamGroup> teamGroups = iTeamGroupService.listByIds(groupTeamIds);
for (EntrustSample entrustSample : entrustSamples) {
TeamGroup teamGroup = teamGroups.stream()
.filter(arg -> arg.getId().intValue() == entrustSample.getTeamGroupId())
.findFirst().orElse(null);
if (entrustSample == null || teamGroup == null) {
continue;
}
String key = entrustSample.getTeamGroupId() + ":" + "1";
//判断缓存是否存在
if (!normProductionCache.containsKey(key)) {
//初始化
initNormProductionCache();
}
NormProduction normProduction = normProductionCache.get(key);
if (normProduction == null) {
//如果没有配置 标准产值设置 跳过不计算
continue;
}
NormProduction.NormProductionDetail productionDetail =
initNormProductionDetail(entrustSample, normProduction, normProduction.getAnalyseRate());
productionDetail.setUserId(entrustSample.getUserId());
productionDetail.setCheckTime(entrustSample.getFinishTime());
productionDetail.setDistributionId(entrustSample.getDistributionId());
productionDetail.setAssessId(entrustSample.getTeamGroupId());
productionDetail.setGroupTeamName(teamGroup.getName());
rts.add(productionDetail);
}
return rts;
}
/**
* 计算分析派发单每条数据的标准产值
*
* @param qwDis 统计条件
* @return 分析任务详情
* @Deprecated 已废弃, 有替代方法
* @see NormProductionServiceImpl#calculateSampleDistributionOptimize
*/
@Deprecated
private List<NormProduction.NormProductionDetail> calculateSampleDistribution
(QueryWrapper<SampleDistribution> qwDis) {
List<SampleDistribution> distributions = iSampleDistributionService.list(qwDis);
List<EntrustSample> entrustSamples = iSampleDistributionService.getEntrustSample();
List<NormProduction.NormProductionDetail> rts = new ArrayList<>(distributions.size());
List<Integer> groupTeamIds = distributions.stream().map(SampleDistribution::getTeamGroupId).collect(Collectors.toList());
if (groupTeamIds.size() == 0) {
return new ArrayList<>();
}
List<TeamGroup> teamGroups = iTeamGroupService.listByIds(groupTeamIds);
//获取每一次派发单的数据
for (SampleDistribution distribution : distributions) {
//判断是否已经配置了
EntrustSample entrustSample = entrustSamples.stream()
.filter(arg -> arg.getDistributionId().intValue() == distribution.getId())
.findFirst().orElse(null);
TeamGroup teamGroup = teamGroups.stream()
.filter(arg -> arg.getId().intValue() == distribution.getTeamGroupId())
.findFirst().orElse(null);
if (entrustSample == null || teamGroup == null) {
continue;
}
String key = distribution.getTeamGroupId() + ":" + "1";
//判断缓存是否存在
if (!normProductionCache.containsKey(key)) {
//初始化
initNormProductionCache();
}
NormProduction normProduction = normProductionCache.get(key);
if (normProduction == null) {
//如果没有配置 标准产值设置 跳过不计算
continue;
}
NormProduction.NormProductionDetail productionDetail =
initNormProductionDetail(entrustSample, normProduction, normProduction.getAnalyseRate());
productionDetail.setUserId(distribution.getUserId());
productionDetail.setCheckTime(distribution.getAcceptTime());
productionDetail.setDistributionId(distribution.getId());
productionDetail.setAssessId(distribution.getTeamGroupId());
productionDetail.setGroupTeamName(teamGroup.getName());
rts.add(productionDetail);
}
return rts;
}
/**
* 初始化产值明细
*
* @param entrustSample 分样任务
* @param normProduction 标准产值配置表
* @return 标准产值明细
*/
private NormProduction.NormProductionDetail initNormProductionDetail(
EntrustSample entrustSample, NormProduction normProduction, Double rate) {
NormProduction.NormProductionDetail productionDetail =
new NormProduction.NormProductionDetail();
productionDetail.setAnalyseRate(normProduction.getAnalyseRate());
productionDetail.setAssessRate(normProduction.getAssessRate());
productionDetail.setSeparateRate(normProduction.getSeparateRate());
productionDetail.setReportedResultRate(normProduction.getReportedResultRate());
productionDetail.setAssessId(normProduction.getAssessId());
productionDetail.setEntrustId(entrustSample.getEntrustId());
productionDetail.setProjectName(entrustSample.getProjectName());
productionDetail.setSampleName(entrustSample.getSampleName());
productionDetail.setSampleId(entrustSample.getSampleId());
productionDetail.setEntrustCode(entrustSample.getEntrustCode());
productionDetail.setWorkTimeCoefficient(calculateWorkTimeCoefficient(normProduction,
rate));
return productionDetail;
}
/**
* 初始化标准产值缓存
*/
private void initNormProductionCache() {
QueryWrapper<NormProduction> qw = new QueryWrapper<>();
qw.eq("status", 1);
List<NormProduction> list = this.list(qw);
for (NormProduction normProduction : list) {
String key = normProduction.getAssessId() + ":" + normProduction.getType();
normProductionCache.put(key, normProduction);
}
}
/**
* 计算标准产值的工时标准系数 plan
* 额定工日*建议系数/报出对应分析结果*考核工值*分析占比
*
* @param normProduction 标准产值配置对象 如:六元素
* @param rate 具体的操作占比 如:统计分析 85%
* @return BigDecimal
*/
private BigDecimal calculateWorkTimeCoefficient(NormProduction normProduction, Double rate) {
//计算出工时标准系数:
//额定工日*建议系数/报出对应分析结果*考核工值*分析占比
BigDecimal quotaDayBig = BigDecimal.valueOf(normProduction.getQuotaDay());
BigDecimal coefficientBig = BigDecimal.valueOf(normProduction.getCoefficient());
BigDecimal reportedAnalyseRtsBig = BigDecimal.valueOf(normProduction.getReportedAnalyseResult());
BigDecimal assessValueBig = BigDecimal.valueOf(normProduction.getAssessValue());
BigDecimal analyseRateBig = BigDecimal.valueOf(rate);
return quotaDayBig.multiply(coefficientBig)
.divide(reportedAnalyseRtsBig, 6, RoundingMode.HALF_DOWN)
.multiply(assessValueBig).multiply(analyseRateBig)
.setScale(6, RoundingMode.HALF_DOWN);
}
}
......@@ -13,7 +13,6 @@ import com.alibaba.fastjson.JSON;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.stereotype.Service;
import javax.servlet.http.HttpServletResponse;
import java.util.ArrayList;
import java.util.Date;
......@@ -34,155 +33,154 @@ import java.util.stream.Collectors;
*/
@Service
public class QualityApplyServiceImpl extends ServiceImpl<QualityApplyMapper, QualityApply>
implements IQualityApplyService {
implements IQualityApplyService {
final
RedisUtil redisUtil;
final
ISysUserService iSysUserService;
final
ISysGroupService iSysGroupService;
final
RedisUtil redisUtil;
final
ISysUserService iSysUserService;
final
ISysGroupService iSysGroupService;
public QualityApplyServiceImpl(RedisUtil redisUtil,
ISysUserService iSysUserService,
ISysGroupService iSysGroupService) {
this.redisUtil = redisUtil;
this.iSysUserService = iSysUserService;
this.iSysGroupService = iSysGroupService;
}
public QualityApplyServiceImpl(RedisUtil redisUtil,
ISysUserService iSysUserService,
ISysGroupService iSysGroupService) {
this.redisUtil = redisUtil;
this.iSysUserService = iSysUserService;
this.iSysGroupService = iSysGroupService;
}
@Override
public Set<Integer> selectQualityApplyStatusByProIds(List<Integer> projectIds) {
if (projectIds.size() == 0) {
return new HashSet<>();
}
QueryWrapper<QualityApply> qw = new QueryWrapper<>();
qw.in("project_id", projectIds);
List<QualityApply> list = this.list(qw);
if (list.size() == 0) {
return new HashSet<>();
}
return list.stream().map(QualityApply::getProjectId).collect(Collectors.toSet());
}
@Override
public Set<Integer> selectQualityApplyStatusByProIds(List<Integer> projectIds) {
if (projectIds.size() == 0) {
return new HashSet<>();
}
QueryWrapper<QualityApply> qw = new QueryWrapper<>();
qw.in("project_id", projectIds);
List<QualityApply> list = this.list(qw);
if (list.size() == 0) {
return new HashSet<>();
}
return list.stream().map(QualityApply::getProjectId).collect(Collectors.toSet());
}
@Override
public void exportQuality(Date startParse, Date endParse, HttpServletResponse response) {
@Override
public void exportQuality(Date startParse, Date endParse, HttpServletResponse response) {
QueryWrapper<QualityApply> qw = new QueryWrapper<>();
if (startParse != null) {
qw.ge("create_time", startParse);
}
if (endParse != null) {
qw.le("create_time", endParse);
}
List<QualityApply> list = this.list(qw);
//找到所有项目id归类
Set<Integer> projectIds = list.stream().map(QualityApply::getProjectId).collect(Collectors.toSet());
String[] headers = null;
List<Object[]> datas = new ArrayList<>();
//关联部门名字
Set<Integer> userIds = list.stream()
.filter(arg -> !"误差".equals(arg.getUserName()) &&
!"标准样".equals(arg.getUserName()))
.map(QualityApply::getUserId)
.collect(Collectors.toSet());
//获取所以用户
final String userCache = "SYS_USER:CACHE";
final String groupCache = "SYS_GROUP:CACHE";
QueryWrapper<QualityApply> qw = new QueryWrapper<>();
if (startParse != null) {
qw.ge("create_time", startParse);
}
if (endParse != null) {
qw.le("create_time", endParse);
}
List<QualityApply> list = this.list(qw);
//找到所有项目id归类
Set<Integer> projectIds = list.stream().map(QualityApply::getProjectId).collect(Collectors.toSet());
List<Object[]> datas = new ArrayList<>();
//关联部门名字
Set<Integer> userIds = list.stream()
.filter(arg -> !"误差".equals(arg.getUserName()) &&
!"标准样".equals(arg.getUserName()))
.map(QualityApply::getUserId)
.collect(Collectors.toSet());
//获取所以用户
final String userCache = "SYS_USER:CACHE";
final String groupCache = "SYS_GROUP:CACHE";
if (!redisUtil.existsKey(userCache)) {
List<SysUser> sysUsers = iSysUserService.list();
redisUtil.setString(userCache, JSON.toJSONString(sysUsers), 600);
}
if (!redisUtil.existsKey(groupCache)) {
List<SysGroup> sysGroups = iSysGroupService.list();
redisUtil.setString(groupCache, JSON.toJSONString(sysGroups), 600);
}
//会有临界值问题
List<SysUser> sysUsers = JSON.parseArray(redisUtil.getString(userCache) + "", SysUser.class);
List<SysGroup> sysGroups = JSON.parseArray(redisUtil.getString(groupCache) + "", SysGroup.class);
Map<Integer, String> userGroupMap = new HashMap<>(userIds.size());
sysUsers.stream()
.filter(arg -> userIds.contains(arg.getId()))
.forEach(arg -> sysGroups.forEach(opt -> {
if (opt.getId().intValue() == arg.getGroupId()) {
userGroupMap.put(arg.getId(), opt.getName());
}
}));
if (userGroupMap.size() == 0) {
return;
}
if (!redisUtil.existsKey(userCache)) {
List<SysUser> sysUsers = iSysUserService.list();
redisUtil.setString(userCache, JSON.toJSONString(sysUsers), 600);
}
if (!redisUtil.existsKey(groupCache)) {
List<SysGroup> sysGroups = iSysGroupService.list();
redisUtil.setString(groupCache, JSON.toJSONString(sysGroups), 600);
}
//会有临界值问题
List<SysUser> sysUsers = JSON.parseArray(redisUtil.getString(userCache) + "", SysUser.class);
List<SysGroup> sysGroups = JSON.parseArray(redisUtil.getString(groupCache) + "", SysGroup.class);
Map<Integer, String> userGroupMap = new HashMap<>(userIds.size());
sysUsers.stream()
.filter(arg -> userIds.contains(arg.getId()))
.forEach(arg -> sysGroups.forEach(opt -> {
if (opt.getId().intValue() == arg.getGroupId()) {
userGroupMap.put(arg.getId(), opt.getName());
}
}));
if (userGroupMap.size() == 0) {
return;
}
for (Integer projectId : projectIds) {
//找到每个项目的检测组 以检测组归类
Set<Integer> teamIds = list.stream()
.filter(arg -> arg.getProjectId().intValue() == projectId)
.map(QualityApply::getTeamGroupId)
.collect(Collectors.toSet());
for (Integer projectId : projectIds) {
//找到每个项目的检测组 以检测组归类
Set<Integer> teamIds = list.stream()
.filter(arg -> arg.getProjectId().intValue() == projectId)
.map(QualityApply::getTeamGroupId)
.collect(Collectors.toSet());
for (Integer teamId : teamIds) {
List<QualityApply> samples = list.stream().filter(arg -> arg.getTeamGroupId().intValue() == teamId
&& arg.getProjectId().intValue() == projectId)
.collect(Collectors.toList());
//以样品归类
Set<Integer> sampleIds = samples.stream().map(QualityApply::getTeamGroupId)
.collect(Collectors.toSet());
for (Integer teamId : teamIds) {
List<QualityApply> samples = list.stream().filter(arg -> arg.getTeamGroupId().intValue() == teamId
&& arg.getProjectId().intValue() == projectId)
.collect(Collectors.toList());
//以样品归类
// Set<Integer> sampleIds = samples.stream().map(QualityApply::getTeamGroupId)
// .collect(Collectors.toSet());
//写每个样品的表头
list.stream()
.filter(arg -> arg.getTeamGroupId().intValue() == teamId)
.findFirst().ifPresent(arg -> {
List<String> teams = JSON.parseArray(arg.getTeams(), String.class);
Object[] objs = new Object[teams.size() + 8];
objs[0] = "项目名称";
objs[1] = "项目编号";
objs[2] = "样品名称";
objs[3] = "样品状态";
objs[4] = "来样编号";
objs[5] = "本所编号";
objs[6] = "部门";
objs[7] = "分析";
for (int i = 0; i < teams.size(); i++) {
String teamName = teams.get(i);
if (teamName.contains("\"")) {
teamName = teamName.replace("\"", "");
}
objs[8 + i] = teamName;
}
datas.add(objs);
});
//为每个样品写值
samples.forEach(arg -> {
List<String> inputValus = JSON.parseArray(arg.getInputResult(), String.class);
Object[] objs = new Object[inputValus.size() + 8];
if (!"误差".equals(arg.getUserName())) {
objs[0] = arg.getProjectName();
objs[1] = arg.getProjectId();
objs[2] = arg.getSampleName();
objs[3] = arg.getSampleForm();
objs[4] = arg.getSampleCode();
objs[5] = arg.getCementCode();
objs[6] = userGroupMap.get(arg.getUserId());
}
//添加名字
objs[7] = arg.getUserName();
for (int i = 0; i < inputValus.size(); i++) {
String value = inputValus.get(i);
if (value == null) {
value = "0";
}
if (value.contains("\"")) {
value = value.replace("\"", "");
}
objs[8 + i] = value;
}
//写每个样品的表头
list.stream()
.filter(arg -> arg.getTeamGroupId().intValue() == teamId)
.findFirst().ifPresent(arg -> {
List<String> teams = JSON.parseArray(arg.getTeams(), String.class);
Object[] objs = new Object[teams.size() + 8];
objs[0] = "项目名称";
objs[1] = "项目编号";
objs[2] = "样品名称";
objs[3] = "样品状态";
objs[4] = "来样编号";
objs[5] = "本所编号";
objs[6] = "部门";
objs[7] = "分析";
for (int i = 0; i < teams.size(); i++) {
String teamName = teams.get(i);
if (teamName.contains("\"")) {
teamName = teamName.replace("\"", "");
}
objs[8 + i] = teamName;
}
datas.add(objs);
});
//为每个样品写值
samples.forEach(arg -> {
List<String> inputValus = JSON.parseArray(arg.getInputResult(), String.class);
Object[] objs = new Object[inputValus.size() + 8];
if (!"误差".equals(arg.getUserName())) {
objs[0] = arg.getProjectName();
objs[1] = arg.getProjectId();
objs[2] = arg.getSampleName();
objs[3] = arg.getSampleForm();
objs[4] = arg.getSampleCode();
objs[5] = arg.getCementCode();
objs[6] = userGroupMap.get(arg.getUserId());
}
//添加名字
objs[7] = arg.getUserName();
for (int i = 0; i < inputValus.size(); i++) {
String value = inputValus.get(i);
if (value == null){
value = "0";
}
if ( value.contains("\"")) {
value = value.replace("\"", "");
}
objs[8 + i] = value;
}
datas.add(objs);
});
datas.add(objs);
});
}
}
ExcelUtil.excelExport("qualityApply", headers, datas, response);
}
}
}
ExcelUtil.excelExport("qualityApply", null, datas, response);
}
}
......@@ -25,31 +25,34 @@ import java.util.Map;
@Service
public class WeiXinService {
@Value("${weixin.corpid}")
private String corpid;
@Value("${weixin.corpsecret}")
private String corpsecret;
@Value("${weixin.corpsecretPC}")
private String corpsecretPC;
@Autowired
private ISysUserService userService;
@Autowired
RedisUtil redisUtil;
/**
* 获取登录token
*
* @param code
* @param type PC管理端 APP小程序端
* @return
*/
public BaseResponse<String> getToken(String code, String type) {
if (StrUtil.isEmpty(code)) {
return BaseResponse.errorMsg("code为必填项!");
}
System.out.println("==================code===================");
System.out.println(code);
try {
@Value("${weixin.corpid}")
private String corpid;
@Value("${weixin.corpsecret}")
private String corpsecret;
@Value("${weixin.corpsecretPC}")
private String corpsecretPC;
@Autowired
private ISysUserService userService;
@Autowired
RedisUtil redisUtil;
final static String ACCESS_TOKEN = "ACCESS_TOKEN";
final static String JSAPITICKET = "JSAPITICKET";
/**
* 获取登录token
*
* @param code
* @param type PC管理端 APP小程序端
* @return
*/
public BaseResponse<String> getToken(String code, String type) {
if (StrUtil.isEmpty(code)) {
return BaseResponse.errorMsg("code为必填项!");
}
System.out.println("==================code===================");
System.out.println(code);
try {
/*String accessToken = null;
if(type.equals("PC")){
accessToken = getAccessToken();
......@@ -68,81 +71,114 @@ public class WeiXinService {
System.out.println("==================UserId===================");
System.out.println(UserId);
JSONObject userJson = getUser(accessToken, UserId);*/
QueryWrapper<SysUser> wrapper = new QueryWrapper<>();
QueryWrapper<SysUser> wrapper = new QueryWrapper<>();
// wrapper.eq("phone", userJson.get("mobile"));
wrapper.eq("phone", code); //暂时用手机号代替code
SysUser sysUser = userService.getOne(wrapper);
if (sysUser == null) {
return BaseResponse.errorMsg("非系统用户不允许登录!");
}
if (sysUser.getStatus() == 0) {
return BaseResponse.errorMsg("用户被禁用!");
}
if (sysUser.getIsDelete() == 0) {
return BaseResponse.errorMsg("用户被删除!");
}
//生成token,存入redis
String token = JwtUtil.createToken(sysUser.getId(), sysUser.getUsername(),
sysUser.getName(), sysUser.getPhone());
System.out.println(token);
redisUtil.setString(sysUser.getId().toString(), token, 3600);
return BaseResponse.okData(token);
} catch (Exception e) {
return BaseResponse.errorMsg(e.getMessage());
}
}
//获取accessToken信息
public String getAccessToken() {
try {
String param = "corpid=%s&corpsecret=%s";
param = String.format(param, corpid, corpsecret);
JSONObject jsonObject = WeixinInterfaceUtil.doGet(Global.ACCESSTOKENURL, param);
String accessToken = jsonObject.getString("access_token");
System.out.println("==================accessToken===================");
System.out.println(accessToken);
return accessToken;
} catch (Exception e) {
return null;
}
}
public String getPCAccessToken() {
try {
String param = "corpid=%s&corpsecret=%s";
param = String.format(param, corpid, corpsecretPC);
JSONObject jsonObject = WeixinInterfaceUtil.doGet(Global.ACCESSTOKENURL, param);
String accessToken = jsonObject.getString("access_token");
System.out.println("==================accessToken===================");
System.out.println(accessToken);
return accessToken;
} catch (Exception e) {
return null;
}
}
//获取用户信息
public JSONObject getUser(String accessToken, String userId) {
try {
String param = "access_token=%s&userid=%s";
param = String.format(param, accessToken, userId);
JSONObject jsonObject = WeixinInterfaceUtil.doGet(Global.USERURL, param);
System.out.println("==================jsonObject===================");
System.out.println(jsonObject);
return jsonObject;
} catch (Exception e) {
return null;
}
}
/**
* 当前登录用户
*
* @return
*/
public BaseResponse<LoginUser> getLoginUser() {
LoginUser loginUser = userService.getLoginUser();
return BaseResponse.okData(loginUser);
}
wrapper.eq("phone", code); //暂时用手机号代替code
SysUser sysUser = userService.getOne(wrapper);
if (sysUser == null) {
return BaseResponse.errorMsg("非系统用户不允许登录!");
}
if (sysUser.getStatus() == 0) {
return BaseResponse.errorMsg("用户被禁用!");
}
if (sysUser.getIsDelete() == 0) {
return BaseResponse.errorMsg("用户被删除!");
}
//生成token,存入redis
String token = JwtUtil.createToken(sysUser.getId(), sysUser.getUsername(),
sysUser.getName(), sysUser.getPhone());
System.out.println(token);
redisUtil.setString(sysUser.getId().toString(), token, 3600);
return BaseResponse.okData(token);
} catch (Exception e) {
return BaseResponse.errorMsg(e.getMessage());
}
}
//获取accessToken信息
public String getAccessToken() {
try {
String param = "corpid=%s&corpsecret=%s";
param = String.format(param, corpid, corpsecret);
JSONObject jsonObject = WeixinInterfaceUtil.doGet(Global.ACCESSTOKENURL, param);
String accessToken = jsonObject.getString("access_token");
System.out.println("==================accessToken===================");
System.out.println(accessToken);
return accessToken;
} catch (Exception e) {
return null;
}
}
//获取accessToken信息
public String getJsapiTicket() {
try {
String accessToken;
String jsapiTicket;
if (!redisUtil.existsKey(ACCESS_TOKEN)) {
String param = "corpid=%s&corpsecret=%s";
param = String.format(param, corpid, corpsecret);
JSONObject jsonObject = WeixinInterfaceUtil.doGet(Global.ACCESSTOKENURL, param);
accessToken = jsonObject.getString("access_token");
redisUtil.setString(ACCESS_TOKEN, accessToken, 7200);
}
accessToken = redisUtil.getString(ACCESS_TOKEN) + "";
System.out.println("==================accessToken===================");
System.out.println(accessToken);
if (!redisUtil.existsKey(JSAPITICKET)) {
String param3 = "access_token=%s&type=agent_config";
param3 = String.format(param3, accessToken);
JSONObject ticketJsonObject = WeixinInterfaceUtil.doGet(Global.userTicket, param3);
jsapiTicket = ticketJsonObject.getString("ticket");
redisUtil.setString(JSAPITICKET, jsapiTicket, 7200);
}
jsapiTicket = redisUtil.getString(JSAPITICKET) + "";
return jsapiTicket;
} catch (Exception e) {
return null;
}
}
public String getPCAccessToken() {
try {
String param = "corpid=%s&corpsecret=%s";
param = String.format(param, corpid, corpsecretPC);
JSONObject jsonObject = WeixinInterfaceUtil.doGet(Global.ACCESSTOKENURL, param);
String accessToken = jsonObject.getString("access_token");
System.out.println("==================accessToken===================");
System.out.println(accessToken);
return accessToken;
} catch (Exception e) {
return null;
}
}
//获取用户信息
public JSONObject getUser(String accessToken, String userId) {
try {
String param = "access_token=%s&userid=%s";
param = String.format(param, accessToken, userId);
JSONObject jsonObject = WeixinInterfaceUtil.doGet(Global.USERURL, param);
System.out.println("==================jsonObject===================");
System.out.println(jsonObject);
return jsonObject;
} catch (Exception e) {
return null;
}
}
/**
* 当前登录用户
*
* @return
*/
public BaseResponse<LoginUser> getLoginUser() {
LoginUser loginUser = userService.getLoginUser();
return BaseResponse.okData(loginUser);
}
}
......@@ -16,8 +16,9 @@ import java.util.Map;
/**
* 校核计算工具类
*
*
* @author zhutianwei
*
*/
public class CheckCountUtil {
......@@ -28,19 +29,19 @@ public class CheckCountUtil {
public final static BigDecimal param10000 = new BigDecimal(10000.00);
//object 转成 BigDecimal
public static BigDecimal getBigDecimal(Object value) {
public static BigDecimal getBigDecimal(Object value ) {
BigDecimal ret = null;
if (value != null) {
if (value instanceof BigDecimal) {
if( value != null ) {
if( value instanceof BigDecimal ) {
ret = (BigDecimal) value;
} else if (value instanceof String) {
ret = new BigDecimal((String) value);
} else if (value instanceof BigInteger) {
ret = new BigDecimal((BigInteger) value);
} else if (value instanceof Number) {
ret = new BigDecimal(((Number) value).doubleValue());
} else if( value instanceof String ) {
ret = new BigDecimal( (String) value );
} else if( value instanceof BigInteger) {
ret = new BigDecimal( (BigInteger) value );
} else if( value instanceof Number ) {
ret = new BigDecimal( ((Number)value).doubleValue() );
} else {
throw new ClassCastException("Not possible to coerce [" + value + "] from class " + value.getClass() + " into a BigDecimal.");
throw new ClassCastException("Not possible to coerce ["+value+"] from class "+value.getClass()+" into a BigDecimal.");
}
}
return ret;
......@@ -48,30 +49,29 @@ public class CheckCountUtil {
/**
* 检测项名称
*
* @param name
* @return
*/
//加 add 减 subtract 乘 multiply 除 divide
public static String checkCount(String name, Map<String, Object> resultMap) {
public static String checkCount(String name, Map<String, String> resultMap) {
BigDecimal endResult = null;
if (name.equals("L.O.I")) {
if(name.equals("L.O.I")){
//样重m1—保留4位⼩数
BigDecimal m1 = getBigDecimal(resultMap.get("样重m1")).setScale(4, BigDecimal.ROUND_HALF_UP);
BigDecimal m1 = getBigDecimal(resultMap.get("样重m1")).setScale(4,BigDecimal.ROUND_HALF_UP);
//空堝重m2—保留4位⼩数
BigDecimal m2 = getBigDecimal(resultMap.get("空堝重m2")).setScale(4, BigDecimal.ROUND_HALF_UP);
BigDecimal m2 = getBigDecimal(resultMap.get("空堝重m2")).setScale(4,BigDecimal.ROUND_HALF_UP);
//烧后重m3—保留4位⼩数
BigDecimal m3 = getBigDecimal(resultMap.get("烧后重m3")).setScale(4, BigDecimal.ROUND_HALF_UP);
BigDecimal m3 = getBigDecimal(resultMap.get("烧后重m3")).setScale(4,BigDecimal.ROUND_HALF_UP);
//计算的核心公式结果
BigDecimal countResult = (m1.add(m2).subtract(m3)).divide(m1, 4);
BigDecimal countResult = (m1.add(m2).subtract(m3)).divide(m1,4);
BigDecimal result1 = countResult.multiply(param100.multiply(param100));
int resultInt1 = result1.setScale(0, BigDecimal.ROUND_DOWN).intValue();
if ((resultInt1 & 1) == 1) { //如果结果为奇数
endResult = countResult.multiply(param100).setScale(2, BigDecimal.ROUND_HALF_UP);
} else {
endResult = countResult.multiply(param100).subtract(new BigDecimal(0.0000000001)).setScale(2, BigDecimal.ROUND_HALF_UP);
int resultInt1 = result1.setScale( 0, BigDecimal.ROUND_DOWN ).intValue();
if((resultInt1&1) == 1){ //如果结果为奇数
endResult = countResult.multiply(param100).setScale(2,BigDecimal.ROUND_HALF_UP);
}else{
endResult = countResult.multiply(param100).subtract(new BigDecimal(0.0000000001)).setScale(2,BigDecimal.ROUND_HALF_UP);
}
} else if (name.equals("SiO2")) {
}else if(name.equals("SiO2")){
//毫升数
BigDecimal VSiO2 = getBigDecimal(resultMap.get("VSiO2"));
//滴定度
......@@ -81,28 +81,28 @@ public class CheckCountUtil {
//计算的核心公式结果
BigDecimal countResult = VSiO2.multiply(TSiO2).divide(m, 4);
BigDecimal result1 = countResult.multiply(param100);
int resultInt1 = result1.setScale(0, BigDecimal.ROUND_DOWN).intValue();
if ((resultInt1 & 1) == 1) { //如果结果为奇数
endResult = countResult.setScale(2, BigDecimal.ROUND_HALF_UP);
} else {
endResult = countResult.subtract(new BigDecimal(0.0000000001)).setScale(2, BigDecimal.ROUND_HALF_UP);
int resultInt1 = result1.setScale( 0, BigDecimal.ROUND_DOWN ).intValue();
if((resultInt1&1) == 1){ //如果结果为奇数
endResult = countResult.setScale(2,BigDecimal.ROUND_HALF_UP);
}else{
endResult = countResult.subtract(new BigDecimal(0.0000000001)).setScale(2,BigDecimal.ROUND_HALF_UP);
}
} else if (name.equals("Al2O3+TiO2")) {
}else if(name.equals("Al2O3+TiO2")){
BigDecimal TAl2O3 = getBigDecimal(resultMap.get("TAl2O3"));
BigDecimal VAl2O3 = getBigDecimal(resultMap.get("VAl2O3"));
BigDecimal K = getBigDecimal(resultMap.get("K"));
BigDecimal VCuSO4_I = getBigDecimal(resultMap.get("VCuSO4(I)"));
BigDecimal m = getBigDecimal(resultMap.get("样重m"));
//计算的核心公式结果
BigDecimal countResult = TAl2O3.multiply(VAl2O3.subtract(K.multiply(VCuSO4_I))).divide(m, 4);
BigDecimal countResult = TAl2O3.multiply(VAl2O3.subtract(K.multiply(VCuSO4_I))).divide(m,4);
BigDecimal result1 = countResult.multiply(param100);
int resultInt1 = result1.setScale(0, BigDecimal.ROUND_DOWN).intValue();
if ((resultInt1 & 1) == 1) { //如果结果为奇数
endResult = countResult.setScale(2, BigDecimal.ROUND_HALF_UP);
} else {
endResult = countResult.subtract(new BigDecimal(0.0000000001)).setScale(2, BigDecimal.ROUND_HALF_UP);
int resultInt1 = result1.setScale( 0, BigDecimal.ROUND_DOWN ).intValue();
if((resultInt1&1) == 1){ //如果结果为奇数
endResult = countResult.setScale(2,BigDecimal.ROUND_HALF_UP);
}else{
endResult = countResult.subtract(new BigDecimal(0.0000000001)).setScale(2,BigDecimal.ROUND_HALF_UP);
}
} else if (name.equals("Al2O3")) {
}else if(name.equals("Al2O3")){
BigDecimal TAl2O3 = getBigDecimal(resultMap.get("TAl2O3"));
BigDecimal VAl2O3 = getBigDecimal(resultMap.get("VAl2O3"));
BigDecimal K = getBigDecimal(resultMap.get("K"));
......@@ -110,220 +110,219 @@ public class CheckCountUtil {
BigDecimal m = getBigDecimal(resultMap.get("样重m"));
BigDecimal VCuSO4_II = getBigDecimal(resultMap.get("VCuSO4(II)"));
//计算的核心公式结果
BigDecimal countResult = TAl2O3.multiply(VAl2O3.subtract(K.multiply(VCuSO4_I.add(VCuSO4_II)))).divide(m, 4);
BigDecimal countResult = TAl2O3.multiply(VAl2O3.subtract(K.multiply(VCuSO4_I.add(VCuSO4_II)))).divide(m,4);
BigDecimal result1 = countResult.multiply(param100);
int resultInt1 = result1.setScale(0, BigDecimal.ROUND_DOWN).intValue();
if ((resultInt1 & 1) == 1) { //如果结果为奇数
endResult = countResult.setScale(2, BigDecimal.ROUND_HALF_UP);
} else {
endResult = countResult.subtract(new BigDecimal(0.0000000001)).setScale(2, BigDecimal.ROUND_HALF_UP);
int resultInt1 = result1.setScale( 0, BigDecimal.ROUND_DOWN ).intValue();
if((resultInt1&1) == 1){ //如果结果为奇数
endResult = countResult.setScale(2,BigDecimal.ROUND_HALF_UP);
}else{
endResult = countResult.subtract(new BigDecimal(0.0000000001)).setScale(2,BigDecimal.ROUND_HALF_UP);
}
} else if (name.equals("Fe2O3")) {
BigDecimal TFe2O3 = getBigDecimal(resultMap.get("TFe2O3"));
BigDecimal VF2O3 = getBigDecimal(resultMap.get("VF2O3"));
}else if(name.equals("Fe2O3")){
BigDecimal TFe2O3 = getBigDecimal(resultMap.get("TFe2O3"));
BigDecimal VF2O3 = getBigDecimal(resultMap.get("VF2O3"));
BigDecimal m = getBigDecimal(resultMap.get("样重m"));
//计算的核心公式结果
BigDecimal countResult = TFe2O3.multiply(VF2O3).divide(m, 4);
BigDecimal countResult = TFe2O3.multiply(VF2O3).divide(m,4);
BigDecimal result1 = countResult.multiply(param100);
int resultInt1 = result1.setScale(0, BigDecimal.ROUND_DOWN).intValue();
if ((resultInt1 & 1) == 1) { //如果结果为奇数
endResult = countResult.setScale(2, BigDecimal.ROUND_HALF_UP);
} else {
endResult = countResult.subtract(new BigDecimal(0.0000000001)).setScale(2, BigDecimal.ROUND_HALF_UP);
int resultInt1 = result1.setScale( 0, BigDecimal.ROUND_DOWN ).intValue();
if((resultInt1&1) == 1){ //如果结果为奇数
endResult = countResult.setScale(2,BigDecimal.ROUND_HALF_UP);
}else{
endResult = countResult.subtract(new BigDecimal(0.0000000001)).setScale(2,BigDecimal.ROUND_HALF_UP);
}
} else if (name.equals("CaO")) {
BigDecimal TCaO = getBigDecimal(resultMap.get("TCaO"));
BigDecimal VCaO = getBigDecimal(resultMap.get("VCaO"));
}else if(name.equals("CaO")){
BigDecimal TCaO = getBigDecimal(resultMap.get("TCaO"));
BigDecimal VCaO = getBigDecimal(resultMap.get("VCaO"));
BigDecimal m = getBigDecimal(resultMap.get("样重m"));
//计算的核心公式结果
BigDecimal countResult = TCaO.multiply(VCaO).divide(m, 4);
BigDecimal countResult = TCaO.multiply(VCaO).divide(m,4);
BigDecimal result1 = countResult.multiply(param100);
int resultInt1 = result1.setScale(0, BigDecimal.ROUND_DOWN).intValue();
if ((resultInt1 & 1) == 1) { //如果结果为奇数
endResult = countResult.setScale(2, BigDecimal.ROUND_HALF_UP);
} else {
endResult = countResult.subtract(new BigDecimal(0.00000000001)).setScale(2, BigDecimal.ROUND_HALF_UP);
int resultInt1 = result1.setScale( 0, BigDecimal.ROUND_DOWN ).intValue();
if((resultInt1&1) == 1){ //如果结果为奇数
endResult = countResult.setScale(2,BigDecimal.ROUND_HALF_UP);
}else{
endResult = countResult.subtract(new BigDecimal(0.00000000001)).setScale(2,BigDecimal.ROUND_HALF_UP);
}
} else if (name.equals("MgO")) {
BigDecimal TMgO = getBigDecimal(resultMap.get("TMgO"));
BigDecimal VMgO = getBigDecimal(resultMap.get("VMgO"));
BigDecimal VCaO = getBigDecimal(resultMap.get("VCaO"));
}else if(name.equals("MgO")){
BigDecimal TMgO = getBigDecimal(resultMap.get("TMgO"));
BigDecimal VMgO = getBigDecimal(resultMap.get("VMgO"));
BigDecimal VCaO = getBigDecimal(resultMap.get("VCaO"));
BigDecimal m = getBigDecimal(resultMap.get("样重m"));
//计算的核心公式结果
BigDecimal countResult = TMgO.multiply(VMgO.subtract(VCaO)).divide(m, 4);
BigDecimal countResult = TMgO.multiply(VMgO.subtract(VCaO)).divide(m,4);
BigDecimal result1 = countResult.multiply(param100);
int resultInt1 = result1.setScale(0, BigDecimal.ROUND_DOWN).intValue();
if ((resultInt1 & 1) == 1) { //如果结果为奇数
endResult = countResult.setScale(2, BigDecimal.ROUND_HALF_UP);
} else {
endResult = countResult.subtract(new BigDecimal(0.0000000001)).setScale(2, BigDecimal.ROUND_HALF_UP);
int resultInt1 = result1.setScale( 0, BigDecimal.ROUND_DOWN ).intValue();
if((resultInt1&1) == 1){ //如果结果为奇数
endResult = countResult.setScale(2,BigDecimal.ROUND_HALF_UP);
}else{
endResult = countResult.subtract(new BigDecimal(0.0000000001)).setScale(2,BigDecimal.ROUND_HALF_UP);
}
} else if (name.equals("TiO2")) {
BigDecimal TTiO2 = getBigDecimal(resultMap.get("TTiO2"));
BigDecimal VCuSO4_II = getBigDecimal(resultMap.get("VCuSO4(II)"));
BigDecimal K = getBigDecimal(resultMap.get("K"));
}else if(name.equals("TiO2")){
BigDecimal TTiO2 = getBigDecimal(resultMap.get("TTiO2"));
BigDecimal VCuSO4_II = getBigDecimal(resultMap.get("VCuSO4(II)"));
BigDecimal K = getBigDecimal(resultMap.get("K"));
BigDecimal m = getBigDecimal(resultMap.get("样重m"));
//计算的核心公式结果
BigDecimal countResult = TTiO2.multiply(VCuSO4_II).multiply(K).divide(m, 4);
BigDecimal countResult = TTiO2.multiply(VCuSO4_II).multiply(K).divide(m,4);
BigDecimal result1 = countResult.multiply(param100);
int resultInt1 = result1.setScale(0, BigDecimal.ROUND_DOWN).intValue();
if ((resultInt1 & 1) == 1) { //如果结果为奇数
endResult = countResult.setScale(2, BigDecimal.ROUND_HALF_UP);
} else {
endResult = countResult.subtract(new BigDecimal(0.00000000001)).setScale(2, BigDecimal.ROUND_HALF_UP);
int resultInt1 = result1.setScale( 0, BigDecimal.ROUND_DOWN ).intValue();
if((resultInt1&1) == 1){ //如果结果为奇数
endResult = countResult.setScale(2,BigDecimal.ROUND_HALF_UP);
}else{
endResult = countResult.subtract(new BigDecimal(0.00000000001)).setScale(2,BigDecimal.ROUND_HALF_UP);
}
} else if (name.equals("重量法_SO3")) {
BigDecimal m2 = getBigDecimal(resultMap.get("烧重m2"));
BigDecimal m1 = getBigDecimal(resultMap.get("埚重m1"));
BigDecimal m3 = getBigDecimal(resultMap.get("空白m3"));
}else if(name.equals("重量法_SO3")){
BigDecimal m2 = getBigDecimal(resultMap.get("烧重m2"));
BigDecimal m1 = getBigDecimal(resultMap.get("埚重m1"));
BigDecimal m3 = getBigDecimal(resultMap.get("空白m3"));
BigDecimal m = getBigDecimal(resultMap.get("样重m"));
//计算的核心公式结果
BigDecimal countResult = m2.subtract(m1).subtract(m3).divide(m, 4).multiply(new BigDecimal(0.343));
endResult = countResult.multiply(param100).setScale(4, BigDecimal.ROUND_HALF_UP);
} else if (name.equals("K2O")) {
BigDecimal CK2O = getBigDecimal(resultMap.get("CK2O"));
BigDecimal V = getBigDecimal(resultMap.get("V"));
BigDecimal AK2O = getBigDecimal(resultMap.get("AK2O"));
BigDecimal countResult = m2.subtract(m1).subtract(m3).divide(m,4).multiply(new BigDecimal(0.343));
endResult = countResult.multiply(param100).setScale(4,BigDecimal.ROUND_HALF_UP);
}else if(name.equals("K2O")){
BigDecimal CK2O = getBigDecimal(resultMap.get("CK2O"));
BigDecimal V = getBigDecimal(resultMap.get("V"));
BigDecimal AK2O = getBigDecimal(resultMap.get("AK2O"));
BigDecimal mR20 = getBigDecimal(resultMap.get("样重R2O"));
//计算的核心公式结果
BigDecimal countResult = CK2O.multiply(V).multiply(AK2O).divide(mR20, 4).divide(param10000, 4);
BigDecimal countResult = CK2O.multiply(V).multiply(AK2O).divide(mR20,4).divide(param10000,4);
BigDecimal result1 = countResult.multiply(param100);
int resultInt1 = result1.setScale(0, BigDecimal.ROUND_DOWN).intValue();
if ((resultInt1 & 1) == 1) { //如果结果为奇数
endResult = countResult.setScale(2, BigDecimal.ROUND_HALF_UP);
} else {
endResult = countResult.subtract(new BigDecimal(0.00000000001)).setScale(2, BigDecimal.ROUND_HALF_UP);
int resultInt1 = result1.setScale( 0, BigDecimal.ROUND_DOWN ).intValue();
if((resultInt1&1) == 1){ //如果结果为奇数
endResult = countResult.setScale(2,BigDecimal.ROUND_HALF_UP);
}else{
endResult = countResult.subtract(new BigDecimal(0.00000000001)).setScale(2,BigDecimal.ROUND_HALF_UP);
}
} else if (name.equals("Na2O")) {
BigDecimal CNa2O = getBigDecimal(resultMap.get("CNa2O"));
BigDecimal V = getBigDecimal(resultMap.get("V"));
BigDecimal ANa2O = getBigDecimal(resultMap.get("ANa2O"));
}else if(name.equals("Na2O")){
BigDecimal CNa2O = getBigDecimal(resultMap.get("CNa2O"));
BigDecimal V = getBigDecimal(resultMap.get("V"));
BigDecimal ANa2O = getBigDecimal(resultMap.get("ANa2O"));
BigDecimal mR20 = getBigDecimal(resultMap.get("样重R2O"));
//计算的核心公式结果
BigDecimal countResult = CNa2O.multiply(V).multiply(ANa2O).divide(mR20, 4).divide(param10000, 4);
BigDecimal countResult = CNa2O.multiply(V).multiply(ANa2O).divide(mR20,4).divide(param10000,4);
BigDecimal result1 = countResult.multiply(param100);
int resultInt1 = result1.setScale(0, BigDecimal.ROUND_DOWN).intValue();
if ((resultInt1 & 1) == 1) { //如果结果为奇数
endResult = countResult.setScale(2, BigDecimal.ROUND_HALF_UP);
} else {
endResult = countResult.subtract(new BigDecimal(0.00000000001)).setScale(2, BigDecimal.ROUND_HALF_UP);
int resultInt1 = result1.setScale( 0, BigDecimal.ROUND_DOWN ).intValue();
if((resultInt1&1) == 1){ //如果结果为奇数
endResult = countResult.setScale(2,BigDecimal.ROUND_HALF_UP);
}else{
endResult = countResult.subtract(new BigDecimal(0.00000000001)).setScale(2,BigDecimal.ROUND_HALF_UP);
}
} else if (name.equals("MnO")) {
BigDecimal CMnO = getBigDecimal(resultMap.get("CMnO"));
BigDecimal V = getBigDecimal(resultMap.get("V"));
BigDecimal AMnO = getBigDecimal(resultMap.get("AMnO"));
}else if(name.equals("MnO")){
BigDecimal CMnO = getBigDecimal(resultMap.get("CMnO"));
BigDecimal V = getBigDecimal(resultMap.get("V"));
BigDecimal AMnO = getBigDecimal(resultMap.get("AMnO"));
BigDecimal mR20 = getBigDecimal(resultMap.get("样重R2O"));
//计算的核心公式结果
BigDecimal countResult = CMnO.multiply(V).multiply(AMnO).divide(mR20, 4).divide(param10000, 4);
BigDecimal countResult = CMnO.multiply(V).multiply(AMnO).divide(mR20,4).divide(param10000,4);
BigDecimal result1 = countResult.multiply(param100);
int resultInt1 = result1.setScale(0, BigDecimal.ROUND_DOWN).intValue();
if ((resultInt1 & 1) == 1) { //如果结果为奇数
endResult = countResult.setScale(2, BigDecimal.ROUND_HALF_UP);
} else {
endResult = countResult.subtract(new BigDecimal(0.00000000001)).setScale(2, BigDecimal.ROUND_HALF_UP);
int resultInt1 = result1.setScale( 0, BigDecimal.ROUND_DOWN ).intValue();
if((resultInt1&1) == 1){ //如果结果为奇数
endResult = countResult.setScale(2,BigDecimal.ROUND_HALF_UP);
}else{
endResult = countResult.subtract(new BigDecimal(0.00000000001)).setScale(2,BigDecimal.ROUND_HALF_UP);
}
} else if (name.equals("Cl")) {
BigDecimal T = getBigDecimal(resultMap.get("T"));
BigDecimal V2 = getBigDecimal(resultMap.get("V2"));
BigDecimal V1 = getBigDecimal(resultMap.get("V1"));
}else if(name.equals("Cl")){
BigDecimal T = getBigDecimal(resultMap.get("T"));
BigDecimal V2 = getBigDecimal(resultMap.get("V2"));
BigDecimal V1 = getBigDecimal(resultMap.get("V1"));
BigDecimal mCl = getBigDecimal(resultMap.get("样重Cl"));
//计算的核心公式结果
BigDecimal countResult = T.multiply(V2.subtract(V1)).divide(mCl, 4).divide(param10, 4);
BigDecimal countResult = T.multiply(V2.subtract(V1)).divide(mCl,4).divide(param10,4);
BigDecimal result1 = countResult.multiply(param1000);
int resultInt1 = result1.setScale(0, BigDecimal.ROUND_DOWN).intValue();
if ((resultInt1 & 1) == 1) { //如果结果为奇数
endResult = countResult.setScale(3, BigDecimal.ROUND_HALF_UP);
} else {
endResult = countResult.subtract(new BigDecimal(0.00000000001)).setScale(3, BigDecimal.ROUND_HALF_UP);
int resultInt1 = result1.setScale( 0, BigDecimal.ROUND_DOWN ).intValue();
if((resultInt1&1) == 1){ //如果结果为奇数
endResult = countResult.setScale(3,BigDecimal.ROUND_HALF_UP);
}else{
endResult = countResult.subtract(new BigDecimal(0.00000000001)).setScale(3,BigDecimal.ROUND_HALF_UP);
}
} else if (name.equals("Mad1")) {
BigDecimal YZ_M1 = getBigDecimal(resultMap.get("样重M1"));
BigDecimal MZ_M1 = getBigDecimal(resultMap.get("皿重M1"));
BigDecimal SZ_M1 = getBigDecimal(resultMap.get("烧重M1"));
}else if(name.equals("Mad1")){
BigDecimal YZ_M1 = getBigDecimal(resultMap.get("样重M1"));
BigDecimal MZ_M1 = getBigDecimal(resultMap.get("皿重M1"));
BigDecimal SZ_M1 = getBigDecimal(resultMap.get("烧重M1"));
//计算的核心公式结果
BigDecimal countResult = YZ_M1.add(MZ_M1).subtract(SZ_M1).divide(YZ_M1, 4);
BigDecimal countResult = YZ_M1.add(MZ_M1).subtract(SZ_M1).divide(YZ_M1,4);
endResult = countResult.multiply(param100);
} else if (name.equals("Mad2")) {
BigDecimal YZ_M2 = getBigDecimal(resultMap.get("样重M2"));
BigDecimal MZ_M2 = getBigDecimal(resultMap.get("皿重M2"));
BigDecimal SZ_M2 = getBigDecimal(resultMap.get("烧重M2"));
}else if(name.equals("Mad2")){
BigDecimal YZ_M2 = getBigDecimal(resultMap.get("样重M2"));
BigDecimal MZ_M2 = getBigDecimal(resultMap.get("皿重M2"));
BigDecimal SZ_M2 = getBigDecimal(resultMap.get("烧重M2"));
//计算的核心公式结果
BigDecimal countResult = YZ_M2.add(MZ_M2).subtract(SZ_M2).divide(YZ_M2, 4);
BigDecimal countResult = YZ_M2.add(MZ_M2).subtract(SZ_M2).divide(YZ_M2,4);
endResult = countResult.multiply(param100);
} else if (name.equals("Aad1")) {
BigDecimal SZ_A1 = getBigDecimal(resultMap.get("烧重A1"));
BigDecimal MZ_A1 = getBigDecimal(resultMap.get("皿重A1"));
BigDecimal YZ_A1 = getBigDecimal(resultMap.get("样重A1"));
}else if(name.equals("Aad1")){
BigDecimal SZ_A1 = getBigDecimal(resultMap.get("烧重A1"));
BigDecimal MZ_A1 = getBigDecimal(resultMap.get("皿重A1"));
BigDecimal YZ_A1 = getBigDecimal(resultMap.get("样重A1"));
//计算的核心公式结果
BigDecimal countResult = SZ_A1.subtract(MZ_A1).divide(YZ_A1, 4);
BigDecimal countResult = SZ_A1.subtract(MZ_A1).divide(YZ_A1,4);
endResult = countResult.multiply(param100);
} else if (name.equals("Aad2")) {
BigDecimal SZ_A2 = getBigDecimal(resultMap.get("烧重A2"));
BigDecimal MZ_A2 = getBigDecimal(resultMap.get("皿重A2"));
BigDecimal YZ_A2 = getBigDecimal(resultMap.get("样重A2"));
}else if(name.equals("Aad2")){
BigDecimal SZ_A2 = getBigDecimal(resultMap.get("烧重A2"));
BigDecimal MZ_A2 = getBigDecimal(resultMap.get("皿重A2"));
BigDecimal YZ_A2 = getBigDecimal(resultMap.get("样重A2"));
//计算的核心公式结果
BigDecimal countResult = SZ_A2.subtract(MZ_A2).divide(YZ_A2, 4);
BigDecimal countResult = SZ_A2.subtract(MZ_A2).divide(YZ_A2,4);
endResult = countResult.multiply(param100);
} else if (name.equals("焦渣")) {
endResult = getBigDecimal(resultMap.get("焦渣特征"));
} else if (name.equals("St,ad")) {
endResult = getBigDecimal(resultMap.get("显示值"));
}else if(name.equals("焦渣")){
endResult = getBigDecimal(resultMap.get("焦渣特征"));
}else if(name.equals("St,ad")){
endResult = getBigDecimal(resultMap.get("显示值"));
}
return endResult.toString();
}
/**
* 求SO3
*
* @param resultMap
* @param countMap
* @return
*/
public static String countSO3(Map<String, Object> resultMap, Map<String, String> countMap) {
public static String countSO3(Map<String, String> resultMap, Map<String, String> countMap) {
BigDecimal weightSO3 = getBigDecimal(countMap.get("重量法_SO3"));
BigDecimal displaySO3 = getBigDecimal(resultMap.get("显示值"));
BigDecimal mSO3 = getBigDecimal(resultMap.get("样重SO3"));
BigDecimal displaySO3= getBigDecimal(resultMap.get("显示值"));
BigDecimal mSO3= getBigDecimal(resultMap.get("样重SO3"));
BigDecimal elseResult = displaySO3.multiply(new BigDecimal(2.5));
BigDecimal countResult = weightSO3.compareTo(new BigDecimal(0)) == 1 ?
weightSO3 : elseResult;
BigDecimal countResult = weightSO3.compareTo(new BigDecimal(0))==1?
weightSO3:elseResult;
BigDecimal result1 = countResult.multiply(param1000);
int resultInt1 = result1.setScale(0, BigDecimal.ROUND_DOWN).intValue();
int resultInt1 = result1.setScale( 0, BigDecimal.ROUND_DOWN ).intValue();
BigDecimal count = null;
if ((resultInt1 & 1) == 1) { //如果结果为奇数
BigDecimal jsResult = weightSO3.compareTo(new BigDecimal(0)) == 1 ?
weightSO3 : elseResult.multiply(mSO3).divide(mSO3, 4);
count = jsResult.setScale(3, BigDecimal.ROUND_HALF_UP);
} else {
BigDecimal osResult = weightSO3.compareTo(new BigDecimal(0)) == 1 ?
weightSO3 : elseResult.multiply(mSO3).divide(mSO3, 4);
count = osResult.subtract(new BigDecimal(0.00000000001)).setScale(3, BigDecimal.ROUND_HALF_UP);
if((resultInt1&1) == 1){ //如果结果为奇数
BigDecimal jsResult = weightSO3.compareTo(new BigDecimal(0))==1?
weightSO3:elseResult.multiply(mSO3).divide(mSO3,4);
count = jsResult.setScale(3,BigDecimal.ROUND_HALF_UP);
}else{
BigDecimal osResult = weightSO3.compareTo(new BigDecimal(0))==1?
weightSO3:elseResult.multiply(mSO3).divide(mSO3,4);
count = osResult.subtract(new BigDecimal(0.00000000001)).setScale(3,BigDecimal.ROUND_HALF_UP);
}
return count.toString();
}
/**
* 求合量 L.O.I+SiO2+(Al2O3+TiO2)+Al2O3+Fe2O3+CaO+MgO+TiO2+K2O+Na2O+MnO+SO3
*
* 求合量 L.O.I+SiO2+(Al2O3+TiO2)+Al2O3+Fe2O3+CaO+MgO+TiO2+K2O+Na2O+MnO+SO3
* @param countMap
* @return
*/
public static String countHL(Map<String, String> countMap) {
List<String> list = new ArrayList<>();
list.add(countMap.get("L.O.I").toString());
list.add(countMap.get("SiO2").toString());
// list.add(countMap.get("Al2O3+TiO2").toString());
list.add(countMap.get("Al2O3").toString());
list.add(countMap.get("Fe2O3").toString());
list.add(countMap.get("CaO").toString());
list.add(countMap.get("MgO").toString());
list.add(countMap.get("TiO2").toString());
list.add(countMap.get("K2O").toString());
list.add(countMap.get("Na2O").toString());
list.add(countMap.get("MnO").toString());
list.add(countMap.get("SO3").toString());
BigDecimal count = new BigDecimal(0);
for (String s : list) {
list.add(countMap.get("L.O.I"));
list.add(countMap.get("SiO2"));
// list.add(countMap.get("Al2O3+TiO2"));
list.add(countMap.get("Al2O3"));
list.add(countMap.get("Fe2O3"));
list.add(countMap.get("CaO"));
list.add(countMap.get("MgO"));
list.add(countMap.get("TiO2"));
list.add(countMap.get("K2O"));
list.add(countMap.get("Na2O"));
list.add(countMap.get("MnO"));
list.add(countMap.get("SO3"));
BigDecimal count=new BigDecimal(0);
for(String s:list) {
count = count.add(new BigDecimal(s));
}
return count.toString();
......@@ -331,547 +330,527 @@ public class CheckCountUtil {
/**
* 求KH (CaO - 1.65*{Al2O3+TiO2} * Fe2O3) / 2.8 / SiO2
*
* @param countMap
* @return
*/
public static String countKH(Map<String, String> countMap) {
BigDecimal CaO = getBigDecimal(countMap.get("Cao"));
BigDecimal Al2O3_TiO2 = getBigDecimal(countMap.get("Al2O3+TiO2"));
BigDecimal Al2O3_TiO2= getBigDecimal(countMap.get("Al2O3+TiO2"));
BigDecimal Fe2O3 = getBigDecimal(countMap.get("Fe2O3"));
BigDecimal SiO2 = getBigDecimal(countMap.get("SiO2"));
BigDecimal KH =
CaO.subtract(new BigDecimal(1.65).multiply(Al2O3_TiO2)).subtract(new BigDecimal(0.35).multiply(Fe2O3)).divide(new BigDecimal(2.8), 4).divide(SiO2, 4);
CaO.subtract(new BigDecimal(1.65).multiply(Al2O3_TiO2)).subtract(new BigDecimal(0.35).multiply(Fe2O3)).divide(new BigDecimal(2.8),4).divide(SiO2,4);
return KH.toString();
}
/**
* 求SM SiO2/ ({Al2O3+TiO2} + Fe2O3)
*
* @param countMap
* @return
*/
public static String countSM(Map<String, String> countMap) {
BigDecimal SiO2 = getBigDecimal(countMap.get("SiO2"));
BigDecimal Al2O3_TiO2 = getBigDecimal(countMap.get("Al2O3+TiO2"));
BigDecimal Al2O3_TiO2= getBigDecimal(countMap.get("Al2O3+TiO2"));
BigDecimal Fe2O3 = getBigDecimal(countMap.get("Fe2O3"));
BigDecimal SM = SiO2.divide(Al2O3_TiO2.add(Fe2O3), 4);
BigDecimal SM = SiO2.divide(Al2O3_TiO2.add(Fe2O3),4);
return SM.toString();
}
/**
* 求AM 「Al2O3+TiO2」/ Fe2O3
*
* @param countMap
* @return
*/
public static String countAM(Map<String, String> countMap) {
BigDecimal Al2O3_TiO2 = getBigDecimal(countMap.get("Al2O3+TiO2"));
BigDecimal Al2O3_TiO2= getBigDecimal(countMap.get("Al2O3+TiO2"));
BigDecimal Fe2O3 = getBigDecimal(countMap.get("Fe2O3"));
BigDecimal AM = Al2O3_TiO2.divide(Fe2O3, 4);
BigDecimal AM = Al2O3_TiO2.divide(Fe2O3,4);
return AM.toString();
}
/**
* 求易烧性等级
*
* @param resultMap 输入集合
* @param countMap 输出集合
* @return
*/
public static String countBurnupLevel(Map<String, Object> resultMap, Map<String, String> countMap) {
BigDecimal fCaO_1450 = getBigDecimal(resultMap.get("fCaO_1450"));
BigDecimal KH = getBigDecimal(countMap.get("KH"));
public static String countBurnupLevel(Map<String, String> resultMap, Map<String, String> countMap) {
BigDecimal fCaO_1450 = getBigDecimal(resultMap.get("fCaO_1450"));
BigDecimal KH= getBigDecimal(countMap.get("KH"));
BigDecimal E = new BigDecimal(45).multiply(KH).subtract(new BigDecimal(37.4));
BigDecimal D = new BigDecimal(35).multiply(KH).subtract(new BigDecimal(29.3));
BigDecimal C = new BigDecimal(26.25).multiply(KH).subtract(new BigDecimal(22.15));
BigDecimal B = new BigDecimal(18.75).multiply(KH).subtract(new BigDecimal(16));
if (fCaO_1450.compareTo(E) == 1) {
if(fCaO_1450.compareTo(E) == 1){
return "E";
} else if (fCaO_1450.compareTo(D) == 1) {
}else if (fCaO_1450.compareTo(D) == 1){
return "D";
} else if (fCaO_1450.compareTo(C) == 1) {
}else if (fCaO_1450.compareTo(C) == 1){
return "C";
} else if (fCaO_1450.compareTo(B) == 1) {
}else if (fCaO_1450.compareTo(B) == 1){
return "B";
} else {
}else{
return "A";
}
}
/**
* 求报出_Mad (Mad1 + Mad2 )/ 2
*
* @param countMap
* @return
*/
public static String countBCMad(Map<String, String> countMap) {
BigDecimal Mad1 = getBigDecimal(countMap.get("Mad1"));
BigDecimal Mad2 = getBigDecimal(countMap.get("Mad2"));
BigDecimal Mad1= getBigDecimal(countMap.get("Mad1"));
BigDecimal Mad2= getBigDecimal(countMap.get("Mad2"));
//计算Mad1 和 Mad2 的平均值
BigDecimal BC_Mad = Mad1.add(Mad2).divide(new BigDecimal(2), 4);
return BC_Mad.toString();
BigDecimal BC_Mad = Mad1.add(Mad2).divide(new BigDecimal(2),4);
return BC_Mad.toString();
}
/**
* 求Mad 报出_Mad *100 判断奇偶数判断后的结果
*
* @param countMap
* @return
*/
public static String countMad(Map<String, String> countMap) {
BigDecimal BC_Mad = getBigDecimal(countMap.get("报出_Mad"));
BigDecimal BC_Mad= getBigDecimal(countMap.get("报出_Mad"));
//判断奇偶数的最终值
BigDecimal result1 = BC_Mad.multiply(param100);
int resultInt1 = result1.setScale(0, BigDecimal.ROUND_DOWN).intValue();
int resultInt1 = result1.setScale( 0, BigDecimal.ROUND_DOWN ).intValue();
BigDecimal Mad = null;
if ((resultInt1 & 1) == 1) { //如果结果为奇数
Mad = BC_Mad.setScale(2, BigDecimal.ROUND_HALF_UP);
} else {
Mad = BC_Mad.subtract(new BigDecimal(0.00000000001)).setScale(2, BigDecimal.ROUND_HALF_UP);
if((resultInt1&1) == 1){ //如果结果为奇数
Mad = BC_Mad.setScale(2,BigDecimal.ROUND_HALF_UP);
}else{
Mad = BC_Mad.subtract(new BigDecimal(0.00000000001)).setScale(2,BigDecimal.ROUND_HALF_UP);
}
return Mad.toString();
return Mad.toString();
}
/**
* 求报出_Aad (Aad1 + Aad2)/2
*
* @param countMap
* @return
*/
public static String countBCAad(Map<String, String> countMap) {
BigDecimal Aad1 = getBigDecimal(countMap.get("Aad1"));
BigDecimal Aad2 = getBigDecimal(countMap.get("Aad2"));
BigDecimal Aad1= getBigDecimal(countMap.get("Aad1"));
BigDecimal Aad2= getBigDecimal(countMap.get("Aad2"));
//计算Mad1 和 Mad2 的平均值
BigDecimal BC_Aad = Aad1.add(Aad2).divide(new BigDecimal(2), 4);
return BC_Aad.toString();
BigDecimal BC_Aad = Aad1.add(Aad2).divide(new BigDecimal(2),4);
return BC_Aad.toString();
}
/**
* 求Aad 报出_Aad *100 判断奇偶数判断后的结果
*
* @param countMap
* @return
*/
public static String countAad(Map<String, String> countMap) {
BigDecimal BC_Aad = getBigDecimal(countMap.get("报出_Aad"));
BigDecimal BC_Aad= getBigDecimal(countMap.get("报出_Aad"));
//判断奇偶数的最终值
BigDecimal result1 = BC_Aad.multiply(param100);
int resultInt1 = result1.setScale(0, BigDecimal.ROUND_DOWN).intValue();
int resultInt1 = result1.setScale( 0, BigDecimal.ROUND_DOWN ).intValue();
BigDecimal Aad = null;
if ((resultInt1 & 1) == 1) { //如果结果为奇数
Aad = BC_Aad.setScale(2, BigDecimal.ROUND_HALF_UP);
} else {
Aad = BC_Aad.subtract(new BigDecimal(0.00000000001)).setScale(2, BigDecimal.ROUND_HALF_UP);
if((resultInt1&1) == 1){ //如果结果为奇数
Aad = BC_Aad.setScale(2,BigDecimal.ROUND_HALF_UP);
}else{
Aad = BC_Aad.subtract(new BigDecimal(0.00000000001)).setScale(2,BigDecimal.ROUND_HALF_UP);
}
return Aad.toString();
return Aad.toString();
}
/**
* 求Vad1
*
* @param resultMap
* @param countMap
* @return
*/
public static String countVad1(Map<String, Object> resultMap, Map<String, String> countMap) {
BigDecimal YZ_V1 = getBigDecimal(resultMap.get("样重V1"));
BigDecimal MZ_V1 = getBigDecimal(resultMap.get("皿重V1"));
BigDecimal SZ_V1 = getBigDecimal(resultMap.get("烧重V1"));
BigDecimal BC_Mad = getBigDecimal(countMap.get("报出_Mad"));
public static String countVad1(Map<String, String> resultMap, Map<String, String> countMap) {
BigDecimal YZ_V1 = getBigDecimal(resultMap.get("样重V1"));
BigDecimal MZ_V1 = getBigDecimal(resultMap.get("皿重V1"));
BigDecimal SZ_V1 = getBigDecimal(resultMap.get("烧重V1"));
BigDecimal BC_Mad = getBigDecimal(countMap.get("报出_Mad"));
//计算的核心公式结果
BigDecimal countResult = YZ_V1.add(MZ_V1).subtract(SZ_V1).divide(YZ_V1, 4);
BigDecimal countResult = YZ_V1.add(MZ_V1).subtract(SZ_V1).divide(YZ_V1,4);
BigDecimal count = countResult.multiply(param100).subtract(BC_Mad);
return count.toString();
return count.toString();
}
/**
* 求Vad2
*
* @param resultMap
* @param countMap
* @return
*/
public static String countVad2(Map<String, Object> resultMap, Map<String, String> countMap) {
BigDecimal YZ_V2 = getBigDecimal(resultMap.get("样重V2"));
BigDecimal MZ_V2 = getBigDecimal(resultMap.get("皿重V2"));
BigDecimal SZ_V2 = getBigDecimal(resultMap.get("烧重V2"));
BigDecimal BC_Mad = getBigDecimal(countMap.get("报出_Mad"));
public static String countVad2(Map<String, String> resultMap, Map<String, String> countMap) {
BigDecimal YZ_V2 = getBigDecimal(resultMap.get("样重V2"));
BigDecimal MZ_V2 = getBigDecimal(resultMap.get("皿重V2"));
BigDecimal SZ_V2 = getBigDecimal(resultMap.get("烧重V2"));
BigDecimal BC_Mad = getBigDecimal(countMap.get("报出_Mad"));
//计算的核心公式结果
BigDecimal countResult = YZ_V2.add(MZ_V2).subtract(SZ_V2).divide(YZ_V2, 4);
BigDecimal countResult = YZ_V2.add(MZ_V2).subtract(SZ_V2).divide(YZ_V2,4);
BigDecimal count = countResult.multiply(param100).subtract(BC_Mad);
return count.toString();
return count.toString();
}
/**
* 求报出_Vad (Vad1+ Vad2)/2
*
* @param countMap
* @return
*/
public static String countBCVad(Map<String, String> countMap) {
BigDecimal Vad1 = getBigDecimal(countMap.get("Vad1"));
BigDecimal Vad2 = getBigDecimal(countMap.get("Vad2"));
BigDecimal Vad1= getBigDecimal(countMap.get("Vad1"));
BigDecimal Vad2= getBigDecimal(countMap.get("Vad2"));
//计算Vad1 和 Vad2 的平均值
BigDecimal BC_Vad = Vad1.add(Vad2).divide(new BigDecimal(2), 4);
return BC_Vad.toString();
BigDecimal BC_Vad = Vad1.add(Vad2).divide(new BigDecimal(2),4);
return BC_Vad.toString();
}
/**
* 求Vad 报出_Vad *100 判断奇偶数判断后的结果
*
* @param countMap
* @return
*/
public static String countVad(Map<String, String> countMap) {
BigDecimal BC_Vad = getBigDecimal(countMap.get("报出_Vad"));
BigDecimal BC_Vad= getBigDecimal(countMap.get("报出_Vad"));
//判断奇偶数的最终值
BigDecimal result1 = BC_Vad.multiply(param100);
int resultInt1 = result1.setScale(0, BigDecimal.ROUND_DOWN).intValue();
int resultInt1 = result1.setScale( 0, BigDecimal.ROUND_DOWN ).intValue();
BigDecimal Vad = null;
if ((resultInt1 & 1) == 1) { //如果结果为奇数
Vad = BC_Vad.setScale(2, BigDecimal.ROUND_HALF_UP);
} else {
Vad = BC_Vad.subtract(new BigDecimal(0.00000000001)).setScale(2, BigDecimal.ROUND_HALF_UP);
if((resultInt1&1) == 1){ //如果结果为奇数
Vad = BC_Vad.setScale(2,BigDecimal.ROUND_HALF_UP);
}else{
Vad = BC_Vad.subtract(new BigDecimal(0.00000000001)).setScale(2,BigDecimal.ROUND_HALF_UP);
}
return Vad.toString();
return Vad.toString();
}
/**
* 求Vdaf Vad *100/(100-Mad-Aad)
*
* @param countMap
* @return
*/
public static String countVdaf(Map<String, String> countMap) {
BigDecimal Vad = getBigDecimal(countMap.get("Vad"));
BigDecimal Mad = getBigDecimal(countMap.get("Mad"));
BigDecimal Aad = getBigDecimal(countMap.get("Aad"));
BigDecimal Vad= getBigDecimal(countMap.get("Vad"));
BigDecimal Mad= getBigDecimal(countMap.get("Mad"));
BigDecimal Aad= getBigDecimal(countMap.get("Aad"));
BigDecimal Vdaf = Vad.multiply(param100).multiply(param100.subtract(Mad).subtract(Aad));
return Vdaf.toString();
return Vdaf.toString();
}
/**
* 求Vdaf Vad *100/(100-Mad-Aad)
*
* @param countMap
* @return
*/
public static String countK1_(Map<String, String> countMap) {
BigDecimal Vdaf = getBigDecimal(countMap.get("Vdaf"));
BigDecimal K1_ =
Vdaf.compareTo(new BigDecimal(62)) == 1 ? new BigDecimal(61.5) : (
Vdaf.compareTo(new BigDecimal(56)) == 1 ? new BigDecimal(63) : (
Vdaf.compareTo(new BigDecimal(49)) == 1 ? new BigDecimal(65) : (
Vdaf.compareTo(new BigDecimal(45)) == 1 ? new BigDecimal(67) : (
Vdaf.compareTo(new BigDecimal(37)) == 1 ? new BigDecimal(68.5) :
new BigDecimal(0)
))));
return K1_.toString();
BigDecimal Vdaf= getBigDecimal(countMap.get("Vdaf"));
BigDecimal K1_=
Vdaf.compareTo(new BigDecimal(62))==1?new BigDecimal(61.5):(
Vdaf.compareTo(new BigDecimal(56))==1?new BigDecimal(63):(
Vdaf.compareTo(new BigDecimal(49))==1?new BigDecimal(65):(
Vdaf.compareTo(new BigDecimal(45))==1?new BigDecimal(67):(
Vdaf.compareTo(new BigDecimal(37))==1?new BigDecimal(68.5):
new BigDecimal(0)
))));
return K1_.toString();
}
/**
* 求K if 焦渣特征=1 JZB1 if 焦渣特征=1.5 JZB1_5 f 焦渣特征=2 JZB2
*
* @param resultMap
* @param countMap
* @return
*/
public static String countK(Map<String, Object> resultMap, Map<String, String> countMap) {
String JZTZ = resultMap.get("焦渣特征").toString();
BigDecimal Vdaf = getBigDecimal(countMap.get("Vdaf"));
public static String countK(Map<String, String> resultMap, Map<String, String> countMap) {
String JZTZ= resultMap.get("焦渣特征");
BigDecimal Vdaf= getBigDecimal(countMap.get("Vdaf"));
//获取焦渣特征序号对应的值
Map<String, String> map = JZTZCountUtil.getJZTZ(Vdaf);
Map<String, String> map = JZTZCountUtil.getJZTZ(Vdaf);
String count = "";
if (JZTZ.equals("1")) {
if(JZTZ.equals("1")){
count = map.get(JZTZ);
} else if (JZTZ.equals("1.5")) {
}else if(JZTZ.equals("1.5")){
count = map.get(JZTZ);
} else if (JZTZ.equals("2")) {
}else if(JZTZ.equals("2")){
count = map.get(JZTZ);
} else if (JZTZ.equals("2.5")) {
}else if(JZTZ.equals("2.5")){
count = map.get(JZTZ);
} else if (JZTZ.equals("3")) {
}else if(JZTZ.equals("3")){
count = map.get(JZTZ);
} else if (JZTZ.equals("3.5")) {
}else if(JZTZ.equals("3.5")){
count = map.get(JZTZ);
} else if (JZTZ.equals("4")) {
}else if(JZTZ.equals("4")){
count = map.get(JZTZ);
} else if (JZTZ.equals("4.5")) {
}else if(JZTZ.equals("4.5")){
count = map.get(JZTZ);
} else if (JZTZ.equals("5")) {
}else if(JZTZ.equals("5")){
count = map.get(JZTZ);
} else if (JZTZ.equals("5.5")) {
}else if(JZTZ.equals("5.5")){
count = map.get(JZTZ);
} else if (JZTZ.equals("6")) {
}else if(JZTZ.equals("6")){
count = map.get(JZTZ);
} else if (JZTZ.equals("6.5")) {
}else if(JZTZ.equals("6.5")){
count = map.get(JZTZ);
} else if (JZTZ.equals("7")) {
}else if(JZTZ.equals("7")){
count = map.get(JZTZ);
} else if (JZTZ.equals("7.5")) {
}else if(JZTZ.equals("7.5")){
count = map.get(JZTZ);
} else if (JZTZ.equals("8")) {
}else if(JZTZ.equals("8")){
count = map.get(JZTZ);
} else {
}else{
count = "false";
}
return count;
return count;
}
/**
* 求Vdaf判断 Vdaf<35?1:0
*
* @param countMap
* @return
*/
public static String countVdafPD(Map<String, String> countMap) {
BigDecimal Vdaf = getBigDecimal(countMap.get("Vdaf"));
Integer VdafPD = Vdaf.compareTo(new BigDecimal(35)) == -1 ? 1 : 0;
return VdafPD.toString();
BigDecimal Vdaf= getBigDecimal(countMap.get("Vdaf"));
Integer VdafPD = Vdaf.compareTo(new BigDecimal(35))==-1?1:0;
return VdafPD.toString();
}
/**
* 求Mad判断 Mad>3?1:0
*
* @param countMap
* @return
*/
public static String countMadPD(Map<String, String> countMap) {
BigDecimal BC_Mad = getBigDecimal(countMap.get("报出_Mad"));
Integer MadPD = BC_Mad.compareTo(new BigDecimal(3)) == 1 ? 1 : 0;
return MadPD.toString();
BigDecimal BC_Mad= getBigDecimal(countMap.get("报出_Mad"));
Integer MadPD = BC_Mad.compareTo(new BigDecimal(3))==1?1:0;
return MadPD.toString();
}
/**
* 求40Mad 0或1 Vdaf判断* Mad判断
*
* @param countMap
* @return
*/
public static String count40Mad0Or1(Map<String, String> countMap) {
BigDecimal VdafPD = getBigDecimal(countMap.get("Vdaf判断"));
BigDecimal MadPD = getBigDecimal(countMap.get("Mad判断"));
BigDecimal VdafPD= getBigDecimal(countMap.get("Vdaf判断"));
BigDecimal MadPD= getBigDecimal(countMap.get("Mad判断"));
BigDecimal count = VdafPD.multiply(MadPD);
return count.toString();
return count.toString();
}
/**
* 求40Mad 0或1
*
* @param countMap
* @return
*/
public static String countAd(Map<String, String> countMap) {
BigDecimal BC_Aad = getBigDecimal(countMap.get("报出_Aad"));
BigDecimal BC_Mad = getBigDecimal(countMap.get("报出_Mad"));
BigDecimal count = BC_Aad.multiply(param100).divide(param100.subtract(BC_Mad), 4);
return count.toString();
BigDecimal BC_Aad= getBigDecimal(countMap.get("报出_Aad"));
BigDecimal BC_Mad= getBigDecimal(countMap.get("报出_Mad"));
BigDecimal count = BC_Aad.multiply(param100).divide(param100.subtract(BC_Mad),4);
return count.toString();
}
/**
* 求Ad系数0.1或0 if Ad>20 0.1 else 0
*
* @param countMap
* @return
*/
public static String countAdXS(Map<String, String> countMap) {
BigDecimal Ad = getBigDecimal(countMap.get("Ad"));
BigDecimal Ad= getBigDecimal(countMap.get("Ad"));
BigDecimal count =
Ad.compareTo(new BigDecimal(20)) == 1 ? new BigDecimal(0.1) : new BigDecimal(0);
return count.toString();
Ad.compareTo(new BigDecimal(20))==1?new BigDecimal(0.1):new BigDecimal(0);
return count.toString();
}
public static String countVdafXS(Map<String, String> countMap) {
BigDecimal Ad = getBigDecimal(countMap.get("Ad"));
BigDecimal Ad= getBigDecimal(countMap.get("Ad"));
Double count =
Ad.compareTo(new BigDecimal(30)) == 1 ? 0.8 : (
Ad.compareTo(new BigDecimal(25)) == 1 ? 0.85 : (
Ad.compareTo(new BigDecimal(20)) == 1 ? 0.95 : (
Ad.compareTo(new BigDecimal(15)) == 1 ? 0.8 : (
Ad.compareTo(new BigDecimal(10)) == 1 ? 0.9 :
0.95
))));
return count.toString();
Ad.compareTo(new BigDecimal(30))==1?0.8:(
Ad.compareTo(new BigDecimal(25))==1?0.85:(
Ad.compareTo(new BigDecimal(20))==1?0.95:(
Ad.compareTo(new BigDecimal(15))==1?0.8:(
Ad.compareTo(new BigDecimal(10))==1?0.9:
0.95
))));
return count.toString();
}
/**
* 求V,daf [Vdaf系数0.8~0.95]* Vdaf- [Ad系数0.1或0]*Ad
*
* @param countMap
* @return
*/
public static String countV_daf(Map<String, String> countMap) {
BigDecimal VdafXS = getBigDecimal(countMap.get("Vdaf系数0.8~0.95"));
BigDecimal Vdaf = getBigDecimal(countMap.get("Vdaf"));
BigDecimal AdXS = getBigDecimal(countMap.get("Ad系数0.1或0"));
BigDecimal Ad = getBigDecimal(countMap.get("Ad"));
BigDecimal VdafXS= getBigDecimal(countMap.get("Vdaf系数0.8~0.95"));
BigDecimal Vdaf= getBigDecimal(countMap.get("Vdaf"));
BigDecimal AdXS= getBigDecimal(countMap.get("Ad系数0.1或0"));
BigDecimal Ad= getBigDecimal(countMap.get("Ad"));
BigDecimal count = VdafXS.multiply(Vdaf).subtract(AdXS.multiply(Ad));
return count.toString();
return count.toString();
}
/**
* 求K0, if V,daf >8 8500 if V,daf >5.5 8400 if V,daf >3 8300 else 8200
*
* @param countMap
* @return
*/
public static String countK0_(Map<String, String> countMap) {
BigDecimal V_daf = getBigDecimal(countMap.get("V,daf"));
BigDecimal V_daf= getBigDecimal(countMap.get("V,daf"));
BigDecimal count =
V_daf.compareTo(new BigDecimal(8)) == 1 ? new BigDecimal(8500) : (
V_daf.compareTo(new BigDecimal(5.5)) == 1 ? new BigDecimal(8400) : (
V_daf.compareTo(new BigDecimal(3)) == 1 ? new BigDecimal(8300) :
new BigDecimal(8200)
));
return count.toString();
V_daf.compareTo(new BigDecimal(8))==1?new BigDecimal(8500):(
V_daf.compareTo(new BigDecimal(5.5))==1?new BigDecimal(8400):(
V_daf.compareTo(new BigDecimal(3))==1?new BigDecimal(8300):
new BigDecimal(8200)
));
return count.toString();
}
/**
* 求Qnet,ad MJ/kg
*
* @param countMap
* @return
*/
public static String countQnet_adMJ_kg(Map<String, Object> resultMap, Map<String, String> countMap) {
BigDecimal YWH_123 = getBigDecimal(resultMap.get("烟无褐123"));
BigDecimal K1_ = getBigDecimal(countMap.get("K1,"));
BigDecimal BC_Mad = getBigDecimal(countMap.get("报出_Mad"));
BigDecimal BC_Aad = getBigDecimal(countMap.get("报出_Aad"));
BigDecimal BC_Vad = getBigDecimal(countMap.get("报出_Vad"));
BigDecimal K = getBigDecimal(countMap.get("K"));
BigDecimal _40Mad_0_1 = getBigDecimal(countMap.get("40Mad 0或1"));
BigDecimal K0_ = getBigDecimal(countMap.get("K0,"));
public static String countQnet_adMJ_kg(Map<String, String> resultMap, Map<String, String> countMap) {
BigDecimal YWH_123= getBigDecimal(resultMap.get("烟无褐123"));
BigDecimal K1_= getBigDecimal(countMap.get("K1,"));
BigDecimal BC_Mad= getBigDecimal(countMap.get("报出_Mad"));
BigDecimal BC_Aad= getBigDecimal(countMap.get("报出_Aad"));
BigDecimal BC_Vad= getBigDecimal(countMap.get("报出_Vad"));
BigDecimal K= getBigDecimal(countMap.get("K"));
BigDecimal _40Mad_0_1= getBigDecimal(countMap.get("40Mad 0或1"));
BigDecimal K0_= getBigDecimal(countMap.get("K0,"));
BigDecimal value = null;
if (YWH_123.compareTo(new BigDecimal(3)) == 0) {
value = param100.multiply(K1_).subtract(K1_.add(new BigDecimal(6)).multiply(BC_Mad.add(BC_Aad)))
if(YWH_123.compareTo(new BigDecimal(3))==0){
value =param100.multiply(K1_).subtract(K1_.add(new BigDecimal(6)).multiply(BC_Mad.add(BC_Aad)))
.subtract(BC_Vad);
} else if (YWH_123.compareTo(new BigDecimal(1)) == 0) {
value = param100.multiply(K).subtract(K.add(new BigDecimal(6)).multiply(BC_Mad.add(BC_Aad)))
} else if(YWH_123.compareTo(new BigDecimal(1))==0){
value =param100.multiply(K).subtract(K.add(new BigDecimal(6)).multiply(BC_Mad.add(BC_Aad)))
.subtract(new BigDecimal(3).multiply(BC_Vad))
.subtract(new BigDecimal(40).multiply(BC_Mad).multiply(_40Mad_0_1));
} else if (YWH_123.compareTo(new BigDecimal(2)) == 0) {
value = K0_.subtract(new BigDecimal(86).multiply(BC_Mad))
}else if(YWH_123.compareTo(new BigDecimal(2))==0){
value =K0_.subtract(new BigDecimal(86).multiply(BC_Mad))
.subtract(new BigDecimal(92).multiply(BC_Aad))
.subtract(new BigDecimal(24).multiply(BC_Vad));
}
BigDecimal count = value.multiply(new BigDecimal(4.1816)).divide(param1000, 4);
return count.toString();
BigDecimal count = value.multiply(new BigDecimal(4.1816)).divide(param1000,4);
return count.toString();
}
/**
* 求易磨性等级
*
* @param resultMap
* @return
*/
public static String countYMXGrade(Map<String, Object> resultMap) {
BigDecimal YMX_kWh_t = getBigDecimal(resultMap.get("易磨性(kWh/t)"));
if (YMX_kWh_t.compareTo(new BigDecimal(18)) == 1) {
public static String countYMXGrade(Map<String, String> resultMap) {
BigDecimal YMX_kWh_t = getBigDecimal(resultMap.get("易磨性(kWh/t)"));
if(YMX_kWh_t.compareTo(new BigDecimal(18))==1){
return "E";
} else if (YMX_kWh_t.compareTo(new BigDecimal(13)) == 1) {
}else if(YMX_kWh_t.compareTo(new BigDecimal(13))==1){
return "D";
} else if (YMX_kWh_t.compareTo(new BigDecimal(10)) == 1) {
}else if(YMX_kWh_t.compareTo(new BigDecimal(10))==1){
return "C";
} else if (YMX_kWh_t.compareTo(new BigDecimal(8)) == 1) {
}else if(YMX_kWh_t.compareTo(new BigDecimal(8))==1){
return "B";
} else {
}else{
return "A";
}
}
/**
* 求易磨性校验码
*
* @param resultMap
* @return
*/
public static String countYMXCode(Map<String, Object> resultMap) {
Double G = Double.valueOf(resultMap.get("G").toString());
Double P80 = Double.valueOf(resultMap.get("P80").toString());
Double F80 = Double.valueOf(resultMap.get("F80").toString());
BigDecimal YMX_kWh_t = getBigDecimal(resultMap.get("易磨性(kWh/t)"));
BigDecimal YMX_MJ_t = getBigDecimal(resultMap.get("易磨性(MJ/t)"));
public static String countYMXCode(Map<String, String> resultMap) {
Double G = Double.valueOf(resultMap.get("G"));
Double P80 = Double.valueOf(resultMap.get("P80"));
Double F80 = Double.valueOf(resultMap.get("F80"));
BigDecimal YMX_kWh_t = getBigDecimal(resultMap.get("易磨性(kWh/t)"));
BigDecimal YMX_MJ_t = getBigDecimal(resultMap.get("易磨性(MJ/t)"));
Double countResult =
Math.pow(80, 0.23) * Math.pow(G, 0.82) * (10 / (Math.pow(P80, 0.5) - 10 / Math.pow(F80, 0.5)));
Math.pow(80,0.23)*Math.pow(G,0.82)*(10/(Math.pow(P80,0.5)- 10/Math.pow(F80,0.5)));
BigDecimal result1 = new BigDecimal(countResult);
BigDecimal value1 =
new BigDecimal(176.2).divide(result1, 4).subtract(new BigDecimal(3.6).multiply(new BigDecimal(P80))).abs();
BigDecimal value2 = YMX_MJ_t.divide(YMX_kWh_t, 4);
if (value1.compareTo(new BigDecimal(0.5)) == -1 &&
new BigDecimal(176.2).divide(result1,4).subtract(new BigDecimal(3.6).multiply(new BigDecimal(P80))).abs();
BigDecimal value2 = YMX_MJ_t.divide(YMX_kWh_t,4);
if(value1.compareTo(new BigDecimal(0.5) ) == -1 &&
value2.compareTo(new BigDecimal(3.5)) == 1 &&
value2.compareTo(new BigDecimal(3.7)) == -1) {
value2.compareTo(new BigDecimal(3.7)) == -1){
return "OK";
} else {
}else{
return "出错了";
}
}
/**
* 计算平行数
*
* @param mainResult 主样数据
* @param mainResult 主样数据
* @param secondaryResult 次样数据
* @return
*/
public static String countParallel(String mainResult, String secondaryResult) {
BigDecimal main = getBigDecimal(mainResult);
BigDecimal secondary = getBigDecimal(secondaryResult);
BigDecimal aveCount = main.add(secondary).divide(new BigDecimal(2), 2);
BigDecimal aveCount = main.add(secondary).divide(new BigDecimal(2),2);
BigDecimal result1 = aveCount.multiply(param100);
int resultInt1 = result1.setScale(0, BigDecimal.ROUND_DOWN).intValue();
int resultInt1 = result1.setScale( 0, BigDecimal.ROUND_DOWN ).intValue();
BigDecimal endResult = null;
if ((resultInt1 & 1) == 1) { //如果结果为奇数
endResult = aveCount.setScale(2, BigDecimal.ROUND_HALF_UP);
} else {
endResult = aveCount.subtract(new BigDecimal(0.0000000001)).setScale(2, BigDecimal.ROUND_HALF_UP);
if((resultInt1&1) == 1){ //如果结果为奇数
endResult = aveCount.setScale(2,BigDecimal.ROUND_HALF_UP);
}else{
endResult = aveCount.subtract(new BigDecimal(0.0000000001)).setScale(2,BigDecimal.ROUND_HALF_UP);
}
return endResult.toString();
return endResult.toString();
}
/**
* 计算平行样的平均值 最大误差值
*
* @return
*/
public static Map<String, Map<String, String>> countParallelAvgError(Map<String, String> groupMap) {
Map<String, Map<String, String>> map = new HashMap<>();
Map<String, String> countResults = new HashMap<>();
Map<String, String> countError = new HashMap<>();
for (Map.Entry<String, String> entry : groupMap.entrySet()) {
public static Map<String,Map<String,String>> countParallelAvgError(Map<String,String> groupMap) {
Map<String,Map<String,String>> map = new HashMap<>();
Map<String,String> countResults = new HashMap<>();
Map<String,String> countError = new HashMap<>();
for(Map.Entry<String,String> entry : groupMap.entrySet()){
String[] values = entry.getValue().split(",");
BigDecimal resultSum = null; //求总和
BigDecimal maxNum = null; //求最大值
BigDecimal minNum = null; //求最小值
for (String val : values) {
for(String val : values){
BigDecimal valBD = getBigDecimal(val);
resultSum = resultSum == null ? valBD : resultSum.add(valBD);
maxNum = maxNum == null ? valBD : (valBD.compareTo(maxNum) == 1 ? valBD : maxNum);
minNum = minNum == null ? valBD : (valBD.compareTo(minNum) == -1 ? valBD : minNum);
resultSum = resultSum == null?valBD:resultSum.add(valBD);
maxNum = maxNum ==null?valBD:(valBD.compareTo(maxNum) == 1?valBD:maxNum);
minNum = minNum==null?valBD:(valBD.compareTo(minNum) == -1?valBD:minNum);
}
//平均值
BigDecimal aveCount = resultSum.divide(new BigDecimal(values.length), 2);
BigDecimal aveCount = resultSum.divide(new BigDecimal(values.length),2);
BigDecimal result1 = aveCount.multiply(param100);
int resultInt1 = result1.setScale(0, BigDecimal.ROUND_DOWN).intValue();
int resultInt1 = result1.setScale( 0, BigDecimal.ROUND_DOWN ).intValue();
BigDecimal ResultsValue = null;
if ((resultInt1 & 1) == 1) { //如果结果为奇数
ResultsValue = aveCount.setScale(2, BigDecimal.ROUND_HALF_UP);
} else {
ResultsValue = aveCount.subtract(new BigDecimal(0.0000000001)).setScale(2, BigDecimal.ROUND_HALF_UP);
if((resultInt1&1) == 1){ //如果结果为奇数
ResultsValue = aveCount.setScale(2,BigDecimal.ROUND_HALF_UP);
}else{
ResultsValue = aveCount.subtract(new BigDecimal(0.0000000001)).setScale(2,BigDecimal.ROUND_HALF_UP);
}
//最大误差值
BigDecimal errorValue = maxNum.subtract(minNum).setScale(2, BigDecimal.ROUND_HALF_UP);
;
BigDecimal errorValue = maxNum.subtract(minNum).setScale(2,BigDecimal.ROUND_HALF_UP);;
countResults.put(entry.getKey(), ResultsValue.toString());
countError.put(entry.getKey(), errorValue.toString());
countResults.put(entry.getKey(),ResultsValue.toString());
countError.put(entry.getKey(),errorValue.toString());
}
map.put("countResults", countResults);
map.put("countError", countError);
return map;
map.put("countResults",countResults);
map.put("countError",countError);
return map;
}
}
......
......@@ -4,7 +4,6 @@ import org.apache.commons.io.FilenameUtils;
import org.csource.common.MyException;
import org.csource.common.NameValuePair;
import org.csource.fastdfs.*;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.io.InputStream;
......
......@@ -3,10 +3,9 @@ package cn.wise.sc.cement.business.util.weixin;
/**
* 功能说明:企业微信全局接口地址
* 修改说明:
*
* @author zhenglibing
* @version 0.1
* @date 2018年1月8日 下午2:27:43
* @version 0.1
*/
public interface Global {
......@@ -17,16 +16,29 @@ public interface Global {
*/
public static final String ACCESSTOKENURL = "https://qyapi.weixin.qq.com/cgi-bin/gettoken";
/**
* 微信公众平台,获取访问用户身份的接口地址,Https请求方式:GET
* 接口地址示例:https://qyapi.weixin.qq.com/cgi-bin/user/getuserinfo?access_token=ACCESS_TOKEN&code=CODE
*/
public static final String USERINFOURL = "https://qyapi.weixin.qq.com/cgi-bin/user/getuserinfo";
/**
* 微信公众平台,获取访问用户信息的接口地址,Https请求方式:GET
* 接口地址示例:https://qyapi.weixin.qq.com/cgi-bin/user/get?access_token=ACCESS_TOKEN&userid=USERID
*/
public static final String USERURL = "https://qyapi.weixin.qq.com/cgi-bin/user/get";
public static final String ticket = "https://qyapi.weixin.qq.com/cgi-bin/get_jsapi_ticket";
/**
* 微信公众平台,发送应用消息的接口地址,Https请求方式:GET
* 接口地址示例:https://qyapi.weixin.qq.com/cgi-bin/message/send?access_token=ACCESS_TOKEN
*/
public static final String SENDMESSAGE = "https://qyapi.weixin.qq.com/cgi-bin/message/send";
public static final String userTicket = "https://qyapi.weixin.qq.com/cgi-bin/ticket/get";
}
package cn.wise.sc.cement.business.util.weixin;
import cn.wise.sc.cement.business.model.ResultVO;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import org.apache.commons.lang3.StringUtils;
import org.springframework.http.*;
import org.springframework.util.MultiValueMap;
import org.springframework.web.client.RestTemplate;
import java.util.*;
/**
* 艺哚哚对外开放接口 工具类
* 对外开放接口 工具类
*/
public class WeixinInterfaceUtil {
private static final String HOST = "https://ydd.whlyj.sh.gov.cn/"; //服务器IP与端口
private static final String APPID = "DSACTSYS";
private static final String APPSECRET = "uzRpwnG6USeZDR0C";
// private static final Long TIMESTAMP = System.currentTimeMillis();
// private static final Long TIMESTAMP = System.currentTimeMillis();
private static final String NONCE = UUID.randomUUID().toString();
public static void main(String[] args) {
public static void main(String[] args){
String param = "corpid=%s&corpsecret=%s";
param = String.format(param, "ww348f91b2573c1867", "gFa_7XvXtCaoeAYERzjRwwz_OTJkJfgBb8weOKjmI3o");
try {
......@@ -30,19 +37,40 @@ public class WeixinInterfaceUtil {
e.printStackTrace();
}
}
public static JSONObject doGet(String url, String param) {
String path = url + "?" + param;
String path= url+"?"+ param;
RestTemplate restTemplate = new RestTemplate();
JSONObject resultMap = restTemplate.getForObject(path, JSONObject.class);
JSONObject resultMap = restTemplate.getForObject(path,JSONObject.class);
return resultMap;
}
/**
* 向目的URL发送post请求
* @param url 目的url
* @param params 发送的参数
* @return ResultVO
*/
public static ResultVO sendPostRequest(String url, MultiValueMap<String, String> params){
RestTemplate client = new RestTemplate();
HttpHeaders headers = new HttpHeaders();
HttpMethod method = HttpMethod.POST;
// 以表单的方式提交
headers.setContentType(MediaType.APPLICATION_FORM_URLENCODED);
//将请求头部和参数合成一个请求
HttpEntity<MultiValueMap<String, String>> requestEntity = new HttpEntity<>(params, headers);
//执行HTTP请求,将返回的结构使用ResultVO类格式化
ResponseEntity<ResultVO> response = client.exchange(url, method, requestEntity, ResultVO.class);
return response.getBody();
}
/**
* 将请求参数放到map里,
* 按照字母请求参数名的字母升序排列非空请求参数(包含 appid)
*
* @param sortedParams
* @return
*/
......@@ -68,4 +96,6 @@ public class WeixinInterfaceUtil {
return content.toString();
}
}
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