Commit 624b9ace authored by 竹天卫's avatar 竹天卫

校核平行样的误差和结果值 优化

parent 071dd8f3
...@@ -27,6 +27,8 @@ public interface TeamMapper extends BaseMapper<Team> { ...@@ -27,6 +27,8 @@ public interface TeamMapper extends BaseMapper<Team> {
List<TeamListVo> getList(); List<TeamListVo> getList();
List<String> getNameList();
TeamVo getDetail(Integer id); TeamVo getDetail(Integer id);
List<Map<String, Object>> exportList(@Param("params") Map<String, Object> params); List<Map<String, Object>> exportList(@Param("params") Map<String, Object> params);
......
...@@ -30,7 +30,7 @@ ...@@ -30,7 +30,7 @@
FROM team t FROM team t
left join team_group tg on tg.id = t.group_id left join team_group tg on tg.id = t.group_id
<include refid="where"/> <include refid="where"/>
ORDER BY t.create_time desc ORDER BY t.group_id, t.id ASC
</select> </select>
<select id="exportList" resultType="java.util.HashMap"> <select id="exportList" resultType="java.util.HashMap">
...@@ -58,9 +58,17 @@ ...@@ -58,9 +58,17 @@
t.method_name as methodName, t.number as number t.method_name as methodName, t.number as number
FROM team t FROM team t
where t.status=1 and t.is_display = 1 where t.status=1 and t.is_display = 1
ORDER BY t.id ASC ORDER BY t.group_id, t.id ASC
</select> </select>
<select id="getNameList" resultType="java.lang.String">
SELECT t.name as name
FROM team t
where t.status=1 and t.is_display = 1
ORDER BY t.group_id, t.id ASC
</select>
<select id="getDetail" resultType="cn.wise.sc.cement.business.model.vo.TeamVo"> <select id="getDetail" resultType="cn.wise.sc.cement.business.model.vo.TeamVo">
SELECT t.*, tg.name as groupName, SELECT t.*, tg.name as groupName,
......
...@@ -354,6 +354,118 @@ public class DataStatisticsServiceImpl implements IDataStatisticsService { ...@@ -354,6 +354,118 @@ public class DataStatisticsServiceImpl implements IDataStatisticsService {
} }
/**
* 委托单进展统计-列表导出(新)
* @param cycle
* @param startDate
* @param endDate
* @param clientId
* @param clientName
* @param fileName
* @param response
*/
public void exportEntrustIngList(Integer cycle, String startDate,
String endDate, Integer clientId, String clientName, String fileName, HttpServletResponse response){
Map<String, Object> params = new HashMap<>();
params.put("cycle", cycle);
params.put("startDate", startDate);
params.put("endDate", endDate);
params.put("clientId", clientId);
params.put("clientName", clientName);
List<Map<String, Object>> list = dataStatisticsMapper.exportEntrustList(params);
List<String> teamNameList = teamMapper.getNameList();
if(teamNameList ==null || teamNameList.size()<=0){
return;
}
if (!CollectionUtils.isEmpty(list)) {
String[] headers = new String[12];
headers[0] = "序号";
headers[1] = "委托单号";
headers[2] = "项目名称";
headers[3] = "项目编号";
headers[4] = "项目类型";
headers[5] = "委托人";
headers[6] = "委托单位";
headers[7] = "委托日期";
headers[8] = "样品数量";
headers[9] = "检测项目";
headers[10] = "产值";
headers[11] = "状态";
for(int i=0; i<teamNameList.size(); i++){
headers[12+i] = teamNameList.get(i);
}
List<Object[]> datas = new ArrayList<>(list.size());
for (Map<String, Object> m : list) {
Object[] objects = new Object[headers.length];
String objj = m.get("entrustId").toString();
Integer entrustId = Integer.valueOf(objj);
//只统计主样的信息
List<Sample> sampleList = sampleMapper.getSampleList(entrustId);
//检测项目名称
List<Integer> teamIdList = new ArrayList<>();
Map<String, Integer> teamMap = new HashMap<>();
//所有样品主样的产值
BigDecimal outputValue = new BigDecimal("0.00");
if (sampleList != null && sampleList.size() > 0) {
//样品名称 列表中的拼接
for (Sample sample : sampleList) {
if(sample.getOutputValue() != null){
outputValue = outputValue.compareTo(BigDecimal.ZERO) == 0 ?
sample.getOutputValue() : (outputValue.add(sample.getOutputValue()));
}
String teamIds = sample.getTeamIds();
String checkTeam = "";
if (teamIds != null) {
String[] teamIdS = teamIds.split("、");
for (String teamId : teamIdS) {
Team team = teamMapper.selectById(Integer.valueOf(teamId));
if (team != null) {
if(!teamIdList.contains(team.getId())){
teamMap.put(team.getName(), 1);
teamIdList.add(team.getId());
}else{
teamMap.put(team.getName(), teamMap.get(team.getName())+1);
}
checkTeam = checkTeam.equals("") ? team.getName() : (checkTeam + "、" + team.getName());
}
}
}
}
}
// JSONArray checkElementArray = mapToJSONArray(teamMap);
// String teamString = JSON.toJSON(checkElementArray).toString();
for (int j = 0; j < headers.length; j++) {
String obj = "";
if(j == 9){
objects[9] = teamMap;
}else if(j == 10){
objects[10] = outputValue;
}else{
obj = m.get(headers[j]).toString();
if (j == 0) {
obj = obj.split("\\.")[0];
}
objects[j] = obj;
}
}
datas.add(objects);
}
ExcelUtil.excelExport(
fileName == null || fileName.trim().length() <= 0 ? "委托单进展统计-列表导出" : fileName, headers,
datas, response);
}
}
/** /**
* 进行中任务数量统计 * 进行中任务数量统计
......
...@@ -3611,6 +3611,11 @@ public class EntrustServiceImpl extends ServiceImpl<EntrustMapper, Entrust> impl ...@@ -3611,6 +3611,11 @@ public class EntrustServiceImpl extends ServiceImpl<EntrustMapper, Entrust> impl
if (entrust == null) { if (entrust == null) {
return BaseResponse.errorMsg("信息错误"); return BaseResponse.errorMsg("信息错误");
} }
Sample sample_this = sampleMapper.selectById(query.getSmapleId());
if(sample_this == null){
return BaseResponse.errorMsg("样品信息错误");
}
entrust.setStatus(7); //校核中状态 entrust.setStatus(7); //校核中状态
//保存校核输入表信息 //保存校核输入表信息
QueryWrapper<SampleDistributionCheckinput> checkinputQueryWrapper = new QueryWrapper<>(); QueryWrapper<SampleDistributionCheckinput> checkinputQueryWrapper = new QueryWrapper<>();
...@@ -3647,6 +3652,9 @@ public class EntrustServiceImpl extends ServiceImpl<EntrustMapper, Entrust> impl ...@@ -3647,6 +3652,9 @@ public class EntrustServiceImpl extends ServiceImpl<EntrustMapper, Entrust> impl
sampleDistributionCheckinputMapper.insert(checkinput); sampleDistributionCheckinputMapper.insert(checkinput);
} }
//根据按钮判断 //根据按钮判断
if(query.getIsAgree() == 0){ //保存 if(query.getIsAgree() == 0){ //保存
//保存校核结果信息 //保存校核结果信息
...@@ -3665,6 +3673,36 @@ public class EntrustServiceImpl extends ServiceImpl<EntrustMapper, Entrust> impl ...@@ -3665,6 +3673,36 @@ public class EntrustServiceImpl extends ServiceImpl<EntrustMapper, Entrust> impl
sampleDistributionCheckMapper.updateById(disCheck); sampleDistributionCheckMapper.updateById(disCheck);
dis.setCheckId(disCheck.getId()); dis.setCheckId(disCheck.getId());
}else{ }else{
//判断是否有平行样
List<Sample> otherSampleList = sampleMapper.getOtherSampleList(entrust.getId(), sample_this.getCementCode(), sample_this.getId());
if(otherSampleList != null && otherSampleList.size() > 0){
for(Sample s : otherSampleList){
QueryWrapper<SampleDistribution> ortherWrapper = new QueryWrapper<>();
ortherWrapper.eq("entrust_id", entrust.getId());
ortherWrapper.eq("sample_id", s.getId());
ortherWrapper.eq("team_group_id", dis.getTeamGroupId());
ortherWrapper.eq("team_id", dis.getTeamId());
List<SampleDistribution> ortherDdistributionList = distributionMapper.selectList(ortherWrapper);
if(ortherDdistributionList.size() > 1 ){
return BaseResponse.errorMsg("检测派发表检测项信息重复");
}
if(ortherDdistributionList != null && ortherDdistributionList.size()>0){
SampleDistribution other = ortherDdistributionList.get(0);
if(other.getCheckId() != null){
dis.setCheckId(other.getCheckId());
}
}
}
//如果其他的平行样也都没有进行校核,则新增校核内容
if(dis.getCheckId() != null){
SampleDistributionCheck disCheck = sampleDistributionCheckMapper.selectById(dis.getCheckId());
disCheck.setDistributionError(disQuery.getDistributionError())
.setLastResult(disQuery.getLastResult())
.setUpdateTime(LocalDateTime.now());
sampleDistributionCheckMapper.updateById(disCheck);
}else{
SampleDistributionCheck disCheck = new SampleDistributionCheck(); SampleDistributionCheck disCheck = new SampleDistributionCheck();
disCheck.setDistributionError(disQuery.getDistributionError()) disCheck.setDistributionError(disQuery.getDistributionError())
.setLastResult(disQuery.getLastResult()) .setLastResult(disQuery.getLastResult())
...@@ -3673,6 +3711,16 @@ public class EntrustServiceImpl extends ServiceImpl<EntrustMapper, Entrust> impl ...@@ -3673,6 +3711,16 @@ public class EntrustServiceImpl extends ServiceImpl<EntrustMapper, Entrust> impl
sampleDistributionCheckMapper.insert(disCheck); sampleDistributionCheckMapper.insert(disCheck);
dis.setCheckId(disCheck.getId()); dis.setCheckId(disCheck.getId());
} }
}else{
SampleDistributionCheck disCheck = new SampleDistributionCheck();
disCheck.setDistributionError(disQuery.getDistributionError())
.setLastResult(disQuery.getLastResult())
.setCreateTime(LocalDateTime.now())
.setUpdateTime(LocalDateTime.now());
sampleDistributionCheckMapper.insert(disCheck);
dis.setCheckId(disCheck.getId());
}
}
distributionMapper.updateById(dis); distributionMapper.updateById(dis);
} }
...@@ -3694,6 +3742,45 @@ public class EntrustServiceImpl extends ServiceImpl<EntrustMapper, Entrust> impl ...@@ -3694,6 +3742,45 @@ public class EntrustServiceImpl extends ServiceImpl<EntrustMapper, Entrust> impl
sampleDistributionCheckMapper.updateById(disCheck); sampleDistributionCheckMapper.updateById(disCheck);
dis.setCheckId(disCheck.getId()); dis.setCheckId(disCheck.getId());
}else{ }else{
//判断是否有平行样
List<Sample> otherSampleList = sampleMapper.getOtherSampleList(entrust.getId(), sample_this.getCementCode(), sample_this.getId());
if(otherSampleList != null && otherSampleList.size() > 0){
for(Sample s : otherSampleList){
QueryWrapper<SampleDistribution> ortherWrapper = new QueryWrapper<>();
ortherWrapper.eq("entrust_id", entrust.getId());
ortherWrapper.eq("sample_id", s.getId());
ortherWrapper.eq("team_group_id", dis.getTeamGroupId());
ortherWrapper.eq("team_id", dis.getTeamId());
List<SampleDistribution> ortherDdistributionList = distributionMapper.selectList(ortherWrapper);
if(ortherDdistributionList.size() > 1 ){
return BaseResponse.errorMsg("检测派发表检测项信息重复");
}
if(ortherDdistributionList != null && ortherDdistributionList.size()>0){
SampleDistribution other = ortherDdistributionList.get(0);
if(other.getCheckId() != null){
dis.setCheckId(other.getCheckId());
}
}
}
//如果其他的平行样也都没有进行校核,则新增校核内容
if(dis.getCheckId() != null){
SampleDistributionCheck disCheck = sampleDistributionCheckMapper.selectById(dis.getCheckId());
disCheck.setDistributionError(disQuery.getDistributionError())
.setLastResult(disQuery.getLastResult())
.setUpdateTime(LocalDateTime.now());
sampleDistributionCheckMapper.updateById(disCheck);
}else{
SampleDistributionCheck disCheck = new SampleDistributionCheck();
disCheck.setDistributionError(disQuery.getDistributionError())
.setLastResult(disQuery.getLastResult())
.setCreateTime(LocalDateTime.now())
.setUpdateTime(LocalDateTime.now());
sampleDistributionCheckMapper.insert(disCheck);
dis.setCheckId(disCheck.getId());
}
}else{
SampleDistributionCheck disCheck = new SampleDistributionCheck(); SampleDistributionCheck disCheck = new SampleDistributionCheck();
disCheck.setDistributionError(disQuery.getDistributionError()) disCheck.setDistributionError(disQuery.getDistributionError())
.setLastResult(disQuery.getLastResult()) .setLastResult(disQuery.getLastResult())
...@@ -3702,6 +3789,8 @@ public class EntrustServiceImpl extends ServiceImpl<EntrustMapper, Entrust> impl ...@@ -3702,6 +3789,8 @@ public class EntrustServiceImpl extends ServiceImpl<EntrustMapper, Entrust> impl
sampleDistributionCheckMapper.insert(disCheck); sampleDistributionCheckMapper.insert(disCheck);
dis.setCheckId(disCheck.getId()); dis.setCheckId(disCheck.getId());
} }
}
distributionMapper.updateById(dis); distributionMapper.updateById(dis);
} }
......
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