批量调整
This commit is contained in:
parent
f69c5a440e
commit
b0d5374034
@ -18,4 +18,5 @@ public interface LabResultMapper {
|
||||
int insertLabResultByBarcode(@Param("jyrq") Date jyrq, @Param("yq") String yq,@Param("ybh") String ybh,@Param("sqh") String sqh);
|
||||
int updateLabResultText(LabResult labResult);
|
||||
List<LabResult> getLabResultListAll(LabResult labResult);
|
||||
void updateByPrimaryKeySelective(LabResult labResult);
|
||||
}
|
||||
|
||||
@ -0,0 +1,47 @@
|
||||
package com.czlis.liswork.controller.work;
|
||||
|
||||
import com.czlis.common.core.controller.BaseController;
|
||||
import com.czlis.common.core.domain.Result;
|
||||
import com.czlis.common.core.domain.entity.lis.LabResult;
|
||||
import com.czlis.liswork.pojo.VO.BatchAdjustQueryVO;
|
||||
import com.czlis.liswork.service.BatchAdjustService;
|
||||
import io.swagger.annotations.Api;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 批量调整
|
||||
*/
|
||||
@RestController
|
||||
@RequestMapping("/batchCheck")
|
||||
@Slf4j
|
||||
@Api(tags = "批量调整")
|
||||
public class BatchAdjustController extends BaseController {
|
||||
|
||||
@Autowired
|
||||
BatchAdjustService batchAdjustService;
|
||||
|
||||
@ApiOperation("调整数据")
|
||||
@PostMapping("/adjustData")
|
||||
public Result adjustData(@RequestBody BatchAdjustQueryVO batchAdjustQueryVO){
|
||||
return batchAdjustService.adjustData(batchAdjustQueryVO);
|
||||
}
|
||||
|
||||
@ApiOperation("保存数据")
|
||||
@PostMapping("/saveData")
|
||||
public Result saveData(@RequestBody List<LabResult> resultList){
|
||||
return batchAdjustService.saveData(resultList,getUsername());
|
||||
}
|
||||
|
||||
|
||||
@ApiOperation("读取数据")
|
||||
@PostMapping("/readData")
|
||||
public Result readData(@RequestBody BatchAdjustQueryVO batchAdjustQueryVO){
|
||||
return batchAdjustService.readData(batchAdjustQueryVO);
|
||||
}
|
||||
|
||||
}
|
||||
@ -0,0 +1,10 @@
|
||||
package com.czlis.liswork.mapper.work;
|
||||
|
||||
import com.czlis.liswork.pojo.VO.BatchAdjustQueryVO;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
public interface BatchAdjustMapper {
|
||||
List<Map<String,Object>> queryData(BatchAdjustQueryVO batchAdjustQueryVO);
|
||||
}
|
||||
@ -0,0 +1,23 @@
|
||||
package com.czlis.liswork.pojo.VO;
|
||||
|
||||
import com.czlis.common.core.domain.entity.lis.LabResult;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
|
||||
@Data
|
||||
@AllArgsConstructor
|
||||
@NoArgsConstructor
|
||||
public class BatchAdjustQueryVO {
|
||||
private Date jyrq;
|
||||
private String ybh1;
|
||||
private String ybh2;
|
||||
private String xmdh;
|
||||
private String adjust;
|
||||
private String yq;
|
||||
private String allitem;
|
||||
private List<LabResult> labResultList;
|
||||
}
|
||||
@ -0,0 +1,15 @@
|
||||
package com.czlis.liswork.service;
|
||||
|
||||
import com.czlis.common.core.domain.Result;
|
||||
import com.czlis.common.core.domain.entity.lis.LabResult;
|
||||
import com.czlis.liswork.pojo.VO.BatchAdjustQueryVO;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public interface BatchAdjustService {
|
||||
Result readData(BatchAdjustQueryVO batchAdjustQueryVO);
|
||||
|
||||
Result saveData(List<LabResult> resultList,String userId);
|
||||
|
||||
Result adjustData(BatchAdjustQueryVO batchAdjustQueryVO);
|
||||
}
|
||||
@ -0,0 +1,122 @@
|
||||
package com.czlis.liswork.service.impl.work;
|
||||
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import com.czlis.common.core.domain.Result;
|
||||
import com.czlis.common.core.domain.entity.lis.LabPat;
|
||||
import com.czlis.common.core.domain.entity.lis.LabResult;
|
||||
import com.czlis.common.core.domain.entity.lis.XmInfo;
|
||||
import com.czlis.interfaceCommon.mapper.LabResultMapper;
|
||||
import com.czlis.interfaceCommon.utils.CommonUtil;
|
||||
import com.czlis.interfaceCommon.utils.LisWorkcom;
|
||||
import com.czlis.liswork.mapper.work.BatchAdjustMapper;
|
||||
import com.czlis.liswork.pojo.VO.BatchAdjustQueryVO;
|
||||
import com.czlis.liswork.service.BatchAdjustService;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import javax.script.ScriptEngine;
|
||||
import javax.script.ScriptEngineManager;
|
||||
import javax.script.ScriptException;
|
||||
import java.math.BigDecimal;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
@Slf4j
|
||||
@Service
|
||||
public class BatchAdjustServiceImpl implements BatchAdjustService {
|
||||
|
||||
@Autowired
|
||||
private BatchAdjustMapper batchAdjustMapper;
|
||||
@Autowired
|
||||
LisWorkcom lisWorkcom;
|
||||
@Autowired
|
||||
private CommonUtil commonUtil;
|
||||
@Autowired
|
||||
LabResultMapper labResultMapper;
|
||||
|
||||
@Override
|
||||
public Result readData(BatchAdjustQueryVO batchAdjustQueryVO) {
|
||||
List<Map<String, Object>> mapList = batchAdjustMapper.queryData(batchAdjustQueryVO);
|
||||
return new Result("0","查询成功!",mapList);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Result saveData(List<LabResult> resultList,String userId) {
|
||||
for (LabResult labResult : resultList) {
|
||||
Date jyrq = labResult.getJyrq();
|
||||
String yq = labResult.getYq();
|
||||
String ybh = labResult.getYbh();
|
||||
LabPat labPatOne = commonUtil.getLabPatOne(jyrq,yq,ybh);
|
||||
if(!lisWorkcom.canmodifysample(labPatOne)) return new Result("-1","没有权限修改报告!");
|
||||
lisWorkcom.setpatLog(jyrq,yq,ybh,userId);
|
||||
LabResult labResult1 = commonUtil.getLabResult(jyrq, yq, ybh, labResult.getXmdh());
|
||||
if(labResult1 == null){
|
||||
commonUtil.insertLabResult(labResult);
|
||||
}else{
|
||||
LabResult labResult2 = new LabResult();
|
||||
labResult2.setJyrq(jyrq);
|
||||
labResult2.setYq(yq);
|
||||
labResult2.setYbh(ybh);
|
||||
labResult2.setXmdh(labResult.getXmdh());
|
||||
labResult2.setCsjg(labResult.getCsjg());
|
||||
commonUtil.updateLabResult(labResult2);
|
||||
}
|
||||
}
|
||||
|
||||
//计算项目,修改labpat
|
||||
for (LabResult labResult : resultList) {
|
||||
Date jyrq = labResult.getJyrq();
|
||||
String yq = labResult.getYq();
|
||||
String ybh = labResult.getYbh();
|
||||
lisWorkcom.calcsample(jyrq,yq,ybh);
|
||||
LabPat labPat = new LabPat();
|
||||
labPat.setJyrq(jyrq);
|
||||
labPat.setYq(yq);
|
||||
labPat.setYbh(ybh);
|
||||
labPat.setLastuser(userId);
|
||||
labPat.setJgbz("1");
|
||||
labPat.setLastdt(commonUtil.getCurrentTime());
|
||||
commonUtil.updateLabPat(labPat);
|
||||
}
|
||||
|
||||
return new Result("0","保存成功!");
|
||||
}
|
||||
|
||||
@Override
|
||||
public Result adjustData(BatchAdjustQueryVO batchAdjustQueryVO) {
|
||||
String adjust = batchAdjustQueryVO.getAdjust();
|
||||
String yq = batchAdjustQueryVO.getYq();
|
||||
String xmdh = batchAdjustQueryVO.getXmdh();
|
||||
if(!adjust.contains("R") && StrUtil.isNumeric(adjust)) return new Result("-1","无效的调整公式!");
|
||||
XmInfo xmInfo = commonUtil.getXmInfo(yq, xmdh);
|
||||
int xsws = -1;
|
||||
if(xmInfo != null) xsws = xmInfo.getXsws();
|
||||
//计算之后的值
|
||||
List<LabResult> labResultList = batchAdjustQueryVO.getLabResultList();
|
||||
for (LabResult labResult : labResultList) {
|
||||
String csjg = labResult.getCsjg();
|
||||
csjg = adjust.replace("R",csjg);
|
||||
// 创建计算引擎
|
||||
ScriptEngine engine = new ScriptEngineManager().getEngineByName("JavaScript");
|
||||
// 计算
|
||||
String res = "";
|
||||
try {
|
||||
//保留的小数位数
|
||||
if(xsws != -1 && xsws != 0){
|
||||
res = String.format("(%s).toFixed(%d)", csjg, xsws);
|
||||
}else{
|
||||
res = String.format("Number((%s).toFixed(10)).toString()", csjg);
|
||||
}
|
||||
res = engine.eval(res).toString();
|
||||
labResult.setCsjg(res);
|
||||
} catch (ScriptException e) {
|
||||
log.error("表达式计算有误:",e);
|
||||
return new Result("-1","表达式计算有误!"+e.getMessage());
|
||||
}
|
||||
|
||||
}
|
||||
return new Result("0","计算成功!",labResultList);
|
||||
}
|
||||
}
|
||||
12
liswork/src/main/resources/mapper/work/BatchAdjustMapper.xml
Normal file
12
liswork/src/main/resources/mapper/work/BatchAdjustMapper.xml
Normal file
@ -0,0 +1,12 @@
|
||||
<?xml version="1.0" encoding="UTF-8" ?>
|
||||
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
"http://mybatis.org/dtd/mybatis-3-mapper.dtd" >
|
||||
<mapper namespace="com.czlis.liswork.mapper.work.BatchAdjustMapper">
|
||||
<select id="queryData" resultType="com.czlis.common.core.domain.entity.lis.LabResult">
|
||||
select * from lab_result where jyrq = #{jyrq} and xmdh = #{xmdh}
|
||||
<if test="yq != null and yq != ''">and yq = #{yq}</if>
|
||||
<if test="ybh1 != null and ybh1 != ''"><![CDATA[and ybh >= #{ybh1}]]></if>
|
||||
<if test="ybh2 != null and ybh2 != ''"><![CDATA[and ybh <= #{ybh2}]]></if>
|
||||
</select>
|
||||
|
||||
</mapper>
|
||||
Loading…
x
Reference in New Issue
Block a user