code
stringlengths
1
2.01M
repo_name
stringlengths
3
62
path
stringlengths
1
267
language
stringclasses
231 values
license
stringclasses
13 values
size
int64
1
2.01M
package org.anddev.andengine.entity.particle.modifier; import java.util.ArrayList; import java.util.List; import org.anddev.andengine.entity.particle.Particle; /** * <p>An {@link ExpireModifier} that holds other {@link BaseSingleValueSpanModifier}s, overriding their * <code>toTime</code>s to match the <code>lifeTime</code> of the particle based on the value from the * ExpireModifier.</p> * * <p>(c) 2011 Nicolas Gramlich<br> * (c) 2011 Zynga Inc.</p> * * @author Scott Kennedy * @since 21:01:00 - 08.08.2011 */ public class ContainerExpireModifier extends ExpireModifier { // =========================================================== // Constants // =========================================================== // =========================================================== // Fields // =========================================================== private final List<BaseSingleValueSpanModifier> mModifiers = new ArrayList<BaseSingleValueSpanModifier>(); // =========================================================== // Constructors // =========================================================== public ContainerExpireModifier(final float pLifeTime) { super(pLifeTime); } public ContainerExpireModifier(final float pMinLifeTime, final float pMaxLifeTime) { super(pMinLifeTime, pMaxLifeTime); } // =========================================================== // Getter & Setter // =========================================================== // =========================================================== // Methods for/from SuperClass/Interfaces // =========================================================== @Override public void onUpdateParticle(final Particle pParticle) { // Apply all the contained modifiers for (final BaseSingleValueSpanModifier modifier : mModifiers) { modifier.onUpdateParticle(pParticle, pParticle.getDeathTime()); } } // =========================================================== // Methods // =========================================================== /** * <p>Adds the specified modifier to the contained modifier list.</p> * * <p>The <code>toTime</code> in the modifier will be ignored, and replaced with the actual * lifetime of the {@link Particle}.</p> * * @param pModifier The modifier to add */ public void addParticleModifier(final BaseSingleValueSpanModifier pModifier) { mModifiers.add(pModifier); } /** * <p>Removes the specified modifier from the contained modifier list.</p> * @param pModifier The modifier to remove * @return true if the list was modified by this operation, false otherwise. */ public boolean removeParticleModifier(final BaseSingleValueSpanModifier pModifier) { return mModifiers.remove(pModifier); } // =========================================================== // Inner and Anonymous Classes // =========================================================== }
zzy421-andengine
src/org/anddev/andengine/entity/particle/modifier/ContainerExpireModifier.java
Java
lgpl
3,043
package org.anddev.andengine.entity.particle.modifier; import org.anddev.andengine.entity.particle.Particle; import org.anddev.andengine.entity.particle.initializer.IParticleInitializer; /** * (c) 2010 Nicolas Gramlich * (c) 2011 Zynga Inc. * * @author Nicolas Gramlich * @since 20:06:05 - 14.03.2010 */ public interface IParticleModifier extends IParticleInitializer { // =========================================================== // Final Fields // =========================================================== // =========================================================== // Methods // =========================================================== public void onUpdateParticle(final Particle pParticle); }
zzy421-andengine
src/org/anddev/andengine/entity/particle/modifier/IParticleModifier.java
Java
lgpl
749
package org.anddev.andengine.entity.particle.modifier; import org.anddev.andengine.entity.particle.Particle; /** * (c) 2010 Nicolas Gramlich * (c) 2011 Zynga Inc. * * @author Nicolas Gramlich * @since 16:10:16 - 04.05.2010 */ public abstract class BaseSingleValueSpanModifier implements IParticleModifier { // =========================================================== // Constants // =========================================================== // =========================================================== // Fields // =========================================================== private final float mFromValue; private final float mToValue; private final float mFromTime; private final float mToTime; private final float mDuration; private final float mSpanValue; // =========================================================== // Constructors // =========================================================== public BaseSingleValueSpanModifier(final float pFromValue, final float pToValue, final float pFromTime, final float pToTime) { this.mFromValue = pFromValue; this.mToValue = pToValue; this.mFromTime = pFromTime; this.mToTime = pToTime; this.mSpanValue = this.mToValue - this.mFromValue; this.mDuration = this.mToTime - this.mFromTime; } // =========================================================== // Getter & Setter // =========================================================== // =========================================================== // Methods for/from SuperClass/Interfaces // =========================================================== protected abstract void onSetInitialValue(final Particle pParticle, final float pValue); protected abstract void onSetValue(final Particle pParticle, final float pValue); @Override public void onInitializeParticle(final Particle pParticle) { this.onSetInitialValue(pParticle, this.mFromValue); } @Override public void onUpdateParticle(final Particle pParticle) { final float lifeTime = pParticle.getLifeTime(); if(lifeTime > this.mFromTime && lifeTime < this.mToTime) { final float percent = (lifeTime - this.mFromTime) / this.mDuration; this.onSetValueInternal(pParticle, percent); } } public void onUpdateParticle(final Particle pParticle, final float overrideToTime) { final float lifeTime = pParticle.getLifeTime(); if (lifeTime > this.mFromTime) { final float percent = (lifeTime - this.mFromTime) / (overrideToTime - this.mFromTime); this.onSetValueInternal(pParticle, percent); } } protected void onSetValueInternal(final Particle pParticle, final float pPercent) { this.onSetValue(pParticle, this.calculateValue(pPercent)); } protected final float calculateValue(final float pPercent) { return this.mFromValue + this.mSpanValue * pPercent; } // =========================================================== // Methods // =========================================================== // =========================================================== // Inner and Anonymous Classes // =========================================================== }
zzy421-andengine
src/org/anddev/andengine/entity/particle/modifier/BaseSingleValueSpanModifier.java
Java
lgpl
3,229
package org.anddev.andengine.entity.particle.modifier; import org.anddev.andengine.engine.camera.Camera; import org.anddev.andengine.entity.particle.Particle; import org.anddev.andengine.entity.particle.modifier.OffCameraExpireModifier; /** * <p>Causes the particle to expire after it has entered and left the view of the camera.</p> * * <p>This allows you to create a particle off camera, move it on camera, and have it expire once it leaves the camera.</p> * * <p>(c) 2011 Nicolas Gramlich<br> * (c) 2011 Zynga Inc.</p> * * @author Scott Kennedy * @since 27:10:00 - 08.08.2011 */ public class OnAndOffCameraExpireModifier extends OffCameraExpireModifier { // =========================================================== // Constants // =========================================================== // =========================================================== // Fields // =========================================================== private boolean mHasBeenOnCamera = false; // =========================================================== // Constructors // =========================================================== public OnAndOffCameraExpireModifier(final Camera pCamera) { super(pCamera); } // =========================================================== // Getter & Setter // =========================================================== // =========================================================== // Methods for/from SuperClass/Interfaces // =========================================================== @Override public void onUpdateParticle(final Particle pParticle) { if(!this.mHasBeenOnCamera && getCamera().isRectangularShapeVisible(pParticle)) { mHasBeenOnCamera = true; } if(this.mHasBeenOnCamera) { super.onUpdateParticle(pParticle); } } // =========================================================== // Methods // =========================================================== // =========================================================== // Inner and Anonymous Classes // =========================================================== }
zzy421-andengine
src/org/anddev/andengine/entity/particle/modifier/OnAndOffCameraExpireModifier.java
Java
lgpl
2,251
package org.anddev.andengine.entity.particle.modifier; import org.anddev.andengine.engine.camera.Camera; import org.anddev.andengine.entity.particle.Particle; /** * (c) 2010 Nicolas Gramlich * (c) 2011 Zynga Inc. * * @author Nicolas Gramlich * @since 21:21:10 - 14.03.2010 */ public class OffCameraExpireModifier implements IParticleModifier { // =========================================================== // Constants // =========================================================== // =========================================================== // Fields // =========================================================== private final Camera mCamera; // =========================================================== // Constructors // =========================================================== public OffCameraExpireModifier(final Camera pCamera) { this.mCamera = pCamera; } // =========================================================== // Getter & Setter // =========================================================== public Camera getCamera() { return this.mCamera; } // =========================================================== // Methods for/from SuperClass/Interfaces // =========================================================== @Override public void onInitializeParticle(final Particle pParticle) { } @Override public void onUpdateParticle(final Particle pParticle) { if(!this.mCamera.isRectangularShapeVisible(pParticle)) { pParticle.setDead(true); } } // =========================================================== // Methods // =========================================================== // =========================================================== // Inner and Anonymous Classes // =========================================================== }
zzy421-andengine
src/org/anddev/andengine/entity/particle/modifier/OffCameraExpireModifier.java
Java
lgpl
1,888
package org.anddev.andengine.entity.particle.modifier; import org.anddev.andengine.entity.particle.Particle; /** * (c) 2010 Nicolas Gramlich * (c) 2011 Zynga Inc. * * @author Nicolas Gramlich * @since 15:19:46 - 29.06.2010 */ public abstract class BaseDoubleValueSpanModifier extends BaseSingleValueSpanModifier { // =========================================================== // Constants // =========================================================== // =========================================================== // Fields // =========================================================== private final float mFromValueB; private final float mToValueB; private final float mSpanValueB; // =========================================================== // Constructors // =========================================================== public BaseDoubleValueSpanModifier(final float pFromValueA, final float pToValueA, final float pFromValueB, final float pToValueB, final float pFromTime, final float pToTime) { super(pFromValueA, pToValueA, pFromTime, pToTime); this.mFromValueB = pFromValueB; this.mToValueB = pToValueB; this.mSpanValueB = this.mToValueB - this.mFromValueB; } // =========================================================== // Getter & Setter // =========================================================== // =========================================================== // Methods for/from SuperClass/Interfaces // =========================================================== @Override @Deprecated protected void onSetValue(final Particle pParticle, final float pValue) { } protected abstract void onSetInitialValues(final Particle pParticle, final float pValueA, final float pValueB); protected abstract void onSetValues(final Particle pParticle, final float pValueA, final float pValueB); @Override public void onSetInitialValue(final Particle pParticle, final float pValueA) { this.onSetInitialValues(pParticle, pValueA, this.mFromValueB); } @Override protected void onSetValueInternal(final Particle pParticle, final float pPercent) { this.onSetValues(pParticle, super.calculateValue(pPercent), this.calculateValueB(pPercent)); } // =========================================================== // Methods // =========================================================== protected final float calculateValueB(final float pPercent) { return this.mFromValueB + this.mSpanValueB * pPercent; } // =========================================================== // Inner and Anonymous Classes // =========================================================== }
zzy421-andengine
src/org/anddev/andengine/entity/particle/modifier/BaseDoubleValueSpanModifier.java
Java
lgpl
2,710
package org.anddev.andengine.entity.particle.modifier; import org.anddev.andengine.entity.particle.Particle; /** * (c) 2010 Nicolas Gramlich * (c) 2011 Zynga Inc. * * @author Nicolas Gramlich * @since 15:19:46 - 29.06.2010 */ public abstract class BaseTripleValueSpanModifier extends BaseDoubleValueSpanModifier { // =========================================================== // Constants // =========================================================== // =========================================================== // Fields // =========================================================== private final float mFromValueC; private final float mToValueC; private final float mSpanValueC; // =========================================================== // Constructors // =========================================================== public BaseTripleValueSpanModifier(final float pFromValueA, final float pToValueA, final float pFromValueB, final float pToValueB, final float pFromValueC, final float pToValueC, final float pFromTime, final float pToTime) { super(pFromValueA, pToValueA, pFromValueB, pToValueB, pFromTime, pToTime); this.mFromValueC = pFromValueC; this.mToValueC = pToValueC; this.mSpanValueC = this.mToValueC - this.mFromValueC; } // =========================================================== // Getter & Setter // =========================================================== // =========================================================== // Methods for/from SuperClass/Interfaces // =========================================================== protected abstract void onSetInitialValues(final Particle pParticle, final float pValueA, final float pValueB, final float pValueC); protected abstract void onSetValues(final Particle pParticle, final float pValueA, final float pValueB, final float pValueC); @Override @Deprecated protected void onSetValues(final Particle pParticle, final float pValueA, final float pValueB) { } @Override public void onSetInitialValues(final Particle pParticle, final float pValueA, final float pValueB) { this.onSetInitialValues(pParticle, pValueA, pValueB, this.mFromValueC); } @Override protected void onSetValueInternal(final Particle pParticle, final float pPercent) { this.onSetValues(pParticle, super.calculateValue(pPercent), super.calculateValueB(pPercent), this.calculateValueC(pPercent)); } // =========================================================== // Methods // =========================================================== private final float calculateValueC(final float pPercent) { return this.mFromValueC + this.mSpanValueC * pPercent; } // =========================================================== // Inner and Anonymous Classes // =========================================================== }
zzy421-andengine
src/org/anddev/andengine/entity/particle/modifier/BaseTripleValueSpanModifier.java
Java
lgpl
2,909
package org.anddev.andengine.entity.particle.modifier; import org.anddev.andengine.entity.particle.Particle; /** * (c) 2010 Nicolas Gramlich * (c) 2011 Zynga Inc. * * @author Nicolas Gramlich * @since 21:21:10 - 14.03.2010 */ public class AlphaModifier extends BaseSingleValueSpanModifier { // =========================================================== // Constants // =========================================================== // =========================================================== // Fields // =========================================================== // =========================================================== // Constructors // =========================================================== public AlphaModifier(final float pFromAlpha, final float pToAlpha, final float pFromTime, final float pToTime) { super(pFromAlpha, pToAlpha, pFromTime, pToTime); } // =========================================================== // Getter & Setter // =========================================================== // =========================================================== // Methods for/from SuperClass/Interfaces // =========================================================== @Override protected void onSetInitialValue(final Particle pParticle, final float pAlpha) { pParticle.setAlpha(pAlpha); } @Override protected void onSetValue(final Particle pParticle, final float pAlpha) { pParticle.setAlpha(pAlpha); } // =========================================================== // Methods // =========================================================== // =========================================================== // Inner and Anonymous Classes // =========================================================== }
zzy421-andengine
src/org/anddev/andengine/entity/particle/modifier/AlphaModifier.java
Java
lgpl
1,824
package org.anddev.andengine.entity.shape; import javax.microedition.khronos.opengles.GL10; import org.anddev.andengine.collision.RectangularShapeCollisionChecker; import org.anddev.andengine.engine.camera.Camera; import org.anddev.andengine.entity.primitive.Line; import org.anddev.andengine.opengl.vertex.VertexBuffer; /** * (c) 2010 Nicolas Gramlich * (c) 2011 Zynga Inc. * * @author Nicolas Gramlich * @since 11:37:50 - 04.04.2010 */ public abstract class RectangularShape extends Shape { // =========================================================== // Constants // =========================================================== // =========================================================== // Fields // =========================================================== protected float mBaseWidth; protected float mBaseHeight; protected float mWidth; protected float mHeight; protected final VertexBuffer mVertexBuffer; // =========================================================== // Constructors // =========================================================== public RectangularShape(final float pX, final float pY, final float pWidth, final float pHeight, final VertexBuffer pVertexBuffer) { super(pX, pY); this.mBaseWidth = pWidth; this.mBaseHeight = pHeight; this.mWidth = pWidth; this.mHeight = pHeight; this.mVertexBuffer = pVertexBuffer; this.mRotationCenterX = pWidth * 0.5f; this.mRotationCenterY = pHeight * 0.5f; this.mScaleCenterX = this.mRotationCenterX; this.mScaleCenterY = this.mRotationCenterY; } // =========================================================== // Getter & Setter // =========================================================== @Override public VertexBuffer getVertexBuffer() { return this.mVertexBuffer; } @Override public float getWidth() { return this.mWidth; } @Override public float getHeight() { return this.mHeight; } @Override public float getBaseWidth() { return this.mBaseWidth; } @Override public float getBaseHeight() { return this.mBaseHeight; } public void setWidth(final float pWidth) { this.mWidth = pWidth; this.updateVertexBuffer(); } public void setHeight(final float pHeight) { this.mHeight = pHeight; this.updateVertexBuffer(); } public void setSize(final float pWidth, final float pHeight) { this.mWidth = pWidth; this.mHeight = pHeight; this.updateVertexBuffer(); } // =========================================================== // Methods for/from SuperClass/Interfaces // =========================================================== public void setBaseSize() { if(this.mWidth != this.mBaseWidth || this.mHeight != this.mBaseHeight) { this.mWidth = this.mBaseWidth; this.mHeight = this.mBaseHeight; this.updateVertexBuffer(); } } @Override protected boolean isCulled(final Camera pCamera) { // TODO Advanced culling! final float x = this.mX; final float y = this.mY; return x > pCamera.getMaxX() || y > pCamera.getMaxY() || x + this.getWidth() < pCamera.getMinX() || y + this.getHeight() < pCamera.getMinY(); } @Override protected void drawVertices(final GL10 pGL, final Camera pCamera) { pGL.glDrawArrays(GL10.GL_TRIANGLE_STRIP, 0, 4); } @Override public void reset() { super.reset(); this.setBaseSize(); final float baseWidth = this.getBaseWidth(); final float baseHeight = this.getBaseHeight(); this.mRotationCenterX = baseWidth * 0.5f; this.mRotationCenterY = baseHeight * 0.5f; this.mScaleCenterX = this.mRotationCenterX; this.mScaleCenterY = this.mRotationCenterY; } @Override public boolean contains(final float pX, final float pY) { return RectangularShapeCollisionChecker.checkContains(this, pX, pY); } @Override public float[] getSceneCenterCoordinates() { return this.convertLocalToSceneCoordinates(this.mWidth * 0.5f, this.mHeight * 0.5f); } @Override public boolean collidesWith(final IShape pOtherShape) { if(pOtherShape instanceof RectangularShape) { final RectangularShape pOtherRectangularShape = (RectangularShape) pOtherShape; return RectangularShapeCollisionChecker.checkCollision(this, pOtherRectangularShape); } else if(pOtherShape instanceof Line) { final Line line = (Line) pOtherShape; return RectangularShapeCollisionChecker.checkCollision(this, line); } else { return false; } } // =========================================================== // Methods // =========================================================== // =========================================================== // Inner and Anonymous Classes // =========================================================== }
zzy421-andengine
src/org/anddev/andengine/entity/shape/RectangularShape.java
Java
lgpl
4,858
package org.anddev.andengine.entity.shape; import org.anddev.andengine.entity.IEntity; import org.anddev.andengine.entity.scene.Scene.ITouchArea; /** * (c) 2010 Nicolas Gramlich * (c) 2011 Zynga Inc. * * @author Nicolas Gramlich * @since 13:32:52 - 07.07.2010 */ public interface IShape extends IEntity, ITouchArea { // =========================================================== // Final Fields // =========================================================== // =========================================================== // Methods // =========================================================== public boolean isCullingEnabled(); public void setCullingEnabled(final boolean pCullingEnabled); public float getWidth(); public float getHeight(); public float getBaseWidth(); public float getBaseHeight(); public float getWidthScaled(); public float getHeightScaled(); // public boolean isVisible(final Camera pCamera); // TODO. Could be use for automated culling. public boolean collidesWith(final IShape pOtherShape); public void setBlendFunction(final int pSourceBlendFunction, final int pDestinationBlendFunction); }
zzy421-andengine
src/org/anddev/andengine/entity/shape/IShape.java
Java
lgpl
1,187
package org.anddev.andengine.entity.shape; import javax.microedition.khronos.opengles.GL10; import javax.microedition.khronos.opengles.GL11; import org.anddev.andengine.engine.camera.Camera; import org.anddev.andengine.entity.Entity; import org.anddev.andengine.input.touch.TouchEvent; import org.anddev.andengine.opengl.buffer.BufferObjectManager; import org.anddev.andengine.opengl.util.GLHelper; import org.anddev.andengine.opengl.vertex.VertexBuffer; /** * (c) 2010 Nicolas Gramlich * (c) 2011 Zynga Inc. * * @author Nicolas Gramlich * @since 11:51:27 - 13.03.2010 */ public abstract class Shape extends Entity implements IShape { // =========================================================== // Constants // =========================================================== public static final int BLENDFUNCTION_SOURCE_DEFAULT = GL10.GL_SRC_ALPHA; public static final int BLENDFUNCTION_DESTINATION_DEFAULT = GL10.GL_ONE_MINUS_SRC_ALPHA; public static final int BLENDFUNCTION_SOURCE_PREMULTIPLYALPHA_DEFAULT = GL10.GL_ONE; public static final int BLENDFUNCTION_DESTINATION_PREMULTIPLYALPHA_DEFAULT = GL10.GL_ONE_MINUS_SRC_ALPHA; // =========================================================== // Fields // =========================================================== protected int mSourceBlendFunction = BLENDFUNCTION_SOURCE_DEFAULT; protected int mDestinationBlendFunction = BLENDFUNCTION_DESTINATION_DEFAULT; private boolean mCullingEnabled = false; // =========================================================== // Constructors // =========================================================== public Shape(final float pX, final float pY) { super(pX, pY); } // =========================================================== // Getter & Setter // =========================================================== @Override public void setBlendFunction(final int pSourceBlendFunction, final int pDestinationBlendFunction) { this.mSourceBlendFunction = pSourceBlendFunction; this.mDestinationBlendFunction = pDestinationBlendFunction; } @Override public boolean isCullingEnabled() { return this.mCullingEnabled; } @Override public void setCullingEnabled(final boolean pCullingEnabled) { this.mCullingEnabled = pCullingEnabled; } @Override public float getWidthScaled() { return this.getWidth() * this.mScaleX; } @Override public float getHeightScaled() { return this.getHeight() * this.mScaleY; } public boolean isVertexBufferManaged() { return this.getVertexBuffer().isManaged(); } /** * @param pVertexBufferManaged when passing <code>true</code> this {@link Shape} will make its {@link VertexBuffer} unload itself from the active {@link BufferObjectManager}, when this {@link Shape} is finalized/garbage-collected. <b><u>WARNING:</u></b> When passing <code>false</code> one needs to take care of that by oneself! */ public void setVertexBufferManaged(final boolean pVertexBufferManaged) { this.getVertexBuffer().setManaged(pVertexBufferManaged); } // =========================================================== // Methods for/from SuperClass/Interfaces // =========================================================== protected abstract void onUpdateVertexBuffer(); protected abstract VertexBuffer getVertexBuffer(); protected abstract void drawVertices(final GL10 pGL, final Camera pCamera); @Override protected void doDraw(final GL10 pGL, final Camera pCamera) { this.onInitDraw(pGL); this.onApplyVertices(pGL); this.drawVertices(pGL, pCamera); } @Override public boolean onAreaTouched(final TouchEvent pSceneTouchEvent, final float pTouchAreaLocalX, final float pTouchAreaLocalY) { return false; } /** * Will only be performed if {@link Shape#isCullingEnabled()} is true. * @param pCamera * @return <code>true</code> when this object is visible by the {@link Camera}, <code>false</code> otherwise. */ protected abstract boolean isCulled(final Camera pCamera); @Override protected void onManagedDraw(final GL10 pGL, final Camera pCamera) { if(!this.mCullingEnabled || !this.isCulled(pCamera)) { super.onManagedDraw(pGL, pCamera); } } @Override public void reset() { super.reset(); this.mSourceBlendFunction = BLENDFUNCTION_SOURCE_DEFAULT; this.mDestinationBlendFunction = BLENDFUNCTION_DESTINATION_DEFAULT; } @Override protected void finalize() throws Throwable { super.finalize(); final VertexBuffer vertexBuffer = this.getVertexBuffer(); if(vertexBuffer.isManaged()) { vertexBuffer.unloadFromActiveBufferObjectManager(); } } // =========================================================== // Methods // =========================================================== protected void onInitDraw(final GL10 pGL) { GLHelper.setColor(pGL, this.mRed, this.mGreen, this.mBlue, this.mAlpha); GLHelper.enableVertexArray(pGL); GLHelper.blendFunction(pGL, this.mSourceBlendFunction, this.mDestinationBlendFunction); } protected void onApplyVertices(final GL10 pGL) { if(GLHelper.EXTENSIONS_VERTEXBUFFEROBJECTS) { final GL11 gl11 = (GL11)pGL; this.getVertexBuffer().selectOnHardware(gl11); GLHelper.vertexZeroPointer(gl11); } else { GLHelper.vertexPointer(pGL, this.getVertexBuffer().getFloatBuffer()); } } protected void updateVertexBuffer() { this.onUpdateVertexBuffer(); } // =========================================================== // Inner and Anonymous Classes // =========================================================== }
zzy421-andengine
src/org/anddev/andengine/entity/shape/Shape.java
Java
lgpl
5,684
package org.anddev.andengine.entity; import java.util.Comparator; import java.util.List; import org.anddev.andengine.util.sort.InsertionSorter; public class ZIndexSorter extends InsertionSorter<IEntity> { // =========================================================== // Constants // =========================================================== private static ZIndexSorter INSTANCE; // =========================================================== // Fields // =========================================================== private final Comparator<IEntity> mZIndexComparator = new Comparator<IEntity>() { @Override public int compare(final IEntity pEntityA, final IEntity pEntityB) { return pEntityA.getZIndex() - pEntityB.getZIndex(); } }; // =========================================================== // Constructors // =========================================================== private ZIndexSorter() { } public static ZIndexSorter getInstance() { if(INSTANCE == null) { INSTANCE = new ZIndexSorter(); } return INSTANCE; } // =========================================================== // Getter & Setter // =========================================================== // =========================================================== // Methods for/from SuperClass/Interfaces // =========================================================== // =========================================================== // Methods // =========================================================== public void sort(final IEntity[] pEntities) { this.sort(pEntities, this.mZIndexComparator); } public void sort(final IEntity[] pEntities, final int pStart, final int pEnd) { this.sort(pEntities, pStart, pEnd, this.mZIndexComparator); } public void sort(final List<IEntity> pEntities) { this.sort(pEntities, this.mZIndexComparator); } public void sort(final List<IEntity> pEntities, final int pStart, final int pEnd) { this.sort(pEntities, pStart, pEnd, this.mZIndexComparator); } // =========================================================== // Inner and Anonymous Classes // =========================================================== }
zzy421-andengine
src/org/anddev/andengine/entity/ZIndexSorter.java
Java
lgpl
2,262
package org.anddev.andengine.audio.sound; import org.anddev.andengine.audio.BaseAudioManager; import android.media.AudioManager; import android.media.SoundPool; /** * (c) 2010 Nicolas Gramlich * (c) 2011 Zynga Inc. * * @author Nicolas Gramlich * @since 13:22:59 - 11.03.2010 */ public class SoundManager extends BaseAudioManager<Sound> { // =========================================================== // Constants // =========================================================== private static final int MAX_SIMULTANEOUS_STREAMS_DEFAULT = 5; // =========================================================== // Fields // =========================================================== private final SoundPool mSoundPool; // =========================================================== // Constructors // =========================================================== public SoundManager() { this(MAX_SIMULTANEOUS_STREAMS_DEFAULT); } public SoundManager(final int pMaxSimultaneousStreams) { this.mSoundPool = new SoundPool(pMaxSimultaneousStreams, AudioManager.STREAM_MUSIC, 0); } // =========================================================== // Getter & Setter // =========================================================== SoundPool getSoundPool() { return this.mSoundPool; } // =========================================================== // Methods for/from SuperClass/Interfaces // =========================================================== // =========================================================== // Methods // =========================================================== @Override public void releaseAll() { super.releaseAll(); this.mSoundPool.release(); } // =========================================================== // Inner and Anonymous Classes // =========================================================== }
zzy421-andengine
src/org/anddev/andengine/audio/sound/SoundManager.java
Java
lgpl
1,947
package org.anddev.andengine.audio.sound; import org.anddev.andengine.audio.BaseAudioEntity; /** * (c) 2010 Nicolas Gramlich * (c) 2011 Zynga Inc. * * @author Nicolas Gramlich * @since 13:22:15 - 11.03.2010 */ public class Sound extends BaseAudioEntity { // =========================================================== // Constants // =========================================================== // =========================================================== // Fields // =========================================================== private final int mSoundID; private int mStreamID = 0; private int mLoopCount = 0; private float mRate = 1.0f; // =========================================================== // Constructors // =========================================================== Sound(final SoundManager pSoundManager, final int pSoundID) { super(pSoundManager); this.mSoundID = pSoundID; } // =========================================================== // Getter & Setter // =========================================================== public void setLoopCount(final int pLoopCount) { this.mLoopCount = pLoopCount; if(this.mStreamID != 0) { this.getAudioManager().getSoundPool().setLoop(this.mStreamID, pLoopCount); } } public void setRate(final float pRate) { this.mRate = pRate; if(this.mStreamID != 0) { this.getAudioManager().getSoundPool().setRate(this.mStreamID, pRate); } } // =========================================================== // Methods for/from SuperClass/Interfaces // =========================================================== // =========================================================== // Methods // =========================================================== @Override protected SoundManager getAudioManager() { return (SoundManager)super.getAudioManager(); } @Override public void play() { final float masterVolume = this.getMasterVolume(); final float leftVolume = this.mLeftVolume * masterVolume; final float rightVolume = this.mRightVolume * masterVolume; this.mStreamID = this.getAudioManager().getSoundPool().play(this.mSoundID, leftVolume, rightVolume, 1, this.mLoopCount, this.mRate); } @Override public void stop() { if(this.mStreamID != 0) { this.getAudioManager().getSoundPool().stop(this.mStreamID); } } @Override public void resume() { if(this.mStreamID != 0) { this.getAudioManager().getSoundPool().resume(this.mStreamID); } } @Override public void pause() { if(this.mStreamID != 0) { this.getAudioManager().getSoundPool().pause(this.mStreamID); } } @Override public void release() { } @Override public void setLooping(final boolean pLooping) { this.setLoopCount((pLooping) ? -1 : 0); } @Override public void setVolume(final float pLeftVolume, final float pRightVolume) { super.setVolume(pLeftVolume, pRightVolume); if(this.mStreamID != 0){ final float masterVolume = this.getMasterVolume(); final float leftVolume = this.mLeftVolume * masterVolume; final float rightVolume = this.mRightVolume * masterVolume; this.getAudioManager().getSoundPool().setVolume(this.mStreamID, leftVolume, rightVolume); } } @Override public void onMasterVolumeChanged(final float pMasterVolume) { this.setVolume(this.mLeftVolume, this.mRightVolume); } // =========================================================== // Inner and Anonymous Classes // =========================================================== }
zzy421-andengine
src/org/anddev/andengine/audio/sound/Sound.java
Java
lgpl
3,628
package org.anddev.andengine.audio.sound; import java.io.FileDescriptor; import java.io.IOException; import android.content.Context; /** * (c) 2010 Nicolas Gramlich * (c) 2011 Zynga Inc. * * @author Nicolas Gramlich * @since 14:23:03 - 11.03.2010 */ public class SoundFactory { // =========================================================== // Constants // =========================================================== // =========================================================== // Fields // =========================================================== private static String sAssetBasePath = ""; // =========================================================== // Constructors // =========================================================== // =========================================================== // Getter & Setter // =========================================================== /** * @param pAssetBasePath must end with '<code>/</code>' or have <code>.length() == 0</code>. */ public static void setAssetBasePath(final String pAssetBasePath) { if(pAssetBasePath.endsWith("/") || pAssetBasePath.length() == 0) { SoundFactory.sAssetBasePath = pAssetBasePath; } else { throw new IllegalStateException("pAssetBasePath must end with '/' or be lenght zero."); } } public static void reset() { SoundFactory.setAssetBasePath(""); } // =========================================================== // Methods for/from SuperClass/Interfaces // =========================================================== // =========================================================== // Methods // =========================================================== public static Sound createSoundFromPath(final SoundManager pSoundManager, final String pPath) throws IOException { final int soundID = pSoundManager.getSoundPool().load(pPath, 1); final Sound sound = new Sound(pSoundManager, soundID); pSoundManager.add(sound); return sound; } public static Sound createSoundFromAsset(final SoundManager pSoundManager, final Context pContext, final String pAssetPath) throws IOException { final int soundID = pSoundManager.getSoundPool().load(pContext.getAssets().openFd(SoundFactory.sAssetBasePath + pAssetPath), 1); final Sound sound = new Sound(pSoundManager, soundID); pSoundManager.add(sound); return sound; } public static Sound createSoundFromResource(final SoundManager pSoundManager, final Context pContext, final int pSoundResID) { final int soundID = pSoundManager.getSoundPool().load(pContext, pSoundResID, 1); final Sound sound = new Sound(pSoundManager, soundID); pSoundManager.add(sound); return sound; } public static Sound createSoundFromFileDescriptor(final SoundManager pSoundManager, final FileDescriptor pFileDescriptor, final long pOffset, final long pLength) throws IOException { final int soundID = pSoundManager.getSoundPool().load(pFileDescriptor, pOffset, pLength, 1); final Sound sound = new Sound(pSoundManager, soundID); pSoundManager.add(sound); return sound; } // =========================================================== // Inner and Anonymous Classes // =========================================================== }
zzy421-andengine
src/org/anddev/andengine/audio/sound/SoundFactory.java
Java
lgpl
3,316
package org.anddev.andengine.audio.sound; import org.anddev.andengine.util.Library; /** * (c) 2010 Nicolas Gramlich * (c) 2011 Zynga Inc. * * @author Nicolas Gramlich * @since 20:41:56 - 20.08.2010 */ public class SoundLibrary extends Library<Sound> { // =========================================================== // Constants // =========================================================== // =========================================================== // Fields // =========================================================== // =========================================================== // Constructors // =========================================================== // =========================================================== // Getter & Setter // =========================================================== // =========================================================== // Methods for/from SuperClass/Interfaces // =========================================================== // =========================================================== // Methods // =========================================================== // =========================================================== // Inner and Anonymous Classes // =========================================================== }
zzy421-andengine
src/org/anddev/andengine/audio/sound/SoundLibrary.java
Java
lgpl
1,355
package org.anddev.andengine.audio; /** * (c) 2010 Nicolas Gramlich * (c) 2011 Zynga Inc. * * @author Nicolas Gramlich * @since 16:35:37 - 13.06.2010 */ public abstract class BaseAudioEntity implements IAudioEntity { // =========================================================== // Constants // =========================================================== // =========================================================== // Fields // =========================================================== private final IAudioManager<? extends IAudioEntity> mAudioManager; protected float mLeftVolume = 1.0f; protected float mRightVolume = 1.0f; // =========================================================== // Constructors // =========================================================== public BaseAudioEntity(final IAudioManager<? extends IAudioEntity> pAudioManager) { this.mAudioManager = pAudioManager; } // =========================================================== // Getter & Setter // =========================================================== protected IAudioManager<? extends IAudioEntity> getAudioManager() { return this.mAudioManager; } public float getActualLeftVolume() { return this.mLeftVolume * this.getMasterVolume(); } public float getActualRightVolume() { return this.mRightVolume * this.getMasterVolume(); } protected float getMasterVolume() { return this.mAudioManager.getMasterVolume(); } // =========================================================== // Methods for/from SuperClass/Interfaces // =========================================================== @Override public float getVolume() { return (this.mLeftVolume + this.mRightVolume) * 0.5f; } @Override public float getLeftVolume() { return this.mLeftVolume; } @Override public float getRightVolume() { return this.mRightVolume; } @Override public final void setVolume(final float pVolume) { this.setVolume(pVolume, pVolume); } @Override public void setVolume(final float pLeftVolume, final float pRightVolume) { this.mLeftVolume = pLeftVolume; this.mRightVolume = pRightVolume; } // =========================================================== // Methods // =========================================================== // =========================================================== // Inner and Anonymous Classes // =========================================================== }
zzy421-andengine
src/org/anddev/andengine/audio/BaseAudioEntity.java
Java
lgpl
2,533
package org.anddev.andengine.audio.music; import java.io.File; import java.io.FileInputStream; import java.io.IOException; import android.content.Context; import android.content.res.AssetFileDescriptor; import android.media.MediaPlayer; /** * (c) 2010 Nicolas Gramlich * (c) 2011 Zynga Inc. * * @author Nicolas Gramlich * @since 15:05:49 - 13.06.2010 */ public class MusicFactory { // =========================================================== // Constants // =========================================================== // =========================================================== // Fields // =========================================================== private static String sAssetBasePath = ""; // =========================================================== // Constructors // =========================================================== // =========================================================== // Getter & Setter // =========================================================== /** * @param pAssetBasePath must end with '<code>/</code>' or have <code>.length() == 0</code>. */ public static void setAssetBasePath(final String pAssetBasePath) { if(pAssetBasePath.endsWith("/") || pAssetBasePath.length() == 0) { MusicFactory.sAssetBasePath = pAssetBasePath; } else { throw new IllegalStateException("pAssetBasePath must end with '/' or be lenght zero."); } } public static void reset() { MusicFactory.setAssetBasePath(""); } // =========================================================== // Methods for/from SuperClass/Interfaces // =========================================================== // =========================================================== // Methods // =========================================================== public static Music createMusicFromFile(final MusicManager pMusicManager, final File pFile) throws IOException { final MediaPlayer mediaPlayer = new MediaPlayer(); mediaPlayer.setDataSource(new FileInputStream(pFile).getFD()); mediaPlayer.prepare(); final Music music = new Music(pMusicManager, mediaPlayer); pMusicManager.add(music); return music; } public static Music createMusicFromAsset(final MusicManager pMusicManager, final Context pContext, final String pAssetPath) throws IOException { final MediaPlayer mediaPlayer = new MediaPlayer(); final AssetFileDescriptor assetFileDescritor = pContext.getAssets().openFd(MusicFactory.sAssetBasePath + pAssetPath); mediaPlayer.setDataSource(assetFileDescritor.getFileDescriptor(), assetFileDescritor.getStartOffset(), assetFileDescritor.getLength()); mediaPlayer.prepare(); final Music music = new Music(pMusicManager, mediaPlayer); pMusicManager.add(music); return music; } public static Music createMusicFromResource(final MusicManager pMusicManager, final Context pContext, final int pMusicResID) throws IOException { final MediaPlayer mediaPlayer = MediaPlayer.create(pContext, pMusicResID); mediaPlayer.prepare(); final Music music = new Music(pMusicManager, mediaPlayer); pMusicManager.add(music); return music; } // =========================================================== // Inner and Anonymous Classes // =========================================================== }
zzy421-andengine
src/org/anddev/andengine/audio/music/MusicFactory.java
Java
lgpl
3,383
package org.anddev.andengine.audio.music; import org.anddev.andengine.audio.BaseAudioManager; /** * (c) 2010 Nicolas Gramlich * (c) 2011 Zynga Inc. * * @author Nicolas Gramlich * @since 15:01:23 - 13.06.2010 */ public class MusicManager extends BaseAudioManager<Music> { // =========================================================== // Constants // =========================================================== // =========================================================== // Fields // =========================================================== // =========================================================== // Constructors // =========================================================== public MusicManager() { } // =========================================================== // Getter & Setter // =========================================================== // =========================================================== // Methods for/from SuperClass/Interfaces // =========================================================== // =========================================================== // Methods // =========================================================== // =========================================================== // Inner and Anonymous Classes // =========================================================== }
zzy421-andengine
src/org/anddev/andengine/audio/music/MusicManager.java
Java
lgpl
1,408
package org.anddev.andengine.audio.music; import org.anddev.andengine.audio.BaseAudioEntity; import android.media.MediaPlayer; import android.media.MediaPlayer.OnCompletionListener; /** * (c) 2010 Nicolas Gramlich * (c) 2011 Zynga Inc. * * @author Nicolas Gramlich * @since 14:53:12 - 13.06.2010 */ public class Music extends BaseAudioEntity { // =========================================================== // Constants // =========================================================== // =========================================================== // Fields // =========================================================== private final MediaPlayer mMediaPlayer; // =========================================================== // Constructors // =========================================================== Music(final MusicManager pMusicManager, final MediaPlayer pMediaPlayer) { super(pMusicManager); this.mMediaPlayer = pMediaPlayer; } // =========================================================== // Getter & Setter // =========================================================== public boolean isPlaying() { return this.mMediaPlayer.isPlaying(); } public MediaPlayer getMediaPlayer() { return this.mMediaPlayer; } // =========================================================== // Methods for/from SuperClass/Interfaces // =========================================================== @Override protected MusicManager getAudioManager() { return (MusicManager)super.getAudioManager(); } @Override public void play() { this.mMediaPlayer.start(); } @Override public void stop() { this.mMediaPlayer.stop(); } @Override public void resume() { this.mMediaPlayer.start(); } @Override public void pause() { this.mMediaPlayer.pause(); } @Override public void release() { this.mMediaPlayer.release(); } @Override public void setLooping(final boolean pLooping) { this.mMediaPlayer.setLooping(pLooping); } @Override public void setVolume(final float pLeftVolume, final float pRightVolume) { super.setVolume(pLeftVolume, pRightVolume); final float masterVolume = this.getAudioManager().getMasterVolume(); final float actualLeftVolume = pLeftVolume * masterVolume; final float actualRightVolume = pRightVolume * masterVolume; this.mMediaPlayer.setVolume(actualLeftVolume, actualRightVolume); } @Override public void onMasterVolumeChanged(final float pMasterVolume) { this.setVolume(this.mLeftVolume, this.mRightVolume); } // =========================================================== // Methods // =========================================================== public void seekTo(final int pMilliseconds) { this.mMediaPlayer.seekTo(pMilliseconds); } public void setOnCompletionListener(final OnCompletionListener pOnCompletionListener) { this.mMediaPlayer.setOnCompletionListener(pOnCompletionListener); } // =========================================================== // Inner and Anonymous Classes // =========================================================== }
zzy421-andengine
src/org/anddev/andengine/audio/music/Music.java
Java
lgpl
3,193
package org.anddev.andengine.audio; /** * (c) 2010 Nicolas Gramlich * (c) 2011 Zynga Inc. * * @author Nicolas Gramlich * @since 15:02:06 - 13.06.2010 */ public interface IAudioManager<T extends IAudioEntity> { // =========================================================== // Final Fields // =========================================================== // =========================================================== // Methods // =========================================================== public float getMasterVolume(); public void setMasterVolume(final float pMasterVolume); public void add(final T pAudioEntity); public void releaseAll(); }
zzy421-andengine
src/org/anddev/andengine/audio/IAudioManager.java
Java
lgpl
692
package org.anddev.andengine.audio; import java.util.ArrayList; /** * (c) 2010 Nicolas Gramlich * (c) 2011 Zynga Inc. * * @author Nicolas Gramlich * @since 18:07:02 - 13.06.2010 */ public abstract class BaseAudioManager<T extends IAudioEntity> implements IAudioManager<T> { // =========================================================== // Constants // =========================================================== // =========================================================== // Fields // =========================================================== protected final ArrayList<T> mAudioEntities = new ArrayList<T>(); protected float mMasterVolume = 1.0f; // =========================================================== // Constructors // =========================================================== // =========================================================== // Getter & Setter // =========================================================== // =========================================================== // Methods for/from SuperClass/Interfaces // =========================================================== @Override public float getMasterVolume() { return this.mMasterVolume; } @Override public void setMasterVolume(final float pMasterVolume) { this.mMasterVolume = pMasterVolume; final ArrayList<T> audioEntities = this.mAudioEntities; for(int i = audioEntities.size() - 1; i >= 0; i--) { final T audioEntity = audioEntities.get(i); audioEntity.onMasterVolumeChanged(pMasterVolume); } } @Override public void add(final T pAudioEntity) { this.mAudioEntities.add(pAudioEntity); } @Override public void releaseAll() { final ArrayList<T> audioEntities = this.mAudioEntities; for(int i = audioEntities.size() - 1; i >= 0; i--) { final T audioEntity = audioEntities.get(i); audioEntity.stop(); audioEntity.release(); } } // =========================================================== // Methods // =========================================================== // =========================================================== // Inner and Anonymous Classes // =========================================================== }
zzy421-andengine
src/org/anddev/andengine/audio/BaseAudioManager.java
Java
lgpl
2,284
package org.anddev.andengine.audio; /** * (c) 2010 Nicolas Gramlich * (c) 2011 Zynga Inc. * * @author Nicolas Gramlich * @since 14:53:29 - 13.06.2010 */ public interface IAudioEntity { // =========================================================== // Final Fields // =========================================================== // =========================================================== // Methods // =========================================================== public void play(); public void pause(); public void resume(); public void stop(); public float getVolume(); public void setVolume(final float pVolume); public float getLeftVolume(); public float getRightVolume(); public void setVolume(final float pLeftVolume, final float pRightVolume); public void onMasterVolumeChanged(final float pMasterVolume); public void setLooping(final boolean pLooping); public void release(); }
zzy421-andengine
src/org/anddev/andengine/audio/IAudioEntity.java
Java
lgpl
957
package org.anddev.andengine.ui.activity; import org.anddev.andengine.audio.music.MusicManager; import org.anddev.andengine.audio.sound.SoundManager; import org.anddev.andengine.engine.Engine; import org.anddev.andengine.engine.options.EngineOptions; import org.anddev.andengine.engine.options.WakeLockOptions; import org.anddev.andengine.entity.scene.Scene; import org.anddev.andengine.opengl.font.FontManager; import org.anddev.andengine.opengl.texture.TextureManager; import org.anddev.andengine.opengl.view.RenderSurfaceView; import org.anddev.andengine.sensor.accelerometer.AccelerometerSensorOptions; import org.anddev.andengine.sensor.accelerometer.IAccelerometerListener; import org.anddev.andengine.sensor.location.ILocationListener; import org.anddev.andengine.sensor.location.LocationSensorOptions; import org.anddev.andengine.sensor.orientation.IOrientationListener; import org.anddev.andengine.sensor.orientation.OrientationSensorOptions; import org.anddev.andengine.ui.IGameInterface; import org.anddev.andengine.util.ActivityUtils; import org.anddev.andengine.util.Debug; import android.content.Context; import android.content.pm.ActivityInfo; import android.media.AudioManager; import android.os.Bundle; import android.os.PowerManager; import android.os.PowerManager.WakeLock; import android.view.Gravity; import android.widget.FrameLayout.LayoutParams; /** * (c) 2010 Nicolas Gramlich * (c) 2011 Zynga Inc. * * @author Nicolas Gramlich * @since 11:27:06 - 08.03.2010 */ public abstract class BaseGameActivity extends BaseActivity implements IGameInterface { // =========================================================== // Constants // =========================================================== // =========================================================== // Fields // =========================================================== protected Engine mEngine; private WakeLock mWakeLock; protected RenderSurfaceView mRenderSurfaceView; protected boolean mHasWindowFocused; private boolean mPaused; private boolean mGameLoaded; // =========================================================== // Constructors // =========================================================== @Override protected void onCreate(final Bundle pSavedInstanceState) { super.onCreate(pSavedInstanceState); this.mPaused = true; this.mEngine = this.onLoadEngine(); this.applyEngineOptions(this.mEngine.getEngineOptions()); this.onSetContentView(); } @Override protected void onResume() { super.onResume(); if(this.mPaused && this.mHasWindowFocused) { this.doResume(); } } @Override public void onWindowFocusChanged(final boolean pHasWindowFocus) { super.onWindowFocusChanged(pHasWindowFocus); if(pHasWindowFocus) { if(this.mPaused) { this.doResume(); } this.mHasWindowFocused = true; } else { if(!this.mPaused) { this.doPause(); } this.mHasWindowFocused = false; } } @Override protected void onPause() { super.onPause(); if(!this.mPaused) { this.doPause(); } } @Override protected void onDestroy() { super.onDestroy(); this.mEngine.interruptUpdateThread(); this.onUnloadResources(); } @Override public void onUnloadResources() { if(this.mEngine.getEngineOptions().needsMusic()) { this.getMusicManager().releaseAll(); } if(this.mEngine.getEngineOptions().needsSound()) { this.getSoundManager().releaseAll(); } } // =========================================================== // Getter & Setter // =========================================================== public Engine getEngine() { return this.mEngine; } public TextureManager getTextureManager() { return this.mEngine.getTextureManager(); } public FontManager getFontManager() { return this.getFontManager(); } public SoundManager getSoundManager() { return this.mEngine.getSoundManager(); } public MusicManager getMusicManager() { return this.mEngine.getMusicManager(); } // =========================================================== // Methods for/from SuperClass/Interfaces // =========================================================== @Override public void onResumeGame() { } @Override public void onPauseGame() { } // =========================================================== // Methods // =========================================================== private void doResume() { if(!this.mGameLoaded) { this.onLoadResources(); final Scene scene = this.onLoadScene(); this.mEngine.onLoadComplete(scene); this.onLoadComplete(); this.mGameLoaded = true; } this.mPaused = false; this.acquireWakeLock(this.mEngine.getEngineOptions().getWakeLockOptions()); this.mEngine.onResume(); this.mRenderSurfaceView.onResume(); this.mEngine.start(); this.onResumeGame(); } private void doPause() { this.mPaused = true; this.releaseWakeLock(); this.mEngine.onPause(); this.mEngine.stop(); this.mRenderSurfaceView.onPause(); this.onPauseGame(); } public void runOnUpdateThread(final Runnable pRunnable) { this.mEngine.runOnUpdateThread(pRunnable); } protected void onSetContentView() { this.mRenderSurfaceView = new RenderSurfaceView(this); this.mRenderSurfaceView.setEGLConfigChooser(false); this.mRenderSurfaceView.setRenderer(this.mEngine); this.setContentView(this.mRenderSurfaceView, this.createSurfaceViewLayoutParams()); } private void acquireWakeLock(final WakeLockOptions pWakeLockOptions) { if(pWakeLockOptions == WakeLockOptions.SCREEN_ON) { ActivityUtils.keepScreenOn(this); } else { final PowerManager pm = (PowerManager) this.getSystemService(Context.POWER_SERVICE); this.mWakeLock = pm.newWakeLock(pWakeLockOptions.getFlag() | PowerManager.ON_AFTER_RELEASE, "AndEngine"); try { this.mWakeLock.acquire(); } catch (final SecurityException e) { Debug.e("You have to add\n\t<uses-permission android:name=\"android.permission.WAKE_LOCK\"/>\nto your AndroidManifest.xml !", e); } } } private void releaseWakeLock() { if(this.mWakeLock != null && this.mWakeLock.isHeld()) { this.mWakeLock.release(); } } private void applyEngineOptions(final EngineOptions pEngineOptions) { if(pEngineOptions.isFullscreen()) { ActivityUtils.requestFullscreen(this); } if(pEngineOptions.needsMusic() || pEngineOptions.needsSound()) { this.setVolumeControlStream(AudioManager.STREAM_MUSIC); } switch(pEngineOptions.getScreenOrientation()) { case LANDSCAPE: this.setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE); break; case PORTRAIT: this.setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT); break; } } protected LayoutParams createSurfaceViewLayoutParams() { final LayoutParams layoutParams = new LayoutParams(LayoutParams.FILL_PARENT, LayoutParams.FILL_PARENT); layoutParams.gravity = Gravity.CENTER; return layoutParams; } protected void enableVibrator() { this.mEngine.enableVibrator(this); } /** * @see {@link Engine#enableLocationSensor(Context, ILocationListener, LocationSensorOptions)} */ protected void enableLocationSensor(final ILocationListener pLocationListener, final LocationSensorOptions pLocationSensorOptions) { this.mEngine.enableLocationSensor(this, pLocationListener, pLocationSensorOptions); } /** * @see {@link Engine#disableLocationSensor(Context)} */ protected void disableLocationSensor() { this.mEngine.disableLocationSensor(this); } /** * @see {@link Engine#enableAccelerometerSensor(Context, IAccelerometerListener)} */ protected boolean enableAccelerometerSensor(final IAccelerometerListener pAccelerometerListener) { return this.mEngine.enableAccelerometerSensor(this, pAccelerometerListener); } /** * @see {@link Engine#enableAccelerometerSensor(Context, IAccelerometerListener, AccelerometerSensorOptions)} */ protected boolean enableAccelerometerSensor(final IAccelerometerListener pAccelerometerListener, final AccelerometerSensorOptions pAccelerometerSensorOptions) { return this.mEngine.enableAccelerometerSensor(this, pAccelerometerListener, pAccelerometerSensorOptions); } /** * @see {@link Engine#disableAccelerometerSensor(Context)} */ protected boolean disableAccelerometerSensor() { return this.mEngine.disableAccelerometerSensor(this); } /** * @see {@link Engine#enableOrientationSensor(Context, IOrientationListener)} */ protected boolean enableOrientationSensor(final IOrientationListener pOrientationListener) { return this.mEngine.enableOrientationSensor(this, pOrientationListener); } /** * @see {@link Engine#enableOrientationSensor(Context, IOrientationListener, OrientationSensorOptions)} */ protected boolean enableOrientationSensor(final IOrientationListener pOrientationListener, final OrientationSensorOptions pLocationSensorOptions) { return this.mEngine.enableOrientationSensor(this, pOrientationListener, pLocationSensorOptions); } /** * @see {@link Engine#disableOrientationSensor(Context)} */ protected boolean disableOrientationSensor() { return this.mEngine.disableOrientationSensor(this); } // =========================================================== // Inner and Anonymous Classes // =========================================================== }
zzy421-andengine
src/org/anddev/andengine/ui/activity/BaseGameActivity.java
Java
lgpl
9,621
package org.anddev.andengine.ui.activity; import org.anddev.andengine.opengl.view.RenderSurfaceView; /** * (c) 2010 Nicolas Gramlich * (c) 2011 Zynga Inc. * * @author Nicolas Gramlich * @since 10:18:50 - 06.10.2010 */ public abstract class LayoutGameActivity extends BaseGameActivity { // =========================================================== // Constants // =========================================================== // =========================================================== // Fields // =========================================================== // =========================================================== // Constructors // =========================================================== // =========================================================== // Getter & Setter // =========================================================== // =========================================================== // Methods for/from SuperClass/Interfaces // =========================================================== protected abstract int getLayoutID(); protected abstract int getRenderSurfaceViewID(); @Override protected void onSetContentView() { super.setContentView(this.getLayoutID()); this.mRenderSurfaceView = (RenderSurfaceView) this.findViewById(this.getRenderSurfaceViewID()); this.mRenderSurfaceView.setEGLConfigChooser(false); this.mRenderSurfaceView.setRenderer(this.mEngine); } // =========================================================== // Methods // =========================================================== // =========================================================== // Inner and Anonymous Classes // =========================================================== }
zzy421-andengine
src/org/anddev/andengine/ui/activity/LayoutGameActivity.java
Java
lgpl
1,795
package org.anddev.andengine.ui.activity; import java.util.concurrent.Callable; import org.anddev.andengine.util.ActivityUtils; import org.anddev.andengine.util.AsyncCallable; import org.anddev.andengine.util.Callback; import org.anddev.andengine.util.progress.ProgressCallable; import android.app.Activity; import android.app.ProgressDialog; /** * (c) 2010 Nicolas Gramlich * (c) 2011 Zynga Inc. * * @author Nicolas Gramlich * @since 18:35:28 - 29.08.2009 */ public abstract class BaseActivity extends Activity { // =========================================================== // Constants // =========================================================== // =========================================================== // Fields // =========================================================== // =========================================================== // Constructors // =========================================================== // =========================================================== // Getter & Setter // =========================================================== // =========================================================== // Methods for/from SuperClass/Interfaces // =========================================================== // =========================================================== // Methods // =========================================================== /** * Performs a task in the background, showing a {@link ProgressDialog}, * while the {@link Callable} is being processed. * * @param <T> * @param pTitleResID * @param pMessageResID * @param pErrorMessageResID * @param pCallable * @param pCallback */ protected <T> void doAsync(final int pTitleResID, final int pMessageResID, final Callable<T> pCallable, final Callback<T> pCallback) { this.doAsync(pTitleResID, pMessageResID, pCallable, pCallback, null); } /** * Performs a task in the background, showing a indeterminate {@link ProgressDialog}, * while the {@link Callable} is being processed. * * @param <T> * @param pTitleResID * @param pMessageResID * @param pErrorMessageResID * @param pCallable * @param pCallback * @param pExceptionCallback */ protected <T> void doAsync(final int pTitleResID, final int pMessageResID, final Callable<T> pCallable, final Callback<T> pCallback, final Callback<Exception> pExceptionCallback) { ActivityUtils.doAsync(this, pTitleResID, pMessageResID, pCallable, pCallback, pExceptionCallback); } /** * Performs a task in the background, showing a {@link ProgressDialog} with an ProgressBar, * while the {@link AsyncCallable} is being processed. * * @param <T> * @param pTitleResID * @param pMessageResID * @param pErrorMessageResID * @param pAsyncCallable * @param pCallback */ protected <T> void doProgressAsync(final int pTitleResID, final ProgressCallable<T> pCallable, final Callback<T> pCallback) { this.doProgressAsync(pTitleResID, pCallable, pCallback, null); } /** * Performs a task in the background, showing a {@link ProgressDialog} with a ProgressBar, * while the {@link AsyncCallable} is being processed. * * @param <T> * @param pTitleResID * @param pMessageResID * @param pErrorMessageResID * @param pAsyncCallable * @param pCallback * @param pExceptionCallback */ protected <T> void doProgressAsync(final int pTitleResID, final ProgressCallable<T> pCallable, final Callback<T> pCallback, final Callback<Exception> pExceptionCallback) { ActivityUtils.doProgressAsync(this, pTitleResID, pCallable, pCallback, pExceptionCallback); } /** * Performs a task in the background, showing an indeterminate {@link ProgressDialog}, * while the {@link AsyncCallable} is being processed. * * @param <T> * @param pTitleResID * @param pMessageResID * @param pErrorMessageResID * @param pAsyncCallable * @param pCallback * @param pExceptionCallback */ protected <T> void doAsync(final int pTitleResID, final int pMessageResID, final AsyncCallable<T> pAsyncCallable, final Callback<T> pCallback, final Callback<Exception> pExceptionCallback) { ActivityUtils.doAsync(this, pTitleResID, pMessageResID, pAsyncCallable, pCallback, pExceptionCallback); } // =========================================================== // Inner and Anonymous Classes // =========================================================== public static class CancelledException extends Exception { private static final long serialVersionUID = -78123211381435596L; } }
zzy421-andengine
src/org/anddev/andengine/ui/activity/BaseActivity.java
Java
lgpl
4,667
package org.anddev.andengine.ui.activity; import org.anddev.andengine.engine.Engine; import org.anddev.andengine.engine.camera.Camera; import org.anddev.andengine.engine.handler.timer.ITimerCallback; import org.anddev.andengine.engine.handler.timer.TimerHandler; import org.anddev.andengine.engine.options.EngineOptions; import org.anddev.andengine.engine.options.EngineOptions.ScreenOrientation; import org.anddev.andengine.engine.options.resolutionpolicy.IResolutionPolicy; import org.anddev.andengine.engine.options.resolutionpolicy.RatioResolutionPolicy; import org.anddev.andengine.entity.scene.Scene; import org.anddev.andengine.entity.scene.SplashScene; import org.anddev.andengine.opengl.texture.TextureOptions; import org.anddev.andengine.opengl.texture.atlas.bitmap.BitmapTextureAtlas; import org.anddev.andengine.opengl.texture.atlas.bitmap.BitmapTextureAtlasFactory; import org.anddev.andengine.opengl.texture.atlas.bitmap.BitmapTextureAtlasTextureRegionFactory; import org.anddev.andengine.opengl.texture.atlas.bitmap.source.IBitmapTextureAtlasSource; import org.anddev.andengine.opengl.texture.bitmap.BitmapTexture.BitmapTextureFormat; import org.anddev.andengine.opengl.texture.region.TextureRegion; import android.app.Activity; import android.content.Intent; /** * (c) 2010 Nicolas Gramlich * (c) 2011 Zynga Inc. * * @author Nicolas Gramlich * @since 08:25:31 - 03.05.2010 */ public abstract class BaseSplashActivity extends BaseGameActivity { // =========================================================== // Constants // =========================================================== // =========================================================== // Fields // =========================================================== private Camera mCamera; private IBitmapTextureAtlasSource mSplashTextureAtlasSource; private TextureRegion mLoadingScreenTextureRegion; // =========================================================== // Constructors // =========================================================== // =========================================================== // Getter & Setter // =========================================================== // =========================================================== // Methods for/from SuperClass/Interfaces // =========================================================== protected abstract ScreenOrientation getScreenOrientation(); protected abstract IBitmapTextureAtlasSource onGetSplashTextureAtlasSource(); protected abstract float getSplashDuration(); protected abstract Class<? extends Activity> getFollowUpActivity(); protected float getSplashScaleFrom() { return 1f; } protected float getSplashScaleTo() { return 1f; } @Override public void onLoadComplete() { } @Override public Engine onLoadEngine() { this.mSplashTextureAtlasSource = this.onGetSplashTextureAtlasSource(); final int width = this.mSplashTextureAtlasSource.getWidth(); final int height = this.mSplashTextureAtlasSource.getHeight(); this.mCamera = this.getSplashCamera(width, height); return new Engine(new EngineOptions(true, this.getScreenOrientation(), this.getSplashResolutionPolicy(width, height), this.mCamera)); } @Override public void onLoadResources() { final BitmapTextureAtlas loadingScreenBitmapTextureAtlas = BitmapTextureAtlasFactory.createForTextureAtlasSourceSize(BitmapTextureFormat.RGBA_8888, this.mSplashTextureAtlasSource, TextureOptions.BILINEAR_PREMULTIPLYALPHA); this.mLoadingScreenTextureRegion = BitmapTextureAtlasTextureRegionFactory.createFromSource(loadingScreenBitmapTextureAtlas, this.mSplashTextureAtlasSource, 0, 0); this.getEngine().getTextureManager().loadTexture(loadingScreenBitmapTextureAtlas); } @Override public Scene onLoadScene() { final float splashDuration = this.getSplashDuration(); final SplashScene splashScene = new SplashScene(this.mCamera, this.mLoadingScreenTextureRegion, splashDuration, this.getSplashScaleFrom(), this.getSplashScaleTo()); splashScene.registerUpdateHandler(new TimerHandler(splashDuration, new ITimerCallback() { @Override public void onTimePassed(final TimerHandler pTimerHandler) { BaseSplashActivity.this.startActivity(new Intent(BaseSplashActivity.this, BaseSplashActivity.this.getFollowUpActivity())); BaseSplashActivity.this.finish(); } })); return splashScene; } // =========================================================== // Methods // =========================================================== protected Camera getSplashCamera(final int pSplashwidth, final int pSplashHeight) { return new Camera(0, 0, pSplashwidth, pSplashHeight); } protected IResolutionPolicy getSplashResolutionPolicy(final int pSplashwidth, final int pSplashHeight) { return new RatioResolutionPolicy(pSplashwidth, pSplashHeight); } // =========================================================== // Inner and Anonymous Classes // =========================================================== }
zzy421-andengine
src/org/anddev/andengine/ui/activity/BaseSplashActivity.java
Java
lgpl
5,135
package org.anddev.andengine.ui; import org.anddev.andengine.engine.Engine; import org.anddev.andengine.entity.scene.Scene; /** * (c) 2010 Nicolas Gramlich * (c) 2011 Zynga Inc. * * @author Nicolas Gramlich * @since 12:03:08 - 14.03.2010 */ public interface IGameInterface { // =========================================================== // Final Fields // =========================================================== // =========================================================== // Methods // =========================================================== public Engine onLoadEngine(); public void onLoadResources(); public void onUnloadResources(); public Scene onLoadScene(); public void onLoadComplete(); public void onPauseGame(); public void onResumeGame(); }
zzy421-andengine
src/org/anddev/andengine/ui/IGameInterface.java
Java
lgpl
819
package org.anddev.andengine.ui.dialog; import org.anddev.andengine.util.Callback; import android.content.Context; import android.content.DialogInterface.OnCancelListener; /** * (c) 2010 Nicolas Gramlich * (c) 2011 Zynga Inc. * * @author Nicolas Gramlich * @since 09:46:00 - 14.12.2009 */ public class StringInputDialogBuilder extends GenericInputDialogBuilder<String> { // =========================================================== // Constants // =========================================================== // =========================================================== // Fields // =========================================================== // =========================================================== // Constructors // =========================================================== public StringInputDialogBuilder(final Context pContext, final int pTitleResID, final int pMessageResID, final int pErrorResID, final int pIconResID, final Callback<String> pSuccessCallback, final OnCancelListener pOnCancelListener) { super(pContext, pTitleResID, pMessageResID, pErrorResID, pIconResID, pSuccessCallback, pOnCancelListener); } public StringInputDialogBuilder(final Context pContext, final int pTitleResID, final int pMessageResID, final int pErrorResID, final int pIconResID, final String pDefaultText, final Callback<String> pSuccessCallback, final OnCancelListener pOnCancelListener) { super(pContext, pTitleResID, pMessageResID, pErrorResID, pIconResID, pDefaultText, pSuccessCallback, pOnCancelListener); } // =========================================================== // Getter & Setter // =========================================================== // =========================================================== // Methods for/from SuperClass/Interfaces // =========================================================== @Override protected String generateResult(final String pInput) { return pInput; } // =========================================================== // Methods // =========================================================== // =========================================================== // Inner and Anonymous Classes // =========================================================== }
zzy421-andengine
src/org/anddev/andengine/ui/dialog/StringInputDialogBuilder.java
Java
lgpl
2,316
package org.anddev.andengine.ui.dialog; import org.anddev.andengine.util.Callback; import org.anddev.andengine.util.Debug; import android.app.AlertDialog; import android.app.Dialog; import android.content.Context; import android.content.DialogInterface; import android.content.DialogInterface.OnCancelListener; import android.content.DialogInterface.OnClickListener; import android.widget.EditText; import android.widget.Toast; /** * (c) 2010 Nicolas Gramlich * (c) 2011 Zynga Inc. * * @author Nicolas Gramlich * @since 09:35:55 - 14.12.2009 */ public abstract class GenericInputDialogBuilder<T> { // =========================================================== // Constants // =========================================================== // =========================================================== // Fields // =========================================================== protected final Callback<T> mSuccessCallback; protected final OnCancelListener mOnCancelListener; protected final int mTitleResID; protected final int mMessageResID; protected final int mIconResID; protected final Context mContext; private final int mErrorResID; private final String mDefaultText; // =========================================================== // Constructors // =========================================================== public GenericInputDialogBuilder(final Context pContext, final int pTitleResID, final int pMessageResID, final int pErrorResID, final int pIconResID, final Callback<T> pSuccessCallback, final OnCancelListener pOnCancelListener){ this(pContext, pTitleResID, pMessageResID, pErrorResID, pIconResID, "", pSuccessCallback, pOnCancelListener); } public GenericInputDialogBuilder(final Context pContext, final int pTitleResID, final int pMessageResID, final int pErrorResID, final int pIconResID, final String pDefaultText, final Callback<T> pSuccessCallback, final OnCancelListener pOnCancelListener){ this.mContext = pContext; this.mTitleResID = pTitleResID; this.mMessageResID = pMessageResID; this.mErrorResID = pErrorResID; this.mIconResID = pIconResID; this.mDefaultText = pDefaultText; this.mSuccessCallback = pSuccessCallback; this.mOnCancelListener = pOnCancelListener; } // =========================================================== // Getter & Setter // =========================================================== // =========================================================== // Methods for/from SuperClass/Interfaces // =========================================================== protected abstract T generateResult(final String pInput); // =========================================================== // Methods // =========================================================== public Dialog create() { final EditText etInput = new EditText(this.mContext); etInput.setText(this.mDefaultText); final AlertDialog.Builder ab = new AlertDialog.Builder(this.mContext); if(this.mTitleResID != 0) { ab.setTitle(this.mTitleResID); } if(this.mMessageResID != 0) { ab.setMessage(this.mMessageResID); } if(this.mIconResID != 0) { ab.setIcon(this.mIconResID); } this.setView(ab, etInput); ab.setOnCancelListener(this.mOnCancelListener) .setPositiveButton(android.R.string.ok, new OnClickListener() { @Override public void onClick(final DialogInterface pDialog, final int pWhich) { final T result; try{ result = GenericInputDialogBuilder.this.generateResult(etInput.getText().toString()); } catch (final IllegalArgumentException e) { Debug.e("Error in GenericInputDialogBuilder.generateResult()", e); Toast.makeText(GenericInputDialogBuilder.this.mContext, GenericInputDialogBuilder.this.mErrorResID, Toast.LENGTH_SHORT).show(); return; } GenericInputDialogBuilder.this.mSuccessCallback.onCallback(result); pDialog.dismiss(); } }) .setNegativeButton(android.R.string.cancel, new OnClickListener() { @Override public void onClick(final DialogInterface pDialog, final int pWhich) { GenericInputDialogBuilder.this.mOnCancelListener.onCancel(pDialog); pDialog.dismiss(); } }); return ab.create(); } protected void setView(final AlertDialog.Builder pBuilder, final EditText pInputEditText) { pBuilder.setView(pInputEditText); } // =========================================================== // Inner and Anonymous Classes // =========================================================== }
zzy421-andengine
src/org/anddev/andengine/ui/dialog/GenericInputDialogBuilder.java
Java
lgpl
4,605
package com.dati.bean; public class Xulie { /** *@author qingyu zhang *@function: *2011-4-4 *下午02:38:14 *zzClub *com.dati.bean */ private String seriseId; private String answerTypeId; private String seriseName; private String createTime; public String getSeriseId() { return seriseId; } public void setSeriseId(String seriseId) { this.seriseId = seriseId; } public String getAnswerTypeId() { return answerTypeId; } public void setAnswerTypeId(String answerTypeId) { this.answerTypeId = answerTypeId; } public String getSeriseName() { return seriseName; } public void setSeriseName(String seriseName) { this.seriseName = seriseName; } public String getCreateTime() { return createTime; } public void setCreateTime(String createTime) { this.createTime = createTime; } }
zzprojects
trunk/zzprojects/zzClub/src/com/dati/bean/Xulie.java
Java
asf20
866
package com.dati.bean; public class DatiMiddle { /** *@author qingyu zhang *@function: *2011-4-13 *上午11:25:31 *zzClub *com.dati.bean */ private String answerMiddleId; private String seriseId; private String answerContent; private String createTime; private String rightAnswer; public String getAnswerMiddleId() { return answerMiddleId; } public void setAnswerMiddleId(String answerMiddleId) { this.answerMiddleId = answerMiddleId; } public String getSeriseId() { return seriseId; } public void setSeriseId(String seriseId) { this.seriseId = seriseId; } public String getAnswerContent() { return answerContent; } public void setAnswerContent(String answerContent) { this.answerContent = answerContent; } public String getCreateTime() { return createTime; } public void setCreateTime(String createTime) { this.createTime = createTime; } public String getRightAnswer() { return rightAnswer; } public void setRightAnswer(String rightAnswer) { this.rightAnswer = rightAnswer; } }
zzprojects
trunk/zzprojects/zzClub/src/com/dati/bean/DatiMiddle.java
Java
asf20
1,089
package com.dati.bean; import java.io.Serializable; public class DatiType implements Serializable{ /** *@author qingyu zhang *@function: *2011-4-4 *下午02:31:36 *zzClub *com.dati.bean */ private String answerTypeId; private int userId; private String typeName; private String createTime; public String getAnswerTypeId() { return answerTypeId; } public void setAnswerTypeId(String answerTypeId) { this.answerTypeId = answerTypeId; } public int getUserId() { return userId; } public void setUserId(int userId) { this.userId = userId; } public String getTypeName() { return typeName; } public void setTypeName(String typeName) { this.typeName = typeName; } public String getCreateTime() { return createTime; } public void setCreateTime(String createTime) { this.createTime = createTime; } }
zzprojects
trunk/zzprojects/zzClub/src/com/dati/bean/DatiType.java
Java
asf20
887
package com.dati.bean; public class SendDati { /** *@author qingyu zhang *@function: *2011-4-13 *上午10:39:32 *zzClub *com.dati.bean */ private int id; private String seriseId; private String answerMiddleId; private int state; private String phone; private String createTime; private String endTime; private int rightOrno; public int getId() { return id; } public void setId(int id) { this.id = id; } public String getSeriseId() { return seriseId; } public void setSeriseId(String seriseId) { this.seriseId = seriseId; } public String getAnswerMiddleId() { return answerMiddleId; } public void setAnswerMiddleId(String answerMiddleId) { this.answerMiddleId = answerMiddleId; } public int getState() { return state; } public void setState(int state) { this.state = state; } public String getPhone() { return phone; } public void setPhone(String phone) { this.phone = phone; } public String getCreateTime() { return createTime; } public void setCreateTime(String createTime) { this.createTime = createTime; } public String getEndTime() { return endTime; } public void setEndTime(String endTime) { this.endTime = endTime; } public int getRightOrno() { return rightOrno; } public void setRightOrno(int rightOrno) { this.rightOrno = rightOrno; } }
zzprojects
trunk/zzprojects/zzClub/src/com/dati/bean/SendDati.java
Java
asf20
1,403
package com.dati.bean; public class setTime { /** *@author qingyu zhang *@function: *2011-4-13 *上午10:42:07 *zzClub *com.dati.bean */ private int id; private String setTime; public int getId() { return id; } public void setId(int id) { this.id = id; } public String getSetTime() { return setTime; } public void setSetTime(String setTime) { this.setTime = setTime; } }
zzprojects
trunk/zzprojects/zzClub/src/com/dati/bean/setTime.java
Java
asf20
433
package com.dati.bean; import java.io.Serializable; public class Answer implements Serializable{ /** *@author qingyu zhang *@function: *2011-4-14 *上午11:42:35 *zzClub *com.dati.bean */ private int answerId; private String answerMiddleId; private int receiveId; private String answerUpPhone; private String answerUpTime; private String answerIntegral; public int getAnswerId() { return answerId; } public void setAnswerId(int answerId) { this.answerId = answerId; } public String getAnswerMiddleId() { return answerMiddleId; } public void setAnswerMiddleId(String answerMiddleId) { this.answerMiddleId = answerMiddleId; } public int getReceiveId() { return receiveId; } public void setReceiveId(int receiveId) { this.receiveId = receiveId; } public String getAnswerUpPhone() { return answerUpPhone; } public void setAnswerUpPhone(String answerUpPhone) { this.answerUpPhone = answerUpPhone; } public String getAnswerUpTime() { return answerUpTime; } public void setAnswerUpTime(String answerUpTime) { this.answerUpTime = answerUpTime; } public String getAnswerIntegral() { return answerIntegral; } public void setAnswerIntegral(String answerIntegral) { this.answerIntegral = answerIntegral; } }
zzprojects
trunk/zzprojects/zzClub/src/com/dati/bean/Answer.java
Java
asf20
1,328
package com.dati.bean; public class Dati { /** *@author qingyu zhang *@function: *2011-4-13 *上午10:45:03 *zzClub *com.dati.bean */ private int datiId; private String smscontent; private String sendPhone; private int state; public int getDatiId() { return datiId; } public void setDatiId(int datiId) { this.datiId = datiId; } public String getSmscontent() { return smscontent; } public void setSmscontent(String smscontent) { this.smscontent = smscontent; } public String getSendPhone() { return sendPhone; } public void setSendPhone(String sendPhone) { this.sendPhone = sendPhone; } public int getState() { return state; } public void setState(int state) { this.state = state; } }
zzprojects
trunk/zzprojects/zzClub/src/com/dati/bean/Dati.java
Java
asf20
778
package com.dati.bean; public class Daan { /** *@author qingyu zhang *@function: *2011-4-13 *下午03:24:57 *zzClub *com.dati.bean */ private int id; private String timuId; private String phone; private String daAn; private int state; public int getId() { return id; } public void setId(int id) { this.id = id; } public String getTimuId() { return timuId; } public void setTimuId(String timuId) { this.timuId = timuId; } public String getPhone() { return phone; } public void setPhone(String phone) { this.phone = phone; } public String getDaAn() { return daAn; } public void setDaAn(String daAn) { this.daAn = daAn; } public int getState() { return state; } public void setState(int state) { this.state = state; } }
zzprojects
trunk/zzprojects/zzClub/src/com/dati/bean/Daan.java
Java
asf20
827
package com.dati.servlet; import java.io.File; import java.io.FileInputStream; import java.io.IOException; import java.io.InputStream; import java.io.PrintWriter; import java.util.ArrayList; import java.util.Hashtable; import java.util.List; import javax.servlet.ServletException; import javax.servlet.http.HttpServlet; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; import jxl.Cell; import jxl.Sheet; import jxl.Workbook; import util.AllTypeList; import util.Constant; import util.UtilDAO; import com.UserModule.bean.TbUserBean; import com.dati.bean.Answer; import com.dati.bean.DatiMiddle; import com.dati.bean.DatiType; import com.dati.bean.Xulie; import com.dati.bean.setTime; import com.dati.dao.DatiDao; import com.dati.dao.DatiTypeDao; import com.dianbo.bean.DianboType; import com.jifen.bean.JiFen; import com.jifen.dao.JifenDao; import com.jspsmart.upload.SmartUpload; public class DatiServlet extends HttpServlet { /** * Constructor of the object. */ public DatiServlet() { super(); } /** * Destruction of the servlet. <br> */ public void destroy() { super.destroy(); // Just puts "destroy" string in log // Put your code here } /** * The doGet method of the servlet. <br> * * This method is called when a form has its tag value method equals to get. * * @param request the request send by the client to the server * @param response the response send by the server to the client * @throws ServletException if an error occurred * @throws IOException if an error occurred */ public void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { response.setContentType("text/html"); PrintWriter out = response.getWriter(); String method= request.getParameter("method"); TbUserBean user = (TbUserBean)request.getSession().getAttribute("User"); if(method.equals("setSubmit")){//答题设置积分 String num = request.getParameter("num"); String xilieId = request.getParameter("xilieId"); JiFen jiFen = new JiFen(); jiFen.setTypeId(""); jiFen.setIntegralType(0); jiFen.setIntegralValue(num); jiFen.setSeriseId(xilieId); jiFen.setSetTime(Constant.decodeDate()); jiFen.setUserId(user.getUserId()); boolean bo = new JifenDao().addJiFenXilie(jiFen); if(bo){ request.getSession().setAttribute("result", "积分设置成功"); }else { request.getSession().setAttribute("result", "积分设置失败"); } List list = new AllTypeList().getLastValue(user.getUserId()); List<DianboType> dianboTypeList = (ArrayList<DianboType>)list.get(0); StringBuffer sb = (StringBuffer)list.get(1); request.getSession().setAttribute("dianboTypeList", dianboTypeList); request.getSession().setAttribute("sb", sb); response.sendRedirect("jifen/jiFenupLoadList.jsp"); }else if(method.equals("setDown")){//答题下行积分设置显示 String dianboId = request.getParameter("dianboId"); String condition=" answerTypeId = '"+dianboId+"'"; List<DatiType> datiTypeList = new DatiTypeDao().getAllDaTiType("tb_answer_type","createTime",condition); request.getSession().setAttribute("datiTypeList", datiTypeList); response.sendRedirect("jifen/jiFendownDatiSet.jsp"); }else if(method.equals("setDownSubmit")){//答题下行积分设置提交 String num = request.getParameter("num"); String typeId = request.getParameter("typeId"); JiFen jiFen = new JiFen(); jiFen.setTypeId(typeId); jiFen.setIntegralType(1); jiFen.setIntegralValue(num); jiFen.setSeriseId(""); jiFen.setSetTime(Constant.decodeDate()); jiFen.setUserId(user.getUserId()); boolean bo = new JifenDao().addJiFen(jiFen); if(bo){ request.getSession().setAttribute("result", "点播下行积分设置成功"); }else { request.getSession().setAttribute("result", "点播下行积分设置失败"); } List list = new AllTypeList().getDownValue(user.getUserId()); List<DianboType> dianboTypeList = (ArrayList<DianboType>)list.get(0); List<DatiType> datiTypeList = (ArrayList<DatiType>)list.get(1); request.getSession().setAttribute("result", ""); request.getSession().setAttribute("dianboTypeList", dianboTypeList); request.getSession().setAttribute("datiTypeList", datiTypeList); response.sendRedirect("jifen/jiFendownList.jsp"); }else if("lookdati".equals(method)){//答题库管理 String datiType = request.getParameter("datiType"); String content = request.getParameter("content"); List<Object> list = this.getLst(datiType, content,user.getUserId()); List<DatiType> datiTypeList =(List<DatiType>)list.get(0); List<Answer> datiList = (List<Answer>)list.get(1); request.getSession().setAttribute("datiList", datiList); request.getSession().setAttribute("datiTypeList", datiTypeList); request.getSession().setAttribute("result", ""); request.getSession().setAttribute("datiSelected", "0"); request.getSession().setAttribute("content",content); response.sendRedirect("hudong/datiList.jsp"); }else if("looksearch".equals(method)){//查询答题 String datitype= Constant.decodeString(request.getParameter("datitype")); String content = Constant.decodeString(request.getParameter("content")); String condition="1=1"; List<Answer> answerList = new ArrayList<Answer>(); if(datitype.equals("0")){ }else{ condition+=" and answerTypeId='"+datitype+"'"; } List<Xulie> xulieList = new DatiTypeDao().getXulieByTypeId("tb_serise", "", condition);//得到系列 String xulieId=""; if(xulieList!=null&&xulieList.size()>0){ for(Xulie xulie:xulieList){ if(xulieId.equals("")){ xulieId+=xulie.getSeriseId(); }else{ xulieId+=","+xulie.getSeriseId(); } } String conditionMidd="seriseId in("+xulieId+")"; if(!content.equals("")){ conditionMidd+=" and answerContent like '%"+content+"%'"; } List<DatiMiddle> datiMiddleList = new DatiDao().getDatiMiddle("tb_answer_middle", "", conditionMidd);//得到中间表记录 String answerMiddle=""; if(datiMiddleList!=null&&datiMiddleList.size()>0){ for(DatiMiddle datiMiddle:datiMiddleList){ if(answerMiddle.equals("")){ answerMiddle+=datiMiddle.getAnswerMiddleId(); }else{ answerMiddle+=","+datiMiddle.getAnswerMiddleId(); } } String conditionAnswer="answerMiddleId in("+answerMiddle+")";//取答题表中的记录 answerList = new DatiDao().getAnswerList("tb_answer", "", conditionAnswer); } } String datiTypeCondition=" userId="+user.getUserId(); List<DatiType> datiTypeList = new DatiTypeDao().getAllDaTiType("tb_answer_type", "", datiTypeCondition); request.getSession().setAttribute("datiList", answerList); request.getSession().setAttribute("datiTypeList", datiTypeList); request.getSession().setAttribute("result", ""); request.getSession().setAttribute("datiSelected", datitype); request.getSession().setAttribute("content",content); response.sendRedirect("hudong/datiList.jsp"); }else if("addDati".equals(method)){ String datiType = request.getParameter("datiType"); String xilieType = request.getParameter("xilieType"); String datianswer = Constant.decodeString(request.getParameter("datianswer")); String daticontent = Constant.decodeString(request.getParameter("daticontent")); DatiMiddle datiMiddle = new DatiMiddle(); String middleId = Constant.getNumT(); datiMiddle.setAnswerMiddleId(middleId); datiMiddle.setAnswerContent(daticontent); datiMiddle.setCreateTime(Constant.decodeDate()); datiMiddle.setRightAnswer(datianswer); datiMiddle.setSeriseId(xilieType); boolean bo = new DatiDao().saveDatiMiddle(datiMiddle); if(bo){ Answer answer = new Answer(); answer.setAnswerIntegral(""); answer.setAnswerMiddleId(middleId); answer.setAnswerUpPhone(""); answer.setAnswerUpTime(Constant.decodeDate()); answer.setReceiveId(0); boolean boo =new DatiDao().saveAnswer(answer); if(boo){ request.getSession().setAttribute("result", "添加答题成功!"); } } List list = this.getLst("", "",user.getUserId()); List<DatiType> datiTypeList =(ArrayList<DatiType>)list.get(0); List<Answer> datiList = (ArrayList<Answer>)list.get(1); request.getSession().setAttribute("datiList", datiList); request.getSession().setAttribute("datiTypeList", datiTypeList); request.getSession().setAttribute("datiSelected", "0"); request.getSession().setAttribute("content",""); response.sendRedirect("hudong/datiList.jsp"); }else if("deleteOneDati".equals(method)){ String datiId =request.getParameter("datiId"); String content = Constant.decodeString(request.getParameter("content")); String datiSelected = request.getParameter("datiSelected"); boolean bo = UtilDAO.del("tb_answer", "answerId", Integer.parseInt(datiId)); if(bo){ request.getSession().setAttribute("result", "答题删除成功!"); }else{ request.getSession().setAttribute("result", "答题删除失败!"); } List<Object> list = this.getLst(datiSelected, content, user.getUserId()); List<DatiType> datiTypeList =(ArrayList<DatiType>)list.get(0); List<Answer> datiList = (ArrayList<Answer>)list.get(1); request.getSession().setAttribute("datiList", datiList); request.getSession().setAttribute("datiTypeList", datiTypeList); request.getSession().setAttribute("datiSelected", datiSelected); request.getSession().setAttribute("content",content); response.sendRedirect("hudong/datiList.jsp"); }else if("deleteAll".equals(method)){ String idList = request.getParameter("idList"); idList = idList.substring(0, idList.length()-1); String content = Constant.decodeString(request.getParameter("content")); String datiSelected = request.getParameter("datiSelected"); String condition=" tb_answer where answerId in("+idList+")"; boolean result=UtilDAO.delAll(condition); if(result){ request.getSession().setAttribute("result", "答题记录删除成功!"); }else{ request.getSession().setAttribute("result", "答题记录删除失败!"); } List<Object> list = this.getLst(datiSelected, content, user.getUserId()); List<DatiType> datiTypeList =(ArrayList<DatiType>)list.get(0); List<Answer> datiList = (ArrayList<Answer>)list.get(1); request.getSession().setAttribute("datiList", datiList); request.getSession().setAttribute("datiTypeList", datiTypeList); request.getSession().setAttribute("datiSelected", datiSelected); request.getSession().setAttribute("content",content); response.sendRedirect("hudong/datiList.jsp"); }else if("importDati".equals(method)){ String realImagePath = Constant.decodeString(request .getParameter("realImagePath")); String tempPath = request.getRealPath("/") + "upload".replace("\\", "/"); String result = ""; File file = new File(tempPath); if(!file.isFile()){ file.mkdirs(); } // new a SmartUpload object SmartUpload su = new SmartUpload(); su.setCharset("UTF-8");// 使用时候最关键的一步 // 上传初始化 su.initialize(this.getServletConfig(),request,response); // 设定上传限制 // 1.限制每个上传文件的最大长度。 su.setMaxFileSize(10000000); // 2.限制总上传数据的长度。 su.setTotalMaxFileSize(20000000); // 3.设定允许上传的文件(通过扩展名限制),仅允许doc,txt文件。 su.setAllowedFilesList("xls,XLS"); boolean sign = true; // 4.设定禁止上传的文件(通过扩展名限制),禁止上传带有exe,bat,jsp,htm,html扩展名的文件和没有扩展名的文件。 try { su.setDeniedFilesList("exe,bat,jsp,htm,html"); // 上传文件 su.upload(); // 将上传文件保存到指定目录 tempPath = tempPath.replace("\\", "/"); tempPath = tempPath + "/"; su.save(tempPath); System.out.println("文件名称"+su.getFiles().getFile(0).getFileName()); tempPath += "\\" + su.getFiles().getFile(0).getFileName(); tempPath = tempPath.replace("\\", "/"); tempPath = tempPath.replace("//", "/"); System.out.println("tempsssssssssssssPath==="+tempPath); Workbook wb; InputStream is2 = new FileInputStream(tempPath); wb = Workbook.getWorkbook(is2); Sheet sheet = wb.getSheet(0); int row = sheet.getRows(); List<Answer> answerList = new ArrayList<Answer>(); String condition="userId="+user.getUserId(); List<DatiType> datiTypeList = new DatiTypeDao().getAllDaTiType("tb_answer_type", "", condition);//得到数据库中已存在答题类型 List<String> datiTypeNameList = new ArrayList<String>();//得到已经存在库中的答题类型的名称 Hashtable<String,List<String>> ht = new Hashtable<String,List<String>>();//得到答题类型下的系列 以答题名称/系列LIST List<String> saveTypeName = new ArrayList<String>();//要保存的答题类型名称 List<String> xilieName = new ArrayList<String>();//要保存的系列名称 List<Xulie> xilieList = new ArrayList<Xulie>(); if(datiTypeList!=null&&datiTypeList.size()>0){ for(DatiType datiType:datiTypeList){ datiTypeNameList.add(datiType.getTypeName()); String conditionXulie = "answerTypeId='"+datiType.getAnswerTypeId()+"'"; List<String> xilieNameList = new ArrayList<String>(); xilieList = new DatiTypeDao().getXulieByTypeId("tb_serise", "", conditionXulie); if(xilieList!=null&&xilieList.size()>0){ xilieNameList = new DatiTypeDao().getXilieNameList(xilieList); } ht.put(datiType.getTypeName(), xilieNameList); } } List<DatiMiddle> datiMiddleList = new ArrayList<DatiMiddle>();//要保存的中间表内容 List<Xulie> xlList = new ArrayList<Xulie>();//要保存的系列 List<Answer> answerLst = new ArrayList<Answer>();//要保存的答题 List<DatiType> dtTypeLst = new ArrayList<DatiType>();//要保存的答题类型 Hashtable<String,String> hhtType = new Hashtable<String,String>(); Hashtable<String,String> hhtSerise = new Hashtable<String,String>(); //模式:类型|||||系列|||题目||||答案 for(int i =1;i<row;i++){ Cell firstCell = sheet.getCell(0, i); String firstContent = firstCell.getContents().trim(); Cell secondCell = sheet.getCell(1, i); String secondContent = secondCell.getContents().trim(); Cell threeCell = sheet.getCell(2, i); String threeContent = threeCell.getContents().trim(); Cell fourCell = sheet.getCell(3, i); String fourContent = fourCell.getContents().trim(); /*if(firstContent.equals("")&&threeContent.equals("")&&fourContent.equals("")){ continue; }*/ if(datiTypeNameList.contains(firstContent)){//数据库中存在此答题类型 List<String> xn = ht.get(firstContent); String answerTypeCodition=" userId="+user.getUserId()+" and typeName='"+firstContent+"'"; List<DatiType> datiTypeLst = new DatiTypeDao().getAllDaTiType("tb_answer_type", "", answerTypeCodition); if(xn.contains(secondContent)){//数据库中已存在此系列 String xilieTypeCondition=" answerTypeId='"+datiTypeLst.get(0).getAnswerTypeId()+"' and seriseName ='"+secondContent+"'"; List<Xulie> xilieType = new DatiTypeDao().getXulieByTypeId("tb_serise","", xilieTypeCondition); DatiMiddle datiM = new DatiMiddle(); String datiMId=Constant.getNumT(); datiM.setAnswerContent(threeContent); datiM.setAnswerMiddleId(datiMId); datiM.setCreateTime(Constant.decodeDate()); datiM.setRightAnswer(fourContent); datiM.setSeriseId(xilieType.get(0).getSeriseId()); datiMiddleList.add(datiM); Answer answer = new Answer(); answer.setAnswerIntegral(""); answer.setAnswerMiddleId(datiMId); answer.setAnswerUpPhone(""); answer.setAnswerUpTime(Constant.decodeDate()); answer.setReceiveId(0); answerLst.add(answer); }else {//数据库中不存在此系列 System.out.println("不存在系列"+secondContent); Xulie xil = new Xulie(); String xilId = Constant.getNum(); xil.setAnswerTypeId(datiTypeLst.get(0).getAnswerTypeId()); xil.setCreateTime(Constant.decodeDate()); xil.setSeriseId(xilId); xil.setSeriseName(secondContent); xlList.add(xil); DatiMiddle datiM = new DatiMiddle(); String datiMId = Constant.getNumT(); datiM.setAnswerContent(threeContent); datiM.setAnswerMiddleId(datiMId); datiM.setCreateTime(Constant.decodeDate()); datiM.setRightAnswer(fourContent); datiM.setSeriseId(xilId); datiMiddleList.add(datiM); Answer answer = new Answer(); answer.setAnswerIntegral(""); answer.setAnswerMiddleId(datiMId); answer.setAnswerUpPhone(""); answer.setAnswerUpTime(Constant.decodeDate()); answer.setReceiveId(0); answerLst.add(answer); } }else if(saveTypeName.contains(firstContent)){ System.out.println("firstContent=="+firstContent); String Typeid = hhtType.get(firstContent); System.out.println("type_id="+Typeid); if(xilieName.contains(secondContent)){ String seriseId = hhtSerise.get(secondContent); DatiMiddle datiM = new DatiMiddle(); String datiMId = Constant.getNumT(); datiM.setAnswerContent(threeContent); datiM.setAnswerMiddleId(datiMId); datiM.setCreateTime(Constant.decodeDate()); datiM.setRightAnswer(fourContent); datiM.setSeriseId(seriseId); datiMiddleList.add(datiM); Answer answer = new Answer(); answer.setAnswerIntegral(""); answer.setAnswerMiddleId(datiMId); answer.setAnswerUpPhone(""); answer.setAnswerUpTime(Constant.decodeDate()); answer.setReceiveId(0); answerLst.add(answer); }else{ Xulie xilie = new Xulie(); String seriseId = Constant.getNum(); xilie.setAnswerTypeId(Typeid); xilie.setCreateTime(Constant.decodeDate()); xilie.setSeriseId(seriseId); xilie.setSeriseName(secondContent); xlList.add(xilie); xilieName.add(secondContent); hhtSerise.put(secondContent, seriseId); DatiMiddle datiM = new DatiMiddle(); String datiMId = Constant.getNumT(); datiM.setAnswerContent(threeContent); datiM.setAnswerMiddleId(datiMId); datiM.setCreateTime(Constant.decodeDate()); datiM.setRightAnswer(fourContent); datiM.setSeriseId(seriseId); datiMiddleList.add(datiM); Answer answer = new Answer(); answer.setAnswerIntegral(""); answer.setAnswerMiddleId(datiMId); answer.setAnswerUpPhone(""); answer.setAnswerUpTime(Constant.decodeDate()); answer.setReceiveId(0); answerLst.add(answer); } }else{ DatiType datiTy= new DatiType(); String dtTypeId=Constant.getNum(); System.out.println("类型ID"+dtTypeId+"&&&"+firstContent); hhtType.put(firstContent, dtTypeId); //System.out.println("IDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDd="+hhtType.get(firstContent)); datiTy.setAnswerTypeId(dtTypeId); datiTy.setCreateTime(Constant.decodeDate()); datiTy.setTypeName(firstContent); datiTy.setUserId(user.getUserId()); dtTypeLst.add(datiTy); saveTypeName.add(firstContent); Xulie xilie = new Xulie(); String seriseId = Constant.getNum(); xilie.setAnswerTypeId(dtTypeId); xilie.setCreateTime(Constant.decodeDate()); xilie.setSeriseId(seriseId); xilie.setSeriseName(secondContent); xlList.add(xilie); xilieName.add(secondContent); hhtSerise.put(secondContent, seriseId); DatiMiddle datiM = new DatiMiddle(); String datiMId = Constant.getNumT(); datiM.setAnswerContent(threeContent); datiM.setAnswerMiddleId(datiMId); datiM.setCreateTime(Constant.decodeDate()); datiM.setRightAnswer(fourContent); datiM.setSeriseId(seriseId); datiMiddleList.add(datiM); Answer answer = new Answer(); answer.setAnswerIntegral(""); answer.setAnswerMiddleId(datiMId); answer.setAnswerUpPhone(""); answer.setAnswerUpTime(Constant.decodeDate()); answer.setReceiveId(0); answerLst.add(answer); } } for(Xulie xxx:xlList){ System.out.println("名称"+xxx.getSeriseName()); } if(dtTypeLst.size()>0){ boolean datiTypeBo = new DatiTypeDao().saveDatiType(dtTypeLst); if(datiTypeBo){ boolean xilieBo = new DatiTypeDao().saveXilie(xlList); if(xilieBo){ boolean middleBo = new DatiDao().saveMiddle(datiMiddleList); if(middleBo){ boolean answerBo = new DatiDao().saveAnswer(answerLst); }else{ request.getSession().setAttribute("result", "答题导入失败!"); } }else{ request.getSession().setAttribute("result", "由于系列导入失败,导致答题导入失败!"); } }else{ request.getSession().setAttribute("result", "由于类型导入失败,导致答题导入失败!"); } }else{ boolean xilieBo = new DatiTypeDao().saveXilie(xlList); if(xilieBo){ boolean middleBo = new DatiDao().saveMiddle(datiMiddleList); if(middleBo){ boolean answerBo = new DatiDao().saveAnswer(answerLst); }else{ request.getSession().setAttribute("result", "答题导入失败!"); } }else{ request.getSession().setAttribute("result", "由于系列导入失败,导致答题导入失败!"); } } }catch(Exception e){ } List<Object> list = this.getLst("", "",user.getUserId()); List<DatiType> datiTypeList =(List<DatiType>)list.get(0); List<Answer> datiList = (List<Answer>)list.get(1); request.getSession().setAttribute("datiList", datiList); request.getSession().setAttribute("datiTypeList", datiTypeList); request.getSession().setAttribute("datiSelected", "0"); request.getSession().setAttribute("content",""); response.sendRedirect("hudong/datiList.jsp"); }else if("setTime".equals(method)){//设置答题时间 setTime setTime = new DatiDao().getSetTime1(); request.getSession().setAttribute("setTime", setTime); request.getSession().setAttribute("result", ""); response.sendRedirect("hudong/setTime.jsp"); }else if("setTimeSubmit".equals(method)){ String minutes = request.getParameter("minutes"); setTime setT = new setTime(); setT.setSetTime(minutes); setT.setId(1); boolean bo = new DatiDao().setTim(setT); if(bo){ request.getSession().setAttribute("result", "时间设置成功"); }else{ request.getSession().setAttribute("result", "时间设置失败"); } setTime setTime = new DatiDao().getSetTime1(); request.getSession().setAttribute("setTime", setTime); response.sendRedirect("hudong/setTime.jsp"); } } public List getLst(String datiType,String content,int userId){ String condition=""; if(datiType.equals("")&&content.equals("")){ }else if(datiType.equals("")&&!content.equals("")){ String middleCondition="answerContent like '%"+content+"%'"; List<DatiMiddle> datiMiddleList = new DatiDao().getDatiMiddle("tb_answer_middle","createTime",middleCondition); String datiMiddleId = ""; if(datiMiddleList!=null&&datiMiddleList.size()>0){ for(DatiMiddle datiMiddle:datiMiddleList){ if(datiMiddleId.equals("")){ datiMiddleId+=datiMiddle.getAnswerMiddleId(); }else{ datiMiddleId+=","+datiMiddle.getAnswerMiddleId(); } } } if(!datiMiddleId.equals("")){ condition="answerMiddleId in("+datiMiddleId+")"; } }else if(!datiType.equals("")&&content.equals("")){ String xilieCondition="answerTypeId='"+datiType+"'"; List<Xulie> xilieList = new DatiTypeDao().getXulieByTypeId("tb_serise", "", xilieCondition); String middleCondition=""; String xilieId = ""; String middleId=""; if(xilieList!=null&&xilieList.size()>0){ for(Xulie xilie:xilieList){ if(xilieId.equals("")){ xilieId+=xilie.getSeriseId(); }else{ xilieId+=","+xilie.getSeriseId(); } } if(!xilieId.equals("")){ middleCondition="seriseId in("+xilieId+")"; List<DatiMiddle> datiMiddleList = new DatiDao().getDatiMiddle("tb_answer_middle","",middleCondition); if(datiMiddleList!=null&&datiMiddleList.size()>0){ for(DatiMiddle datiMid:datiMiddleList){ if(middleId.equals("")){ middleId+=datiMid.getAnswerMiddleId(); }else{ middleId+=","+datiMid.getAnswerMiddleId(); } } } if(!middleId.equals("")){ condition="answerMiddleId in("+middleId+")"; } } } }else if(!datiType.equals("")&&!content.equals("")){ String xilieCondition="answerTypeId='"+datiType+"'"; List<Xulie> xilieList = new DatiTypeDao().getXulieByTypeId("tb_serise", "", xilieCondition); String middleCondition=""; String xilieId = ""; String middleId=""; if(xilieList!=null&&xilieList.size()>0){ for(Xulie xilie:xilieList){ if(xilieId.equals("")){ xilieId+=xilie.getSeriseId(); }else{ xilieId+=","+xilie.getSeriseId(); } } if(!xilieId.equals("")){ middleCondition="seriseId in("+xilieId+") and answerContent like '%"+content+"%'"; List<DatiMiddle> datiMiddleList = new DatiDao().getDatiMiddle("tb_answer_middle","",middleCondition); if(datiMiddleList!=null&&datiMiddleList.size()>0){ for(DatiMiddle datiMid:datiMiddleList){ if(middleId.equals("")){ middleId+=datiMid.getAnswerMiddleId(); }else{ middleId+=","+datiMid.getAnswerMiddleId(); } } } if(!middleId.equals("")){ condition="answerMiddleId in("+middleId+")"; } } } } String datiTypeCondition="userId="+userId; List<DatiType> datiTypeList = new DatiTypeDao().getAllDaTiType("tb_answer_type", "", datiTypeCondition); List<Answer> datiList = new DatiDao().getAnswerList("tb_answer", "answerUpTime", condition); List<Object> list = new ArrayList<Object>(); list.add(datiTypeList); list.add(datiList); return list; } /** * The doPost method of the servlet. <br> * * This method is called when a form has its tag value method equals to post. * * @param request the request send by the client to the server * @param response the response send by the server to the client * @throws ServletException if an error occurred * @throws IOException if an error occurred */ public void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { response.setContentType("text/html"); PrintWriter out = response.getWriter(); doGet(request,response); } /** * Initialization of the servlet. <br> * * @throws ServletException if an error occurs */ public void init() throws ServletException { // Put your code here } /** *@author qingyu zhang *@function: *2011-4-4 *下午02:40:00 *zzClub *com.dati.servlet */ }
zzprojects
trunk/zzprojects/zzClub/src/com/dati/servlet/DatiServlet.java
Java
asf20
28,095
package com.dati.servlet; import java.io.IOException; import java.io.PrintWriter; import java.net.URLEncoder; import java.util.ArrayList; import java.util.List; import java.util.Random; import javax.servlet.ServletException; import javax.servlet.http.HttpServlet; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; import util.AllTypeList; import util.Constant; import util.TotalClass; import util.UtilDAO; import com.UserModule.bean.TbUserBean; import com.dati.bean.Answer; import com.dati.bean.DatiMiddle; import com.dati.bean.DatiType; import com.dati.bean.Xulie; import com.dati.dao.DatiDao; import com.dati.dao.DatiTypeDao; import com.dianbo.bean.DianboType; import com.jifen.bean.JiFen; import com.jifen.dao.JifenDao; public class DatiTypeServlet extends HttpServlet { /** * Constructor of the object. */ public DatiTypeServlet() { super(); } /** * Destruction of the servlet. <br> */ public void destroy() { super.destroy(); // Just puts "destroy" string in log // Put your code here } /** * The doGet method of the servlet. <br> * * This method is called when a form has its tag value method equals to get. * * @param request the request send by the client to the server * @param response the response send by the server to the client * @throws ServletException if an error occurred * @throws IOException if an error occurred */ public void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { //response.setContentType("text/html"); response.setContentType("text/html;charset=UTF-8"); TbUserBean user = (TbUserBean)request.getSession().getAttribute("User"); PrintWriter out = response.getWriter(); String method=request.getParameter("method"); if(method.equals("addType")){//新增一答题类型 response.sendRedirect("jifen/addDatiType.jsp"); }else if(method.equals("addTypeSubmit")){//新增答题类型提交 String datiTypeName = Constant.decodeString(request.getParameter("datiTypeName")); DatiType datiType = new DatiType(); String idNum = Constant.getNum(); datiType.setAnswerTypeId(idNum); datiType.setCreateTime(Constant.decodeDate()); datiType.setTypeName(datiTypeName); datiType.setUserId(user.getUserId()); boolean bo = new DatiTypeDao().addDatiType(datiType); List list = new AllTypeList().getLastValue(user.getUserId()); List<DianboType> dianboTypeList = (ArrayList<DianboType>)list.get(0); StringBuffer sb = (StringBuffer)list.get(1); request.getSession().setAttribute("result", "答题类型新建成功!"); request.getSession().setAttribute("dianboTypeList", dianboTypeList); request.getSession().setAttribute("sb", sb); response.sendRedirect("jifen/jiFenupLoadList.jsp"); }else if(method.equals("modifyType")){//在修改类型时的显示操作 String typeId = request.getParameter("typeId"); DatiType datiType = new DatiTypeDao().getDatiType(typeId); request.getSession().setAttribute("datiType", datiType); response.sendRedirect("jifen/modifyDatiType.jsp?num="+new Random().nextInt(10000)); }else if(method.equals("modifyTypeSubmit")){//修改类型的提交功能 String datiTypeName = Constant.decodeString(request.getParameter("datiTypeName")); String typeId = request.getParameter("datiType"); DatiType datiType = new DatiType(); datiType.setCreateTime(Constant.decodeDate()); datiType.setAnswerTypeId(typeId); datiType.setTypeName(datiTypeName); datiType.setUserId(user.getUserId()); boolean bo = new DatiTypeDao().modifyDatiType(datiType); List list = new AllTypeList().getLastValue(user.getUserId()); List<DianboType> dianboTypeList = (ArrayList<DianboType>)list.get(0); StringBuffer sb = (StringBuffer)list.get(1); if(bo){ request.getSession().setAttribute("result", "答题类型修改成功!"); }else{ request.getSession().setAttribute("result", "答题类型修改失败!"); } request.getSession().setAttribute("dianboTypeList", dianboTypeList); request.getSession().setAttribute("sb", sb); response.sendRedirect("jifen/jiFenupLoadList.jsp"); }else if(method.equals("deleteType")){//删除答题类型 String datiTypeId = request.getParameter("typeId"); System.out.println("删除=datiType==="+datiTypeId); String xilieCondition=" answerTypeId='"+datiTypeId+"'"; List<Xulie> xilieList = new DatiTypeDao().getXulieByTypeId("tb_serise", "", xilieCondition); String seriseIds = ""; if(xilieList!=null&&xilieList.size()>0){ for(Xulie xilie:xilieList){ if(seriseIds.equals("")){ seriseIds+=xilie.getSeriseId(); }else{ seriseIds+=","+xilie.getSeriseId(); } } String datiMidCondition=" seriseId in("+seriseIds+")"; List<DatiMiddle> datiMidList = new DatiDao().getDatiMiddle("tb_answer_middle", "", datiMidCondition); String middleIds = ""; if(datiMidList!=null&&datiMidList.size()>0){ for(DatiMiddle datiMid:datiMidList){ if(middleIds.equals("")){ middleIds+=datiMid.getAnswerMiddleId(); }else{ middleIds+=","+datiMid.getAnswerMiddleId(); } } String answerCondition= " tb_answer where answerMiddleId in("+middleIds+")"; boolean answerBo = UtilDAO.delAll(answerCondition); if(answerBo){ String midCondition=" tb_answer_middle where answerMiddleId in("+middleIds+")"; boolean middBo = UtilDAO.delAll(midCondition); if(middBo){ String xiLCondition=" tb_serise where seriseId in("+seriseIds+")"; boolean xilBo = UtilDAO.delAll(xiLCondition); if(xilBo){ boolean boo = UtilDAO.del("tb_answer_type", "answerTypeId", datiTypeId); if(boo){ request.getSession().setAttribute("result", "答题类型删除成功"); }else{ request.getSession().setAttribute("result", "答题类型删除失败"); } }else{ request.getSession().setAttribute("result", "由于删除答题系列错误导致答题类型删除失败"); } }else{ request.getSession().setAttribute("result", "由于删除答题内容错误导致答题类型删除失败"); } }else{ request.getSession().setAttribute("result", "由于删除答题错误导致答题类型删除失败"); } }else{ String xiLCondition=" tb_serise where seriseId in("+seriseIds+")"; boolean xilBo = UtilDAO.delAll(xiLCondition); if(xilBo){ boolean boo = UtilDAO.del("tb_answer_type", "answerTypeId", datiTypeId); if(boo){ request.getSession().setAttribute("result", "答题类型删除成功"); }else{ request.getSession().setAttribute("result", "答题类型删除失败"); } }else{ request.getSession().setAttribute("result", "由于答题系列删除错误导致答题类型删除失败"); } } }else{ boolean boo = UtilDAO.del("tb_answer_type", "answerTypeId", datiTypeId); if(boo){ request.getSession().setAttribute("result", "答题类型删除成功"); }else{ request.getSession().setAttribute("result", "答题类型删除失败"); } } /*boolean bo = UtilDAO.del("tb_serise", "answerTypeId", datiTypeId); if(bo){ boolean boo = UtilDAO.del("tb_answer_type", "answerTypeId", datiTypeId); if(boo){ request.getSession().setAttribute("result", "删除成功!"); }else{ request.getSession().setAttribute("result", "删除失败!"); } }else{ request.getSession().setAttribute("result", "删除失败!"); }*/ List list = new AllTypeList().getLastValue(user.getUserId()); List<DianboType> dianboTypeList = (ArrayList<DianboType>)list.get(0); StringBuffer sb = (StringBuffer)list.get(1); request.getSession().setAttribute("dianboTypeList", dianboTypeList); request.getSession().setAttribute("sb", sb); response.sendRedirect("jifen/jiFenupLoadList.jsp"); }else if(method.equals("addXiLie")){ String typeId = request.getParameter("typeId"); request.getSession().setAttribute("typeId", typeId); response.sendRedirect("jifen/addXiLie.jsp?num="+new Random().nextInt(10000000)); }else if(method.equals("addXilieSubmit")){//新增系列提交 String typeId=request.getParameter("typeId"); String xilieName = Constant.decodeString(request.getParameter("xilieName")); Xulie xulie = new Xulie(); xulie.setAnswerTypeId(typeId); xulie.setCreateTime(Constant.decodeDate()); xulie.setSeriseId(Constant.getNum()); xulie.setSeriseName(xilieName); boolean bo = new DatiTypeDao().addXulie(xulie); List list = new AllTypeList().getLastValue(user.getUserId()); List<DianboType> dianboTypeList = (ArrayList<DianboType>)list.get(0); StringBuffer sb = (StringBuffer)list.get(1); if(bo){ request.getSession().setAttribute("result", "答题系列新建成功!"); }else{ request.getSession().setAttribute("result", "答题系列新建失败!"); } request.getSession().setAttribute("dianboTypeList", dianboTypeList); request.getSession().setAttribute("sb", sb); response.sendRedirect("jifen/jiFenupLoadList.jsp?num="+new Random().nextInt(10000000)); }else if(method.equals("modifyXilie")){//修改系列 String xilieId = request.getParameter("xilieId"); System.out.println("xilieId==="+xilieId); Xulie xl = new DatiTypeDao().getXulie(xilieId); request.getSession().setAttribute("xilie", xl); response.sendRedirect("jifen/modifyDatiXilie.jsp?num="+new Random().nextInt(10000)); }else if(method.equals("modifyXilieSubmit")){//修改系列提交 String xilieId = request.getParameter("xilieId"); String xilieName = Constant.decodeString(request.getParameter("xilieName")); Xulie xl = new Xulie(); xl.setCreateTime(Constant.decodeDate()); xl.setSeriseId(xilieId); xl.setSeriseName(xilieName); boolean bo = new DatiTypeDao().modifyXulie(xl); List list = new AllTypeList().getLastValue(user.getUserId()); List<DianboType> dianboTypeList = (ArrayList<DianboType>)list.get(0); StringBuffer sb = (StringBuffer)list.get(1); if(bo){ request.getSession().setAttribute("result", "答题系列修改成功!"); }else{ request.getSession().setAttribute("result", "答题系列修改失败!"); } request.getSession().setAttribute("dianboTypeList", dianboTypeList); request.getSession().setAttribute("sb", sb); response.sendRedirect("jifen/jiFenupLoadList.jsp?num="+new Random().nextInt(10000000)); }else if(method.equals("deleteXilie")){//删除某个系列 String xilieId = request.getParameter("xilieId"); //boolean bo = UtilDAO.del("tb_serise", "seriseId", xilieId); String datiMidCondition=" seriseId ='"+xilieId+"'"; List<DatiMiddle> datiMidList = new DatiDao().getDatiMiddle("tb_answer_middle", "", datiMidCondition); String middleIds = ""; if(datiMidList!=null&&datiMidList.size()>0){ for(DatiMiddle datiMid:datiMidList){ if(middleIds.equals("")){ middleIds+=datiMid.getAnswerMiddleId(); }else{ middleIds+=","+datiMid.getAnswerMiddleId(); } } String answerCondition= " tb_answer where answerMiddleId in("+middleIds+")"; boolean answerBo = UtilDAO.delAll(answerCondition); if(answerBo){ String midCondition=" tb_answer_middle where answerMiddleId in("+middleIds+")"; boolean middBo = UtilDAO.delAll(midCondition); if(middBo){ String xiLCondition=" tb_serise where seriseId ='"+xilieId+"'"; boolean xilBo = UtilDAO.delAll(xiLCondition); if(xilBo){ request.getSession().setAttribute("result", "系列删除成功"); }else{ request.getSession().setAttribute("result", "系列删除失败"); } }else{ request.getSession().setAttribute("result", "由于删除答题内容错误导致答题系列删除失败"); } }else{ request.getSession().setAttribute("result", "由于删除答题错误导致答题系列删除失败"); } }else{ String xiLCondition=" tb_serise where seriseId ='"+xilieId+"'"; boolean xilBo = UtilDAO.delAll(xiLCondition); if(xilBo){ request.getSession().setAttribute("result", "系列删除成功"); }else{ request.getSession().setAttribute("result", "系列删除失败"); } } List list = new AllTypeList().getLastValue(user.getUserId()); List<DianboType> dianboTypeList = (ArrayList<DianboType>)list.get(0); StringBuffer sb = (StringBuffer)list.get(1); request.getSession().setAttribute("dianboTypeList", dianboTypeList); request.getSession().setAttribute("sb", sb); response.sendRedirect("jifen/jiFenupLoadList.jsp?num="+new Random().nextInt(10000000)); }else if(method.equals("setJiFen")){//设置积分 String xilieId = request.getParameter("xilieId"); Xulie xi = new DatiTypeDao().getXulie(xilieId); request.getSession().setAttribute("xilie", xi); response.sendRedirect("jifen/jiFenupLoadSetDati.jsp?num="+new Random().nextInt(10000000)); }else if("getXilieByTypeId".equals(method)){//根据答题类型的ID得到此类型的系列 //response.setContentType("Content-Type:text/html;charset=utf-8"); String typeId = request.getParameter("typeId"); System.out.println("typeId=="+typeId); String condition="answerTypeId='"+typeId+"'";// List<Xulie> xilieList = new DatiTypeDao().getXulieByTypeId("tb_serise", "createTime", condition); StringBuffer sb = new StringBuffer(); sb.append("<select id=\"xilieSelect\" name=\"xilieSelect\" onchange=\"selectXilie(xilieSelect.value)\">"); sb.append("<option value=\"0\">选择系列</option>"); if(xilieList!=null&&xilieList.size()>0){ for(Xulie xilie:xilieList){ sb.append("<option value=\""+xilie.getSeriseId()+"\">"+xilie.getSeriseName()+"</option>"); } } sb.append("</select><input type=\"hidden\" name=\"xilie_Type\" id=\"xilie_Type\" value=\"0\"/>"); System.out.println("sb=="+sb); String lastStr = URLEncoder.encode(sb.toString(), "UTF-8"); String str = lastStr.replaceAll("\\+", " "); System.out.println("lastStr=="+str); out.println(str); //out.println("张庆玉"); }else if("getXilieValue".equals(method)){ String xilieId = request.getParameter("xilieId"); String condition = "seriseId='"+xilieId+"' and integralType=0"; JiFen jifen = new JifenDao().getJiFen("tb_integral", "setTime", condition); String fenshu = ""; if(jifen==null){ fenshu="0"; }else fenshu = jifen.getIntegralValue(); out.println(fenshu); } } /** * The doPost method of the servlet. <br> * * This method is called when a form has its tag value method equals to post. * * @param request the request send by the client to the server * @param response the response send by the server to the client * @throws ServletException if an error occurred * @throws IOException if an error occurred */ public void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { response.setContentType("text/html"); PrintWriter out = response.getWriter(); doGet(request,response); } /** * Initialization of the servlet. <br> * * @throws ServletException if an error occurs */ public void init() throws ServletException { // Put your code here } /** *@author qingyu zhang *@function: *2011-4-4 *下午02:41:24 *zzClub *com.dati.servlet */ }
zzprojects
trunk/zzprojects/zzClub/src/com/dati/servlet/DatiTypeServlet.java
Java
asf20
15,929
package com.dati.dao; import java.sql.ResultSet; import java.sql.SQLException; import java.sql.Statement; import java.util.ArrayList; import java.util.List; import util.TotalClass; import util.UtilDAO; import com.dati.bean.DatiType; import com.dati.bean.Xulie; public class DatiTypeDao { /** *@author qingyu zhang *@function: *2011-4-4 *下午02:41:48 *zzClub *com.dati.dao */ private ResultSet rs = null; // 成功失败标志 private boolean flag = false; private Statement st = null; // 要执行的语句 private String sql = ""; private List<DatiType> datiTypeList = null; private List<Xulie> xulieList = null; /** * *@author qingyu zhang *@function: * @param datiType * @return *2011-4-6 *下午04:31:46 *zzClub *com.dati.dao *boolean */ public boolean addDatiType(DatiType datiType){ boolean bo = false; sql = "insert into tb_answer_type (answerTypeId,userId,typeName,createTime)" + " values('"+datiType.getAnswerTypeId()+"',"+datiType.getUserId()+",'"+datiType.getTypeName()+"','"+datiType.getCreateTime()+"')"; bo = new TotalClass().operatorObject(sql); return bo; } /** * *@author qingyu zhang *@function:根据条件得到符合条件的答题类型 * @param table * @param order * @param condition * @return *2011-4-7 *上午09:10:54 *zzClub *com.dati.dao *List<DatiType> */ public List<DatiType> getAllDaTiType(String table,String order,String condition){ sql=UtilDAO.getList(table, order, condition); System.out.println("语句=="+sql); rs = new TotalClass().getResult(sql); try { while(rs.next()){ if(datiTypeList==null){ datiTypeList= new ArrayList<DatiType>(); } datiTypeList.add(this.getDatiType(rs)); } } catch (SQLException e) { // TODO Auto-generated catch block e.printStackTrace(); }finally{ return datiTypeList; } } public DatiType getDatiType(ResultSet rs){ DatiType dt = new DatiType(); try { dt.setAnswerTypeId(rs.getString("answerTypeId")); dt.setCreateTime(rs.getString("createTime")); dt.setTypeName(rs.getString("typeName")); dt.setUserId(rs.getInt("userId")); } catch (SQLException e) { // TODO Auto-generated catch block e.printStackTrace(); } return dt; } /** * *@author qingyu zhang *@function: * @param typeId * @return *2011-4-7 *下午02:02:54 *zzClub *com.dati.dao *DatiType */ public DatiType getDatiType(String typeId){ DatiType datiType = null; sql="select * from tb_answer_type where answerTypeId='"+typeId+"'"; rs= new TotalClass().getResult(sql); try { while(rs.next()){ if(datiType==null){ datiType = new DatiType(); } datiType = this.getDatiType(rs); } } catch (SQLException e) { // TODO Auto-generated catch block e.printStackTrace(); } return datiType; } /** * *@author qingyu zhang *@function:根据答题的类型来取得此答题类型下的系列 * @param table * @param order * @param condition * @return *2011-4-7 *上午09:20:34 *zzClub *com.dati.dao *List<Xulie> */ public List<Xulie> getXulieByTypeId(String table,String order,String condition){ sql=UtilDAO.getList(table, order, condition); System.out.println("系列语句="+sql); rs = new TotalClass().getResult(sql); try { while(rs.next()){ if(xulieList==null){ xulieList = new ArrayList<Xulie>(); } xulieList.add(this.getXulie(rs)); } } catch (SQLException e) { // TODO Auto-generated catch block e.printStackTrace(); } return xulieList; } public Xulie getXulie(ResultSet rs){ Xulie xl = new Xulie(); try { xl.setAnswerTypeId(rs.getString("answerTypeId")); xl.setCreateTime(rs.getString("createTime")); xl.setSeriseName(rs.getString("seriseName")); xl.setSeriseId(rs.getString("seriseId")); } catch (SQLException e) { // TODO Auto-generated catch block e.printStackTrace(); } return xl; } public boolean modifyDatiType(DatiType dt){ boolean bo = false; sql = "update tb_answer_type set typeName='"+dt.getTypeName()+"',createTime='"+dt.getCreateTime()+"' where answerTypeId='"+dt.getAnswerTypeId()+"'"; System.out.println("sql=="+sql); bo = new TotalClass().operatorObject(sql); return bo ; } /** * *@author qingyu zhang *@function:新增系列 * @param xulie * @return *2011-4-7 *下午03:52:54 *zzClub *com.dati.dao *boolean */ public boolean addXulie(Xulie xulie){ boolean bo = false; sql="insert into tb_serise (seriseId,answerTypeId,seriseName,createTime) " + "values('"+xulie.getSeriseId()+"','"+xulie.getAnswerTypeId()+"','"+xulie.getSeriseName()+"','"+xulie.getCreateTime()+"')"; bo = new TotalClass().operatorObject(sql); return bo ; } /** * *@author qingyu zhang *@function:根据系列的ID得到此系列对象 * @param xilie * @return *2011-4-8 *上午07:47:54 *zzClub *com.dati.dao *Xulie */ public Xulie getXulie(String xilie){ Xulie xl = new Xulie(); sql = "select * from tb_serise where seriseId='"+xilie+"'"; System.out.println("修改系列="+sql); rs = new TotalClass().getResult(sql); try { if(rs.next()){ xl = this.getXulie(rs); } } catch (SQLException e) { // TODO Auto-generated catch block e.printStackTrace(); } return xl; } /** * *@author qingyu zhang *@function:修改系列名称 * @param xl * @return *2011-4-8 *上午08:09:48 *zzClub *com.dati.dao *boolean */ public boolean modifyXulie(Xulie xl){ boolean bo = false; sql = "update tb_serise set seriseName='"+xl.getSeriseName()+"' ,createTime='"+xl.getCreateTime()+"' where seriseId='"+xl.getSeriseId()+"'"; bo = new TotalClass().operatorObject(sql); return bo ; } /** * 把系列名称存放到一个LIST中 *@author qingyu zhang *@function: * @param xilie * @return *2011-4-18 *下午03:12:42 *zzClub *com.dati.dao *List<String> */ public List<String> getXilieNameList(List<Xulie> xilie){ List<String> list = new ArrayList<String>(); if(xilie!=null&&xilie.size()>0){ for(Xulie xl:xilie){ list.add(xl.getSeriseName()); } } return list; } /** * 批量导入答题类型 *@author qingyu zhang *@function: * @param datiTypeList * @return *2011-4-18 *下午09:52:22 *zzClub *com.dati.dao *boolean */ public boolean saveDatiType(List<DatiType> datiTypeList){ boolean bo = false; st = new TotalClass().getStatement(); try{ for(DatiType datiType:datiTypeList){ String hql = "insert into tb_answer_type (answerTypeId,userId,typeName,createTime) " + "values('"+datiType.getAnswerTypeId()+"',"+datiType.getUserId()+",'"+datiType.getTypeName()+"','"+datiType.getCreateTime()+"')"; System.out.println("类型语句"+hql); st.addBatch(hql); } st.executeBatch(); bo = true; }catch(Exception e){ e.printStackTrace(); } return bo; } /** * 批量导入系列 *@author qingyu zhang *@function: * @param xilieList * @return *2011-4-18 *下午09:57:07 *zzClub *com.dati.dao *boolean */ public boolean saveXilie(List<Xulie> xilieList){ boolean bo = false; st = new TotalClass().getStatement(); try{ for(Xulie xilie:xilieList){ String hql = "insert into tb_serise (seriseId,answerTypeId,seriseName,createTime) " + "values('"+xilie.getSeriseId()+"','"+xilie.getAnswerTypeId()+"','"+xilie.getSeriseName()+"','"+xilie.getCreateTime()+"')"; System.out.println("系列"+hql); st.addBatch(hql); } st.executeBatch(); bo = true; }catch(Exception e){ e.printStackTrace(); } return bo; } }
zzprojects
trunk/zzprojects/zzClub/src/com/dati/dao/DatiTypeDao.java
Java
asf20
7,961
package com.dati.dao; import java.sql.PreparedStatement; import java.sql.ResultSet; import java.sql.SQLException; import java.sql.Statement; import java.util.ArrayList; import java.util.List; import util.TotalClass; import util.UtilDAO; import com.dati.bean.Answer; import com.dati.bean.Daan; import com.dati.bean.Dati; import com.dati.bean.DatiMiddle; import com.dati.bean.SendDati; import com.dati.bean.setTime; public class DatiDao { /** *@author qingyu zhang *@function: *2011-4-4 *下午02:42:01 *zzClub *com.dati.dao */ private ResultSet rs =null; private Statement st = null; private PreparedStatement pt = null; private String sql = ""; private List<Dati> datiList = null; private List<DatiMiddle> datiMiddle = null; private List<SendDati> sendDatiList = null; private List<Daan> daanList = null; public DatiDao(){ } /** * *@author qingyu zhang *@function: * @param table * @param order * @param condition * @return *2011-4-13 *上午10:51:23 *zzClub *com.dati.dao *List<Dati> */ public List<Dati> getDatiList(String table,String order,String condition){ sql = UtilDAO.getList(table, order, condition); rs = new TotalClass().getResult(sql); try { while(rs.next()){ if(datiList==null){ datiList = new ArrayList<Dati>(); } datiList.add(this.getDati(rs)); } } catch (SQLException e) { // TODO Auto-generated catch block e.printStackTrace(); } return datiList; } public Dati getDati(ResultSet rs){ Dati dati = new Dati(); try { dati.setDatiId(rs.getInt("datiId")); dati.setSendPhone(rs.getString("sendPhone")); dati.setSmscontent(rs.getString("smscontent")); dati.setState(rs.getInt("state")); } catch (SQLException e) { // TODO Auto-generated catch block e.printStackTrace(); } return dati; } /** * *@author qingyu zhang *@function: * @param table * @param order * @param condition * @return *2011-4-13 *上午11:28:36 *zzClub *com.dati.dao *List<DatiMiddle> */ public List<DatiMiddle> getDatiMiddle(String table,String order,String condition){ sql = UtilDAO.getList(table, order, condition); System.out.println("sql$$$$$$$$$$$"+sql); rs = new TotalClass().getResult(sql); try { while(rs.next()){ if(datiMiddle==null){ datiMiddle = new ArrayList<DatiMiddle>(); } datiMiddle.add(this.getDatiMiddle(rs)); } } catch (SQLException e) { // TODO Auto-generated catch block e.printStackTrace(); } return datiMiddle; } public DatiMiddle getDatiMiddle(ResultSet rs){ DatiMiddle datiMiddle = new DatiMiddle(); try { datiMiddle.setAnswerContent(rs.getString("answerContent")); datiMiddle.setAnswerMiddleId(rs.getString("answerMiddleId")); datiMiddle.setCreateTime(rs.getString("createTime")); datiMiddle.setRightAnswer(rs.getString("rightAnswer")); datiMiddle.setSeriseId(rs.getString("seriseId")); } catch (SQLException e) { // TODO Auto-generated catch block e.printStackTrace(); } return datiMiddle; } public String getSetTime(){ sql="select * from setTime"; rs = new TotalClass().getResult(sql); String time =""; try { if(rs.next()){ time = rs.getString("setTime"); } } catch (SQLException e) { // TODO Auto-generated catch block e.printStackTrace(); } return time; } /** * 把答题 的类型状态修改成1 *@author qingyu zhang *@function: * @param datiId * @return *2011-4-13 *下午01:50:59 *zzClub *com.dati.dao *boolean */ public boolean modifyDati(String datiId){ boolean bo= false; sql = "update tb_send_dati set state =1 where datiId in("+datiId+")"; st= new TotalClass().getStatement(); try { bo = st.execute(sql); bo = true; } catch (SQLException e) { // TODO Auto-generated catch block e.printStackTrace(); } return bo; } /** * *@author qingyu zhang *@function: * @param id * @return *2011-4-13 *下午02:28:12 *zzClub *com.dati.dao *boolean */ public boolean modifySendDati(String middleId,String phone){ boolean bo = false; sql="update sendDati set state=1 where answerMiddleId='"+middleId+"' and state=0 and phone='"+phone+"'"; System.out.println("修改状态"+sql); st = new TotalClass().getStatement(); try { bo = st.execute(sql); bo = true; } catch (SQLException e) { // TODO Auto-generated catch block e.printStackTrace(); } return bo ; } /** * *@author qingyu zhang *@function:根据条件得到sendDati中状态为1 的记录 * @param table * @param order * @param condition * @return *2011-4-13 *下午02:52:42 *zzClub *com.dati.dao *List<SendDati> */ public List<SendDati> getSendDati(String table,String order,String condition){ sql = UtilDAO.getList(table, order, condition); System.out.println("sql##########"+sql); rs = new TotalClass().getResult(sql); try { while(rs.next()){ if(sendDatiList==null){ sendDatiList = new ArrayList<SendDati>(); } sendDatiList.add(this.getSendDati(rs)); } } catch (SQLException e) { // TODO Auto-generated catch block e.printStackTrace(); } return sendDatiList; } public SendDati getSendDati(ResultSet rs){ SendDati sendDati = new SendDati(); try { sendDati.setAnswerMiddleId(rs.getString("answerMiddleId")); sendDati.setCreateTime(rs.getString("createTime")); sendDati.setEndTime(rs.getString("endTime")); sendDati.setId(rs.getInt("id")); sendDati.setPhone(rs.getString("phone")); sendDati.setRightOrno(rs.getInt("rightOrno")); sendDati.setSeriseId(rs.getString("seriseId")); sendDati.setState(rs.getInt("state")); } catch (SQLException e) { // TODO Auto-generated catch block e.printStackTrace(); } return sendDati; } /** * *@author qingyu zhang *@function:得到上传上来的题目答案 * @param table * @param condition * @param order * @return *2011-4-13 *下午04:45:42 *zzClub *com.dati.dao *List<Daan> */ public List<Daan> getDaanList(String table,String condition,String order){ sql = UtilDAO.getList(table, order, condition); rs = new TotalClass().getResult(sql); try { while(rs.next()){ if(daanList==null){ daanList = new ArrayList<Daan>(); } daanList.add(this.getDaan(rs)); } } catch (SQLException e) { // TODO Auto-generated catch block e.printStackTrace(); } return daanList; } public Daan getDaan(ResultSet rs){ Daan daan = new Daan(); try { daan.setDaAn(rs.getString("daAn")); daan.setId(rs.getInt("id")); daan.setPhone(rs.getString("phone")); daan.setState(rs.getInt("state")); daan.setTimuId(rs.getString("timuId")); } catch (SQLException e) { // TODO Auto-generated catch block e.printStackTrace(); } return daan; } /** * 在分拣时根据手机号码与上传的信息ID得到此记录的中间表ID *@author qingyu zhang *@function: * @param table * @param order * @param condition * @return *2011-4-14 *上午11:46:36 *zzClub *com.dati.dao *List<Answer> */ public List<Answer> getAnswerList(String table,String order,String condition){ List<Answer> answerList = null; sql = UtilDAO.getList(table, order, condition); System.out.println("搜索"+sql); rs = new TotalClass().getResult(sql); try { while(rs.next()){ if(answerList==null){ answerList =new ArrayList<Answer>(); } answerList.add(this.getAnswer(rs)); } } catch (SQLException e) { // TODO Auto-generated catch block e.printStackTrace(); } return answerList; } public Answer getAnswer(ResultSet rs){ Answer answer = new Answer(); try { answer.setAnswerId(rs.getInt("answerId")); answer.setAnswerIntegral(rs.getString("answerIntegral")); answer.setAnswerMiddleId(rs.getString("answerMiddleId")); answer.setAnswerUpPhone(rs.getString("answerUpPhone")); answer.setAnswerUpTime(rs.getString("answerUpTime")); answer.setReceiveId(rs.getInt("receiveId")); } catch (SQLException e) { // TODO Auto-generated catch block e.printStackTrace(); } return answer; } public boolean saveDatiMiddle(DatiMiddle middle){ sql="insert into tb_answer_middle (answerMiddleId,seriseId,answerContent,createTime,rightAnswer) " + "values('"+middle.getAnswerMiddleId()+"','"+middle.getSeriseId()+"','"+middle.getAnswerContent()+"','"+middle.getCreateTime() +"','"+middle.getRightAnswer()+"')"; System.out.println("插入语句"+sql); boolean bo = new TotalClass().operatorObject(sql); return bo; } public boolean saveAnswer(Answer answer){ sql="insert into tb_answer (answerMiddleId,receiveId,answerUpPhone,answerUpTime,answerIntegral) " + "values('"+answer.getAnswerMiddleId()+"',"+answer.getReceiveId()+",'"+answer.getAnswerUpPhone()+"','"+answer.getAnswerUpTime()+"','"+answer.getAnswerIntegral()+"')"; boolean bo = new TotalClass().operatorObject(sql); return bo; } /** * 批量导入中间表数据 *@author qingyu zhang *@function: * @param middleList * @return *2011-4-18 *下午10:01:06 *zzClub *com.dati.dao *boolean */ public boolean saveMiddle(List<DatiMiddle> middleList){ boolean bo = false; st = new TotalClass().getStatement(); try{ for(DatiMiddle middle:middleList){ String hql = "insert into tb_answer_middle (answerMiddleId,seriseId,answerContent,createTime,rightAnswer) " + "values('"+middle.getAnswerMiddleId()+"','"+middle.getSeriseId()+"','"+middle.getAnswerContent()+"','"+middle.getCreateTime()+"','"+middle.getRightAnswer()+"')"; st.addBatch(hql); } st.executeBatch(); bo = true; }catch(Exception e){ e.printStackTrace(); } return bo; } /** * 批量导入答题 *@author qingyu zhang *@function: * @param answerList * @return *2011-4-18 *下午10:06:05 *zzClub *com.dati.dao *boolean */ public boolean saveAnswer(List<Answer> answerList){ boolean bo = false; st = new TotalClass().getStatement(); try{ for(Answer answer:answerList){ String hql = "insert into tb_answer (answerMiddleId,receiveId,answerUpPhone,answerUpTime,answerIntegral) " + "values('"+answer.getAnswerMiddleId()+"',"+answer.getReceiveId()+",'"+answer.getAnswerUpPhone()+"','"+answer.getAnswerUpTime()+"','"+answer.getAnswerIntegral()+"')"; st.addBatch(hql); } st.executeBatch(); bo = true; }catch(Exception e){ e.printStackTrace(); } return bo; } /** * 得到设置答题 的时间 *@author qingyu zhang *@function: * @return *2011-4-19 *上午10:38:34 *zzClub *com.dati.dao *setTime */ public setTime getSetTime1(){ setTime setT = new setTime(); sql="select * from setTime where id=1"; rs = new TotalClass().getResult(sql); try { if(rs.next()){ setT = this.getSetTime(rs); } } catch (SQLException e) { // TODO Auto-generated catch block e.printStackTrace(); } return setT; } public setTime getSetTime(ResultSet rs){ setTime setT = new setTime(); try { setT.setId(rs.getInt("id")); setT.setSetTime(rs.getString("setTime")); } catch (SQLException e) { // TODO Auto-generated catch block e.printStackTrace(); } return setT; } /** * 设置答题时间 *@author qingyu zhang *@function: * @param setT * @return *2011-4-19 *上午10:55:39 *zzClub *com.dati.dao *boolean */ public boolean setTim(setTime setT){ boolean bo = false; sql = "update setTime set setTime='"+setT.getSetTime()+"' where id="+setT.getId(); st = new TotalClass().getStatement(); try { bo = st.execute(sql); bo = true; } catch (SQLException e) { // TODO Auto-generated catch block e.printStackTrace(); } return bo; } }
zzprojects
trunk/zzprojects/zzClub/src/com/dati/dao/DatiDao.java
Java
asf20
12,158
package com.SmsModule.bean; import java.io.Serializable; import java.util.Date; public class TbSmsSend implements Serializable{ /** * 短信发送表 * jhc * 2011-1-27下午01:31:31 */ public TbSmsSend(){ } /** * 张庆玉 */ private int smsId; private int userId; private String smsContent; private int smsSendState;//发送状态 0未发送 1发送成功 2发送失败 private String sendTime; private String destAdd; private String createTime; private int isSendTime;//是否定时发送 private String seriseId;//系列号(3)+题目(5) /** * END */ public int getSmsId() { return smsId; } public void setSmsId(int smsId) { this.smsId = smsId; } public int getUserId() { return userId; } public void setUserId(int userId) { this.userId = userId; } public String getSmsContent() { return smsContent; } public void setSmsContent(String smsContent) { this.smsContent = smsContent; } public int getSmsSendState() { return smsSendState; } public void setSmsSendState(int smsSendState) { this.smsSendState = smsSendState; } public String getSendTime() { return sendTime; } public void setSendTime(String sendTime) { this.sendTime = sendTime; } public String getDestAdd() { return destAdd; } public void setDestAdd(String destAdd) { this.destAdd = destAdd; } public String getCreateTime() { return createTime; } public void setCreateTime(String createTime) { this.createTime = createTime; } public int getIsSendTime() { return isSendTime; } public void setIsSendTime(int isSendTime) { this.isSendTime = isSendTime; } public String getSeriseId() { return seriseId; } public void setSeriseId(String seriseId) { this.seriseId = seriseId; } }
zzprojects
trunk/zzprojects/zzClub/src/com/SmsModule/bean/TbSmsSend.java
Java
asf20
1,865
package com.SmsModule.bean; import java.util.Date; public class TbSmsSendContent { /** * 短信内容表 * jhc * 2011-1-27下午01:31:10 */ public TbSmsSendContent(){ } /** * 短信内容id */ private String smsSendContentId; /** * 短信类型id */ private int typeId; /** * 短信内容 */ private String smsSendContent; /** * 用户特服号码 */ private String orgNum; /** * 用户id */ private int userId; /** * 审核状态 0未审核 1审核成功 2审核失败 */ private int reviewState; /** * 创建时间 */ private String createTime; public String getSmsSendContentId() { return smsSendContentId; } public void setSmsSendContentId(String smsSendContentId) { this.smsSendContentId = smsSendContentId; } public int getTypeId() { return typeId; } public void setTypeId(int typeId) { this.typeId = typeId; } public String getSmsSendContent() { return smsSendContent; } public void setSmsSendContent(String smsSendContent) { this.smsSendContent = smsSendContent; } public String getOrgNum() { return orgNum; } public void setOrgNum(String orgNum) { this.orgNum = orgNum; } public int getUserId() { return userId; } public void setUserId(int userId) { this.userId = userId; } public int getReviewState() { return reviewState; } public void setReviewState(int reviewState) { this.reviewState = reviewState; } public String getCreateTime() { return createTime; } public void setCreateTime(String createTime) { this.createTime = createTime; } }
zzprojects
trunk/zzprojects/zzClub/src/com/SmsModule/bean/TbSmsSendContent.java
Java
asf20
1,682
package com.SmsModule.bean; import java.io.Serializable; public class TbCommonPhrase implements Serializable{ /** * 常用短语 * jhc * */ public TbCommonPhrase(){ } private int phraseId; private String phraseContent; private int useCount; private int userId; private String createTime; public int getPhraseId() { return phraseId; } public void setPhraseId(int phraseId) { this.phraseId = phraseId; } public String getPhraseContent() { return phraseContent; } public void setPhraseContent(String phraseContent) { this.phraseContent = phraseContent; } public int getUseCount() { return useCount; } public void setUseCount(int useCount) { this.useCount = useCount; } public int getUserId() { return userId; } public void setUserId(int userId) { this.userId = userId; } public String getCreateTime() { return createTime; } public void setCreateTime(String createTime) { this.createTime = createTime; } }
zzprojects
trunk/zzprojects/zzClub/src/com/SmsModule/bean/TbCommonPhrase.java
Java
asf20
1,025
package com.SmsModule.bean; import java.io.Serializable; import java.util.Date; public class TbSmsReceive implements Serializable{ /** * 短信接收表 * jhc * 2011-1-27上午11:06:50 */ public TbSmsReceive(){ } /** * 接收短信的编号id */ private int receiveId; /** * 接收短信内容 */ private String receiveContent; /** * 发送号码 */ private String sendPhone; /** * 特服号码 */ private String orgNum; /** * 回复的短信类型 */ private int receiveType; /** * 接收时间 */ private String receiveTime; private int state;//是否分拣0:未分拣1:分拣 public int getReceiveId() { return receiveId; } public void setReceiveId(int receiveId) { this.receiveId = receiveId; } public String getReceiveContent() { return receiveContent; } public void setReceiveContent(String receiveContent) { this.receiveContent = receiveContent; } public String getSendPhone() { return sendPhone; } public void setSendPhone(String sendPhone) { this.sendPhone = sendPhone; } public String getOrgNum() { return orgNum; } public void setOrgNum(String orgNum) { this.orgNum = orgNum; } public int getReceiveType() { return receiveType; } public void setReceiveType(int receiveType) { this.receiveType = receiveType; } public String getReceiveTime() { return receiveTime; } public void setReceiveTime(String receiveTime) { this.receiveTime = receiveTime; } public int getState() { return state; } public void setState(int state) { this.state = state; } }
zzprojects
trunk/zzprojects/zzClub/src/com/SmsModule/bean/TbSmsReceive.java
Java
asf20
1,863
package com.SmsModule.bean; public class TbSendType { /** * 发送类型表 * jhc * 2011-1-27下午01:32:22 */ public TbSendType(){ } /** * 类型编号 */ private int typeId; /** * 类型名称 */ private String typeName; /** * 创建时间 */ private String createTime; public int getTypeId() { return typeId; } public void setTypeId(int typeId) { this.typeId = typeId; } public String getTypeName() { return typeName; } public void setTypeName(String typeName) { this.typeName = typeName; } public String getCreateTime() { return createTime; } public void setCreateTime(String createTime) { this.createTime = createTime; } }
zzprojects
trunk/zzprojects/zzClub/src/com/SmsModule/bean/TbSendType.java
Java
asf20
781
package com.SmsModule.bean; import java.io.Serializable; public class TbSmsSc implements Serializable{ /** *@author qingyu zhang *@function: *2011-4-12 *下午10:51:46 *zzClub *com.SmsModule.bean */ private int smsId; private String destAdd; private String smscontent; private String sendPhone; private int smsType; private String createTime; public int getSmsId() { return smsId; } public void setSmsId(int smsId) { this.smsId = smsId; } public String getDestAdd() { return destAdd; } public void setDestAdd(String destAdd) { this.destAdd = destAdd; } public String getSmscontent() { return smscontent; } public void setSmscontent(String smscontent) { this.smscontent = smscontent; } public String getSendPhone() { return sendPhone; } public void setSendPhone(String sendPhone) { this.sendPhone = sendPhone; } public int getSmsType() { return smsType; } public void setSmsType(int smsType) { this.smsType = smsType; } public String getCreateTime() { return createTime; } public void setCreateTime(String createTime) { this.createTime = createTime; } }
zzprojects
trunk/zzprojects/zzClub/src/com/SmsModule/bean/TbSmsSc.java
Java
asf20
1,182
package com.SmsModule.servlet; import gonggong.GetJifen; import java.io.BufferedReader; import java.io.File; import java.io.FileInputStream; import java.io.FileReader; import java.io.IOException; import java.io.InputStream; import java.io.PrintWriter; import java.sql.Timestamp; import java.text.SimpleDateFormat; import java.util.ArrayList; import java.util.Date; import java.util.List; import java.util.Random; import javax.servlet.ServletException; import javax.servlet.http.HttpServlet; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; import jxl.Cell; import jxl.Sheet; import jxl.Workbook; import util.Constant; import util.QunfaThree; import util.UtilDAO; import com.AddressListModule.bean.KehujifenBean; import com.BlackPhoneModule.bean.BlackPhoneBean; import com.BlackPhoneModule.dao.BlackPhoneModuleDao; import com.SmsModule.bean.TbSmsReceive; import com.SmsModule.bean.TbSmsSc; import com.SmsModule.bean.TbSmsSend; import com.SmsModule.dao.TbSmsScDAO; import com.SmsModule.dao.TbSmsSendDAO; import com.UserModule.bean.TbUserBean; import com.dati.bean.Answer; import com.dati.bean.DatiMiddle; import com.dati.bean.DatiType; import com.dati.dao.DatiDao; import com.dati.dao.DatiTypeDao; import com.dianbo.bean.Dianbo; import com.dianbo.bean.DianboType; import com.dianbo.dao.DianboDao; import com.dianbo.dao.DianboTypeDao; import com.jifen.dao.JifenDao; import com.jspsmart.upload.SmartUpload; public class TbSmsServlet extends HttpServlet { /** * Destruction of the servlet. <br> */ public void destroy() { super.destroy(); // Just puts "destroy" string in log // Put your code here } /** * The doGet method of the servlet. <br> * * This method is called when a form has its tag value method equals to get. * * @param request the request send by the client to the server * @param response the response send by the server to the client * @throws ServletException if an error occurred * @throws IOException if an error occurred */ public void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { response.setContentType("text/html"); response.setCharacterEncoding("utf-8"); response.setContentType("text/html;charset=utf-8"); PrintWriter out = response.getWriter(); String method = request.getParameter("method"); String nowDate = Constant.decodeDate();//当前时间 TbUserBean tbUser=(TbUserBean)request.getSession().getAttribute("User"); TbSmsSendDAO tbsmssend=new TbSmsSendDAO(); if(method.equals("upLoad")){ SmartUpload su = new SmartUpload(); List<TbSmsSend> saveSmsList = new ArrayList<TbSmsSend>();//要保存的发送短信 su.setCharset("UTF-8"); String realImagePath = Constant.decodeString(request .getParameter("filePath")); String tempPath = request.getRealPath("/") + "upload".replace("\\", "/"); String result = ""; File file = new File(tempPath); if(!file.isFile()){ file.mkdirs(); } // 上传初始化 su.initialize(this.getServletConfig(),request,response); // 设定上传限制 // 1.限制每个上传文件的最大长度。 su.setMaxFileSize(10000000); // 2.限制总上传数据的长度。 su.setTotalMaxFileSize(20000000); // 3.设定允许上传的文件(通过扩展名限制),仅允许doc,txt文件。 su.setAllowedFilesList("xls,XLS,txt,TXT"); try{ // 4.设定禁止上传的文件(通过扩展名限制),禁止上传带有exe,bat,jsp,htm,html扩展名的文件和没有扩展名的文件。 su.setDeniedFilesList("exe,bat,jsp,htm,html"); // 将上传文件保存到指定目录 tempPath = tempPath.replace("\\", "/"); tempPath = tempPath + "/"; su.upload(); su.save(tempPath); tempPath += "\\" + su.getFiles().getFile(0).getFileName(); tempPath = tempPath.replace("\\", "/"); tempPath = tempPath.replace("//", "/"); List<String> backPhoneList = new ArrayList<String>();//此为黑名单 QunfaThree qf = new QunfaThree(); qf.setBackPhoneList(backPhoneList); qf.setTbUser(tbUser); qf.setTempPath(tempPath); if(su.getFiles().getFile(0).getFileName().contains("xls")||su.getFiles().getFile(0).getFileName().contains("XLS")){ qf.setTypeId("0"); qf.run(); }else if(su.getFiles().getFile(0).getFileName().contains("txt")||su.getFiles().getFile(0).getFileName().contains("TXT")){ qf.setTypeId("1"); qf.run(); } }catch(Exception e){ e.printStackTrace(); } request.getSession().setAttribute("result", "短信提交成功!"); response.sendRedirect("SmsModule/SmsSend.jsp"); }else if(method.equals("look")){ request.getSession().setAttribute("result", ""); response.sendRedirect("SmsModule/SmsSend.jsp"); }else if(method.equals("save")){//发送短信 List<TbSmsSend> smsSendList = new ArrayList<TbSmsSend>(); String txtArea = request.getParameter("txtArea"); String time = request.getParameter("time");//得到发送类型 String message = Constant.decodeString(request.getParameter("message")); String lastMsgContent = java.net.URLDecoder.decode(message, "UTF-8"); //当前时间 Date date = new Date(); SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); String[] ch = txtArea.split(";"); List<BlackPhoneBean> blackPhoneList = new BlackPhoneModuleDao().getAllTbBlackPhone("tb_blackPhone", "", ""); List<String> blackPhone = new ArrayList<String>(); if(blackPhoneList!=null&&blackPhoneList.size()>0){ for(BlackPhoneBean bp:blackPhoneList){ blackPhone.add(bp.getPhone()); } } if(time.equals("thistime")){//及时发送 for(String ph:ch){ if(!ph.equals("")){ if(!blackPhone.contains(ph)){ TbSmsSend smsSend = new TbSmsSend(); smsSend.setCreateTime(Constant.decodeDate()); smsSend.setDestAdd(ph); smsSend.setIsSendTime(0); smsSend.setSendTime(Constant.decodeDate()); smsSend.setSmsContent(message); smsSend.setSmsSendState(0); smsSend.setUserId(tbUser.getUserId()); smsSend.setSeriseId(String.valueOf(tbUser.getOrgNum())); smsSendList.add(smsSend); } } } }else{ String userDate = request.getParameter("sendTime"); for(String ph:ch){ if(!ph.equals("")){ if(!blackPhone.contains(ph)){ TbSmsSend smsSend = new TbSmsSend(); smsSend.setCreateTime(Constant.decodeDate()); smsSend.setDestAdd(ph); smsSend.setIsSendTime(0); smsSend.setSendTime(Constant.decodeDate()); smsSend.setSmsContent(message); smsSend.setSmsSendState(0); smsSend.setUserId(tbUser.getUserId()); smsSend.setSeriseId(String.valueOf(tbUser.getOrgNum())); smsSendList.add(smsSend); } } } } if(smsSendList!=null&&smsSendList.size()>0){ boolean bo = new TbSmsSendDAO().addSmsList(smsSendList); if(bo){ request.getSession().setAttribute("result", "短信提交成功!"); }else{ request.getSession().setAttribute("result", "短信提交失败!"); } } response.sendRedirect("SmsModule/SmsSend.jsp"); }else if(method.equals("smsSend")){//查看短信发送的记录 String startTime=Constant.decodeString(request.getParameter("startTime")); String endTime=Constant.decodeString(request.getParameter("endTime")); String phone=request.getParameter("phone"); String content=request.getParameter("content"); String condition="userId="+tbUser.getUserId(); if(startTime.equals("")){ startTime= Constant.decodeDateT()+" 00:00:00"; } if(endTime.equals("")){ endTime= Constant.decodeDateT()+" 23:59:59"; } condition+=getCondition(startTime,endTime,phone,content); List<TbSmsSend> smsSendList = new ArrayList<TbSmsSend>(); smsSendList = new TbSmsSendDAO().getSmsList("tb_sms_send", "createTime", condition); request.getSession().setAttribute("smsSendList", smsSendList); request.getSession().setAttribute("startTime", startTime); request.getSession().setAttribute("endTime", endTime); request.getSession().setAttribute("phone", phone); request.getSession().setAttribute("content", content); request.getSession().setAttribute("result", ""); response.sendRedirect("SmsModule/SmsList.jsp"); }else if(method.equals("deleteOne")){//单个删除 String startTime=Constant.decodeString(request.getParameter("startTime")); String endTime=Constant.decodeString(request.getParameter("endTime")); String smsId = request.getParameter("smsId"); String phone = request.getParameter("phone"); String content = Constant.decodeString(request.getParameter("content")); boolean bo =UtilDAO.del("tb_sms_send", "smsId", smsId); if(bo){ request.getSession().setAttribute("result", "删除成功!"); }else { request.getSession().setAttribute("result", "删除失败!"); } String condition="userId="+tbUser.getUserId(); condition+=getCondition(startTime,endTime,phone,content); List<TbSmsSend> smsSendList = new ArrayList<TbSmsSend>(); smsSendList = new TbSmsSendDAO().getSmsList("tb_sms_send", "createTime", condition); request.getSession().setAttribute("smsSendList", smsSendList); request.getSession().setAttribute("startTime", startTime); request.getSession().setAttribute("endTime", endTime); request.getSession().setAttribute("phone", phone); request.getSession().setAttribute("content", content); response.sendRedirect("SmsModule/SmsList.jsp"); }else if(method.equals("deleteAll")){//批删 String startTime=Constant.decodeString(request.getParameter("startTime")); String endTime=Constant.decodeString(request.getParameter("endTime")); String phone = request.getParameter("phone"); String content = Constant.decodeString(request.getParameter("content")); String idList = request.getParameter("idList"); String smsId=""; if(!idList.equals("")){ smsId = idList.substring(0, idList.length()-1); } String condition=" tb_sms_send where smsId in("+smsId+")"; boolean bo =UtilDAO.delAll(condition);; if(bo){ request.getSession().setAttribute("result", "删除成功!"); }else { request.getSession().setAttribute("result", "删除失败!"); } String condi="userId="+tbUser.getUserId(); condi+=this.getCondition(startTime, endTime, phone, content); List<TbSmsSend> smsSendList = new ArrayList<TbSmsSend>(); smsSendList = new TbSmsSendDAO().getSmsList("tb_sms_send", "createTime", condi); request.getSession().setAttribute("smsSendList", smsSendList); request.getSession().setAttribute("startTime", startTime); request.getSession().setAttribute("endTime", endTime); request.getSession().setAttribute("phone", phone); request.getSession().setAttribute("content", content); response.sendRedirect("SmsModule/SmsList.jsp"); }else if(method.equals("search")){//查询操作 String startTime=Constant.decodeString(request.getParameter("startTime")); String endTime=Constant.decodeString(request.getParameter("endTime")); String phone = request.getParameter("phone"); String content = Constant.decodeString(request.getParameter("content")); String condi="userId="+tbUser.getUserId(); condi+=this.getCondition(startTime, endTime, phone, content); List<TbSmsSend> smsSendList = new ArrayList<TbSmsSend>(); smsSendList = new TbSmsSendDAO().getSmsList("tb_sms_send", "createTime", condi); request.getSession().setAttribute("smsSendList", smsSendList); request.getSession().setAttribute("startTime", startTime); request.getSession().setAttribute("endTime", endTime); request.getSession().setAttribute("phone", phone); request.getSession().setAttribute("content", content); request.getSession().setAttribute("result", ""); response.sendRedirect("SmsModule/SmsList.jsp"); }else if(method.equals("smsSendRece")){//查看短信接收 String startTime=Constant.decodeString(request.getParameter("startTime")); String endTime=Constant.decodeString(request.getParameter("endTime")); String phone = request.getParameter("phone"); String content = Constant.decodeString(request.getParameter("content")); if(startTime.equals("")){ startTime=Constant.decodeDateT()+" 00:00:00"; } if(endTime.equals("")){ endTime=Constant.decodeDateT()+" 23:59:59"; } String condition="1=1"; condition+=getConditionRec(startTime,endTime,phone,content); List<TbSmsReceive> receiveList = new ArrayList<TbSmsReceive>(); receiveList = new TbSmsSendDAO().getSmsRecList("tb_smsReceive", "receiveTime", condition); request.getSession().setAttribute("receiveList", receiveList); request.getSession().setAttribute("startTime", startTime); request.getSession().setAttribute("endTime", endTime); request.getSession().setAttribute("phone", phone); request.getSession().setAttribute("content", content); request.getSession().setAttribute("result", ""); response.sendRedirect("SmsModule/SmsReceiveList.jsp"); }else if(method.equals("deleteOneRec")){//单个删除接收短信 String startTime=Constant.decodeString(request.getParameter("startTime")); String endTime=Constant.decodeString(request.getParameter("endTime")); String smsId = request.getParameter("smsId"); String phone = request.getParameter("phone"); String content = Constant.decodeString(request.getParameter("content")); boolean bo =UtilDAO.del("tb_smsReceive", "receiveId", smsId); if(bo){ request.getSession().setAttribute("result", "删除成功!"); }else { request.getSession().setAttribute("result", "删除失败!"); } String condition="1=1"; condition+=getConditionRec(startTime,endTime,phone,content); List<TbSmsReceive> receiveList = new ArrayList<TbSmsReceive>(); receiveList = new TbSmsSendDAO().getSmsRecList("tb_smsReceive", "receiveTime", condition); request.getSession().setAttribute("receiveList", receiveList); request.getSession().setAttribute("startTime", startTime); request.getSession().setAttribute("endTime", endTime); request.getSession().setAttribute("phone", phone); request.getSession().setAttribute("content", content); request.getSession().setAttribute("result", ""); response.sendRedirect("SmsModule/SmsReceiveList.jsp"); }else if(method.equals("deleteAllRec")){//批量删除 String startTime=Constant.decodeString(request.getParameter("startTime")); String endTime=Constant.decodeString(request.getParameter("endTime")); String phone = request.getParameter("phone"); String content = Constant.decodeString(request.getParameter("content")); String idList = request.getParameter("idList"); String smsId=""; if(!idList.equals("")){ smsId = idList.substring(0, idList.length()-1); } String condition=" tb_smsReceive where receiveId in("+smsId+")"; boolean bo =UtilDAO.delAll(condition);; if(bo){ request.getSession().setAttribute("result", "删除成功!"); }else { request.getSession().setAttribute("result", "删除失败!"); } String condi="1=1"; condi+=getConditionRec(startTime,endTime,phone,content); List<TbSmsReceive> receiveList = new ArrayList<TbSmsReceive>(); receiveList = new TbSmsSendDAO().getSmsRecList("tb_smsReceive", "receiveTime", condi); request.getSession().setAttribute("receiveList", receiveList); request.getSession().setAttribute("startTime", startTime); request.getSession().setAttribute("endTime", endTime); request.getSession().setAttribute("phone", phone); request.getSession().setAttribute("content", content); response.sendRedirect("SmsModule/SmsReceiveList.jsp"); }else if(method.equals("searchRec")){///查询接收 String startTime=Constant.decodeString(request.getParameter("startTime")); String endTime=Constant.decodeString(request.getParameter("endTime")); String phone = request.getParameter("phone"); String content = Constant.decodeString(request.getParameter("content")); String condi="1=1"; condi+=getConditionRec(startTime,endTime,phone,content); List<TbSmsReceive> receiveList = new ArrayList<TbSmsReceive>(); receiveList = new TbSmsSendDAO().getSmsRecList("tb_smsReceive", "receiveTime", condi); request.getSession().setAttribute("receiveList", receiveList); request.getSession().setAttribute("startTime", startTime); request.getSession().setAttribute("endTime", endTime); request.getSession().setAttribute("phone", phone); request.getSession().setAttribute("content", content); request.getSession().setAttribute("result", ""); response.sendRedirect("SmsModule/SmsReceiveList.jsp"); }else if("fenjian".equals(method)){//短信分拣 String smsId = request.getParameter("smsId"); String sendPhone = request.getParameter("sendPhone"); String smsType = request.getParameter("smsType"); String startTime = Constant.decodeString(request.getParameter("startTime")); System.out.println("startTime=="+startTime); String endTime = Constant.decodeString(request.getParameter("endTime")); System.out.println("endTime=="+endTime); String content = Constant.decodeString(request.getParameter("content")); String oldPhone= Constant.decodeString(request.getParameter("phone")); KehujifenBean kehujifen = new JifenDao().getKehujifen(sendPhone); String totalJifen="0";//此号码原有分数 if(kehujifen==null){ totalJifen="0"; }else{ totalJifen = kehujifen.getCustomerIntegral(); } List<DianboType> dianboTypeList = new ArrayList<DianboType>(); List<DatiType> datiTypeList = new ArrayList<DatiType>(); String conditionDianbo = "userId="+tbUser.getUserId(); String conditionDati="userId = "+tbUser.getUserId(); dianboTypeList = new DianboTypeDao().getDianboList("tb_qsType_answer", conditionDianbo, "createTime"); datiTypeList = new DatiTypeDao().getAllDaTiType("tb_answer_type", "createTime", conditionDati); request.getSession().setAttribute("dianboTypeList", dianboTypeList); request.getSession().setAttribute("datiTypeList", datiTypeList); request.getSession().setAttribute("sendPhone", sendPhone); request.getSession().setAttribute("startTime", startTime); request.getSession().setAttribute("endTime", endTime); request.getSession().setAttribute("content", content); request.getSession().setAttribute("oldPhone", oldPhone); response.sendRedirect("SmsModule/fenjianSms.jsp?smsId="+smsId+"&num="+new Random().nextInt(10000000)+"&smsType="+smsType+"&totalJifen="+totalJifen); }else if("smsUpload".equals(method)){//上传上来的短信 String startTime=Constant.decodeString(request.getParameter("startTime")); String endTime=Constant.decodeString(request.getParameter("endTime")); String phone = request.getParameter("phone"); String content = Constant.decodeString(request.getParameter("content")); if(startTime.equals("")){ startTime=Constant.decodeDateT()+" 00:00:00"; } if(endTime.equals("")){ endTime=Constant.decodeDateT()+" 23:59:59"; } System.out.println("startTIme=="+startTime+"&&endTime=="+endTime); List<TbSmsSc> receiveList= this.getSmsScList(startTime, endTime, phone, content); request.getSession().setAttribute("receiveList", receiveList); request.getSession().setAttribute("startTime", startTime); request.getSession().setAttribute("endTime", endTime); request.getSession().setAttribute("phone", phone); request.getSession().setAttribute("content", content); request.getSession().setAttribute("result", ""); response.sendRedirect("SmsModule/SmsSCList.jsp"); }else if("searchRecSc".equals(method)){ String startTime=Constant.decodeString(request.getParameter("startTime")); String endTime=Constant.decodeString(request.getParameter("endTime")); String phone = request.getParameter("phone"); String content = Constant.decodeString(request.getParameter("content")); List<TbSmsSc> receiveList= this.getSmsScList(startTime, endTime, phone, content); request.getSession().setAttribute("receiveList", receiveList); request.getSession().setAttribute("startTime", startTime); request.getSession().setAttribute("endTime", endTime); request.getSession().setAttribute("phone", phone); request.getSession().setAttribute("content", content); request.getSession().setAttribute("result", ""); response.sendRedirect("SmsModule/SmsSCList.jsp"); }else if("deleteAllRecSc".equals(method)){ String startTime=Constant.decodeString(request.getParameter("startTime")); String endTime=Constant.decodeString(request.getParameter("endTime")); String phone = request.getParameter("phone"); String content = Constant.decodeString(request.getParameter("content")); String allSmsId[] = request.getParameterValues("deleteAll"); String smsId=""; if(allSmsId.length>0){ for(String id:allSmsId){ smsId+=id+","; } smsId = smsId.substring(0, smsId.length()-1); } String condition=" tb_smsRec_sc where smsId in("+smsId+")"; boolean bo =UtilDAO.delAll(condition);; if(bo){ request.getSession().setAttribute("result", "删除成功!"); }else { request.getSession().setAttribute("result", "删除失败!"); } List<TbSmsSc> receiveList= this.getSmsScList(startTime, endTime, phone, content); request.getSession().setAttribute("receiveList", receiveList); request.getSession().setAttribute("startTime", startTime); request.getSession().setAttribute("endTime", endTime); request.getSession().setAttribute("phone", phone); request.getSession().setAttribute("content", content); response.sendRedirect("SmsModule/SmsSCList.jsp"); }else if("deleteOneRecSc".equals(method)){ String startTime=Constant.decodeString(request.getParameter("startTime")); String endTime=Constant.decodeString(request.getParameter("endTime")); String smsId = request.getParameter("smsId"); String phone = request.getParameter("phone"); String content = Constant.decodeString(request.getParameter("content")); boolean bo =UtilDAO.del("tb_smsRec_sc", "smsId", smsId); if(bo){ request.getSession().setAttribute("result", "删除成功!"); }else { request.getSession().setAttribute("result", "删除失败!"); } List<TbSmsSc> receiveList= this.getSmsScList(startTime, endTime, phone, content); request.getSession().setAttribute("receiveList", receiveList); request.getSession().setAttribute("startTime", startTime); request.getSession().setAttribute("endTime", endTime); request.getSession().setAttribute("phone", phone); request.getSession().setAttribute("content", content); request.getSession().setAttribute("result", ""); response.sendRedirect("SmsModule/SmsSCList.jsp"); }else if("fenjianSubmit".equals(method)){//分拣提交操作 String dianboOrDati = request.getParameter("dianboOrDati");//判断是点播还是答题? String phone = request.getParameter("phone"); String fenshu = request.getParameter("fenshu"); String smsId = request.getParameter("smsId"); TbSmsSc smsSc = new TbSmsScDAO().getTbSmsSc(Integer.parseInt(smsId)); if(dianboOrDati.equals("0")){//dianbo Dianbo dianbo = new Dianbo(); String dianboType = request.getParameter("dianboType"); dianbo.setQsContent(smsSc.getSmscontent()); dianbo.setQsIntegral(""); dianbo.setQsUpPhone(phone); dianbo.setQsUpTime(Constant.decodeDate()); dianbo.setReceiveId(Integer.parseInt(smsId)); dianbo.setTypeId(dianboType); String condition=" tb_qs_info where receiveId="+smsId+" and qsUpPhone='"+phone+"'"; boolean boo = UtilDAO.delAll(condition); boolean bo = false; if(boo){ bo = new DianboDao().addDianbo(dianbo); if(bo){ request.getSession().setAttribute("result", "短信分拣成功!"); }else{ request.getSession().setAttribute("result", "短信分拣失败!"); } }else{ bo = new DianboDao().addDianbo(dianbo); boolean bol = new GetJifen().saveJifenToCustomer(phone, fenshu); request.getSession().setAttribute("result", "短信分拣成功!"); } }else if(dianboOrDati.equals("1")){//答题 String dati_Type = request.getParameter("dati_Type"); String xilie_Type = request.getParameter("xilie_Type"); String cond = " receiveId="+smsId+" and answerUpPhone='"+phone+"'"; List<Answer> answerList = new DatiDao().getAnswerList("tb_answer", "", cond); boolean bo = false; String content = smsSc.getSmscontent(); String lastContent = content.substring(0,content.length()-1);//题目 String rightAnswer = content.substring(content.length()-1);//正确答案 if(answerList!=null&&answerList.size()>0){ String middleId = answerList.get(0).getAnswerMiddleId(); int answerId = answerList.get(0).getAnswerId(); boolean bol = UtilDAO.del("tb_answer", "answerId", answerId); if(bol){ bo = UtilDAO.del("tb_answer_middle", "answerMiddleId", middleId);//删除中间表 if(bo){ DatiMiddle datiMid = new DatiMiddle(); String num = Constant.getNumT(); datiMid.setAnswerContent(lastContent); datiMid.setAnswerMiddleId(num); datiMid.setCreateTime(Constant.decodeDate()); datiMid.setRightAnswer(rightAnswer); datiMid.setSeriseId(xilie_Type); boolean bool= new DatiDao().saveDatiMiddle(datiMid); if(bool){ Answer answer = new Answer(); answer.setAnswerIntegral(""); answer.setAnswerMiddleId(num); answer.setAnswerUpPhone(phone); answer.setAnswerUpTime(Constant.decodeDate()); answer.setReceiveId(Integer.parseInt(smsId)); boolean bl = new DatiDao().saveAnswer(answer); if(bl){ request.getSession().setAttribute("result", "短信分拣成功!"); //boolean bll = new GetJifen().saveJifenToCustomer(phone, fenshu); }else{ request.getSession().setAttribute("result", "短信分拣失败!"); } } }else{ request.getSession().setAttribute("result", "短信分拣失败!"); } } }else{ DatiMiddle datiMid = new DatiMiddle(); String num = Constant.getNumT(); datiMid.setAnswerContent(lastContent); datiMid.setAnswerMiddleId(num); datiMid.setCreateTime(Constant.decodeDate()); datiMid.setRightAnswer(rightAnswer); datiMid.setSeriseId(xilie_Type); boolean bool= new DatiDao().saveDatiMiddle(datiMid); if(bool){ Answer answer = new Answer(); answer.setAnswerIntegral(""); answer.setAnswerMiddleId(num); answer.setAnswerUpPhone(phone); answer.setAnswerUpTime(Constant.decodeDate()); answer.setReceiveId(Integer.parseInt(smsId)); boolean bl = new DatiDao().saveAnswer(answer); if(bl){ request.getSession().setAttribute("result", "短信分拣成功!"); boolean bll = new GetJifen().saveJifenToCustomer(phone, fenshu); }else{ request.getSession().setAttribute("result", "短信分拣失败!"); } } } } String startTime=Constant.decodeString(request.getParameter("startTime")); String endTime=Constant.decodeString(request.getParameter("endTime")); String content = Constant.decodeString(request.getParameter("content")); String oldPhone = Constant.decodeString(request.getParameter("oldPhone")); List<TbSmsSc> receiveList= this.getSmsScList(startTime, endTime, oldPhone, content); request.getSession().setAttribute("receiveList", receiveList); request.getSession().setAttribute("startTime", startTime); request.getSession().setAttribute("endTime", endTime); request.getSession().setAttribute("phone", oldPhone); request.getSession().setAttribute("content", content); response.sendRedirect("SmsModule/SmsSCList.jsp"); }else if("sendAgin".equals(method)){//短信重发 String smsId = request.getParameter("smsId"); String sql="update tb_sms_send set smsSendState=0,createTime='"+Constant.decodeDate()+"',sendTime='"+Constant.decodeDate()+"' where smsId="+smsId; boolean bo = new TbSmsSendDAO().updateSmsSend(sql); String phone=""; String content=""; String condition="userId="+tbUser.getUserId(); String startTime=Constant.decodeDateT()+" 00:00:00"; String endTime = Constant.decodeDateT()+" 23:59:59"; condition+=getCondition(startTime,endTime,phone,content); List<TbSmsSend> smsSendList = new ArrayList<TbSmsSend>(); smsSendList = new TbSmsSendDAO().getSmsList("tb_sms_send", "createTime", condition); request.getSession().setAttribute("smsSendList", smsSendList); request.getSession().setAttribute("startTime", startTime); request.getSession().setAttribute("endTime", endTime); request.getSession().setAttribute("phone", phone); request.getSession().setAttribute("content", content); if(bo){ request.getSession().setAttribute("result", "重发成功!"); }else{ request.getSession().setAttribute("result", "重发失败!"); } response.sendRedirect("SmsModule/SmsList.jsp"); } }//end doPost public List<TbSmsSc> getSmsScList(String startTime,String endTime,String phone,String content){ String condi="1=1"; condi+=getConditionRecSC(startTime,endTime,phone,content); List<TbSmsSc> receiveList = new ArrayList<TbSmsSc>(); receiveList = new TbSmsSendDAO().getSmsSc("tb_smsRec_sc", "createTime", condi); return receiveList; } /** * The doPost method of the servlet. <br> * * This method is called when a form has its tag value method equals to post. * * @param request the request send by the client to the server * @param response the response send by the server to the client * @throws ServletException if an error occurred * @throws IOException if an error occurred */ public String getCondition(String startTime,String endTime,String phone,String content){ String condition=""; if(startTime.equals("")&&endTime.equals("")&&phone.equals("")&&content.equals("")){ }else if(!startTime.equals("")&&endTime.equals("")&&phone.equals("")&&content.equals("")){ condition+=" and createTime >='"+startTime+"'"; }else if(startTime.equals("")&&!endTime.equals("")&&phone.equals("")&&content.equals("")){ condition+=" and createTime<='"+endTime+"'"; }else if(startTime.equals("")&&endTime.equals("")&&!phone.equals("")&&content.equals("")){ condition+=" and destAdd='"+phone+"'"; }else if(startTime.equals("")&&endTime.equals("")&&phone.equals("")&&!content.equals("")){ condition+="smsContent like '%"+content+"%'"; }else if(!startTime.equals("")&&!endTime.equals("")&&phone.equals("")&&content.equals("")){ condition+=" and createTime >='"+startTime+"' and createTime<='"+endTime+"'"; }else if(!startTime.equals("")&&endTime.equals("")&&!phone.equals("")&&content.equals("")){ condition+=" and createTime >='"+startTime+"' and destAdd='"+phone+"'"; }else if(!startTime.equals("")&&endTime.equals("")&&phone.equals("")&&!content.equals("")){ condition+=" and createTime >='"+startTime+"' and smsContent like '%"+content+"%'"; }else if(startTime.equals("")&&!endTime.equals("")&&!phone.equals("")&&content.equals("")){ condition+=" and destAdd='"+phone+"' and createTime<='"+endTime+"'"; }else if(startTime.equals("")&&!endTime.equals("")&&phone.equals("")&&!content.equals("")){ condition+=" and createTime<='"+endTime+"' and smsContent like '%"+content+"%'"; }else if(startTime.equals("")&&endTime.equals("")&&!phone.equals("")&&!content.equals("")){ condition+=" and destAdd='"+phone+"' and smsContent like '%"+content+"%'"; }else if(!startTime.equals("")&&!endTime.equals("")&&!phone.equals("")&&content.equals("")){ condition+=" and createTime >='"+startTime+"' and createTime<='"+endTime+"' and destAdd='"+phone+"'"; }else if(!startTime.equals("")&&endTime.equals("")&&!phone.equals("")&&!content.equals("")){ condition+=" and createTime >='"+startTime+"' and destAdd='"+phone+"' and smsContent like '%"+content+"%'"; }else if(startTime.equals("")&&!endTime.equals("")&&!phone.equals("")&&!content.equals("")){ condition+=" and destAdd='"+phone+"' and createTime<='"+endTime+"' and smsContent like '%"+content+"%'"; }else if(!startTime.equals("")&&!endTime.equals("")&&!phone.equals("")&&!content.equals("")){ condition+=" and createTime >='"+startTime+"' and createTime<='"+endTime+"' and destAdd='"+phone+"' and smsContent like '%"+content+"%'"; }else if(!startTime.equals("")&&!endTime.equals("")&&phone.equals("")&&!content.equals("")){ condition+=" and createTime >='"+startTime+"' and createTime<='"+endTime+"' and smsContent like '%"+content+"%'"; } return condition; } public String getConditionRec(String startTime,String endTime,String phone,String content){ String condition=""; Date startDate = Timestamp.valueOf(startTime); Date endDate = Timestamp.valueOf(endTime); if(!phone.equals("")&&content.equals("")){ condition+=" and sendPhone='"+phone+"' and receiveTime>='"+startDate+"' and receiveTime<='"+endDate+"'"; }else if(phone.equals("")&&!content.equals("")){ condition+=" and receiveContent like '%"+content+"%' and receiveTime>='"+startDate+"' and receiveTime<='"+endDate+"'"; }else if(!phone.equals("")&&!content.equals("")){ condition+=" and receiveContent like '%"+content+"%' and sendPhone='"+phone+"' and receiveTime>='"+startDate+"' and receiveTime<='"+endDate+"'"; }else { condition+=" and receiveTime>='"+startDate+"' and receiveTime<='"+endDate+"'"; } return condition; } /** * *@author qingyu zhang *@function:上传的信息 * @param startTime * @param endTime * @param phone * @param content * @return *2011-4-12 *下午10:54:02 *zzClub *com.SmsModule.servlet *String */ public String getConditionRecSC(String startTime,String endTime,String phone,String content){ String condition=""; Date startDate = Timestamp.valueOf(startTime); Date endDate = Timestamp.valueOf(endTime); if(!phone.equals("")&&content.equals("")){ condition+=" and sendPhone='"+phone+"' and createTime>='"+startDate+"' and createTime<='"+endDate+"'"; }else if(phone.equals("")&&!content.equals("")){ condition+=" and smscontent like '%"+content+"%' and createTime>='"+startDate+"' and createTime<='"+endDate+"'"; }else if(!phone.equals("")&&!content.equals("")){ condition+=" and smscontent like '%"+content+"%' and sendPhone='"+phone+"' and createTime>='"+startDate+"' and createTime<='"+endDate+"'"; }else { condition+=" and createTime>='"+startDate+"' and createTime<='"+endDate+"'"; } return condition; } public void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { doGet(request,response); } /** * Initialization of the servlet. <br> * * @throws ServletException if an error occurs */ public void init() throws ServletException { // Put your code here System.out.println("init方法"); } }
zzprojects
trunk/zzprojects/zzClub/src/com/SmsModule/servlet/TbSmsServlet.java
Java
asf20
35,816
package com.SmsModule.servlet; import java.io.File; import java.io.FileInputStream; import java.io.IOException; import java.io.InputStream; import java.io.PrintWriter; import java.util.ArrayList; import java.util.Calendar; import java.util.Date; import java.util.List; import javax.servlet.ServletException; import javax.servlet.http.HttpServlet; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; import jxl.Cell; import jxl.Sheet; import jxl.Workbook; import util.Constant; import com.SmsModule.bean.TbCommonPhrase; import com.SmsModule.bean.TbSmsSend; import com.SmsModule.dao.TbSmsTemplateDAO; import com.UserModule.bean.TbUserBean; import com.jspsmart.upload.SmartUpload; public class TbSmsTemplateServlet extends HttpServlet{ public void destroy() { super.destroy(); } protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { TbSmsTemplateDAO smstemplate=new TbSmsTemplateDAO(); response.setContentType("text/html"); response.setCharacterEncoding("utf-8"); response.setContentType("text/html;charset=utf-8"); PrintWriter out = response.getWriter(); String method = request.getParameter("method"); TbUserBean tbUser=(TbUserBean)request.getSession().getAttribute("User"); //查询所有的常用短语 if(method.equals("search")){ String tiaojian=" userId="+tbUser.getUserId(); List SmsTemplateList=null; SmsTemplateList=smstemplate.getTbCommonPhraseAll("tb_CommonPhrase", tiaojian, "createTime"); request.getSession().setAttribute("SmsTemplateList",SmsTemplateList); response.sendRedirect("SmsModule/SmsTemplate.jsp?s=1"); }else if(method.equals("searchTemplate")){//选择常用短语 String fromname=request.getParameter("fromname"); String tiaojian=" userId="+tbUser.getUserId(); List SmsTemplateList=null; SmsTemplateList=smstemplate.getTbCommonPhraseAll("tb_CommonPhrase", tiaojian, "createTime"); request.getSession().setAttribute("SelectSmsTemplateList",SmsTemplateList); response.sendRedirect("SmsModule/SelectSmsTemplate.jsp?s=1&fromname="+fromname); }else if(method.equals("add")){ String phraseContent=Constant.decodeString(request.getParameter("phraseContent")); TbCommonPhrase tbCommonPhrase=new TbCommonPhrase(); tbCommonPhrase.setPhraseContent(phraseContent); tbCommonPhrase.setUserId(tbUser.getUserId()); tbCommonPhrase.setUseCount(0); int insertflag=smstemplate.addTbCommonPhrase(tbCommonPhrase); if(insertflag>0){ request.getSession().setAttribute("resultSM", "添加常用短语成功!"); //out.write("<script language='javascript'>alert('添加常用短语成功!');</script>"); }else{ request.getSession().setAttribute("resultSM", "添加常用短语失败!"); //out.write("<script language='javascript'>alert('添加常用短语失败!');</script>"); } String tiaojian=" userId="+tbUser.getUserId(); List<TbCommonPhrase> SmsTemplateList=null; SmsTemplateList=smstemplate.getTbCommonPhraseAll("tb_CommonPhrase", tiaojian, "createTime"); request.getSession().setAttribute("SmsTemplateList",SmsTemplateList); response.sendRedirect("SmsModule/SmsTemplate.jsp?s=1"); }else if(method.equals("update")){ }else if(method.equals("deleteOne")){ String PhraseId=request.getParameter("PhraseId"); boolean result=smstemplate.del("tb_CommonPhrase", "PhraseId", PhraseId); if(result){ request.getSession().setAttribute("resultSM", "常用短语删除成功!"); //out.write("<script language='javascript'>alert('常用短语删除成功!');</script>"); }else{ request.getSession().setAttribute("resultSM", "常用短语删除失败!"); //out.write("<script language='javascript'>alert('常用短语删除失败!');</script>"); } String tiaojian=" userId="+tbUser.getUserId(); List SmsTemplateList=smstemplate.getTbCommonPhraseAll("tb_CommonPhrase", tiaojian, "createTime"); request.getSession().setAttribute("SmsTemplateList",SmsTemplateList); response.sendRedirect("SmsModule/SmsTemplate.jsp?s=1"); }else if(method.equals("deleteAll")){ String idList = request.getParameter("idList"); idList = idList.substring(0, idList.length()-1); boolean result=smstemplate.delin("tb_CommonPhrase", "PhraseId", idList); if(result){ request.getSession().setAttribute("resultSM", "常用短语删除成功!"); //out.write("<script language='javascript'>alert('常用短语删除成功!');</script>"); }else{ request.getSession().setAttribute("resultSM", "常用短语删除失败!"); //out.write("<script language='javascript'>alert('常用短语删除失败!');</script>"); } String tiaojian=" userId="+tbUser.getUserId(); List SmsTemplateList=smstemplate.getTbCommonPhraseAll("tb_CommonPhrase", tiaojian, "createTime"); request.getSession().setAttribute("SmsTemplateList",SmsTemplateList); response.sendRedirect("SmsModule/SmsTemplate.jsp?s=1"); } } protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { doGet(request,response); } public void init() throws ServletException { } }
zzprojects
trunk/zzprojects/zzClub/src/com/SmsModule/servlet/TbSmsTemplateServlet.java
Java
asf20
5,416
package com.SmsModule.dao; import java.sql.Connection; import java.sql.PreparedStatement; import java.sql.ResultSet; import java.util.ArrayList; import java.util.List; import util.ConnectDB; import util.UtilDAO; import com.SmsModule.bean.TbSmsReceive; import com.SmsModule.bean.TbSmsSend; /** * 短信接收模块操作DAO * jhc * 2011-1-27下午01:52:05 */ public class TbSmsReceiveDAO { private Connection conn = null; private PreparedStatement pt = null; private ResultSet rs = null; private boolean flag = false; private String sql = ""; private TbSmsReceive tbsmsreceive=null; private List<TbSmsReceive> TbSmsReceiveList=null; /** * 查询短信接收列表 * jhc * 2011-1-27 下午01:55:27 */ public List<TbSmsReceive> getTbSmsReceiveAll(String tableName,String tiaojian,String order){ try { conn = ConnectDB.getSqlServerConnection(); sql = UtilDAO.getList(tableName,order, tiaojian); pt = conn.prepareStatement(sql); rs = pt.executeQuery(); while(rs.next()) { if(TbSmsReceiveList==null) { TbSmsReceiveList = new ArrayList<TbSmsReceive>(); } tbsmsreceive = new TbSmsReceive(); tbsmsreceive.setReceiveId(rs.getInt("receiveId")); tbsmsreceive.setReceiveContent(rs.getString("receiveContent")); tbsmsreceive.setSendPhone(rs.getString("sendPhone")); tbsmsreceive.setOrgNum(rs.getString("orgNum")); tbsmsreceive.setReceiveType(rs.getInt("receiveType")); tbsmsreceive.setReceiveTime(rs.getString("receiveTime")); TbSmsReceiveList.add(tbsmsreceive); } } catch (Exception e) { // TODO Auto-generated catch block e.printStackTrace(); return null; }finally { ConnectDB.closeSqlConnection(); } return TbSmsReceiveList; } /** * 多项删除 * jhc * 2011-1-27 下午02:30:38 */ public boolean del(String tableName,String keyId,String idList){ boolean bo = UtilDAO.del(tableName, keyId, idList); return bo ; } public static void main(String[] args) { } }
zzprojects
trunk/zzprojects/zzClub/src/com/SmsModule/dao/TbSmsReceiveDAO.java
Java
asf20
2,124
package com.SmsModule.dao; import java.sql.ResultSet; import java.sql.SQLException; import java.sql.Statement; import java.util.ArrayList; import java.util.List; import util.TotalClass; import util.UtilDAO; import com.SmsModule.bean.TbSmsReceive; import com.SmsModule.bean.TbSmsSc; import com.SmsModule.bean.TbSmsSend; import com.dianbo.bean.DianboType; /** * 短信发送模块操作DAO * jhc * 2011-1-27下午01:51:54 */ public class TbSmsSendDAO { private String sql = ""; private DianboType dianboType=null; private List<DianboType> dianboTypeList = null; List<TbSmsSend> smsSendList = null; List<TbSmsReceive> smsRecList = null; List<TbSmsSc> tbSmsScList = null; private ResultSet rs = null; private Statement st = null; /** * *@author qingyu zhang *@function:批量导入短信 * @param smsList * @return *2011-4-10 *上午10:31:23 *zzClub *com.SmsModule.dao *boolean */ public boolean addSmsList(List<TbSmsSend> smsList){ boolean bo = false; try{ st = new TotalClass().getStatement(); if(smsList!=null&&smsList.size()>0){ for(TbSmsSend smsSend:smsList){ String hql = "insert into tb_sms_send (userId,smsContent,smsSendState,sendTime,destAdd,isSendTime,createTime,seriseId) " + "values("+smsSend.getUserId()+",'"+smsSend.getSmsContent()+"',"+smsSend.getSmsSendState()+",'"+smsSend.getSendTime() +"','"+smsSend.getDestAdd()+"',"+smsSend.getIsSendTime()+",'"+smsSend.getCreateTime()+"','"+smsSend.getSeriseId()+"')"; st.addBatch(hql); } st.executeBatch(); } bo = true; }catch(Exception e){ e.printStackTrace(); } return bo; } /** * *@author qingyu zhang *@function:发送答题方法 * @param smsList * @return *2011-4-13 *下午02:20:59 *zzClub *com.SmsModule.dao *boolean */ public boolean addSmsListDati(List<TbSmsSend> smsList){ boolean bo = false; try{ st = new TotalClass().getStatement(); if(smsList!=null&&smsList.size()>0){ for(TbSmsSend smsSend:smsList){ String hql = "insert into tb_sms_send (userId,smsContent,smsSendState,sendTime,destAdd,isSendTime,createTime,seriseId) " + "values("+smsSend.getUserId()+",'"+smsSend.getSmsContent()+"',"+smsSend.getSmsSendState()+",'"+smsSend.getSendTime() +"','"+smsSend.getDestAdd()+"',"+smsSend.getIsSendTime()+",'"+smsSend.getCreateTime()+"','"+smsSend.getSeriseId()+"')"; System.out.println("插入tb_sms_send=="+hql); st.addBatch(hql); } st.executeBatch(); } bo = true; }catch(Exception e){ e.printStackTrace(); } return bo; } /** * *@author qingyu zhang *@function: * @param table * @param order * @param condition * @return *2011-4-11 *上午09:13:59 *zzClub *com.SmsModule.dao *List<TbSmsSend> */ public List<TbSmsSend> getSmsList(String table,String order,String condition){ sql= UtilDAO.getList(table, order, condition); rs = new TotalClass().getResult(sql); try { while(rs.next()){ if(smsSendList==null){ smsSendList =new ArrayList<TbSmsSend>(); } smsSendList.add(this.getSmsSend(rs)); } } catch (SQLException e) { // TODO Auto-generated catch block e.printStackTrace(); } return smsSendList; } public TbSmsSend getSmsSend(ResultSet rs){ TbSmsSend smsSend = new TbSmsSend(); try { smsSend.setCreateTime(rs.getString("createTime")); smsSend.setDestAdd(rs.getString("destAdd")); smsSend.setIsSendTime(rs.getInt("isSendTime")); smsSend.setSendTime(rs.getString("sendTime")); smsSend.setSmsContent(rs.getString("smsContent")); smsSend.setSmsId(rs.getInt("smsId")); smsSend.setSmsSendState(rs.getInt("smsSendState")); smsSend.setUserId(rs.getInt("userId")); } catch (SQLException e) { // TODO Auto-generated catch block e.printStackTrace(); } return smsSend; } public List<TbSmsReceive> getSmsRecList(String table,String order,String condition){ sql= UtilDAO.getList(table, order, condition); System.out.println("语句=="+sql); rs = new TotalClass().getResult(sql); try { while(rs.next()){ if(smsRecList==null){ smsRecList =new ArrayList<TbSmsReceive>(); } smsRecList.add(this.getSmsRecSend(rs)); } } catch (SQLException e) { // TODO Auto-generated catch block e.printStackTrace(); } return smsRecList; } public TbSmsReceive getSmsRecSend(ResultSet rs){ TbSmsReceive smsRec = new TbSmsReceive(); try { smsRec.setOrgNum(rs.getString("orgNum")); smsRec.setReceiveContent(rs.getString("receiveContent")); smsRec.setReceiveId(rs.getInt("receiveId")); smsRec.setReceiveTime(rs.getString("receiveTime")); smsRec.setReceiveType(rs.getInt("receiveType")); smsRec.setSendPhone(rs.getString("sendPhone")); smsRec.setState(rs.getInt("state")); } catch (SQLException e) { // TODO Auto-generated catch block e.printStackTrace(); } return smsRec; } public List<TbSmsSc> getSmsSc(String table,String order,String condition){ sql= UtilDAO.getList(table, order, condition); System.out.println("语句=="+sql); rs = new TotalClass().getResult(sql); try { while(rs.next()){ if(tbSmsScList==null){ tbSmsScList = new ArrayList<TbSmsSc>(); } tbSmsScList.add(this.getSmsSc(rs)); } } catch (SQLException e) { // TODO Auto-generated catch block e.printStackTrace(); } return tbSmsScList; } public TbSmsSc getSmsSc(ResultSet rs){ TbSmsSc tbSmsSc = new TbSmsSc(); try { tbSmsSc.setCreateTime(rs.getString("createTime")); tbSmsSc.setDestAdd(rs.getString("destAdd")); tbSmsSc.setSendPhone(rs.getString("sendPhone")); tbSmsSc.setSmscontent(rs.getString("smscontent")); tbSmsSc.setSmsId(rs.getInt("smsId")); tbSmsSc.setSmsType(rs.getInt("smsType")); } catch (SQLException e) { // TODO Auto-generated catch block e.printStackTrace(); } return tbSmsSc; } /** * 短信重发功能 *@author qingyu zhang *@function: * @param str *2011-5-5 *下午05:29:18 *zzClub *com.SmsModule.dao *void */ public boolean updateSmsSend(String str){ boolean bo = false; st = new TotalClass().getStatement(); try { st.execute(str); bo = true; } catch (SQLException e) { // TODO Auto-generated catch block e.printStackTrace(); } return bo; } }
zzprojects
trunk/zzprojects/zzClub/src/com/SmsModule/dao/TbSmsSendDAO.java
Java
asf20
6,513
package com.SmsModule.dao; import java.sql.Connection; import java.sql.PreparedStatement; import java.sql.ResultSet; import java.sql.Statement; import java.util.ArrayList; import java.util.List; import util.ConnectDB; import util.UtilDAO; import com.SmsModule.bean.TbCommonPhrase; /** * 短信常用短语 * @author jhc * */ public class TbSmsTemplateDAO { private Connection conn = null; private PreparedStatement pt = null; private Statement st = null; private ResultSet rs = null; private boolean flag = false; private String sql = ""; private TbCommonPhrase smsTemplate=null; private List<TbCommonPhrase> smsTemplateList=null; /** * 查询所有常用短语 * @param tableName * @param tiaojian * @param order * @return */ public List<TbCommonPhrase> getTbCommonPhraseAll(String tableName,String tiaojian,String order){ try { conn = ConnectDB.getSqlServerConnection(); sql = UtilDAO.getList(tableName, order, tiaojian); pt = conn.prepareStatement(sql); rs = pt.executeQuery(); while(rs.next()) { if(smsTemplateList==null) { smsTemplateList = new ArrayList<TbCommonPhrase>(); } smsTemplateList.add(this.getsmsTemplateList(rs)); } } catch (Exception e) { // TODO Auto-generated catch block e.printStackTrace(); return null; }finally { ConnectDB.closeSqlConnection(); } return smsTemplateList; } /** * 传入结果集返回单个信息 * @param rs 结果集 * @return TbUsers * @throws Exception */ public TbCommonPhrase getsmsTemplateList(ResultSet rs) throws Exception{ TbCommonPhrase tbCommonPhrase = new TbCommonPhrase(); tbCommonPhrase.setPhraseId(rs.getInt("phraseId")); tbCommonPhrase.setPhraseContent(rs.getString("phraseContent")); tbCommonPhrase.setUseCount(rs.getInt("useCount")); tbCommonPhrase.setUserId(rs.getInt("userId")); tbCommonPhrase.setCreateTime(rs.getString("createTime")); return tbCommonPhrase; } /** * 插入常用短语 * jhc * 2011-1-27 下午01:59:58 */ public int addTbCommonPhrase(TbCommonPhrase tbCommonPhrase){ int num = 0; try { conn = ConnectDB.getSqlServerConnection(); sql = "insert into tb_CommonPhrase(phraseContent,useCount,userId) " + "values('"+tbCommonPhrase.getPhraseContent()+"',"+tbCommonPhrase.getUseCount()+","+tbCommonPhrase.getUserId()+")"; pt = conn.prepareStatement(sql); num = pt.executeUpdate(); } catch (Exception e) { // TODO Auto-generated catch block e.printStackTrace(); num = 0; }finally { ConnectDB.closeSqlConnection(); } return num ; } /** * 单条记录删除 * jhc * 2011-1-27 下午02:30:38 */ public boolean del(String tableName,String keyId,String idList){ boolean bo = UtilDAO.del(tableName, keyId, idList); return bo ; } /** * 多项删除 * jhc * 2011-1-27 下午02:30:38 */ public boolean delin(String tableName,String keyId,String idList){ boolean bo = UtilDAO.delin(tableName, keyId, idList); return bo ; } /** * 根据选择的常用短语Id修改常用短语内容 * jhc * 2011-2-9 上午11:18:21 */ public boolean modifyTemplateContent(String phraseContent,int phraseId){ boolean bo = false; try { conn = ConnectDB.getSqlServerConnection(); sql = "update tb_CommonPhrase set phraseContent='"+phraseContent+"' where phraseId="+phraseId+""; pt = conn.prepareStatement(sql); pt.execute(); bo = true; } catch (Exception e) { // TODO Auto-generated catch block e.printStackTrace(); bo = false; }finally{ ConnectDB.closeSqlConnection(); } return bo; } }
zzprojects
trunk/zzprojects/zzClub/src/com/SmsModule/dao/TbSmsTemplateDAO.java
Java
asf20
3,783
package com.SmsModule.dao; import java.sql.ResultSet; import java.sql.SQLException; import java.sql.Statement; import java.util.List; import util.TotalClass; import com.SmsModule.bean.TbSmsSc; import com.dianbo.bean.DianboType; import com.order.bean.TbOrder; public class TbSmsScDAO { /** *@author qingyu zhang *@function: *2011-4-13 *上午08:27:19 *zzClub *com.SmsModule.dao */ private String sql = ""; private TbSmsSc smsSc=null; private ResultSet rs = null; private List<TbSmsSc> smsScList = null; private Statement st = null; /** * *@author qingyu zhang *@function:根据上传的短信ID得到单个上传对象 * @param smsId * @return *2011-4-13 *上午08:29:20 *zzClub *com.SmsModule.dao *TbSmsSc */ public TbSmsSc getTbSmsSc(int smsId){ sql = "select * from tb_smsRec_sc where smsId="+smsId; rs = new TotalClass().getResult(sql); try { while(rs.next()){ if(smsSc==null){ smsSc = new TbSmsSc(); } smsSc = this.getTbSmsSc(rs); } } catch (SQLException e) { // TODO Auto-generated catch block e.printStackTrace(); } return smsSc; } public TbSmsSc getTbSmsSc(ResultSet rs){ TbSmsSc tbSmsSc = new TbSmsSc(); try { tbSmsSc.setCreateTime(rs.getString("createTime")); tbSmsSc.setDestAdd(rs.getString("destAdd")); tbSmsSc.setSendPhone(rs.getString("sendPhone")); tbSmsSc.setSmscontent(rs.getString("smscontent")); tbSmsSc.setSmsId(rs.getInt("smsId")); tbSmsSc.setSmsType(rs.getInt("smsType")); } catch (SQLException e) { // TODO Auto-generated catch block e.printStackTrace(); } return tbSmsSc; } }
zzprojects
trunk/zzprojects/zzClub/src/com/SmsModule/dao/TbSmsScDAO.java
Java
asf20
1,699
package com.SmsModule.dao; import java.sql.Connection; import java.sql.PreparedStatement; import java.sql.ResultSet; import java.util.List; import util.ConnectDB; import com.SmsModule.bean.TbSendType; /** * 发送类型模块操作DAO * jhc * 2011-1-27下午01:51:28 */ public class TbSendTypeDAO { private Connection conn = null; private PreparedStatement pt = null; private ResultSet rs = null; private boolean flag = false; private String sql = ""; private TbSendType tbsendtype=null; private List<TbSendType> TbSendTypeList=null; /** * 得到发送类型模块信息列表 * jhc * 2011-1-27 下午01:55:27 */ public List<TbSendType> getTbSendTypeAll(){ return TbSendTypeList; } /** * 根据类型id查询类型名称 * @param args */ public TbSendType getTbSendTypeByTypeId(int inTypeId){ try { conn = ConnectDB.getSqlServerConnection(); sql = "select * from tb_sendType where typeId=?"; pt = conn.prepareStatement(sql); pt.setInt(1, inTypeId); rs = pt.executeQuery(); if (rs.next()) { tbsendtype=this.getTbSendTypeInfo(rs); } } catch (Exception e) { e.printStackTrace(); } finally { ConnectDB.closeSqlConnection(); } return tbsendtype; } public TbSendType getTbSendTypeInfo(ResultSet rs) throws Exception{ TbSendType sendtype=new TbSendType(); sendtype.setTypeName(rs.getString("typeName")); return sendtype; } public static void main(String[] args) { } }
zzprojects
trunk/zzprojects/zzClub/src/com/SmsModule/dao/TbSendTypeDAO.java
Java
asf20
1,633
package com.BlackPhoneModule.bean; import java.io.Serializable; public class BlackPhoneBean implements Serializable{ private int id; private String phone; private int userid; private String createTime; public int getId() { return id; } public void setId(int id) { this.id = id; } public String getPhone() { return phone; } public void setPhone(String phone) { this.phone = phone; } public int getUserid() { return userid; } public void setUserid(int userid) { this.userid = userid; } public String getCreateTime() { return createTime; } public void setCreateTime(String createTime) { this.createTime = createTime; } }
zzprojects
trunk/zzprojects/zzClub/src/com/BlackPhoneModule/bean/BlackPhoneBean.java
Java
asf20
726
package com.BlackPhoneModule.servlet; import java.io.File; import java.io.FileInputStream; import java.io.IOException; import java.io.InputStream; import java.io.PrintWriter; import java.util.ArrayList; import java.util.List; import javax.servlet.ServletException; import javax.servlet.http.HttpServlet; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; import jxl.Cell; import jxl.Sheet; import jxl.Workbook; import util.Constant; import com.BlackPhoneModule.bean.BlackPhoneBean; import com.BlackPhoneModule.dao.BlackPhoneModuleDao; import com.UserModule.bean.TbUserBean; import com.jspsmart.upload.SmartUpload; public class BlackPhoneModuleServlet extends HttpServlet { @Override protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { response.setContentType("text/html"); String method= request.getParameter("method");//get the name of method PrintWriter out = response.getWriter(); TbUserBean user = (TbUserBean)request.getSession().getAttribute("User"); BlackPhoneModuleDao blackPhonedao=new BlackPhoneModuleDao(); if(method.equals("lookBlackPhone")){ List BlackPhoneList=null; BlackPhoneList=blackPhonedao.getAllTbBlackPhone("tb_blackPhone", "createTime", ""); request.getSession().setAttribute("phone", ""); request.getSession().setAttribute("BlackPhoneList",BlackPhoneList); response.sendRedirect("AddressListModule/BlackPhoneList.jsp?s=1"); }else if(method.equals("looksearch")){ String phone=request.getParameter("phone"); String tiaojian=""; if(phone==null || "".equals(phone)){ }else{ tiaojian=" phone like '%"+phone+"%'"; } List BlackPhoneList=null; BlackPhoneList=blackPhonedao.getAllTbBlackPhone("tb_blackPhone","createTime",tiaojian); request.getSession().setAttribute("phone", phone); request.getSession().setAttribute("BlackPhoneList",BlackPhoneList); response.sendRedirect("AddressListModule/BlackPhoneList.jsp?s=1"); }else if(method.equals("deleteOne")){ String BlackPhoneId=request.getParameter("BlackPhoneId"); boolean result=blackPhonedao.del("tb_blackPhone", "id", BlackPhoneId); if(result){ request.getSession().setAttribute("resultSM", "黑名单号码删除成功!"); }else{ request.getSession().setAttribute("resultSM", "黑名单号码删除失败!"); } List BlackPhoneList=blackPhonedao.getAllTbBlackPhone("tb_blackPhone", "createTime",""); request.getSession().setAttribute("BlackPhoneList",BlackPhoneList); response.sendRedirect("AddressListModule/BlackPhoneList.jsp?s=1"); }else if(method.equals("deleteAll")){ String idList = request.getParameter("idList"); idList = idList.substring(0, idList.length()-1); boolean result=blackPhonedao.delin("tb_blackPhone", "id", idList); if(result){ request.getSession().setAttribute("resultSM", "黑名单号码删除成功!"); }else{ request.getSession().setAttribute("resultSM", "黑名单号码删除失败!"); } List BlackPhoneList=blackPhonedao.getAllTbBlackPhone("tb_blackPhone","createTime",""); request.getSession().setAttribute("BlackPhoneList",BlackPhoneList); response.sendRedirect("AddressListModule/BlackPhoneList.jsp?s=1"); }else if(method.equals("importBlackPhoneSubmit")){ String realImagePath = Constant.decodeString(request .getParameter("realImagePath")); String tempPath = request.getRealPath("/") + "upload".replace("\\", "/"); String result = ""; File file = new File(tempPath); if(!file.isFile()){ file.mkdirs(); } // new a SmartUpload object SmartUpload su = new SmartUpload(); su.setCharset("UTF-8");// 使用时候最关键的一步 // 上传初始化 su.initialize(this.getServletConfig(),request,response); // 设定上传限制 // 1.限制每个上传文件的最大长度。 su.setMaxFileSize(10000000); // 2.限制总上传数据的长度。 su.setTotalMaxFileSize(20000000); // 3.设定允许上传的文件(通过扩展名限制),仅允许doc,txt文件。 su.setAllowedFilesList("xls,XLS"); boolean sign = true; // 4.设定禁止上传的文件(通过扩展名限制),禁止上传带有exe,bat,jsp,htm,html扩展名的文件和没有扩展名的文件。 try { su.setDeniedFilesList("exe,bat,jsp,htm,html"); // 上传文件 su.upload(); // 将上传文件保存到指定目录 tempPath = tempPath.replace("\\", "/"); tempPath = tempPath + "/"; su.save(tempPath); System.out.println("文件名称"+su.getFiles().getFile(0).getFileName()); tempPath += "\\" + su.getFiles().getFile(0).getFileName(); tempPath = tempPath.replace("\\", "/"); tempPath = tempPath.replace("//", "/"); System.out.println("tempsssssssssssssPath==="+tempPath); Workbook wb; InputStream is2 = new FileInputStream(tempPath); wb = Workbook.getWorkbook(is2); Sheet sheet = wb.getSheet(0); int row = sheet.getRows(); List<BlackPhoneBean> BlackPhoneList = new ArrayList<BlackPhoneBean>(); //// 表结构是:手机号码,当前时间 for(int i = 1;i<row;i++){ Cell firstCell = sheet.getCell(0, i); String firstContent = firstCell.getContents(); BlackPhoneBean blackphoneBean = new BlackPhoneBean(); blackphoneBean.setPhone(firstContent); blackphoneBean.setCreateTime(Constant.decodeDate()); blackphoneBean.setUserid(user.getUserId()); BlackPhoneList.add(blackphoneBean); } if(BlackPhoneList!=null&&BlackPhoneList.size()>0){ boolean bo = new BlackPhoneModuleDao().saveBlackPhoneList(BlackPhoneList); if(bo){ result="黑名单号码导入成功"; }else{ result="黑名单号码导入失败"; } } } catch (Exception e) { e.printStackTrace(); } List BlackPhoneList=null; BlackPhoneList=blackPhonedao.getAllTbBlackPhone("tb_blackPhone","createTime",""); request.getSession().setAttribute("phone", ""); request.getSession().setAttribute("resultSM", result); request.getSession().setAttribute("BlackPhoneList",BlackPhoneList); response.sendRedirect("AddressListModule/BlackPhoneList.jsp?s=1"); }else if(method.equals("addBlackPhoneSubmit")){ String blackphone=request.getParameter("blackphone"); List<BlackPhoneBean> blackphoneList = new ArrayList<BlackPhoneBean>(); BlackPhoneBean blackphoneBean = new BlackPhoneBean(); blackphoneBean.setPhone(blackphone); blackphoneBean.setCreateTime(Constant.decodeDate()); blackphoneBean.setUserid(user.getUserId()); blackphoneList.add(blackphoneBean); String result=""; boolean bo = new BlackPhoneModuleDao().saveBlackPhoneList(blackphoneList); if(bo){ result="黑名单号码新增成功"; }else{ result="黑名单号码新增失败"; } List BlackPhoneList=null; BlackPhoneList=blackPhonedao.getAllTbBlackPhone("tb_blackPhone","createTime",""); request.getSession().setAttribute("phone", ""); request.getSession().setAttribute("resultSM", result); request.getSession().setAttribute("BlackPhoneList",BlackPhoneList); response.sendRedirect("AddressListModule/BlackPhoneList.jsp?s=1"); } } @Override protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { // TODO Auto-generated method stub this.doGet(request, response); } @Override public void init() throws ServletException { super.init(); } }
zzprojects
trunk/zzprojects/zzClub/src/com/BlackPhoneModule/servlet/BlackPhoneModuleServlet.java
Java
asf20
7,797
package com.BlackPhoneModule.dao; import java.sql.Connection; import java.sql.PreparedStatement; import java.sql.ResultSet; import java.sql.Statement; import java.util.ArrayList; import java.util.List; import util.ConnectDB; import util.UtilDAO; import com.BlackPhoneModule.bean.BlackPhoneBean; public class BlackPhoneModuleDao { // 数据库连接 private Connection conn = null; // st对象 private PreparedStatement pt = null; private Statement st = null; // 结果集 private ResultSet rs = null; // 成功失败标志 private boolean flag = false; // 要执行的语句 private String sql = ""; private BlackPhoneBean blackPhoneBean = null; private List<BlackPhoneBean> blackPhoneList = null; //显示所有黑名单 public List<BlackPhoneBean> getAllTbBlackPhone(String tableName,String order,String tiaojian){ try{ conn = ConnectDB.getSqlServerConnection(); sql= UtilDAO.getList(tableName, order, tiaojian); System.out.println("查询语句"+sql); pt = conn.prepareStatement(sql); rs = pt.executeQuery(); while(rs.next()){ if(blackPhoneList==null){ blackPhoneList = new ArrayList<BlackPhoneBean>(); } blackPhoneList.add(this.getblackPhoneList(rs)); } }catch(Exception e){ System.out.println("error!!!!!!!!!!"); return null; }finally{ ConnectDB.closeSqlConnection(); } return blackPhoneList; } /** * *@author qingyu zhang *@function:get a object from ResultSet * @param rs * @return *2011-2-17 *下午03:03:01 *AddressListModule *com.AddressListModule.dao *DirectoryBean */ public BlackPhoneBean getblackPhoneList(ResultSet rs){ BlackPhoneBean blackPhone = new BlackPhoneBean(); try{ blackPhone.setCreateTime(rs.getString("createTime")); blackPhone.setId(rs.getInt("id")); blackPhone.setPhone(rs.getString("phone")); blackPhone.setUserid(rs.getInt("userid")); }catch(Exception e){ e.printStackTrace(); }finally{ return blackPhone; } } /** * 单条记录删除 * jhc * 2011-1-27 下午02:30:38 */ public boolean del(String tableName,String keyId,String idList){ boolean bo = UtilDAO.del(tableName, keyId, idList); return bo ; } /** * 多项删除 * jhc * 2011-1-27 下午02:30:38 */ public boolean delin(String tableName,String keyId,String idList){ boolean bo = UtilDAO.delin(tableName, keyId, idList); return bo ; } public boolean saveBlackPhoneList(List<BlackPhoneBean> blackphoneList){ boolean bo = false; try { conn = ConnectDB.getSqlServerConnection(); st = conn.createStatement(); if(blackphoneList!=null&&blackphoneList.size()>0){ for(BlackPhoneBean blackphone:blackphoneList){ String hql = "insert into tb_blackPhone (phone,createTime,userid) " + "values('"+blackphone.getPhone()+"','"+blackphone.getCreateTime()+"',"+blackphone.getUserid()+")"; System.out.println("hql==="+hql); st.addBatch(hql); } st.executeBatch(); bo = true; } }catch(Exception e){ e.printStackTrace(); bo = false; }finally{ ConnectDB.closeSqlConnection(); return bo ; } } }
zzprojects
trunk/zzprojects/zzClub/src/com/BlackPhoneModule/dao/BlackPhoneModuleDao.java
Java
asf20
3,223
package com.AddressListModule.bean; public class TbUserDirectory { /** *@author qingyu zhang *@function: *2011-2-25 *上午10:20:18 *MmsModule *com.UserModule.bean */ private int user_directoryId; private int userId; private int directoryId; private String createDate; public int getUser_directoryId() { return user_directoryId; } public void setUser_directoryId(int user_directoryId) { this.user_directoryId = user_directoryId; } public int getUserId() { return userId; } public void setUserId(int userId) { this.userId = userId; } public int getDirectoryId() { return directoryId; } public void setDirectoryId(int directoryId) { this.directoryId = directoryId; } public String getCreateDate() { return createDate; } public void setCreateDate(String createDate) { this.createDate = createDate; } }
zzprojects
trunk/zzprojects/zzClub/src/com/AddressListModule/bean/TbUserDirectory.java
Java
asf20
894
package com.AddressListModule.bean; import java.io.Serializable; import java.util.Date; public class ContactBean implements Serializable{ /** *@author qingyu zhang *@function: *2011-2-17 *02:09:59 *AddressListModule *com.AddressListModule.bean */ private int customerId; private String customerName; private String customerPhone; private String customerIntegral; private int dirId; private String lastTime; public int getCustomerId() { return customerId; } public void setCustomerId(int customerId) { this.customerId = customerId; } public String getCustomerName() { return customerName; } public void setCustomerName(String customerName) { this.customerName = customerName; } public String getCustomerPhone() { return customerPhone; } public void setCustomerPhone(String customerPhone) { this.customerPhone = customerPhone; } public String getCustomerIntegral() { return customerIntegral; } public void setCustomerIntegral(String customerIntegral) { this.customerIntegral = customerIntegral; } public int getDirId() { return dirId; } public void setDirId(int dirId) { this.dirId = dirId; } public String getLastTime() { return lastTime; } public void setLastTime(String lastTime) { this.lastTime = lastTime; } }
zzprojects
trunk/zzprojects/zzClub/src/com/AddressListModule/bean/ContactBean.java
Java
asf20
1,352
package com.AddressListModule.bean; import java.io.Serializable; import java.util.Date; public class DirectoryBean implements Serializable{ /** *@author qingyu zhang *@function: *2011-2-17 *02:09:31 *AddressListModule *com.AddressListModule.bean */ private int dirId; private int dirLevel; private int parentDirId; private String dirName; private int userId; //private Date createTime; private String createTime; public String getCreateTime() { return createTime; } public void setCreateTime(String createTime) { this.createTime = createTime; } public int getDirId() { return dirId; } public void setDirId(int dirId) { this.dirId = dirId; } public int getDirLevel() { return dirLevel; } public void setDirLevel(int dirLevel) { this.dirLevel = dirLevel; } public int getParentDirId() { return parentDirId; } public void setParentDirId(int parentDirId) { this.parentDirId = parentDirId; } public String getDirName() { return dirName; } public void setDirName(String dirName) { this.dirName = dirName; } public int getUserId() { return userId; } public void setUserId(int userId) { this.userId = userId; } /*public Date getCreateTime() { return createTime; } public void setCreateTime(Date createTime) { this.createTime = createTime; }*/ }
zzprojects
trunk/zzprojects/zzClub/src/com/AddressListModule/bean/DirectoryBean.java
Java
asf20
1,387
package com.AddressListModule.bean; import java.io.Serializable; import java.util.Date; public class KehujifenBean implements Serializable{ /** *@author qingyu zhang *@function: *2011-2-17 *02:09:59 *AddressListModule *com.AddressListModule.bean */ private int customerId; private String customerName; private String customerPhone; private String customerIntegral; private int dirId; private String lastTime; public int getCustomerId() { return customerId; } public void setCustomerId(int customerId) { this.customerId = customerId; } public String getCustomerName() { return customerName; } public void setCustomerName(String customerName) { this.customerName = customerName; } public String getCustomerPhone() { return customerPhone; } public void setCustomerPhone(String customerPhone) { this.customerPhone = customerPhone; } public String getCustomerIntegral() { return customerIntegral; } public void setCustomerIntegral(String customerIntegral) { this.customerIntegral = customerIntegral; } public int getDirId() { return dirId; } public void setDirId(int dirId) { this.dirId = dirId; } public String getLastTime() { return lastTime; } public void setLastTime(String lastTime) { this.lastTime = lastTime; } }
zzprojects
trunk/zzprojects/zzClub/src/com/AddressListModule/bean/KehujifenBean.java
Java
asf20
1,354
package com.AddressListModule.servlet; import java.io.File; import java.io.FileInputStream; import java.io.IOException; import java.io.InputStream; import java.io.PrintWriter; import java.util.ArrayList; import java.util.List; import java.util.Random; import javax.servlet.ServletException; import javax.servlet.http.HttpServlet; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; import jxl.Cell; import jxl.Sheet; import jxl.Workbook; import util.Constant; import util.UtilDAO; import com.AddressListModule.bean.DirectoryBean; import com.AddressListModule.bean.KehujifenBean; import com.AddressListModule.bean.TbUserDirectory; import com.AddressListModule.dao.AddressModuleDao; import com.AddressListModule.dao.KehujifenModuleDao; import com.AddressListModule.dao.TbUserDirectoryDAO; import com.UserModule.bean.TbUserBean; import com.UserModule.dao.TbUserDAO; import com.dianbo.bean.Dianbo; import com.dianbo.bean.DianboType; import com.dianbo.dao.DianboDao; import com.dianbo.dao.DianboTypeDao; import com.jspsmart.upload.SmartUpload; public class KehujifenServlet extends HttpServlet { protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { response.setContentType("text/html"); String method= request.getParameter("method");//get the name of method PrintWriter out = response.getWriter(); TbUserBean user = (TbUserBean)request.getSession().getAttribute("User"); if(method.equals("lookContact")){//show the contact String page = request.getParameter("Page"); String phone = request.getParameter("phone"); String condition = "1=1"; if(!phone.equals("")){ condition+=" and customerPhone='"+phone+"'"; } List<KehujifenBean> kehujifenList = new KehujifenModuleDao().getContactList("tb_kehujifen", "lastTime", condition); request.getSession().setAttribute("phone", phone); request.getSession().setAttribute("kehujifenList", kehujifenList); request.getSession().setAttribute("resultAdd", ""); response.sendRedirect("AddressListModule/kehujifenList.jsp?Page="+page); }else if(method.equals("modifyContact")){//modify a linkMan String contactId = request.getParameter("mmsId"); int num = new Random().nextInt(10000); KehujifenBean kehujifenBean = new KehujifenModuleDao().getContact(contactId); List<KehujifenBean> kehujifenList=new ArrayList<KehujifenBean>(); kehujifenList.add(kehujifenBean); request.getSession().setAttribute("kehujifenBean", kehujifenBean); response.sendRedirect("AddressListModule/modifyKehujifen.jsp?num="+num); }else if(method.equals("modifyContactSubmit")){//modify a linkMan submit int num = new Random().nextInt(10000); //String linkMan = Constant.decodeString(request.getParameter("linkName")); String linkPhone = Constant.decodeString(request.getParameter("linkPhone")); String contactId = request.getParameter("mmsId"); String customerIntegral=request.getParameter("customerIntegral");//积分 KehujifenBean kehujifenBean = new KehujifenBean(); kehujifenBean.setCustomerId(Integer.parseInt(contactId)); kehujifenBean.setCustomerIntegral(customerIntegral); kehujifenBean.setCustomerPhone(linkPhone); kehujifenBean.setLastTime(Constant.decodeDate()); String condition = "1=1"; if(!linkPhone.equals("")){ condition+=" and customerPhone='"+linkPhone+"'"; } boolean bo = new KehujifenModuleDao().modifyContact(kehujifenBean); List<KehujifenBean> kehujifenList = new KehujifenModuleDao().getContactList("tb_kehujifen", "lastTime", condition); request.getSession().setAttribute("phone", linkPhone); request.getSession().setAttribute("kehujifenList", kehujifenList); response.sendRedirect("AddressListModule/kehujifenList.jsp?num="+num); }else if(method.equals("searchContact")){//search the contact String phone = request.getParameter("phone"); String condition = "1=1"; if(!phone.equals("")){ condition+=" and customerPhone='"+phone+"'"; } List<KehujifenBean> kehujifenList = new KehujifenModuleDao().getContactList("tb_kehujifen", "lastTime", condition); request.getSession().setAttribute("phone", phone); request.getSession().setAttribute("kehujifenList", kehujifenList); response.sendRedirect("AddressListModule/kehujifenList.jsp"); }else if(method.equals("deleteAllContact")){ String mmsId = request.getParameter("idList"); mmsId = mmsId.substring(0, mmsId.length()-1); String phone = request.getParameter("phone"); String condition = " tb_kehujifen where customerId in("+mmsId+")"; boolean bo = UtilDAO.delAll(condition); String conditionT = "1=1"; if(!phone.equals("")){ conditionT+=" and customerPhone='"+phone+"'"; } List<KehujifenBean> kehujifenList = new KehujifenModuleDao().getContactList("tb_kehujifen", "lastTime", conditionT); request.getSession().setAttribute("phone", phone); request.getSession().setAttribute("kehujifenList", kehujifenList); request.getSession().setAttribute("resultAdd", "删除成功"); response.sendRedirect("AddressListModule/kehujifenList.jsp"); }else if(method.equals("deleteContact")){//delete a contact String mmsId = request.getParameter("mmsId"); String phone = request.getParameter("phone"); boolean bo = UtilDAO.del("tb_kehujifen", "customerId", Integer.parseInt(mmsId)); String conditionT = "1=1"; if(!phone.equals("")){ conditionT+=" and customerPhone='"+phone+"'"; } List<KehujifenBean> kehujifenList = new KehujifenModuleDao().getContactList("tb_kehujifen", "lastTime", conditionT); request.getSession().setAttribute("phone", phone); request.getSession().setAttribute("kehujifenList", kehujifenList); request.getSession().setAttribute("resultAdd", "删除成功"); response.sendRedirect("AddressListModule/kehujifenList.jsp"); } else if(method.equals("importjifenSubmit")){ String realImagePath = Constant.decodeString(request .getParameter("realImagePath")); String tempPath = request.getRealPath("/") + "upload".replace("\\", "/"); String result = ""; File file = new File(tempPath); if(!file.isFile()){ file.mkdirs(); } // new a SmartUpload object SmartUpload su = new SmartUpload(); su.setCharset("UTF-8");// 使用时候最关键的一步 // 上传初始化 su.initialize(this.getServletConfig(),request,response); // 设定上传限制 // 1.限制每个上传文件的最大长度。 su.setMaxFileSize(10000000); // 2.限制总上传数据的长度。 su.setTotalMaxFileSize(20000000); // 3.设定允许上传的文件(通过扩展名限制),仅允许doc,txt文件。 su.setAllowedFilesList("xls,XLS"); boolean sign = true; // 4.设定禁止上传的文件(通过扩展名限制),禁止上传带有exe,bat,jsp,htm,html扩展名的文件和没有扩展名的文件。 try { su.setDeniedFilesList("exe,bat,jsp,htm,html"); // 上传文件 su.upload(); // 将上传文件保存到指定目录 tempPath = tempPath.replace("\\", "/"); tempPath = tempPath + "/"; su.save(tempPath); System.out.println("文件名称"+su.getFiles().getFile(0).getFileName()); tempPath += "\\" + su.getFiles().getFile(0).getFileName(); tempPath = tempPath.replace("\\", "/"); tempPath = tempPath.replace("//", "/"); System.out.println("tempsssssssssssssPath==="+tempPath); Workbook wb; InputStream is2 = new FileInputStream(tempPath); wb = Workbook.getWorkbook(is2); Sheet sheet = wb.getSheet(0); int row = sheet.getRows(); List<KehujifenBean> kehujifenList = new ArrayList<KehujifenBean>(); List allphoneList = new KehujifenModuleDao().allphone(); List phoneList=new ArrayList(); //// 表:手机号码,积分 for(int i = 1;i<row;i++){ Cell firstCell = sheet.getCell(0, i); String firstContent = firstCell.getContents(); Cell secondCell = sheet.getCell(1, i); String secondContent = secondCell.getContents(); System.out.println("手机号码"+firstContent); if(allphoneList.contains(firstContent) || phoneList.contains(firstContent)){ continue; }else { phoneList.add(firstContent); KehujifenBean kehujifenbean=new KehujifenBean(); kehujifenbean.setCustomerName(""); kehujifenbean.setCustomerIntegral(secondContent); kehujifenbean.setCustomerPhone(firstContent); kehujifenbean.setLastTime(Constant.decodeDate()); kehujifenList.add(kehujifenbean); } } System.out.println("kehujifenList:++++"+kehujifenList.size()); if(kehujifenList!=null&&kehujifenList.size()>0){ boolean bo = new KehujifenModuleDao().saveContactList(kehujifenList); if(bo){ result="客户信息导入成功"; }else{ result="客户信息导入失败"; } } } catch (Exception e) { e.printStackTrace(); } List<KehujifenBean> kehujifenList = new KehujifenModuleDao().getContactList("tb_kehujifen", "lastTime", ""); request.getSession().setAttribute("phone", ""); request.getSession().setAttribute("kehujifenList", kehujifenList); request.getSession().setAttribute("resultAdd", result); response.sendRedirect("AddressListModule/kehujifenList.jsp"); }else if(method.equals("addkehuSubmit")){ String phone=request.getParameter("addphone"); String jifen=request.getParameter("jifen"); KehujifenBean kehujifenbean=new KehujifenBean(); kehujifenbean.setCustomerIntegral(jifen); kehujifenbean.setCustomerPhone(phone); kehujifenbean.setCustomerName(""); kehujifenbean.setDirId(0); kehujifenbean.setLastTime(Constant.decodeDate()); List allphoneList = new KehujifenModuleDao().allphone(); String result=""; if(allphoneList.contains(phone)){ result="此手机号码已存在,请重新添加"; }else{ boolean bo = new KehujifenModuleDao().addContact(kehujifenbean); System.out.println("bo:|||"+bo); if(bo){ result="客户信息新增成功"; }else{ result="客户信息新增失败"; } } List<KehujifenBean> kehujifenList = new KehujifenModuleDao().getContactList("tb_kehujifen", "lastTime", ""); request.getSession().setAttribute("phone", ""); request.getSession().setAttribute("kehujifenList", kehujifenList); request.getSession().setAttribute("resultAdd", result); response.sendRedirect("AddressListModule/kehujifenList.jsp"); } } /** * *@author qingyu zhang *@function:在新建用户时对其进行通讯录赋值时的操作 * @param dirName * @param startTime * @param endTime * @return *2011-3-4 *上午09:08:13 *UserModule *com.AddressListModule.servlet *List<DirectoryBean> */ public List<DirectoryBean> getTopDirectryListUser(String dirName,String startTime,String endTime ){ List<DirectoryBean> directoryList = new ArrayList(); String condition = ""; if(!dirName.equals("")){ condition+=" and dirName like'%"+dirName+"%'"; } directoryList = new KehujifenModuleDao().getAllTbDirectory("tb_directory","createTime",condition); return directoryList; } /** * *@author qingyu zhang *@function:在用户表中对一个用户的通讯录群组进行修改 * @param sb * @param parDirId * @param request * @return *2011-3-3 *下午04:18:12 *UserModule *com.AddressListModule.servlet *String */ public String getDirStringByRoleUser(StringBuffer sb,int parDirId,HttpServletRequest request,List<String> str){ System.out.println("come heree!!!!!!====!!!"+str.size()); StringBuffer sssb = null; if(sb==null){ sssb = new StringBuffer(); }else{ sssb = sb ; } String condition = "parentDirId="+parDirId; System.out.println("condition=-"+condition); List<DirectoryBean> dirList = new KehujifenModuleDao().getAllTbDirectory("tb_directory","createTime",condition); if(dirList!=null&&dirList.size()>0){ sssb.append(" <ul class=\"treeview\">"); for(DirectoryBean dir:dirList){ //sbALL.append(" <ul class=\"treeview\">"); String strcheck=""; if(str.contains(String.valueOf(dir.getDirId()))){ strcheck="checked"; } sssb.append("<li><input type=\"checkbox\""+strcheck+" name=\"select_Dir\" id=\""+dir.getDirId()+"\" onclick=\"ts(this);\" /><a>"+dir.getDirName()+"</a>"); /*if(tbUser.getUserState()==0){//superadmin sssb.append("<li><input type=\"checkbox\" name=\"select_Dir\" id=\""+dir.getDirId()+"\" onclick=\"ts(this);\" /><a>"+dir.getDirName()+"</a>"); }else{ if(commonDirList.contains(dir)){ sssb.append("<li><input type=\"checkbox\" name=\"select_Dir\" id=\""+dir.getDirId()+"\" onclick=\"ts(this);\" /><a>"+dir.getDirName()+"</a>"); } }*/ this.getDirStringByRoleUser(sssb,dir.getDirId(),request,str); sssb.append("</li>"); } sssb.append("</ul>"); }else{ //sbALL.append("</li>"); } //sbALL.append("</li>"); return sssb.toString(); } /** * *@author qingyu zhang *@function:get the records by conditions * @param dirName * @param tiaojian * @return *2011-2-17 *下午02:32:23 *AddressListModule *com.AddressListModule.servlet *List<DirectoryBean> */ public List<DirectoryBean> getDirectryList(String tiaojian ){ List<DirectoryBean> directoryList = new ArrayList(); String condition = ""; condition=tiaojian; directoryList = new KehujifenModuleDao().getAllTbDirectory("tb_directory","createTime",condition); return directoryList; } /** * *@author qingyu zhang *@function:get the first level Directory * @param dirName * @param startTime * @param endTime * @return *2011-2-17 *下午03:12:49 *AddressListModule *com.AddressListModule.servlet *List<DirectoryBean> */ public List<DirectoryBean> getTopDirectryList(String dirName,String startTime,String endTime ){ List<DirectoryBean> directoryList = new ArrayList(); String condition = ""; condition+="dirLevel=0 "; if(!startTime.equals("")){ condition+=" and userId="+startTime; } if(!dirName.equals("")){ condition+=" and dirName like'%"+dirName+"%'"; } directoryList = new KehujifenModuleDao().getAllTbDirectory("tb_directory","createTime",condition); return directoryList; } /** * *@author qingyu zhang *@function:have not the checkBox * @param parDirId * @return *2011-2-19 *上午11:09:38 *AddressListModule *com.AddressListModule.servlet *String */ public String getDirStringShow(StringBuffer sb,int parDirId){ StringBuffer ssb =null; if(sb==null){ ssb = new StringBuffer(); }else{ ssb = sb; } String condition = "parentDirId="+parDirId; List<DirectoryBean> dirList = new KehujifenModuleDao().getAllTbDirectory("tb_directory","createTime",condition); if(dirList!=null&&dirList.size()>0){ ssb.append(" <ul class=\"treeview\">"); for(DirectoryBean dir:dirList){ //sbALL.append(" <ul class=\"treeview\">"); ssb.append("<li class=\""+dir.getDirId()+"\"><a onClick=\"$.msgbox({height:510,width:800,content:{type:'iframe',content:'./AddressServlet?method=getLinkMan&Page=1&Page=1&dirId="+dir.getDirId()+"'},title: '联系人列表'})\" value=\""+dir.getDirName()+"\" >"+dir.getDirName()+"</a><span title=\"添加通讯录\" class=\"addnode\"><a style=\"cursor:hand\" onclick=\"$mb=$.msgbox({height:220,width:500,content:{type:\'ajax\',content:\'./AddressServlet?method=addDir&dirLevel="+dir.getDirLevel()+"&dirId="+dir.getDirId()+"\'},title:\'新增通讯录\',onAjaxed: function(data){}});\">添加通讯录</a></span><span title=\"编辑通讯录\" class=\"editnode\"><a style=\"cursor:hand\" onclick=\"$mb=$.msgbox({height:220,width:500,content:{type:\'ajax\',content:\'./AddressServlet?method=modifyDir&dirLevel="+dir.getDirLevel()+"&dirId="+dir.getDirId()+"\'},title:\'编辑通讯录\',onAjaxed: function(data){}});\">编辑通讯录</a></span><span title=\"删除通讯录\" class=\"delnode\"><a style=\"cursor:hand\" onclick=\"$mb=$.msgbox({height:220,width:500,content:{type:\'ajax\',content:\'./AddressServlet?method=deleteDir&dirLevel="+dir.getDirLevel()+"&dirId="+dir.getDirId()+"\'},title:\'删除通讯录\',onAjaxed: function(data){}});\">删除通讯录</a></span><span title=\"新增联系人\" class=\"addLinkMan\"><a style=\"cursor:hand\" onclick=\"$mb=$.msgbox({height:400,width:500,content:{type:\'ajax\',content:\'./AddressServlet?method=addLinkMan&dirLevel="+dir.getDirLevel()+"&dirId="+dir.getDirId()+"\'},title:\'新增联系人\',onAjaxed: function(data){}});\">新增联系人</a></span><span title=\"导入联系人\" class=\"importLinkMan\"><a style=\"cursor:hand\" onclick=\"$mb=$.msgbox({height:220,width:500,content:{type:\'ajax\',content:\'./AddressServlet?method=importLinkMan&dirLevel="+dir.getDirLevel()+"&dirId="+dir.getDirId()+"\'},title:\'导入联系人\',onAjaxed: function(data){}});\">导入联系人</a></span>"); this.getDirStringShow(ssb,dir.getDirId()); ssb.append("</li>"); } ssb.append("</ul>"); }else{ //sbALL.append("</li>"); } //sbALL.append("</li>"); return ssb.toString(); } /** * *@author qingyu zhang *@function:get the linkMan by directoryId * @param dirId * @return *2011-2-19 *下午02:46:09 *AddressListModule *com.AddressListModule.servlet *StringBuffer */ public List getLinkMan(int dirId){ String condition ="dirId="+dirId; List<KehujifenBean> kehujifenList = new KehujifenModuleDao().getContactList("tb_kehujifen", "lastTime", condition); if(kehujifenList==null){ kehujifenList = new ArrayList(); } return kehujifenList; } /** * *@author qingyu zhang *@function:get linkMans by dirIds (1,2,3,4....) * @param dirIds * @return *2011-2-26 *下午03:15:42 *MmsModule *com.AddressListModule.servlet *List */ public List<KehujifenBean> getLinkMans(String tiaojian){ String condition =tiaojian; List<KehujifenBean> kehujifenList = new KehujifenModuleDao().getContactList("tb_kehujifen", "lastTime", condition); if(kehujifenList==null){ kehujifenList = new ArrayList(); } return kehujifenList; } /** * *@author qingyu zhang *@function:get the directory by role * @param dirName * @param tiaojian * @return *2011-2-25 *上午10:18:31 *MmsModule *com.AddressListModule.servlet *List<DirectoryBean> */ public List<TbUserDirectory> getDirectryListByRole(String tiaojian ){ List<TbUserDirectory> directoryList = new ArrayList(); String condition = ""; condition=tiaojian; directoryList = new KehujifenModuleDao().getUserDirByRole("tb_userDirectory","createDate",condition); return directoryList; } /** * *@author qingyu zhang *@function:get a Directory * @param tableName * @param inKey * @param keyValue * @return *2011-2-25 *上午10:46:13 *MmsModule *com.AddressListModule.servlet *DirectoryBean */ public DirectoryBean getDirectory(String tableName,String inKey,int keyValue){ DirectoryBean dir = new KehujifenModuleDao().getDirectory(tableName, inKey,keyValue); return dir; } /** * *@author qingyu zhang *@function:get common direcotry from tb_userDirectory * @param sb * @param parDirId * @return *2011-2-25 *上午10:51:49 *MmsModule *com.AddressListModule.servlet *String */ public String getDirStringByRole(StringBuffer sb,int parDirId,HttpServletRequest request){ StringBuffer sssb = null; if(sb==null){ sssb = new StringBuffer(); }else{ sssb = sb ; } TbUserBean tbUser = (TbUserBean)request.getSession().getAttribute("User"); String condition = "parentDirId="+parDirId; List<DirectoryBean> dirList = new KehujifenModuleDao().getAllTbDirectory("tb_directory","createTime",condition); if(dirList!=null&&dirList.size()>0){ sssb.append(" <ul class=\"treeview\">"); for(DirectoryBean dir:dirList){ //sbALL.append(" <ul class=\"treeview\">"); sssb.append("<li><input type=\"checkbox\" name=\"select_Dir\" id=\""+dir.getDirId()+"\" onclick=\"ts(this);\" /><a>"+dir.getDirName()+"</a>"); /*if(tbUser.getUserState()==0){//superadmin sssb.append("<li><input type=\"checkbox\" name=\"select_Dir\" id=\""+dir.getDirId()+"\" onclick=\"ts(this);\" /><a>"+dir.getDirName()+"</a>"); }else{ if(commonDirList.contains(dir)){ sssb.append("<li><input type=\"checkbox\" name=\"select_Dir\" id=\""+dir.getDirId()+"\" onclick=\"ts(this);\" /><a>"+dir.getDirName()+"</a>"); } }*/ this.getDirStringByRole(sssb,dir.getDirId(),request); sssb.append("</li>"); } sssb.append("</ul>"); }else{ //sbALL.append("</li>"); } //sbALL.append("</li>"); return sssb.toString(); } /** * *@author qingyu zhang *@function:所赋予权限中通讯录只有大于一级目录的存在 * @param commonDirList * @param condition * @return *2011-3-1 *上午09:23:28 *MmsModule *com.AddressListModule.servlet *List<DirectoryBean> 7 5 */ public List<String> dirLst(List<DirectoryBean> commonDirList){ List<String> lastDirLst = new ArrayList<String>(); for(DirectoryBean db :commonDirList){ lastDirLst.add(String.valueOf(db.getDirId())); } for(DirectoryBean directory:commonDirList){ String condition ="parentDirId="+directory.getDirId(); List<DirectoryBean> chilDirectory= this.getDirectryList(condition); if(chilDirectory!=null&&chilDirectory.size()>0){ for(int v = 0;v<chilDirectory.size();v++){ DirectoryBean chilDir = chilDirectory.get(v); if(lastDirLst.contains(String.valueOf(chilDir.getDirId()))){ boolean bo = lastDirLst.remove(String.valueOf(chilDir.getDirId())); } } } } return lastDirLst; } @Override protected void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException { // TODO Auto-generated method stub this.doGet(req, resp); } /** *@author qingyu zhang *@function: *2011-2-17 *下午02:13:57 *AddressListModule *com.AddressListModule.servlet */ }
zzprojects
trunk/zzprojects/zzClub/src/com/AddressListModule/servlet/KehujifenServlet.java
Java
asf20
22,614
package com.AddressListModule.servlet; import java.io.File; import java.io.FileInputStream; import java.io.IOException; import java.io.InputStream; import java.io.PrintWriter; import java.util.ArrayList; import java.util.Date; import java.util.List; import java.util.Random; import javax.servlet.ServletException; import javax.servlet.http.HttpServlet; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; import jxl.Cell; import jxl.Sheet; import jxl.Workbook; import util.Constant; import util.UtilDAO; import com.AddressListModule.bean.ContactBean; import com.AddressListModule.bean.DirectoryBean; import com.AddressListModule.bean.TbUserDirectory; import com.AddressListModule.dao.AddressModuleDao; import com.AddressListModule.dao.TbUserDirectoryDAO; import com.UserModule.bean.TbUserBean; import com.UserModule.dao.*; import com.jspsmart.upload.SmartUpload; public class AddressModuleServlet extends HttpServlet { protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { response.setContentType("text/html"); String method= request.getParameter("method");//get the name of method PrintWriter out = response.getWriter(); TbUserBean user = (TbUserBean)request.getSession().getAttribute("User"); if(method.equals("lookDir")){//show the record of directory StringBuffer sb = new StringBuffer(); String dirName = Constant.decodeString(request.getParameter("dirName")); String dingwei = request.getParameter("dingwei"); List<DirectoryBean> topDirectoryList = this.getTopDirectryList("", String.valueOf(user.getUserId()), "");//get the first level directory sb.append(" <li class=\"0\"><a>通讯录</a><span title=\"添加通讯录\" class=\"addnode\"><a style=\"cursor:hand\" onclick=\"$mb=$.msgbox({height:220,width:500,content:{type:\'ajax\',content:\'./AddressServlet?method=addDir&dirLevel=-1&dirId=0\'},title:\'新增通讯录\',onAjaxed: function(data){}});\">添加通讯录</a></span><ul>"); if(topDirectoryList!=null&&topDirectoryList.size()>0){ for(int i = 0;i<topDirectoryList.size();i++){ DirectoryBean directoryBean =(DirectoryBean)topDirectoryList.get(i); sb.append(" <li class=\""+directoryBean.getDirId()+"\"><a onClick=\"$.msgbox({height:510,width:800,content:{type:'iframe',content:'./AddressServlet?method=getLinkMan&Page=1&dirId="+directoryBean.getDirId()+"'},title: '联系人列表'})\" value=\""+directoryBean.getDirName()+"\" >"+directoryBean.getDirName()+"</a><span title=\"添加通讯录\" class=\"addnode\"><a style=\"cursor:hand\" onclick=\"$mb=$.msgbox({height:220,width:500,content:{type:\'ajax\',content:\'./AddressServlet?method=addDir&dirLevel="+directoryBean.getDirLevel()+"&dirId="+directoryBean.getDirId()+"\'},title:\'新增通讯录\',onAjaxed: function(data){}});\">添加通讯录</a></span><span title=\"编辑通讯录\" class=\"editnode\"><a style=\"cursor:hand\" onclick=\"$mb=$.msgbox({height:220,width:500,content:{type:\'ajax\',content:\'./AddressServlet?method=modifyDir&dirLevel="+directoryBean.getDirLevel()+"&dirId="+directoryBean.getDirId()+"\'},title:\'编辑通讯录\',onAjaxed: function(data){}});\">编辑通讯录</a></span><span title=\"删除通讯录\" class=\"delnode\"><a style=\"cursor:hand\" onclick=\"$mb=$.msgbox({height:220,width:500,content:{type:\'ajax\',content:\'./AddressServlet?method=deleteDir&dirLevel="+directoryBean.getDirLevel()+"&dirId="+directoryBean.getDirId()+"\'},title:\'删除通讯\',onAjaxed: function(data){}});\">删除通讯录</a></span><span title=\"新增联系人\" class=\"addLinkMan\"><a style=\"cursor:hand\" onclick=\"$mb=$.msgbox({height:400,width:500,content:{type:\'ajax\',content:\'./AddressServlet?method=addLinkMan&dirLevel="+directoryBean.getDirLevel()+"&dirId="+directoryBean.getDirId()+"\'},title:\'新增联系人\',onAjaxed: function(data){}});\">新增联系人</a></span><span title=\"导入联系人\" class=\"importLinkMan\"><a style=\"cursor:hand\" onclick=\"$mb=$.msgbox({height:220,width:500,content:{type:\'ajax\',content:\'./AddressServlet?method=importLinkMan&dirLevel="+directoryBean.getDirLevel()+"&dirId="+directoryBean.getDirId()+"\'},title:\'导入联系人\',onAjaxed: function(data){}});\">导入联系人</a></span>"); String chilDirectory = this.getDirStringShow(null,directoryBean.getDirId()); sb.append(chilDirectory); sb.append("</li>"); } //sb.append("</li>"); } sb.append("</ul></li>"); request.getSession().setAttribute("sb", sb); response.sendRedirect("AddressListModule/showDirectry.jsp?dingwei="+dingwei); }else if(method.equals("addDir")){//add a directory String dirId = request.getParameter("dirId"); String dirLevel = request.getParameter("dirLevel");//the level of the directory //request.getSession().setAttribute("dirId", dirId); response.sendRedirect("AddressListModule/addDirectory.jsp?dirId="+dirId+"&dirLevel="+dirLevel); }else if(method.equals("addDirSubmit")){ StringBuffer sb = new StringBuffer(); String fatherDirId = request.getParameter("fatherDirId"); String dirLevel = request.getParameter("dirLevel");//the level of a directory String dirName = Constant.decodeString(request.getParameter("dirName")); DirectoryBean addDirectoryBean = new DirectoryBean(); addDirectoryBean.setCreateTime(Constant.decodeDate()); addDirectoryBean.setDirLevel(Integer.parseInt(dirLevel)+1); addDirectoryBean.setDirName(dirName); addDirectoryBean.setParentDirId(Integer.parseInt(fatherDirId)); addDirectoryBean.setUserId(user.getUserId()); boolean bo = new AddressModuleDao().add(addDirectoryBean); if(bo){ fatherDirId = String.valueOf(new AddressModuleDao().getDirectory("tb_directory")); } List<DirectoryBean> topDirectoryList = this.getTopDirectryList("", "","");//get the first level directory //sb.append(" <li class=\"0\"><a>通讯录</a><span title=\"添加通讯录\" class=\"addnode\"><a style=\"cursor:hand\" onclick=\"$mb=$.msgbox({height:220,width:500,content:{type:\'ajax\',content:\'../AddressServlet?method=addDir&dirLevel=-1&dirId=0\'},title:\'新增通讯录\',onAjaxed: function(data){}});\">添加通讯录</a></span><span title=\"编辑通讯录\" class=\"editnode\"><a style=\"cursor:hand\" onclick=\"$mb=$.msgbox({height:220,width:500,content:{type:\'ajax\',content:\'../AddressServlet?method=modifyDir&dirLevel=-1&dirId=0\'},title:\'编辑通讯录\',onAjaxed: function(data){}});\">编辑通讯录</a></span><span title=\"删除通讯录\" class=\"delnode\"><a style=\"cursor:hand\" onclick=\"$.msgbox({height:220,width:500,content:{type:\'ajax\',content:\'../AddressServlet?method=deleteDir&dirLevel=-1&dirId=0\'},title:\'删除通讯\',onAjaxed: function(data){}});\">删除通讯录</a></span> <ul>"); sb.append(" <li class=\"0\"><a>通讯录</a><span title=\"添加通讯录\" class=\"addnode\"><a style=\"cursor:hand\" onclick=\"$mb=$.msgbox({height:220,width:500,content:{type:\'ajax\',content:\'./AddressServlet?method=addDir&dirLevel=-1&dirId=0\'},title:\'新增通讯录\',onAjaxed: function(data){}});\">添加通讯录</a></span><span title=\"编辑通讯录\" class=\"editnode\"><a style=\"cursor:hand\" onclick=\"$mb=$.msgbox({height:220,width:500,content:{type:\'ajax\',content:\'../AddressServlet?method=modifyDir&dirLevel=-1&dirId=0\'},title:\'编辑通讯录\',onAjaxed: function(data){}});\">编辑通讯录</a></span><span title=\"删除通讯录\" class=\"delnode\"><a style=\"cursor:hand\" onclick=\"$.msgbox({height:220,width:500,content:{type:\'ajax\',content:\'../AddressServlet?method=deleteDir&dirLevel=-1&dirId=0\'},title:\'删除通讯\',onAjaxed: function(data){}});\">删除通讯录</a></span> <ul>"); if(topDirectoryList!=null&&topDirectoryList.size()>0){ for(int i = 0;i<topDirectoryList.size();i++){ DirectoryBean directoryBean =(DirectoryBean)topDirectoryList.get(i); sb.append(" <li class=\""+directoryBean.getDirId()+"\"><a onclick=\"$mb=$.msgbox({height:400,width:800,content:{type:'iframe',content:'./AddressServlet?method=getLinkMan&Page=1&dirId="+directoryBean.getDirId()+"'},title: '联系人'});\">"+directoryBean.getDirName()+"</a><span title=\"添加通讯录\" class=\"addnode\"><a style=\"cursor:hand\" onclick=\"$mb=$.msgbox({height:220,width:500,content:{type:\'ajax\',content:\'./AddressServlet?method=addDir&dirLevel="+directoryBean.getDirLevel()+"&dirId="+directoryBean.getDirId()+"\'},title:\'新增通讯录\',onAjaxed: function(data){}});\">添加通讯录</a></span><span title=\"编辑通讯录\" class=\"editnode\"><a style=\"cursor:hand\" onclick=\"$mb=$.msgbox({height:220,width:500,content:{type:\'ajax\',content:\'./AddressServlet?method=modifyDir&dirLevel="+directoryBean.getDirLevel()+"&dirId="+directoryBean.getDirId()+"\'},title:\'编辑通讯录\',onAjaxed: function(data){}});\">编辑通讯录</a></span><span title=\"删除通讯录\" class=\"delnode\"><a style=\"cursor:hand\" onclick=\"$.msgbox({height:220,width:500,content:{type:\'ajax\',content:\'./AddressServlet?method=deleteDir&dirLevel="+directoryBean.getDirLevel()+"&dirId="+directoryBean.getDirId()+"\'},title:\'删除通讯\',onAjaxed: function(data){}});\">删除通讯录</a></span><span title=\"新增联系人\" class=\"addLinkMan\"><a style=\"cursor:hand\" onclick=\"$mb=$.msgbox({height:400,width:500,content:{type:\'ajax\',content:\'./AddressServlet?method=addLinkMan&dirLevel="+directoryBean.getDirLevel()+"&dirId="+directoryBean.getDirId()+"\'},title:\'新增联系人\',onAjaxed: function(data){}});\">新增联系人</a></span><span title=\"导入联系人\" class=\"importLinkMan\"><a style=\"cursor:hand\" onclick=\"$mb=$.msgbox({height:220,width:500,content:{type:\'ajax\',content:\'./AddressServlet?method=importLinkMan&dirLevel="+directoryBean.getDirLevel()+"&dirId="+directoryBean.getDirId()+"\'},title:\'导入联系人\',onAjaxed: function(data){}});\">导入联系人</a></span>"); String chilDirectory = this.getDirStringShow(null,directoryBean.getDirId()); sb.append(chilDirectory); sb.append("</li>"); } //sb.append("</li>"); } sb.append("</ul></li>"); request.getSession().setAttribute("sb", sb); response.sendRedirect("AddressListModule/showDirectry.jsp?dingwei="+fatherDirId); }else if(method.equals("modifyDir")){//modify a directory int num = new Random().nextInt(10000); String dirLevel = request.getParameter("dirLevel"); String dirId = request.getParameter("dirId"); DirectoryBean directoryBean = new AddressModuleDao().getDirectory("tb_directory", "dirId", Integer.parseInt(dirId)); request.getSession().setAttribute("directoryBean", directoryBean); response.sendRedirect("AddressListModule/modifyDirectory.jsp?dirLevel="+dirLevel+"&num="+num); }else if(method.equals("modifyDirSubmit")){//the submit of the modify StringBuffer sb = new StringBuffer(); String dirLevel = request.getParameter("dirLevel"); String dirId = request.getParameter("dirId"); String dirName = Constant.decodeString(request.getParameter("dirName")); DirectoryBean dirBean = new DirectoryBean(); dirBean.setDirId(Integer.parseInt(dirId)); dirBean.setDirName(dirName); boolean bo = new AddressModuleDao().modifyDirectory(dirBean); List<DirectoryBean> topDirectoryList = this.getTopDirectryList("", "","");//get the first level directory sb.append(" <li class=\"0\"><a>通讯录</a><span title=\"添加通讯录\" class=\"addnode\"><a style=\"cursor:hand\" onclick=\"$mb=$.msgbox({height:220,width:500,content:{type:\'ajax\',content:\'./AddressServlet?method=addDir&dirLevel=-1&dirId=0\'},title:\'新增通讯录\',onAjaxed: function(data){}});\">添加通讯录</a></span><span title=\"编辑通讯录\" class=\"editnode\"><a style=\"cursor:hand\" onclick=\"$mb=$.msgbox({height:220,width:500,content:{type:\'ajax\',content:\'../AddressServlet?method=modifyDir&dirLevel=-1&dirId=0\'},title:\'编辑通讯录\',onAjaxed: function(data){}});\">编辑通讯录</a></span><span title=\"删除通讯录\" class=\"delnode\"><a style=\"cursor:hand\" onclick=\"$.msgbox({height:220,width:500,content:{type:\'ajax\',content:\'../AddressServlet?method=deleteDir&dirLevel=-1&dirId=0\'},title:\'删除通讯\',onAjaxed: function(data){}});\">删除通讯录</a></span> <ul>"); if(topDirectoryList!=null&&topDirectoryList.size()>0){ for(int i = 0;i<topDirectoryList.size();i++){ DirectoryBean directoryBean =(DirectoryBean)topDirectoryList.get(i); sb.append(" <li class=\""+directoryBean.getDirId()+"\"><a onclick=\"$mb=$.msgbox({height:400,width:800,content:{type:'iframe',content:'./AddressServlet?method=getLinkMan&Page=1&dirId="+directoryBean.getDirId()+"'},title: '联系人'});\">"+directoryBean.getDirName()+"</a><span title=\"添加通讯录\" class=\"addnode\"><a style=\"cursor:hand\" onclick=\"$mb=$.msgbox({height:220,width:500,content:{type:\'ajax\',content:\'./AddressServlet?method=addDir&dirLevel="+directoryBean.getDirLevel()+"&dirId="+directoryBean.getDirId()+"\'},title:\'新增通讯录\',onAjaxed: function(data){}});\">添加通讯录</a></span><span title=\"编辑通讯录\" class=\"editnode\"><a style=\"cursor:hand\" onclick=\"$mb=$.msgbox({height:220,width:500,content:{type:\'ajax\',content:\'./AddressServlet?method=modifyDir&dirLevel="+directoryBean.getDirLevel()+"&dirId="+directoryBean.getDirId()+"\'},title:\'编辑通讯录\',onAjaxed: function(data){}});\">编辑通讯录</a></span><span title=\"删除通讯录\" class=\"delnode\"><a style=\"cursor:hand\" onclick=\"$.msgbox({height:220,width:500,content:{type:\'ajax\',content:\'./AddressServlet?method=deleteDir&dirLevel="+directoryBean.getDirLevel()+"&dirId="+directoryBean.getDirId()+"\'},title:\'删除通讯\',onAjaxed: function(data){}});\">删除通讯录</a></span><span title=\"新增联系人\" class=\"addLinkMan\"><a style=\"cursor:hand\" onclick=\"$mb=$.msgbox({height:400,width:500,content:{type:\'ajax\',content:\'./AddressServlet?method=addLinkMan&dirLevel="+directoryBean.getDirLevel()+"&dirId="+directoryBean.getDirId()+"\'},title:\'新增联系人\',onAjaxed: function(data){}});\">新增联系人</a></span><span title=\"导入联系人\" class=\"importLinkMan\"><a style=\"cursor:hand\" onclick=\"$mb=$.msgbox({height:220,width:500,content:{type:\'ajax\',content:\'./AddressServlet?method=importLinkMan&dirLevel="+directoryBean.getDirLevel()+"&dirId="+directoryBean.getDirId()+"\'},title:\'导入联系人\',onAjaxed: function(data){}});\">导入联系人</a></span>"); String chilDirectory = this.getDirStringShow(null,directoryBean.getDirId()); sb.append(chilDirectory); sb.append("</li>"); } //sb.append("</li>"); } sb.append("</ul></li>"); request.getSession().setAttribute("sb", sb); response.sendRedirect("AddressListModule/showDirectry.jsp?dingwei="+dirId); }else if(method.equals("deleteDir")){//delete a directory String dirLevel = request.getParameter("dirLevel"); String dirId = request.getParameter("dirId"); int num = new Random().nextInt(10000); DirectoryBean directoryBean = new AddressModuleDao().getDirectory("tb_directory", "dirId", Integer.parseInt(dirId)); request.getSession().setAttribute("directoryBean", directoryBean); response.sendRedirect("AddressListModule/deleteDirectory.jsp?dirLevel="+dirLevel+"&num="+num); }else if(method.equals("deleteDirSubmit")){//the submit of delete a directory StringBuffer sb = new StringBuffer(); String dirId = request.getParameter("dirId"); String fatherId = request.getParameter("fatherId"); boolean fatherBo = UtilDAO.del("tb_directory", "dirId", dirId); if(fatherBo){ String conditionChil = " parentDirId="+dirId; String chilDirId = new AddressModuleDao().getChilDirId("tb_directory", "", conditionChil); if(!chilDirId.equals("")){ chilDirId=chilDirId+dirId; }else{ chilDirId=dirId; } String condition=" tb_directory where parentDirId="+dirId; boolean chilBo = UtilDAO.delAll(condition); String conditionTT=" tb_customer where dirId in("+chilDirId+")"; boolean contentBo = UtilDAO.delAll(conditionTT); } List<DirectoryBean> topDirectoryList = this.getTopDirectryList("", "", "");//get the first level directory sb.append(" <li class=\"0\"><a>通讯录</a><span title=\"添加通讯录\" class=\"addnode\"><a style=\"cursor:hand\" onclick=\"$mb=$.msgbox({height:220,width:500,content:{type:\'ajax\',content:\'./AddressServlet?method=addDir&dirLevel=-1&dirId=0\'},title:\'新增通讯录\',onAjaxed: function(data){}});\">添加通讯录</a></span><ul>"); if(topDirectoryList!=null&&topDirectoryList.size()>0){ for(int i = 0;i<topDirectoryList.size();i++){ DirectoryBean directoryBean =(DirectoryBean)topDirectoryList.get(i); sb.append(" <li class=\""+directoryBean.getDirId()+"\"><a onclick=\"$mb=$.msgbox({height:400,width:800,content:{type:'iframe',content:'./AddressServlet?method=getLinkMan&Page=1&dirId="+directoryBean.getDirId()+"'},title: '联系人'});\">"+directoryBean.getDirName()+"</a><span title=\"添加通讯录\" class=\"addnode\"><a style=\"cursor:hand\" onclick=\"$mb=$.msgbox({height:220,width:500,content:{type:\'ajax\',content:\'./AddressServlet?method=addDir&dirLevel="+directoryBean.getDirLevel()+"&dirId="+directoryBean.getDirId()+"\'},title:\'新增通讯录\',onAjaxed: function(data){}});\">添加通讯录</a></span><span title=\"编辑通讯录\" class=\"editnode\"><a style=\"cursor:hand\" onclick=\"$mb=$.msgbox({height:220,width:500,content:{type:\'ajax\',content:\'./AddressServlet?method=modifyDir&dirLevel="+directoryBean.getDirLevel()+"&dirId="+directoryBean.getDirId()+"\'},title:\'编辑通讯录\',onAjaxed: function(data){}});\">编辑通讯录</a></span><span title=\"删除通讯录\" class=\"delnode\"><a style=\"cursor:hand\" onclick=\"$mb=$.msgbox({height:220,width:500,content:{type:\'ajax\',content:\'./AddressServlet?method=deleteDir&dirLevel="+directoryBean.getDirLevel()+"&dirId="+directoryBean.getDirId()+"\'},title:\'删除通讯\',onAjaxed: function(data){}});\">删除通讯录</a></span><span title=\"新增联系人\" class=\"addLinkMan\"><a style=\"cursor:hand\" onclick=\"$mb=$.msgbox({height:400,width:500,content:{type:\'ajax\',content:\'./AddressServlet?method=addLinkMan&dirLevel="+directoryBean.getDirLevel()+"&dirId="+directoryBean.getDirId()+"\'},title:\'新增联系人\',onAjaxed: function(data){}});\">新增联系人</a></span><span title=\"导入联系人\" class=\"importLinkMan\"><a style=\"cursor:hand\" onclick=\"$mb=$.msgbox({height:220,width:500,content:{type:\'ajax\',content:\'./AddressServlet?method=importLinkMan&dirLevel="+directoryBean.getDirLevel()+"&dirId="+directoryBean.getDirId()+"\'},title:\'导入联系人\',onAjaxed: function(data){}});\">导入联系人</a></span>"); String chilDirectory = this.getDirStringShow(null,directoryBean.getDirId()); sb.append(chilDirectory); sb.append("</li>"); } //sb.append("</li>"); } sb.append("</ul></li>"); request.getSession().setAttribute("sb", sb); response.sendRedirect("AddressListModule/showDirectry.jsp?dingwei="+fatherId); }else if(method.equals("selectDir")){//select the Directory when send mms or sms List<DirectoryBean> lastDirList = new ArrayList<DirectoryBean>(); String formName = request.getParameter("formName"); String selectPhone = request.getParameter("selectPhone"); TbUserBean tbUser =(TbUserBean)request.getSession().getAttribute("User");//get the loginUser int userState = tbUser.getUserState();//the state of loginUser 0:超级管理员1:管理员2:普通用户3:审核人员 StringBuffer sb = new StringBuffer(); List<DirectoryBean> topDirectoryList =new ArrayList<DirectoryBean>(); if(userState==0){ topDirectoryList =this.getTopDirectryList("", "", "");//get the first level directory }else if(userState>0){ String tiaojian=""; String tiaojianRole=""; tiaojian="userId="+tbUser.getUserId(); List<DirectoryBean> dirList = this.getDirectryList(tiaojian); if(dirList!=null&&dirList.size()>0){ for(DirectoryBean db:dirList){ tiaojianRole+=db.getDirId()+","; } tiaojianRole=tiaojianRole.substring(0,tiaojianRole.length()-1); } List<TbUserDirectory> userDirList = this.getDirectryListByRole(tiaojianRole);//get the object from tb_userDirectory table if(dirList!=null&&dirList.size()>0){ topDirectoryList = dirList; } if(userDirList!=null&&userDirList.size()>0){ for(TbUserDirectory tbUserDir:userDirList){ DirectoryBean dirB = this.getDirectory("tb_directory", "dirId", tbUserDir.getDirectoryId()); if(!topDirectoryList.contains(dirB)){ topDirectoryList.add(dirB); } } } } sb.append(" <li class=\"0\"><a>通讯录</a><ul>"); if(topDirectoryList!=null&&topDirectoryList.size()>0){ List<String> dirLst = this.dirLst(topDirectoryList); if(dirLst!=null&&dirLst.size()>0){ for(String vv:dirLst){ DirectoryBean d = this.getDirectory("tb_directory", "dirId", Integer.parseInt(vv)); lastDirList.add(d); } } } if(lastDirList!=null&&lastDirList.size()>0){ for(int i = 0;i<lastDirList.size();i++){ DirectoryBean directoryBean =(DirectoryBean)lastDirList.get(i); sb.append(" <li><input type=\"checkbox\" name=\"select_Dir\" id=\""+directoryBean.getDirId()+"\" onclick=\"ts(this);\" /><a>"+directoryBean.getDirName()+"</a>"); String chilDirectory = this.getDirStringByRole(null,directoryBean.getDirId(),request); sb.append(chilDirectory); sb.append("</li>"); } //sb.append("</li>"); } sb.append("</ul></li>"); request.getSession().setAttribute("sb", sb); int num = new Random().nextInt(10000); response.sendRedirect("SmsModule/selectDirectory.jsp?num="+num+"&formName="+formName+"&selectPhone="+selectPhone); }else if(method.equals("getLinkMan")){//get the linkMan by directoryId String dirId = request.getParameter("dirId"); int num = new Random().nextInt(10000); String Page = request.getParameter("Page"); List<ContactBean> contactList = this.getLinkMan(Integer.parseInt(dirId)); request.getSession().setAttribute("contactList", contactList); response.sendRedirect("AddressListModule/ShowContact.jsp?dirId="+dirId+"&num="+num+"&Page="+Page); }else if(method.equals("addLinkMan")){//add a linkMan String dirId = request.getParameter("dirId"); String createTime = Constant.decodeDateT(); response.sendRedirect("AddressListModule/addContact.jsp?dirId="+dirId+"&createTime="+createTime); }else if(method.equals("addContactSubmit")){//the submit add a linkMan StringBuffer sb = new StringBuffer(); String linkName = Constant.decodeString(request.getParameter("linkName")); String linkPhone = request.getParameter("linkPhone"); String dirId = request.getParameter("dirId"); String jifen = request.getParameter("jifen"); //Date birthday = Timestamp.valueOf(linkBirth); ContactBean contactBean = new ContactBean(); contactBean.setCustomerIntegral("0"); contactBean.setCustomerName(linkName); contactBean.setCustomerPhone(linkPhone); contactBean.setLastTime(Constant.decodeDate()); contactBean.setDirId(Integer.parseInt(dirId)); contactBean.setCustomerIntegral(jifen); boolean bo = new AddressModuleDao().addContact(contactBean); List<DirectoryBean> topDirectoryList = this.getTopDirectryList("", "", "");//get the first level directory sb.append(" <li class=\"0\"><a>通讯录</a> <span title=\"添加通讯录\" class=\"addnode\"><a style=\"cursor:hand\" onclick=\"$mb=$.msgbox({height:220,width:500,content:{type:\'ajax\',content:\'./AddressServlet?method=addDir&dirLevel=-1&dirId=0\'},title:\'新增通讯录\',onAjaxed: function(data){}});\">添加通讯录</a></span><ul>"); if(topDirectoryList!=null&&topDirectoryList.size()>0){ for(int i = 0;i<topDirectoryList.size();i++){ DirectoryBean directoryBean =(DirectoryBean)topDirectoryList.get(i); sb.append(" <li class=\""+directoryBean.getDirId()+"\"><a onclick=\"$mb=$.msgbox({height:400,width:800,content:{type:'iframe',content:'./AddressServlet?method=getLinkMan&Page=1&dirId="+directoryBean.getDirId()+"'},title: '联系人'});\">"+directoryBean.getDirName()+"</a><span title=\"添加通讯录\" class=\"addnode\"><a style=\"cursor:hand\" onclick=\"$mb=$.msgbox({height:220,width:500,content:{type:\'ajax\',content:\'./AddressServlet?method=addDir&dirLevel="+directoryBean.getDirLevel()+"&dirId="+directoryBean.getDirId()+"\'},title:\'新增通讯录\',onAjaxed: function(data){}});\">添加通讯录</a></span><span title=\"编辑通讯录\" class=\"editnode\"><a style=\"cursor:hand\" onclick=\"$mb=$.msgbox({height:220,width:500,content:{type:\'ajax\',content:\'./AddressServlet?method=modifyDir&dirLevel="+directoryBean.getDirLevel()+"&dirId="+directoryBean.getDirId()+"\'},title:\'编辑通讯录\',onAjaxed: function(data){}});\">编辑通讯录</a></span><span title=\"删除通讯录\" class=\"delnode\"><a style=\"cursor:hand\" onclick=\"$mb=$.msgbox({height:220,width:500,content:{type:\'ajax\',content:\'./AddressServlet?method=deleteDir&dirLevel="+directoryBean.getDirLevel()+"&dirId="+directoryBean.getDirId()+"\'},title:\'删除通讯\',onAjaxed: function(data){}});\">删除通讯录</a></span><span title=\"新增联系人\" class=\"addLinkMan\"><a style=\"cursor:hand\" onclick=\"$mb=$.msgbox({height:400,width:500,content:{type:\'ajax\',content:\'./AddressServlet?method=addLinkMan&dirLevel="+directoryBean.getDirLevel()+"&dirId="+directoryBean.getDirId()+"\'},title:\'新增联系人\',onAjaxed: function(data){}});\">新增联系人</a></span><span title=\"导入联系人\" class=\"importLinkMan\"><a style=\"cursor:hand\" onclick=\"$mb=$.msgbox({height:220,width:500,content:{type:\'ajax\',content:\'./AddressServlet?method=importLinkMan&dirLevel="+directoryBean.getDirLevel()+"&dirId="+directoryBean.getDirId()+"\'},title:\'导入联系人\',onAjaxed: function(data){}});\">导入联系人</a></span>"); String chilDirectory = this.getDirStringShow(null,directoryBean.getDirId()); sb.append(chilDirectory); sb.append("</li>"); } //sb.append("</li>"); } sb.append("</ul></li>"); request.getSession().setAttribute("sb", sb); response.sendRedirect("AddressListModule/showDirectry.jsp?dingwei="+dirId); }else if(method.equals("modifyContact")){//modify a linkMan System.out.println("come here !!!!!!"); String contactId = request.getParameter("mmsId"); System.out.println("come here !!!!!!"+contactId); int num = new Random().nextInt(10000); System.out.println("come here !!!!!!"); ContactBean contactBean = new AddressModuleDao().getContact(contactId); System.out.println("come here !!!!!!"); List<ContactBean> contactList=new ArrayList<ContactBean>(); System.out.println("aaa"); contactList.add(contactBean); System.out.println("bbbb"); request.getSession().setAttribute("contact_Bean", contactBean); System.out.println("cccc"); response.sendRedirect("AddressListModule/modifyContact.jsp?num="+num); System.out.println("ddddd"); }else if(method.equals("modifyContactSubmit")){//modify a linkMan submit int num = new Random().nextInt(10000); String linkMan = Constant.decodeString(request.getParameter("linkName")); String linkPhone = Constant.decodeString(request.getParameter("linkPhone")); String contactId = request.getParameter("mmsId"); String customerIntegral=request.getParameter("customerIntegral");//积分 ContactBean contactBean = new ContactBean(); contactBean.setCustomerId(Integer.parseInt(contactId)); contactBean.setCustomerIntegral(customerIntegral); contactBean.setCustomerName(linkMan); contactBean.setCustomerPhone(linkPhone); contactBean.setLastTime(Constant.decodeDate()); String condition = "1=1"; if(!linkPhone.equals("")){ condition+=" and customerPhone='"+linkPhone+"'"; } if(!linkMan.equals("")){ condition+=" and customerName like '%"+linkMan+"%'"; } boolean bo = new AddressModuleDao().modifyContact(contactBean); List<ContactBean> contactList = new AddressModuleDao().getContactList("tb_customer", "lastTime", condition); request.getSession().setAttribute("phone", linkPhone); request.getSession().setAttribute("linkName", linkMan); request.getSession().setAttribute("contactList", contactList); response.sendRedirect("AddressListModule/contactList.jsp?num="+num); }else if(method.equals("lookContact")){//show the contact String linkName = Constant.decodeString(request.getParameter("linkName")); String page = request.getParameter("Page"); String phone = request.getParameter("phone"); String condition = "1=1"; if(!phone.equals("")){ condition+=" and customerPhone='"+phone+"'"; } if(!linkName.equals("")){ condition+=" and customerName like '%"+linkName+"%'"; } List<ContactBean> contactList = new AddressModuleDao().getContactList("tb_customer", "lastTime", condition); request.getSession().setAttribute("phone", phone); request.getSession().setAttribute("linkName", linkName); request.getSession().setAttribute("contactList", contactList); request.getSession().setAttribute("resultAdd", ""); response.sendRedirect("AddressListModule/contactList.jsp?Page="+page); }else if(method.equals("searchContact")){//search the contact String linkName = Constant.decodeString(request.getParameter("linkName")); String phone = request.getParameter("phone"); String condition = "1=1"; if(!phone.equals("")){ condition+=" and customerPhone='"+phone+"'"; } if(!linkName.equals("")){ condition+=" and customerName like '%"+linkName+"%'"; } List<ContactBean> contactList = new AddressModuleDao().getContactList("tb_customer", "lastTime", condition); request.getSession().setAttribute("linkName", linkName); request.getSession().setAttribute("phone", phone); request.getSession().setAttribute("contactList", contactList); response.sendRedirect("AddressListModule/contactList.jsp"); }else if(method.equals("deleteAllContact")){ String mmsId = request.getParameter("idList"); mmsId = mmsId.substring(0, mmsId.length()-1); String linkName = Constant.decodeString(request.getParameter("linkName")); String phone = request.getParameter("phone"); String condition = " tb_customer where customerId in("+mmsId+")"; boolean bo = UtilDAO.delAll(condition); String conditionT = "1=1"; if(!phone.equals("")){ conditionT+=" and customerPhone='"+phone+"'"; } if(!linkName.equals("")){ conditionT+=" and customerName like '%"+linkName+"%'"; } List<ContactBean> contactList = new AddressModuleDao().getContactList("tb_customer", "lastTime", conditionT); request.getSession().setAttribute("linkName", linkName); request.getSession().setAttribute("phone", phone); request.getSession().setAttribute("contactList", contactList); request.getSession().setAttribute("resultAdd", "删除成功"); response.sendRedirect("AddressListModule/contactList.jsp"); }else if(method.equals("deleteContact")){//delete a contact String mmsId = request.getParameter("mmsId"); String linkName = Constant.decodeString(request.getParameter("linkName")); String phone = request.getParameter("phone"); boolean bo = UtilDAO.del("tb_customer", "customerId", Integer.parseInt(mmsId)); String conditionT = "1=1"; if(!phone.equals("")){ conditionT+=" and customerPhone='"+phone+"'"; } if(!linkName.equals("")){ conditionT+=" and customerName like '%"+linkName+"%'"; } List<ContactBean> contactList = new AddressModuleDao().getContactList("tb_customer", "lastTime", conditionT); request.getSession().setAttribute("linkName", linkName); request.getSession().setAttribute("phone", phone); request.getSession().setAttribute("contactList", contactList); request.getSession().setAttribute("resultAdd", "删除成功"); response.sendRedirect("AddressListModule/contactList.jsp"); }else if(method.equals("getLinkMans")){//get the linkMans when you send a sms or an mms System.out.println("进入!"); String formName=request.getParameter("formName"); String selectPhone = request.getParameter("selectPhone"); String dirId = request.getParameter("dirId"); dirId = dirId.substring(0, dirId.length()-1); String condition="dirId in("+dirId+")"; List<ContactBean> linkMans = this.getLinkMans(condition); StringBuffer sb = new StringBuffer(); sb.append(formName+","); sb.append(selectPhone+","); if(linkMans!=null&&linkMans.size()>0){ for(ContactBean contact: linkMans){ sb.append("<option>"+contact.getCustomerPhone()+"</option>"); } }else{ //sb.append(""); } out.println(sb.toString()); }else if(method.equals("importLinkMan")){ String dirId = request.getParameter("dirId"); int num = new Random().nextInt(10000); response.sendRedirect("AddressListModule/importContact.jsp?dirId="+dirId+"&num="+num); }else if(method.equals("importContactSubmit")){ String dirId = request.getParameter("dirId"); String realImagePath = Constant.decodeString(request .getParameter("realImagePath")); String tempPath = request.getRealPath("/") + "upload".replace("\\", "/"); String result = ""; File file = new File(tempPath); if(!file.isFile()){ file.mkdirs(); } // new a SmartUpload object SmartUpload su = new SmartUpload(); System.out.println("aaaa"); su.setCharset("UTF-8");// 使用时候最关键的一步 // 上传初始化 System.out.println("bbbbbbb"); su.initialize(this.getServletConfig(),request,response); System.out.println("ccccccc"); // 设定上传限制 // 1.限制每个上传文件的最大长度。 su.setMaxFileSize(10000000); System.out.println("dddddd"); // 2.限制总上传数据的长度。 su.setTotalMaxFileSize(20000000); System.out.println("fffffffff"); // 3.设定允许上传的文件(通过扩展名限制),仅允许doc,txt文件。 su.setAllowedFilesList("xls,XLS"); System.out.println("eeeeeeee"); boolean sign = true; System.out.println("gggggggg"); // 4.设定禁止上传的文件(通过扩展名限制),禁止上传带有exe,bat,jsp,htm,html扩展名的文件和没有扩展名的文件。 try { su.setDeniedFilesList("exe,bat,jsp,htm,html"); System.out.println("hhhhhhhh"); // 上传文件 su.upload(); System.out.println("iiiiiiii"); // 将上传文件保存到指定目录 tempPath = tempPath.replace("\\", "/"); System.out.println("jjjjjjjjjj"); tempPath = tempPath + "/"; System.out.println("kkkkkkkkkk"); su.save(tempPath); System.out.println("文件名称"+su.getFiles().getFile(0).getFileName()); tempPath += "\\" + su.getFiles().getFile(0).getFileName(); tempPath = tempPath.replace("\\", "/"); tempPath = tempPath.replace("//", "/"); System.out.println("tempsssssssssssssPath==="+tempPath); Workbook wb; InputStream is2 = new FileInputStream(tempPath); wb = Workbook.getWorkbook(is2); Sheet sheet = wb.getSheet(0); int row = sheet.getRows(); List<ContactBean> contactList = new ArrayList<ContactBean>(); int maxId = new AddressModuleDao().getMaxContantId();//在导入时把联系人表中取得ID最大值 //// 表结构是:姓名:手机号码:积分 for(int i = 1;i<row;i++){ Cell firstCell = sheet.getCell(0, i); String firstContent = firstCell.getContents(); Cell secondCell = sheet.getCell(1,i); String secondContent = secondCell.getContents(); ContactBean contactBean = new ContactBean(); contactBean.setCustomerIntegral("0"); contactBean.setCustomerName(firstContent); contactBean.setCustomerPhone(secondContent); contactBean.setDirId(Integer.parseInt(dirId)); contactBean.setLastTime(Constant.decodeDate()); contactList.add(contactBean); } if(contactList!=null&&contactList.size()>0){ boolean bo = new AddressModuleDao().saveContactList(contactList); if(bo){ result="导入成功"; }else{ result="导入失败"; } } } catch (Exception e) { e.printStackTrace(); } StringBuffer sb = new StringBuffer(); List<DirectoryBean> topDirectoryList = this.getTopDirectryList("", "", "");//get the first level directory sb.append(" <li class=\"0\"><a>通讯录</a><span title=\"添加通讯录\" class=\"addnode\"><a style=\"cursor:hand\" onclick=\"$mb=$.msgbox({height:220,width:500,content:{type:\'ajax\',content:\'./AddressServlet?method=addDir&dirLevel=-1&dirId=0\'},title:\'新增通讯录\',onAjaxed: function(data){}});\">添加通讯录</a></span><ul>"); if(topDirectoryList!=null&&topDirectoryList.size()>0){ for(int i = 0;i<topDirectoryList.size();i++){ DirectoryBean directoryBean =(DirectoryBean)topDirectoryList.get(i); sb.append(" <li class=\""+directoryBean.getDirId()+"\"><a onClick=\"$.msgbox({height:510,width:800,content:{type:'iframe',content:'./AddressServlet?method=getLinkMan&Page=1&dirId="+directoryBean.getDirId()+"'},title: '联系人列表'})\" value=\""+directoryBean.getDirName()+"\" >"+directoryBean.getDirName()+"</a><span title=\"添加通讯录\" class=\"addnode\"><a style=\"cursor:hand\" onclick=\"$mb=$.msgbox({height:220,width:500,content:{type:\'ajax\',content:\'./AddressServlet?method=addDir&dirLevel="+directoryBean.getDirLevel()+"&dirId="+directoryBean.getDirId()+"\'},title:\'新增通讯录\',onAjaxed: function(data){}});\">添加通讯录</a></span><span title=\"编辑通讯录\" class=\"editnode\"><a style=\"cursor:hand\" onclick=\"$mb=$.msgbox({height:220,width:500,content:{type:\'ajax\',content:\'./AddressServlet?method=modifyDir&dirLevel="+directoryBean.getDirLevel()+"&dirId="+directoryBean.getDirId()+"\'},title:\'编辑通讯录\',onAjaxed: function(data){}});\">编辑通讯录</a></span><span title=\"删除通讯录\" class=\"delnode\"><a style=\"cursor:hand\" onclick=\"$mb=$.msgbox({height:220,width:500,content:{type:\'ajax\',content:\'./AddressServlet?method=deleteDir&dirLevel="+directoryBean.getDirLevel()+"&dirId="+directoryBean.getDirId()+"\'},title:\'删除通讯\',onAjaxed: function(data){}});\">删除通讯录</a></span><span title=\"新增联系人\" class=\"addLinkMan\"><a style=\"cursor:hand\" onclick=\"$mb=$.msgbox({height:400,width:500,content:{type:\'ajax\',content:\'./AddressServlet?method=addLinkMan&dirLevel="+directoryBean.getDirLevel()+"&dirId="+directoryBean.getDirId()+"\'},title:\'新增联系人\',onAjaxed: function(data){}});\">新增联系人</a></span><span title=\"导入联系人\" class=\"importLinkMan\"><a style=\"cursor:hand\" onclick=\"$mb=$.msgbox({height:220,width:500,content:{type:\'ajax\',content:\'./AddressServlet?method=importLinkMan&dirLevel="+directoryBean.getDirLevel()+"&dirId="+directoryBean.getDirId()+"\'},title:\'导入联系人\',onAjaxed: function(data){}});\">导入联系人</a></span>"); String chilDirectory = this.getDirStringShow(null,directoryBean.getDirId()); sb.append(chilDirectory); sb.append("</li>"); } //sb.append("</li>"); } sb.append("</ul></li>"); request.getSession().setAttribute("sb", sb); response.sendRedirect("AddressListModule/showDirectry.jsp?dingwei="+dirId); }else if(method.equals("givesDir")){//在新建用户时对其进行通讯录赋予 List<DirectoryBean> lastDirList = new ArrayList<DirectoryBean>(); String formName = request.getParameter("formName"); String selectPhone = request.getParameter("selectPhone"); String user_Id = request.getParameter("userId"); TbUserBean tbUser =new TbUserDAO().getTbUsersByUserId(Integer.parseInt(user_Id));//get the loginUser System.out.println("user_Id=="+user_Id); int userState = tbUser.getUserState();//the state of loginUser 0:超级管理员1:管理员2:普通用户3:审核人员 StringBuffer sb = new StringBuffer(); List<DirectoryBean> topDirectoryList =new ArrayList<DirectoryBean>(); List<DirectoryBean> directoryList =new ArrayList<DirectoryBean>(); String tiaojian="userId="+user_Id; List<DirectoryBean> dirList = this.getDirectryList(tiaojian); List<TbUserDirectory> userDirList = this.getDirectryListByRole(tiaojian);//get the object from tb_userDirectory table if(dirList!=null&&dirList.size()>0){ directoryList = dirList; } System.out.println("to heree!!!!!!!!!"); if(userDirList!=null&&userDirList.size()>0){ for(TbUserDirectory tbUserDir:userDirList){ DirectoryBean dirB = this.getDirectory("tb_directory", "dirId", tbUserDir.getDirectoryId()); if(!directoryList.contains(dirB)){ directoryList.add(dirB); } } } System.out.println("aaaaaaaabbbbbbb"+directoryList.size()); if(userState==0||userState==1){ System.out.println("superadmin!!!"); topDirectoryList =this.getTopDirectryListUser("", "", "");//get the first level directory }else if(userState>1){ System.out.println("user come in!!!!!"); //topDirectoryList = directoryList; String tiaojianT="userId="+tbUser.getCreateUserId(); List<DirectoryBean> dirListT = this.getDirectryList(tiaojianT); List<TbUserDirectory> userDirListT = this.getDirectryListByRole(tiaojianT);//get the object from tb_userDirectory table if(dirListT!=null&&dirListT.size()>0){ for(int x = 0;x<dirListT.size();x++){ if(!topDirectoryList.contains(dirListT.get(x))){ topDirectoryList.add(dirListT.get(x)); } } } System.out.println("aaaaaaaabbbbbbbTTT"+directoryList.size()); if(userDirListT!=null&&userDirListT.size()>0){ System.out.println("1111111==="+directoryList.size()); for(TbUserDirectory tbUserDir:userDirListT){ System.out.println("112222222=="+directoryList.size()); DirectoryBean dirBT = this.getDirectory("tb_directory", "dirId", tbUserDir.getDirectoryId()); System.out.println("33333333=="+directoryList.size()); if(!topDirectoryList.contains(dirBT)){ System.out.println("4444444=="+directoryList.size()); topDirectoryList.add(dirBT); } } } System.out.println("aaaaaaaabbbbTTTTTTTTRRRRRRRRRbbb"+directoryList.size()); System.out.println("to heree!!!!!!!!!"); System.out.println("sizdddddde==="+topDirectoryList.size()); } List<String> DirIdList = new ArrayList<String>(); if(directoryList!=null&&directoryList.size()>0){ System.out.println("commmmmmmmmmmmmmmmmmmmmmmmm"+directoryList.get(0).getDirName()); for(int y=0;y<directoryList.size();y++){ System.out.println("ID号"+directoryList.get(y).getDirId()); DirIdList.add(String.valueOf(directoryList.get(y).getDirId())); } } for(String str:DirIdList){ System.out.println("strIDDDDDDDDD==="+str); } System.out.println("size========="+topDirectoryList.size()); sb.append(" <li class=\"0\"><a>通讯录</a> <span title=\"添加通讯录\" class=\"addnode\"><a style=\"cursor:hand\" onclick=\"$mb=$.msgbox({height:220,width:500,content:{type:\'ajax\',content:\'./AddressServlet?method=addDir&dirLevel=-1&dirId=0\'},title:\'新增通讯录\',onAjaxed: function(data){}});\">添加通讯录</a></span><ul>"); List<String> dirLst = this.dirLst(topDirectoryList); if(dirLst!=null&&dirLst.size()>0){ for(String vv:dirLst){ DirectoryBean d = this.getDirectory("tb_directory", "dirId", Integer.parseInt(vv)); lastDirList.add(d); } } if(lastDirList!=null&&lastDirList.size()>0){ for(int i = 0;i<lastDirList.size();i++){ DirectoryBean directoryBean =(DirectoryBean)lastDirList.get(i); String checkStr=""; if(DirIdList.contains(String.valueOf(directoryBean.getDirId()))){ checkStr="checked"; } sb.append(" <li><input type=\"checkbox\" "+checkStr+" name=\"select_Dir\" id=\""+directoryBean.getDirId()+"\" onclick=\"ts(this);\" /><a>"+directoryBean.getDirName()+"</a>"); String chilDirectory = this.getDirStringByRoleUser(null,directoryBean.getDirId(),request,DirIdList); sb.append(chilDirectory); sb.append("</li>"); } //sb.append("</li>"); } sb.append("</ul></li>"); request.getSession().setAttribute("sb", sb); int num = new Random().nextInt(10000); System.out.println("====givesDir====formName==="+formName+"======"+selectPhone); response.sendRedirect("UserModule/selectDirectory.jsp?num="+num+"&formName="+formName+"&selectPhone="+selectPhone+"&userId="+user_Id); }else if(method.equals("givesDirSubmit")){//新建用户时对其进行通讯录赋值的提交操作 System.out.println("提交"); String dirId = request.getParameter("dirId"); String userId = request.getParameter("userId"); System.out.println(userId+"===="+dirId); List<TbUserDirectory> userDirList = new ArrayList<TbUserDirectory>(); if(!dirId.equals("")){ String dir_Id[] = dirId.split(","); for(int z=0;z<dir_Id.length;z++){ TbUserDirectory userDir = new TbUserDirectory(); userDir.setCreateDate(Constant.decodeDate()); userDir.setDirectoryId(Integer.parseInt(dir_Id[z])); userDir.setUserId(Integer.parseInt(userId)); userDirList.add(userDir); } boolean bbo = new TbUserDirectoryDAO().deleteUserDir(Integer.parseInt(userId)); boolean bo = new TbUserDirectoryDAO().saveUserDirList(userDirList); } }else if(method.equals("getDirByParId")){ //response.setCharacterEncoding("UTF-8"); StringBuffer sb = new StringBuffer(); String parDirId = request.getParameter("parDir"); String nextDir = request.getParameter("nextDir"); sb.append(nextDir+","); String condition="userId="+user.getUserId(); List<TbUserDirectory> userDirectoryList = new AddressModuleDao().getUserDirByRole("tb_userDirectory","createDate",condition); if(userDirectoryList!=null&&userDirectoryList.size()>0){ for(TbUserDirectory userDir:userDirectoryList){ parDirId+=","+userDir.getDirectoryId(); } } String conditionDir = "parentDirId in("+parDirId+")"; List<DirectoryBean> dirList = new AddressModuleDao().getAllTbDirectory("tb_directory", "createTime", conditionDir); if(dirList!=null&&dirList.size()>0){ for(DirectoryBean db:dirList){ sb.append("<option value=\""+db.getDirId()+"\">"+db.getDirName()+"</option>"); } } System.out.println("sb===="+sb.toString()); out.println(sb.toString()); } } /** * *@author qingyu zhang *@function:在新建用户时对其进行通讯录赋值时的操作 * @param dirName * @param startTime * @param endTime * @return *2011-3-4 *上午09:08:13 *UserModule *com.AddressListModule.servlet *List<DirectoryBean> */ public List<DirectoryBean> getTopDirectryListUser(String dirName,String startTime,String endTime ){ List<DirectoryBean> directoryList = new ArrayList(); String condition = ""; if(!dirName.equals("")){ condition+=" and dirName like'%"+dirName+"%'"; } directoryList = new AddressModuleDao().getAllTbDirectory("tb_directory","createTime",condition); return directoryList; } /** * *@author qingyu zhang *@function:在用户表中对一个用户的通讯录群组进行修改 * @param sb * @param parDirId * @param request * @return *2011-3-3 *下午04:18:12 *UserModule *com.AddressListModule.servlet *String */ public String getDirStringByRoleUser(StringBuffer sb,int parDirId,HttpServletRequest request,List<String> str){ System.out.println("come heree!!!!!!====!!!"+str.size()); StringBuffer sssb = null; if(sb==null){ sssb = new StringBuffer(); }else{ sssb = sb ; } String condition = "parentDirId="+parDirId; System.out.println("condition=-"+condition); List<DirectoryBean> dirList = new AddressModuleDao().getAllTbDirectory("tb_directory","createTime",condition); if(dirList!=null&&dirList.size()>0){ sssb.append(" <ul class=\"treeview\">"); for(DirectoryBean dir:dirList){ //sbALL.append(" <ul class=\"treeview\">"); String strcheck=""; if(str.contains(String.valueOf(dir.getDirId()))){ strcheck="checked"; } sssb.append("<li><input type=\"checkbox\""+strcheck+" name=\"select_Dir\" id=\""+dir.getDirId()+"\" onclick=\"ts(this);\" /><a>"+dir.getDirName()+"</a>"); /*if(tbUser.getUserState()==0){//superadmin sssb.append("<li><input type=\"checkbox\" name=\"select_Dir\" id=\""+dir.getDirId()+"\" onclick=\"ts(this);\" /><a>"+dir.getDirName()+"</a>"); }else{ if(commonDirList.contains(dir)){ sssb.append("<li><input type=\"checkbox\" name=\"select_Dir\" id=\""+dir.getDirId()+"\" onclick=\"ts(this);\" /><a>"+dir.getDirName()+"</a>"); } }*/ this.getDirStringByRoleUser(sssb,dir.getDirId(),request,str); sssb.append("</li>"); } sssb.append("</ul>"); }else{ //sbALL.append("</li>"); } //sbALL.append("</li>"); return sssb.toString(); } /** * *@author qingyu zhang *@function:get the records by conditions * @param dirName * @param tiaojian * @return *2011-2-17 *下午02:32:23 *AddressListModule *com.AddressListModule.servlet *List<DirectoryBean> */ public List<DirectoryBean> getDirectryList(String tiaojian ){ List<DirectoryBean> directoryList = new ArrayList(); String condition = ""; condition=tiaojian; directoryList = new AddressModuleDao().getAllTbDirectory("tb_directory","createTime",condition); return directoryList; } /** * *@author qingyu zhang *@function:get the first level Directory * @param dirName * @param startTime * @param endTime * @return *2011-2-17 *下午03:12:49 *AddressListModule *com.AddressListModule.servlet *List<DirectoryBean> */ public List<DirectoryBean> getTopDirectryList(String dirName,String startTime,String endTime ){ List<DirectoryBean> directoryList = new ArrayList(); String condition = ""; condition+="dirLevel=0 "; if(!startTime.equals("")){ condition+=" and userId="+startTime; } if(!dirName.equals("")){ condition+=" and dirName like'%"+dirName+"%'"; } directoryList = new AddressModuleDao().getAllTbDirectory("tb_directory","createTime",condition); return directoryList; } /** * *@author qingyu zhang *@function:have not the checkBox * @param parDirId * @return *2011-2-19 *上午11:09:38 *AddressListModule *com.AddressListModule.servlet *String */ public String getDirStringShow(StringBuffer sb,int parDirId){ StringBuffer ssb =null; if(sb==null){ ssb = new StringBuffer(); }else{ ssb = sb; } String condition = "parentDirId="+parDirId; List<DirectoryBean> dirList = new AddressModuleDao().getAllTbDirectory("tb_directory","createTime",condition); if(dirList!=null&&dirList.size()>0){ ssb.append(" <ul class=\"treeview\">"); for(DirectoryBean dir:dirList){ //sbALL.append(" <ul class=\"treeview\">"); ssb.append("<li class=\""+dir.getDirId()+"\"><a onClick=\"$.msgbox({height:510,width:800,content:{type:'iframe',content:'./AddressServlet?method=getLinkMan&Page=1&Page=1&dirId="+dir.getDirId()+"'},title: '联系人列表'})\" value=\""+dir.getDirName()+"\" >"+dir.getDirName()+"</a><span title=\"添加通讯录\" class=\"addnode\"><a style=\"cursor:hand\" onclick=\"$mb=$.msgbox({height:220,width:500,content:{type:\'ajax\',content:\'./AddressServlet?method=addDir&dirLevel="+dir.getDirLevel()+"&dirId="+dir.getDirId()+"\'},title:\'新增通讯录\',onAjaxed: function(data){}});\">添加通讯录</a></span><span title=\"编辑通讯录\" class=\"editnode\"><a style=\"cursor:hand\" onclick=\"$mb=$.msgbox({height:220,width:500,content:{type:\'ajax\',content:\'./AddressServlet?method=modifyDir&dirLevel="+dir.getDirLevel()+"&dirId="+dir.getDirId()+"\'},title:\'编辑通讯录\',onAjaxed: function(data){}});\">编辑通讯录</a></span><span title=\"删除通讯录\" class=\"delnode\"><a style=\"cursor:hand\" onclick=\"$mb=$.msgbox({height:220,width:500,content:{type:\'ajax\',content:\'./AddressServlet?method=deleteDir&dirLevel="+dir.getDirLevel()+"&dirId="+dir.getDirId()+"\'},title:\'删除通讯录\',onAjaxed: function(data){}});\">删除通讯录</a></span><span title=\"新增联系人\" class=\"addLinkMan\"><a style=\"cursor:hand\" onclick=\"$mb=$.msgbox({height:400,width:500,content:{type:\'ajax\',content:\'./AddressServlet?method=addLinkMan&dirLevel="+dir.getDirLevel()+"&dirId="+dir.getDirId()+"\'},title:\'新增联系人\',onAjaxed: function(data){}});\">新增联系人</a></span><span title=\"导入联系人\" class=\"importLinkMan\"><a style=\"cursor:hand\" onclick=\"$mb=$.msgbox({height:220,width:500,content:{type:\'ajax\',content:\'./AddressServlet?method=importLinkMan&dirLevel="+dir.getDirLevel()+"&dirId="+dir.getDirId()+"\'},title:\'导入联系人\',onAjaxed: function(data){}});\">导入联系人</a></span>"); this.getDirStringShow(ssb,dir.getDirId()); ssb.append("</li>"); } ssb.append("</ul>"); }else{ //sbALL.append("</li>"); } //sbALL.append("</li>"); return ssb.toString(); } /** * *@author qingyu zhang *@function:get the linkMan by directoryId * @param dirId * @return *2011-2-19 *下午02:46:09 *AddressListModule *com.AddressListModule.servlet *StringBuffer */ public List getLinkMan(int dirId){ String condition ="dirId="+dirId; List<ContactBean> contactList = new AddressModuleDao().getContactList("tb_customer", "lastTime", condition); if(contactList==null){ contactList = new ArrayList(); } return contactList; } /** * *@author qingyu zhang *@function:get linkMans by dirIds (1,2,3,4....) * @param dirIds * @return *2011-2-26 *下午03:15:42 *MmsModule *com.AddressListModule.servlet *List */ public List<ContactBean> getLinkMans(String tiaojian){ String condition =tiaojian; List<ContactBean> contactList = new AddressModuleDao().getContactList("tb_customer", "lastTime", condition); if(contactList==null){ contactList = new ArrayList(); } return contactList; } /** * *@author qingyu zhang *@function:get the directory by role * @param dirName * @param tiaojian * @return *2011-2-25 *上午10:18:31 *MmsModule *com.AddressListModule.servlet *List<DirectoryBean> */ public List<TbUserDirectory> getDirectryListByRole(String tiaojian ){ List<TbUserDirectory> directoryList = new ArrayList(); String condition = ""; condition=tiaojian; directoryList = new AddressModuleDao().getUserDirByRole("tb_userDirectory","createDate",condition); return directoryList; } /** * *@author qingyu zhang *@function:get a Directory * @param tableName * @param inKey * @param keyValue * @return *2011-2-25 *上午10:46:13 *MmsModule *com.AddressListModule.servlet *DirectoryBean */ public DirectoryBean getDirectory(String tableName,String inKey,int keyValue){ DirectoryBean dir = new AddressModuleDao().getDirectory(tableName, inKey,keyValue); return dir; } /** * *@author qingyu zhang *@function:get common direcotry from tb_userDirectory * @param sb * @param parDirId * @return *2011-2-25 *上午10:51:49 *MmsModule *com.AddressListModule.servlet *String */ public String getDirStringByRole(StringBuffer sb,int parDirId,HttpServletRequest request){ StringBuffer sssb = null; if(sb==null){ sssb = new StringBuffer(); }else{ sssb = sb ; } TbUserBean tbUser = (TbUserBean)request.getSession().getAttribute("User"); String condition = "parentDirId="+parDirId; List<DirectoryBean> dirList = new AddressModuleDao().getAllTbDirectory("tb_directory","createTime",condition); if(dirList!=null&&dirList.size()>0){ sssb.append(" <ul class=\"treeview\">"); for(DirectoryBean dir:dirList){ //sbALL.append(" <ul class=\"treeview\">"); sssb.append("<li><input type=\"checkbox\" name=\"select_Dir\" id=\""+dir.getDirId()+"\" onclick=\"ts(this);\" /><a>"+dir.getDirName()+"</a>"); /*if(tbUser.getUserState()==0){//superadmin sssb.append("<li><input type=\"checkbox\" name=\"select_Dir\" id=\""+dir.getDirId()+"\" onclick=\"ts(this);\" /><a>"+dir.getDirName()+"</a>"); }else{ if(commonDirList.contains(dir)){ sssb.append("<li><input type=\"checkbox\" name=\"select_Dir\" id=\""+dir.getDirId()+"\" onclick=\"ts(this);\" /><a>"+dir.getDirName()+"</a>"); } }*/ this.getDirStringByRole(sssb,dir.getDirId(),request); sssb.append("</li>"); } sssb.append("</ul>"); }else{ //sbALL.append("</li>"); } //sbALL.append("</li>"); return sssb.toString(); } /** * *@author qingyu zhang *@function:所赋予权限中通讯录只有大于一级目录的存在 * @param commonDirList * @param condition * @return *2011-3-1 *上午09:23:28 *MmsModule *com.AddressListModule.servlet *List<DirectoryBean> 7 5 */ public List<String> dirLst(List<DirectoryBean> commonDirList){ List<String> lastDirLst = new ArrayList<String>(); for(DirectoryBean db :commonDirList){ lastDirLst.add(String.valueOf(db.getDirId())); } for(DirectoryBean directory:commonDirList){ String condition ="parentDirId="+directory.getDirId(); List<DirectoryBean> chilDirectory= this.getDirectryList(condition); if(chilDirectory!=null&&chilDirectory.size()>0){ for(int v = 0;v<chilDirectory.size();v++){ DirectoryBean chilDir = chilDirectory.get(v); if(lastDirLst.contains(String.valueOf(chilDir.getDirId()))){ boolean bo = lastDirLst.remove(String.valueOf(chilDir.getDirId())); } } } } return lastDirLst; } @Override protected void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException { // TODO Auto-generated method stub this.doGet(req, resp); } /** *@author qingyu zhang *@function: *2011-2-17 *下午02:13:57 *AddressListModule *com.AddressListModule.servlet */ }
zzprojects
trunk/zzprojects/zzClub/src/com/AddressListModule/servlet/AddressModuleServlet.java
Java
asf20
59,068
package com.AddressListModule.dao; import java.sql.Connection; import java.sql.PreparedStatement; import java.sql.ResultSet; import java.sql.Statement; import java.util.ArrayList; import java.util.List; import util.ConnectDB; import util.UtilDAO; import com.AddressListModule.bean.TbUserDirectory; public class TbUserDirectoryDAO { private Connection conn = null; private PreparedStatement pt = null; private Statement st = null; private ResultSet rs = null; private boolean flag = false; private String sql = ""; private TbUserDirectory tbUserDirectory=null; private List<TbUserDirectory> tbUserDirectoryList=null; public boolean add(TbUserDirectory inTbUserDirectory){ if(isExistTbUserDirectory(inTbUserDirectory)) return true; try { conn = ConnectDB.getSqlServerConnection(); sql = "insert into tb_UserDirectory(userId,directoryId) values(?,?)"; pt = conn.prepareStatement(sql); pt.setInt(1, inTbUserDirectory.getUserId()); pt.setInt(2, inTbUserDirectory.getDirectoryId()); if (pt.executeUpdate() > 0) { flag = true; } }catch (Exception e) { e.printStackTrace(); } finally { ConnectDB.closeSqlConnection(); } return flag; } public boolean del(int inUserDirectoryId){ return UtilDAO.del("tb_UserDirectory", "user_directoryId", inUserDirectoryId); } public boolean delByUserId(int inUserId){ return UtilDAO.del("tb_UserDirectory", "userId", inUserId); } public boolean delByDirectoryId(int inDirectoryId){ return UtilDAO.del("tb_UserDirectory", "directoryId", inDirectoryId); } public boolean isExistTbUserDirectory(TbUserDirectory inTbUserDirectory){ try { conn = ConnectDB.getSqlServerConnection(); sql = "select * from tb_UserDirectory where userId=? And directoryId=?"; pt = conn.prepareStatement(sql); pt.setInt(1, inTbUserDirectory.getUserId()); pt.setInt(2, inTbUserDirectory.getDirectoryId()); rs = pt.executeQuery(); if(rs.next()) { flag=true; } } catch (Exception e) { e.printStackTrace(); } finally { ConnectDB.closeSqlConnection(); } return flag; } public TbUserDirectory getTbUserDirectoryByUserDirectoryId(int inUserDirectoryId){ try { conn = ConnectDB.getSqlServerConnection(); sql = "select * from tb_UserDirectory where user_directoryId=?"; pt = conn.prepareStatement(sql); pt.setInt(1, inUserDirectoryId); rs = pt.executeQuery(); if(rs.next()) { tbUserDirectory=getTbUserDirectoryInfo(rs); } } catch (Exception e) { e.printStackTrace(); } finally { ConnectDB.closeSqlConnection(); } return tbUserDirectory; } public List<TbUserDirectory> getTbUserDirectoryByUserId(int inUserId){ try { tbUserDirectoryList=null; conn = ConnectDB.getSqlServerConnection(); sql = "select * from tb_UserDirectory where userId=?"; pt = conn.prepareStatement(sql); pt.setInt(1, inUserId); rs = pt.executeQuery(); while(rs.next()) { if(tbUserDirectoryList==null){ tbUserDirectoryList=new ArrayList<TbUserDirectory>(); } tbUserDirectoryList.add(getTbUserDirectoryInfo(rs)); } } catch (Exception e) { e.printStackTrace(); } finally { ConnectDB.closeSqlConnection(); } return tbUserDirectoryList; } public List<TbUserDirectory> getTbUserDirectoryByDirectoryId(int inDirectoryId){ try { tbUserDirectoryList=null; conn = ConnectDB.getSqlServerConnection(); sql = "select * from tb_UserDirectory where directoryId=?"; pt = conn.prepareStatement(sql); pt.setInt(1, inDirectoryId); rs = pt.executeQuery(); while(rs.next()) { if(tbUserDirectoryList==null){ tbUserDirectoryList=new ArrayList<TbUserDirectory>(); } tbUserDirectoryList.add(getTbUserDirectoryInfo(rs)); } } catch (Exception e) { e.printStackTrace(); } finally { ConnectDB.closeSqlConnection(); } return tbUserDirectoryList; } public TbUserDirectory getTbUserDirectoryInfo(ResultSet rs) throws Exception{ TbUserDirectory tbUserDirectory=new TbUserDirectory(); tbUserDirectory.setUser_directoryId(rs.getInt("user_directoryId")); tbUserDirectory.setUserId(rs.getInt("userId")); tbUserDirectory.setDirectoryId(rs.getInt("directoryId")); tbUserDirectory.setCreateDate(rs.getString("createTime")); return tbUserDirectory; } /** * *@author qingyu zhang *@function:save list into the table of TbUserDirectory * @param userDirList * @return *2011-3-3 *下午02:47:48 *UserModule *com.AddressListModule.dao *boolean */ public boolean saveUserDirList(List<TbUserDirectory> userDirList){ boolean bo = false; try{ conn = ConnectDB.getSqlServerConnection(); st = conn.createStatement(); if(userDirList!=null&&userDirList.size()>0){ for(int v = 0;v<userDirList.size();v++){ String hql = "insert into tb_UserDirectory(userId,directoryId,createDate) " + "values("+userDirList.get(v).getUserId()+","+userDirList.get(v).getDirectoryId()+",'"+userDirList.get(v).getCreateDate()+"')"; st.addBatch(hql); } } st.executeBatch(); bo = true; }catch(Exception e){ e.printStackTrace(); }finally { ConnectDB.closeSqlConnection(); return bo; } } public boolean deleteUserDir(int userId){ boolean bo = false; try{ conn = ConnectDB.getSqlServerConnection(); sql = "delete from tb_userDirectory where userId="+userId; pt = conn.prepareStatement(sql); bo= pt.execute(); }catch(Exception e){ e.printStackTrace(); }finally { ConnectDB.closeSqlConnection(); return bo; } } }
zzprojects
trunk/zzprojects/zzClub/src/com/AddressListModule/dao/TbUserDirectoryDAO.java
Java
asf20
6,393
package com.AddressListModule.dao; import java.sql.Connection; import java.sql.PreparedStatement; import java.sql.ResultSet; import java.sql.Statement; import java.util.ArrayList; import java.util.List; import util.ConnectDB; import util.UtilDAO; import com.AddressListModule.bean.ContactBean; import com.AddressListModule.bean.DirectoryBean; import com.AddressListModule.bean.TbUserDirectory; public class AddressModuleDao { /** *@author qingyu zhang *@function: *2011-2-17 *下午02:13:22 *AddressListModule *com.AddressListModule.dao */ // 数据库连接 private Connection conn = null; // st对象 private PreparedStatement pt = null; private Statement st = null; // 结果集 private ResultSet rs = null; // 成功失败标志 private boolean flag = false; // 要执行的语句 private String sql = ""; private DirectoryBean directoryBean = null; private ContactBean contactBean = null; private List<DirectoryBean> directoryList = null; private List<ContactBean> contactList = null; private List<TbUserDirectory> userDirectoryList = null; /** * *@author qingyu zhang *@function:add a record of directory * @param direct * @return *2011-2-17 *下午02:17:47 *AddressListModule *com.AddressListModule.dao *boolean */ public boolean add(DirectoryBean direct){ boolean bo = false; try{ conn = ConnectDB.getSqlServerConnection(); sql = "insert into tb_directory (dirLevel,parentDirId,dirName,userId,createTime) " + "values("+direct.getDirLevel()+","+direct.getParentDirId()+",'"+direct.getDirName()+"',"+direct.getUserId()+",'"+direct.getCreateTime()+"')"; pt = conn.prepareStatement(sql); bo = pt.execute(); bo = true; }catch(Exception e){ e.printStackTrace(); bo = false; }finally{ ConnectDB.closeSqlConnection(); } return bo; } /** * *@author qingyu zhang *@function:add a contact * @param contactBean * @return *2011-2-22 *下午02:18:17 *AddressListModule *com.AddressListModule.dao *boolean */ public boolean addContact(ContactBean contactBean){ boolean bo = false; try { conn = ConnectDB.getSqlServerConnection(); sql = "insert into tb_customer (customerName,customerPhone,lastTime,dirId,customerIntegral) " + "values('"+contactBean.getCustomerName()+"','"+contactBean.getCustomerPhone()+"','"+contactBean.getLastTime() +"',"+contactBean.getDirId()+",'"+contactBean.getCustomerIntegral()+"')"; System.out.println("新增SQL=="+sql); pt = conn.prepareStatement(sql); bo = pt.execute(); }catch(Exception e){ e.printStackTrace(); }finally{ ConnectDB.closeSqlConnection(); } return bo; } /** * *@author qingyu zhang *@function:save directory with arrayList * @param directList * @return *2011-2-17 *下午02:18:47 *AddressListModule *com.AddressListModule.dao *boolean */ public boolean addList(ArrayList directList){ return true; } /** * *@author qingyu zhang *@function:get List of directory by condition * @param tableName * @param order * @param condition * @return *2011-2-17 *下午02:20:20 *AddressListModule *com.AddressListModule.dao *List<DirectoryBean> */ public List<DirectoryBean> getAllTbDirectory(String tableName,String order,String condition){ try{ conn = ConnectDB.getSqlServerConnection(); sql= UtilDAO.getList(tableName, order, condition); System.out.println("查询语句"+sql); pt = conn.prepareStatement(sql); rs = pt.executeQuery(); while(rs.next()){ if(directoryList==null){ directoryList = new ArrayList<DirectoryBean>(); } directoryList.add(this.getDirectory(rs)); } }catch(Exception e){ System.out.println("error!!!!!!!!!!"); return null; }finally{ ConnectDB.closeSqlConnection(); } return directoryList; } /** * *@author qingyu zhang *@function:get a object from ResultSet * @param rs * @return *2011-2-17 *下午03:03:01 *AddressListModule *com.AddressListModule.dao *DirectoryBean */ public DirectoryBean getDirectory(ResultSet rs){ DirectoryBean directory = new DirectoryBean(); try{ directory.setCreateTime(rs.getString("createTime")); directory.setDirId(rs.getInt("dirId")); directory.setDirLevel(rs.getInt("dirLevel")); directory.setDirName(rs.getString("dirName")); directory.setParentDirId(rs.getInt("parentDirId")); directory.setUserId(rs.getInt("userId")); }catch(Exception e){ e.printStackTrace(); }finally{ return directory; } } /** * *@author qingyu zhang *@function:get the linkMan by condition * @param tableName * @param order * @param condition * @return *2011-2-19 *下午02:53:57 *AddressListModule *com.AddressListModule.dao *List<ContactBean> */ public List<ContactBean> getContactList(String tableName,String order,String condition){ try{ conn = ConnectDB.getSqlServerConnection(); sql= UtilDAO.getListT(tableName, order, condition); pt = conn.prepareStatement(sql); System.out.println("sql==="+sql); rs = pt.executeQuery(); while(rs.next()){ if(contactList==null){ contactList = new ArrayList(); } contactList.add(this.getContact(rs)); } }catch(Exception e){ System.out.println("error!!!!!!!!!!"); return null; }finally{ ConnectDB.closeSqlConnection(); } return contactList; } /** * *@author qingyu zhang *@function:get a object of linkMan * @param rs * @return *2011-2-19 *下午02:54:52 *AddressListModule *com.AddressListModule.dao *ContactBean */ public ContactBean getContact(ResultSet rs){ ContactBean contactBean = new ContactBean(); try{ contactBean.setCustomerId(rs.getInt("customerId")); contactBean.setCustomerIntegral(rs.getString("customerIntegral")); contactBean.setCustomerName(rs.getString("customerName"));; contactBean.setCustomerPhone(rs.getString("customerPhone")); contactBean.setDirId(rs.getInt("dirId")); contactBean.setLastTime(rs.getString("lastTime")); }catch(Exception e){ e.printStackTrace(); }finally{ return contactBean; } } /** * *@author qingyu zhang *@function:get the ID of Directory by MAX(ID) * @param tableName * @param condition * @return *2011-2-22 *上午09:44:29 *AddressListModule *com.AddressListModule.dao *DirectoryBean */ public int getDirectory(String tableName){ int maxDirId = 0; try{ conn = ConnectDB.getSqlServerConnection(); sql = "select max(dirId) maxDirId from "+tableName; pt = conn.prepareStatement(sql); rs = pt.executeQuery(); if(rs.next()){ maxDirId = rs.getInt("maxDirId"); } }catch(Exception e){ e.printStackTrace(); }finally{ ConnectDB.closeSqlConnection(); return maxDirId; } } /** * *@author qingyu zhang *@function:get a directory by dirId * @param tablName * @param inKey * @param dirId * @return *2011-2-22 *上午10:12:32 *AddressListModule *com.AddressListModule.dao *DirectoryBean */ public DirectoryBean getDirectory(String tablName,String inKey,int dirId){ try{ conn = ConnectDB.getSqlServerConnection(); sql = UtilDAO.getObject(tablName, inKey, dirId); pt =conn.prepareStatement(sql); rs = pt.executeQuery(); if(rs.next()){ if(directoryBean==null){ directoryBean = new DirectoryBean(); } directoryBean = this.getDirectory(rs); } }catch(Exception e){ e.printStackTrace(); }finally{ ConnectDB.closeSqlConnection(); return directoryBean; } } /** * *@author qingyu zhang *@function:modify a Directory * @param directoryBean * @return *2011-2-22 *上午10:27:18 *AddressListModule *com.AddressListModule.dao *boolean */ public boolean modifyDirectory(DirectoryBean directoryBean){ boolean bo = false; try{ conn = ConnectDB.getSqlServerConnection(); sql = "update tb_directory set dirName='"+directoryBean.getDirName()+"' where dirId="+directoryBean.getDirId(); pt = conn.prepareStatement(sql); bo = pt.execute(); }catch(Exception e){ e.printStackTrace(); bo = false; }finally{ ConnectDB.closeSqlConnection(); return bo; } } /** * *@author qingyu zhang *@function:update a linkMan * @param contactBean * @return *2011-2-23 *下午01:37:06 *AddressListModule *com.AddressListModule.dao *boolean */ public boolean modifyContact(ContactBean contactBean){ boolean bo = false; try{ conn = ConnectDB.getSqlServerConnection(); sql = "update tb_customer set customerName='"+contactBean.getCustomerName()+"',customerPhone='"+contactBean.getCustomerPhone() +"',lastTime='"+contactBean.getLastTime()+"',customerIntegral='"+contactBean.getCustomerIntegral()+"' where customerId="+contactBean.getCustomerId(); System.out.println("修改的语句"+sql); pt = conn.prepareStatement(sql); bo = pt.execute(); }catch(Exception e){ e.printStackTrace(); }finally{ ConnectDB.closeSqlConnection(); return bo; } } /** * *@author qingyu zhang *@function:get the chilDirIdList of parDirId * @param parDirId * @return *2011-2-24 *下午03:03:27 *AddressListModule *com.AddressListModule.dao *String */ public String getChilDirId(String tableName,String order,String condition){ String chilDirId = ""; try{ sql= UtilDAO.getList(tableName, order, condition); conn = ConnectDB.getSqlServerConnection(); pt = conn.prepareStatement(sql); rs = pt.executeQuery(); while(rs.next()){ chilDirId+=this.getDirectory(rs).getDirId()+","; } }catch(Exception e){ e.printStackTrace(); }finally{ ConnectDB.closeSqlConnection(); return chilDirId; } } /** * *@author qingyu zhang *@function:get a ContactBean by ID * @param contactId * @return *2011-2-23 *下午03:56:09 *AddressListModule *com.AddressListModule.dao *ContactBean */ public ContactBean getContact(String contactId){ try{ conn = ConnectDB.getSqlServerConnection(); sql = "select * from tb_customer where customerId="+contactId; pt =conn.prepareStatement(sql); rs = pt.executeQuery(); if(rs.next()){ if(contactBean==null){ contactBean = new ContactBean(); } contactBean = this.getContact(rs); } }catch(Exception e){ e.printStackTrace(); }finally{ ConnectDB.closeSqlConnection(); return contactBean; } } /** * *@author qingyu zhang *@function:get the directory from tb_userDirectory * @param tableName * @param orde * @param condition * @return *2011-2-25 *上午10:28:07 *MmsModule *com.AddressListModule.dao *List<TbUserDirectory> */ public List<TbUserDirectory> getUserDirByRole(String tableName,String order ,String condition){ try{ conn = ConnectDB.getSqlServerConnection(); sql= UtilDAO.getList(tableName, order, condition); pt = conn.prepareStatement(sql); rs = pt.executeQuery(); while(rs.next()){ if(userDirectoryList==null){ userDirectoryList = new ArrayList(); } userDirectoryList.add(this.getUserDirectory(rs)); } }catch(Exception e){ System.out.println("error!!!!!!!!!!"); return null; }finally{ ConnectDB.closeSqlConnection(); return userDirectoryList; } } /** * *@author qingyu zhang *@function:get a object of TbUserDirectory * @param rs * @return *2011-2-25 *上午10:30:24 *MmsModule *com.AddressListModule.dao *TbUserDirectory */ public TbUserDirectory getUserDirectory(ResultSet rs){ TbUserDirectory tbUserDir = new TbUserDirectory(); try { tbUserDir.setCreateDate(rs.getString("createDate")); tbUserDir.setDirectoryId(rs.getInt("directoryId")); tbUserDir.setUser_directoryId(rs.getInt("user_directoryId")); tbUserDir.setUserId(rs.getInt("userId")); }catch(Exception e){ e.printStackTrace(); }finally{ ConnectDB.closeSqlConnection(); return tbUserDir; } } /** * *@author qingyu zhang *@function:save contact by List * @param contactList * @return *2011-3-7 *下午08:43:16 *bzsafety *com.AddressListModule.dao *boolean */ public boolean saveContactList(List<ContactBean> contactList){ boolean bo = false; try { conn = ConnectDB.getSqlServerConnection(); st = conn.createStatement(); if(contactList!=null&&contactList.size()>0){ for(ContactBean contact:contactList){ String hql = "insert into tb_customer (customerName,customerPhone,lastTime,dirId,customerIntegral) " + "values('"+contact.getCustomerName()+"','"+contact.getCustomerPhone()+"','"+contact.getLastTime() +"',"+contact.getDirId()+",'"+contact.getCustomerIntegral()+"')"; System.out.println("hql==="+hql); st.addBatch(hql); } st.executeBatch(); bo = true; } }catch(Exception e){ e.printStackTrace(); bo = false; }finally{ ConnectDB.closeSqlConnection(); return bo ; } } /** * *@author qingyu zhang *@function:get a directory by dirId * @param dirId * @return *2011-3-18 *上午11:32:43 *bzsafety *com.AddressListModule.dao *DirectoryBean */ public DirectoryBean getDirect(int dirId){ try { conn = ConnectDB.getSqlServerConnection(); sql="select * from tb_directory where dirId="+dirId; pt = conn.prepareStatement(sql); rs = pt.executeQuery(); while(rs.next()){ if(directoryBean==null){ directoryBean = new DirectoryBean(); directoryBean = getDirectory(rs); } } } catch (Exception e) { // TODO Auto-generated catch block e.printStackTrace(); }finally{ ConnectDB.closeSqlConnection(); return directoryBean; } } public int getMaxContantId(){ int maxNum = 0; try { conn = ConnectDB.getSqlServerConnection(); sql = "select Max(customerId) maxId from tb_customer"; pt = conn.prepareStatement(sql); rs = pt.executeQuery(); if(rs.next()){ maxNum = rs.getInt("maxId"); } } catch (Exception e) { // TODO Auto-generated catch block e.printStackTrace(); }finally{ ConnectDB.closeSqlConnection(); return maxNum; } } }
zzprojects
trunk/zzprojects/zzClub/src/com/AddressListModule/dao/AddressModuleDao.java
Java
asf20
14,639
package com.AddressListModule.dao; import java.sql.Connection; import java.sql.PreparedStatement; import java.sql.ResultSet; import java.sql.Statement; import java.util.ArrayList; import java.util.List; import util.ConnectDB; import util.UtilDAO; import com.AddressListModule.bean.KehujifenBean; import com.AddressListModule.bean.DirectoryBean; import com.AddressListModule.bean.KehujifenBean; import com.AddressListModule.bean.TbUserDirectory; public class KehujifenModuleDao { /** *@author qingyu zhang *@function: *2011-2-17 *下午02:13:22 *AddressListModule *com.AddressListModule.dao */ // 数据库连接 private Connection conn = null; // st对象 private PreparedStatement pt = null; private Statement st = null; // 结果集 private ResultSet rs = null; // 成功失败标志 private boolean flag = false; // 要执行的语句 private String sql = ""; private DirectoryBean directoryBean = null; private KehujifenBean contactBean = null; private List<DirectoryBean> directoryList = null; private List<KehujifenBean> contactList = null; private List<TbUserDirectory> userDirectoryList = null; /** * *@author qingyu zhang *@function:add a record of directory * @param direct * @return *2011-2-17 *下午02:17:47 *AddressListModule *com.AddressListModule.dao *boolean */ public boolean add(DirectoryBean direct){ boolean bo = false; try{ conn = ConnectDB.getSqlServerConnection(); sql = "insert into tb_directory (dirLevel,parentDirId,dirName,userId,createTime) " + "values("+direct.getDirLevel()+","+direct.getParentDirId()+",'"+direct.getDirName()+"',"+direct.getUserId()+",'"+direct.getCreateTime()+"')"; pt = conn.prepareStatement(sql); bo = pt.execute(); bo = true; }catch(Exception e){ e.printStackTrace(); bo = false; }finally{ ConnectDB.closeSqlConnection(); } return bo; } /** * *@author qingyu zhang *@function:add a contact * @param contactBean * @return *2011-2-22 *下午02:18:17 *AddressListModule *com.AddressListModule.dao *boolean */ public boolean addContact(KehujifenBean contactBean){ boolean bo = false; try { conn = ConnectDB.getSqlServerConnection(); sql = "insert into tb_kehujifen (customerName,customerPhone,lastTime,dirId,customerIntegral) " + "values('"+contactBean.getCustomerName()+"','"+contactBean.getCustomerPhone()+"','"+contactBean.getLastTime() +"',"+contactBean.getDirId()+",'"+contactBean.getCustomerIntegral()+"')"; System.out.println("新增SQL=="+sql); pt = conn.prepareStatement(sql); int ifinsertok = pt.executeUpdate(); if(ifinsertok>0){ bo=true; } System.out.println("bo++++++++++++++++++++++++"+bo); }catch(Exception e){ e.printStackTrace(); }finally{ ConnectDB.closeSqlConnection(); } return bo; } /** * *@author qingyu zhang *@function:save directory with arrayList * @param directList * @return *2011-2-17 *下午02:18:47 *AddressListModule *com.AddressListModule.dao *boolean */ public boolean addList(ArrayList directList){ return true; } /** * *@author qingyu zhang *@function:get List of directory by condition * @param tableName * @param order * @param condition * @return *2011-2-17 *下午02:20:20 *AddressListModule *com.AddressListModule.dao *List<DirectoryBean> */ public List<DirectoryBean> getAllTbDirectory(String tableName,String order,String condition){ try{ conn = ConnectDB.getSqlServerConnection(); sql= UtilDAO.getList(tableName, order, condition); System.out.println("查询语句"+sql); pt = conn.prepareStatement(sql); rs = pt.executeQuery(); while(rs.next()){ if(directoryList==null){ directoryList = new ArrayList<DirectoryBean>(); } directoryList.add(this.getDirectory(rs)); } }catch(Exception e){ System.out.println("error!!!!!!!!!!"); return null; }finally{ ConnectDB.closeSqlConnection(); } return directoryList; } public List allphone(){ List allphoneList=new ArrayList(); try { conn = ConnectDB.getSqlServerConnection(); sql= "select customerPhone from tb_kehujifen"; System.out.println("查询语句"+sql); pt = conn.prepareStatement(sql); rs = pt.executeQuery(); while(rs.next()){ allphoneList.add(rs.getString("customerPhone")); } } catch (Exception e) { e.printStackTrace(); }finally{ ConnectDB.closeSqlConnection(); } return allphoneList; } /** * *@author qingyu zhang *@function:get a object from ResultSet * @param rs * @return *2011-2-17 *下午03:03:01 *AddressListModule *com.AddressListModule.dao *DirectoryBean */ public DirectoryBean getDirectory(ResultSet rs){ DirectoryBean directory = new DirectoryBean(); try{ directory.setCreateTime(rs.getString("createTime")); directory.setDirId(rs.getInt("dirId")); directory.setDirLevel(rs.getInt("dirLevel")); directory.setDirName(rs.getString("dirName")); directory.setParentDirId(rs.getInt("parentDirId")); directory.setUserId(rs.getInt("userId")); }catch(Exception e){ e.printStackTrace(); }finally{ return directory; } } /** * *@author qingyu zhang *@function:get the linkMan by condition * @param tableName * @param order * @param condition * @return *2011-2-19 *下午02:53:57 *AddressListModule *com.AddressListModule.dao *List<KehujifenBean> */ public List<KehujifenBean> getContactList(String tableName,String order,String condition){ try{ conn = ConnectDB.getSqlServerConnection(); sql= UtilDAO.getListT(tableName, order, condition); pt = conn.prepareStatement(sql); System.out.println("sql==="+sql); rs = pt.executeQuery(); while(rs.next()){ if(contactList==null){ contactList = new ArrayList(); } contactList.add(this.getContact(rs)); } }catch(Exception e){ System.out.println("error!!!!!!!!!!"); return null; }finally{ ConnectDB.closeSqlConnection(); } return contactList; } /** * *@author qingyu zhang *@function:get a object of linkMan * @param rs * @return *2011-2-19 *下午02:54:52 *AddressListModule *com.AddressListModule.dao *KehujifenBean */ public KehujifenBean getContact(ResultSet rs){ KehujifenBean contactBean = new KehujifenBean(); try{ contactBean.setCustomerId(rs.getInt("customerId")); contactBean.setCustomerIntegral(rs.getString("customerIntegral")); contactBean.setCustomerName(rs.getString("customerName"));; contactBean.setCustomerPhone(rs.getString("customerPhone")); contactBean.setDirId(rs.getInt("dirId")); contactBean.setLastTime(rs.getString("lastTime")); }catch(Exception e){ e.printStackTrace(); }finally{ return contactBean; } } /** * *@author qingyu zhang *@function:get the ID of Directory by MAX(ID) * @param tableName * @param condition * @return *2011-2-22 *上午09:44:29 *AddressListModule *com.AddressListModule.dao *DirectoryBean */ public int getDirectory(String tableName){ int maxDirId = 0; try{ conn = ConnectDB.getSqlServerConnection(); sql = "select max(dirId) maxDirId from "+tableName; pt = conn.prepareStatement(sql); rs = pt.executeQuery(); if(rs.next()){ maxDirId = rs.getInt("maxDirId"); } }catch(Exception e){ e.printStackTrace(); }finally{ ConnectDB.closeSqlConnection(); return maxDirId; } } /** * *@author qingyu zhang *@function:get a directory by dirId * @param tablName * @param inKey * @param dirId * @return *2011-2-22 *上午10:12:32 *AddressListModule *com.AddressListModule.dao *DirectoryBean */ public DirectoryBean getDirectory(String tablName,String inKey,int dirId){ try{ conn = ConnectDB.getSqlServerConnection(); sql = UtilDAO.getObject(tablName, inKey, dirId); pt =conn.prepareStatement(sql); rs = pt.executeQuery(); if(rs.next()){ if(directoryBean==null){ directoryBean = new DirectoryBean(); } directoryBean = this.getDirectory(rs); } }catch(Exception e){ e.printStackTrace(); }finally{ ConnectDB.closeSqlConnection(); return directoryBean; } } /** * *@author qingyu zhang *@function:modify a Directory * @param directoryBean * @return *2011-2-22 *上午10:27:18 *AddressListModule *com.AddressListModule.dao *boolean */ public boolean modifyDirectory(DirectoryBean directoryBean){ boolean bo = false; try{ conn = ConnectDB.getSqlServerConnection(); sql = "update tb_directory set dirName='"+directoryBean.getDirName()+"' where dirId="+directoryBean.getDirId(); pt = conn.prepareStatement(sql); bo = pt.execute(); }catch(Exception e){ e.printStackTrace(); bo = false; }finally{ ConnectDB.closeSqlConnection(); return bo; } } /** * *@author qingyu zhang *@function:update a linkMan * @param contactBean * @return *2011-2-23 *下午01:37:06 *AddressListModule *com.AddressListModule.dao *boolean */ public boolean modifyContact(KehujifenBean contactBean){ boolean bo = false; try{ conn = ConnectDB.getSqlServerConnection(); sql = "update tb_kehujifen set customerName='"+contactBean.getCustomerName()+"',customerPhone='"+contactBean.getCustomerPhone() +"',lastTime='"+contactBean.getLastTime()+"',customerIntegral='"+contactBean.getCustomerIntegral()+"' where customerId="+contactBean.getCustomerId(); System.out.println("修改的语句"+sql); pt = conn.prepareStatement(sql); bo = pt.execute(); }catch(Exception e){ e.printStackTrace(); }finally{ ConnectDB.closeSqlConnection(); return bo; } } /** * *@author qingyu zhang *@function:get the chilDirIdList of parDirId * @param parDirId * @return *2011-2-24 *下午03:03:27 *AddressListModule *com.AddressListModule.dao *String */ public String getChilDirId(String tableName,String order,String condition){ String chilDirId = ""; try{ sql= UtilDAO.getList(tableName, order, condition); conn = ConnectDB.getSqlServerConnection(); pt = conn.prepareStatement(sql); rs = pt.executeQuery(); while(rs.next()){ chilDirId+=this.getDirectory(rs).getDirId()+","; } }catch(Exception e){ e.printStackTrace(); }finally{ ConnectDB.closeSqlConnection(); return chilDirId; } } /** * *@author qingyu zhang *@function:get a KehujifenBean by ID * @param contactId * @return *2011-2-23 *下午03:56:09 *AddressListModule *com.AddressListModule.dao *KehujifenBean */ public KehujifenBean getContact(String contactId){ try{ conn = ConnectDB.getSqlServerConnection(); sql = "select * from tb_kehujifen where customerId="+contactId; pt =conn.prepareStatement(sql); rs = pt.executeQuery(); if(rs.next()){ if(contactBean==null){ contactBean = new KehujifenBean(); } contactBean = this.getContact(rs); } }catch(Exception e){ e.printStackTrace(); }finally{ ConnectDB.closeSqlConnection(); return contactBean; } } /** * *@author qingyu zhang *@function:get the directory from tb_userDirectory * @param tableName * @param orde * @param condition * @return *2011-2-25 *上午10:28:07 *MmsModule *com.AddressListModule.dao *List<TbUserDirectory> */ public List<TbUserDirectory> getUserDirByRole(String tableName,String order ,String condition){ try{ conn = ConnectDB.getSqlServerConnection(); sql= UtilDAO.getList(tableName, order, condition); pt = conn.prepareStatement(sql); rs = pt.executeQuery(); while(rs.next()){ if(userDirectoryList==null){ userDirectoryList = new ArrayList(); } userDirectoryList.add(this.getUserDirectory(rs)); } }catch(Exception e){ System.out.println("error!!!!!!!!!!"); return null; }finally{ ConnectDB.closeSqlConnection(); return userDirectoryList; } } /** * *@author qingyu zhang *@function:get a object of TbUserDirectory * @param rs * @return *2011-2-25 *上午10:30:24 *MmsModule *com.AddressListModule.dao *TbUserDirectory */ public TbUserDirectory getUserDirectory(ResultSet rs){ TbUserDirectory tbUserDir = new TbUserDirectory(); try { tbUserDir.setCreateDate(rs.getString("createDate")); tbUserDir.setDirectoryId(rs.getInt("directoryId")); tbUserDir.setUser_directoryId(rs.getInt("user_directoryId")); tbUserDir.setUserId(rs.getInt("userId")); }catch(Exception e){ e.printStackTrace(); }finally{ ConnectDB.closeSqlConnection(); return tbUserDir; } } /** * *@author qingyu zhang *@function:save contact by List * @param contactList * @return *2011-3-7 *下午08:43:16 *bzsafety *com.AddressListModule.dao *boolean */ public boolean saveContactList(List<KehujifenBean> contactList){ boolean bo = false; try { conn = ConnectDB.getSqlServerConnection(); st = conn.createStatement(); if(contactList!=null&&contactList.size()>0){ for(KehujifenBean contact:contactList){ String hql = "insert into tb_kehujifen (customerName,customerPhone,lastTime,dirId,customerIntegral) " + "values('"+contact.getCustomerName()+"','"+contact.getCustomerPhone()+"','"+contact.getLastTime() +"',"+contact.getDirId()+",'"+contact.getCustomerIntegral()+"')"; System.out.println("hql==="+hql); st.addBatch(hql); } st.executeBatch(); bo = true; } }catch(Exception e){ e.printStackTrace(); bo = false; }finally{ ConnectDB.closeSqlConnection(); return bo ; } } /** * *@author qingyu zhang *@function:get a directory by dirId * @param dirId * @return *2011-3-18 *上午11:32:43 *bzsafety *com.AddressListModule.dao *DirectoryBean */ public DirectoryBean getDirect(int dirId){ try { conn = ConnectDB.getSqlServerConnection(); sql="select * from tb_directory where dirId="+dirId; pt = conn.prepareStatement(sql); rs = pt.executeQuery(); while(rs.next()){ if(directoryBean==null){ directoryBean = new DirectoryBean(); directoryBean = getDirectory(rs); } } } catch (Exception e) { // TODO Auto-generated catch block e.printStackTrace(); }finally{ ConnectDB.closeSqlConnection(); return directoryBean; } } public int getMaxContantId(){ int maxNum = 0; try { conn = ConnectDB.getSqlServerConnection(); sql = "select Max(customerId) maxId from tb_kehujifen"; pt = conn.prepareStatement(sql); rs = pt.executeQuery(); if(rs.next()){ maxNum = rs.getInt("maxId"); } } catch (Exception e) { // TODO Auto-generated catch block e.printStackTrace(); }finally{ ConnectDB.closeSqlConnection(); return maxNum; } } }
zzprojects
trunk/zzprojects/zzClub/src/com/AddressListModule/dao/KehujifenModuleDao.java
Java
asf20
15,368
package com.jifen.bean; import java.io.Serializable; public class JiFen implements Serializable{ /** *@author qingyu zhang *@function: *2011-4-6 *上午07:43:54 *zzClub *com.jifen.bean */ private int integralId; private String typeId; private int userId; private String integralValue; private int integralType;//区分点播、答题的上行或下行 private String setTime; private String seriseId; public int getIntegralId() { return integralId; } public void setIntegralId(int integralId) { this.integralId = integralId; } public String getTypeId() { return typeId; } public void setTypeId(String typeId) { this.typeId = typeId; } public int getUserId() { return userId; } public void setUserId(int userId) { this.userId = userId; } public String getIntegralValue() { return integralValue; } public void setIntegralValue(String integralValue) { this.integralValue = integralValue; } public int getIntegralType() { return integralType; } public void setIntegralType(int integralType) { this.integralType = integralType; } public String getSetTime() { return setTime; } public void setSetTime(String setTime) { this.setTime = setTime; } public String getSeriseId() { return seriseId; } public void setSeriseId(String seriseId) { this.seriseId = seriseId; } }
zzprojects
trunk/zzprojects/zzClub/src/com/jifen/bean/JiFen.java
Java
asf20
1,407
package com.jifen.servlet; import java.io.IOException; import java.io.PrintWriter; import javax.servlet.ServletException; import javax.servlet.http.HttpServlet; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; public class JifenServlet extends HttpServlet { /** * Constructor of the object. */ public JifenServlet() { super(); } /** * Destruction of the servlet. <br> */ public void destroy() { super.destroy(); // Just puts "destroy" string in log // Put your code here } /** * The doGet method of the servlet. <br> * * This method is called when a form has its tag value method equals to get. * * @param request the request send by the client to the server * @param response the response send by the server to the client * @throws ServletException if an error occurred * @throws IOException if an error occurred */ public void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { response.setContentType("text/html"); PrintWriter out = response.getWriter(); out .println("<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.01 Transitional//EN\">"); out.println("<HTML>"); out.println(" <HEAD><TITLE>A Servlet</TITLE></HEAD>"); out.println(" <BODY>"); out.print(" This is "); out.print(this.getClass()); out.println(", using the GET method"); out.println(" </BODY>"); out.println("</HTML>"); out.flush(); out.close(); } /** * The doPost method of the servlet. <br> * * This method is called when a form has its tag value method equals to post. * * @param request the request send by the client to the server * @param response the response send by the server to the client * @throws ServletException if an error occurred * @throws IOException if an error occurred */ public void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { response.setContentType("text/html"); PrintWriter out = response.getWriter(); out .println("<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.01 Transitional//EN\">"); out.println("<HTML>"); out.println(" <HEAD><TITLE>A Servlet</TITLE></HEAD>"); out.println(" <BODY>"); out.print(" This is "); out.print(this.getClass()); out.println(", using the POST method"); out.println(" </BODY>"); out.println("</HTML>"); out.flush(); out.close(); } /** * Initialization of the servlet. <br> * * @throws ServletException if an error occurs */ public void init() throws ServletException { // Put your code here } /** *@author qingyu zhang *@function: *2011-4-6 *上午07:49:29 *zzClub *com.jifen.servlet */ }
zzprojects
trunk/zzprojects/zzClub/src/com/jifen/servlet/JifenServlet.java
Java
asf20
2,843
package com.jifen.dao; import java.sql.ResultSet; import java.sql.SQLException; import util.TotalClass; import util.UtilDAO; import com.AddressListModule.bean.KehujifenBean; import com.jifen.bean.JiFen; public class JifenDao { /** *@author qingyu zhang *@function: *2011-4-6 *上午07:49:09 *zzClub *com.jifen.dao */ private String sql = ""; private ResultSet rs = null; JiFen jiFen = null; /** * *@author qingyu zhang *@function:设置点播积分 * @param jf * @return *2011-4-6 *上午09:32:55 *zzClub *com.jifen.dao *boolean */ public boolean addJiFen(JiFen jf){ System.out.println("得到ID="+jf.getTypeId()); boolean bo = false; String condition=" typeId='"+jf.getTypeId()+"'and integralType="+jf.getIntegralType(); JiFen jiFen = getJiFen("tb_integral","setTime",condition); if(jiFen==null){ sql="insert into tb_integral (typeId,userId,integralValue,integralType,setTime,seriseId) " + "values('"+jf.getTypeId()+"',"+jf.getUserId()+",'"+jf.getIntegralValue()+"',"+jf.getIntegralType()+",'"+jf.getSetTime()+"','"+jf.getSeriseId()+"')"; }else{ sql="update tb_integral set integralValue='"+jf.getIntegralValue()+"',setTime='"+jf.getSetTime()+"' where typeId='"+jf.getTypeId()+"' and integralType="+jf.getIntegralType(); } System.out.println("插入语句"+sql); bo = new TotalClass().operatorObject(sql); return bo; } public boolean addJiFenXilie(JiFen jf){ System.out.println("得到ID="+jf.getTypeId()); boolean bo = false; String condition=" seriseId='"+jf.getSeriseId()+"'"; JiFen jiFen = getJiFen("tb_integral","setTime",condition); if(jiFen==null){ sql="insert into tb_integral (userId,integralValue,integralType,setTime,seriseId) " + "values("+jf.getUserId()+",'"+jf.getIntegralValue()+"',"+jf.getIntegralType()+",'"+jf.getSetTime()+"','"+jf.getSeriseId()+"')"; }else{ sql="update tb_integral set integralValue='"+jf.getIntegralValue()+"',setTime='"+jf.getSetTime()+"' where seriseId='"+jf.getSeriseId()+"'"; } System.out.println("插入语句"+sql); bo = new TotalClass().operatorObject(sql); return bo; } /** * *@author qingyu zhang *@function:根据typeId得到积分对象 * @param table * @param order * @param conditions * @return *2011-4-6 *上午07:53:22 *zzClub *com.jifen.dao *JiFen */ public JiFen getJiFen(String table,String order,String condition){ sql= UtilDAO.getList(table, order, condition); System.out.println("修改积分语句"+sql); ResultSet rs = new TotalClass().getResult(sql); try { if(rs.next()){ if(jiFen==null){ jiFen = new JiFen(); } jiFen = getJiFen(rs); } } catch (SQLException e) { // TODO Auto-generated catch block e.printStackTrace(); } return jiFen; } public JiFen getJiFen(ResultSet rs){ JiFen jf = new JiFen(); try { jf.setIntegralId(rs.getInt("integralId")); jf.setIntegralType(rs.getInt("integralType")); jf.setIntegralValue(rs.getString("integralValue")); jf.setSeriseId(rs.getString("seriseId")); jf.setSetTime(rs.getString("setTime")); jf.setTypeId(rs.getString("typeId")); jf.setUserId(rs.getInt("userId")); } catch (SQLException e) { // TODO Auto-generated catch block e.printStackTrace(); } return jf; } /** * *@author qingyu zhang *@function:根据手机号码得到此号码的积分 * @param phone * @return *2011-4-15 *上午11:00:27 *zzClub *com.jifen.dao *KehujifenBean */ public KehujifenBean getKehujifen(String phone){ sql="select * from tb_kehujifen where customerPhone='"+phone+"'"; rs = new TotalClass().getResult(sql); KehujifenBean kehujifen = null; try { while(rs.next()){ if(kehujifen==null){ kehujifen =new KehujifenBean(); } kehujifen.setCustomerId(rs.getInt("customerId")); kehujifen.setCustomerIntegral(rs.getString("customerIntegral")); kehujifen.setCustomerName(rs.getString("customerName")); kehujifen.setCustomerPhone(rs.getString("customerPhone")); kehujifen.setLastTime(rs.getString("lastTime")); kehujifen.setDirId(rs.getInt("dirId")); } } catch (SQLException e) { // TODO Auto-generated catch block e.printStackTrace(); } return kehujifen; } }
zzprojects
trunk/zzprojects/zzClub/src/com/jifen/dao/JifenDao.java
Java
asf20
4,398
package com.UserModule.bean; import java.io.Serializable; public class TbUserBean implements Serializable{ /** *@author qingyu zhang *@function: *2011-3-23 *下午09:41:20 *zzClub *com.UserModule.bean */ private int userId; private String userName; private String userPhone; private int userSex; private String userBirth; private String userPass; private int userState; private String createTime; private int createUserId; private int orgNum; public int getUserId() { return userId; } public void setUserId(int userId) { this.userId = userId; } public String getUserName() { return userName; } public void setUserName(String userName) { this.userName = userName; } public String getUserPhone() { return userPhone; } public void setUserPhone(String userPhone) { this.userPhone = userPhone; } public int getUserSex() { return userSex; } public void setUserSex(int userSex) { this.userSex = userSex; } public String getUserBirth() { return userBirth; } public void setUserBirth(String userBirth) { this.userBirth = userBirth; } public String getUserPass() { return userPass; } public void setUserPass(String userPass) { this.userPass = userPass; } public int getUserState() { return userState; } public void setUserState(int userState) { this.userState = userState; } public int getCreateUserId() { return createUserId; } public void setCreateUserId(int createUserId) { this.createUserId = createUserId; } public String getCreateTime() { return createTime; } public void setCreateTime(String createTime) { this.createTime = createTime; } public TbUserBean() { } public TbUserBean(String userName, String userPass) { this.userName = userName; this.userPass = userPass; } public TbUserBean(String userName, String userPass,int orgNum) { this.userName = userName; this.userPass = userPass; this.orgNum = orgNum; } public TbUserBean(int userId, String userName, String userPass) { this.userId = userId; this.userName = userName; this.userPass = userPass; } public int getOrgNum() { return orgNum; } public void setOrgNum(int orgNum) { this.orgNum = orgNum; } }
zzprojects
trunk/zzprojects/zzClub/src/com/UserModule/bean/TbUserBean.java
Java
asf20
2,312
package com.UserModule.servlet; import java.io.File; import java.io.IOException; import java.util.Random; import javax.servlet.ServletException; import javax.servlet.http.HttpServlet; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; import javax.servlet.http.HttpSession; import org.apache.commons.configuration.XMLConfiguration; import util.ConnectDB; import util.UtilDAO; import com.UserModule.bean.TbUserBean; import com.UserModule.dao.TbUserDAO; public class TbUsersServlet extends HttpServlet{ public void processRequest(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { String method = ""; if (request.getParameter("method") != null) { method = request.getParameter("method"); } if ("add".equals(method)) { String userName=request.getParameter("userName"); String userPass=request.getParameter("userPass"); String biaoshi=request.getParameter("biaoshi"); if(new TbUserDAO().add(new TbUserBean(userName,userPass,Integer.parseInt(biaoshi)))) { request.getSession().setAttribute("userModuleResult", "添加用户成功"); }else{ request.getSession().setAttribute("userModuleResult", "添加用户失败"); } response.sendRedirect("UserModule/UsersList.jsp"); }//end method add if ("edit".equals(method)) { int userId=Integer.parseInt(request.getParameter("userId")); String userName=request.getParameter("userName"); String userPass=request.getParameter("userPass"); if(new TbUserDAO().edit(new TbUserBean(userId,userName,userPass))){ request.getSession().setAttribute("userModuleResult", "修改用户成功"); }else{ request.getSession().setAttribute("userModuleResult", "修改用户失败"); } response.sendRedirect("UserModule/UsersList.jsp"); } if("login".equals(method)){ String userName=request.getParameter("userName"); String userPass=request.getParameter("userPass"); TbUserBean tu=new TbUserDAO().checkLogin(userName,userPass); request.getSession().setAttribute("User", tu); if(tu!=null){ response.sendRedirect("index.jsp?err=1"); }else{ response.sendRedirect("UserModule/Login.jsp?err=1"); } } }// end method processRequest public void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { this.processRequest(request, response); }// end method doGet; public void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { this.processRequest(request, response); }// end method doPost }
zzprojects
trunk/zzprojects/zzClub/src/com/UserModule/servlet/TbUsersServlet.java
Java
asf20
2,727
package com.UserModule.dao; import java.sql.Connection; import java.sql.PreparedStatement; import java.sql.ResultSet; import java.sql.SQLException; import java.util.ArrayList; import java.util.List; import util.ConnectDB; import util.Constant; import util.UtilDAO; import com.UserModule.bean.TbUserBean; /** * user operate DAO * @author vsked * */ public class TbUserDAO { private Connection conn = null; private PreparedStatement pt = null; private ResultSet rs = null; private boolean flag = false; private String sql = ""; private TbUserBean tbUsers=null; private List<TbUserBean> tbUsersList=null; /** * add user * @param inTbUsers * @return */ public boolean add(TbUserBean inTbUsers){ try { conn = ConnectDB.getSqlServerConnection(); sql = "insert into tb_User(userName,userPass,createTime,orgNum) values(?,?,?,?)"; pt = conn.prepareStatement(sql); pt.setString(1, inTbUsers.getUserName()); pt.setString(2, inTbUsers.getUserPass()); pt.setString(3, Constant.decodeDate()); pt.setInt(4, inTbUsers.getOrgNum()); if (pt.executeUpdate() > 0) { flag = true; } } catch (Exception e) { e.printStackTrace(); } finally { ConnectDB.closeSqlConnection(); } return flag; } /** * delete user * @param inUserId * @return */ public boolean del(int inUserId){ Connection inConn=null; try{ inConn=ConnectDB.getSqlServerConnection(); UtilDAO.del("tb_User", "userId", inUserId); flag=true; }catch (Exception e) { e.printStackTrace(); }finally{ ConnectDB.closeSqlConnection(); } return flag; } public boolean edit(TbUserBean inTbUsers){ try { conn = ConnectDB.getSqlServerConnection(); sql = "update tb_User set userName=?,userPass=? where userId=?"; pt = conn.prepareStatement(sql); pt.setString(1, inTbUsers.getUserName()); pt.setString(2, inTbUsers.getUserPass()); pt.setInt(3, inTbUsers.getUserId()); if (pt.executeUpdate() > 0) { flag = true; } } catch (Exception e) { e.printStackTrace(); } finally { ConnectDB.closeSqlConnection(); } return flag; } /** * get tbusers by userid * @param inUserId * @return */ public TbUserBean getTbUsersByUserId(int inUserId){ try { conn = ConnectDB.getSqlServerConnection(); sql = "select * from tb_User where userId=?"; pt = conn.prepareStatement(sql); pt.setInt(1, inUserId); rs = pt.executeQuery(); if (rs.next()) { tbUsers=this.getTbUsersInfo(rs); } } catch (Exception e) { e.printStackTrace(); } finally { ConnectDB.closeSqlConnection(); } return tbUsers; } /** * login check method * @param inName username * @param inPassword password * @return */ public TbUserBean checkLogin(String inName, String inPassword) { try { conn = ConnectDB.getSqlServerConnection(); sql = "select * from tb_User where userName=? and userPass=?"; pt = conn.prepareStatement(sql); pt.setString(1, inName); pt.setString(2, inPassword); rs = pt.executeQuery(); if (rs.next()) { tbUsers=this.getTbUsersInfo(rs); } } catch (Exception e) { e.printStackTrace(); } finally { ConnectDB.closeSqlConnection(); } return tbUsers; } public List<TbUserBean> getAllTbUsers(){ try { conn = ConnectDB.getSqlServerConnection(); sql = "select * from tb_User"; pt = conn.prepareStatement(sql); rs = pt.executeQuery(); while (rs.next()) { if(tbUsersList==null){ tbUsersList=new ArrayList<TbUserBean>(); } tbUsersList.add(this.getTbUsersInfo(rs)); } } catch (Exception e) { e.printStackTrace(); } finally { ConnectDB.closeSqlConnection(); } return tbUsersList; } /** * input ResultSet get TbUserBean Info * @param rs ResultSet * @return TbUserBean * @throws Exception */ public TbUserBean getTbUsersInfo(ResultSet rs) throws Exception{ TbUserBean inTbUsers=new TbUserBean(); inTbUsers.setUserId(rs.getInt("userId")); inTbUsers.setUserName(rs.getString("userName")); inTbUsers.setUserPass(rs.getString("userPass")); inTbUsers.setCreateTime(rs.getString("createTime")); inTbUsers.setOrgNum(rs.getInt("orgNum")); return inTbUsers; } /** * get database exist userOrgNumArray * @return List<Integer> or null */ public List<Integer> getUserOrgNumArray(){ List<Integer> orgNumList=null; try { conn = ConnectDB.getSqlServerConnection(); sql = "select * from tb_User"; pt = conn.prepareStatement(sql); rs = pt.executeQuery(); while (rs.next()) { if(orgNumList==null){ orgNumList=new ArrayList<Integer>(); } orgNumList.add(rs.getInt("orgNum")); } } catch (Exception e) { e.printStackTrace(); } finally { ConnectDB.closeSqlConnection(); } return orgNumList; } /** * @param args */ public static void main(String[] args) { /* TbUserBean tu=new TbUsersDAO().checkLogin("admin", "admin"); System.out.println(tu); */ List<TbUserBean> tuList=new TbUserDAO().getAllTbUsers(); if(tuList!=null){ for(int i=0;i<tuList.size();i++){ TbUserBean tu=tuList.get(i); } } }//end main method }//end class
zzprojects
trunk/zzprojects/zzClub/src/com/UserModule/dao/TbUserDAO.java
Java
asf20
6,176
package com.dianbo.bean; import java.io.Serializable; public class Dianbo implements Serializable{ /** *@author qingyu zhang *@function: *2011-4-12 *下午09:37:41 *zzClub *com.dianbo.bean */ private int qsInfoId; private int receiveId; private String typeId; private String qsContent; private String qsUpPhone; private String qsUpTime; private String qsIntegral; public int getQsInfoId() { return qsInfoId; } public void setQsInfoId(int qsInfoId) { this.qsInfoId = qsInfoId; } public int getReceiveId() { return receiveId; } public void setReceiveId(int receiveId) { this.receiveId = receiveId; } public String getTypeId() { return typeId; } public void setTypeId(String typeId) { this.typeId = typeId; } public String getQsContent() { return qsContent; } public void setQsContent(String qsContent) { this.qsContent = qsContent; } public String getQsUpPhone() { return qsUpPhone; } public void setQsUpPhone(String qsUpPhone) { this.qsUpPhone = qsUpPhone; } public String getQsUpTime() { return qsUpTime; } public void setQsUpTime(String qsUpTime) { this.qsUpTime = qsUpTime; } public String getQsIntegral() { return qsIntegral; } public void setQsIntegral(String qsIntegral) { this.qsIntegral = qsIntegral; } }
zzprojects
trunk/zzprojects/zzClub/src/com/dianbo/bean/Dianbo.java
Java
asf20
1,357
package com.dianbo.bean; import java.io.Serializable; public class DianboType implements Serializable{ /** *@author qingyu zhang *@function: *2011-4-4 *下午02:31:36 *zzClub *com.dati.bean */ private String typeId; private int userId; private String typeName; private String createTime; public int getUserId() { return userId; } public void setUserId(int userId) { this.userId = userId; } public String getTypeName() { return typeName; } public void setTypeName(String typeName) { this.typeName = typeName; } public String getTypeId() { return typeId; } public void setTypeId(String typeId) { this.typeId = typeId; } public String getCreateTime() { return createTime; } public void setCreateTime(String createTime) { this.createTime = createTime; } }
zzprojects
trunk/zzprojects/zzClub/src/com/dianbo/bean/DianboType.java
Java
asf20
853
package com.dianbo.bean; public class SendDianbo { /** *@author qingyu zhang *@function: *2011-4-12 *下午09:08:40 *zzClub *com.dianbo.bean */ private int dianboId; private String smscontent; private String sendPhone; private int state; public int getDianboId() { return dianboId; } public void setDianboId(int dianboId) { this.dianboId = dianboId; } public String getSmscontent() { return smscontent; } public void setSmscontent(String smscontent) { this.smscontent = smscontent; } public String getSendPhone() { return sendPhone; } public void setSendPhone(String sendPhone) { this.sendPhone = sendPhone; } public int getState() { return state; } public void setState(int state) { this.state = state; } }
zzprojects
trunk/zzprojects/zzClub/src/com/dianbo/bean/SendDianbo.java
Java
asf20
802
package com.dianbo.servlet; import java.io.File; import java.io.FileInputStream; import java.io.IOException; import java.io.InputStream; import java.io.PrintWriter; import java.util.ArrayList; import java.util.List; import java.util.Random; import javax.servlet.ServletException; import javax.servlet.http.HttpServlet; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; import jxl.Cell; import jxl.Sheet; import jxl.Workbook; import util.AllTypeList; import util.Constant; import com.BlackPhoneModule.bean.BlackPhoneBean; import com.BlackPhoneModule.dao.BlackPhoneModuleDao; import com.UserModule.bean.TbUserBean; import com.dati.bean.DatiType; import com.dianbo.bean.Dianbo; import com.dianbo.bean.DianboType; import com.dianbo.dao.DianboDao; import com.dianbo.dao.DianboTypeDao; import com.ibm.db2.jcc.b.di; import com.jifen.bean.JiFen; import com.jifen.dao.JifenDao; import com.jspsmart.upload.SmartUpload; public class DianboServlet extends HttpServlet { /** * Constructor of the object. */ public DianboServlet() { super(); } /** * Destruction of the servlet. <br> */ public void destroy() { super.destroy(); // Just puts "destroy" string in log // Put your code here } /** * The doGet method of the servlet. <br> * * This method is called when a form has its tag value method equals to get. * * @param request the request send by the client to the server * @param response the response send by the server to the client * @throws ServletException if an error occurred * @throws IOException if an error occurred */ public void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { response.setContentType("text/html"); PrintWriter out = response.getWriter(); String method=request.getParameter("method"); TbUserBean user = (TbUserBean)request.getSession().getAttribute("User"); if(method.equals("set")){//对点播类型进行积分设置 String dianboId = request.getParameter("dianboId"); String condition=" typeId = '"+dianboId+"'"; List<DianboType> dianboTypeList = new DianboTypeDao().getDianboList("tb_qsType_answer",condition,"createTime"); for(DianboType dt:dianboTypeList){ System.out.println("名称"+dt.getTypeName()); } request.getSession().setAttribute("dianboTypeList", dianboTypeList); response.sendRedirect("jifen/jiFenupLoadSet.jsp"); }else if(method.equals("setSubmit")){ String num = request.getParameter("num"); String typeId = request.getParameter("typeId"); JiFen jiFen = new JiFen(); jiFen.setTypeId(typeId); jiFen.setIntegralType(0); jiFen.setIntegralValue(num); jiFen.setSeriseId(""); jiFen.setSetTime(Constant.decodeDate()); jiFen.setUserId(user.getUserId()); boolean bo = new JifenDao().addJiFen(jiFen); if(bo){ request.getSession().setAttribute("result", "积分设置成功"); }else { request.getSession().setAttribute("result", "积分设置失败"); } List list = new AllTypeList().getLastValue(user.getUserId()); List<DianboType> dianboTypeList = (ArrayList<DianboType>)list.get(0); StringBuffer sb = (StringBuffer)list.get(1); request.getSession().setAttribute("dianboTypeList", dianboTypeList); request.getSession().setAttribute("sb", sb); response.sendRedirect("jifen/jiFenupLoadList.jsp"); }else if(method.equals("setDown")){ String dianboId = request.getParameter("dianboId"); String condition=" typeId = '"+dianboId+"'"; List<DianboType> dianboTypeList = new DianboTypeDao().getDianboList("tb_qsType_answer",condition,"createTime"); request.getSession().setAttribute("dianboTypeList", dianboTypeList); response.sendRedirect("jifen/jiFendownSet.jsp"); }else if(method.equals("setDownSubmit")){//设置点播的下行积分提交 String num = request.getParameter("num"); String typeId = request.getParameter("typeId"); JiFen jiFen = new JiFen(); jiFen.setTypeId(typeId); jiFen.setIntegralType(1); jiFen.setIntegralValue(num); jiFen.setSeriseId(""); jiFen.setSetTime(Constant.decodeDate()); jiFen.setUserId(user.getUserId()); boolean bo = new JifenDao().addJiFen(jiFen); if(bo){ request.getSession().setAttribute("result", "点播下行积分设置成功"); }else { request.getSession().setAttribute("result", "点播下行积分设置失败"); } List list = new AllTypeList().getDownValue(user.getUserId()); List<DianboType> dianboTypeList = (ArrayList<DianboType>)list.get(0); List<DatiType> datiTypeList = (ArrayList<DatiType>)list.get(1); request.getSession().setAttribute("result", ""); request.getSession().setAttribute("dianboTypeList", dianboTypeList); request.getSession().setAttribute("datiTypeList", datiTypeList); response.sendRedirect("jifen/jiFendownList.jsp"); }else if(method.equals("lookdianbo")){ //查询所有点播资源库的信息 String content=request.getParameter("content"); content=Constant.decodeString(content); List dianboList=new DianboDao().getDianboList("tb_qs_info","qsUpTime", ""); request.getSession().setAttribute("selectdianbotype", ""); request.getSession().setAttribute("dianboList", dianboList); request.getSession().setAttribute("content", content); response.sendRedirect("hudong/dianboList.jsp?s=1"); }else if(method.equals("looksearch")){ String content=request.getParameter("content"); content=Constant.decodeString(content); String dianbotype=request.getParameter("dianbotype"); String tiaojian=" 1=1"; if(content==null || "".equals(content)){ content=""; }else{ tiaojian+=" and qsContent like '%"+content+"%'"; } System.out.println("dianbotype:"+dianbotype); if("0".equals(dianbotype)){ }else{ tiaojian+=" and typeId="+dianbotype; } List dianboList=new DianboDao().getDianboList("tb_qs_info","qsUpTime", tiaojian); request.getSession().setAttribute("selectdianbotype", dianbotype); request.getSession().setAttribute("dianboList", dianboList); request.getSession().setAttribute("content", content); response.sendRedirect("hudong/dianboList.jsp?s=1"); }else if(method.equals("deleteOne")){ String qsInfoId=request.getParameter("qsInfoId"); boolean result=new DianboDao().del("tb_qs_info", "qsInfoId", qsInfoId); if(result){ request.getSession().setAttribute("resultSM", "此点播记录删除成功!"); }else{ request.getSession().setAttribute("resultSM", "此点播记录删除失败!"); } String content=request.getParameter("content"); content=Constant.decodeString(content); String dianbotype=request.getParameter("dianbotype"); List dianboList=new DianboDao().getDianboList("tb_qs_info","qsUpTime", ""); request.getSession().setAttribute("selectdianbotype", dianbotype); request.getSession().setAttribute("dianboList", dianboList); request.getSession().setAttribute("content", content); response.sendRedirect("hudong/dianboList.jsp?s=1"); }else if(method.equals("deleteAll")){ String idList = request.getParameter("idList"); idList = idList.substring(0, idList.length()-1); boolean result=new DianboDao().delin("tb_qs_info", "qsInfoId", idList); if(result){ request.getSession().setAttribute("resultSM", "点播记录删除成功!"); }else{ request.getSession().setAttribute("resultSM", "点播记录删除失败!"); } String content=request.getParameter("content"); content=Constant.decodeString(content); String dianbotype=request.getParameter("dianbotype"); List dianboList=new DianboDao().getDianboList("tb_qs_info","qsUpTime", ""); request.getSession().setAttribute("selectdianbotype", dianbotype); request.getSession().setAttribute("dianboList", dianboList); request.getSession().setAttribute("content", content); response.sendRedirect("hudong/dianboList.jsp?s=1"); }else if(method.equals("importDianboSubmit")){ String realImagePath = Constant.decodeString(request .getParameter("realImagePath")); String tempPath = request.getRealPath("/") + "upload".replace("\\", "/"); String result = ""; File file = new File(tempPath); if(!file.isFile()){ file.mkdirs(); } // new a SmartUpload object SmartUpload su = new SmartUpload(); su.setCharset("UTF-8");// 使用时候最关键的一步 // 上传初始化 su.initialize(this.getServletConfig(),request,response); // 设定上传限制 // 1.限制每个上传文件的最大长度。 su.setMaxFileSize(10000000); // 2.限制总上传数据的长度。 su.setTotalMaxFileSize(20000000); // 3.设定允许上传的文件(通过扩展名限制),仅允许doc,txt文件。 su.setAllowedFilesList("xls,XLS"); boolean sign = true; // 4.设定禁止上传的文件(通过扩展名限制),禁止上传带有exe,bat,jsp,htm,html扩展名的文件和没有扩展名的文件。 try { su.setDeniedFilesList("exe,bat,jsp,htm,html"); // 上传文件 su.upload(); // 将上传文件保存到指定目录 tempPath = tempPath.replace("\\", "/"); tempPath = tempPath + "/"; su.save(tempPath); System.out.println("文件名称"+su.getFiles().getFile(0).getFileName()); tempPath += "\\" + su.getFiles().getFile(0).getFileName(); tempPath = tempPath.replace("\\", "/"); tempPath = tempPath.replace("//", "/"); System.out.println("tempsssssssssssssPath==="+tempPath); Workbook wb; InputStream is2 = new FileInputStream(tempPath); wb = Workbook.getWorkbook(is2); Sheet sheet = wb.getSheet(0); int row = sheet.getRows(); List<Dianbo> DianboList = new ArrayList<Dianbo>(); //// 表结构是:手机号码,当前时间 for(int i = 1;i<row;i++){ Cell firstCell = sheet.getCell(0, i); String firstContent = firstCell.getContents(); Cell secondCell = sheet.getCell(1, i); String secondContent = secondCell.getContents(); if(firstContent.equals("")&&secondContent.equals("")){ break; } Dianbo dianboBean=new Dianbo(); boolean iscunzaitype=new DianboTypeDao().getTypeByName(firstContent); //判断是否存在此点播类型 String Typeid=""; if(iscunzaitype){ DianboType dianboType=new DianboTypeDao().getDianboTypebyName(firstContent); Typeid=dianboType.getTypeId(); }else{//不存在此点播类型时,创建类型,并获取其类型id DianboType dianboType=new DianboType(); dianboType.setTypeName(firstContent); dianboType.setUserId(user.getUserId()); dianboType.setCreateTime(Constant.decodeDate()); Typeid=Constant.getNum(); dianboType.setTypeId(Typeid); boolean addtype=new DianboTypeDao().addDianboType(dianboType); //Typeid=new DianboTypeDao().getMaxtypeid(); } dianboBean.setQsContent(secondContent); dianboBean.setTypeId(Typeid); dianboBean.setQsUpTime(Constant.decodeDate()); dianboBean.setQsUpPhone(""); DianboList.add(dianboBean); } if(DianboList!=null&&DianboList.size()>0){ boolean bo = new DianboDao().saveDianboList(DianboList); if(bo){ result="点播记录导入成功"; }else{ result="点播记录导入失败"; } } } catch (Exception e) { e.printStackTrace(); } List BlackPhoneList=null; request.getSession().setAttribute("selectdianbotype", ""); request.getSession().setAttribute("resultSM", result); //String content=request.getParameter("content"); List dianboList=new DianboDao().getDianboList("tb_qs_info","qsUpTime", ""); request.getSession().setAttribute("dianboList", dianboList); request.getSession().setAttribute("content", ""); response.sendRedirect("hudong/dianboList.jsp?s=1"); }else if(method.equals("addDianboSubmit")){ String typeid=request.getParameter("dianbotypeadd"); String qsContent=request.getParameter("Dianbocontent"); Dianbo dianboBean=new Dianbo(); dianboBean.setTypeId(typeid); dianboBean.setQsContent(qsContent); dianboBean.setQsUpTime(Constant.decodeDate()); dianboBean.setQsUpPhone(""); String result=""; boolean bo = new DianboDao().addDianbo(dianboBean); if(bo){ result="点播记录新增成功"; }else{ result="点播记录新增失败"; } request.getSession().setAttribute("selectdianbotype", ""); request.getSession().setAttribute("resultSM", result); List dianboList=new DianboDao().getDianboList("tb_qs_info","qsUpTime", ""); request.getSession().setAttribute("dianboList", dianboList); request.getSession().setAttribute("content", ""); response.sendRedirect("hudong/dianboList.jsp?s=1"); } } public List<DianboType> getDianboType(TbUserBean user){ String condition="userId = "+user.getUserId(); List<DianboType> dianboTypeList = new ArrayList<DianboType>(); dianboTypeList = new DianboTypeDao().getDianboList("tb_qsType_answer", condition, "createTime"); return dianboTypeList; } /** * The doPost method of the servlet. <br> * * This method is called when a form has its tag value method equals to post. * * @param request the request send by the client to the server * @param response the response send by the server to the client * @throws ServletException if an error occurred * @throws IOException if an error occurred */ public void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { response.setContentType("text/html"); PrintWriter out = response.getWriter(); doGet(request,response); } /** * Initialization of the servlet. <br> * * @throws ServletException if an error occurs */ public void init() throws ServletException { // Put your code here } /** *@author qingyu zhang *@function: *2011-4-4 *下午02:40:37 *zzClub *com.dianbo.servlet */ }
zzprojects
trunk/zzprojects/zzClub/src/com/dianbo/servlet/DianboServlet.java
Java
asf20
14,194
package com.dianbo.servlet; import java.io.IOException; import java.io.PrintWriter; import java.util.ArrayList; import java.util.List; import javax.servlet.ServletException; import javax.servlet.http.HttpServlet; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; import util.AllTypeList; import util.Constant; import util.TotalClass; import util.UtilDAO; import com.UserModule.bean.TbUserBean; import com.dati.bean.DatiType; import com.dianbo.bean.DianboType; import com.dianbo.dao.DianboTypeDao; import com.jifen.bean.JiFen; import com.jifen.dao.JifenDao; public class DianboTypeServlet extends HttpServlet { /** * Constructor of the object. */ public DianboTypeServlet() { super(); } /** * Destruction of the servlet. <br> */ public void destroy() { super.destroy(); // Just puts "destroy" string in log // Put your code here } /** * The doGet method of the servlet. <br> * * This method is called when a form has its tag value method equals to get. * * @param request the request send by the client to the server * @param response the response send by the server to the client * @throws ServletException if an error occurred * @throws IOException if an error occurred */ public void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { response.setContentType("text/html"); PrintWriter out = response.getWriter(); String method=request.getParameter("method"); TbUserBean user = (TbUserBean)request.getSession().getAttribute("User"); if(method.equals("look")){//查询点播的类型 List list = new AllTypeList().getLastValue(user.getUserId()); List<DianboType> dianboTypeList = (ArrayList<DianboType>)list.get(0); StringBuffer sb = (StringBuffer)list.get(1); request.getSession().setAttribute("result", ""); request.getSession().setAttribute("dianboTypeList", dianboTypeList); request.getSession().setAttribute("sb", sb); response.sendRedirect("jifen/jiFenupLoadList.jsp"); }else if(method.equals("addTypeSubmit")){//新增类型 String dianboTypeName = Constant.decodeString(request.getParameter("dianboTypeName")); boolean boo = new DianboTypeDao().getTypeByName(dianboTypeName); if(boo){ request.getSession().setAttribute("result", "此名称已经存在!"); }else { DianboType dianboType=new DianboType(); dianboType.setCreateTime(Constant.decodeDate()); dianboType.setTypeId(TotalClass.getNum()); dianboType.setTypeName(dianboTypeName); dianboType.setUserId(user.getUserId()); boolean bo = new DianboTypeDao().addDianboType(dianboType); if(bo){ request.getSession().setAttribute("result", "点播类型新建成功!"); }else{ request.getSession().setAttribute("result", "点播类型新建失败!"); } } List list = new AllTypeList().getLastValue(user.getUserId()); List<DianboType> dianboTypeList = (ArrayList<DianboType>)list.get(0); StringBuffer sb = (StringBuffer)list.get(1); request.getSession().setAttribute("dianboTypeList", dianboTypeList); request.getSession().setAttribute("sb", sb); response.sendRedirect("jifen/jiFenupLoadList.jsp"); }else if(method.equals("modifyType")){//显示要修改的点播类型 String dianboId = request.getParameter("dianboId"); String condition=" typeId = '"+dianboId+"' "; List<DianboType> dianboTypeList = new DianboTypeDao().getDianboList("tb_qsType_answer", condition, "createTime"); DianboType dianboType = new DianboType(); if(dianboTypeList!=null&&dianboTypeList.size()>0){ dianboType = dianboTypeList.get(0); } request.getSession().setAttribute("dianboType", dianboType); response.sendRedirect("jifen/modifyDianboType.jsp"); }else if(method.equals("modifyTypeSubmit")){//修改点播类型提交 String dianboTypeId = request.getParameter("dianboTypeId"); String dianboTypeName = Constant.decodeString(request.getParameter("dianboTypeName")); DianboType dianboType = new DianboType(); dianboType.setCreateTime(Constant.decodeDate()); dianboType.setTypeId(dianboTypeId); dianboType.setTypeName(dianboTypeName); boolean bo = new DianboTypeDao().modifyDianboType(dianboType); if(bo){ request.getSession().setAttribute("result", "点播类型修改成功!"); }else{ request.getSession().setAttribute("result", "点播类型修改失败!"); } List list = new AllTypeList().getLastValue(user.getUserId()); List<DianboType> dianboTypeList = (ArrayList<DianboType>)list.get(0); StringBuffer sb = (StringBuffer)list.get(1); request.getSession().setAttribute("dianboTypeList", dianboTypeList); request.getSession().setAttribute("sb", sb); response.sendRedirect("jifen/jiFenupLoadList.jsp"); }else if(method.equals("del")){ String dianboTypeId = request.getParameter("dianboTypeId"); boolean bo = UtilDAO.del("tb_integral", "typeId", dianboTypeId); boolean boo =false; if(bo){ boo = UtilDAO.del("tb_qsType_answer", "typeId", dianboTypeId); } List list = new AllTypeList().getLastValue(user.getUserId()); List<DianboType> dianboTypeList = (ArrayList<DianboType>)list.get(0); StringBuffer sb = (StringBuffer)list.get(1); if(boo){ request.getSession().setAttribute("result", "点播类型删除成功!"); }else{ request.getSession().setAttribute("result", "点播类型删除失败!"); } request.getSession().setAttribute("dianboTypeList", dianboTypeList); request.getSession().setAttribute("sb", sb); response.sendRedirect("jifen/jiFenupLoadList.jsp"); }else if(method.equals("lookDown")){//点播下行类型的积分查询 List list = new AllTypeList().getDownValue(user.getUserId()); List<DianboType> dianboTypeList = (ArrayList<DianboType>)list.get(0); List<DatiType> datiTypeList = (ArrayList<DatiType>)list.get(1); request.getSession().setAttribute("result", ""); request.getSession().setAttribute("dianboTypeList", dianboTypeList); request.getSession().setAttribute("datiTypeList", datiTypeList); response.sendRedirect("jifen/jiFendownList.jsp"); }else if("getValueByTypeId".equals(method)){//根据点播类型的ID得到此类型的分数 String typeId = request.getParameter("typeId"); System.out.println("typeId=="+typeId); String condition="typeId='"+typeId+"' and integralType=0";//得到此点播类型上行的分数 JiFen jifen = new JifenDao().getJiFen("tb_integral", "setTime", condition); String fenshu = ""; if(jifen==null){ fenshu="0"; }else fenshu = jifen.getIntegralValue(); out.println(fenshu); } } /** * *@author qingyu zhang *@function:根据登录用户得到其下的所有答题类型 * @param userId * @return *2011-4-7 *上午09:26:14 *zzClub *com.dianbo.servlet *StringBuffer */ /** * The doPost method of the servlet. <br> * * This method is called when a form has its tag value method equals to post. * * @param request the request send by the client to the server * @param response the response send by the server to the client * @throws ServletException if an error occurred * @throws IOException if an error occurred */ public void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { response.setContentType("text/html"); PrintWriter out = response.getWriter(); doGet(request,response); } /** * Initialization of the servlet. <br> * * @throws ServletException if an error occurs */ public void init() throws ServletException { // Put your code here } /** *@author qingyu zhang *@function: *2011-4-4 *下午02:41:03 *zzClub *com.dianbo.servlet */ }
zzprojects
trunk/zzprojects/zzClub/src/com/dianbo/servlet/DianboTypeServlet.java
Java
asf20
8,015
package com.dianbo.dao; import java.sql.Connection; import java.sql.PreparedStatement; import java.sql.ResultSet; import java.sql.SQLException; import java.sql.Statement; import java.util.ArrayList; import java.util.List; import util.ConnectDB; import util.TotalClass; import util.UtilDAO; import com.BlackPhoneModule.bean.BlackPhoneBean; import com.dianbo.bean.Dianbo; public class DianboDao { /** *@author qingyu zhang *@function: *2011-4-4 *下午02:42:34 *zzClub *com.dianbo.dao */ private ResultSet rs =null; private String sql = ""; private List<Dianbo> dianboList = null; // 数据库连接 private Connection conn = null; // st对象 private PreparedStatement pt = null; private Statement st = null; /** * *@author qingyu zhang *@function: * @param table * @param order * @param condition * @return *2011-4-12 *下午09:42:53 *zzClub *com.dianbo.dao *List<Dianbo> */ public List<Dianbo> getDianboList(String table,String order,String condition){ sql = UtilDAO.getList(table, order, condition); rs = new TotalClass().getResult(sql); System.out.println("sql||"+sql); try { while(rs.next()){ if(dianboList==null){ dianboList = new ArrayList<Dianbo>(); } dianboList.add(this.getDianbo(rs)); } } catch (SQLException e) { // TODO Auto-generated catch block e.printStackTrace(); } return dianboList; } public Dianbo getDianbo(ResultSet rs){ Dianbo dianbo = new Dianbo(); try { dianbo.setQsContent(rs.getString("qsContent")); dianbo.setQsInfoId(rs.getInt("qsInfoId")); dianbo.setQsIntegral(rs.getString("qsIntegral")); dianbo.setQsUpPhone(rs.getString("qsUpPhone")); dianbo.setQsUpTime(rs.getString("qsUpTime")); dianbo.setReceiveId(rs.getInt("receiveId")); dianbo.setTypeId(rs.getString("typeId")); } catch (SQLException e) { // TODO Auto-generated catch block e.printStackTrace(); } return dianbo; } public boolean modifyState(String dianboId){ boolean bo = false; String hql = "update tb_send_dianbo set state=1 where dianboId in("+dianboId+")"; bo = new TotalClass().operatorObject(hql); return bo; } /** * *@author qingyu zhang *@function:分拣时存放点播 * @param dianbo * @return *2011-4-13 *上午08:40:05 *zzClub *com.dianbo.dao *boolean */ public boolean addDianbo(Dianbo dianbo){ boolean bo = false; sql="insert into tb_qs_info(receiveId,typeId,qsContent,qsUpPhone,qsUpTime) " + "values("+dianbo.getReceiveId()+",'"+dianbo.getTypeId()+"','"+dianbo.getQsContent()+"','"+dianbo.getQsUpPhone()+"','"+dianbo.getQsUpTime()+"')"; System.out.println("sql:||insert|||"+sql); bo = new TotalClass().operatorObject(sql); return bo; } public boolean saveDianboList(List<Dianbo> dianboList){ boolean bo = false; try { conn = ConnectDB.getSqlServerConnection(); st = conn.createStatement(); if(dianboList!=null&&dianboList.size()>0){ for(Dianbo dianbo:dianboList){ String hql ="insert into tb_qs_info(receiveId,typeId,qsContent,qsUpPhone,qsUpTime) " + "values("+dianbo.getReceiveId()+",'"+dianbo.getTypeId()+"','"+dianbo.getQsContent()+"','"+dianbo.getQsUpPhone()+"','"+dianbo.getQsUpTime()+"')"; System.out.println("hql==="+hql); st.addBatch(hql); } st.executeBatch(); bo = true; } }catch(Exception e){ e.printStackTrace(); bo = false; }finally{ ConnectDB.closeSqlConnection(); return bo ; } } /** * 单条记录删除 * jhc * 2011-1-27 下午02:30:38 */ public boolean del(String tableName,String keyId,String idList){ boolean bo = UtilDAO.del(tableName, keyId, idList); return bo ; } /** * 多项删除 * jhc * 2011-1-27 下午02:30:38 */ public boolean delin(String tableName,String keyId,String idList){ boolean bo = UtilDAO.delin(tableName, keyId, idList); return bo ; } }
zzprojects
trunk/zzprojects/zzClub/src/com/dianbo/dao/DianboDao.java
Java
asf20
4,028
package com.dianbo.dao; import java.sql.ResultSet; import java.sql.SQLException; import java.util.ArrayList; import java.util.List; import util.TotalClass; import util.UtilDAO; import com.dianbo.bean.DianboType; import com.jifen.bean.JiFen; import com.jifen.dao.JifenDao; public class DianboTypeDao { /** * *@author qingyu zhang *@function:根据条件查询点播类型 * @param table * @param condition * @param order * @return *2011-4-5 *上午07:54:10 *zzClub *com.dianbo.dao *List<DianboType> */ // 要执行的语句 private String sql = ""; private DianboType dianboType=null; private List<DianboType> dianboTypeList = null; private ResultSet rs = null; /** * *@author qingyu zhang *@function:add a dianboType * @param dianboType * @return *2011-4-5 *下午03:55:43 *zzClub *com.dianbo.dao *boolean */ public boolean addDianboType(DianboType dianboType){ boolean bo = false; sql="insert into tb_qsType_answer (typeId,userId,typeName,createTime) " + "values('"+dianboType.getTypeId()+"',"+dianboType.getUserId()+",'"+dianboType.getTypeName()+"','"+dianboType.getCreateTime()+"')"; bo = new TotalClass().operatorObject(sql); return bo ; } /** * *@author qingyu zhang *@function:modify a DianboType * @param dianboType * @return *2011-4-5 *下午04:05:11 *zzClub *com.dianbo.dao *boolean */ public boolean modifyDianboType(DianboType dianboType){ boolean bo = false; sql="update tb_qsType_answer set typeName='"+dianboType.getTypeName()+"',createTime='"+dianboType.getCreateTime()+"' where typeId='"+dianboType.getTypeId()+"'"; System.out.println("修改系列"+sql); bo = new TotalClass().operatorObject(sql); return bo; } public List<DianboType> getDianboList(String table,String condition,String order){ sql= UtilDAO.getList(table, order, condition); System.out.println("sql语句="+sql); ResultSet rs = new TotalClass().getResult(sql); try { while(rs.next()){ DianboType dianbo = getDianboType(rs); if(dianboTypeList==null){ dianboTypeList = new ArrayList<DianboType>(); } dianboTypeList.add(dianbo); } } catch (SQLException e) { // TODO Auto-generated catch block e.printStackTrace(); } return dianboTypeList; } public DianboType getDianboType(ResultSet rs){ DianboType dbType=new DianboType(); try { dbType.setCreateTime(rs.getString("createTime")); dbType.setTypeId(rs.getString("typeId")); dbType.setTypeName(rs.getString("typeName")); dbType.setUserId(rs.getInt("userId")); } catch (SQLException e) { // TODO Auto-generated catch block e.printStackTrace(); } return dbType; } /*public static Object getObj(ResultSet rs){ Object obj = new Object(); try { ResultSetMetaData rsd= rs.getMetaData(); int colNum = rsd.getColumnCount();//得到表中的列数 if(colNum>0){ for(int i = 1;i<colNum;i++){ String colName = rsd.getColumnName(i); int colType = rsd.getColumnType(i); String colTypeName = ""; if(colType==12){//String colTypeName="String"; rs.getString(colName); }else if(colType==4){//int colTypeName="int"; rs.getInt(colName); }else if(colType==2004){//blob rs.getBlob(colName); }else if(colType==16){//boolean rs.getBoolean(colName); }else if(colType==2005){//clob rs.getClob(colName); }else if(colType==91){//date rs.getDate(colName); }else if(colType==8){//double rs.getDouble(colName); }else if(colType==6){//float rs.getFloat(colName); }else if(colType==93){//TIMESTAMP rs.getTimestamp(colName); }else if(colType==92){//time rs.getTime(colName); } } } } catch (SQLException e) { // TODO Auto-generated catch block e.printStackTrace(); } return rs; }*/ /** * 验证此名称是否存在 */ public boolean getTypeByName(String typeName){ boolean bo = false; sql="select * from tb_qsType_answer where typeName ='"+typeName+"'"; System.out.println("sql==="+sql); rs = new TotalClass().getResult(sql); try { if(rs.next()){ bo = true; } } catch (SQLException e) { // TODO Auto-generated catch block e.printStackTrace(); } return bo; } public String getMaxtypeid(){ String maxTypeid=""; sql="select top 1 * from tb_qsType_answer order by createTime desc"; rs=new TotalClass().getResult(sql); try{ if(rs.next()){ maxTypeid=rs.getString(0); System.out.println("maxTypeid:"+maxTypeid); } }catch(SQLException ex){ ex.printStackTrace(); } return maxTypeid; } /** * *@author qingyu zhang *@function:根据主键ID得到单个对象 * @param typeId * @return *2011-4-11 *下午08:43:27 *zzClub *com.dianbo.dao *DianboType */ public DianboType getDianboType(String typeId){ DianboType dianboType = null; sql = "select * from tb_qsType_answer where typeId='"+typeId+"'"; System.out.println("sql==="+sql); rs = new TotalClass().getResult(sql); try { while(rs.next()){ if(dianboType==null){ dianboType = new DianboType(); } dianboType = this.getDianboType(rs); } } catch (SQLException e) { // TODO Auto-generated catch block e.printStackTrace(); } return dianboType; } public DianboType getDianboTypebyName(String typeName){ DianboType dianboType = null; sql = "select * from tb_qsType_answer where typeName='"+typeName+"'"; System.out.println("sql==="+sql); rs = new TotalClass().getResult(sql); try { while(rs.next()){ if(dianboType==null){ dianboType = new DianboType(); } dianboType = this.getDianboType(rs); } } catch (SQLException e) { // TODO Auto-generated catch block e.printStackTrace(); } return dianboType; } public static void main(String args[]){ List<DianboType> dianbaoList =new DianboTypeDao().getDianboList("tb_qsType_answer","", "createTIme"); for(DianboType dbtype:dianbaoList){ System.out.println("name=="+dbtype.getTypeName()); } } }
zzprojects
trunk/zzprojects/zzClub/src/com/dianbo/dao/DianboTypeDao.java
Java
asf20
6,271
package com.order.bean; public class TbWuxiaoOrder { /** *@author qingyu zhang *@function: *2011-4-12 *上午08:17:08 *zzClub *com.order.bean */ private int invalidId; private int userId; private String invalidContent; private int status; public int getStatus() { return status; } public void setStatus(int status) { this.status = status; } public int getInvalidId() { return invalidId; } public void setInvalidId(int invalidId) { this.invalidId = invalidId; } public int getUserId() { return userId; } public void setUserId(int userId) { this.userId = userId; } public String getInvalidContent() { return invalidContent; } public void setInvalidContent(String invalidContent) { this.invalidContent = invalidContent; } }
zzprojects
trunk/zzprojects/zzClub/src/com/order/bean/TbWuxiaoOrder.java
Java
asf20
815
package com.order.bean; import java.io.Serializable; public class TbOrder implements Serializable{ /** *@author qingyu zhang *@function: *2011-4-11 *下午04:40:14 *zzClub *com.order.bean */ private int orderId; private int userId; //private String orderName; private String typeId; private String orderValue; private String createTime; private int orderType;//标识点播或答题 public int getOrderId() { return orderId; } public void setOrderId(int orderId) { this.orderId = orderId; } public int getUserId() { return userId; } public void setUserId(int userId) { this.userId = userId; } public String getOrderValue() { return orderValue; } public void setOrderValue(String orderValue) { this.orderValue = orderValue; } public String getCreateTime() { return createTime; } public void setCreateTime(String createTime) { this.createTime = createTime; } public int getOrderType() { return orderType; } public void setOrderType(int orderType) { this.orderType = orderType; } public String getTypeId() { return typeId; } public void setTypeId(String typeId) { this.typeId = typeId; } }
zzprojects
trunk/zzprojects/zzClub/src/com/order/bean/TbOrder.java
Java
asf20
1,221
package com.order.servlet; import java.io.IOException; import java.io.PrintWriter; import java.util.ArrayList; import java.util.List; import java.util.Random; import javax.servlet.ServletException; import javax.servlet.http.HttpServlet; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; import util.Constant; import com.UserModule.bean.TbUserBean; import com.dati.bean.DatiType; import com.dati.dao.DatiTypeDao; import com.dianbo.bean.DianboType; import com.dianbo.dao.DianboTypeDao; import com.order.bean.TbOrder; import com.order.bean.TbWuxiaoOrder; import com.order.dao.TbOrderDao; public class TbOrderServlet extends HttpServlet { /** * Constructor of the object. */ public TbOrderServlet() { super(); } /** * Destruction of the servlet. <br> */ public void destroy() { super.destroy(); // Just puts "destroy" string in log // Put your code here } /** * The doGet method of the servlet. <br> * * This method is called when a form has its tag value method equals to get. * * @param request the request send by the client to the server * @param response the response send by the server to the client * @throws ServletException if an error occurred * @throws IOException if an error occurred */ public void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { response.setContentType("text/html"); PrintWriter out = response.getWriter(); String method=request.getParameter("method"); TbUserBean user = (TbUserBean)request.getSession().getAttribute("User"); if("look".equals(method)){//显示指令 List list = this.getValue(user); List<TbOrder> orderDianboList = (ArrayList<TbOrder>)list.get(0); List<TbOrder> orderDatiList = (ArrayList<TbOrder>)list.get(1); request.getSession().setAttribute("orderDianboList", orderDianboList); request.getSession().setAttribute("orderDatiList", orderDatiList); request.getSession().setAttribute("result", ""); response.sendRedirect("hudong/orderList.jsp"); }else if("addOrder".equals(method)){//新建指令时的显示 String formName = request.getParameter("formName"); String orderType = request.getParameter("orderType");//点播或答题 String condition="userId="+user.getUserId()+" and orderType=0"; List<TbOrder> orderDianboList = new ArrayList<TbOrder>(); orderDianboList = new TbOrderDao().getOrderList("tb_order", "createTime", condition); String conditionT="userId="+user.getUserId()+" and orderType=1"; List<TbOrder> orderDatiList = new ArrayList<TbOrder>(); orderDatiList = new TbOrderDao().getOrderList("tb_order", "createTime", conditionT); List<String> orderTypeList = new ArrayList<String>();//存放已设置指令对应的点播或答题的ID if(orderDianboList!=null&&orderDianboList.size()>0){ for(TbOrder orde:orderDianboList){ if(!orderTypeList.contains(orde.getTypeId())){ orderTypeList.add(orde.getTypeId()); } } } if(orderDatiList!=null&&orderDatiList.size()>0){ for(TbOrder orde:orderDatiList){ if(!orderTypeList.contains(orde.getTypeId())){ orderTypeList.add(orde.getTypeId()); } } } List<DatiType> datiTypeList = new ArrayList<DatiType>(); String conditionDati = "userId="+user.getUserId(); datiTypeList = new DatiTypeDao().getAllDaTiType("tb_answer_type", "createTime", conditionDati); List<DianboType> dianboTypeList = new ArrayList<DianboType>(); dianboTypeList = new DianboTypeDao().getDianboList("tb_qsType_answer", conditionDati, "createTime"); List<DianboType> lastDianboTypeList = new ArrayList<DianboType>();//能进行设置指令的点播类型 List<DatiType> lastDatiTypeList = new ArrayList<DatiType>(); if(datiTypeList!=null&&datiTypeList.size()>0){ for(DatiType dati:datiTypeList){ if(!orderTypeList.contains(dati.getAnswerTypeId())){ lastDatiTypeList.add(dati); } } } if(dianboTypeList!=null&&dianboTypeList.size()>0){ for(DianboType dianbo:dianboTypeList){ if(!orderTypeList.contains(dianbo.getTypeId())){ lastDianboTypeList.add(dianbo); } } } request.getSession().setAttribute("lastDianboTypeList", lastDianboTypeList); request.getSession().setAttribute("lastDatiTypeList", lastDatiTypeList); response.sendRedirect("hudong/addOrder.jsp?orderType="+orderType+"&num="+new Random().nextInt(1000000)+"&formName="+formName); }else if("addOrderSubmit".equals(method)){//新增指令提交 String orderType = request.getParameter("orderType");//区分是点播或答题 String orderName = request.getParameter("orderName"); String typeId = request.getParameter("typeId"); TbOrder order = new TbOrder(); order.setCreateTime(Constant.decodeDate()); order.setOrderType(Integer.parseInt(orderType)); order.setOrderValue(orderName); order.setTypeId(typeId); order.setUserId(user.getUserId()); boolean bo = new TbOrderDao().saveOrder(order); if(bo){ request.getSession().setAttribute("result", "指令设置成功!"); }else{ request.getSession().setAttribute("result", "指令设置失败!"); } List list = this.getValue(user); List<TbOrder> orderDianboList = (ArrayList<TbOrder>)list.get(0); List<TbOrder> orderDatiList = (ArrayList<TbOrder>)list.get(1); request.getSession().setAttribute("orderDianboList", orderDianboList); request.getSession().setAttribute("orderDatiList", orderDatiList); response.sendRedirect("hudong/orderList.jsp"); }else if("modifyOrder".equals(method)){//修改显示 String orderId = request.getParameter("id"); String condition = "orderId="+orderId; String formName = request.getParameter("formName"); List<TbOrder> order = new TbOrderDao().getOrderList("tb_order", "createTime", condition); TbOrder tbOrder = order.get(0); request.getSession().setAttribute("tbOrder", tbOrder); response.sendRedirect("hudong/modifyOrder.jsp?formName="+formName+"&num="+new Random().nextInt(10000000)); }else if("modifyOrderSubmit".equals(method)){//修改提交 System.out.println("修改提交"); String id = request.getParameter("id"); String orderName = Constant.decodeString(request.getParameter("orderName")); System.out.println("orderName=="+orderName); TbOrder order = new TbOrder(); order.setCreateTime(Constant.decodeDate()); order.setOrderValue(orderName); order.setOrderId(Integer.parseInt(id)); boolean bo = new TbOrderDao().modifyOrder(order); if(bo){ request.getSession().setAttribute("result", "指令修改成功!"); }else{ request.getSession().setAttribute("result", "指令修改失败!"); } List list = this.getValue(user); List<TbOrder> orderDianboList = (ArrayList<TbOrder>)list.get(0); List<TbOrder> orderDatiList = (ArrayList<TbOrder>)list.get(1); request.getSession().setAttribute("orderDianboList", orderDianboList); request.getSession().setAttribute("orderDatiList", orderDatiList); response.sendRedirect("hudong/orderList.jsp"); }else if("del".equals(method)){ String id = request.getParameter("id"); boolean bo = new TbOrderDao().deleteOrder(Integer.parseInt(id)); if(bo){ request.getSession().setAttribute("result", "指令删除成功!"); }else{ request.getSession().setAttribute("result", "指令删除失败!"); } List list = this.getValue(user); List<TbOrder> orderDianboList = (ArrayList<TbOrder>)list.get(0); List<TbOrder> orderDatiList = (ArrayList<TbOrder>)list.get(1); request.getSession().setAttribute("orderDianboList", orderDianboList); request.getSession().setAttribute("orderDatiList", orderDatiList); response.sendRedirect("hudong/orderList.jsp"); }else if("lookWuxiao".equals(method)){//设置无效指令 String condition="userId="+user.getUserId(); List<TbWuxiaoOrder> wuxiaoList =new ArrayList<TbWuxiaoOrder>(); wuxiaoList = new TbOrderDao().getWuxiaoList("tb_invalid", "", condition); request.getSession().setAttribute("wuxiaoList", wuxiaoList); request.getSession().setAttribute("result", ""); response.sendRedirect("hudong/setWuxiao.jsp"); }else if("setWuxiao".equals(method)){//设置无效指令提交 String wuxiao = Constant.decodeString(request.getParameter("wuxiao")); int isreply=Integer.parseInt(request.getParameter("isreply")); TbWuxiaoOrder wuxiaoOrder = new TbWuxiaoOrder(); wuxiaoOrder.setInvalidContent(wuxiao); wuxiaoOrder.setUserId(user.getUserId()); wuxiaoOrder.setStatus(isreply); boolean bo = new TbOrderDao().saveWuxiao(wuxiaoOrder); if(bo){ request.getSession().setAttribute("result", "设置成功!"); }else { request.getSession().setAttribute("result", "设置失败!"); } String condition="userId="+user.getUserId(); List<TbWuxiaoOrder> wuxiaoList =new ArrayList<TbWuxiaoOrder>(); wuxiaoList = new TbOrderDao().getWuxiaoList("tb_invalid", "", condition); request.getSession().setAttribute("wuxiaoList", wuxiaoList); response.sendRedirect("hudong/setWuxiao.jsp"); } } public List getValue(TbUserBean user){ List list = new ArrayList(); String condition="userId="+user.getUserId()+" and orderType=0"; List<TbOrder> orderDianboList = new ArrayList<TbOrder>(); orderDianboList = new TbOrderDao().getOrderList("tb_order", "createTime", condition); String conditionT="userId="+user.getUserId()+" and orderType=1"; List<TbOrder> orderDatiList = new ArrayList<TbOrder>(); orderDatiList = new TbOrderDao().getOrderList("tb_order", "createTime", conditionT); list.add(orderDianboList); list.add(orderDatiList); return list; } /** * The doPost method of the servlet. <br> * * This method is called when a form has its tag value method equals to post. * * @param request the request send by the client to the server * @param response the response send by the server to the client * @throws ServletException if an error occurred * @throws IOException if an error occurred */ public void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { response.setContentType("text/html"); PrintWriter out = response.getWriter(); doGet(request,response); } /** * Initialization of the servlet. <br> * * @throws ServletException if an error occurs */ public void init() throws ServletException { // Put your code here } /** *@author qingyu zhang *@function: *2011-4-11 *下午04:42:14 *zzClub *com.order.servlet */ }
zzprojects
trunk/zzprojects/zzClub/src/com/order/servlet/TbOrderServlet.java
Java
asf20
10,797
package com.order.dao; import java.sql.ResultSet; import java.sql.SQLException; import java.sql.Statement; import java.util.ArrayList; import java.util.List; import util.TotalClass; import util.UtilDAO; import com.dianbo.bean.DianboType; import com.order.bean.TbOrder; import com.order.bean.TbWuxiaoOrder; public class TbOrderDao { /** *@author qingyu zhang *@function: *2011-4-11 *下午04:42:40 *zzClub *com.order.dao */ private String sql = ""; private DianboType dianboType=null; private ResultSet rs = null; private List<TbOrder> orderList = null; private Statement st = null; /** * *@author qingyu zhang *@function:根据条件得到相应的指令记录 * @param table * @param order * @param condition * @return *2011-4-11 *下午04:47:14 *zzClub *com.order.dao *List<TbOrder> */ public List<TbOrder> getOrderList(String table,String order,String condition){ sql=UtilDAO.getList(table, order, condition); rs = new TotalClass().getResult(sql); try { while(rs.next()){ if(orderList==null){ orderList = new ArrayList<TbOrder>(); } orderList.add(this.getOrder(rs)); } } catch (SQLException e) { // TODO Auto-generated catch block e.printStackTrace(); } return orderList; } public TbOrder getOrder(ResultSet rs){ TbOrder tbOrder = new TbOrder(); try { tbOrder.setCreateTime(rs.getString("createTime")); tbOrder.setOrderId(rs.getInt("orderId")); tbOrder.setTypeId(rs.getString("typeId")); tbOrder.setOrderType(rs.getInt("orderType")); tbOrder.setOrderValue(rs.getString("orderValue")); tbOrder.setUserId(rs.getInt("userId")); } catch (SQLException e) { // TODO Auto-generated catch block e.printStackTrace(); } return tbOrder; } /** * *@author qingyu zhang *@function:新增一指令 * @param order * @return *2011-4-11 *下午10:33:02 *zzClub *com.order.dao *boolean */ public boolean saveOrder(TbOrder order){ boolean bo = false; sql="insert into tb_order(userId,typeId,orderValue,createTime,orderType)" + " values("+order.getUserId()+",'"+order.getTypeId()+"','"+order.getOrderValue()+"','"+order.getCreateTime()+"',"+order.getOrderType()+")"; bo = new TotalClass().operatorObject(sql); return bo; } /** * *@author qingyu zhang *@function:修改单个指令 * @param order * @return *2011-4-11 *下午10:54:31 *zzClub *com.order.dao *boolean */ public boolean modifyOrder(TbOrder order){ boolean bo = false; sql="update tb_order set orderValue='"+order.getOrderValue()+"',createTime='"+order.getCreateTime()+"' where orderId="+order.getOrderId(); bo = new TotalClass().operatorObject(sql); return bo; } /** * *@author qingyu zhang *@function:根据指令ID删除单个对象 * @param orderId * @return *2011-4-11 *下午10:58:44 *zzClub *com.order.dao *boolean */ public boolean deleteOrder(int orderId){ boolean bo = false; sql="delete tb_order where orderId="+orderId; bo = new TotalClass().operatorObject(sql); return bo; } /** * *@author qingyu zhang *@function: * @param table * @param order * @param condition * @return *2011-4-12 *上午08:19:50 *zzClub *com.order.dao *List<TbWuxiaoOrder> */ public List<TbWuxiaoOrder> getWuxiaoList(String table,String order,String condition){ List<TbWuxiaoOrder> wuxiaoList = null; sql=UtilDAO.getList(table, order, condition); rs = new TotalClass().getResult(sql); try { while(rs.next()){ if(wuxiaoList==null){ wuxiaoList = new ArrayList<TbWuxiaoOrder>(); } wuxiaoList.add(this.getWuxiao(rs)); } } catch (SQLException e) { // TODO Auto-generated catch block e.printStackTrace(); } return wuxiaoList; } public TbWuxiaoOrder getWuxiao(ResultSet rs){ TbWuxiaoOrder wuxiao = new TbWuxiaoOrder(); try { wuxiao.setInvalidContent(rs.getString("invalidContent")); wuxiao.setInvalidId(rs.getInt("invalidId")); wuxiao.setUserId(rs.getInt("userId")); wuxiao.setStatus(rs.getInt("status")); } catch (SQLException e) { // TODO Auto-generated catch block e.printStackTrace(); } return wuxiao; } public boolean saveWuxiao(TbWuxiaoOrder wuxiao){ boolean bo = false; boolean boo = this.getWuxiao(wuxiao.getUserId()); if(boo){ sql = "update tb_invalid set invalidContent='"+wuxiao.getInvalidContent()+"',status="+wuxiao.getStatus()+" where userId="+wuxiao.getUserId(); }else{ sql="insert into tb_invalid (userId,invalidContent,status) values("+wuxiao.getUserId()+",'"+wuxiao.getInvalidContent()+"',"+wuxiao.getStatus()+")"; } bo = new TotalClass().operatorObject(sql); return bo ; } public boolean getWuxiao(int userId){ boolean bo = false; sql = "select count(*) cnt from tb_invalid where userId="+userId; rs = new TotalClass().getResult(sql); try { while(rs.next()){ int num = rs.getInt("cnt"); if(num>0){ bo = true; } } } catch (SQLException e) { // TODO Auto-generated catch block e.printStackTrace(); } return bo ; } }
zzprojects
trunk/zzprojects/zzClub/src/com/order/dao/TbOrderDao.java
Java
asf20
5,276
package gonggong; import java.sql.SQLException; import java.sql.Statement; import java.text.ParseException; import java.text.SimpleDateFormat; import java.util.ArrayList; import java.util.Date; import java.util.List; import java.util.Random; import util.Constant; import util.TotalClass; import com.SmsModule.bean.TbSmsSend; import com.SmsModule.dao.TbSmsSendDAO; import com.dati.bean.Daan; import com.dati.bean.DatiMiddle; import com.dati.bean.SendDati; import com.dati.dao.DatiDao; import com.jifen.bean.JiFen; import com.jifen.dao.JifenDao; public class ScanSendDatiDao { private Statement st = null; private String sql = ""; /** *@author qingyu zhang *@function: *2011-4-13 *下午02:46:16 *zzClub *gonggong */ public void operator(){ getSendDati(); } /** * *@author qingyu zhang *@function:得到所有状态为1的即已发送但是没有验证答案的记录 * @return *2011-4-13 *下午02:49:40 *zzClub *gonggong *List<SendDati> */ public void getSendDati(){ String condition="state=1"; List<SendDati> sendDatiList = new DatiDao().getSendDati("sendDati", "", condition); if(sendDatiList!=null&&sendDatiList.size()>0){ for(SendDati sendDati:sendDatiList){ List<TbSmsSend> smsSendList = new ArrayList<TbSmsSend>(); TbSmsSend smsSend = new TbSmsSend(); SimpleDateFormat format=new SimpleDateFormat("yyyy-MM-dd HH:mm"); String timuId = sendDati.getAnswerMiddleId(); String phone = sendDati.getPhone(); String seriseId = sendDati.getSeriseId(); String conditionTimu="answerMiddleId='"+timuId+"'"; List<DatiMiddle> datiMiddleList = new DatiDao().getDatiMiddle("tb_answer_middle", "", conditionTimu); String rightAnswer = datiMiddleList.get(0).getRightAnswer();//得到此题目的正确答案 try { Date nowDate = format.parse(Constant.decodeDateTT()); Date endDate = format.parse(sendDati.getEndTime()); String daanCondition="phone='"+phone+"' and timuId='"+timuId+"' and state=0"; List<Daan> daanList = new DatiDao().getDaanList("tb_daan", daanCondition, ""); JiFen jifen = this.getJifen(seriseId, 1); String jifenValue = "0"; if(jifen!=null){ jifenValue=jifen.getIntegralValue();//得到此系列的积分 } int totalNum = getSendDatiTotal(seriseId,phone,sendDati.getCreateTime(),sendDati.getEndTime()); if(nowDate.after(endDate)){//时间过期,则把此系列中所有标识为0或1 的修改成2 //修改此系列中其他没有发送的信息的状态并得到总条数 List<SendDati> lst = getSendDatiList(seriseId,phone,sendDati.getCreateTime(),sendDati.getEndTime()); int askNum = 0; if(lst!=null&&lst.size()>0){ askNum=lst.size(); } System.out.println("总数"+totalNum); System.out.println("正确"+askNum); String content = "你在规定的时间内没有回答完此系列答题,此系列有"+totalNum+"道题,回答"+askNum+"题."; String rightJifen ="0"; if(daanList!=null&&daanList.size()>0)//回答正确 { boolean ben = new GetJifen().modifyDaan(timuId, phone);//修改表中tb_daan中的状态 boolean bo = daanList.get(0).getDaAn().equals(rightAnswer); if(bo){ modifySendDati(sendDati.getId(),0);//成功 content+="此题回答正确."; rightJifen = new GetJifen().getJiFen(jifenValue, totalNum,askNum+1); if(rightJifen.equals("0")){ rightJifen="1"; } }else{ modifySendDati(sendDati.getId(),1);//失败 content+="此题回答错误,正确答案:"+rightAnswer; rightJifen = new GetJifen().getJiFen(jifenValue, totalNum,askNum); if(rightJifen.equals("0")){ rightJifen="1"; } } //修改表tb_daan中的状态 }else{ modifySendDati(sendDati.getId(),1);//失败 content+="此题没有回答."; rightJifen = new GetJifen().getJiFen(jifenValue, totalNum+askNum,askNum); if(rightJifen.equals("0")){ rightJifen="1"; } } content+="此次积分是:"+rightJifen+"分"; smsSend.setCreateTime(Constant.decodeDate()); smsSend.setDestAdd(phone); smsSend.setIsSendTime(0); smsSend.setSendTime(Constant.decodeDate()); smsSend.setSeriseId(seriseId+timuId); smsSend.setSmsContent(content); smsSend.setSmsSendState(0); smsSend.setUserId(0); smsSendList.add(smsSend); boolean bol = new TbSmsSendDAO().addSmsList(smsSendList);//发送短信 if(bol){ boolean bool = new GetJifen().saveJifenToCustomer(phone, rightJifen);//存放积分 } System.out.println("过期content==="+content); }else{//时间不过期 String content = "此系列有"+totalNum+"题"; if(daanList!=null&&daanList.size()>0)//回答记录中存在此题目 { boolean ben = new GetJifen().modifyDaan(timuId, phone);//修改表中tb_daan中的状态 boolean bo = daanList.get(0).getDaAn().equals(rightAnswer); if(bo){ modifySendDati(sendDati.getId(),0);//成功 content+="此题回答正确."; }else{ modifySendDati(sendDati.getId(),1);//失败 content+="此题回答错误,正确答案:"+rightAnswer; } //从没有发送的系列题目中选取下一信息发送 List<SendDati> sendDatiLst = new GetJifen().getSendDati(seriseId, phone, sendDati.getEndTime(), 0, ""); List<SendDati> sendDatiLstOk = new GetJifen().getSendDati(seriseId, phone, sendDati.getEndTime(), 2, "0");//已经发送成功的 int okNum =0; if(sendDatiLstOk!=null&&sendDatiLstOk.size()>0){ okNum=sendDatiLstOk.size(); } if(sendDatiLst!=null&&sendDatiLst.size()>0){//此系列中存在其他答题 int num = new Random().nextInt(sendDatiLst.size()); SendDati sendDt = sendDatiLst.get(num); String conditionTimuT="answerMiddleId='"+sendDt.getAnswerMiddleId()+"'"; List<DatiMiddle> datiMiddleLst = new DatiDao().getDatiMiddle("tb_answer_middle", "", conditionTimuT); content+="下题:"+datiMiddleLst.get(0).getAnswerContent(); //修改此题目的状态为1 boolean ble = modifySendDati(sendDt.getId()); }else{ String rightJifen = new GetJifen().getJiFen(jifenValue, totalNum, okNum); if(rightJifen.equals("0")){ rightJifen="1"; } content+="此系列已答完.此次积分为"+rightJifen; boolean bool = new GetJifen().saveJifenToCustomer(phone, rightJifen);//存放积分 } TbSmsSend sms = new TbSmsSend(); sms.setCreateTime(Constant.decodeDate()); sms.setDestAdd(phone); sms.setIsSendTime(0); sms.setSendTime(Constant.decodeDate()); sms.setSeriseId("0"+seriseId+timuId); sms.setSmsContent(content);// sms.setSmsSendState(0); sms.setUserId(0); smsSendList.add(sms); System.out.println("不过期content==="+content); boolean bol = new TbSmsSendDAO().addSmsList(smsSendList);//发送短信 } } } catch (ParseException e) { // TODO Auto-generated catch block e.printStackTrace(); }//年-月-日 时:分 } } } /** * *@author qingyu zhang *@function:根据表tb_daan的ID修改其状态为1 * @param daanId * @return *2011-4-13 *下午05:00:30 *zzClub *gonggong *boolean */ public boolean modifyDaan(int daanId){ boolean bo = false; sql="update tb_daan set state=1 where id="+daanId; st = new TotalClass().getStatement(); try { bo = st.execute(sql); bo = true; } catch (SQLException e) { // TODO Auto-generated catch block e.printStackTrace(); } return bo; } /** * *@author qingyu zhang *@function:修改此条记录是否正确、0:正确 1:失败 * @param sendDatiId * @param rightOrno * @return *2011-4-13 *下午05:11:56 *zzClub *gonggong *boolean */ public boolean modifySendDati(int sendDatiId,int rightOrno){ boolean bo = false; sql="update sendDati set rightOrno="+rightOrno+",state=2 where id="+sendDatiId; st = new TotalClass().getStatement(); try { bo = st.execute(sql); bo = true; } catch (SQLException e) { // TODO Auto-generated catch block e.printStackTrace(); } return bo ; } /** * *@author qingyu zhang *@function:当答题时间过时后。可根据系列ID修改此系列中没有发送的其他题目。。即状态(state)为1和0的。 * @param serise * @return *2011-4-13 *下午05:17:58 *zzClub *gonggong *boolean */ public int modifySendDati(String serise,String phone,String createTime,String endTime){ boolean bo = false; int num = 0; String condition ="seriseId='"+serise+"' and phone='"+phone+"' and state in(1,0) and createTime='"+createTime+"' and endTime='"+endTime+"'"; String sendDatiId = ""; List<SendDati> sendDatiList = new DatiDao().getSendDati("sendDati", "", condition); if(sendDatiList!=null&&sendDatiList.size()>0){ for(SendDati sendDati:sendDatiList){ if(sendDatiId.equals("")){ sendDatiId+=sendDati.getId(); }else{ sendDatiId+=","+sendDati.getId(); } } num = sendDatiList.size(); } if(!sendDatiId.equals("")){ bo = modifySendDati(sendDatiId); } return num ; } public int getSendDatiTotal(String serise,String phone,String createTime,String endTime){ boolean bo = false; int num = 0; String condition ="seriseId='"+serise+"' and phone='"+phone+"' and state in(1,0,2) and createTime='"+createTime+"' and endTime='"+endTime+"'"; String sendDatiId = ""; List<SendDati> sendDatiList = new DatiDao().getSendDati("sendDati", "", condition); num = sendDatiList.size(); return num ; } /** * *@author qingyu zhang *@function:在特定时间内得到此系列中回答正确的记录 * @param serise * @param phone * @param createTime * @param endTime * @param rightOrno * @return *2011-4-14 *上午09:07:11 *zzClub *gonggong *List<SendDati> */ public List<SendDati> getSendDatiList(String serise,String phone,String createTime,String endTime){ String condition ="seriseId='"+serise+"' and phone='"+phone+"' and state in(1,0) and createTime='"+createTime+"' and endTime='"+endTime+"' and rightOrno=0"; String sendDatiId = ""; List<SendDati> sendDatiList = new DatiDao().getSendDati("sendDati", "", condition); return sendDatiList; } public boolean modifySendDati(String ids){ boolean bo = false; sql = "update sendDati set state=2 ,rightOrno=1 where id in("+ids+")"; st = new TotalClass().getStatement(); try { bo = st.execute(sql); bo = true; } catch (SQLException e) { // TODO Auto-generated catch block e.printStackTrace(); } return bo ; } /** * 根据系列ID得到此系列上行或下行的分数0:上行 1:下行 *@author qingyu zhang *@function: * @param seriseId * @param num * @return *2011-4-13 *下午09:33:13 *zzClub *gonggong *List<JiFen> */ public JiFen getJifen(String seriseId,int num){ String condition="seriseId='"+seriseId+"' and integralType=1"; JiFen jifen = new JiFen(); jifen = new JifenDao().getJiFen("tb_integral", "", condition); return jifen; } /** * *@author qingyu zhang *@function:修改表sendDati状态为1 * @param sendDatiId * @return *2011-4-14 *上午08:36:04 *zzClub *gonggong *boolean */ public boolean modifySendDati(int sendDatiId){ String sql = "update sendDati set state=1 where id="+sendDatiId; boolean bo = new TotalClass().operatorObject(sql); return bo ; } }
zzprojects
trunk/zzprojects/zzClub/src/gonggong/ScanSendDatiDao.java
Java
asf20
12,171
package gonggong; import java.math.BigDecimal; import java.text.DecimalFormat; import java.util.List; import util.Constant; import util.TotalClass; import com.AddressListModule.bean.ContactBean; import com.AddressListModule.dao.AddressModuleDao; import com.dati.bean.SendDati; import com.dati.dao.DatiDao; public class GetJifen { /** * *@author qingyu zhang *@function: * @param fenshu 此系列的分数 * @param totalNum此系列总数 * @param rightNum答对的题目数 * @return *2011-4-13 *下午10:00:43 *zzClub *gonggong *String */ public String getJiFen(String fenshu,int totalNum,int rightNum){ int a = rightNum; int b = totalNum; double ab = (double)a/b; BigDecimal bi = new BigDecimal(ab); DecimalFormat df2 = new DecimalFormat("####"); String str = df2.format(bi); return str; } /** * *@author qingyu zhang *@function:把得到 的积分存放到用户表中 * @param phone * @param fenshu * @return *2011-4-13 *下午10:14:38 *zzClub *gonggong *boolean */ public boolean saveJifenToCustomer(String phone,String fenshu){ String sql = ""; boolean bo = false; String condition="customerPhone='"+phone+"'"; List<ContactBean> contactList = new AddressModuleDao().getContactList("tb_kehujifen", "", condition); if(contactList!=null&&contactList.size()>0){ int fs = Integer.parseInt(fenshu)+Integer.parseInt(contactList.get(0).getCustomerIntegral()); sql="update tb_kehujifen set customerIntegral='"+fs+"',lastTime='"+Constant.decodeDate()+"' where customerPhone='"+phone+"'"; }else { int fs = Integer.parseInt(fenshu); sql = "insert into tb_kehujifen (customerPhone,customerIntegral,lastTime) values('"+phone+"',"+fs+",'"+Constant.decodeDate()+"')"; } System.out.println("导入积分语句="+sql); bo = new TotalClass().operatorObject(sql); return bo; } /** * 如果存在答案。修改此记录的状态 *@author qingyu zhang *@function: * @param timuId * @param phone * @return *2011-4-14 *上午07:54:01 *zzClub *gonggong *boolean */ public boolean modifyDaan(String timuId,String phone){ boolean bo = false; String sql="update tb_daan set state=1 where timuId='"+timuId+"' and phone='"+phone+"' and state=0"; bo = new TotalClass().operatorObject(sql); return bo ; } /** * *@author qingyu zhang *@function:根据条件得到此系列中没有发送的题目。 * @param seriseId * @param phone * @param endTime * @param state * @param rightOrno * @return *2011-4-14 *上午08:08:09 *zzClub *gonggong *List<SendDati> */ public List<SendDati> getSendDati(String seriseId,String phone,String endTime,int state,String rightOrno){ String condition="";// if(rightOrno.equals("")){ condition="phone='"+phone+"' and seriseId='"+seriseId+"' and endTime='"+endTime+"' and state="+state; }else{ condition="phone='"+phone+"' and seriseId='"+seriseId+"' and endTime='"+endTime+"' and state="+state+" and rightOrno="+rightOrno; } List<SendDati> sendDatiList = new DatiDao().getSendDati("sendDati", "", condition); return sendDatiList; } }
zzprojects
trunk/zzprojects/zzClub/src/gonggong/GetJifen.java
Java
asf20
3,279
package gonggong; import java.sql.ResultSet; import java.sql.SQLException; import java.util.ArrayList; import java.util.List; import java.util.Random; import util.Constant; import util.TotalClass; import util.UtilDAO; import com.SmsModule.bean.TbSmsSend; import com.SmsModule.dao.TbSmsSendDAO; import com.dianbo.bean.Dianbo; import com.dianbo.bean.SendDianbo; import com.dianbo.dao.DianboDao; import com.jifen.bean.JiFen; import com.jifen.dao.JifenDao; import com.order.bean.TbOrder; import com.order.dao.TbOrderDao; public class SanDianboDao { private ResultSet rs = null; private String sql = ""; private List<SendDianbo> sendDianboList = null; public void operator(){ List<SendDianbo> sendDianboList = this.getSendDianbo(); if(sendDianboList!=null&&sendDianboList.size()>0){ boolean bo = this.sendSms(sendDianboList); if(bo){ String dianboId = ""; for(SendDianbo dianbo:sendDianboList){ if(dianboId.equals("")){ dianboId+=dianbo.getDianboId(); }else{ dianboId+=","+dianbo.getDianboId(); } } boolean boo= new DianboDao().modifyState(dianboId); } } } /** *@author qingyu zhang *@function:得到状态为0的要点播的信息 *2011-4-12 *下午09:11:56 *zzClub *gonggong */ public List<SendDianbo> getSendDianbo(){ String tiaojian="state = 0"; sql = UtilDAO.getList("tb_send_dianbo", "", tiaojian); rs = new TotalClass().getResult(sql); try { while(rs.next()){ if(sendDianboList==null){ sendDianboList = new ArrayList<SendDianbo>(); } sendDianboList.add(this.getSendDianbo(rs)); } } catch (SQLException e) { // TODO Auto-generated catch block e.printStackTrace(); } return sendDianboList; } public SendDianbo getSendDianbo(ResultSet rs){ SendDianbo sendDianbo = new SendDianbo(); try { sendDianbo.setDianboId(rs.getInt("dianboId")); sendDianbo.setSendPhone(rs.getString("sendPhone")); sendDianbo.setSmscontent(rs.getString("smscontent")); sendDianbo.setState(rs.getInt("state")); } catch (SQLException e) { // TODO Auto-generated catch block e.printStackTrace(); } return sendDianbo; } /** * *@author qingyu zhang *@function:把取到的数据进行发送 * @param sendDianboList *2011-4-12 *下午09:24:53 *zzClub *gonggong *void */ public boolean sendSms(List<SendDianbo> sendDianboList){ boolean bo = false; List<TbSmsSend> smsSendList = new ArrayList<TbSmsSend>(); if(sendDianboList!=null&&sendDianboList.size()>0){ for(SendDianbo dianbo:sendDianboList){ String smscontent = dianbo.getSmscontent(); String lastSmscontent = smscontent;//.substring(2).trim().toLowerCase();//指令 ym(幽默) String phone = dianbo.getSendPhone(); TbSmsSend sms = this.getSms(lastSmscontent, phone); if(sms!=null){ smsSendList.add(sms); } } } if(smsSendList!=null&&smsSendList.size()>0){ bo = new TbSmsSendDAO().addSmsList(smsSendList); } return bo ; } /** * 得到此点播类型的积分 *@author qingyu zhang *@function: * @param typeId * @param num * @return *2011-4-14 *上午09:48:53 *zzClub *gonggong *JiFen */ public JiFen getJifenDianbo(String typeId,int num){ String condition="typeId='"+typeId+"' and integralType=1"; JiFen jifen = null;//new JiFen(); jifen = new JifenDao().getJiFen("tb_integral", "", condition); return jifen; } /** * *@author qingyu zhang *@function:根据指令得到其点播下的所有信息中的一条记录 * @param orderName * @return *2011-4-12 *下午09:31:14 *zzClub *gonggong *TbSmsSend */ public TbSmsSend getSms(String orderName,String phone){ TbSmsSend sms = null; String condition ="orderValue='"+orderName+"' and orderType=0"; List<TbOrder> orderList = new TbOrderDao().getOrderList("tb_order", "", condition); if(orderList!=null&&orderList.size()>0){ TbOrder order = orderList.get(0); String typeId = order.getTypeId(); String conditionT = "typeId='"+typeId+"'"; List<Dianbo> dianboList = new ArrayList<Dianbo>(); dianboList = new DianboDao().getDianboList("tb_qs_info","qsUpTime",conditionT); int num =0; if(dianboList!=null&&dianboList.size()>0){ num =new Random().nextInt(dianboList.size()); } if(dianboList!=null&&dianboList.size()>0){ sms = new TbSmsSend(); Dianbo dianbo = dianboList.get(num); sms.setCreateTime(Constant.decodeDate()); sms.setDestAdd(phone); sms.setIsSendTime(0); sms.setSendTime(Constant.decodeDate()); sms.setSmsContent(dianbo.getQsContent()); sms.setSmsSendState(0); sms.setUserId(0); sms.setSeriseId("0"); //加用户点播的积分 JiFen jifen = getJifenDianbo(typeId,1); String fenSh = "0"; if(jifen!=null){ fenSh= jifen.getIntegralValue(); } boolean bo = new GetJifen().saveJifenToCustomer(phone,fenSh); } } return sms; } }
zzprojects
trunk/zzprojects/zzClub/src/gonggong/SanDianboDao.java
Java
asf20
5,114
package gonggong; import java.sql.SQLException; import java.sql.Statement; import java.text.Format; import java.text.SimpleDateFormat; import java.util.ArrayList; import java.util.Date; import java.util.List; import java.util.Random; import util.Constant; import util.TotalClass; import com.SmsModule.bean.TbSmsSend; import com.SmsModule.dao.TbSmsSendDAO; import com.dati.bean.Dati; import com.dati.bean.DatiMiddle; import com.dati.bean.SendDati; import com.dati.bean.Xulie; import com.dati.dao.DatiDao; import com.dati.dao.DatiTypeDao; import com.order.bean.TbOrder; import com.order.dao.TbOrderDao; public class ScanDatiDao { /** *@author qingyu zhang *@function: *2011-4-13 *上午10:36:07 *zzClub *gonggong */ Statement st = null; public void operator(){ List<Dati> datiList = new ScanDatiDao().getDatiList(); if(datiList!=null&&datiList.size()>0){ new ScanDatiDao().sendDati(datiList); boolean bo = modifyState(datiList); } } /** * *@author qingyu zhang *@function: * @return *2011-4-13 *上午10:46:36 *zzClub *gonggong *List<Dati> */ public List<Dati> getDatiList(){ String condition="state=0"; List<Dati> datiList = new DatiDao().getDatiList("tb_send_dati", "", condition); return datiList; } public void sendDati(List<Dati> datiList){ if(datiList!=null&&datiList.size()>0){ for(Dati dati:datiList){ String phone = dati.getSendPhone(); String content = dati.getSmscontent(); String lastContent = content;//content.substring(2).trim().toLowerCase();//答题指令如:生活(sh) System.out.println("指令=="+lastContent); getDatiType(lastContent,phone); } } } /** * *@author qingyu zhang *@function:根据指令值得到与其相应的答题 ID; * @param orderName *2011-4-13 *上午11:09:45 *zzClub *gonggong *void */ public void getDatiType(String orderName,String phone){ String condition="orderValue='"+orderName+"' and orderType=1"; List<TbOrder> orderList = new TbOrderDao().getOrderList("tb_order", "createTime", condition); TbOrder order = orderList.get(0); String typeId = order.getTypeId(); getXilieList(typeId,phone); } /** * *@author qingyu zhang *@function:根据答题类型得到其下的所有系列 * @param typeId * @return *2011-4-13 *上午11:15:23 *zzClub *gonggong *List<Xulie> */ public void getXilieList(String typeId,String phone){ String condition="answerTypeId='"+typeId+"'"; List<Xulie> xilieList = new DatiTypeDao().getXulieByTypeId("tb_serise", "createTime", condition); int num = 0; Xulie xilie = null; /** * 随机从所有系列中选择一个系列 */ if(xilieList!=null&&xilieList.size()>0){ num = new Random().nextInt(xilieList.size()); xilie = xilieList.get(num); } if(xilie!=null){ getTimu(xilie,phone); } } public void getTimu(Xulie xilie,String phone){ List<TbSmsSend> smsSendList = new ArrayList<TbSmsSend>(); String condition = "seriseId='"+xilie.getSeriseId()+"'"; List<DatiMiddle> datiMiddle = new DatiDao().getDatiMiddle("tb_answer_middle", "createTime", condition); if(datiMiddle!=null&&datiMiddle.size()>0){ List<SendDati> sendDatiList = this.saveTimu(datiMiddle,phone); //保存到表中 if(sendDatiList!=null&&sendDatiList.size()>0){ boolean bo = saveSmsTosendDati(sendDatiList); if(bo){ TbSmsSend smsSend = new TbSmsSend(); SendDati sendDati = sendDatiList.get(0); smsSend.setCreateTime(Constant.decodeDate()); smsSend.setDestAdd(sendDati.getPhone()); smsSend.setIsSendTime(0); smsSend.setSendTime(Constant.decodeDate()); String timuId = sendDati.getAnswerMiddleId(); String condi="answerMiddleId='"+timuId+"'"; List<DatiMiddle> datiMi = new DatiDao().getDatiMiddle("tb_answer_middle", "createTime", condi); smsSend.setSmsContent(datiMi.get(0).getAnswerContent()); smsSend.setSmsSendState(0); smsSend.setUserId(0); smsSend.setSeriseId("0"+sendDati.getSeriseId()+sendDati.getAnswerMiddleId()); smsSendList.add(smsSend); boolean boo = new TbSmsSendDAO().addSmsListDati(smsSendList); if(boo){ boolean booo = new DatiDao().modifySendDati(sendDati.getAnswerMiddleId(),phone); System.out.println("修改成功!"); } } } } } /** * *@author qingyu zhang *@function:存放要发送答题到表sendDati * @param datiMiddleList *2011-4-13 *上午11:35:05 *zzClub *gonggong *void */ public List<SendDati> saveTimu(List<DatiMiddle> datiMiddleList,String phone){ List<SendDati> sendDatiList = new ArrayList<SendDati>(); Format format=new SimpleDateFormat("yyyy-MM-dd HH:mm"); Date today=new Date(); long time=0; int fen = Integer.parseInt(new DatiDao().getSetTime()); time=(today.getTime()/1000)+60*fen; Date newDate=new Date(); newDate.setTime(time*1000); for(DatiMiddle datiMiddle:datiMiddleList){ SendDati sendDati = new SendDati(); sendDati.setAnswerMiddleId(datiMiddle.getAnswerMiddleId()); sendDati.setCreateTime(format.format(today)); sendDati.setEndTime(format.format(newDate)); sendDati.setPhone(phone); sendDati.setRightOrno(9); sendDati.setState(0); sendDati.setSeriseId(datiMiddle.getSeriseId()); sendDatiList.add(sendDati); } return sendDatiList; } /** * *@author qingyu zhang *@function:把得到的系列答题存放 到表sendDati中 * @param sendDatiList * @return *2011-4-13 *下午01:23:51 *zzClub *gonggong *boolean */ public boolean saveSmsTosendDati(List<SendDati> sendDatiList){ boolean bo = false; st = new TotalClass().getStatement(); try { for(SendDati sendDati:sendDatiList){ String hql ="insert into sendDati (seriseId,answerMiddleId,state,phone,createTime,endTime,rightOrno) " + "values('"+sendDati.getSeriseId()+"','"+sendDati.getAnswerMiddleId()+"',"+sendDati.getState()+",'"+sendDati.getPhone() +"','"+sendDati.getCreateTime()+"','"+sendDati.getEndTime()+"',"+sendDati.getRightOrno()+")"; System.out.println("导入表sendDati==="+hql); st.addBatch(hql); } st.executeBatch(); bo = true; } catch (SQLException e) { // TODO Auto-generated catch block e.printStackTrace(); } return bo ; } /** * 修改表sendDati中的state值 *@author qingyu zhang *@function: * @param dati * @return *2011-4-13 *下午01:43:54 *zzClub *gonggong *boolean */ public boolean modifyState(List<Dati> datiList){ boolean bo = false; String datiId = ""; for(Dati dati:datiList){ if(datiId.equals("")){ datiId+=dati.getDatiId(); }else{ datiId+=","+dati.getDatiId(); } } bo = new DatiDao().modifyDati(datiId); return bo ; } }
zzprojects
trunk/zzprojects/zzClub/src/gonggong/ScanDatiDao.java
Java
asf20
6,992
package util; import java.text.ParseException; import java.text.SimpleDateFormat; import java.util.Date; public class DateUitl { public static final String FORMAT_DATESTAMP = "yyyy-MM-dd HH:mm:ss"; public static final String FORMAT_DATE = "yyyy-MM-dd"; public static Date stringToDate(String dateString, String fmt) { SimpleDateFormat ft = new SimpleDateFormat(fmt); Date date = null; try { date = ft.parse(dateString); } catch (ParseException e) { // TODO Auto-generated catch block e.printStackTrace(); } return date; } public static Date stringToDate(String dateString) { return stringToDate(dateString, DateUitl.FORMAT_DATE); } }
zzprojects
trunk/zzprojects/zzClub/src/util/DateUitl.java
Java
asf20
701
package util; import java.io.BufferedReader; import java.io.File; import java.io.FileInputStream; import java.io.FileReader; import java.io.InputStream; import java.util.ArrayList; import java.util.List; import jxl.Cell; import jxl.Sheet; import jxl.Workbook; import com.SmsModule.bean.TbSmsSend; import com.SmsModule.dao.TbSmsSendDAO; import com.UserModule.bean.TbUserBean; public class QunfaThree implements Runnable { private String typeId; private String tempPath; private List<String> backPhoneList; private TbUserBean tbUser; public void run() { // TODO Auto-generated method stub System.out.println("dddd"+typeId+"=="+tempPath); new QunfaThree().sendSms(typeId, tempPath, backPhoneList, tbUser); } /** *@author qingyu zhang *@function: *2011-5-5 *下午01:56:07 *zzClub *util */ /** * typeId区分是导入的txt还是excel * tempPath * 黑名单 */ public void sendSms(String typeId,String tempPath,List<String> backPhoneList,TbUserBean tbUser){ try{ List<TbSmsSend> saveSmsList = new ArrayList<TbSmsSend>();//要保存的发送短信 if(typeId.equals("0")){//Excel导入 Workbook wb; InputStream is2 = new FileInputStream(tempPath); wb = Workbook.getWorkbook(is2); Sheet sheet = wb.getSheet(0); int row = sheet.getRows(); for(int i =1;i<row;i++){ TbSmsSend smsSend = new TbSmsSend(); Cell phoneCell= sheet.getCell(0, i); String phone = phoneCell.getContents(); Cell contentCell = sheet.getCell(1, i); String content = contentCell.getContents(); if(phone.equals("")&&content.equals("")){ break; } if(!backPhoneList.contains(phone)){ smsSend.setCreateTime(Constant.decodeDate()); smsSend.setDestAdd(phone); smsSend.setIsSendTime(0); smsSend.setSendTime(Constant.decodeDate()); smsSend.setSmsContent(content); smsSend.setSmsSendState(0);//发送状态0:未发送1:成功2:失败 smsSend.setUserId(tbUser.getUserId()); smsSend.setSeriseId(String.valueOf(tbUser.getOrgNum())); saveSmsList.add(smsSend); } } }else if(typeId.equals("1")){//txt导入 BufferedReader bs = new BufferedReader(new FileReader(new File(tempPath))); String readContent=""; while((readContent=bs.readLine())!=null){ TbSmsSend smsSend = new TbSmsSend(); String rowContent = readContent; String phone = rowContent.split(":")[0]; String content = rowContent.split(":")[1]; if(!backPhoneList.contains(phone)){ smsSend.setCreateTime(Constant.decodeDate()); smsSend.setDestAdd(phone); smsSend.setIsSendTime(0); smsSend.setSendTime(Constant.decodeDate()); smsSend.setSmsContent(content); smsSend.setSmsSendState(0);//发送状态0:未发送1:成功2:失败 smsSend.setUserId(tbUser.getUserId()); smsSend.setSeriseId(String.valueOf(tbUser.getOrgNum())); saveSmsList.add(smsSend); } } } boolean bo = new TbSmsSendDAO().addSmsList(saveSmsList); }catch(Exception e){ e.printStackTrace(); } } public String getTypeId() { return typeId; } public void setTypeId(String typeId) { this.typeId = typeId; } public String getTempPath() { return tempPath; } public void setTempPath(String tempPath) { this.tempPath = tempPath; } public List<String> getBackPhoneList() { return backPhoneList; } public void setBackPhoneList(List<String> backPhoneList) { this.backPhoneList = backPhoneList; } public TbUserBean getTbUser() { return tbUser; } public void setTbUser(TbUserBean tbUser) { this.tbUser = tbUser; } }
zzprojects
trunk/zzprojects/zzClub/src/util/QunfaThree.java
Java
asf20
3,765
package util; import java.io.UnsupportedEncodingException; import java.net.URLDecoder; import java.text.SimpleDateFormat; import java.util.Date; import java.util.Random; public class Constant { public static final String FLOOR = "1"; public static final String DINNER = "2"; public static String sucResult(String strName){ StringBuffer sb =new StringBuffer(); sb.append("<script language='javascript'>"); sb.append("alert('"+strName+"');"); sb.append("</scri"+"pt>"); return sb.toString(); } public static String sucResultAndReturn(String strName,String url){ StringBuffer sb =new StringBuffer(); sb.append("<script language='javascript'>"); sb.append("alert('"+strName+"');"); sb.append("location.href='"+url+"'"); sb.append("</scri"+"pt>"); return sb.toString(); } public static String sucReturn(String url){ StringBuffer sb =new StringBuffer(); sb.append("<script language='javascript'>"); sb.append("location.href='"+url+"'"); sb.append("</scri"+"pt>"); return sb.toString(); } //��String���н��� public static String decodeString(String str) { String result = null; try { result = URLDecoder.decode(str, "UTF-8"); } catch (UnsupportedEncodingException e) { // TODO Auto-generated catch block e.printStackTrace(); } return result; } //�õ���ǰʱ�� public static String decodeDate(){ Date date = new Date(); SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); return sdf.format(date); } public static String decodeDateT(){ Date date = new Date(); SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd"); return sdf.format(date); } public static String decodeDateTT(){ Date date = new Date(); SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm"); return sdf.format(date); } public static String getTableName() { Date date = new Date(); SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd"); String str = sdf.format(date); String month = str.substring(5, 7); String day = str.substring(8, 10); String lastStr = month+day; return lastStr; } public static String nullToString(String str){ if(str==null){ return ""; }else{ return str; } } /** * *@author qingyu zhang *@function:�õ�һ�����λ�� * @return *Nov 25, 2010 *4:34:13 PM *yxpsb *com.psb.util *String */ public static String getNum(){ Random random = new Random(); String rand=""; for (int i=1;i<4;i++) { rand+=String.valueOf(random.nextInt(10)); } return rand; } public static String getNumT(){ Random random = new Random(); String rand=""; for (int i=0;i<5;i++) { rand+=String.valueOf(random.nextInt(10)); } return rand; } public static void main(String args[]) { String ss = Constant.getTableName(); System.out.println("ss="+ss); } }
zzprojects
trunk/zzprojects/zzClub/src/util/Constant.java
Java
asf20
2,978
package util; import java.sql.Connection; import java.sql.PreparedStatement; import java.sql.ResultSet; import java.sql.Statement; import java.util.ArrayList; import java.util.Hashtable; import java.util.Iterator; public class Update_Status { private Connection conn = null; private PreparedStatement pt = null; private Statement st = null; private ResultSet rs = null; private boolean flag = false; private String sql = ""; /** * *@author jhc *@function:根据日期得到MAS表中天表的名称,以此来修改表中相应数据的状态 * @param date *Aug 6, 2010 *9:23:05 AM *bzsafety *util *void */ public void updateSmsStatus(String dateTime,String date){ Connection con = null; PreparedStatement pst =null; PreparedStatement pstT =null; ResultSet rs = null; ResultSet rsT = null; try { ArrayList<String> smsList = getSms(dateTime);//得到自己表中要修改状态的记录 if(smsList!=null&&smsList.size()>0) { ArrayList modifyStatusList = getSmsStatus(smsList,date); if(modifyStatusList!=null&&modifyStatusList.size()>0) { updateStatus(modifyStatusList); } } }catch(Exception e){ e.printStackTrace(); } } /** * jhc * @param dateTime * @return */ public ArrayList getSms(String dateTime){ String lastDateTime = dateTime.substring(0, 10); //System.out.println("lastDateTime==="+lastDateTime); ArrayList smsIdList = new ArrayList(); try { conn = ConnectDB.getConn("zzClub"); String sql = "select * from tb_sms_send where sendTime like '%"+lastDateTime+"%' and smsSendState=0"; //System.out.println("得到要"+sql); pt = conn.prepareStatement(sql); rs = pt.executeQuery(); while(rs.next()) { String smsId = String.valueOf(rs.getInt("smsId")); smsIdList.add(smsId); } }catch(Exception e){ e.printStackTrace(); } finally { ConnectDB.closeSqlConnection(); } return smsIdList; } /** * *@author jhc *@function:根据从自己表中得到的要修改的短信ID从MAS表中得到此短信的发送状态 * @param smsIdList * @return *Oct 20, 2010 *10:35:49 AM *bzsafety *util *ArrayList */ public ArrayList getSmsStatus(ArrayList smsIdList,String date){ String tableName = "tbl_SMResult_"+date;//得到MAS中天表的名称 String smsId =""; ArrayList smsResultList = new ArrayList(); try { conn =ConnectDB.getConn("DB_CustomSMS"); for(int i = 0;i<smsIdList.size();i++) { smsId = smsIdList.get(i).toString()+","; } String lastSmsId = smsId.substring(0,smsId.length()-1); String hql = "select Recv_Status,Reserve2 from "+tableName +" where Reserve2 in('"+lastSmsId+"')"; //System.out.println("得到MAS表中"+hql); pt = conn.prepareStatement(hql); rs = pt.executeQuery(); while(rs.next()) { String status = rs.getString("Recv_Status"); String sms_Id = rs.getString("Reserve2"); Hashtable ht = new Hashtable(); ht.put(sms_Id, status); smsResultList.add(ht); } }catch(Exception e){ e.printStackTrace(); } finally { ConnectDB.closeSqlConnection(); } return smsResultList; } /** * *@author jhc *@function:根据从MAS表中得到要修改状态的记录更新自己表中的记录 * @param list *Oct 20, 2010 *10:47:08 AM *bzsafety *util *void */ public void updateStatus(ArrayList list){ try { conn =ConnectDB.getConn("zzClub"); st = conn.createStatement(); for(int i = 0;i<list.size();i++) { Hashtable ht = (Hashtable)list.get(i); Iterator it = ht.keySet().iterator(); while(it.hasNext()) { String smsId = it.next().toString();//得到表sms_send中的主键 String status = ht.get(smsId).toString();//根据smsId得到此记录的状态 int zhuangTai = 0; if(Integer.parseInt(status)==0){ zhuangTai=1; }else { zhuangTai=2; } String hql = "update tb_sms_send set smsSendState ="+zhuangTai+" where smsId="+Integer.parseInt(smsId); //System.out.println("修改自己的表"+hql); st.addBatch(hql); } } st.executeBatch(); }catch(Exception e){ e.printStackTrace(); } } public static void main(String[] args) throws Exception { Connection conn =ConnectDB.getSqlServerConnectionMas(); System.out.println(conn); } }
zzprojects
trunk/zzprojects/zzClub/src/util/Update_Status.java
Java
asf20
4,502
package util; import java.util.ArrayList; import java.util.List; import java.util.Random; import com.dati.bean.DatiType; import com.dati.bean.Xulie; import com.dati.dao.DatiTypeDao; import com.dianbo.bean.DianboType; import com.dianbo.dao.DianboTypeDao; public class AllTypeList { /** *@author qingyu zhang *@function: *2011-4-7 *下午02:30:14 *zzClub *util */ public List getLastValue(int userId){ List list = new ArrayList(); String condition="userId = "+userId; List<DianboType> dianboTypeList = new ArrayList<DianboType>(); dianboTypeList = new DianboTypeDao().getDianboList("tb_qsType_answer", condition, "createTime"); /** * 下面得到答题的类型 * start!!!!!!!!!! */ StringBuffer sb = new StringBuffer(); sb.append(" <li class=\"0\"><a>答题类型</a><span title=\"添加答题类型\" class=\"addnode\"><a style=\"cursor:hand\" onclick=\"$mb=$.msgbox({height:220,width:500,content:{type:\'ajax\',content:\'./DatiTypeServlet?method=addType\'},title:\'新增答题类型\'});\">答题类型</a></span><ul class=\"treeview\">"); sb.append(getDatiType(userId)); sb.append("</ul></li>"); list.add(dianboTypeList); list.add(sb); return list; } /** * *@author qingyu zhang *@function:在下行积分设置时得到答题、点播的类型 * @param userId * @return *2011-4-9 *下午09:49:06 *zzClub *util *List */ public List getDownValue(int userId){ List list = new ArrayList(); String condition="userId = "+userId; List<DianboType> dianboTypeList = new ArrayList<DianboType>(); dianboTypeList = new DianboTypeDao().getDianboList("tb_qsType_answer", condition, "createTime"); /** * 下面得到答题的类型 * start!!!!!!!!!! */ String conditionT = "userId="+userId; List<DatiType> datiTypeList = new ArrayList<DatiType>(); datiTypeList = new DatiTypeDao().getAllDaTiType("tb_answer_type", "createTime", conditionT); list.add(dianboTypeList); list.add(datiTypeList); return list; } public StringBuffer getDatiType(int userId){ StringBuffer sb = new StringBuffer(); String condition=" userId= "+userId; List<DatiType> datiTypeList = new ArrayList<DatiType>(); datiTypeList = new DatiTypeDao().getAllDaTiType("tb_answer_type", "createTime", condition); if(datiTypeList!=null&&datiTypeList.size()>0){ for(DatiType datiType:datiTypeList){ sb.append(" <li class=\""+datiType.getAnswerTypeId()+"\"><a>"+datiType.getTypeName()+"</a>"); sb.append("<span title=\"修改类型\" class=\"editnode\"><a style=\"cursor:hand\" onclick=\"$mb=$.msgbox({height:220,width:500,content:{type:\'ajax\',content:\'./DatiTypeServlet?method=modifyType&typeId="+datiType.getAnswerTypeId()+"\'},title:\'修改类型\',onAjaxed: function(data){}});\">修改类型</a></span>"); sb.append("<span title=\"删除类型\" class=\"delnode\"><a style=\"cursor:hand\" onclick=\"deleteDatiType('../DatiTypeServlet?method=deleteType&typeId="+datiType.getAnswerTypeId()+"')\">删除类型</a></span>"); sb.append("<span title=\"新增系列\" class=\"addnode\"><a style=\"cursor:hand\" onclick=\"$mb=$.msgbox({height:220,width:500,content:{type:\'ajax\',content:\'./DatiTypeServlet?method=addXiLie&typeId="+datiType.getAnswerTypeId()+"\'},title:\'新增系列\',onAjaxed: function(data){}});\">系列</a></span>"); String conditionT=" answerTypeId ='"+datiType.getAnswerTypeId()+"'"; List<Xulie> xulieList = new DatiTypeDao().getXulieByTypeId("tb_serise", "createTime", conditionT); if(xulieList!=null&&xulieList.size()>0){ sb.append(" <ul class=\"treeview\">"); for(Xulie xulie:xulieList){ sb.append("<li class=\""+xulie.getSeriseId()+"\"><a>"+xulie.getSeriseName()+"</a>"); sb.append("<span title=\"修改系列\" class=\"editnode\"><a style=\"cursor:hand\" onclick=\"$mb=$.msgbox({height:220,width:500,content:{type:\'ajax\',content:\'./DatiTypeServlet?method=modifyXilie&xilieId="+xulie.getSeriseId()+"&num="+new Random().nextInt(10000)+"\'},title:\'修改系列\',onAjaxed: function(data){}});\">修改系列</a></span>"); sb.append("<span title=\"删除系列\" class=\"delnode\"><a style=\"cursor:hand\" onclick=\"deleteXilie('../DatiTypeServlet?method=deleteXilie&xilieId="+xulie.getSeriseId()+"&num="+new Random().nextInt(10000)+"')\">删除系列</a></span>"); sb.append("<span title=\"设置积分\" class=\"editnode\"><a style=\"cursor:hand\" onclick=\"mb=$.msgbox({height:220,width:500,content:{type:\'iframe\',content:\'./DatiTypeServlet?method=setJiFen&xilieId="+xulie.getSeriseId()+"\'},title:\'设置积分\',onAjaxed: function(data){}});\">设置积分</a></span></li>"); } sb.append("</ur>"); } sb.append("</li>"); } } System.out.println("sb==="+sb.toString()); return sb; } }
zzprojects
trunk/zzprojects/zzClub/src/util/AllTypeList.java
Java
asf20
4,943
package util; import java.util.ArrayList; import java.util.List; public class MyPagination { public List<Object> list=null; private int recordCount=0; private int pagesize=0; private int maxPage=0; //初始化分页信息 public List getInitPage(List list,int Page,int pagesize){ List<Object> newList=new ArrayList<Object>(); this.list=list; recordCount=list.size(); this.pagesize=pagesize; this.maxPage=getMaxPage(); try{ for(int i=(Page-1)*pagesize;i<=Page*pagesize-1;i++){ try{ if(i>=recordCount){break;} }catch(Exception e){} newList.add((Object)list.get(i)); } }catch(Exception e){ e.printStackTrace(); } return newList; } //获取指定页的数据 public List<Object> getAppointPage(int Page){ List<Object> newList=new ArrayList<Object>(); try{ for(int i=(Page-1)*pagesize;i<=Page*pagesize-1;i++){ try{ if(i>=recordCount){break;} }catch(Exception e){} newList.add((Object)list.get(i)); } }catch(Exception e){ e.printStackTrace(); } return newList; } //获取最大记录数 public int getMaxPage(){ int maxPage=(recordCount%pagesize==0)?(recordCount/pagesize):(recordCount/pagesize+1); return maxPage; } //获取总记录数 public int getRecordSize(){ return recordCount; } //获取当前页数 public int getPage(String str){ System.out.println("STR:"+str+"&&&&"+recordCount); if(str==null){ str="0"; } int Page=Integer.parseInt(str); if(Page<1){ Page=1; }else{ if(((Page-1)*pagesize+1)>recordCount){ Page=maxPage; } } return Page; } public String printCtrl(int Page){ String strHtml="<table width='100%' border='0' cellspacing='0' cellpadding='0'><tr> <td class='pagination'>共有["+recordCount+"]条记录 当前页数:["+Page+"/"+maxPage+"] &nbsp;"; try{ if(Page>1){ strHtml=strHtml+"<a href='?Page=1'>首页</a>"; strHtml=strHtml+"&nbsp;<a href='?Page="+(Page-1)+"'>上一页</a>"; } if(Page<maxPage){ strHtml=strHtml+"&nbsp;<a href='?Page="+(Page+1)+"'>下一页</a>&nbsp;<a href='?Page="+maxPage+"'>尾页&nbsp;</a>"; } strHtml=strHtml+"</td> </tr></table>"; }catch(Exception e){ e.printStackTrace(); } return strHtml; } public String printCtrl(String pagePath,int Page){ String strHtml="<table width='100%' border='0' cellspacing='0' cellpadding='0'><tr> <td class='pagination'>共有["+recordCount+"]条记录 当前页数:["+Page+"/"+maxPage+"] &nbsp;"; try{ if(Page>1){ strHtml=strHtml+"<a href='"+pagePath+"?Page=1'>首页</a>"; strHtml=strHtml+"&nbsp;<a href='"+pagePath+"?Page="+(Page-1)+"'>上一页</a>"; } if(Page<maxPage){ strHtml=strHtml+"&nbsp;<a href='"+pagePath+"?Page="+(Page+1)+"'>下一页</a>&nbsp;<a href='"+pagePath+"?Page="+maxPage+"'>尾页&nbsp;</a>"; } strHtml=strHtml+"</td> </tr></table>"; }catch(Exception e){ e.printStackTrace(); } return strHtml; } public String printCtrl(int Page,String id){ //id="&id="+id; String strHtml="<table width='100%' border='0' cellspacing='0' cellpadding='0'><tr> <td class='pagination' >共有["+recordCount+"]条记录 当前页数:["+Page+"/"+maxPage+"] &nbsp;"; try{ if(Page>1){ strHtml=strHtml+"<a href='?Page=1"+id+"'>首页</a>"; strHtml=strHtml+"&nbsp;<a href='?Page="+(Page-1)+id+"'>上一页</a>"; } if(Page<maxPage){ strHtml=strHtml+"&nbsp;<a href='?Page="+(Page+1)+id+"'>下一页</a>&nbsp;<a href='?Page="+maxPage+id+"'>尾页&nbsp;</a>"; } strHtml=strHtml+"</td></tr></table>"; }catch(Exception e){ e.printStackTrace(); } return strHtml; } public String printCtrl(String pagePath,int Page,String id){ //id="&id="+id; String strHtml="<table width='100%' border='0' cellspacing='0' cellpadding='0'><tr> <td class='pagination' >共有["+recordCount+"]条记录 当前页数:["+Page+"/"+maxPage+"] &nbsp;"; try{ if(Page>1){ strHtml=strHtml+"<a href='"+pagePath+"?Page=1"+id+"'>首页</a>"; strHtml=strHtml+"&nbsp;<a href='"+pagePath+"?Page="+(Page-1)+id+"'>上一页</a>"; } if(Page<maxPage){ strHtml=strHtml+"&nbsp;<a href='"+pagePath+"?Page="+(Page+1)+id+"'>下一页</a>&nbsp;<a href='"+pagePath+"?Page="+maxPage+id+"'>尾页&nbsp;</a>"; } strHtml=strHtml+"</td></tr></table>"; }catch(Exception e){ e.printStackTrace(); } return strHtml; } }//end class
zzprojects
trunk/zzprojects/zzClub/src/util/MyPagination.java
Java
asf20
4,514
package util; import java.sql.Connection; import java.sql.PreparedStatement; import java.sql.ResultSet; import java.util.ArrayList; import java.util.List; import java.util.Random; /** *common database DAO * @author vsked */ public class UtilDAO { private static Connection conn = null; private static PreparedStatement pt = null; private ResultSet rs = null; private static boolean flag = false; private static String sql = ""; /** * @param inTableName table * @param inKey primary key name * @param inId * @return */ public static boolean del(String inTableName,String inKey, String inId) { try { conn = ConnectDB.getSqlServerConnection(); sql = "delete from " + inTableName + " where "+inKey+"=?"; System.out.println("sql:"+sql); pt = conn.prepareStatement(sql); pt.setString(1, inId); if (pt.executeUpdate() > 0) { flag = true; } } catch (Exception e) { e.printStackTrace(); } finally { ConnectDB.closeSqlConnection(); } return flag; } public static boolean del(Connection inConn,String inTableName,String inKey, String inId) { try { conn = inConn; sql = "delete from " + inTableName + " where "+inKey+"=?"; pt = conn.prepareStatement(sql); pt.setString(1, inId); if (pt.executeUpdate() > 0) { flag = true; } } catch (Exception e) { e.printStackTrace(); } return flag; } /** * @param inTableName table * @param inKey primary key * @param inId * @return */ public static boolean del(String inTableName,String inKey, int inId) { try { conn = ConnectDB.getSqlServerConnection(); sql = "delete from " + inTableName + " where "+inKey+"=?"; pt = conn.prepareStatement(sql); pt.setInt(1, inId); if (pt.executeUpdate() > 0) { flag = true; } } catch (Exception e) { e.printStackTrace(); } finally { ConnectDB.closeSqlConnection(); } return flag; } public static boolean del(Connection inConn,String inTableName,String inKey, int inId) { try { conn = inConn; sql = "delete from " + inTableName + " where "+inKey+"=?"; pt = conn.prepareStatement(sql); pt.setInt(1, inId); if (pt.executeUpdate() > 0) { flag = true; } } catch (Exception e) { e.printStackTrace(); } return flag; } /** * delete all record from table * @param inTableName * @return true or false */ public static boolean delAll(String inTableName) { try { conn = ConnectDB.getSqlServerConnection(); sql = "delete from " + inTableName; pt = conn.prepareStatement(sql); if (pt.executeUpdate() > 0) { flag = true; } } catch (Exception e) { e.printStackTrace(); } finally { ConnectDB.closeSqlConnection(); } return flag; } public static boolean delAll(Connection inConn,String inTableName) { try { conn = inConn; sql = "delete from " + inTableName; pt = conn.prepareStatement(sql); if (pt.executeUpdate() > 0) { flag = true; } } catch (Exception e) { e.printStackTrace(); } return flag; } /** * *@author qingyu zhang *@function:get the recoder of the mms by condition * @param inTableName :the name of table * @param inKey:the primary key of table * @param order: the order of table * @param tiaojian:the condition of the table * @return *Feb 9, 2011 *9:05:02 AM *vskWebFrameWork *util *String */ public static String getList(String inTableName, String order,String tiaojian) { ArrayList lst = new ArrayList(); try { if(!order.equals("")) { if(!tiaojian.equals("")) { sql="select * from "+inTableName+" where "+tiaojian+" order by "+order +" desc"; }else{ sql = "select * from "+inTableName+" order by "+order +" desc"; } }else{ if(!tiaojian.equals("")) { sql = "select * from "+inTableName+" where "+tiaojian; }else{ sql="select * from "+inTableName; } } } catch (Exception e) { e.printStackTrace(); return null; } return sql; } /** * *@author qingyu zhang *@function:get the recoder of the mms by condition * @param inTableName :the name of table * @param inKey:the primary key of table * @param order: the order of table * @param tiaojian:the condition of the table * @return *Feb 9, 2011 *9:05:02 AM *vskWebFrameWork *util *String */ public static String getListT(String inTableName, String order,String tiaojian) { ArrayList lst = new ArrayList(); try { if(!order.equals("")) { if(!tiaojian.equals("")) { sql="select * from "+inTableName+" where "+tiaojian+" order by "+order; }else{ sql = "select * from "+inTableName+" order by "+order; } }else{ if(!tiaojian.equals("")) { sql = "select * from "+inTableName+" where "+tiaojian; }else{ sql="select * from "+inTableName; } } } catch (Exception e) { e.printStackTrace(); return null; } return sql; } /** * *@author qingyu zhang *@function:get the object by the primary key * @param inTableName:the name of table * @param inKey:the primary key of table * @param id:the value of primary key * @return *Feb 9, 2011 *9:10:10 AM *vskWebFrameWork *util *String */ public static String getObject(String inTableName, String inKey,int id){ sql = "select * from "+inTableName +" where "+inKey+"="+id; return sql; } /** * * @param inTableName * @param inColumn * @return */ public static boolean updateAll(String inTableName,String inColumn) { try { conn = ConnectDB.getSqlServerConnection(); sql = "update " + inTableName+" set "+inColumn; pt = conn.prepareStatement(sql); if (pt.executeUpdate() > 0) { flag = true; } } catch (Exception e) { e.printStackTrace(); } finally { ConnectDB.closeSqlConnection(); } return flag; } /** * * @param inTableName * @param inColumn update columnString * @param inPrimarykey primary key * @return */ public static boolean updateAll(String inTableName,String inColumn,String inPrimarykey) { try { conn = ConnectDB.getSqlServerConnection(); sql = "update " + inTableName+" set "+inColumn+" where "+inPrimarykey; pt = conn.prepareStatement(sql); if (pt.executeUpdate() > 0) { flag = true; } } catch (Exception e) { e.printStackTrace(); } finally { ConnectDB.closeSqlConnection(); } return flag; } public static boolean updateAll(Connection inConn,String inTableName,String inColumn,String inPrimarykey) { try { conn = inConn; sql = "update " + inTableName+" set "+inColumn+" where "+inPrimarykey; pt = conn.prepareStatement(sql); if (pt.executeUpdate() > 0) { flag = true; } } catch (Exception e) { e.printStackTrace(); } return flag; } /** * 截取字符 */ public static String sub_String(String str) { String lastString = ""; if(str.length()>30) { lastString = str.substring(0, 30); }else { lastString = str; } return lastString; } /** * del some id * @param inTableName * @param inKey * @param inId * @return */ public static boolean delin(String inTableName,String inKey, String inId) { try { conn = ConnectDB.getSqlServerConnection(); sql = "delete from " + inTableName + " where "+inKey+" in ("+inId+")"; pt = conn.prepareStatement(sql); if (pt.executeUpdate() > 0) { flag = true; } } catch (Exception e) { e.printStackTrace(); } finally { ConnectDB.closeSqlConnection(); } return flag; } public static boolean delin(Connection inConn,String inTableName,String inKey, String inId) { try { conn = inConn; sql = "delete from " + inTableName + " where "+inKey+" in ("+inId+")"; pt = conn.prepareStatement(sql); if (pt.executeUpdate() > 0) { flag = true; } } catch (Exception e) { e.printStackTrace(); } return flag; } }//end class
zzprojects
trunk/zzprojects/zzClub/src/util/UtilDAO.java
Java
asf20
9,610
package util; import java.io.BufferedReader; import java.io.File; import java.io.FileInputStream; import java.io.FileOutputStream; import java.io.FileReader; import java.io.InputStreamReader; import java.awt.Image; import java.awt.image.BufferedImage; import java.io.File; import java.io.FileOutputStream; import java.io.IOException; import javax.imageio.ImageIO; import com.sun.image.codec.jpeg.JPEGCodec; import com.sun.image.codec.jpeg.JPEGImageEncoder; import org.apache.poi.hssf.usermodel.HSSFCell; import org.apache.poi.hssf.usermodel.HSSFCellStyle; import org.apache.poi.hssf.usermodel.HSSFRow; import org.apache.poi.hssf.usermodel.HSSFSheet; import org.apache.poi.hssf.usermodel.HSSFWorkbook; import org.apache.poi.ss.usermodel.CellStyle; /** * 文件操作 * @author 非灭天 * */ public class FileOperate { private static String[] af=null; public static String imageExt="bmp,BMP,JPG,jpg,JPEG,jpeg,gif,GIF,"; public static String voiceExt="wav,WAV,MP3,mp3,amr,AMR,"; public static String excelExt="XLS,xls,"; /** * 文件保存路径 */ public static String excelSavePath = "./export.xls"; /** * 得到文件保存路径 * @return */ public static String getExcelSavePath() { return excelSavePath; } /** * 设置文件保存路径 * @param excelSavePath */ public static void setExcelSavePath(String excelSavePath) { FileOperate.excelSavePath = excelSavePath; } /** * 工作表总数 */ private static int sheetIndexTest = 1; /** * 最大行 */ private int rowIndexTest = 4; /** * 最大列 */ private int colIndexTest = 6; /** * 读取文件 * @param fname * @return */ public static String readFile(String fname) { String content = ""; try { BufferedReader br = new BufferedReader(new BufferedReader(new InputStreamReader(new FileInputStream(new File(fname)),"utf-8"))); while (br.ready()) { String s = br.readLine(); if("".equals(content)) { content=s; }else{ content += s ; } } br.close(); } catch (Exception ex) { } return content; } /** * 读取目录内所有文件 * @param strv 路径 * @return String[] */ public static String[] readAllFilesinDirectory(String strv) { File f = new File(strv); if(f.list()!=null){ String fs[] = f.list(); af=new String[fs.length]; for (int i = 0; i < fs.length; i++) { File fv = new File(fs[i]); if (fv.canWrite()) { break; } else { try { System.out.println(f.getCanonicalPath() + fs[i]); af[i]=fs[i]; // VskVmethodBody.readAllDirectory(f.getCanonicalPath() + fs[i]); } catch (Exception e) { e.printStackTrace(); } } } } return af; } /** * 传入二维数组 写成excel文件 * write excel to file */ public static void writeExcel(String[][] inArray) { try { if(inArray==null){ inArray=new String[0][0]; } // 创建新工作薄  // create new Excel workbook   HSSFWorkbook workbook = new HSSFWorkbook(); for (int sheetIndex = 0; sheetIndex < sheetIndexTest; sheetIndex++) { // 在工作薄中创建工作表 sheet X    // create new sheet in workbook HSSFSheet sheet = workbook.createSheet("sheet" + sheetIndex); // HSSFSheet sheet = workbook.createSheet(); for (int rowIndex = 0; rowIndex < inArray.length; rowIndex++) { // 在工作表中创建行 // create row in sheet HSSFRow row = sheet.createRow(rowIndex); for (int colIndex = 0; colIndex < inArray[0].length; colIndex++) { // 在索引rowIndex的位置创建单元格(左上端) // create column in row HSSFCell cell = row.createCell(colIndex); // 定义单元格为字符串类型    // set the cell data type cell.setCellType(HSSFCell.CELL_TYPE_STRING); // 在单元格中输入一些内容 // set the cell data cell.setCellValue(inArray[rowIndex][colIndex]); }// end for colIndex }// end for rowIndex }// end for sheetIndex // 新建一输出文件流 // new FileOutputStream FileOutputStream fOut = new FileOutputStream(excelSavePath); // 把相应的Excel 工作簿存盘 // save the excel workbook workbook.write(fOut); fOut.flush(); // 操作结束,关闭文件 // finish operate close file fOut.close(); } catch (Exception e) { e.printStackTrace(); } }// end method writeExcel /** * 删除文件 * * @param fname */ public static void deleteFile(String fname) { // System.out.println(fname); (new File(fname)).delete(); } public static String getDBConfig(String fname){ return FileOperate.readFile(fname); } /** * 读取excel文件 * @param inFile 文件路径 * read excel file */ public static String[][] readExcel(String inFile) { String[][] tempArray=null; try { // read the workbook in file HSSFWorkbook workbook = new HSSFWorkbook(new FileInputStream(inFile)); // get the sheet in workbook // HSSFSheet sheet = workbook.getSheet("Sheet0"); //得到excel内工作表总数 int sheetIndexTest=workbook.getNumberOfSheets(); for (int sheetIndex = 0; sheetIndex < sheetIndexTest; sheetIndex++) { // you can use getSheetAt(int index) get the sheet in workbook // 也可用getSheetAt(int index)按索引引用 HSSFSheet sheet = workbook.getSheetAt(sheetIndex); //得到工作表内行数 int rowIndexTest=sheet.getPhysicalNumberOfRows(); for (int rowIndex = 0; rowIndex < rowIndexTest; rowIndex++) { HSSFRow row = sheet.getRow(rowIndex); //得到列数 int colIndexTest=row.getLastCellNum(); for (int colIndex = 0; colIndex < colIndexTest; colIndex++) { HSSFCell cell = row.getCell(colIndex); if(tempArray==null){ tempArray=new String[rowIndexTest][colIndexTest]; } //System.out.print("["+rowIndex + ":" + colIndex + "||" + cell.getStringCellValue()+"]"); tempArray[rowIndex][colIndex]=(String)(cell.getStringCellValue()==null?cell.getNumericCellValue():cell.getStringCellValue()); }// end for colIndex //System.out.println(); }// end for rowIndex } } catch (Exception e) { e.printStackTrace(); } return tempArray; }// end method readExcel /** * * @param inFilePath * @param outFilePath * @param inWidth * @param inHeight */ public static void changePictureSize(String inFilePath,String outFilePath,int inWidth,int inHeight){ File src = new File(inFilePath) ; try { Image image = ImageIO.read(src) ; int width = inWidth ; int height = inHeight ; BufferedImage bufferedImage = new BufferedImage(width,height,BufferedImage.TYPE_INT_RGB) ; bufferedImage.getGraphics().drawImage(image, 0, 0, width, height,null) ; FileOutputStream fos = new FileOutputStream(outFilePath) ; JPEGImageEncoder encoder = JPEGCodec.createJPEGEncoder(fos) ; encoder.encode(bufferedImage) ; fos.close(); } catch (IOException e) { e.printStackTrace(); } } /** * @param args * @throws Exception */ public static void main(String[] args) throws Exception { Image ti=ImageIO.read(new File("g:/1.jpg")); System.out.println(ti.getWidth(null)+"||"+ti.getHeight(null)); }//end main method }//end class
zzprojects
trunk/zzprojects/zzClub/src/util/FileOperate.java
Java
asf20
7,660
package util; import java.sql.Connection; import java.sql.ResultSet; import java.sql.Statement; public class VskPage { public static String divClassString=""; public static String aClassString=""; public static String selectClassString=""; /** * 记录总数 */ public static int allRecordCount=0; /** * 每页显示记录 */ private int everyPageRecord=10; /** * 当前页 */ private int currentPage=0; /** * 总页数 */ private int maxPage=5; /** * 总记录sql语句 */ private String allCountSql=""; /** * 处理当前页范围 */ public void processCurrentPage(){ if(currentPage<=1) currentPage=1; else if(currentPage>=maxPage) currentPage=maxPage; } public int getAllRecordCount() { return allRecordCount; } public int getEveryPageRecord() { return everyPageRecord; } public void setEveryPageRecord(int everyPageRecord) { this.everyPageRecord = everyPageRecord; } public int getCurrentPage() { return currentPage; } public void setCurrentPage(int currentPage) { this.currentPage = currentPage; } public String getAllCountSql() { return allCountSql; } public void setAllCountSql(String allCountSql) { this.allCountSql = allCountSql; } public void processAllCountSql(){ if(this.getCurrentPage()==1 && allCountSql.indexOf("top")>1) this.allCountSql=this.allCountSql.replace("top "+everyPageRecord+" *", "count(*)"); else if(allCountSql.indexOf("top")<1) this.allCountSql=this.allCountSql.replace("*", " count(*)"); } public String processPageSql(String inTableName,String inPrimaryKey){ return getCurrentPage()<=1?"select top "+everyPageRecord+" * from "+inTableName:"select top "+everyPageRecord+" * from "+inTableName+" where "+inPrimaryKey+" not in (select top "+(currentPage-1)*everyPageRecord+" "+inPrimaryKey+" from "+inTableName+")"; } public String processPageSql(int inCurrentPage,String inTableName,String inPrimaryKey,String inWhere){ return inCurrentPage<=1?"select top "+everyPageRecord+" * from "+inTableName+inWhere:"select top "+everyPageRecord+" * from "+inTableName+" where "+inPrimaryKey+" not in (select top "+(currentPage-1)*everyPageRecord+" "+inPrimaryKey+" from "+inTableName+")"+inWhere; } /** * 得到总页数 * @return */ public int getMaxPage(){ return (allRecordCount/everyPageRecord)+1; } public int getAllRecordCount(Connection inConn,String inSql){ try{ Statement st=inConn.createStatement(); processAllCountSql(); ResultSet rs=st.executeQuery(this.getAllCountSql()); if(rs.next()) allRecordCount=rs.getInt(1); }catch (Exception e) { e.printStackTrace(); return 0; } this.maxPage=getMaxPage(); return allRecordCount; } public String printCtrla(String inPage){ String vskPageStringa="<div align='center' "+divClassString+">"; vskPageStringa+="共"+allRecordCount+"条数据当前第"+currentPage+"页"; vskPageStringa+="<a href='"+inPage+"?Page=1' "+aClassString+" >首页</a>"; vskPageStringa+="<a href='"+inPage+"?Page="+(currentPage-1<=1?1:currentPage-1)+"' "+aClassString+" >上页</a>"; vskPageStringa+="<select onchange='window.location=\""+inPage+"?Page=\"+this.value;' "+selectClassString+" >"; vskPageStringa+="<option value='1'>请选择</option>"; if(maxPage>1){ for(int i=1;i<=maxPage;i++) vskPageStringa+="<option value='"+i+"' "+(currentPage==i?" selected ":"")+" >"+i+"</option> \n"; } vskPageStringa+="</select>"; vskPageStringa+="<a href='"+inPage+"?Page="+(currentPage+1>=maxPage?maxPage:currentPage+1)+"' "+aClassString+" >下页</a>"; vskPageStringa+="<a href='"+inPage+"?Page="+maxPage+"' "+aClassString+" >尾页</a>"; vskPageStringa+="共"+getMaxPage()+"页"; vskPageStringa+="</div>"; return vskPageStringa; } public String printCtrla(String inPage,String inParameter){ String vskPageStringa="<div align='center' "+divClassString+" >"; vskPageStringa+="共"+allRecordCount+"条数据当前第"+currentPage+"页"; vskPageStringa+="<a href='"+inPage+"?Page=1"+inParameter+"' "+aClassString+" >首页</a>"; vskPageStringa+="<a href='"+inPage+"?Page="+(currentPage-1<=1?1:currentPage-1)+inParameter+"' "+aClassString+" >上页</a>"; vskPageStringa+="<select onchange='window.location=\""+inPage+"?Page=\"+this.value+\""+inParameter+"\";' "+selectClassString+" >"; vskPageStringa+="<option value='1'>请选择</option>"; if(maxPage>1){ for(int i=1;i<=maxPage;i++) vskPageStringa+="<option value='"+i+"' "+(currentPage==i?" selected ":"")+" >"+i+"</option> \n"; } vskPageStringa+="</select>"; vskPageStringa+="<a href='"+inPage+"?Page="+(currentPage+1>=maxPage?maxPage:currentPage+1)+inParameter+"' "+aClassString+" >下页</a>"; vskPageStringa+="<a href='"+inPage+"?Page="+maxPage+inParameter+"' "+aClassString+" >尾页</a>"; vskPageStringa+="共"+getMaxPage()+"页"; vskPageStringa+="</div>"; return vskPageStringa; } public VskPage() { } public VskPage(int everyPageRecord, int currentPage) { this.everyPageRecord = everyPageRecord; this.currentPage = currentPage; } public static void main(String[] args) { String sql="select top 10 * from SmsRecordTable where SmsIndex not in (select top 20 SmsIndex from SmsRecordTable) and PhoneNumber like '%%' and SmsContent like '%%' and Status='接收' order by SmsTime asc"; VskPage vp=new VskPage(10,3); //System.out.println(vp.processPageSql(vp.getCurrentPage(), "Tb_User", "UserId", (vp.getCurrentPage()<=1?" where ":" and ")+" 1=1")); System.out.println(sql.indexOf("top "+vp.getEveryPageRecord()+" *")); } }
zzprojects
trunk/zzprojects/zzClub/src/util/VskPage.java
Java
asf20
5,747
package util; public class Pageation { public static String getPagination(int pageNum, int pageCount, int recordCount, String pageUrl) { String url = pageUrl.contains("?") ? pageUrl : pageUrl + "?"; StringBuffer buffer = new StringBuffer(); buffer.append("��" + pageNum + "/" + pageCount + "ҳ��" + recordCount + "��¼"); buffer.append(pageNum == 1 ? "��һҳ" : "<a href='" + url + "'&pageNum=1>��һҳ</a>"); buffer.append(pageNum == 1 ? "��һҳ" : "<a href='" + url + "&pageNum=" + (pageNum - 1) + "'>��һҳ</a>"); buffer.append(pageNum == 1 ? "��һҳ" : "<a href='" + url + "&pageNum=" + (pageNum + 1) + "'>��һҳ</a>"); buffer.append(pageNum == pageCount ? "���һҳ" : "<a href='" + url + "&pageNum=" + (pageCount) + "'>���һҳ</a>"); buffer.append("<form method='post' name='myform' action=" + url + ""); buffer.append("<select name='pageNum'>"); for (int i = 0; i < pageCount - 1; i++) { buffer.append("<option vlaue=" + i + ">" + i + 1 + "</option>"); } buffer.append("</select>"); buffer.append("<input type='submit' name='sub' value='��ѯ' />"); buffer.append("</form>"); return buffer.toString(); } }
zzprojects
trunk/zzprojects/zzClub/src/util/Pageation.java
Java
asf20
1,256
package util; import java.io.File; import java.sql.*; import org.apache.commons.configuration.XMLConfiguration; /** * sqlserver数据库连接 * @author vsked * */ public class ConnectDB { private static Connection conn = null; private static PreparedStatement pt = null; private static ResultSet rs = null; private static boolean flag = false; private static String sql = ""; static Connection objconn=null; /** * 得到sqlserver数据库连接 * @return Connection * @throws Exception */ public static Connection getSqlServerConnection() throws Exception{ XMLConfiguration config = new XMLConfiguration(((new File(ConnectDB.class.getResource("/").getPath()).getPath()).replace("\\", "/")+"/DBConfig.xml").replace("%20", " ")); String type1=config.getString("type"); String driver1=config.getString("driver"); String address1=config.getString("address"); String port1=config.getString("port"); String database1=config.getString("database"); String userName1=config.getString("username"); String passWord1=config.getString("password"); Class.forName(driver1); return DriverManager.getConnection("jdbc:microsoft:sqlserver://"+address1+":"+port1+";databasename="+database1, userName1, passWord1); } public static Connection getSqlServerConnectionMas() throws Exception{ XMLConfiguration config = new XMLConfiguration(((new File(ConnectDB.class.getResource("/").getPath()).getPath()).replace("\\", "/")+"/DBConfig.xml").replace("%20", " ")); String type1=config.getString("type1"); String driver1=config.getString("driver1"); String address1=config.getString("address1"); String port1=config.getString("port1"); String database1=config.getString("database1"); String userName1=config.getString("username1"); String passWord1=config.getString("password1"); Class.forName(driver1); return DriverManager.getConnection("jdbc:microsoft:sqlserver://"+address1+":"+port1+";databasename="+database1, userName1, passWord1); } public static synchronized Connection getConn(String date) { try { Class.forName("net.sourceforge.jtds.jdbc.Driver"); objconn = DriverManager.getConnection("jdbc:jtds:sqlserver://127.0.0.1:1433;DatabaseName="+date,"CustomSMS","SqlMsde@InfoxEie2000"); } catch (Exception e) { e.printStackTrace(); } return objconn; } /** * 关闭数据库连接 */ public static void closeSqlConnection() { try { if (rs != null) { rs.close(); } if (pt != null) { pt.close(); } if (conn != null) { conn.close(); } } catch (Exception e) { e.printStackTrace(); } } public static void main(String[] args) throws Exception { System.out.println(ConnectDB.getSqlServerConnection()); }//end main }
zzprojects
trunk/zzprojects/zzClub/src/util/ConnectDB.java
Java
asf20
2,850
package util; import java.sql.Connection; import java.sql.PreparedStatement; import java.sql.ResultSet; import java.sql.SQLException; import java.sql.Statement; import java.util.List; import java.util.Random; public class TotalClass { /** *@author qingyu zhang *@function: *2011-4-4 *下午02:43:43 *zzClub *util */ // 数据库连接 private Connection conn = null; // st对象 private PreparedStatement pt = null; private Statement st = null; // 结果集 private ResultSet rs = null; // 成功失败标志 private boolean flag = false; // 要执行的语句 private String sql = ""; public ResultSet getResult(String sql){ try { pt = getConn().prepareStatement(sql); rs = pt.executeQuery(); } catch (SQLException e) { // TODO Auto-generated catch block e.printStackTrace(); }finally{ return rs; } } /** * *@author qingyu zhang *@function:when you add or delete or modify ref the method * @param sql * @return *2011-4-5 *下午03:59:49 *zzClub *util *boolean */ public boolean operatorObject(String sql){ boolean bo = false; conn = getConn(); try { pt = conn.prepareStatement(sql); bo = pt.execute(); bo = true; } catch (SQLException e) { // TODO Auto-generated catch block e.printStackTrace(); bo = false; } return bo ; } //得到数据库的连接 public Connection getConn(){ try { conn = ConnectDB.getSqlServerConnection(); } catch (Exception e) { // TODO Auto-generated catch block e.printStackTrace(); }finally{ ConnectDB.closeSqlConnection(); return conn; } } public Statement getStatement(){ try { st = getConn().createStatement(); } catch (SQLException e) { // TODO Auto-generated catch block e.printStackTrace(); }finally{ ConnectDB.closeSqlConnection(); return st; } } /** * *@author qingyu zhang *@function:得到一个六位数 * @return *2011-4-6 *下午03:55:15 *zzClub *util *String */ public static String getNum(){ String checkCodeStr=""; Random rd=new Random(); for(int i=0;i<6;i++){ checkCodeStr+=rd.nextInt(9); } return checkCodeStr; } }
zzprojects
trunk/zzprojects/zzClub/src/util/TotalClass.java
Java
asf20
2,288