Commit 55aaee17 authored by wufeifan's avatar wufeifan

新增故障管理

parent 57e1ce2c
...@@ -4,6 +4,7 @@ package com.yeejoin.equipmanage.controller; ...@@ -4,6 +4,7 @@ package com.yeejoin.equipmanage.controller;
import com.baomidou.mybatisplus.core.metadata.IPage; import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.yeejoin.equipmanage.common.entity.vo.EquipmentFaultVO; import com.yeejoin.equipmanage.common.entity.vo.EquipmentFaultVO;
import com.yeejoin.equipmanage.common.utils.FileHelper;
import com.yeejoin.equipmanage.service.IEquipmentFaultService; import com.yeejoin.equipmanage.service.IEquipmentFaultService;
import io.swagger.annotations.Api; import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation; import io.swagger.annotations.ApiOperation;
...@@ -13,6 +14,8 @@ import org.springframework.web.bind.annotation.*; ...@@ -13,6 +14,8 @@ import org.springframework.web.bind.annotation.*;
import org.typroject.tyboot.core.foundation.enumeration.UserType; import org.typroject.tyboot.core.foundation.enumeration.UserType;
import org.typroject.tyboot.core.restful.doc.TycloudOperation; import org.typroject.tyboot.core.restful.doc.TycloudOperation;
import javax.servlet.http.HttpServletResponse;
import java.text.SimpleDateFormat;
import java.util.Date; import java.util.Date;
import java.util.List; import java.util.List;
...@@ -27,33 +30,9 @@ import java.util.List; ...@@ -27,33 +30,9 @@ import java.util.List;
@RequestMapping(value = "/equipment-fault", produces = MediaType.APPLICATION_JSON_UTF8_VALUE) @RequestMapping(value = "/equipment-fault", produces = MediaType.APPLICATION_JSON_UTF8_VALUE)
public class EquipmentFaultController { public class EquipmentFaultController {
//@Autowired
//IEquipmentDetailService equipmentDetailService;
@Autowired @Autowired
IEquipmentFaultService iEquipmentFaultService; IEquipmentFaultService iEquipmentFaultService;
///**
// * 查询所有故障记录
// */
//@GetMapping(value = "/getEquipmentFaultAll")
//@TycloudOperation(ApiLevel = UserType.AGENCY)
//@ApiOperation(httpMethod = "GET", value = "装备及故障列表", notes = "装备及故障列表")
//public List<EquipmentFaultVO> getEquipmentFaultAll() {
// List<DetailssAmountVO> detailssAmountVOS = equipmentDetailService.getall();
// ArrayList<EquipmentFaultVO> equipmentFaults = new ArrayList<>();
// EquipmentFaultVO equipmentFault = new EquipmentFaultVO();
// for (DetailssAmountVO detailssAmountVO : detailssAmountVOS) {
// equipmentFault.setEqName(detailssAmountVO.getEquipmentName());
// equipmentFault.setName(detailssAmountVO.getName());
// equipmentFaults.add(equipmentFault);
// }
// return equipmentFaults;
//}
@RequestMapping(value = "/listDate", method = RequestMethod.GET) @RequestMapping(value = "/listDate", method = RequestMethod.GET)
@TycloudOperation(ApiLevel = UserType.AGENCY) @TycloudOperation(ApiLevel = UserType.AGENCY)
@ApiOperation(httpMethod = "GET", value = "列表分页查询", notes = "列表分页查询") @ApiOperation(httpMethod = "GET", value = "列表分页查询", notes = "列表分页查询")
...@@ -62,7 +41,7 @@ public class EquipmentFaultController { ...@@ -62,7 +41,7 @@ public class EquipmentFaultController {
@RequestParam(required = false) String code, @RequestParam(required = false) String code,
@RequestParam(required = false)String eqCode, @RequestParam(required = false)String eqCode,
@RequestParam(required = false)String name, @RequestParam(required = false)String name,
@RequestParam(required = false)Date faultOccurTime) { @RequestParam(required = false)String faultOccurTime) {
int start = (pageNum - 1) * pageSize; int start = (pageNum - 1) * pageSize;
List<EquipmentFaultVO> list = iEquipmentFaultService.selectEquipmentFaultList(start, pageSize, code, eqCode, name, faultOccurTime); List<EquipmentFaultVO> list = iEquipmentFaultService.selectEquipmentFaultList(start, pageSize, code, eqCode, name, faultOccurTime);
int count = iEquipmentFaultService.selectEquipmentFaultListCount(code, eqCode, name, faultOccurTime); int count = iEquipmentFaultService.selectEquipmentFaultListCount(code, eqCode, name, faultOccurTime);
...@@ -72,28 +51,19 @@ public class EquipmentFaultController { ...@@ -72,28 +51,19 @@ public class EquipmentFaultController {
return psge; return psge;
} }
@ApiOperation(value = "导出故障清单", notes = "导出故障清单")
/*@RequestMapping(value = "/listDate", method = RequestMethod.GET) @PostMapping(value = "/export",produces = "application/json;charset=UTF-8")
@TycloudOperation(ApiLevel = UserType.AGENCY) @TycloudOperation(ApiLevel = UserType.AGENCY,needAuth = false)
@ApiOperation(httpMethod = "GET", value = "列表分页查询", notes = "列表分页查询") public void exportDangerList(@RequestBody List<EquipmentFaultVO> equipmentFaultVO, @RequestParam Integer prop, HttpServletResponse response) {
public Page listPage(@RequestParam(value = "current") int pageNum, SimpleDateFormat formatter= new SimpleDateFormat("yyyyMMdd");
@RequestParam(value = "size") int pageSize, String format = formatter.format(new Date());
@RequestParam(required = false) String name, if(prop==1){//全部导出
@RequestParam(required = false) String standard, equipmentFaultVO = iEquipmentFaultService.getAll();
@RequestParam(required = false) String manufacturerName) { FileHelper.exportExcel(equipmentFaultVO, "故障清单", "装备清单", EquipmentFaultVO.class, format + ".xls", response);
int start = (pageNum - 1) * pageSize; }
List<Map<String, Object>> list = equipmentDetailService.selectEquList(start, pageSize, name, standard, manufacturerName); else {//仅仅导出筛选结果的数据
List<Map<String, Object>> list2 = equipmentDetailService.selectEquListcount(name, standard, manufacturerName); FileHelper.exportExcel(equipmentFaultVO, "故障清单", "装备清单", EquipmentFaultVO.class, format + ".xls", response);
}
Page psge = new Page(pageNum, pageSize, list2 == null ? 0 : list2.size()); }
psge.setRecords(list);
return psge;
}*/
} }
...@@ -17,9 +17,10 @@ public interface EquipmentFaultMapper extends BaseMapper<EquipmentDetail> { ...@@ -17,9 +17,10 @@ public interface EquipmentFaultMapper extends BaseMapper<EquipmentDetail> {
/** /**
* 故障管理分页列表 * 故障管理分页列表
*/ */
List<EquipmentFaultVO> selectEquipmentFaultList(@Param("current") int current, @Param("size") int size, @Param("code") String code, @Param("eqCode") String eqCode, @Param("name") String name, @Param("faultOccurTime") Date faultOccurTime); List<EquipmentFaultVO> selectEquipmentFaultList(@Param("current") int current, @Param("size") int size, @Param("code") String code, @Param("eqCode") String eqCode, @Param("name") String name, @Param("faultOccurTime") String faultOccurTime);
int selectEquipmentFaultListcount(@Param("code") String code, @Param("eqCode") String eqCode, @Param("name") String name, @Param("faultOccurTime") Date faultOccurTime); int selectEquipmentFaultListcount(@Param("code") String code, @Param("eqCode") String eqCode, @Param("name") String name, @Param("faultOccurTime") String faultOccurTime);
List<EquipmentFaultVO> getAll();
} }
...@@ -10,9 +10,9 @@ import java.util.List; ...@@ -10,9 +10,9 @@ import java.util.List;
*/ */
public interface IEquipmentFaultService { public interface IEquipmentFaultService {
List<EquipmentFaultVO> selectEquipmentFaultList(int pageNum, int pageSize, String code, String eqCode, String name, Date faultOccurTime); List<EquipmentFaultVO> selectEquipmentFaultList(int pageNum, int pageSize, String code, String eqCode, String name, String faultOccurTime);
int selectEquipmentFaultListCount(String code, String eqCode, String name, Date faultOccurTime);
int selectEquipmentFaultListCount(String code, String eqCode, String name, String faultOccurTime);
List<EquipmentFaultVO> getAll();
} }
...@@ -6,7 +6,6 @@ import com.yeejoin.equipmanage.service.IEquipmentFaultService; ...@@ -6,7 +6,6 @@ import com.yeejoin.equipmanage.service.IEquipmentFaultService;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import java.util.Date;
import java.util.List; import java.util.List;
...@@ -17,21 +16,40 @@ public class EquipmentFaultServiceImpl implements IEquipmentFaultService { ...@@ -17,21 +16,40 @@ public class EquipmentFaultServiceImpl implements IEquipmentFaultService {
EquipmentFaultMapper equipmentFaultMapper; EquipmentFaultMapper equipmentFaultMapper;
@Override @Override
public List<EquipmentFaultVO> selectEquipmentFaultList(int pageNum, int pageSize, String code, String eqCode, String name, Date faultOccurTime) { public List<EquipmentFaultVO> selectEquipmentFaultList(int pageNum, int pageSize, String code, String eqCode, String name, String faultOccurTime) {
return equipmentFaultMapper.selectEquipmentFaultList(pageNum, pageSize, code, eqCode, name, faultOccurTime); String newCode = "";
if (code != null){
char[] chars = code.toCharArray();
for (int i = chars.length - 1; i >= 0; i--) {
if ("0".equals(String.valueOf(chars[i]))) {
newCode = code.substring(0, i);
} else {
break;
}
}
}
return equipmentFaultMapper.selectEquipmentFaultList(pageNum, pageSize, newCode, eqCode, name, faultOccurTime);
} }
@Override @Override
public int selectEquipmentFaultListCount(String code, String eqCode, String name, Date faultOccurTime) { public int selectEquipmentFaultListCount(String code, String eqCode, String name, String faultOccurTime) {
return equipmentFaultMapper.selectEquipmentFaultListcount(code, eqCode, name, faultOccurTime); String newCode = "";
if (code != null){
char[] chars = code.toCharArray();
for (int i = chars.length - 1; i >= 0; i--) {
if ("0".equals(String.valueOf(chars[i]))) {
newCode = code.substring(0, i);
} else {
break;
}
}
}
return equipmentFaultMapper.selectEquipmentFaultListcount(newCode, eqCode, name, faultOccurTime);
} }
/*public Page<EquipmentFaultVO> page(Page<EquipmentFaultVO> pageBean, EquipmentFaultReq equipmentFaultReq) {
List<EquipmentFaultVO> list = equipmentFaultMapper.page(pageBean.offset(), pageBean.getSize(), equipmentFaultReq);
int count = equipmentFaultMapper.count(equipmentFaultReq);
pageBean.setRecords(list);
pageBean.setTotal(count);
return pageBean;
}*/
@Override
public List<EquipmentFaultVO> getAll() {
return equipmentFaultMapper.getAll();
}
} }
...@@ -20,10 +20,10 @@ ...@@ -20,10 +20,10 @@
LEFT JOIN wl_equipment_category wlec ON wled.code = wlec.code LEFT JOIN wl_equipment_category wlec ON wled.code = wlec.code
LEFT JOIN wl_equipment_fault_knowledge wlef ON wlp.fault_knowledge_id = wlef.type LEFT JOIN wl_equipment_fault_knowledge wlef ON wlp.fault_knowledge_id = wlef.type
<where> <where>
<if test="code != null and code != ''"> AND wled.code LIKE CONCAT('%',#{code},'%' )</if> <if test="code != null and code != ''"> AND wlec.code LIKE CONCAT(#{code},'%' )</if>
<if test="eqCode != null and eqCode != ''"> AND wled.eq_code LIKE CONCAT('%',#{eqCode},'%' )</if> <if test="eqCode != null and eqCode != ''"> AND wled.eq_code LIKE CONCAT('%',#{eqCode},'%' )</if>
<if test="name != null and name != ''"> AND wled.name LIKE CONCAT('%',#{name},'%' )</if> <if test="name != null and name != ''"> AND wled.name LIKE CONCAT('%',#{name},'%' )</if>
<if test="faultOccurTime != null and faultOccurTime != ''"> AND faultOccurTime LIKE CONCAT('%',#{faultOccurTime},'%' )</if> <if test="faultOccurTime != null and faultOccurTime != ''"> AND wlp.create_date LIKE CONCAT('%',#{faultOccurTime},'%' )</if>
</where> </where>
ORDER BY wlp.create_date DESC ORDER BY wlp.create_date DESC
LIMIT #{current},#{size} LIMIT #{current},#{size}
...@@ -39,10 +39,31 @@ ...@@ -39,10 +39,31 @@
LEFT JOIN wl_equipment_category wlec ON wled.code = wlec.code LEFT JOIN wl_equipment_category wlec ON wled.code = wlec.code
LEFT JOIN wl_equipment_fault_knowledge wlef ON wlp.fault_knowledge_id = wlef.type LEFT JOIN wl_equipment_fault_knowledge wlef ON wlp.fault_knowledge_id = wlef.type
<where> <where>
<if test="code != null and code != ''"> AND wled.code LIKE CONCAT('%',#{code},'%' )</if> <if test="code != null and code != ''"> AND wlec.code LIKE CONCAT(#{code},'%' )</if>
<if test="eqCode != null and eqCode != ''"> AND wled.eq_code LIKE CONCAT('%',#{eqCode},'%' )</if> <if test="eqCode != null and eqCode != ''"> AND wled.eq_code LIKE CONCAT('%',#{eqCode},'%' )</if>
<if test="name != null and name != ''"> AND wled.name LIKE CONCAT('%',#{name},'%' )</if> <if test="name != null and name != ''"> AND wled.name LIKE CONCAT('%',#{name},'%' )</if>
<if test="faultOccurTime != null and faultOccurTime != ''"> AND wlp.create_date LIKE CONCAT('%',#{faultOccurTime},'%' )</if> <if test="faultOccurTime != null and faultOccurTime != ''"> AND wlp.create_date LIKE CONCAT('%',#{faultOccurTime},'%' )</if>
</where> </where>
</select> </select>
<select id="getAll" resultType="com.yeejoin.equipmanage.common.entity.vo.EquipmentFaultVO">
SELECT
wled.id,
wlec.code AS code,
wlec.name AS eq_name,
wled.eq_code,
wled.name,
wlef.type,
wlef.reason,
wlef.measure,
wlp.create_date AS faultOccurTime
FROM
wl_equipment_detail wled
LEFT JOIN wl_equipment_specific wles ON wled.id = wles.equipment_detail_id
LEFT JOIN wl_equipment_params wlp ON wles.iot_code = wlp.detail_id
LEFT JOIN wl_equipment_category wlec ON wled.code = wlec.code
LEFT JOIN wl_equipment_fault_knowledge wlef ON wlp.fault_knowledge_id = wlef.type
ORDER BY wlp.create_date DESC
</select>
</mapper> </mapper>
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