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