Commit 0ada32d0 authored by 竹天卫's avatar 竹天卫

委托管理 校核计算功能 完成到KH 检测项

parent ba9b09a9
......@@ -25,7 +25,7 @@ import static com.google.common.collect.Lists.newArrayList;
public class Swagger2Configuration {
//api接口包扫描路径
public static final String SWAGGER_SCAN_BASE_PACKAGE = "cn.wise.sc.cement";
public static final String SWAGGER_SCAN_BASE_PACKAGE = "cn.wise.sc.cement.business.controller";
public static final String VERSION = "1.0.0";
......@@ -33,8 +33,12 @@ public class Swagger2Configuration {
public Docket docket() {
return new Docket(DocumentationType.SWAGGER_2).groupName("swagger接口文档")
.apiInfo(new ApiInfoBuilder().title("swagger接口文档")
.contact(new Contact("Wisenergy", "http://www.wisenergy.cn/", "service@wisenergy.cn")).version("1.0").build())
.select().paths(PathSelectors.any()).build()
.contact(new Contact("Wisenergy", "http://www.wisenergy.cn/", "service@wisenergy.cn"))
.description("天津院项目")
.version(VERSION).build())
.select()
.apis(RequestHandlerSelectors.basePackage(SWAGGER_SCAN_BASE_PACKAGE))
.paths(PathSelectors.any()).build()
.securitySchemes(newArrayList(apiKey()))
.securityContexts(newArrayList(securityContext()))
.enableUrlTemplating(false)
......@@ -60,9 +64,6 @@ public class Swagger2Configuration {
return newArrayList(new SecurityReference("BearerToken", authorizationScopes));
}
@Value("${swagger.basic.username}")
private String username;
@Value("${swagger.basic.password}")
......
......@@ -60,7 +60,7 @@ public class EntityEnclosureController {
fileName = file.getOriginalFilename().substring(0,file.getOriginalFilename().lastIndexOf("."));
extName = file.getOriginalFilename().substring(file.getOriginalFilename().lastIndexOf("."));
}else {
return BaseResponse.errorMsg("该账号已在其他地方登陆");
return BaseResponse.errorMsg("登录信息失效");
}
String picUrl = filePath;
map.put("fileUrl",picUrl);
......@@ -90,7 +90,7 @@ public class EntityEnclosureController {
fileName = file.getOriginalFilename().substring(0,file.getOriginalFilename().lastIndexOf("."));
extName = file.getOriginalFilename().substring(file.getOriginalFilename().lastIndexOf("."));
}else {
return BaseResponse.errorMsg("该账号已在其他地方登陆");
return BaseResponse.errorMsg("登录信息失效");
}
String picUrl = filePath;
map.put("fileUrl",picUrl);
......@@ -135,7 +135,7 @@ public class EntityEnclosureController {
return BaseResponse.errorMsg("没有文件");
}
}else {
return BaseResponse.errorMsg("该账号已在其他地方登陆");
return BaseResponse.errorMsg("登录信息失效");
}
return BaseResponse.okData(map);
}catch (Exception e){
......@@ -159,7 +159,7 @@ public class EntityEnclosureController {
out.write(by);
out.close();
}else {
return BaseResponse.errorMsg("该账号已在其他地方登陆");
return BaseResponse.errorMsg("登录信息失效");
}
return BaseResponse.okMsg("成功");
}catch (Exception e){
......@@ -209,7 +209,7 @@ public class EntityEnclosureController {
}
}
}else {
return BaseResponse.errorMsg("该账号已在其他地方登陆");
return BaseResponse.errorMsg("登录信息失效");
}
return BaseResponse.okMsg("成功");
......
......@@ -12,11 +12,15 @@ import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import io.swagger.models.auth.In;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import java.util.List;
import java.util.Map;
/**
* <p>
* 前端控制器
......@@ -59,13 +63,13 @@ public class EntrustController {
return BaseResponse.errorMsg("失败!");
}
@ApiOperation(value = "置顶")
@ApiOperation(value = "置顶取消置顶 (createTime = updateTime显示置顶,否则显示取消置顶)")
@PostMapping("/setTopping")
public BaseResponse setTopping(Integer id) {
try {
return entrustService.setTopping(id);
}catch (Exception e) {
log.debug("置顶{}",e);
log.debug("置顶取消置顶{}",e);
}
return BaseResponse.errorMsg("失败!");
}
......@@ -151,9 +155,8 @@ public class EntrustController {
}
@ApiOperation(value = "接受样品处理任务")
@ApiImplicitParam(name = "ids", value = "样品处理表id集合", required = true, allowMultiple=true, dataType="Integer", paramType = "query")
@PostMapping("/acceptHandle")
public BaseResponse acceptHandle(Integer[] ids) {
public BaseResponse acceptHandle(@RequestBody Integer[] ids) {
try {
return entrustService.acceptHandle(ids);
}catch (Exception e) {
......@@ -196,9 +199,8 @@ public class EntrustController {
}
@ApiOperation(value = "完成样品处理任务")
@ApiImplicitParam(name = "ids", value = "样品处理表id集合", required = true, allowMultiple=true, dataType="Integer", paramType = "query")
@PostMapping("/finishHandle")
public BaseResponse finishHandle(Integer[] ids) {
public BaseResponse finishHandle(@RequestBody Integer[] ids) {
try {
return entrustService.finishHandle(ids);
}catch (Exception e) {
......@@ -247,9 +249,8 @@ public class EntrustController {
@ApiOperation(value = "接受检测项目任务")
@ApiImplicitParam(name = "ids", value = "任务派发表id集合", required = true, allowMultiple=true, dataType="Integer", paramType = "query")
@PostMapping("/acceptDistribution")
public BaseResponse acceptDistribution(Integer[] ids) {
public BaseResponse acceptDistribution(@RequestBody Integer[] ids) {
try {
return entrustService.acceptDistribution(ids);
}catch (Exception e) {
......@@ -271,9 +272,8 @@ public class EntrustController {
@ApiOperation(value = "完成检测项目任务")
@ApiImplicitParam(name = "ids", value = "任务派发表id集合", required = true, allowMultiple=true, dataType="Integer", paramType = "query")
@PostMapping("/finishDistribution")
public BaseResponse finishDistribution(Integer[] ids) {
public BaseResponse finishDistribution(@RequestBody Integer[] ids) {
try {
return entrustService.finishDistribution(ids);
}catch (Exception e) {
......@@ -336,9 +336,23 @@ public class EntrustController {
return BaseResponse.errorMsg("失败!");
}
@ApiOperation(value = "校核计算")
@PostMapping("/checkCount")
public BaseResponse checkCount(Integer teamGroupId, @RequestBody Map<String, Object> mainResult) {
try {
return entrustService.checkCount(teamGroupId, mainResult);
}catch (Exception e) {
log.debug("校核计算{}",e);
}
return BaseResponse.errorMsg("失败!");
}
@ApiOperation(value = "数据校核")
@PostMapping("/check")
public BaseResponse check(CheckQuery query) {
public BaseResponse check(@RequestBody CheckQuery query) {
try {
return entrustService.check(query);
}catch (Exception e) {
......
......@@ -5,6 +5,7 @@ import cn.wise.sc.cement.business.entity.SysGroup;
import cn.wise.sc.cement.business.entity.TeamGroup;
import cn.wise.sc.cement.business.model.BaseResponse;
import cn.wise.sc.cement.business.model.PageQuery;
import cn.wise.sc.cement.business.model.query.TeamGroupQuery;
import cn.wise.sc.cement.business.service.ITeamGroupService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
......@@ -51,7 +52,7 @@ public class TeamGroupController {
@ApiOperation(value = "新增检测组")
@PostMapping("/create")
public BaseResponse create(@RequestBody TeamGroup query) {
public BaseResponse create(@RequestBody TeamGroupQuery query) {
try {
return teamGroupService.create(query);
}catch (Exception e) {
......@@ -62,7 +63,7 @@ public class TeamGroupController {
@ApiOperation(value = "修改检测组")
@PostMapping("/update")
public BaseResponse update(@RequestBody TeamGroup query) {
public BaseResponse update(@RequestBody TeamGroupQuery query) {
try {
return teamGroupService.update(query);
}catch (Exception e) {
......
......@@ -50,7 +50,7 @@
left join client c on c.id = e.client_id
left join sys_user su on su.id = e.user_id
<include refid="where" />
order by e.update_time desc
order by e.is_urgent desc, e.update_time desc
</select>
<select id="getDetail" resultType="cn.wise.sc.cement.business.model.vo.EntrustVo">
......
......@@ -18,20 +18,13 @@ public class SampleCheckQuery {
@ApiModelProperty("样品表d")
private Integer sampleId;
@ApiModelProperty("本所编号")
private String cementCode;
@ApiModelProperty("检测人员id")
private String userId;
@ApiModelProperty("检测人员姓名")
private String userName;
@ApiModelProperty("检测设备表id")
private Integer equipmentId;
@ApiModelProperty("检测设备名称")
private String equipmentName;
@ApiModelProperty("基本元素检测结果 json串")
private String baseResult;
......
package cn.wise.sc.cement.business.model.query;
import com.alibaba.fastjson.JSONArray;
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableId;
import com.mysql.cj.xdevapi.JsonArray;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
......@@ -10,6 +12,7 @@ import lombok.experimental.Accessors;
import java.io.Serializable;
import java.time.LocalDateTime;
import java.util.Map;
/**
* <p>
......@@ -39,13 +42,13 @@ public class SampleCheckTeamQuery {
{"样重m":"40","K值":1.0274,"Vsio2":3.89,................}
*/
@ApiModelProperty("主样检测结果 json串")
private String main_result;
private Map<String, Object> mainResult;
@ApiModelProperty("次样检测结果json串")
private String secondary_result;
private JSONArray secondaryResult;
@ApiModelProperty("最终校核计算结果json串")
private String end_result;
private JSONArray endResult;
@ApiModelProperty("备注")
private String remark;
......
package cn.wise.sc.cement.business.model.query;
import com.alibaba.fastjson.JSONArray;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import java.math.BigDecimal;
import java.time.LocalDateTime;
/**
* @description:
* @author: qh
* @create: 2020-08-07 15:42
**/
@Data
public class TeamGroupQuery {
@ApiModelProperty("检测组id")
private Integer id;
@ApiModelProperty("检测组名称")
private String name;
@ApiModelProperty("校核元素 json串")
private JSONArray checkElement;
@ApiModelProperty("备注")
private String remark;
}
......@@ -87,6 +87,12 @@ public class EntrustVo {
@ApiModelProperty(" 剩余样品处理方法(0,取回,1由本所统一处置)")
private Integer handleMethod;
@ApiModelProperty("创建时间")
private LocalDateTime createTime;
@ApiModelProperty("修改时间")
private LocalDateTime updateTime;
@ApiModelProperty("备注")
private String remark;
......
......@@ -74,6 +74,8 @@ public interface IEntrustService extends IService<Entrust> {
BaseResponse<List<SampleDistribution>> getEnclosureList(Integer sampleId, Integer teamGroupId, Integer userId);
BaseResponse<Map<String, Object>> checkCount(Integer teamGroupId, Map<String, Object> mainResult);
BaseResponse<String> check(CheckQuery query);
......
......@@ -3,6 +3,7 @@ package cn.wise.sc.cement.business.service;
import cn.wise.sc.cement.business.entity.TeamGroup;
import cn.wise.sc.cement.business.model.BaseResponse;
import cn.wise.sc.cement.business.model.PageQuery;
import cn.wise.sc.cement.business.model.query.TeamGroupQuery;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.service.IService;
......@@ -18,9 +19,9 @@ public interface ITeamGroupService extends IService<TeamGroup> {
BaseResponse<IPage<TeamGroup>> getPage(PageQuery pageQuery, String name);
BaseResponse<TeamGroup> create(TeamGroup query);
BaseResponse<TeamGroup> create(TeamGroupQuery query);
BaseResponse<TeamGroup> update(TeamGroup query);
BaseResponse<TeamGroup> update(TeamGroupQuery query);
......
......@@ -3,20 +3,26 @@ package cn.wise.sc.cement.business.service.impl;
import cn.wise.sc.cement.business.entity.EntityEnclosure;
import cn.wise.sc.cement.business.entity.TeamGroup;
import cn.wise.sc.cement.business.mapper.EntityEnclosureMapper;
import cn.wise.sc.cement.business.mapper.TeamGroupMapper;
import cn.wise.sc.cement.business.mapper.TeamMapper;
import cn.wise.sc.cement.business.model.BaseResponse;
import cn.wise.sc.cement.business.model.query.EnclosureQuery;
import cn.wise.sc.cement.business.service.IEntityEnclosureService;
import cn.wise.sc.cement.business.util.CheckCountUtil;
import com.alibaba.fastjson.JSONArray;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import io.swagger.models.auth.In;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import javax.annotation.Resource;
import java.math.BigDecimal;
import java.math.BigInteger;
import java.text.SimpleDateFormat;
import java.time.LocalDateTime;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
import java.util.*;
@Service
public class CommonServiceImpl {
......@@ -25,6 +31,8 @@ public class CommonServiceImpl {
private EntityEnclosureMapper entityEnclosureMapper;
@Autowired
private IEntityEnclosureService entityEnclosureService;
@Resource
private TeamMapper teamMapper;
/**
* 生成编号
......@@ -151,6 +159,35 @@ public class CommonServiceImpl {
public Map<String, Object> checkCount(Integer teamGroupId, Map<String, Object> resultMap ){
List<String> checkResutlList = teamMapper.getByGroup(teamGroupId);
//100倍
BigDecimal param100 = new BigDecimal(100.00);
Map<String, Object> countMap = new HashMap<>();
for(String name : checkResutlList){
if(name.equals("L.O.I")){
countMap.put("L.O.I",CheckCountUtil.checkCount(name,resultMap));
}else if(name.equals("SiO2")){
countMap.put("SiO2",CheckCountUtil.checkCount(name,resultMap));
}
}
//合量
BigDecimal countHL = CheckCountUtil.countHL(countMap);
countMap.put("合量", countHL);
//KH
BigDecimal countKH = CheckCountUtil.countKH(countMap);
countMap.put("KH", countKH);
return countMap;
}
......
......@@ -162,7 +162,7 @@ public class EntrustServiceImpl extends ServiceImpl<EntrustMapper, Entrust> impl
}
/**
* 置顶
* 置顶取消置顶
* @param id 委托表id
* @return
*/
......@@ -174,9 +174,16 @@ public class EntrustServiceImpl extends ServiceImpl<EntrustMapper, Entrust> impl
if(entrust == null){
return BaseResponse.errorMsg("数据错误");
}
entrust.setUpdateTime(LocalDateTime.now());
String msg = "";
if(entrust.getCreateTime().isEqual(entrust.getUpdateTime())){
entrust.setUpdateTime(LocalDateTime.now());
msg = "置顶成功";
}else{
entrust.setUpdateTime(entrust.getCreateTime());
msg = "取消置顶成功";
}
entrustMapper.updateById(entrust);
return BaseResponse.okMsg("置顶成功");
return BaseResponse.okMsg(msg);
}
......@@ -478,7 +485,6 @@ public class EntrustServiceImpl extends ServiceImpl<EntrustMapper, Entrust> impl
}
if(query.getSampleHandleQueryList() != null && query.getSampleHandleQueryList().size()>0){
List<SampleHandleQuery> sampleHandleQueryList = query.getSampleHandleQueryList();
List<SampleHandle> sampleHandleList = new ArrayList<>();
for(SampleHandleQuery sampleHandleQuery : sampleHandleQueryList){
//样品处理表
SampleHandle sampleHandle = new SampleHandle();
......@@ -496,7 +502,7 @@ public class EntrustServiceImpl extends ServiceImpl<EntrustMapper, Entrust> impl
}
BeanUtils.copyProperties(sampleHandleQuery, sampleHandle);
sampleHandle.setStatus(0).setCreateTime(LocalDateTime.now());
sampleHandleList.add(sampleHandle);
sampleHandleMapper.insert(sampleHandle);
//样品处理项附件表
if(sampleHandle.getContent() != null){
String[] handIdS = sampleHandle.getContent().split("、");
......@@ -518,7 +524,6 @@ public class EntrustServiceImpl extends ServiceImpl<EntrustMapper, Entrust> impl
sampleHandleEnclosureService.saveBatch(sampleHandleEnclosureList);
}
}
sampleHandleService.saveBatch(sampleHandleList);
}
//该委托单下的样品改为已领用状态
/*QueryWrapper<Sample> sampleWrapper = new QueryWrapper<>();
......@@ -606,9 +611,32 @@ public class EntrustServiceImpl extends ServiceImpl<EntrustMapper, Entrust> impl
Map<String, Object> params = new HashMap<>();
params.put("id", id);
params.put("userId", loginUser.getId());
List<SampleHandleVo> SampleHandleList = sampleHandleMapper.getSampleHandleList(params);
List<SampleHandleVo> sampleHandleList = sampleHandleMapper.getSampleHandleList(params);
Integer handleStatus = null;
if(sampleHandleList != null && sampleHandleList.size()>0){
for(SampleHandleVo shVo : sampleHandleList){
if(handleStatus != null && handleStatus != shVo.getStatus()){
return BaseResponse.errorMsg("接受或完成的状态信息错误");
}
handleStatus = shVo.getStatus()==1?1:(shVo.getStatus()==2?2:0);
String contentName = "";
if(shVo.getContent() != null){
String[] handIdS = shVo.getContent().split("、");
List<SampleHandleEnclosure> sampleHandleEnclosureList = new ArrayList<>();
for(String handleId : handIdS){
Handle handle = handleMapper.selectById(Integer.valueOf(handleId));
if(handle == null){
return BaseResponse.errorMsg("选择的处理项信息有误");
}
contentName = contentName.equals("")?handle.getName():contentName+"、"+handle.getName();
}
}
shVo.setContentName(contentName);
}
}
entrust.setIsHandle(handleStatus); //0显示接受按钮,1显示完成按钮(可以上传附件),2和null不显示按钮
map.put("entrust", entrust);
map.put("SampleHandleList", SampleHandleList);
map.put("sampleHandleList", sampleHandleList);
return BaseResponse.okData(map);
}
......@@ -1029,7 +1057,7 @@ public class EntrustServiceImpl extends ServiceImpl<EntrustMapper, Entrust> impl
*/
@Transactional
@Override
public BaseResponse<String> finishDistribution(Integer[] ids){
public BaseResponse<String> finishDistribution(Integer[]ids){
LoginUser loginUser = userService.getLoginUser();
if(loginUser == null){
return BaseResponse.errorMsg("请登录账号");
......@@ -1234,7 +1262,6 @@ public class EntrustServiceImpl extends ServiceImpl<EntrustMapper, Entrust> impl
return BaseResponse.okData(sampleCheckVoList);
}
//
/**
* 根据样品id,检测组id,检测人id 查询任务检测附件信息
......@@ -1253,12 +1280,20 @@ public class EntrustServiceImpl extends ServiceImpl<EntrustMapper, Entrust> impl
}
//校核计算
public BaseResponse<String> checkCount(CheckQuery query){
/**
* 校核计算
* @param teamGroupId
* @param mainResult
* @return
*/
public BaseResponse<Map<String, Object>> checkCount(Integer teamGroupId, Map<String, Object> mainResult){
Map<String, Object> map = commonService.checkCount(teamGroupId, mainResult);
return BaseResponse.okData(map);
}
return null;
}
//校核保存
......@@ -1306,7 +1341,6 @@ public class EntrustServiceImpl extends ServiceImpl<EntrustMapper, Entrust> impl
check.setSampleId(checkQuery.getSampleId())
.setUserId(loginUser.getId())
.setEquipmentId(checkQuery.getEquipmentId())
.setEquipmentName(checkQuery.getEquipmentName())
.setCreateTime(LocalDateTime.now());
sampleCheckService.save(check);
String testItems = "";
......
......@@ -7,13 +7,17 @@ import cn.wise.sc.cement.business.mapper.TeamGroupMapper;
import cn.wise.sc.cement.business.mapper.TeamMapper;
import cn.wise.sc.cement.business.model.BaseResponse;
import cn.wise.sc.cement.business.model.PageQuery;
import cn.wise.sc.cement.business.model.query.TeamGroupQuery;
import cn.wise.sc.cement.business.model.vo.GroupVo;
import cn.wise.sc.cement.business.service.ITeamGroupService;
import com.alibaba.fastjson.JSON;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.BeanUtils;
import org.springframework.context.annotation.Bean;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
......@@ -58,7 +62,7 @@ public class TeamGroupServiceImpl extends ServiceImpl<TeamGroupMapper, TeamGroup
*/
@Override
@Transactional
public BaseResponse<TeamGroup> create(TeamGroup query) {
public BaseResponse<TeamGroup> create(TeamGroupQuery query) {
if (StringUtils.isEmpty(query.getName())) {
return BaseResponse.errorMsg("检测项组名称不能为空!");
}
......@@ -68,9 +72,17 @@ public class TeamGroupServiceImpl extends ServiceImpl<TeamGroupMapper, TeamGroup
if (count > 0) {
return BaseResponse.errorMsg(query.getName() + "已存在");
}
query.setCreateTime(LocalDateTime.now());
teamGroupMapper.insert(query);
return BaseResponse.okData(query);
TeamGroup teamGroup = new TeamGroup();
BeanUtils.copyProperties(query, teamGroup);
if(query.getCheckElement() != null && query.getCheckElement().size()>0){
String checkElement = JSON.toJSON(query.getCheckElement()).toString();
teamGroup.setCheckElement(checkElement);
}else{
teamGroup.setCheckElement(null);
}
teamGroup.setCreateTime(LocalDateTime.now());
teamGroupMapper.insert(teamGroup);
return BaseResponse.okData(teamGroup);
}
/**
......@@ -80,7 +92,7 @@ public class TeamGroupServiceImpl extends ServiceImpl<TeamGroupMapper, TeamGroup
*/
@Override
@Transactional
public BaseResponse<TeamGroup> update(TeamGroup query) {
public BaseResponse<TeamGroup> update(TeamGroupQuery query) {
if (StringUtils.isEmpty(query.getName())) {
return BaseResponse.errorMsg("检测项组名称不能为空!");
}
......@@ -91,8 +103,18 @@ public class TeamGroupServiceImpl extends ServiceImpl<TeamGroupMapper, TeamGroup
if (count > 0) {
return BaseResponse.errorMsg(query.getName() + "已存在");
}
teamGroupMapper.updateById(query);
return BaseResponse.okData(query);
TeamGroup teamGroup = teamGroupMapper.selectById(query.getId());
if(teamGroup == null){
return BaseResponse.errorMsg("数据错误!");
}
if(query.getCheckElement() != null && query.getCheckElement().size()>0){
String checkElement = JSON.toJSON(query.getCheckElement()).toString();
teamGroup.setCheckElement(checkElement);
}else{
teamGroup.setCheckElement(null);
}
teamGroupMapper.updateById(teamGroup);
return BaseResponse.okData(teamGroup);
}
......
......@@ -62,8 +62,8 @@ public class UserServiceImpl extends ServiceImpl<SysUserMapper, SysUser> impleme
public LoginUser getLoginUser() {
try {
String token = request.getHeader("Authorization");
System.out.println("==================Authorization===================");
System.out.println(token);
// System.out.println("==================Authorization===================");
// System.out.println(token);
Map map = JwtUtil.parserToken(token);
Object obj = redisUtil.getString(map.get("id").toString());
BusinessExceptionEnum.CACHE_NOT_FOUND.assertNotNull(obj);
......
......@@ -46,19 +46,20 @@ public class WeiXinService {
System.out.println("==================code===================");
System.out.println(code);
try {
String accessToken = getAccessToken();
String param = "access_token=%s&code=%s";
param = String.format(param, accessToken, code);
JSONObject jsonObject = WeixinInterfaceUtil.doGet(Global.USERINFOURL, param);
if(jsonObject.get("errcode").toString().equals("40029")){
return BaseResponse.errorMsg("code失效!");
}
String UserId = jsonObject.getString("UserId");
System.out.println("==================UserId===================");
System.out.println(UserId);
JSONObject userJson = getUser(accessToken, UserId);
// String accessToken = getAccessToken();
// String param = "access_token=%s&code=%s";
// param = String.format(param, accessToken, code);
// JSONObject jsonObject = WeixinInterfaceUtil.doGet(Global.USERINFOURL, param);
// if(jsonObject.get("errcode").toString().equals("40029")){
// return BaseResponse.errorMsg("code失效!");
// }
// String UserId = jsonObject.getString("UserId");
// System.out.println("==================UserId===================");
// System.out.println(UserId);
// JSONObject userJson = getUser(accessToken, UserId);
QueryWrapper<SysUser> wrapper = new QueryWrapper<>();
wrapper.eq("phone", userJson.get("mobile"));
// wrapper.eq("phone", userJson.get("mobile"));
wrapper.eq("phone", code); //暂时用手机号代替code
SysUser sysUser = userService.getOne(wrapper);
if(sysUser == null){
return BaseResponse.errorMsg("非系统用户不允许登录!");
......
package cn.wise.sc.cement.business.util;
import org.apache.poi.hssf.usermodel.HSSFWorkbook;
import org.apache.poi.ss.formula.functions.T;
import org.apache.poi.ss.usermodel.*;
import javax.servlet.http.HttpServletResponse;
import java.io.*;
import java.math.BigDecimal;
import java.math.BigInteger;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
/**
* excel工具类
*
* @author zhutianwei
*
*/
public class CheckCountUtil {
//倍数
public final static BigDecimal param10 = new BigDecimal(10.00);
public final static BigDecimal param100 = new BigDecimal(100.00);
public final static BigDecimal param1000 = new BigDecimal(1000.00);
//object 转成 BigDecimal
public static BigDecimal getBigDecimal(Object value ) {
BigDecimal ret = null;
if( value != null ) {
if( value instanceof BigDecimal ) {
ret = (BigDecimal) value;
} else if( value instanceof String ) {
ret = new BigDecimal( (String) value );
} else if( value instanceof BigInteger) {
ret = new BigDecimal( (BigInteger) value );
} else if( value instanceof Number ) {
ret = new BigDecimal( ((Number)value).doubleValue() );
} else {
throw new ClassCastException("Not possible to coerce ["+value+"] from class "+value.getClass()+" into a BigDecimal.");
}
}
return ret;
}
/**
* 检测项名称
* @param name
* @return
*/
//加 add 减 subtract 乘 multiply 除 divide
public static BigDecimal checkCount(String name, Map<String, Object> resultMap) {
BigDecimal endResult = null;
if(name.equals("L.O.I")){
//样重m1—保留4位⼩数
BigDecimal m1 = getBigDecimal(resultMap.get("样重m1")).setScale(4,BigDecimal.ROUND_HALF_UP);
//空堝重m2—保留4位⼩数
BigDecimal m2 = getBigDecimal(resultMap.get("空堝重m2")).setScale(4,BigDecimal.ROUND_HALF_UP);
//烧后重m3—保留4位⼩数
BigDecimal m3 = getBigDecimal(resultMap.get("烧后重m3")).setScale(4,BigDecimal.ROUND_HALF_UP);
//计算的核心公式结果
BigDecimal countResult = (m1.add(m2).subtract(m3)).divide(m1);
BigDecimal result1 = countResult.multiply(param100.multiply(param100));
int resultInt1 = result1.setScale( 0, BigDecimal.ROUND_DOWN ).intValue();
if((resultInt1&1) == 1){ //如果结果为奇数
endResult = countResult.multiply(param100).setScale(2,BigDecimal.ROUND_HALF_UP);
}else{
endResult = countResult.multiply(param100).subtract(new BigDecimal(0.0000000001)).setScale(2,BigDecimal.ROUND_HALF_UP);
}
}else if(name.equals("SiO2")){
//毫升数
BigDecimal VSiO2 = getBigDecimal(resultMap.get("VSiO2"));
//滴定度
BigDecimal TSiO2 = getBigDecimal(resultMap.get("TSiO2"));
//样m
BigDecimal m = getBigDecimal(resultMap.get("样重m"));
//计算的核心公式结果
BigDecimal countResult = VSiO2.multiply(TSiO2).divide(m);
BigDecimal result1 = countResult.multiply(param100);
int resultInt1 = result1.setScale( 0, BigDecimal.ROUND_DOWN ).intValue();
if((resultInt1&1) == 1){ //如果结果为奇数
endResult = countResult.setScale(2,BigDecimal.ROUND_HALF_UP);
}else{
endResult = countResult.subtract(new BigDecimal(0.0000000001)).setScale(2,BigDecimal.ROUND_HALF_UP);
}
}else if(name.equals("Al2O3+TiO2")){
BigDecimal TAl2O3 = getBigDecimal(resultMap.get("TAl2O3"));
BigDecimal VAl2O3 = getBigDecimal(resultMap.get("VAl2O3"));
BigDecimal K = getBigDecimal(resultMap.get("K"));
BigDecimal VCuSO4_I = getBigDecimal(resultMap.get("VCuSO4(I)"));
BigDecimal m = getBigDecimal(resultMap.get("样重m"));
//计算的核心公式结果
BigDecimal countResult = TAl2O3.multiply(VAl2O3.subtract(K.multiply(VCuSO4_I))).divide(m);
BigDecimal result1 = countResult.multiply(param100);
int resultInt1 = result1.setScale( 0, BigDecimal.ROUND_DOWN ).intValue();
if((resultInt1&1) == 1){ //如果结果为奇数
endResult = countResult.setScale(2,BigDecimal.ROUND_HALF_UP);
}else{
endResult = countResult.subtract(new BigDecimal(0.0000000001)).setScale(2,BigDecimal.ROUND_HALF_UP);
}
}else if(name.equals("Al2O3")){
BigDecimal TAl2O3 = getBigDecimal(resultMap.get("TAl2O3"));
BigDecimal VAl2O3 = getBigDecimal(resultMap.get("VAl2O3"));
BigDecimal K = getBigDecimal(resultMap.get("K"));
BigDecimal VCuSO4_I = getBigDecimal(resultMap.get("VCuSO4(I)"));
BigDecimal m = getBigDecimal(resultMap.get("样重m"));
BigDecimal VCuSO4_II = getBigDecimal(resultMap.get("VCuSO4(II)"));
//计算的核心公式结果
BigDecimal countResult = TAl2O3.multiply(VAl2O3.subtract(K.multiply(VCuSO4_I.add(VCuSO4_II)))).divide(m);
BigDecimal result1 = countResult.multiply(param100);
int resultInt1 = result1.setScale( 0, BigDecimal.ROUND_DOWN ).intValue();
if((resultInt1&1) == 1){ //如果结果为奇数
endResult = countResult.setScale(2,BigDecimal.ROUND_HALF_UP);
}else{
endResult = countResult.subtract(new BigDecimal(0.0000000001)).setScale(2,BigDecimal.ROUND_HALF_UP);
}
}else if(name.equals("Fe2O3")){
BigDecimal TFe2O3 = getBigDecimal(resultMap.get("TFe2O3"));
BigDecimal VF2O3 = getBigDecimal(resultMap.get("VF2O3"));
BigDecimal m = getBigDecimal(resultMap.get("样重m"));
//计算的核心公式结果
BigDecimal countResult = TFe2O3.multiply(VF2O3).divide(m);
BigDecimal result1 = countResult.multiply(param100);
int resultInt1 = result1.setScale( 0, BigDecimal.ROUND_DOWN ).intValue();
if((resultInt1&1) == 1){ //如果结果为奇数
endResult = countResult.setScale(2,BigDecimal.ROUND_HALF_UP);
}else{
endResult = countResult.subtract(new BigDecimal(0.0000000001)).setScale(2,BigDecimal.ROUND_HALF_UP);
}
}else if(name.equals("Cl")){
BigDecimal T = getBigDecimal(resultMap.get("T"));
BigDecimal V2 = getBigDecimal(resultMap.get("V2 "));
BigDecimal V1 = getBigDecimal(resultMap.get("V1 "));
BigDecimal mCl = getBigDecimal(resultMap.get("样重Cl"));
//计算的核心公式结果
BigDecimal countResult = T.multiply(V2.subtract(V1)).divide(mCl).divide(param10);
BigDecimal result1 = countResult.multiply(param1000);
int resultInt1 = result1.setScale( 0, BigDecimal.ROUND_DOWN ).intValue();
if((resultInt1&1) == 1){ //如果结果为奇数
endResult = countResult.setScale(3,BigDecimal.ROUND_HALF_UP);
}else{
endResult = countResult.subtract(new BigDecimal(0.00000000001)).setScale(3,BigDecimal.ROUND_HALF_UP);
}
}else if(name.equals("CaO")){
BigDecimal TCaO = getBigDecimal(resultMap.get("TCaO"));
BigDecimal VCaO = getBigDecimal(resultMap.get("VCaO"));
BigDecimal m = getBigDecimal(resultMap.get("样重m"));
//计算的核心公式结果
BigDecimal countResult = TCaO.multiply(VCaO).divide(m);
BigDecimal result1 = countResult.multiply(param100);
int resultInt1 = result1.setScale( 0, BigDecimal.ROUND_DOWN ).intValue();
if((resultInt1&1) == 1){ //如果结果为奇数
endResult = countResult.setScale(2,BigDecimal.ROUND_HALF_UP);
}else{
endResult = countResult.subtract(new BigDecimal(0.00000000001)).setScale(2,BigDecimal.ROUND_HALF_UP);
}
}
return endResult;
}
/**
* 求合量 L.O.I+SiO2+Al2O3+Fe2O3+CaO+MgO+TiO2+K2O+Na2O+MnO+SO3
* @param countMap
* @return
*/
public static BigDecimal countHL(Map<String, Object> countMap) {
List<String> list = new ArrayList<>();
list.add(countMap.get("L.O.I").toString());
list.add(countMap.get("SiO2").toString());
list.add(countMap.get("Al2O3").toString());
list.add(countMap.get("Fe2O3").toString());
list.add(countMap.get("CaO").toString());
list.add(countMap.get("MgO").toString());
list.add(countMap.get("TiO2").toString());
list.add(countMap.get("K2O").toString());
list.add(countMap.get("Na2O").toString());
list.add(countMap.get("MnO").toString());
list.add(countMap.get("SO3").toString());
BigDecimal count=new BigDecimal(0);
for(String s:list) {
count = count.add(new BigDecimal(s));
}
return count;
}
/**
* 求KH (CaO - 1.65*{Al2O3+TiO2} * Fe2O3) / 2.8 / SiO2
* @param countMap
* @return
*/
public static BigDecimal countKH(Map<String, Object> countMap) {
BigDecimal CaO = getBigDecimal(countMap.get("Cao"));
BigDecimal Al2O3_TiO2= getBigDecimal(countMap.get("Al2O3+TiO2"));
BigDecimal Fe2O3 = getBigDecimal(countMap.get("Fe2O3"));
BigDecimal SiO2 = getBigDecimal(countMap.get("SiO2"));
BigDecimal KH =
CaO.subtract(new BigDecimal(1.65).multiply(Al2O3_TiO2).multiply(Fe2O3)).divide(new BigDecimal(2.8)).divide(SiO2);
return KH;
}
}
//计算多个值的和
/*List<String> list=new ArrayList<>();
list.add("123.0");
list.add("12.0");
list.add("3.0");
BigDecimal count=new BigDecimal(0);
for(String s:list) {
count = count.add(new BigDecimal(s));
}
System.out.println(count);
*/
......@@ -21,6 +21,10 @@ spring:
port: 6379
host: localhost
# password: Wise_@123456
servlet:
multipart:
max-file-size: 100MB
max-request-size: 100MB
# 设置swagger用户名密码
swagger:
basic:
......
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