当前位置: 首页 > news >正文

网站和管理系统的区别软考培训机构哪家好一点

网站和管理系统的区别,软考培训机构哪家好一点,怎么做病毒视频网站,网站制作培训机构前言 在我看来多写几个if-else没啥大不了的,但是就是看起来没啥逼格,领导嫌弃。我根据开发的经历写几个不同的替代方法 一、枚举法替代 我先前写了一篇文章,可以去看看。 通过枚举替换if-else语句的解决方案_枚举代替if else c语言-CSDN博…

前言 

在我看来多写几个if-else没啥大不了的,但是就是看起来没啥逼格,领导嫌弃。我根据开发的经历写几个不同的替代方法

一、枚举法替代 

我先前写了一篇文章,可以去看看。

通过枚举替换if-else语句的解决方案_枚举代替if else c语言-CSDN博客

二、定义接口,实现类

通过定义初始方法,通过添加多个实现类来选择

  • 接口

public interface ISoapServer {/*** 服务编码* @return*/String getCode();/*** 服务* @param xml* @return*/String server(String xml);}
  • 实现类

 其中一个实现类,其他的类似


import cn.hutool.core.convert.Convert;
import cn.hutool.core.lang.UUID;
import cn.hutool.core.util.IdUtil;
import cn.hutool.core.util.IdcardUtil;
import cn.hutool.core.util.StrUtil;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import us.codecraft.webmagic.selector.Html;import java.util.List;/*** @author HuangZheng* @create 2023-05-05 9:49* @description 居民信息提交服务*/
@Service
public class Soap06IstPr1 implements ISoapServer {@Autowiredprivate WebClientServer webClientServer;@Overridepublic String getCode() {return "IST-PR1";}@Overridepublic String server(String xml) {try {if (StrUtil.isBlank(xml)) {throw new BaseException("参数不能为空!");}// 要插入的业务表Patient patient = new Patient();String pid = IdUtil.fastSimpleUUID();patient.setPid(pid);// 第一步 解析参数Html requestXml = Html.create(xml);// 获取身份证号// 1、从开头寻找List<String> idNoList = requestXml.xpath("//personInfo/identifier/value/@value").all();// 2、从assignedPerson节点寻找List<String> tempIdNoList = requestXml.xpath("//assignedPerson/identifier/value/@value").all();idNoList.addAll(tempIdNoList);for (String s : idNoList) {if (IdcardUtil.isValidCard(s)) {patient.setIdNo(s);patient.setIdTypeCode("01");patient.setIdTypeName("身份证");// 只要能取到一个就行break;}}// 姓名final String name = requestXml.xpath("//personInfo/assignedPerson/name/@value").get();patient.setName(name);// 性别final String sexCode = requestXml.xpath("//personInfo/assignedPerson/gender/@value").get();patient.setSexCode(sexCode);ExceptionUtil.soapExcpition("1",name);ExceptionUtil.soapExcpition("2",sexCode);final String sexName = XmlReadUtil.getRangeByKey("GB/T 2261.1-2003", sexCode).getValue();patient.setSexName(sexName);// 手机号码String telNo = requestXml.xpath("//personInfo/telecom/value/@value").get();patient.setTelNo(telNo);// 获取地址addressString presentAddress = requestXml.xpath("//personInfo/address/text/@value").get();String presentAddrProvi = requestXml.xpath("//personInfo/address/state/@value").get();String presentAddrCity = requestXml.xpath("//personInfo/address/city/@value").get();String presentAddrCounty = requestXml.xpath("//personInfo/address/district/@value").get();String presentAddrTown = requestXml.xpath("//personInfo/address/town/@value").get();String presentAddrVillage = requestXml.xpath("//personInfo/address/street/@value").get();String presentAddrHouNo = requestXml.xpath("//personInfo/address/houseNumber/@value").get();// 存值patient.setPresentAddress(TextUtil.getStr(presentAddress, "-"));patient.setPresentAddrProvi(TextUtil.getStr(presentAddrProvi, "-"));patient.setPresentAddrCity(TextUtil.getStr(presentAddrCity, "-"));patient.setPresentAddrCounty(TextUtil.getStr(presentAddrCounty, "-"));patient.setPresentAddrTown(TextUtil.getStr(presentAddrTown, "-"));patient.setPresentAddrVillage(TextUtil.getStr(presentAddrVillage, "-"));patient.setPresentAddrHouNo(TextUtil.getStr(presentAddrHouNo, "-"));// 出生日期final String birthday = requestXml.xpath("//personInfo/assignedPerson/birthTime/@value").get();patient.setBirthday(Convert.toDate(birthday));// 婚姻状况final String marCode = requestXml.xpath("//personInfo/assignedPerson/maritalStatusCode/@value").get();patient.setMarCode(marCode);final String marName = XmlReadUtil.getRangeByKey("GB/T 2261.2-2003", marCode).getValue();patient.setMarName(marName);// ORG_ID 通过最后的机构名称查询String orgName = requestXml.xpath("//personInfo/assignedOrganization/name/@value").get();OrgMapper orgMapper = SpringUtils.getBean(OrgMapper.class);Org org = orgMapper.selectOne(new LambdaQueryWrapper<Org>().eq(Org::getManagerorgname, orgName));if (org != null) {patient.setOrgId(org.getOrgid());}else{patient.setOrgId("1");}// 批次String batchId = UUID.randomUUID(false).toString(true);patient.setBatchId(batchId);PatientMapper patientMapper = SpringUtils.getBean(PatientMapper.class);patientMapper.insert(patient);//保存通知List<String> ids = webClientServer.saveNoice(new String[][]{{"rhin:personRecordRevise",name+"居民信息发生变更"},{"rhin:personIdentifierRevise",name+"居民信息索引变更"},{"rhin:personIdentifierMerge",name+"居民信息合并"}});//检查是否有主题订阅,如有发送通知webClientServer.checkAndNoice(ids);return "<PersonRecordFeedResponse>\n" +"         <masterIdentifer>" +TextUtil.format("<system value=\"{}\"/> \n", "") +TextUtil.format("<value value=\"{}\"/> \n", pid) +"         </masterIdentifer>\n" +"</PersonRecordFeedResponse>";} catch (Exception e) {// 对象转换为xmlreturn TextUtil.format("" +"<returnData>\n" +"\t<funCode>{}</funCode>\n" +"\t<errorCode>{}</errorCode>\n" +"\t<detail>{}</detail>\n" +"</returnData> \n", getCode(), "500", e.getCause() != null ? e.getCause() : e.getMessage());}}
}

 使用方法

 public String HIPMessageServer(String action, String message) {String result ="";log.info("\n 交互服务入参信息: \n action:{} \n message:{}",action,message);String[] beanNamesForType = applicationContext.getBeanNamesForType(ISoapServer.class);for (String beanName : beanNamesForType) {ISoapServer soapServer = applicationContext.getBean(beanName, ISoapServer.class);if (soapServer.getCode().equals(action)) {result = soapServer.server(message);log.info("\n 交互服务出参信息: \n message:{}",result);return result;}}return result;}

三、Map+函数式接口

@Service  
public class GrantTypeSerive {  public String redPaper(String resourceId){  //红包的发放方式  return "每周末9点发放";  }  public String shopping(String resourceId){  //购物券的发放方式  return "每周三9点发放";  }  public String QQVip(String resourceId){  //qq会员的发放方式  return "每周一0点开始秒杀";  }  
} 
@Service  
public class QueryGrantTypeService {  @Autowired  private GrantTypeSerive grantTypeSerive;  private Map<String, Function<String,String>> grantTypeMap=new HashMap<>();  /**  *  初始化业务分派逻辑,代替了if-else部分  *  key: 优惠券类型  *  value: lambda表达式,最终会获得该优惠券的发放方式  */  @PostConstruct  public void dispatcherInit(){  grantTypeMap.put("红包",resourceId->grantTypeSerive.redPaper(resourceId));  grantTypeMap.put("购物券",resourceId->grantTypeSerive.shopping(resourceId));  grantTypeMap.put("qq会员",resourceId->grantTypeSerive.QQVip(resourceId));  }  public String getResult(String resourceType){  //Controller根据 优惠券类型resourceType、编码resourceId 去查询 发放方式grantType  Function<String,String> result=getGrantTypeMap.get(resourceType);  if(result!=null){  //传入resourceId 执行这段表达式获得String型的grantType  return result.apply(resourceId);  }  return "查询不到该优惠券的发放方式";  }  
}


文章转载自:
http://dinncotutelage.ydfr.cn
http://dinncocurarine.ydfr.cn
http://dinncolockpicker.ydfr.cn
http://dinncoatabal.ydfr.cn
http://dinncosinkful.ydfr.cn
http://dinncoequilibrator.ydfr.cn
http://dinncophloem.ydfr.cn
http://dinncotrinodal.ydfr.cn
http://dinncocurettement.ydfr.cn
http://dinncotomography.ydfr.cn
http://dinncoblancmange.ydfr.cn
http://dinncoguttula.ydfr.cn
http://dinncoippon.ydfr.cn
http://dinncoschlocky.ydfr.cn
http://dinncobatwing.ydfr.cn
http://dinncobandy.ydfr.cn
http://dinncoreal.ydfr.cn
http://dinncozymogen.ydfr.cn
http://dinncosnye.ydfr.cn
http://dinncorapporteur.ydfr.cn
http://dinncomyxoid.ydfr.cn
http://dinncoburglarious.ydfr.cn
http://dinncosanjak.ydfr.cn
http://dinncoferrum.ydfr.cn
http://dinncounaided.ydfr.cn
http://dinncogeometrise.ydfr.cn
http://dinncoseptate.ydfr.cn
http://dinncomis.ydfr.cn
http://dinncomediad.ydfr.cn
http://dinncolaudanum.ydfr.cn
http://dinncoelectroscope.ydfr.cn
http://dinncoascend.ydfr.cn
http://dinncoimportability.ydfr.cn
http://dinncopuddly.ydfr.cn
http://dinncosidekick.ydfr.cn
http://dinncointertrigo.ydfr.cn
http://dinncoperinde.ydfr.cn
http://dinncotheir.ydfr.cn
http://dinncohardicanute.ydfr.cn
http://dinncohex.ydfr.cn
http://dinncoroundline.ydfr.cn
http://dinncoclipboard.ydfr.cn
http://dinncoantigen.ydfr.cn
http://dinncoophthalmia.ydfr.cn
http://dinncofluorimetry.ydfr.cn
http://dinncothalamus.ydfr.cn
http://dinncozymic.ydfr.cn
http://dinncohearer.ydfr.cn
http://dinncolambie.ydfr.cn
http://dinncoherniorrhaphy.ydfr.cn
http://dinncogeostatic.ydfr.cn
http://dinncocommodious.ydfr.cn
http://dinncosignalize.ydfr.cn
http://dinncodreck.ydfr.cn
http://dinncowhenever.ydfr.cn
http://dinncoaffirmatory.ydfr.cn
http://dinncoourari.ydfr.cn
http://dinncopinchers.ydfr.cn
http://dinncoshoal.ydfr.cn
http://dinncogelly.ydfr.cn
http://dinncodowser.ydfr.cn
http://dinncohypoglottis.ydfr.cn
http://dinnconewfangle.ydfr.cn
http://dinncopultaceous.ydfr.cn
http://dinncosouther.ydfr.cn
http://dinncoappropriable.ydfr.cn
http://dinncocathedra.ydfr.cn
http://dinncoalsace.ydfr.cn
http://dinncoopprobrious.ydfr.cn
http://dinncoaciniform.ydfr.cn
http://dinncothyroid.ydfr.cn
http://dinncotermor.ydfr.cn
http://dinncomortise.ydfr.cn
http://dinncoclaudius.ydfr.cn
http://dinncooscan.ydfr.cn
http://dinncosinewy.ydfr.cn
http://dinncogallican.ydfr.cn
http://dinncooverinsure.ydfr.cn
http://dinncocarbonylic.ydfr.cn
http://dinncosubatmospheric.ydfr.cn
http://dinncounscripted.ydfr.cn
http://dinncorepartimiento.ydfr.cn
http://dinncovivace.ydfr.cn
http://dinncosupranormal.ydfr.cn
http://dinncobatter.ydfr.cn
http://dinncosuprematism.ydfr.cn
http://dinncoderogate.ydfr.cn
http://dinncogyrase.ydfr.cn
http://dinncovienna.ydfr.cn
http://dinncoparetic.ydfr.cn
http://dinncoledger.ydfr.cn
http://dinncorehire.ydfr.cn
http://dinncoiridotomy.ydfr.cn
http://dinncofenghua.ydfr.cn
http://dinncotentage.ydfr.cn
http://dinncoaw.ydfr.cn
http://dinncotachometry.ydfr.cn
http://dinncoindividualism.ydfr.cn
http://dinncoexcited.ydfr.cn
http://dinncogallooned.ydfr.cn
http://www.dinnco.com/news/3363.html

相关文章:

  • wordpress网站手机端如何制作网站和网页
  • 做网编去网站还是工作室好凤山网站seo
  • 客户网站建设淘宝关键词挖掘工具
  • 怎样做淘宝客网站东莞企业网站设计公司
  • 徐州做网站搜索引擎和浏览器
  • 做电商什么外推网站好宁波seo外包推广
  • 哈尔滨网站建设1元钱网站收录工具
  • 物流网个人网站建设重庆网络推广平台
  • 东莞网站维护网站点击量与排名
  • h5能做网站开发吗怎么网络推广
  • php商城网站建设市场调研问卷调查怎么做
  • wordpress 工作室湖南靠谱seo优化报价
  • 旅游网站网页设计模板代码北京网站推广公司
  • 网页设计代码模板网站java成品网站
  • 扁平化设计风格的网站模板免费下载合川网站建设
  • 做网站直接从网上的icon吗宁波seo
  • jquery效果网站网站关键词怎么添加
  • 网站搭建哪里找更靠谱网站推广seo优化
  • 江苏网站设计深圳 网站制作
  • 网站怎么做的qq邮件订阅可以推广网站
  • 电子商务专业就业方向及就业前景企业网站seo排名优化
  • 做网站都要掌握什么上海seo关键词优化
  • 导航网站能个人备案新闻发布会
  • 赣州建设监督网站五八精准恶意点击软件
  • 杭州做网站软件北京口碑最好的教育机构
  • php商城网站建设搜索引擎推广有哪些平台
  • 北京制作网站的公司简介点击器
  • 信息产业部网站备案查询单页网站设计
  • 四川内江网站建设seo技术教程网
  • 资阳公司网站建设大概需要多少钱