Commit 821c05a0 by lijingjing

添加克隆验证问题;

添加下载excel接口;
parent c9a26c00
......@@ -24,6 +24,7 @@ import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import javax.servlet.http.HttpServletResponse;
import java.util.ArrayList;
import java.util.List;
......@@ -326,4 +327,16 @@ public class EntrustReportController extends ServiceController {
return success(entrustReportService.backFromReportIssueToAllow(ids, reason, getAccount()));
}
@ApiOperation("委托下报告")
@PostMapping("/report_under_entrust")
public RestResult<List<EntrustReport>> getReportUnderEntrust(@RequestParam("entrustId") Long entrustId) {
return success(entrustReportService.getReportUnderEntrust(entrustId));
}
@ApiOperation("下载excel")
@GetMapping("/download")
public void downloadExcel(@RequestParam("id") Long id, HttpServletResponse response) {
entrustReportService.downloadExcel(id, response);
}
}
......@@ -8,6 +8,7 @@ import com.patzn.cloud.service.hmhj.entity.EntrustReport;
import com.patzn.cloud.service.hmhj.enums.EntrustReportStatusEnum;
import com.patzn.cloud.service.hmhj.vo.EntrustReportVO;
import javax.servlet.http.HttpServletResponse;
import java.io.File;
import java.util.List;
......@@ -55,4 +56,7 @@ public interface IEntrustReportService extends IBaseService<EntrustReport> {
boolean updateLastFlowCheckByEntrustId(Long entrustId, Account account);
List<EntrustReport> getReportUnderEntrust(Long entrustId);
void downloadExcel(Long id, HttpServletResponse response);
}
......@@ -5,6 +5,7 @@ import com.baomidou.mybatisplus.mapper.EntityWrapper;
import com.baomidou.mybatisplus.mapper.Wrapper;
import com.baomidou.mybatisplus.plugins.Page;
import com.baomidou.mybatisplus.toolkit.CollectionUtils;
import com.baomidou.mybatisplus.toolkit.StringUtils;
import com.patzn.cloud.commons.api.RestAssert;
import com.patzn.cloud.commons.controller.Account;
import com.patzn.cloud.commons.service.impl.BaseServiceImpl;
......@@ -25,6 +26,7 @@ import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import javax.servlet.http.HttpServletResponse;
import java.io.File;
import java.io.InputStream;
import java.util.*;
......@@ -109,6 +111,20 @@ public class EntrustReportServiceImpl extends BaseServiceImpl<EntrustReportMappe
}
@Override
public List<EntrustReport> getReportUnderEntrust(Long entrustId) {
RestAssert.fail(null == entrustId, "委托编号为空");
return list(Condition.create().eq("entrust_id", entrustId));
}
@Override
public void downloadExcel(Long id, HttpServletResponse response) {
RestAssert.fail(null == id, "报告编号为空");
EntrustReport report = getById(id);
RestAssert.fail(StringUtils.isEmpty(report.getObjectKey()), "报告objectKey为空");
ossClient.download(report.getObjectKey(), report.getSampleName() + ".xlsx", response);
}
@Override
public boolean removeByIds(List<Long> ids) {
entrustReportRelSampleService.remove(Condition.create().in("report_id", ids));
return baseMapper.deleteBatchIds(ids) > 0;
......
......@@ -269,10 +269,12 @@ public class EntrustServiceImpl extends BaseServiceImpl<EntrustMapper, Entrust>
}
// 验证样品非空字段
private void judgeSampleFields(EntrustSample sample) {
RestAssert.fail(StringUtils.isBlank(sample.getCode()), "样品编号不能为空");
RestAssert.fail(StringUtils.isBlank(sample.getName()), "样品名称(物资名称)不能为空");
RestAssert.fail(StringUtils.isBlank(sample.getSampleFrom()), "样品来源不能为空");
private void judgeSampleFields(EntrustSample sample, boolean isRequiredFill) {
if (isRequiredFill) {
RestAssert.fail(StringUtils.isBlank(sample.getCode()), "样品编号不能为空");
RestAssert.fail(StringUtils.isBlank(sample.getName()), "样品名称(物资名称)不能为空");
RestAssert.fail(StringUtils.isBlank(sample.getSampleFrom()), "样品来源不能为空");
}
}
@Transactional(rollbackFor = Exception.class)
......@@ -305,7 +307,7 @@ public class EntrustServiceImpl extends BaseServiceImpl<EntrustMapper, Entrust>
sample.setEntrustId(entrust.getId());
//生成样品编号
initSampleCode(sample);
judgeSampleFields(sample);
judgeSampleFields(sample, true);
sample.setId(IdWorker.getId());
sample.setOrderBy(incNum);
saveSampleList.add(sample);
......@@ -504,7 +506,7 @@ public class EntrustServiceImpl extends BaseServiceImpl<EntrustMapper, Entrust>
saveSampleList.add(sample);
}
judgeSampleFields(sample);
judgeSampleFields(sample, true);
List<EntrustSampleItem> viewItemList = dto.getItemList();
if (CollectionUtils.isNotEmpty(viewItemList)) {
......@@ -1008,12 +1010,17 @@ public class EntrustServiceImpl extends BaseServiceImpl<EntrustMapper, Entrust>
int sampleIndex = 0;
for (EntrustSample sample : sampleList) {
Long oldSampleId = sample.getId();
String sampleCode = sample.getCode();
sample.setId(null);
sample.setId(IdWorker.getId());
sample.setCode(null);
//生成样品编号,可能存在为空的情况
initSampleCode(sample);
judgeSampleFields(sample);
// 样品编号问题,手填的样品编号不清空
if (StringUtils.isBlank(sample.getCode())) {
sample.setCode(sampleCode);
}
judgeSampleFields(sample, false);
sample.setEntrustId(entrust.getId()).setOrderBy(sampleIndex).setStatus(EntrustSampleStatusEnum.DRAFT).setProgress(EntrustSampleStatusEnum.DRAFT)
.setOrderBy(sampleIndex).setOkJudge(null).setJudgerId(null).setJudgeProgress(null).setJudger(null).setJudgeStatus(null).setJudgeCheckTime(null)
.setJudgeCheckerId(null).setAppearanceResult(null).setSurplusSampleLimit(null).setReceiver(null).setReceiverId(null).setReceiveTime(null)
......
......@@ -424,7 +424,7 @@
WHERE ii.deleted = 0
GROUP BY ii.entrust_sample_item_id
) ii on ii.entrust_sample_item_id = i.id
where e.deleted = 0 and s.deleted = 0 and i.deleted = 0
where e.deleted = 0 and s.deleted = 0 and i.deleted = 0 and s.type = 0
and coalesce(ii."END_INDEX",0) = 0
<if test="null != vo.entrustId">
and e.id = #{vo.entrustId}
......
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