|
|
@ -24,6 +24,7 @@ import com.baomidou.mybatisplus.core.metadata.IPage; |
|
|
|
import com.elink.esua.epdc.commons.mybatis.service.impl.CrudServiceImpl; |
|
|
|
import com.elink.esua.epdc.commons.tools.constant.FieldConstant; |
|
|
|
import com.elink.esua.epdc.commons.tools.constant.NumConstant; |
|
|
|
import com.elink.esua.epdc.commons.tools.constant.StrConstant; |
|
|
|
import com.elink.esua.epdc.commons.tools.exception.RenException; |
|
|
|
import com.elink.esua.epdc.commons.tools.page.PageData; |
|
|
|
import com.elink.esua.epdc.commons.tools.utils.ConvertUtils; |
|
|
@ -37,6 +38,7 @@ import com.elink.esua.epdc.dto.house.result.EpdcPopulationErrorResultDTO; |
|
|
|
import com.elink.esua.epdc.dto.personroom.EpidemicBuildingUnitDTO; |
|
|
|
import com.elink.esua.epdc.dto.personroom.EpidemicUnitOwnerDTO; |
|
|
|
import com.elink.esua.epdc.dto.personroom.form.GetHouseInfoFormDTO; |
|
|
|
import com.elink.esua.epdc.dto.personroom.form.HouseQrcodeZipFormDTO; |
|
|
|
import com.elink.esua.epdc.dto.personroom.result.*; |
|
|
|
import com.elink.esua.epdc.vaccine.epidemic.entity.EpidemicUserErrorEntity; |
|
|
|
import com.elink.esua.epdc.vaccine.epidemic.entity.EpidemicUserInfoEntity; |
|
|
@ -63,6 +65,7 @@ import org.springframework.transaction.annotation.Transactional; |
|
|
|
import org.springframework.web.multipart.MultipartFile; |
|
|
|
|
|
|
|
import javax.imageio.ImageIO; |
|
|
|
import javax.imageio.stream.ImageOutputStream; |
|
|
|
import javax.servlet.http.HttpServletResponse; |
|
|
|
import java.awt.image.BufferedImage; |
|
|
|
import java.io.*; |
|
|
@ -105,9 +108,6 @@ public class EpidemicBuildingUnitServiceImpl extends CrudServiceImpl<EpidemicBui |
|
|
|
|
|
|
|
@Autowired |
|
|
|
private VimOssFeignClient ossFeignClient; |
|
|
|
//
|
|
|
|
// @Autowired
|
|
|
|
// private HouseQRcodeUtils houseQRcodeUtils;
|
|
|
|
|
|
|
|
@Autowired |
|
|
|
private QrCodeProperties qrCodeProperties; |
|
|
@ -129,6 +129,8 @@ public class EpidemicBuildingUnitServiceImpl extends CrudServiceImpl<EpidemicBui |
|
|
|
@Override |
|
|
|
public QueryWrapper<EpidemicBuildingUnitEntity> getWrapper(Map<String, Object> params) { |
|
|
|
String id = (String) params.get(FieldConstant.ID_HUMP); |
|
|
|
String buildingId = (String) params.get("buildingId"); |
|
|
|
String unit = (String) params.get("unit"); |
|
|
|
String roomNo = (String) params.get("roomNo"); |
|
|
|
String type = (String) params.get("roomType"); |
|
|
|
String owner = (String) params.get("ownerName"); |
|
|
@ -137,6 +139,8 @@ public class EpidemicBuildingUnitServiceImpl extends CrudServiceImpl<EpidemicBui |
|
|
|
|
|
|
|
QueryWrapper<EpidemicBuildingUnitEntity> wrapper = new QueryWrapper<>(); |
|
|
|
wrapper.eq(StringUtils.isNotBlank(id), FieldConstant.ID, id); |
|
|
|
wrapper.eq(StringUtils.isNotBlank(buildingId), "BUILDING_ID", buildingId); |
|
|
|
wrapper.eq(StringUtils.isNotBlank(unit), "UNIT", unit); |
|
|
|
wrapper.eq(StringUtils.isNotBlank(roomNo), "ROOM_NO", roomNo); |
|
|
|
wrapper.eq(StringUtils.isNotBlank(type), "ROOM_TYPE", type); |
|
|
|
wrapper.eq(StringUtils.isNotBlank(owner), "OWNER_NAME", owner); |
|
|
@ -166,6 +170,13 @@ public class EpidemicBuildingUnitServiceImpl extends CrudServiceImpl<EpidemicBui |
|
|
|
@Override |
|
|
|
@Transactional(rollbackFor = Exception.class) |
|
|
|
public Result saveNew(EpidemicBuildingUnitDTO dto) { |
|
|
|
Map<String, Object> params = new HashMap<>(8); |
|
|
|
params.put("buildingId", dto.getBuildingId()); |
|
|
|
params.put("unit", dto.getUnit()); |
|
|
|
params.put("roomNo", dto.getRoomNo()); |
|
|
|
if (!list(params).isEmpty()) { |
|
|
|
throw new RenException("房屋已存在"); |
|
|
|
} |
|
|
|
checkData(dto); |
|
|
|
EpidemicBuildingUnitEntity entity = ConvertUtils.sourceToTarget(dto, EpidemicBuildingUnitEntity.class); |
|
|
|
insert(entity); |
|
|
@ -322,6 +333,29 @@ public class EpidemicBuildingUnitServiceImpl extends CrudServiceImpl<EpidemicBui |
|
|
|
return maxCode; |
|
|
|
} |
|
|
|
|
|
|
|
@Override |
|
|
|
public void updateErrorRoom() { |
|
|
|
List<EpidemicBuildingUnitEntity> list = baseDao.getErrorRoom(); |
|
|
|
list.forEach(item -> { |
|
|
|
log.info("正在处理" + item.getBuildingId() + "/" + item.getUnit() + "/" + item.getRoomNo()); |
|
|
|
Map<String, Object> params = new HashMap<>(); |
|
|
|
params.put("buildingId", item.getBuildingId().toString()); |
|
|
|
params.put("unit", item.getUnit()); |
|
|
|
params.put("roomNo", item.getRoomNo()); |
|
|
|
List<EpidemicBuildingUnitDTO> dtos = list(params); |
|
|
|
EpidemicBuildingUnitDTO base = dtos.get(0); |
|
|
|
dtos.forEach(dto -> { |
|
|
|
// 更新关系表的房屋ID
|
|
|
|
epidemicUnitOwnerDao.updateByUnitId(dto.getId(), base.getId()); |
|
|
|
if (!dto.getId().equals(base.getId())) { |
|
|
|
String[] ids = new String[]{dto.getId().toString()}; |
|
|
|
// 删除无用的房屋
|
|
|
|
delete(ids); |
|
|
|
} |
|
|
|
}); |
|
|
|
}); |
|
|
|
} |
|
|
|
|
|
|
|
@Override |
|
|
|
public void updateMaCode() { |
|
|
|
Map<String, Object> params = new HashMap<>(4); |
|
|
@ -342,13 +376,13 @@ public class EpidemicBuildingUnitServiceImpl extends CrudServiceImpl<EpidemicBui |
|
|
|
List<EpidemicBuildingUnitDTO> list = baseDao.listUnitHasNotUrl(); |
|
|
|
if (!list.isEmpty()) { |
|
|
|
list.forEach(item -> { |
|
|
|
String url = ""; |
|
|
|
try { |
|
|
|
url = createHouseQrcodeUrl(item); |
|
|
|
String name = item.getBuildingName() + StrConstant.HYPHEN + item.getUnit() + StrConstant.HYPHEN + item.getRoomNo(); |
|
|
|
String maUrl = createHouseQrCodeUrl(item.getRoomCode(), name); |
|
|
|
item.setMaUrl(maUrl); |
|
|
|
} catch (Exception e) { |
|
|
|
throw new RenException("房屋码上传失败"); |
|
|
|
} |
|
|
|
item.setMaUrl(url); |
|
|
|
}); |
|
|
|
List<EpidemicBuildingUnitEntity> updateList = ConvertUtils.sourceToTarget(list, EpidemicBuildingUnitEntity.class); |
|
|
|
updateBatchById(updateList); |
|
|
@ -357,7 +391,7 @@ public class EpidemicBuildingUnitServiceImpl extends CrudServiceImpl<EpidemicBui |
|
|
|
} |
|
|
|
|
|
|
|
@Override |
|
|
|
public void downloadZip(HttpServletResponse response) throws Exception { |
|
|
|
public void downloadZip(HouseQrcodeZipFormDTO formDTO, HttpServletResponse response) throws Exception { |
|
|
|
//response
|
|
|
|
response.reset(); |
|
|
|
//文件的名称
|
|
|
@ -370,14 +404,14 @@ public class EpidemicBuildingUnitServiceImpl extends CrudServiceImpl<EpidemicBui |
|
|
|
response.setHeader("Content-Disposition", "attachment;filename=" + downloadFilename); |
|
|
|
ZipOutputStream zip = new ZipOutputStream(response.getOutputStream()); |
|
|
|
|
|
|
|
List<EpidemicBuildingUnitDTO> houseList = baseDao.listUnitHasUrl(); |
|
|
|
List<EpidemicBuildingUnitDTO> houseList = baseDao.listUnitHasCode(formDTO); |
|
|
|
String urlPre = qrCodeProperties.getPre(); |
|
|
|
|
|
|
|
for (EpidemicBuildingUnitDTO house : houseList) { |
|
|
|
|
|
|
|
BufferedImage image = HouseQRcodeUtils.drawHouseQRImage(house.getBuildingName() + house.getUnit() + house.getRoomNo(), |
|
|
|
qrCodeProperties.getPre() + house.getRoomCode()); |
|
|
|
|
|
|
|
try { |
|
|
|
BufferedImage image = HouseQRcodeUtils.drawHouseQRImage(house.getBuildingName() + StrConstant.HYPHEN + house.getUnit() + StrConstant.HYPHEN + house.getRoomNo(), |
|
|
|
urlPre + house.getRoomCode()); |
|
|
|
|
|
|
|
byte[] buf = new byte[8192]; |
|
|
|
int len; |
|
|
|
//添加到zip
|
|
|
@ -388,6 +422,7 @@ public class EpidemicBuildingUnitServiceImpl extends CrudServiceImpl<EpidemicBui |
|
|
|
zip.write(buf, 0, len); |
|
|
|
} |
|
|
|
inputStream.close(); |
|
|
|
zip.closeEntry(); |
|
|
|
} catch (IOException e) { |
|
|
|
throw new RenException("组装zip失败"); |
|
|
|
} |
|
|
@ -395,6 +430,43 @@ public class EpidemicBuildingUnitServiceImpl extends CrudServiceImpl<EpidemicBui |
|
|
|
zip.close(); |
|
|
|
} |
|
|
|
|
|
|
|
@Override |
|
|
|
public void createQrCode(String roomId, HttpServletResponse response) { |
|
|
|
try { |
|
|
|
EpidemicBuildingUnitDetailResultDTO house = get(roomId); |
|
|
|
if (null == house) { |
|
|
|
throw new RenException("未查到房屋信息"); |
|
|
|
} |
|
|
|
//url组成:小程序地址?房屋编码
|
|
|
|
String url = qrCodeProperties.getPre() + house.getRoomCode(); |
|
|
|
String name = house.getBuildingName() + StrConstant.HYPHEN + house.getUnit() + StrConstant.HYPHEN + house.getRoomNo(); |
|
|
|
BufferedImage image = HouseQRcodeUtils.drawHouseQRImage(name, url); |
|
|
|
//BufferedImage 转 InputStream
|
|
|
|
ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream(); |
|
|
|
ImageOutputStream imageOutput = ImageIO.createImageOutputStream(byteArrayOutputStream); |
|
|
|
ImageIO.write(image, "png", imageOutput); |
|
|
|
InputStream inputStream = new ByteArrayInputStream(byteArrayOutputStream.toByteArray()); |
|
|
|
long length = imageOutput.length(); |
|
|
|
String fileName = house.getBuildingName() + house.getUnit() + house.getRoomNo() + ".png"; |
|
|
|
response.setContentType("application/octet-stream"); |
|
|
|
response.setContentLength((int) length); |
|
|
|
response.setHeader("Content-Disposition", "attachment;filename=" + URLEncoder.encode(fileName, StrConstant.UTF_8)); |
|
|
|
|
|
|
|
//输出流
|
|
|
|
byte[] bytes = new byte[1024]; |
|
|
|
OutputStream outputStream = response.getOutputStream(); |
|
|
|
long count = 0; |
|
|
|
while (count < length) { |
|
|
|
int len = inputStream.read(bytes, 0, 1024); |
|
|
|
count += len; |
|
|
|
outputStream.write(bytes, 0, len); |
|
|
|
} |
|
|
|
outputStream.flush(); |
|
|
|
} catch (Exception e) { |
|
|
|
throw new RenException("生成房屋码失败"); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
/** |
|
|
|
* 将BufferedImage转换为InputStream |
|
|
|
* |
|
|
@ -570,6 +642,20 @@ public class EpidemicBuildingUnitServiceImpl extends CrudServiceImpl<EpidemicBui |
|
|
|
unitEntity.setStreetId(parentAndAllDeptDTO.getStreetId().toString()); |
|
|
|
unitEntity.setStreetName(parentAndAllDeptDTO.getStreet()); |
|
|
|
insert(unitEntity); |
|
|
|
|
|
|
|
// 新增的房屋也要放到待筛选列表,后续循环便可认为该房屋是已存在的
|
|
|
|
EpidemicUnitInfoResultDTO newUnit = new EpidemicUnitInfoResultDTO(); |
|
|
|
newUnit.setBuildingId(buildingOptional.get().getId()); |
|
|
|
newUnit.setBuildingName(buildingOptional.get().getBuildingName()); |
|
|
|
newUnit.setGridId(buildingOptional.get().getGridId()); |
|
|
|
newUnit.setPlotId(buildingOptional.get().getPlotId()); |
|
|
|
newUnit.setPlotName(buildingOptional.get().getPlotName()); |
|
|
|
newUnit.setUnit(item.getUnit().trim().toUpperCase()); |
|
|
|
newUnit.setUnitId(unitEntity.getId()); |
|
|
|
newUnit.setRoomNo(item.getRoomNo().trim().toUpperCase()); |
|
|
|
newUnit.setRoomMaCode(roomCode); |
|
|
|
unitList.add(newUnit); |
|
|
|
|
|
|
|
EpidemicUnitOwnerEntity entity = new EpidemicUnitOwnerEntity(); |
|
|
|
entity.setIdCard(item.getIdCard()); |
|
|
|
entity.setUnitId(unitEntity.getId()); |
|
|
@ -647,7 +733,7 @@ public class EpidemicBuildingUnitServiceImpl extends CrudServiceImpl<EpidemicBui |
|
|
|
public Result<HouseInfoResultDTO> getHouseInfo(GetHouseInfoFormDTO formDTO) { |
|
|
|
HouseInfoResultDTO houseInfoResultDTO = baseDao.getHouseInfo(formDTO); |
|
|
|
|
|
|
|
if(houseInfoResultDTO != null){ |
|
|
|
if (houseInfoResultDTO != null) { |
|
|
|
List<FamilyMemberInfoResultDTO> members = epidemicUnitOwnerDao.getFamilyMemberInfoByUnitId(houseInfoResultDTO.getId()); |
|
|
|
houseInfoResultDTO.setMembers(members); |
|
|
|
} |
|
|
@ -656,11 +742,11 @@ public class EpidemicBuildingUnitServiceImpl extends CrudServiceImpl<EpidemicBui |
|
|
|
return new Result<HouseInfoResultDTO>().ok(houseInfoResultDTO); |
|
|
|
} |
|
|
|
|
|
|
|
public String createHouseQrcodeUrl(EpidemicBuildingUnitDTO house) throws Exception { |
|
|
|
public String createHouseQrCodeUrl(String roomCode, String name) throws Exception { |
|
|
|
//url组成:小程序地址?房屋编码
|
|
|
|
String url = qrCodeProperties.getPre() + house.getRoomCode(); |
|
|
|
String fileName = house.getBuildingName() + house.getUnit() + house.getRoomNo() + ".png"; |
|
|
|
BufferedImage image = HouseQRcodeUtils.drawHouseQRImage(house.getBuildingName() + house.getUnit() + house.getRoomNo(), url); |
|
|
|
String url = qrCodeProperties.getPre() + roomCode; |
|
|
|
String fileName = name + ".png"; |
|
|
|
BufferedImage image = HouseQRcodeUtils.drawHouseQRImage(name, url); |
|
|
|
ByteArrayOutputStream out = new ByteArrayOutputStream(); |
|
|
|
try { |
|
|
|
ImageIO.write(image, "png", out); |
|
|
|