Commit 1cbace48 authored by 竹天卫's avatar 竹天卫

新增委托时 根据选择的委托单位再去选择项目

parent a6e322fb
......@@ -13,6 +13,8 @@ import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import javax.servlet.http.HttpServletResponse;
import java.util.Map;
/**
......@@ -57,6 +59,21 @@ public class EntrustController {
return BaseResponse.errorMsg("失败!");
}
@ApiOperation("委托列表导出")
@PostMapping("/export")
public void export(String startDate, String endDate, Integer status,
Integer clientId, String projectName, String projectCode,
String fileName, HttpServletResponse response) {
try {
entrustService.export(startDate, endDate, status,
clientId, projectName, projectCode,
fileName, response);
} catch (Exception e) {
log.debug("委托列表导出{}", e);
}
}
@ApiOperation(value = "置顶取消置顶 (createTime = updateTime显示置顶,否则显示取消置顶)")
@PostMapping("/setTopping")
public BaseResponse setTopping(Integer id) {
......
......@@ -137,7 +137,16 @@ public class ProjectController {
}
@ApiOperation(value = "根据委托单位id获取项目列表")
@GetMapping("/getProjectList")
public BaseResponse getProjectList(Integer clientId) {
try {
return projectService.getProjectList(clientId);
} catch (Exception e) {
log.debug("根据委托单位id获取项目列表{}", e);
}
return BaseResponse.errorMsg("失败!");
}
......
......@@ -42,4 +42,6 @@ public interface EntrustMapper extends BaseMapper<Entrust> {
List<QualityDetail> getQualityDetail(@Param("entrustId") Integer entrustId);
List<Map<String, Object>> exportList(@Param("params") Map<String, Object> params);
}
......@@ -24,6 +24,8 @@ public interface ProjectMapper extends BaseMapper<Project> {
List<ProjectVo> getList();
List<ProjectVo> getProjectList(Integer clientId);
ProjectVo getByName(String name);
List<Map<String, Object>> exportList(@Param("params") Map<String, Object> params);
......
......@@ -56,6 +56,66 @@
order by e.is_urgent desc, e.update_time desc
</select>
<select id="exportList" resultType="java.util.HashMap">
SELECT
(@i:=@i+1) as 序号,
e.id as entrustId,
e.entrust_code as 委托编号,
(
CASE e.is_urgent
WHEN 0 THEN '不加急'
WHEN 1 THEN '加急'
ELSE NULL
END
) as 是否加急,
e.project_name as 项目名称,
e.project_code as 项目编号,
su.name as 委托人,
c.name as 委托单位,
e.entrust_date as 委托日期,
e.sample_num as 样品数量,
(
CASE e.status
WHEN 0 THEN '未评审'
WHEN 1 THEN '已通过'
WHEN 2 THEN '未通过'
WHEN 3 THEN '样品处理中'
WHEN 4 THEN '样品处理完成'
WHEN 5 THEN '样品检测中'
WHEN 6 THEN '样品检测完成'
WHEN 7 THEN '校核中'
WHEN 8 THEN '校核完成'
ELSE ''
END
) as 状态
from entrust e
left join project p on p.id = e.project_id
left join client c on c.id = e.client_id
left join sys_user su on su.id = e.user_id
,(select @i:=0)aa
<include refid="where"/>
order by 序号,e.is_urgent desc, e.update_time desc
</select>
<select id="getDetail" resultType="cn.wise.sc.cement.business.model.vo.EntrustVo">
select e.*,
(
......
......@@ -6,7 +6,7 @@
<if test="params.code != null and params.code != ''">
and t.code = #{params.code}
</if>
<if test="params.clientId != null and params.clientId != ''">
<if test="params.clientId != null">
and t.client_id = #{params.clientId}
</if>
<if test="params.name != null and params.name != ''">
......@@ -32,6 +32,18 @@
order by t.id desc
</select>
<select id="getProjectList" resultType="cn.wise.sc.cement.business.model.vo.ProjectVo">
select t.*,
cl.id as clientId, cl.name clientName
FROM project t
left join client cl on cl.id = t.client_id
where t.status = 1
<if test="clientId != null">
and t.client_id = #{clientId}
</if>
order by t.id desc
</select>
<select id="getByName" resultType="cn.wise.sc.cement.business.model.vo.ProjectVo">
select t.*,
cl.id as clientId, cl.name clientName
......
......@@ -11,6 +11,7 @@ import cn.wise.sc.cement.business.model.vo.*;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.service.IService;
import javax.servlet.http.HttpServletResponse;
import java.util.List;
import java.util.Map;
......@@ -93,4 +94,8 @@ public interface IEntrustService extends IService<Entrust> {
String projectCode);
QualityDetailVo getQualityDetail(Integer entrustId);
void export(String startDate, String endDate, Integer status,
Integer clientId, String projectName, String projectCode,
String fileName, HttpServletResponse response);
}
......@@ -39,6 +39,13 @@ public interface IProjectService extends IService<Project> {
*/
BaseResponse<List<ProjectVo>> getList();
/**
* 根据委托单位id获取项目列表
* @param clientId
* @return
*/
BaseResponse<List<ProjectVo>> getProjectList(Integer clientId);
/**
* 新增项目
*
......
......@@ -11,10 +11,12 @@ import cn.wise.sc.cement.business.model.query.*;
import cn.wise.sc.cement.business.model.vo.*;
import cn.wise.sc.cement.business.service.*;
import cn.wise.sc.cement.business.util.CheckCountUtil;
import cn.wise.sc.cement.business.util.ExcelUtil;
import cn.wise.sc.cement.business.util.RedisUtil;
import com.alibaba.fastjson.JSON;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.core.toolkit.CollectionUtils;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.apache.commons.lang3.StringUtils;
......@@ -24,6 +26,7 @@ import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import javax.annotation.Resource;
import javax.servlet.http.HttpServletResponse;
import java.math.BigDecimal;
import java.text.SimpleDateFormat;
import java.time.LocalDate;
......@@ -1880,4 +1883,107 @@ public class EntrustServiceImpl extends ServiceImpl<EntrustMapper, Entrust> impl
return JSON.toJSONString(map);
}
/**
* 委托列表导出
* @param startDate
* @param endDate
* @param status
* @param clientId
* @param projectName
* @param projectCode
* @param fileName
* @param response
*/
@Override
public void export(String startDate, String endDate, Integer status,
Integer clientId, String projectName, String projectCode,
String fileName, HttpServletResponse response){
Map<String, Object> params = new HashMap<>();
params.put("startDate", startDate);
params.put("endDate", endDate);
params.put("status", status);
params.put("clientId", clientId);
params.put("projectName", projectName);
params.put("projectCode", projectCode);
List<Map<String, Object>> list= entrustMapper.exportList(params);
if (!CollectionUtils.isEmpty(list)) {
Map<String, Object> map = list.get(0);
String[] headers = new String[map.size()];
headers[0] = "序号";
headers[1] = "委托编号";
headers[2] = "是否加急";
headers[3] = "项目名称";
headers[4] = "项目编号";
headers[5] = "委托人";
headers[6] = "委托单位";
headers[7] = "委托日期";
headers[8] = "样品数量";
headers[9] = "检测项目";
headers[10] = "检测依据编号";
headers[11] = "状态";
List<Object[]> datas = new ArrayList<>(list.size());
for (Map<String, Object> m : list) {
Object[] objects = new Object[headers.length];
for (int j = 0; j < headers.length; j++) {
String obj = m.get(headers[j]).toString();
//如果序号带小数点 去除.0,保留整数
if(j==0){
obj = obj.split("\\.")[0];
}
objects[j] = obj;
}
//根据委托编号id 获取所有样品的检测项目 和 检测依据编号
Integer entrustId = Integer.valueOf(m.get("entrustId").toString());
System.out.println(entrustId);
QueryWrapper<SampleTmp> queryWrapper = new QueryWrapper<>();
queryWrapper.eq("entrust_id", entrustId);
List<SampleTmp> sampleTmpList = sampleTmpService.list(queryWrapper);
//检测项目名称
String sampleNames = "";
if (sampleTmpList != null && sampleTmpList.size() > 0) {
//样品名称 列表中的拼接
for (SampleTmp sampleTmp : sampleTmpList) {
sampleNames = sampleNames.equals("") ? sampleTmp.getName() : (sampleNames + "、" + sampleTmp.getName());
}
// entrustVo.setSampleNames(sampleNames);
//检测项 和检测依据 列表里只显示第一个样品的
SampleTmp sampleTmp = sampleTmpList.get(0);
String teamIds = sampleTmp.getTeamIds();
String checkTeam = "";
if (teamIds != null) {
String[] teamIdS = teamIds.split("、");
for (String teamId : teamIdS) {
Team team = teamMapper.selectById(Integer.valueOf(teamId));
if (team != null) {
checkTeam = checkTeam.equals("") ? team.getName() : (checkTeam + "、" + team.getName());
}
}
}
// entrustVo.setCheckTeam(checkTeam);
// entrustVo.setCheckMethodNumber(sampleTmp.getMethodNumbers());
}
datas.add(objects);
}
ExcelUtil.excelExport(
fileName == null || fileName.trim().length() <= 0 ? "委托列表": fileName, headers,
datas, response);
}
}
}
......@@ -70,6 +70,17 @@ public class ProjectServiceImpl extends ServiceImpl<ProjectMapper, Project> impl
return BaseResponse.okData(list);
}
@Override
public BaseResponse<List<ProjectVo>> getProjectList(Integer clientId) {
List<ProjectVo> list = projectMapper.getProjectList(clientId);
return BaseResponse.okData(list);
}
@Override
@Transactional
public BaseResponse<Project> create(ProjectQuery query) {
......
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