标签:
package com.sanqiu.yycg.business.action;
import java.util.ArrayList;
import java.util.List;
import javax.annotation.Resource;
import javax.servlet.http.HttpSession;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.validation.BindingResult;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import com.sanqiu.yycg.base.domain.Dictinfo;
import com.sanqiu.yycg.base.domain.Useryy;
import com.sanqiu.yycg.base.domain.vo.ActiveUser;
import com.sanqiu.yycg.base.domain.vo.PageQuery;
import com.sanqiu.yycg.base.process.context.Config;
import com.sanqiu.yycg.base.process.result.DataGridResultInfo;
import com.sanqiu.yycg.base.process.result.ExceptionResultInfo;
import com.sanqiu.yycg.base.process.result.ResultInfo;
import com.sanqiu.yycg.base.process.result.ResultUtil;
import com.sanqiu.yycg.base.process.result.SubmitResultInfo;
import com.sanqiu.yycg.base.service.SystemConfigService;
import com.sanqiu.yycg.base.service.UserService;
import com.sanqiu.yycg.business.dao.YycgdmxMapper;
import com.sanqiu.yycg.business.domain.Yycgdmx;
import com.sanqiu.yycg.business.domain.YycgdmxExample;
import com.sanqiu.yycg.business.domain.vo.GysypmlCustom;
import com.sanqiu.yycg.business.domain.vo.GysypmlQueryVo;
import com.sanqiu.yycg.business.domain.vo.YpxxCustom;
import com.sanqiu.yycg.business.domain.vo.YycgdCustom;
import com.sanqiu.yycg.business.domain.vo.YycgdQueryVo;
import com.sanqiu.yycg.business.domain.vo.YycgdmxCustom;
import com.sanqiu.yycg.business.service.CgdService;
import com.sanqiu.yycg.util.MyUtil;
/**
* @author 吴煌彬
@todo 采购单管理
* @projectname yycg-core
* 下午5:03:33 2016年5月31日
*/
@Controller
@RequestMapping("/cgd")
public class CgdAction {
@Resource
private UserService userService;
@Resource
private CgdService cgdService;
@Resource
private SystemConfigService systemConfigService;
/*
* 创建采购单页面
*/
@RequestMapping("/addcgd")
public String addcgd(HttpSession session,Model model) throws Exception{
ActiveUser activeUser = (ActiveUser) session.getAttribute(Config.ACTIVEUSER_KEY);
String sysmc = activeUser.getSysmc();
String yycgdmc = sysmc + MyUtil.getDate() + "采购单";//采购单名称生成
model.addAttribute("yycgdmc", yycgdmc);
String year = MyUtil.get_YYYY(MyUtil.getDate());
model.addAttribute("year", year);
return "/business/cgd/addcgd";
}
/*
* 创建采购单基本信息保存
*/
@RequestMapping("/addcgdsubmit")
public @ResponseBody SubmitResultInfo addcgdsubmit(HttpSession session ,String year, YycgdQueryVo yycgdQueryVo) throws Exception{
ActiveUser activeUser = (ActiveUser) session.getAttribute(Config.ACTIVEUSER_KEY);
String useryyid = activeUser.getSysid();
String yycgdid = null;//采购单id
yycgdid = cgdService.insertYycgd(useryyid, year, yycgdQueryVo.getYycgdCustom());
ResultInfo resultInfo = ResultUtil.createSuccess(Config.MESSAGE, 906, null);
//将yycgdid传送到jsp页面
resultInfo.getSysdata().put("yycgdid", yycgdid);
return ResultUtil.createSubmitResult(resultInfo);
}
/*
* 采购单信息修改页面
*/
@RequestMapping("/editcgd")
public String editcgd(String id,Model model) throws Exception{
List<Dictinfo> jyztlist = systemConfigService.findDictinfoByType("003");
model.addAttribute("jyztlist", jyztlist);
List<Dictinfo> cgztlist = systemConfigService.findDictinfoByType("011");
model.addAttribute("cgztlist",cgztlist);
List<Dictinfo> lblist = systemConfigService.findDictinfoByType("001");
model.addAttribute("lblist", lblist);
YycgdCustom yycgdCustom = cgdService.findYycgdById(id);
model.addAttribute("yycgd", yycgdCustom);
return "/business/cgd/editcgd";
}
/*
* 采购单修改信息提交
*/
@RequestMapping("/editcgdsubmit")
public @ResponseBody SubmitResultInfo editcgdsubmit(String id,YycgdQueryVo yycgdQueryVo) throws Exception{
cgdService.updateYycgd(id, yycgdQueryVo.getYycgdCustom());
return ResultUtil.createSubmitResult(ResultUtil.createSuccess(Config.MESSAGE, 906, null));
}
/*
* 采购单明细查询
*/
@RequestMapping("/queryYycgdmx_result")
public @ResponseBody DataGridResultInfo queryYycgdmx_result (String id,YycgdQueryVo yycgdQueryVo,int rows, int page) throws Exception{
DataGridResultInfo dataGridResultInfo = new DataGridResultInfo();
int total = cgdService.findYycgdmxCountByYycgdid(id, yycgdQueryVo);
PageQuery pageQuery = new PageQuery();
pageQuery.setPageParams(total, rows, page);
yycgdQueryVo.setPageQuery(pageQuery);
List<YycgdmxCustom> list = cgdService.findYycgdmxListByYycgdid(id, yycgdQueryVo);
dataGridResultInfo.setTotal(total);
dataGridResultInfo.setRows(list);
return dataGridResultInfo;
}
/*
* 采购药品添加查询页面
*/
@RequestMapping("/queryaddyycgdmx")
public String queryaddyycgdmx(Model model,String yycgdid) throws Exception{
//数据字典提取
List<Dictinfo> jyztlist = systemConfigService.findDictinfoByType("003");
model.addAttribute("jyztlist", jyztlist);
List<Dictinfo> controllist = systemConfigService.findDictinfoByType("011");
model.addAttribute("controllist",controllist);
List<Dictinfo> lblist = systemConfigService.findDictinfoByType("001");
model.addAttribute("lblist", lblist);
List<Dictinfo> zlcclist = systemConfigService.findDictinfoByType("004");
model.addAttribute("zlcclist", zlcclist);
//采购单id传到页面queryaddyycgdmx
model.addAttribute("yycgdid",yycgdid);
return "/business/cgd/queryaddyycgdmx";
}
/*
* 采购药品添加明细
*/
@RequestMapping("/queryaddyycgdmx_result")
public @ResponseBody DataGridResultInfo queryaddyycgdmx_result(HttpSession session,String yycgdid,YycgdQueryVo yycgdQueryVo,int page,int rows) throws Exception{
ActiveUser activeUser = (ActiveUser) session.getAttribute(Config.ACTIVEUSER_KEY);
String useryyid = activeUser.getSysid();
DataGridResultInfo dataGridResultInfo = new DataGridResultInfo();
int total = cgdService.findAddYycgdCount(useryyid, yycgdid, yycgdQueryVo);
PageQuery pageQuery = new PageQuery();
pageQuery.setPageParams(total, rows, page); //计算分页参数
yycgdQueryVo.setPageQuery(pageQuery);
List<YycgdmxCustom> list = cgdService.findAddYycgdList(useryyid, yycgdid, yycgdQueryVo);
dataGridResultInfo.setTotal(total); //总条数
dataGridResultInfo.setRows(list); //内容
return dataGridResultInfo;
}
/*
* 采购单药品添加提交
*/
@RequestMapping("/addyycgdmxsubmit")
public @ResponseBody SubmitResultInfo addyycgdmxsubmit(String yycgdid,YycgdQueryVo yycgdQueryVo,int [] indexs) throws Exception{
List<YycgdmxCustom> list = yycgdQueryVo.getYycgdmxCustoms();
int count = indexs.length; //页面勾选的总数
int count_success = 0;
int count_error = 0;
List<ResultInfo> msg_error = new ArrayList<ResultInfo>();
for(int i = 0; i< count ;i++){
ResultInfo resultInfo = null;
YycgdmxCustom yycgdmxCustom = list.get(indexs[i]);//获取选中的采购单明细
String ypxxid = yycgdmxCustom.getYpxxid();
String usergysid = yycgdmxCustom.getUsergysid();
try{
cgdService.insertYycgdmx(yycgdid, ypxxid, usergysid);
}catch(Exception e){
e.printStackTrace();
if(e instanceof ExceptionResultInfo){
resultInfo = ((ExceptionResultInfo) e).getResultInfo();
}else{
resultInfo = ResultUtil.createFail(Config.MESSAGE, 900,null);
}
}
if(resultInfo == null){
count_success++;
}else{
count_error++;
msg_error.add(resultInfo);//保存错误信息
}
}
if(count_error == 0){
return ResultUtil.createSubmitResult(ResultUtil.createSuccess(Config.MESSAGE,907,new Object[]{
count_success,count_error
}));
}
//错误执行信息提示
return ResultUtil.createSubmitResult(ResultUtil.createFail(Config.MESSAGE,907,new Object[]{
count_success,count_error
}),msg_error);
}
/*
* 采购单药品保存
*/
@RequestMapping("/savecgl")
public @ResponseBody SubmitResultInfo savecgl(String id,YycgdQueryVo yycgdQueryVo,int [] indexs) throws Exception{
List<YycgdmxCustom> list = yycgdQueryVo.getYycgdmxCustoms();
int count = indexs.length; //页面勾选的总数
int count_success = 0;
int count_error = 0;
List<ResultInfo> msg_error = new ArrayList<ResultInfo>();
for(int i = 0; i< count ;i++){
ResultInfo resultInfo = null;
YycgdmxCustom yycgdmxCustom = list.get(indexs[i]);//获取选中的采购单明细
String ypxxid = yycgdmxCustom.getYpxxid();
Integer cgl = yycgdmxCustom.getCgl();//采购量
try{
cgdService.updateYycgdmx(id, ypxxid, cgl);
}catch(Exception e){
e.printStackTrace();
if(e instanceof ExceptionResultInfo){
resultInfo = ((ExceptionResultInfo) e).getResultInfo();
}else{
resultInfo = ResultUtil.createFail(Config.MESSAGE, 900,null);
}
}
if(resultInfo == null){
count_success++;
}else{
count_error++;
msg_error.add(resultInfo);//保存错误信息
}
}
if(count_error == 0){
return ResultUtil.createSubmitResult(ResultUtil.createSuccess(Config.MESSAGE,907,new Object[]{
count_success,count_error
}));
}
//错误执行信息提示
return ResultUtil.createSubmitResult(ResultUtil.createFail(Config.MESSAGE,907,new Object[]{
count_success,count_error
}),msg_error);
}
/*
* 采购单药品删除提交
*/
@RequestMapping("/yycgdmxdelsubmit")
public @ResponseBody SubmitResultInfo yycgdmxdelsubmit(HttpSession sessions ,int [] indexs, YycgdQueryVo yycgdQueryVo,String id) throws Exception{
List<YycgdmxCustom> list = yycgdQueryVo.getYycgdmxCustoms();
int count = indexs.length; //页面勾选的总数
int count_success = 0;
int count_error = 0;
List<ResultInfo> msg_error = new ArrayList<ResultInfo>();
for(int i = 0; i< count ;i++){
ResultInfo resultInfo = null;
YycgdmxCustom yycgdmxCustom = list.get(indexs[i]);
String ypxxid = yycgdmxCustom.getYpxxid();
try{
cgdService.deleteYycgdmxByYycgdidAndYpxxid(ypxxid, id);
}catch(Exception e){
e.printStackTrace();
if(e instanceof ExceptionResultInfo){
resultInfo = ((ExceptionResultInfo) e).getResultInfo();
}else{
resultInfo = ResultUtil.createFail(Config.MESSAGE, 900,null);
}
}
if(resultInfo == null){
count_success++;
}else{
count_error++;
msg_error.add(resultInfo);//保存错误信息
}
}
if(count_error == 0){
return ResultUtil.createSubmitResult(ResultUtil.createSuccess(Config.MESSAGE,907,new Object[]{
count_success,count_error
}));
}
//错误执行信息提示
return ResultUtil.createSubmitResult(ResultUtil.createFail(Config.MESSAGE,907,new Object[]{
count_success,count_error
}),msg_error);
}
/*
* 采购单查询页面
*/
@RequestMapping("/querycgd")
public String yycgdlist(Model model) throws Exception{
List<Dictinfo> cgdztlist = systemConfigService.findDictinfoByType("010");
model.addAttribute("cgdztlist", cgdztlist);
model.addAttribute("year", MyUtil.get_YYYY(MyUtil.getDate()));
return "/business/cgd/queryYycgd";
}
/*
* 采购单查询
*/
@RequestMapping("/queryYycgd_result")
public @ResponseBody DataGridResultInfo yycgdlist_result (HttpSession session,String year,String id,YycgdQueryVo yycgdQueryVo,int rows, int page) throws Exception{
DataGridResultInfo dataGridResultInfo = new DataGridResultInfo();
ActiveUser activeUser = (ActiveUser) session.getAttribute(Config.ACTIVEUSER_KEY);
String useryyid = activeUser.getSysid();
int total = cgdService.findYycgdCount(year, useryyid, yycgdQueryVo);
PageQuery pageQuery = new PageQuery();
pageQuery.setPageParams(total, rows, page);
yycgdQueryVo.setPageQuery(pageQuery);
List<YycgdCustom> list = cgdService.findYycgdList(year, useryyid, yycgdQueryVo);
dataGridResultInfo.setTotal(total);
dataGridResultInfo.setRows(list);
return dataGridResultInfo;
}
@RequestMapping("/submitYycgd")
public @ResponseBody
SubmitResultInfo submitYycgd(String id) throws Exception {
cgdService.saveSubmitSatus(id);
return ResultUtil.createSubmitResult(ResultUtil.createSuccess(
Config.MESSAGE, 906, null));
}
// 采购单审核列表页面
@RequestMapping("/querycheckcgd")
public String checkyycgdlist(Model model) throws Exception {
// 药品类别
List<Dictinfo> cgdztlist = systemConfigService.findDictinfoByType("010");
model.addAttribute("cgdztlist", cgdztlist);
// 当前年份
model.addAttribute("year", MyUtil.get_YYYY(MyUtil.getDate()));
return "/business/cgd/checkyycgdlist";
}
@RequestMapping("/checkyycgdlist_result")
public @ResponseBody DataGridResultInfo checkyycgdlist_result(ActiveUser activeUser, String year,YycgdQueryVo yycgdQueryVo,int page, int rows) throws Exception {
// 监管单位id
String userjdid = activeUser.getSysid();// 单位id
// 列表的总数
int total = cgdService.findCheckYycgdCount(year, userjdid, yycgdQueryVo);
// 分页参数
PageQuery pageQuery = new PageQuery();
pageQuery.setPageParams(total, rows, page);
yycgdQueryVo.setPageQuery(pageQuery);// 设置分页参数
// 分页查询列表
List<YycgdCustom> list = cgdService.findCheckYycgdList(year, userjdid,
yycgdQueryVo);
DataGridResultInfo dataGridResultInfo = new DataGridResultInfo();
dataGridResultInfo.setTotal(total);
dataGridResultInfo.setRows(list);
return dataGridResultInfo;
}
// 采购单审核提交
@RequestMapping("/checkcgdsubmit")
public @ResponseBody SubmitResultInfo checkcgdsubmit(YycgdQueryVo yycgdQueryVo, int[] indexs) throws Exception {
// 页面提交的业务数据(多个),要处理的业务数据,页面中传入的参数
List<YycgdCustom> list = yycgdQueryVo.getYycgdCustoms();
// 处理数据的总数
int count = indexs.length;
// 处理成功的数量
int count_success = 0;
// 处理失败的数量
int count_error = 0;
// 处理失败的原因
List<ResultInfo> msgs_error = new ArrayList<ResultInfo>();
for (int i = 0; i < count; i++) {
ResultInfo resultInfo = null;
// 根据选中行的序号获取要处理的业务数据(单个)
YycgdCustom yycgdCustom = list.get(indexs[i]);
// 采购单id
String yycgdid = yycgdCustom.getId();
try {
cgdService.saveYycgdCheckStatus(yycgdid, yycgdCustom);
} catch (Exception e) {
e.printStackTrace();
// 进行异常解析
if (e instanceof ExceptionResultInfo) {
resultInfo = ((ExceptionResultInfo) e).getResultInfo();
} else {
// 构造未知错误异常
resultInfo = ResultUtil.createFail(Config.MESSAGE, 900,
null);
}
}
if (resultInfo == null) {
// 说明成功
count_success++;
} else {
count_error++;
// 记录失败原因
msgs_error.add(resultInfo);
}
}
// 提示用户成功数量、失败数量、失败原因
// 改成返回详细信息
return ResultUtil.createSubmitResult(
ResultUtil.createSuccess(Config.MESSAGE, 907, new Object[] {
count_success, count_error }), msgs_error);
}
// 采购单受理页面
@RequestMapping("/disposecgd")
public String disposeyycgd(Model model) throws Exception {
// 当前年份
model.addAttribute("year", MyUtil.get_YYYY(MyUtil.getDate()));
return "/business/cgd/disposeyycgd";
}
// 采购单受理列表结果集
@RequestMapping("/disposeyycgd_result")
public @ResponseBody DataGridResultInfo disposeyycgd_result(ActiveUser activeUser, String year,YycgdQueryVo yycgdQueryVo,int page, int rows) throws Exception {
// 供货商id
String usergysid = activeUser.getSysid();// 单位id
// 列表的总数
int total = cgdService.findDisposeYycgdCount(usergysid, year,
yycgdQueryVo);
// 分页参数
PageQuery pageQuery = new PageQuery();
pageQuery.setPageParams(total, rows, page);
yycgdQueryVo.setPageQuery(pageQuery);// 设置分页参数
// 分页查询列表
List<YycgdmxCustom> list = cgdService.findDisposeYycgdList(usergysid,
year, yycgdQueryVo);
DataGridResultInfo dataGridResultInfo = new DataGridResultInfo();
dataGridResultInfo.setTotal(total);
dataGridResultInfo.setRows(list);
return dataGridResultInfo;
}
// 采购单受理提交
@RequestMapping("/disposeyycgdsubmit")
public @ResponseBody SubmitResultInfo disposeyycgdsubmit(YycgdQueryVo yycgdQueryVo, int[] indexs ) throws Exception {
// 页面提交的业务数据(多个),要处理的业务数据,页面中传入的参数
List<YycgdmxCustom> list = yycgdQueryVo.getYycgdmxCustoms();
// 处理数据的总数
int count = indexs.length;
// 处理成功的数量
int count_success = 0;
// 处理失败的数量
int count_error = 0;
// 处理失败的原因
List<ResultInfo> msgs_error = new ArrayList<ResultInfo>();
for (int i = 0; i < count; i++) {
ResultInfo resultInfo = null;
// 根据选中行的序号获取要处理的业务数据(单个)
YycgdmxCustom yycgdmxCustom = list.get(indexs[i]);
// 采购单id
String yycgdid = yycgdmxCustom.getYycgdid();
// 药品id
String ypxxid = yycgdmxCustom.getYpxxid();
try {
cgdService.saveSendStatus(yycgdid, ypxxid);
} catch (Exception e) {
e.printStackTrace();
// 进行异常解析
if (e instanceof ExceptionResultInfo) {
resultInfo = ((ExceptionResultInfo) e).getResultInfo();
} else {
// 构造未知错误异常
resultInfo = ResultUtil.createFail(Config.MESSAGE, 900,
null);
}
}
if (resultInfo == null) {
// 说明成功
count_success++;
} else {
count_error++;
// 记录失败原因
msgs_error.add(resultInfo);
}
}
// 提示用户成功数量、失败数量、失败原因
// 改成返回详细信息
return ResultUtil.createSubmitResult(
ResultUtil.createSuccess(Config.MESSAGE, 907, new Object[] {
count_success, count_error }), msgs_error);
}
}
标签:
原文地址:http://www.cnblogs.com/mlsq2015/p/5578504.html