Jelajahi Sumber

新增认可申报设备一览表、计量溯源导出接口

wy 4 bulan lalu
induk
melakukan
26e7ae6ff2

+ 37 - 1
ibps-provider-root/modules/provider-business/src/main/java/com/lc/ibps/components/equipment/api/IEquipmentCardService.java

@@ -1,6 +1,7 @@
 package com.lc.ibps.components.equipment.api;
 
 import java.util.List;
+import java.util.Map;
 
 import org.hibernate.validator.constraints.NotBlank;
 import org.hibernate.validator.constraints.NotEmpty;
@@ -14,6 +15,8 @@ import org.springframework.web.bind.annotation.RestController;
 import com.lc.ibps.cloud.entity.APIPageList;
 import com.lc.ibps.cloud.entity.APIRequest;
 import com.lc.ibps.cloud.entity.APIResult;
+
+import javax.servlet.http.HttpServletResponse;
 import javax.validation.Valid;
 import com.lc.ibps.components.equipment.persistence.entity.EquipmentCardPo;
 
@@ -44,7 +47,40 @@ public interface IEquipmentCardService {
 	@RequestMapping(value = "/query", method = RequestMethod.POST)
 	public APIResult<APIPageList<EquipmentCardPo>> query(
 			@RequestBody(required = true) APIRequest request);
-	
+
+	/**
+	 *
+	 * 设备档案卡自定义按钮导出
+	 */
+	@RequestMapping(value = "/export", method = RequestMethod.POST)
+	public APIResult<List<Map<String,Object>>> export(
+			@RequestParam(name = "id",required = false) String id,
+			@RequestParam(name = "bianZhiBuMen",required = false) String buMen,
+			@RequestParam(name = "startBianZhiShiJian",required = false) String start,
+			@RequestParam(name = "endBianZhiShiJian",required = false) String end,
+			@RequestParam(name = "yuanSheBeiBian",required = false) String yuan,
+			@RequestParam(name = "sheBeiMingCheng",required = false) String name,
+			@RequestParam(name = "sheBeiLeiXing",required = false) String type,
+			@RequestParam(name = "sheBeiZhuangTai",required = false) String stats,
+			@RequestParam(name = "cunFangDiDian",required = false) String diDian,
+			@RequestParam(name = "guanLiRen",required = false) String user,
+			@RequestParam(name = "diDian",required = false) String po);
+
+	/**
+	 *
+	 * 计量溯源导出
+	 */
+	@RequestMapping(value = "/traceability", method = RequestMethod.POST)
+	public APIResult<List<Map<String,Object>>> traceability(
+			@RequestParam(name = "id",required = false) String id,
+			@RequestParam(name = "bianZhiBuMen",required = false) String buMen,
+			@RequestParam(name = "startBianZhiShiJian",required = false) String start,
+			@RequestParam(name = "endBianZhiShiJian",required = false) String end,
+			@RequestParam(name = "xiangMu",required = false) String xiangMu,
+			@RequestParam(name = "pinPai",required = false) String pinPai,
+			@RequestParam(name = "mingCheng",required = false) String mingCheng,
+			@RequestParam(name = "diDian",required = false) String po);
+
 	/**
 	 * 
 	 * 根据id查询【设备档案卡】

+ 125 - 3
ibps-provider-root/modules/provider-business/src/main/java/com/lc/ibps/components/equipment/provider/EquipmentCardProvider.java

@@ -1,11 +1,18 @@
 package com.lc.ibps.components.equipment.provider;
 
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.List;
+import java.net.URLEncoder;
+import java.util.*;
 
 import javax.annotation.Resource;
+import javax.servlet.http.HttpServletResponse;
 
+import com.lc.ibps.base.db.mybatis.CommonDao;
+import com.lc.ibps.base.framework.table.ICommonDao;
+import com.lc.ibps.components.poi.excel.entity.ExportParams;
+import com.lc.ibps.components.poi.excel.entity.enmus.ExcelType;
+import com.lc.ibps.components.poi.excel.entity.params.ExcelExportEntity;
+import com.lc.ibps.components.verification.excel.PVExcelUtil;
+import org.apache.poi.ss.usermodel.Workbook;
 import org.springframework.stereotype.Service;
 import org.springframework.web.bind.annotation.RequestBody;
 import org.springframework.web.bind.annotation.RequestParam;
@@ -45,6 +52,9 @@ public class EquipmentCardProvider extends GenericProvider implements IEquipment
 	@Resource
 	private EquipmentCardRepository equipmentCardRepository;
 
+	@Resource
+	private ICommonDao<?> commonDao;
+
 	@ApiOperation(value = "设备档案卡列表(分页条件查询)数据", notes = "设备档案卡列表(分页条件查询)数据")
 	@Override
 	public APIResult<APIPageList<EquipmentCardPo>> query(
@@ -63,6 +73,118 @@ public class EquipmentCardProvider extends GenericProvider implements IEquipment
 		return result;
 	}
 
+	@ApiOperation(value = "设备档案卡导出数据", notes = "设备档案卡列表(分页条件查询)数据")
+	@Override
+	public APIResult<List<Map<String,Object>>> export(
+			@ApiParam(name = "request", value = "传入查询请求json字符串", required = true)
+			@RequestParam(name = "id",required = false) String id,
+			@RequestParam(name = "bianZhiBuMen",required = false) String buMen,
+			@RequestParam(name = "startBianZhiShiJian",required = false) String start,
+			@RequestParam(name = "endBianZhiShiJian",required = false) String end,
+			@RequestParam(name = "yuanSheBeiBian",required = false) String yuan,
+			@RequestParam(name = "sheBeiMingCheng",required = false) String name,
+			@RequestParam(name = "sheBeiLeiXing",required = false) String type,
+			@RequestParam(name = "sheBeiZhuangTai",required = false) String stats,
+			@RequestParam(name = "cunFangDiDian",required = false) String diDian,
+			@RequestParam(name = "guanLiRen",required = false) String user,
+			@RequestParam(name = "diDian",required = false) String po) {
+		APIResult<List<Map<String,Object>>> result = new APIResult<List<Map<String,Object>>>();
+		try {
+			String sql = " select s.id_," +
+					"p.name_ as bian_zhi_bu_men_, " +
+					"s.bian_zhi_shi_jian, " +
+					"s.yuan_she_bei_bian, " +
+					"s.she_bei_ming_cheng_, " +
+					"s.she_bei_lei_xing_, " +
+					"s.cun_fang_di_dian_, " +
+					" ( select GROUP_CONCAT(e2.name_ SEPARATOR ',') " +
+					"        FROM ibps_party_employee e2 " +
+					"        WHERE FIND_IN_SET(e2.id_, s.guan_li_ren_) " +
+					"    ) AS guan_li_ren_, " +
+					"s.gui_ge_xing_hao_, " +
+					"s.chang_shang_, " +
+					"s.gong_ying_shang_, " +
+					"s.ji_shen_xu_hao_, " +
+					"s.qi_yong_ri_qi_ " +
+					"from t_sbdj s join ibps_party_position p on s.bian_zhi_bu_men_ = p.id_ where ";
+			String fixSql = buildSql(id,buMen,start,end,yuan,name,type,stats,diDian,user,po);
+			String orderSql = " order by STR_TO_DATE(bian_zhi_shi_jian, '%Y-%m-%d %H:%i') desc,s.create_time_ desc";
+			List<Map<String, Object>> data = (List<Map<String, Object>>) commonDao.query(sql + fixSql + orderSql);
+			result.setData(data);
+		} catch (Exception e) {
+			logger.error("设备档案卡导出失败", e);
+		}
+		return result;
+	}
+
+	public String buildSql(String id,String buMen,String start,String end,String yuan,String name,String type,String stats,String diDian,String user,String po){
+		String fixSql = "";
+		if(BeanUtils.isNotEmpty(buMen)){
+			fixSql = " find_in_set(bian_zhi_bu_men_ ,'" + buMen +"')";
+		}
+		if(BeanUtils.isNotEmpty(id)){
+			fixSql +=  BeanUtils.isNotEmpty(fixSql) ? " and  find_in_set(s.id_, '" + id + "')" : " find_in_set(s.id_, '" + id + "')";
+		}
+		if(BeanUtils.isNotEmpty(start)){
+			fixSql += BeanUtils.isNotEmpty(fixSql) ? " and bian_zhi_shi_jian between '" + start + "' and '" + end + "'" :"bian_zhi_shi_jian between '" + start + "' and '" + end + "'";
+		}
+		if(BeanUtils.isNotEmpty(yuan)){
+			fixSql += BeanUtils.isNotEmpty(fixSql) ? " and yuan_she_bei_bian like '%" + yuan + "%'" : " yuan_she_bei_bian like '%" + yuan + "%'";
+		}
+		if(BeanUtils.isNotEmpty(name)){
+			fixSql += BeanUtils.isNotEmpty(fixSql) ? " and she_bei_ming_cheng_ like '%" + name +"%'" : " she_bei_ming_cheng_ like '%" + name +"%'" ;
+		}
+		if(BeanUtils.isNotEmpty(type)){
+			fixSql += BeanUtils.isNotEmpty(fixSql) ? " and  find_in_set(she_bei_lei_xing_, '" + type + "')" : " find_in_set(she_bei_lei_xing_, '" + type + "')";
+		}
+		if(BeanUtils.isNotEmpty(stats)){
+			fixSql += BeanUtils.isNotEmpty(fixSql) ? " and  find_in_set(she_bei_zhuang_ta, '" + stats + "')" : " find_in_set(she_bei_zhuang_ta, '" + stats + "')";
+		}
+		if(BeanUtils.isNotEmpty(diDian)){
+			fixSql += BeanUtils.isNotEmpty(fixSql) ? " and  find_in_set(cun_fang_wei_zhi_, '" + diDian + "')" : " find_in_set(cun_fang_wei_zhi_, '" + diDian + "')";
+		}
+		if(BeanUtils.isNotEmpty(user)){
+			fixSql += BeanUtils.isNotEmpty(fixSql) ? " and  find_in_set(guan_li_ren_, '" + user + "')" : " find_in_set(guan_li_ren_, '" + user + "')";
+		}
+		if(BeanUtils.isNotEmpty(po)){
+			fixSql += BeanUtils.isNotEmpty(fixSql) ? " and di_dian_ = '" + po + "'" :  " di_dian_ = '" + po + "'";
+		}
+		return fixSql;
+	}
+
+	@Override
+	public APIResult<List<Map<String, Object>>> traceability(String id,String buMen, String start, String end, String xiangMu, String pinPai, String mingCheng, String po) {
+		APIResult<List<Map<String, Object>>> result = new APIResult<List<Map<String, Object>>>();
+		String sql =" select j.id_,p.name_ as bian_zhi_bu_men_,j.xiang_mu_,j.xi_tong_,j.pin_pai_,j.xing_hao_,j.zhou_qi_,ming_cheng_,j.bian_hao_,j.cheng_xu_ " +
+				" from t_jlsyylbzb j join ibps_party_position p on j.bian_zhi_bu_men_ = p.id_ where ";
+		String fixSql = "";
+		if(BeanUtils.isNotEmpty(buMen)){
+		    fixSql = " find_in_set(bian_zhi_bu_men_,'" + buMen +"') ";
+		}
+		if(BeanUtils.isNotEmpty(id)){
+			fixSql += BeanUtils.isNotEmpty(fixSql) ? " and  find_in_set(j.id_, '" + id + "')" : " find_in_set(j.id_, '" + id + "')";
+		}
+		if(BeanUtils.isNotEmpty(start)){
+			 fixSql += BeanUtils.isNotEmpty(fixSql) ? " and bian_zhi_shi_jian between '" + start + "' and '" + end + "'" :" bian_zhi_shi_jian between '" + start + "' and '" + end + "'";
+		}
+		if(BeanUtils.isNotEmpty(xiangMu)){
+			fixSql += BeanUtils.isNotEmpty(fixSql) ? " and xiang_mu_ like '%" + xiangMu + "%'" :" xiang_mu_ like '%" + xiangMu + "%'";
+		}
+		if(BeanUtils.isNotEmpty(pinPai)){
+			fixSql += BeanUtils.isNotEmpty(fixSql) ? " and pin_pai_ like '%" + pinPai + "%'" :" pin_pai_ like '%" + pinPai + "%'";
+		}
+		if(BeanUtils.isNotEmpty(mingCheng)){
+			fixSql += BeanUtils.isNotEmpty(fixSql) ? " and ming_cheng_ like '%" + mingCheng + "%'" :" ming_cheng_ like '%" + mingCheng + "%'";
+		}
+		if(BeanUtils.isNotEmpty(po)){
+			fixSql += BeanUtils.isNotEmpty(fixSql) ? " and di_dian_ = '" + po + "'" :  " di_dian_ = '" + po + "'";
+		}
+		String orderSql = "  order by STR_TO_DATE(bian_zhi_shi_jian, '%Y-%m-%d %H:%i') desc,j.create_time_ desc";
+		List<Map<String, Object>> data = (List<Map<String, Object>>) commonDao.query(sql + fixSql + orderSql);
+		result.setData(data);
+		return result;
+	}
+
 	@ApiOperation(value = "根据id查询设备档案卡", notes = "根据id查询设备档案卡")
 	@Override
 	public APIResult<EquipmentCardPo> get(