| | |
| | | import com.fgkj.mapper.impl.User_infMapper; |
| | | import com.fgkj.mapper.impl.User_task_paramMapper; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.jdbc.datasource.DataSourceTransactionManager; |
| | | import org.springframework.stereotype.Service; |
| | | import org.springframework.transaction.TransactionDefinition; |
| | | import org.springframework.transaction.TransactionStatus; |
| | | |
| | | import java.util.ArrayList; |
| | | import java.util.List; |
| | | |
| | | import javax.annotation.Resource; |
| | | @Service |
| | | public class User_task_paramService { |
| | | |
| | | @Autowired |
| | | @Resource |
| | | private User_task_paramMapper mapper; |
| | | @Autowired |
| | | @Resource |
| | | private User_infMapper userInfMapper; |
| | | @Autowired |
| | | DataSourceTransactionManager dataSourceTransactionManager; |
| | | @Autowired |
| | | TransactionDefinition transactionDefinition; |
| | | |
| | | //4.2作业参数(新增作业参数) |
| | | public ServiceModel add(Object obj) { |
| | | public ServiceModel add(User_task_param obj) { |
| | | ServiceModel model = new ServiceModel(); |
| | | Boolean bl=mapper.add(obj); |
| | | Boolean bl= null; |
| | | try { |
| | | bl = mapper.add(obj); |
| | | } catch (Exception e) { |
| | | e.printStackTrace(); |
| | | model.setMsg("添加失败!"); |
| | | return model; |
| | | } |
| | | if(bl){ |
| | | model.setCode(1); |
| | | model.setMsg("添加成功!"); |
| | |
| | | |
| | | } |
| | | //4.2作业参数(修改操作/重命名操作) |
| | | public ServiceModel update(Object obj) { |
| | | public ServiceModel update(User_task_param obj) { |
| | | ServiceModel model = new ServiceModel(); |
| | | Boolean bl=mapper.update(obj); |
| | | Boolean bl= null; |
| | | try { |
| | | bl = mapper.update(obj); |
| | | } catch (Exception e) { |
| | | e.printStackTrace(); |
| | | model.setMsg("修改失败!"); |
| | | return model; |
| | | } |
| | | if(bl){ |
| | | model.setCode(1); |
| | | model.setMsg("修改成功!"); |
| | |
| | | } |
| | | |
| | | //4.2作业参数(一次修改多个作业参数) |
| | | public ServiceModel updatePro(Object obj){ |
| | | public ServiceModel updatePro(List<User_task_param> list){ |
| | | TransactionStatus transactionStatus = dataSourceTransactionManager.getTransaction(transactionDefinition); |
| | | ServiceModel model = new ServiceModel(); |
| | | List<User_task_param> list=(List<User_task_param>) obj; |
| | | ArrayList<String> sql_str = new ArrayList<String>();//存放所有的sql语句 |
| | | if(list!=null && list.size()>0){ |
| | | for(int i=0;i<list.size();i++){ |
| | | sql_str.add(mapper.updatePro(list.get(i))); |
| | | } |
| | | } |
| | | //TODO perry待查 |
| | | boolean flag=true; |
| | | //boolean flag= DateUtil.makeManualCommit(DBUtil.getConn(), sql_str); |
| | | if(list!=null && list.size()>0){ |
| | | for(int i=0;i<list.size();i++){ |
| | | if (!(mapper.updatePro(list.get(i))>0)){ |
| | | flag=false; |
| | | } |
| | | } |
| | | } |
| | | if(flag){ |
| | | dataSourceTransactionManager.commit(transactionStatus); |
| | | model.setCode(1); |
| | | model.setMsg("修改成功"); |
| | | }else{ |
| | | dataSourceTransactionManager.rollback(transactionStatus); |
| | | model.setCode(0); |
| | | model.setMsg("修改失败"); |
| | | } |
| | |
| | | } |
| | | |
| | | //4.2作业参数(删除) |
| | | public ServiceModel delete(Object obj) { |
| | | public ServiceModel delete(User_task_param obj) { |
| | | ServiceModel model = new ServiceModel(); |
| | | Boolean bl=mapper.del(obj); |
| | | Boolean bl=mapper.del(obj)>0; |
| | | if(bl){ |
| | | model.setCode(1); |
| | | model.setMsg("删除成功!"); |
| | |
| | | return model; |
| | | } |
| | | //4.2根据参数id查基本参数和模板参数 |
| | | public ServiceModel serchByCondition(Object obj){ |
| | | public ServiceModel serchByCondition(User_task_param obj){ |
| | | ServiceModel model = new ServiceModel(); |
| | | User_inf uinf=new User_inf(); |
| | | List<User_task_param> list=mapper.serchByCondition(obj); |
| | | for (int i=0;i<list.size();i++) { |
| | | String uids=list.get(i).getTp_master_id(); |
| | | if (uids.length()<1) uids="0"; |
| | | int uid=Integer.parseInt(uids); |
| | | uinf.setUId(uid); |
| | | uinf.setuId(uid); |
| | | List<User_inf> listu=userInfMapper.serchUname(uinf); |
| | | if(listu.size()>0&&listu!=null){ |
| | | uids=listu.get(0).getUName(); |
| | | uids=listu.get(0).getuName(); |
| | | } |
| | | list.get(i).setTp_master_id(uids); |
| | | } |