• 026医疗项目-模块二:药品目录的导入导出-导入功能的Service的编写


    这个导入功能要实现的效果是:

     思路是:

    因为我们最后是在Action层中调用的HxlsRead工具,这个工具传入的就是我们要实现的上一篇文章说到的实现了HxlsOptRowsInterface接口的类。所以我们的Server层的类直接去继承HxlsOptRowsInterface接口。然后把这个Service传入到Action中HxlsRead工具中,的这篇文章说的就是Service 层:

    代码如下:

    package yycg.business.service.impl;
    
    import java.util.List;
    
    import org.springframework.beans.factory.annotation.Autowired;
    
    import yycg.business.dao.mapper.YpxxMapper;
    import yycg.business.pojo.po.Ypxx;
    import yycg.util.HxlsOptRowsInterface;
    import yycg.util.UUIDBuild;
    
    public class YpxxImportServiceImpl implements HxlsOptRowsInterface{
        @Autowired
        YpxxMapper ypxxMapper;
    
        @Override
        public String optRows(int sheetIndex, int curRow, List<String> rowlist)
                throws Exception {
            Ypxx ypxx=new Ypxx();
    //从list中的到数据然后封装入Ypxx对象中,再把这个对象插入到数据库中。        
    String mc=rowlist.get(0);//商品的名字
    String jx=rowlist.get(1);//剂型
    String gg=rowlist.get(2);//价格
    String zhxs=rowlist.get(3);//转换系数
    String zbjg=rowlist.get(4);//中标的价格
    String scqymc=rowlist.get(5);//生产企业的名字
    String spmc=rowlist.get(6);//商品的名称
    String jyzt=rowlist.get(7);//交易状态 
            ypxx.setId(UUIDBuild.getUUID());//设置主键id
            ypxx.setMc(mc);
            ypxx.setJx(jx);
            ypxx.setGg(gg);
            ypxx.setZhxs(zhxs);
            ypxx.setZbjg(Float.valueOf(zbjg));
            ypxx.setScqymc(scqymc);
            ypxx.setSpmc(spmc);
            ypxx.setSpmc(spmc);
            //对交易的状态进行检验,我们的交易状态需要是1或者不符合状态的就报错
            if(jyzt==null||!jyzt.equals(1)||!jyzt.equals(0))
            {
                return "交易状态有问题“请输入1:正常。2:暂停";
                
            }
            ypxx.setJyzt(jyzt);
            /*
             * 这里还缺少一个bm值得插入,我们使用数据库的触发器来实现这个功能。
             */
            //调用Mapper。把数据插入到数据库中。
            ypxxMapper.insert(ypxx);
            return "success";
        }
    
    }
  • 相关阅读:
    IM服务器架构实现
    TCP打洞技术
    Java的守护线程与非守护线程
    SQL中时间为空的处理小结
    tfs
    Silverlight技术总结
    PMS
    Silverlight的TabControl的selectionChanged事件中读取不到TextBox值的bug。
    hahahahahah
    APM文章
  • 原文地址:https://www.cnblogs.com/shenxiaoquan/p/6107558.html
Copyright © 2020-2023  润新知