|
@@ -2,11 +2,13 @@ package com.idea.buildManage.service;
|
|
|
|
|
|
import cn.hutool.core.bean.BeanUtil;
|
|
|
import cn.hutool.core.util.IdUtil;
|
|
|
-import com.alibaba.fastjson.JSON;
|
|
|
+import com.alibaba.excel.EasyExcel;
|
|
|
import com.alibaba.fastjson.JSONObject;
|
|
|
import com.github.pagehelper.PageHelper;
|
|
|
import com.github.pagehelper.PageInfo;
|
|
|
import com.idea.buildManage.dto.ParkFloorDiscDto;
|
|
|
+import com.idea.buildManage.excel.ParkFloorDiscExcel;
|
|
|
+import com.idea.buildManage.excel.WriteHandlerStrategy;
|
|
|
import com.idea.buildManage.response.ParkFloorDiscRespson;
|
|
|
import com.idea.buildManage.mapper.ParkFloorDiscExtendMapper;
|
|
|
import com.idea.buildManage.mapper.ParkFloorDiscMapper;
|
|
@@ -18,10 +20,13 @@ import com.rockstar.shiro.util.ShiroUtils;
|
|
|
import com.rockstar.util.SnowflakeIdWorker;
|
|
|
import com.rockstar.util.StringUtils;
|
|
|
import org.apache.commons.collections.CollectionUtils;
|
|
|
-import org.apache.poi.util.StringUtil;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
|
|
|
+import javax.servlet.http.HttpServletResponse;
|
|
|
+import java.io.IOException;
|
|
|
+import java.net.URLEncoder;
|
|
|
+import java.text.SimpleDateFormat;
|
|
|
import java.util.*;
|
|
|
import java.util.stream.Collectors;
|
|
|
|
|
@@ -63,7 +68,7 @@ public class ParkFloorDiscService implements BaseService<ParkFloorDisc, ParkFloo
|
|
|
ParkFloorDiscExample ex = new ParkFloorDiscExample();
|
|
|
ex.setOrderByClause("created_at asc");
|
|
|
ParkFloorDiscExample.Criteria criteria = ex.createCriteria();
|
|
|
- if(StringUtils.isNotEmpty(model.getGroupIds())){
|
|
|
+ if (StringUtils.isNotEmpty(model.getGroupIds())) {
|
|
|
List<String> groupIds = Arrays.asList(model.getGroupIds().split(","));
|
|
|
criteria.andGroupIdIn(groupIds);
|
|
|
}
|
|
@@ -95,7 +100,7 @@ public class ParkFloorDiscService implements BaseService<ParkFloorDisc, ParkFloo
|
|
|
MnpBuildingExample mnpBuildingExample = new MnpBuildingExample();
|
|
|
mnpBuildingExample.createCriteria().andDiscIdEqualTo(record.getId());
|
|
|
List<MnpBuilding> mnpBuildings = buildingService.selectByExample(mnpBuildingExample);
|
|
|
- for(MnpBuilding build: mnpBuildings){
|
|
|
+ for (MnpBuilding build : mnpBuildings) {
|
|
|
build.setDiscName(record.getName());
|
|
|
buildingService.updateByPrimaryKey(build);
|
|
|
}
|
|
@@ -159,15 +164,16 @@ public class ParkFloorDiscService implements BaseService<ParkFloorDisc, ParkFloo
|
|
|
|
|
|
/**
|
|
|
* 新增分期
|
|
|
+ *
|
|
|
* @param model
|
|
|
* @return
|
|
|
*/
|
|
|
- public int add(ParkFloorDiscRespson model){
|
|
|
+ public int add(ParkFloorDiscRespson model) {
|
|
|
String houseTypeStr = model.getHouseTypeStr();
|
|
|
String id = IdUtil.simpleUUID();
|
|
|
model.setId(id);
|
|
|
List<HouseType> houseTypes = JSONObject.parseArray(houseTypeStr, HouseType.class);
|
|
|
- for(HouseType houseType : houseTypes){
|
|
|
+ for (HouseType houseType : houseTypes) {
|
|
|
houseType.setId(IdUtil.simpleUUID());
|
|
|
houseType.setDiscId(id);
|
|
|
houseTypeService.insertSelective(houseType);
|
|
@@ -180,10 +186,11 @@ public class ParkFloorDiscService implements BaseService<ParkFloorDisc, ParkFloo
|
|
|
|
|
|
/**
|
|
|
* 编辑分期
|
|
|
+ *
|
|
|
* @param model
|
|
|
* @return
|
|
|
*/
|
|
|
- public int edit(ParkFloorDiscRespson model){
|
|
|
+ public int edit(ParkFloorDiscRespson model) {
|
|
|
|
|
|
//先删除对应户型库
|
|
|
HouseTypeExample houseTypeExample = new HouseTypeExample();
|
|
@@ -191,9 +198,9 @@ public class ParkFloorDiscService implements BaseService<ParkFloorDisc, ParkFloo
|
|
|
houseTypeService.deleteByExample(houseTypeExample);
|
|
|
String houseTypeStr = model.getHouseTypeStr();
|
|
|
List<HouseType> houseTypes = JSONObject.parseArray(houseTypeStr, HouseType.class);
|
|
|
- for(HouseType houseType : houseTypes){
|
|
|
+ for (HouseType houseType : houseTypes) {
|
|
|
// 没有id的情况
|
|
|
- if(StringUtils.isEmpty(houseType.getId())){
|
|
|
+ if (StringUtils.isEmpty(houseType.getId())) {
|
|
|
houseType.setId(IdUtil.simpleUUID());
|
|
|
}
|
|
|
houseType.setDiscId(model.getId());
|
|
@@ -206,7 +213,7 @@ public class ParkFloorDiscService implements BaseService<ParkFloorDisc, ParkFloo
|
|
|
public ParkFloorDiscRespson getById(String id) {
|
|
|
ParkFloorDisc parkFloorDisc = selectByPrimaryKey(id);
|
|
|
ParkFloorDiscRespson parkFloorDiscRespson = new ParkFloorDiscRespson();
|
|
|
- BeanUtil.copyProperties(parkFloorDisc,parkFloorDiscRespson);
|
|
|
+ BeanUtil.copyProperties(parkFloorDisc, parkFloorDiscRespson);
|
|
|
// HouseTypeExample houseTypeExample = new HouseTypeExample();
|
|
|
// houseTypeExample.createCriteria().andDiscIdEqualTo(id);
|
|
|
// List<HouseType> houseTypes = houseTypeService.selectByExampleWithBLOBs(houseTypeExample);
|
|
@@ -217,49 +224,66 @@ public class ParkFloorDiscService implements BaseService<ParkFloorDisc, ParkFloo
|
|
|
return parkFloorDiscRespson;
|
|
|
}
|
|
|
|
|
|
- public Map<String,String> getNameIdMap() {
|
|
|
+ public Map<String, String> getNameIdMap() {
|
|
|
Map<String, String> map = new HashMap<>();
|
|
|
List<ParkFloorDisc> list = selectByExample(new ParkFloorDiscExample());
|
|
|
if (CollectionUtils.isNotEmpty(list)) {
|
|
|
- map = list.stream().collect(Collectors.toMap(ParkFloorDisc::getName, ParkFloorDisc::getId, (v1, v2) ->v1));
|
|
|
+ map = list.stream().collect(Collectors.toMap(ParkFloorDisc::getName, ParkFloorDisc::getId, (v1, v2) -> v1));
|
|
|
}
|
|
|
return map;
|
|
|
}
|
|
|
|
|
|
- public void insertBatch(List<ParkFloorDisc> list){
|
|
|
- extendMapper.insertBatch(list);
|
|
|
+ public void insertBatch(List<ParkFloorDisc> list) {
|
|
|
+ extendMapper.insertBatch(list);
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* 分期删除
|
|
|
+ *
|
|
|
* @param id
|
|
|
* @return
|
|
|
*/
|
|
|
- public int delete(String id){
|
|
|
+ public int delete(String id) {
|
|
|
MnpBuildingExample buildingExample = new MnpBuildingExample();
|
|
|
buildingExample.createCriteria().andDiscIdEqualTo(id);
|
|
|
List<MnpBuilding> mnpBuildings = buildingService.selectByExample(buildingExample);
|
|
|
- if(CollectionUtils.isNotEmpty(mnpBuildings)){
|
|
|
+ if (CollectionUtils.isNotEmpty(mnpBuildings)) {
|
|
|
throw new RuntimeException("该数据有子单元/楼栋存在,无法删除");
|
|
|
}
|
|
|
return deleteByPrimaryKey(id);
|
|
|
}
|
|
|
|
|
|
|
|
|
- public String getOrderNum(ParkFloorDisc floorDisc){
|
|
|
+ public String getOrderNum(ParkFloorDisc floorDisc) {
|
|
|
|
|
|
ParkFloorDiscExample example = new ParkFloorDiscExample();
|
|
|
example.createCriteria().andGroupIdEqualTo(floorDisc.getGroupId());
|
|
|
Long count = countByExample(example);
|
|
|
String number = "";
|
|
|
- if(count.doubleValue() == 0){
|
|
|
+ if (count.doubleValue() == 0) {
|
|
|
number = "01";
|
|
|
- }else {
|
|
|
+ } else {
|
|
|
count++;
|
|
|
number = String.format("%02d", count);
|
|
|
}
|
|
|
return number;
|
|
|
}
|
|
|
|
|
|
+ public void errorListExport(List<ParkFloorDiscExcel> list, HttpServletResponse response) throws IOException {
|
|
|
+
|
|
|
+
|
|
|
+ SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
|
|
|
+ String date = sdf.format(new Date());
|
|
|
+ response.setContentType("application/vnd.ms-excel");
|
|
|
+ response.setCharacterEncoding("utf-8");
|
|
|
+ String fileName = URLEncoder.encode("失败几率" + date, "UTF-8");
|
|
|
+ response.setHeader("Content-disposition", "attachment;filename=" + fileName + ".xlsx");
|
|
|
+ EasyExcel.write(response.getOutputStream(), ParkFloorDiscExcel.class)
|
|
|
+ .inMemory(true)
|
|
|
+ .registerWriteHandler(new WriteHandlerStrategy())//自定义样式
|
|
|
+ .sheet().doWrite(list);
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
|
|
|
}
|