Commit a4ad43ff authored by 竹天卫's avatar 竹天卫

导出功能

parent e8a26512
...@@ -81,12 +81,6 @@ public class EquipmentController { ...@@ -81,12 +81,6 @@ public class EquipmentController {
@ApiOperation(value = "新增设备") @ApiOperation(value = "新增设备")
@PostMapping("/create") @PostMapping("/create")
public BaseResponse create(@RequestBody EquipmentQuery query) { public BaseResponse create(@RequestBody EquipmentQuery query) {
...@@ -208,6 +202,16 @@ public class EquipmentController { ...@@ -208,6 +202,16 @@ public class EquipmentController {
return BaseResponse.errorMsg("失败!"); return BaseResponse.errorMsg("失败!");
} }
@ApiOperation("设备维修列表导出")
@PostMapping("/exportTroubleshooting")
public void exportTroubleshooting(Integer equipmentIde, String fileName, HttpServletResponse response) {
try {
equipmentService.exportTroubleshooting(equipmentIde, fileName, response);
} catch (Exception e) {
log.debug("设备维修列表导出{}", e);
}
}
@ApiOperation(value = "维修登记详情") @ApiOperation(value = "维修登记详情")
@GetMapping("getTroubleshootingDetail/{id}") @GetMapping("getTroubleshootingDetail/{id}")
public BaseResponse getTroubleshootingDetail(@PathVariable Integer id){ public BaseResponse getTroubleshootingDetail(@PathVariable Integer id){
...@@ -257,6 +261,16 @@ public class EquipmentController { ...@@ -257,6 +261,16 @@ public class EquipmentController {
return BaseResponse.errorMsg("失败!"); return BaseResponse.errorMsg("失败!");
} }
@ApiOperation("报废申请列表导出")
@PostMapping("/exportScrapApproval")
public void exportScrapApproval(String brand, Integer supplierId, String name, String fileName, HttpServletResponse response) {
try {
equipmentService.exportScrapApproval(brand, supplierId, name, fileName, response);
} catch (Exception e) {
log.debug("报废申请列表导出{}", e);
}
}
@ApiOperation(value = "报废申请详情") @ApiOperation(value = "报废申请详情")
@GetMapping("getscrapApprovalDetail/{id}") @GetMapping("getscrapApprovalDetail/{id}")
public BaseResponse getscrapApprovalDetail(@PathVariable Integer id){ public BaseResponse getscrapApprovalDetail(@PathVariable Integer id){
......
...@@ -8,6 +8,7 @@ import com.baomidou.mybatisplus.core.metadata.IPage; ...@@ -8,6 +8,7 @@ import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import org.apache.ibatis.annotations.Param; import org.apache.ibatis.annotations.Param;
import java.util.List;
import java.util.Map; import java.util.Map;
/** /**
...@@ -22,6 +23,9 @@ public interface EquipmentScrapMapper extends BaseMapper<EquipmentScrap> { ...@@ -22,6 +23,9 @@ public interface EquipmentScrapMapper extends BaseMapper<EquipmentScrap> {
IPage<EquipmentScrapVo> getPage(@Param("page") Page page, @Param("params") Map<String, Object> params); IPage<EquipmentScrapVo> getPage(@Param("page") Page page, @Param("params") Map<String, Object> params);
List<Map<String, Object>> exportList(@Param("params") Map<String, Object> params);
EquipmentScrapVo getScrapDetail(Integer id); EquipmentScrapVo getScrapDetail(Integer id);
} }
...@@ -8,6 +8,7 @@ import com.baomidou.mybatisplus.core.metadata.IPage; ...@@ -8,6 +8,7 @@ import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import org.apache.ibatis.annotations.Param; import org.apache.ibatis.annotations.Param;
import java.util.List;
import java.util.Map; import java.util.Map;
/** /**
...@@ -22,6 +23,8 @@ public interface EquipmentTroubleshootingMapper extends BaseMapper<EquipmentTrou ...@@ -22,6 +23,8 @@ public interface EquipmentTroubleshootingMapper extends BaseMapper<EquipmentTrou
IPage<EquipmentTroubleshootingVo> getPage(@Param("page") Page page, @Param("params") Map<String, Object> params); IPage<EquipmentTroubleshootingVo> getPage(@Param("page") Page page, @Param("params") Map<String, Object> params);
List<Map<String, Object>> exportList(@Param("params") Map<String, Object> params);
EquipmentTroubleshootingVo getTroubleshootingDetail(Integer id); EquipmentTroubleshootingVo getTroubleshootingDetail(Integer id);
} }
...@@ -22,11 +22,37 @@ ...@@ -22,11 +22,37 @@
e.name as equipmentName, e.code as code, e.brand as brand, e.model as model, e.purchase_date as purchaseDate, e.name as equipmentName, e.code as code, e.brand as brand, e.model as model, e.purchase_date as purchaseDate,
e.assets_value as assetsValue e.assets_value as assetsValue
FROM equipment_scrap es FROM equipment_scrap es
left join equipment e on e.id = et.equipment_id left join equipment e on e.id = es.equipment_id
<include refid="where" /> <include refid="where" />
ORDER BY es.create_time ASC ORDER BY es.create_time ASC
</select> </select>
<select id="exportList" resultType="java.util.HashMap">
SELECT
(@i:=@i+1) as 序号,
e.name as 设备名称,
e.code as 设备编号,
e.model as '规格/型号',
IF(ISNULL(e.purchase_date),'',e.purchase_date) as 购置日期,
IF(ISNULL(e.assets_value),'',e.assets_value) as 设备原值,
IF(ISNULL(es.scrap_reason),'',es.scrap_reason) as 报废原因,
IF(ISNULL(su.name),'',su.name) as 申请人,
IF(ISNULL(es.scrap_date),'',es.scrap_date) as 报废申请日期,
(
CASE es.status
WHEN 0 THEN '待审批'
WHEN 1 THEN '已通过'
WHEN 2 THEN '未通过'
ELSE NULL
END
) as 申请结果
FROM equipment_scrap es
left join equipment e on e.id = es.equipment_id
left join sys_user su on su.id = es.user_id
,(select @i:=0)et
<include refid="where" />
ORDER BY es.create_time ASC
</select>
<select id="getScrapDetail" resultType="cn.wise.sc.cement.business.model.vo.EquipmentScrapVo"> <select id="getScrapDetail" resultType="cn.wise.sc.cement.business.model.vo.EquipmentScrapVo">
......
...@@ -17,6 +17,29 @@ ...@@ -17,6 +17,29 @@
</select> </select>
<select id="exportList" resultType="java.util.HashMap">
SELECT
(@i:=@i+1) as 序号,
e.name as 设备名称,
e.code as 设备编号,
e.model as '规格/型号',
IF(ISNULL(et.find_date),'',et.find_date) as 发现日期,
IF(ISNULL(et.find_user),'',et.find_user) as 发现人,
IF(ISNULL(et.fault_phenomenon),'',et.fault_phenomenon) as 故障描述,
IF(ISNULL(et.repair_conclusion),'',et.repair_conclusion) as 实施结果
FROM equipment_troubleshooting et
left join equipment e on e.id = et.equipment_id
,(select @i:=0)et
<include refid="where" />
ORDER BY et.create_time ASC
</select>
<select id="getTroubleshootingDetail" resultType="cn.wise.sc.cement.business.model.vo.EquipmentTroubleshootingVo"> <select id="getTroubleshootingDetail" resultType="cn.wise.sc.cement.business.model.vo.EquipmentTroubleshootingVo">
SELECT et.*, SELECT et.*,
e.name as equipmentName, e.code as code, e.brand as brand, e.model as model e.name as equipmentName, e.code as code, e.brand as brand, e.model as model
......
...@@ -42,6 +42,8 @@ public interface IEquipmentService extends IService<Equipment> { ...@@ -42,6 +42,8 @@ public interface IEquipmentService extends IService<Equipment> {
BaseResponse<IPage<EquipmentTroubleshootingVo>> getTroubleshootingPage(PageQuery pageQuery, Integer equipmentId); BaseResponse<IPage<EquipmentTroubleshootingVo>> getTroubleshootingPage(PageQuery pageQuery, Integer equipmentId);
void exportTroubleshooting(Integer equipmentId, String fileName, HttpServletResponse response);
BaseResponse<EquipmentTroubleshootingVo> getTroubleshootingDetail(Integer id); BaseResponse<EquipmentTroubleshootingVo> getTroubleshootingDetail(Integer id);
BaseResponse<String> scrap(EquipmentScrapQuery query); BaseResponse<String> scrap(EquipmentScrapQuery query);
...@@ -51,6 +53,8 @@ public interface IEquipmentService extends IService<Equipment> { ...@@ -51,6 +53,8 @@ public interface IEquipmentService extends IService<Equipment> {
BaseResponse<IPage<EquipmentScrapVo>> getScrapApprovalPage(PageQuery pageQuery, BaseResponse<IPage<EquipmentScrapVo>> getScrapApprovalPage(PageQuery pageQuery,
String brand, Integer supplierId, String name); String brand, Integer supplierId, String name);
void exportScrapApproval(String brand, Integer supplierId, String name, String fileName, HttpServletResponse response);
BaseResponse<EquipmentScrapVo> getscrapApprovalDetail(Integer id); BaseResponse<EquipmentScrapVo> getscrapApprovalDetail(Integer id);
BaseResponse<IPage<EquipmentUseVo>> getUsePage(PageQuery pageQuery, BaseResponse<IPage<EquipmentUseVo>> getUsePage(PageQuery pageQuery,
......
...@@ -368,6 +368,47 @@ public class EquipmentServiceImpl extends ServiceImpl<EquipmentMapper, Equipment ...@@ -368,6 +368,47 @@ public class EquipmentServiceImpl extends ServiceImpl<EquipmentMapper, Equipment
return BaseResponse.okData(pages); return BaseResponse.okData(pages);
} }
/**
* 设备维修列表导出
* @param equipmentId
* @param fileName
* @param response
*/
@Override
public void exportTroubleshooting(Integer equipmentId, String fileName, HttpServletResponse response) {
Map<String, Object> params = new HashMap<>();
params.put("equipmentId", equipmentId);
List<Map<String, Object>> list= troubleshootingMapper.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] = "实施结果";
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();
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);
}
}
/** /**
* 维修登记详情 * 维修登记详情
* @param id 设备故障维修登记表id * @param id 设备故障维修登记表id
...@@ -458,6 +499,56 @@ public class EquipmentServiceImpl extends ServiceImpl<EquipmentMapper, Equipment ...@@ -458,6 +499,56 @@ public class EquipmentServiceImpl extends ServiceImpl<EquipmentMapper, Equipment
return BaseResponse.okData(pages); return BaseResponse.okData(pages);
} }
/**
* 报废申请列表导出
* @param brand
* @param supplierId
* @param name
* @param fileName
* @param response
*/
public void exportScrapApproval(String brand, Integer supplierId, String name, String fileName, HttpServletResponse response) {
Map<String, Object> params = new HashMap<>();
params.put("brand", brand);
params.put("supplierId", supplierId);
params.put("name", name);
List<Map<String, Object>> list= scrapMapper.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] = "申请结果";
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();
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);
}
}
/** /**
* 报废申请详情 * 报废申请详情
......
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