码迷,mamicode.com
首页 > 其他好文 > 详细

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

时间:2016-11-28 00:38:05      阅读:154      评论:0      收藏:0      [点我收藏+]

标签:bean   code   list   .com   throws   dex   imp   equals   com   

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

技术分享

 

 思路是:

技术分享

因为我们最后是在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";
    }

}

 

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

标签:bean   code   list   .com   throws   dex   imp   equals   com   

原文地址:http://www.cnblogs.com/shenxiaoquan/p/6107558.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!