| | |
| | | import com.google.common.collect.Lists; |
| | | import com.panzhihua.common.model.dtos.community.OperationDetailDTO; |
| | | import com.panzhihua.common.model.dtos.community.reserve.*; |
| | | import com.panzhihua.common.model.helper.AESUtil; |
| | | import com.panzhihua.common.model.vos.R; |
| | | import com.panzhihua.common.model.vos.community.ComActReserveIndexVo; |
| | | import com.panzhihua.common.model.vos.community.bigscreen.IndexBackReserve; |
| | |
| | | import com.panzhihua.common.model.vos.community.questnaire.QuestnaiteSubSelectionVO; |
| | | import com.panzhihua.common.model.vos.community.questnaire.QuestnaiteSubVO; |
| | | import com.panzhihua.common.model.vos.community.reserve.*; |
| | | import com.panzhihua.common.utlis.Snowflake; |
| | | import com.panzhihua.common.utlis.StringUtils; |
| | | import com.panzhihua.service_community.dao.ComActReserveMapper; |
| | | import com.panzhihua.service_community.dao.ComActReserveSubMapper; |
| | |
| | | import com.panzhihua.service_community.service.ComActReserveSubSelectionService; |
| | | import lombok.extern.slf4j.Slf4j; |
| | | import org.springframework.beans.BeanUtils; |
| | | import org.springframework.beans.factory.annotation.Value; |
| | | import org.springframework.stereotype.Service; |
| | | import org.springframework.transaction.annotation.Transactional; |
| | | |
| | |
| | | import java.io.IOException; |
| | | import java.math.BigDecimal; |
| | | import java.math.RoundingMode; |
| | | import java.security.InvalidKeyException; |
| | | import java.security.NoSuchAlgorithmException; |
| | | import java.util.ArrayList; |
| | | import java.util.Date; |
| | | import java.util.List; |
| | | import org.springframework.transaction.annotation.Transactional; |
| | | |
| | | import javax.annotation.Resource; |
| | | import javax.crypto.BadPaddingException; |
| | | import javax.crypto.IllegalBlockSizeException; |
| | | import javax.crypto.NoSuchPaddingException; |
| | | import java.util.ArrayList; |
| | | import java.util.Date; |
| | | import java.util.List; |
| | |
| | | private ComActReserveSubSelectionService comActReserveSubSelectionService; |
| | | @Resource |
| | | private ComActReserveRecordService comActReserveRecordService; |
| | | @Resource |
| | | private ComMngPopulationDAO comMngPopulationDAO; |
| | | @Resource |
| | | private ComMngPopulationHouseDAO comMngPopulationHouseDAO; |
| | | @Resource |
| | | private ComMngPopulationCommunityTagsDAO comMngPopulationCommunityTagsDAO; |
| | | @Resource |
| | | private ComMngPopulationHouseUserDAO comMngPopulationHouseUserDAO; |
| | | @Value("${domain.aesKey:}") |
| | | private String aesKey; |
| | | |
| | | private final static String COMMIT="用户已提交"; |
| | | @Override |
| | | @Transactional |
| | | public R commit(ComActReserveCommitVO comActReserveCommitVO) { |
| | | if(comActReserveCommitVO!=null){ |
| | | ComMngPopulationHouseDO comMngPopulationHouseDO=new ComMngPopulationHouseDO(); |
| | | Long userId=comActReserveCommitVO.getUserId(); |
| | | Date nowDate=DateUtil.date(); |
| | | //查询预约登记记录 |
| | |
| | | else { |
| | | List<QuestnaiteSubVO> questnaiteSubVOS = JSON.parseArray(comActReserveCommitVO.getJsonObject(),QuestnaiteSubVO.class); |
| | | if(!questnaiteSubVOS.isEmpty()){ |
| | | String idCard=""; |
| | | String houseId=""; |
| | | String phone=""; |
| | | Long questId=comActReserveCommitVO.getId(); |
| | | List<ComActReserveAnswerContentDO> answerContentList=new ArrayList<>(); |
| | | for(QuestnaiteSubVO questnaiteSub:questnaiteSubVOS){ |
| | |
| | | answerContentDO.setAnswerContent(subSelectionDO.getContent()); |
| | | answerContentList.add(answerContentDO); |
| | | } |
| | | }else{ |
| | | } |
| | | else{ |
| | | //文字描述不做处理 |
| | | if(!questnaiteSub.getType().equals(QuestnaiteSubVO.type.describe)){ |
| | | if(!questnaiteSub.getType().equals(QuestnaiteSubVO.type.describe)&&!questnaiteSub.getType().equals(QuestnaiteSubVO.type.address)){ |
| | | //问答题处理 |
| | | String values = questnaiteSub.getValues(); |
| | | ComActReserveAnswerContentDO answerContentDO = new ComActReserveAnswerContentDO(); |
| | |
| | | answerContentDO.setAnswerContent(values); |
| | | answerContentList.add(answerContentDO); |
| | | } |
| | | if(questnaiteSub.getType().equals(QuestnaiteSubVO.type.card)){ |
| | | idCard=questnaiteSub.getValues(); |
| | | } |
| | | if(questnaiteSub.getType().equals(QuestnaiteSubVO.type.phone)){ |
| | | phone=questnaiteSub.getValues(); |
| | | } |
| | | if(questnaiteSub.getType().equals(QuestnaiteSubVO.type.address)){ |
| | | houseId=questnaiteSub.getValues(); |
| | | comMngPopulationHouseDO=comMngPopulationHouseDAO.selectById(houseId); |
| | | if(comMngPopulationHouseDO!=null){ |
| | | ComActReserveAnswerContentDO answerContentDO = new ComActReserveAnswerContentDO(); |
| | | answerContentDO.setUserId(userId); |
| | | answerContentDO.setCreateAt(nowDate); |
| | | answerContentDO.setCreateBy(userId); |
| | | answerContentDO.setReserveSubId(queSubId); |
| | | answerContentDO.setType(2); |
| | | answerContentDO.setAnswerContent(comMngPopulationHouseDO.getAddress()); |
| | | answerContentList.add(answerContentDO); |
| | | } |
| | | } |
| | | } |
| | | } |
| | | if(!answerContentList.isEmpty()){ |
| | | //判断实有人口情况 |
| | | if(StringUtils.isNotEmpty(idCard)&&StringUtils.isNotEmpty(houseId)){ |
| | | Integer count=comMngPopulationDAO.selectCount(new QueryWrapper<ComMngPopulationDO>().lambda().eq(ComMngPopulationDO::getCardNoStr,idCard)); |
| | | if(count==0){ |
| | | ComMngPopulationDO comMngPopulationDO=savePopulation(idCard); |
| | | if(comMngPopulationHouseDO!=null){ |
| | | comMngPopulationDO.setId(Snowflake.getId()); |
| | | comMngPopulationDO.setAddress(comMngPopulationHouseDO.getAddress()); |
| | | comMngPopulationDO.setActId(comMngPopulationHouseDO.getCommunityId()); |
| | | comMngPopulationDO.setStreetId(comMngPopulationHouseDO.getStreetId()); |
| | | comMngPopulationDO.setVillageId(comMngPopulationHouseDO.getVillageId()); |
| | | comMngPopulationDO.setHouseId(comMngPopulationHouseDO.getId()); |
| | | comMngPopulationDO.setOutOrLocal(1); |
| | | comMngPopulationDO.setPhone(phone); |
| | | comMngPopulationDO.setName(comActReserveCommitVO.getName()); |
| | | comMngPopulationDO.setRoad(comMngPopulationHouseDO.getAlley()); |
| | | comMngPopulationDO.setDoorNo(comMngPopulationHouseDO.getHouseNum()); |
| | | comMngPopulationDO.setFloor(comMngPopulationHouseDO.getFloor()); |
| | | comMngPopulationDO.setUnitNo(comMngPopulationHouseDO.getUnitNo()); |
| | | comMngPopulationDO.setHouseNo(comMngPopulationHouseDO.getHouseNo()); |
| | | comMngPopulationDAO.insert(comMngPopulationDO); |
| | | ComMngPopulationCommunityTagsDO comMngPopulationCommunityTagsDO=new ComMngPopulationCommunityTagsDO(); |
| | | comMngPopulationCommunityTagsDO.setCommunityId(comMngPopulationDO.getActId()); |
| | | comMngPopulationCommunityTagsDO.setPopulationId(comMngPopulationDO.getId()); |
| | | comMngPopulationCommunityTagsDO.setId(Snowflake.getId()); |
| | | comMngPopulationCommunityTagsDO.setCreateAt(new Date()); |
| | | comMngPopulationCommunityTagsDAO.insert(comMngPopulationCommunityTagsDO); |
| | | ComMngPopulationHouseUserDO comMngPopulationHouseUserDO=new ComMngPopulationHouseUserDO(); |
| | | comMngPopulationHouseUserDO.setId(Snowflake.getId()); |
| | | comMngPopulationHouseUserDO.setPopulId(comMngPopulationDO.getId()); |
| | | comMngPopulationHouseUserDO.setHouseId(Long.parseLong(houseId)); |
| | | comMngPopulationHouseUserDO.setRelation(1); |
| | | comMngPopulationHouseUserDO.setRelationId(1); |
| | | comMngPopulationHouseUserDO.setResidence(1); |
| | | comMngPopulationHouseUserDO.setCreateAt(new Date()); |
| | | comMngPopulationHouseUserDAO.insert(comMngPopulationHouseUserDO); |
| | | } |
| | | } |
| | | } |
| | | //更新回答用户数量 |
| | | Integer joinCount = comActReserveDO.getJoinCount(); |
| | | comActReserveDO.setJoinCount(joinCount != null ? joinCount + 1 : 1); |
| | |
| | | return null; |
| | | } |
| | | |
| | | public ComMngPopulationDO savePopulation(String idCard){ |
| | | ComMngPopulationDO comMngPopulationDO=new ComMngPopulationDO(); |
| | | comMngPopulationDO.setDeath("1"); |
| | | comMngPopulationDO.setCardNoStr(idCard); |
| | | comMngPopulationDO.setCardNo(idCard); |
| | | comMngPopulationDO.setSex(getSex(idCard)); |
| | | comMngPopulationDO.setBirthday(getBirthday(idCard)); |
| | | return comMngPopulationDO; |
| | | } |
| | | public Integer getSex(String idCard){ |
| | | char c = idCard.charAt(idCard.length() - 2); |
| | | Integer gender = Integer.parseInt(String.valueOf(c)); |
| | | if(gender % 2 == 1){ |
| | | return 1; |
| | | }else{ |
| | | return 2; |
| | | } |
| | | } |
| | | public String getBirthday(String idCard){ |
| | | return idCard.substring(6).substring(0, 4)+"-"+idCard.substring(10).substring(0, 2)+"-"+idCard.substring(12).substring(0,2); |
| | | } |
| | | |
| | | |
| | | public static void getFileByBytes(byte[] bytes, String filePath, String fileName) { |
| | | BufferedOutputStream bos = null; |