LiTaohong 5 jaren geleden
bovenliggende
commit
3d5eeeeb1c

+ 0 - 209
svr/svr-internet-hospital-entrance/src/main/java/com/yihu/jw/entrance/controller/expressage/ExpressageEndpoint.java

@ -1,209 +0,0 @@
package com.yihu.jw.entrance.controller.expressage;
import com.yihu.jw.entity.hospital.prescription.WlyyExpressagePriceDO;
import com.yihu.jw.entity.hospital.prescription.WlyyPrescriptionExpressageDO;
import com.yihu.jw.hospital.prescription.dao.OutpatientDao;
import com.yihu.jw.hospital.prescription.service.PrescriptionExpressageService;
import com.yihu.jw.restmodel.web.Envelop;
import com.yihu.jw.restmodel.web.endpoint.EnvelopRestEndpoint;
import com.yihu.jw.rm.hospital.BaseHospitalRequestMapping;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.apache.commons.lang.StringUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.util.CollectionUtils;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import java.net.URLDecoder;
import java.util.List;
@RestController
@RequestMapping(value = BaseHospitalRequestMapping.Expressage.PREFIX)
@Api(value = "门诊处方快递物流管理器", description = "门诊处方快递物流管理器", tags = {"wlyy基础服务 - 门诊处方快递物流管理服务接口"})
public class ExpressageEndpoint extends EnvelopRestEndpoint {
    private static Logger logger = LoggerFactory.getLogger(ExpressageEndpoint.class);
    @Autowired
    private PrescriptionExpressageService sfexpressService;
    @Autowired
    private OutpatientDao outpatientDao;
    private String successxml = "<Response service='RoutePushService'><Head>OK</Head></Response>";
    private String failedxml = "<Response service='RoutePushService'><Head>ERR</Head><ERROR code='-1'>系统发生数据错误或运行时异常</ERROR></Response>";
    @RequestMapping(value="/routepushservice",method = RequestMethod.POST)
    @ApiOperation("接受顺丰推送过来的路由信息")
    public Envelop SFRoutePushService (
            @ApiParam(name="content", value="入参报文") @RequestParam(value = "content",required = true) String content){
        try {
            content = URLDecoder.decode(content,"utf-8");
            logger.info("顺丰路由信息推送,xml="+content);
            sfexpressService.SFRoutePushService(content);
            return success(successxml);
        }catch (Exception e){
            logger.error("接收顺丰路由信息推送失败,入参xml:"+content);
            //日志文件中记录异常信息
            //返回接口异常信息处理结果
            return failed(failedxml);
        }
    }
    @RequestMapping(value="/sfrouteserviceSearch",method = RequestMethod.GET)
    @ApiOperation("通过门诊编号查询顺丰物流派送记录")
    public Envelop SFRouteServiceSearch(@ApiParam(name="outpatientId", value="门诊编号") @RequestParam(value = "outpatientId",required = true) String outpatientId){
        try {
            List<WlyyPrescriptionExpressageDO> expressageDOList = sfexpressService.findByField("outpatientId",outpatientId);
            if(CollectionUtils.isEmpty(expressageDOList)){
                return failed("当前门诊没有物流信息!");
            }
            WlyyPrescriptionExpressageDO sfexpress_obj = expressageDOList.get(0);
            String result  = sfexpressService.getRoutInfosSearch(sfexpress_obj);
            return success(result);
        }catch (Exception e){
            //返回接口异常信息处理结果
            return failed( "查询失败,"+e.getMessage());
        }
    }
    @RequestMapping(value = "/getsfexpressprice", method = RequestMethod.GET)
    @ApiOperation("根据收寄地址获取快递费用")
    public Envelop SFExpressPrice(
//            @ApiParam(name = "j_city", value = "寄方地址(城市),默认为厦门", defaultValue = "厦门")
//            @RequestParam(value = "j_city", required = false) String j_city,
            @ApiParam(name = "d_province", value = "收方地址(省份)")
            @RequestParam(value = "d_province", required = false) String d_province,
            @ApiParam(name = "d_city", value = "收方地址(城市)")
            @RequestParam(value = "d_city", required = false) String d_city){
        try {
            WlyyExpressagePriceDO expreprice = sfexpressService.getSFExpressPrice(d_province,d_city);
            return success(expreprice);
        }catch (Exception e){
            //返回接口异常信息处理结果
            return failed("获取快递费用,"+e.getMessage());
        }
    }
    @RequestMapping(value = "/sforderfilterservice", method = RequestMethod.GET)
    @ApiOperation("查询派送地址是否属于顺丰的派送范围")
    public Envelop SFOrderFilterService(
            @ApiParam(name = "d_address", value = "派送地址", defaultValue = "福建省厦门市思明区软件园二期望海路55号")
            @RequestParam(value = "d_address", required = true) String d_address){
        try {
            boolean result = sfexpressService.getSFOrderFilterService(d_address);
            if(result){
                return success("地址可派送!");
            }else{
                return failed("地址不可派送!");
            }
        }catch (Exception e){
            return failed("异常:"+e.getMessage());
        }
    }
    @RequestMapping(value="/sforderservice",method = RequestMethod.POST)
    @ApiOperation("向顺丰快递下订单")
    public Envelop SFOrderService(
            @ApiParam(name="outpatientId", value="门诊编号") @RequestParam(value = "outpatientId",required = true) String outpatientId){
        try {
            List<WlyyPrescriptionExpressageDO> expressageDOList = sfexpressService.findByField("outpatientId",outpatientId);
            if(CollectionUtils.isEmpty(expressageDOList)){
                return failed("顺丰快递下单失败,未找到该处方的派送地址!");
            }else{
                WlyyPrescriptionExpressageDO sfexpress_obj = expressageDOList.get(0);
                //如果该处方的快递单号已生成,则说明已经下单成功,不需要重复下单,直接返回成功
                if(StringUtils.isNotBlank(sfexpress_obj.getMailno())){
                    return success("顺丰快递下单成功!");
                }else{
                    //如果该处方的快递单号未生成,则继续下单
                    //由于下单前已经判断过是否派送,这里不再重复判断----huangwenjie-2017.08.04
                    //先判断地址是否可派送boolean delivery = sfexpressService.getSFOrderFilterService(sfexpress_obj.getProvinceName()+sfexpress_obj.getCityName()+sfexpress_obj.getTownName()+sfexpress_obj.getAddress());
                    //根据业务订单号判断是否已经下单成功
                    boolean go_on = sfexpressService.sfOrderSearchService(sfexpress_obj);
                    //如果该业务订单号未下单成功过,则重新下单
                    if(go_on){
                        //请求顺丰接口下单,成功下单后,返回快递单号
                        sfexpress_obj = sfexpressService.postSFOrderService(sfexpress_obj);
                        //保存快递单号和增加处方物流记录为配送
                        sfexpressService.updatePrescriptionExpressage(sfexpress_obj);
                    }
                    return success("顺丰快递下单成功!");
                }
            }
        }catch (Exception e){
            //返回接口异常信息处理结果
            return failed(e.getMessage());
        }
    }
    @RequestMapping(value="/sfgetorderinfoservice",method = RequestMethod.GET)
    @ApiOperation("通过门诊编号查询顺丰快递单信息(不包含物流记录)")
    public Envelop SFGetOrderInfo(
            @ApiParam(name="outpatientId", value="门诊编号") @RequestParam(value = "outpatientId",required = true) String outpatientId){
        try {
            List<WlyyPrescriptionExpressageDO> expressageDOList = sfexpressService.findByField("outpaitentId",outpatientId);
            if(CollectionUtils.isEmpty(expressageDOList)){
                return failed( "查询失败,");
            }
            WlyyPrescriptionExpressageDO sfexpress_obj = expressageDOList.get(0);
            return success(sfexpress_obj);
        }catch (Exception e) {
            return failed("查询失败," + e.getMessage());
        }
    }
    @RequestMapping(value="/sfordersearchservice",method = RequestMethod.GET)
    @ApiOperation("通过门诊编号查询顺丰快递是否下单成功")
    public Envelop SFOrderSearchService(
            @ApiParam(name="outpatientId", value="门诊编号") @RequestParam(value = "outpatientId",required = true) String outpatientId){
        List<WlyyPrescriptionExpressageDO> expressageDOList = sfexpressService.findByField("outpaitentId",outpatientId);
        if(CollectionUtils.isEmpty(expressageDOList)){
            return failed( "查询失败,");
        }
        try {
            WlyyPrescriptionExpressageDO sfexpress_obj = expressageDOList.get(0);
            boolean go_on = sfexpressService.sfOrderSearchServiceJustSearch(sfexpress_obj);
            return success(go_on);
        }catch (Exception e) {
            return failed("查询失败," + e.getMessage());
        }
    }
    @RequestMapping(value="/sforderConfirm",method = RequestMethod.GET)
    @ApiOperation("通过快递单号取消快递")
    public Envelop sforderConfirm(
            @ApiParam(name="mailno", value="快递单号") @RequestParam(value = "mailno",required = true) String mailno){
        List<WlyyPrescriptionExpressageDO> expressageDOList = sfexpressService.findByField("mailno",mailno);
        if(CollectionUtils.isEmpty(expressageDOList)){
            return failed( "当前快递单号的门诊不存在,");
        }
        try {
            WlyyPrescriptionExpressageDO sfexpress_obj = expressageDOList.get(0);
            String result = sfexpressService.postOrderConfirmService(sfexpress_obj);
            return success(result);
        }catch (Exception e) {
            return failed("异常," + e.getMessage());
        }
    }
}

+ 0 - 109
svr/svr-internet-hospital-entrance/src/main/java/com/yihu/jw/entrance/controller/expressage/WlyyPatientExpressageAddrEndpoint.java

@ -1,109 +0,0 @@
package com.yihu.jw.entrance.controller.expressage;
import com.yihu.jw.entrance.service.WlyyPatientExpressageAddrService;
import com.yihu.jw.restmodel.hospital.prescription.WlyyPatientExpressageAddrVO;
import com.yihu.jw.restmodel.web.Envelop;
import com.yihu.jw.restmodel.web.ListEnvelop;
import com.yihu.jw.restmodel.web.ObjEnvelop;
import com.yihu.jw.restmodel.web.PageEnvelop;
import com.yihu.jw.restmodel.web.endpoint.EnvelopRestEndpoint;
import com.yihu.jw.rm.hospital.BaseHospitalRequestMapping;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import java.util.List;
import com.yihu.jw.entity.hospital.prescription.WlyyPatientExpressageAddrDO;
/**
 * 居民收获地址控制器
 *
 * @version <pre>
 * Author	Version		Date		Changes
 * Administrator 	1.0  		2019年06月12日 	Created
 *
 * </pre>
 * @since 1.
 */
@RestController
@RequestMapping(value = BaseHospitalRequestMapping.WlyyPatientExpressageAddr.PREFIX)
@Api(value = "居民收获地址管理", description = "居民收获地址管理服务接口", tags = {"wlyy基础服务 - 居民收获地址管理服务接口"})
public class WlyyPatientExpressageAddrEndpoint extends EnvelopRestEndpoint {
    @Autowired
    private WlyyPatientExpressageAddrService wlyyPatientExpressageAddrService;
    @PostMapping(value = BaseHospitalRequestMapping.WlyyPatientExpressageAddr.CREATE)
    @ApiOperation(value = "创建")
    public Envelop create(
            @ApiParam(name = "jsonData", value = "Json数据", required = true)
            @RequestParam String jsonData) throws Exception {
        StringBuilder log = new StringBuilder();
        WlyyPatientExpressageAddrDO addrDO = wlyyPatientExpressageAddrService.createAddr(jsonData, log);
        if (!StringUtils.isEmpty(log.toString())) {
            return failed(log.toString());
        }
        return success(addrDO);
    }
    @PostMapping(value = BaseHospitalRequestMapping.WlyyPatientExpressageAddr.DELETE)
    @ApiOperation(value = "删除")
    public Envelop delete(
            @ApiParam(name = "ids", value = "id串,中间用,分隔", required = true)
            @RequestParam(value = "ids") String ids) {
        wlyyPatientExpressageAddrService.delete(ids.split(","));
        return success("删除成功");
    }
    @PostMapping(value = BaseHospitalRequestMapping.WlyyPatientExpressageAddr.setDefault)
    @ApiOperation(value = "将地址设置为默认")
    public Envelop setAddrDefault(
            @ApiParam(name = "patient", value = "居民code", required = true) @RequestParam(value = "patient") String patient,
            @ApiParam(name = "addrId", value = "当前地址id", required = true) @RequestParam(value = "addrId") String addrId) {
        StringBuilder error = null;
        wlyyPatientExpressageAddrService.setAddrDefault(patient, addrId, error);
        if (null != error && !StringUtils.isEmpty(error.toString())) {
            return failed("设置默认地址失败:" + error.toString());
        }
        return success("设置默认地址成功");
    }
    @PostMapping(value = BaseHospitalRequestMapping.WlyyPatientExpressageAddr.hasDefault)
    @ApiOperation(value = "判断当前居民是否已经存在默认地址")
    public Envelop setAddrDefault(
            @ApiParam(name = "patient", value = "居民code", required = true) @RequestParam(value = "patient") String patient) {
        boolean result = wlyyPatientExpressageAddrService.hasDefault(patient);
        return success(result);
    }
    @PostMapping(value = BaseHospitalRequestMapping.WlyyPatientExpressageAddr.UPDATE)
    @ApiOperation(value = "更新")
    public ObjEnvelop<WlyyPatientExpressageAddrVO> update(
            @ApiParam(name = "jsonData", value = "Json数据", required = true)
            @RequestParam String jsonData) throws Exception {
        WlyyPatientExpressageAddrDO wlyyPatientExpressageAddr = toEntity(jsonData, WlyyPatientExpressageAddrDO.class);
        if (null == wlyyPatientExpressageAddr.getId()) {
            return failed("ID不能为空", ObjEnvelop.class);
        }
        wlyyPatientExpressageAddr = wlyyPatientExpressageAddrService.save(wlyyPatientExpressageAddr);
        return success(wlyyPatientExpressageAddr, WlyyPatientExpressageAddrVO.class);
    }
    @GetMapping(value = BaseHospitalRequestMapping.WlyyPatientExpressageAddr.LIST)
    @ApiOperation(value = "获取列表")
    public ListEnvelop<WlyyPatientExpressageAddrVO> list(
            @ApiParam(name = "fields", value = "返回的字段,为空返回全部字段")
            @RequestParam(value = "fields", required = false) String fields,
            @ApiParam(name = "filters", value = "过滤器,为空检索所有条件")
            @RequestParam(value = "filters", required = false) String filters,
            @ApiParam(name = "sorts", value = "排序,规则参见说明文档")
            @RequestParam(value = "sorts", required = false) String sorts) throws Exception {
        List<WlyyPatientExpressageAddrDO> wlyyPatientExpressageAddrs = wlyyPatientExpressageAddrService.search(fields, filters, sorts);
        return success(wlyyPatientExpressageAddrs, WlyyPatientExpressageAddrVO.class);
    }
}