1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834 |
- package com.minpay.mt.machine.action;
- import com.itextpdf.text.pdf.qrcode.WriterException;
- import com.min.util.CommonUtil;
- import com.minpay.common.bean.User;
- import com.minpay.common.constant.Constant;
- import com.minpay.common.format.IFormatService;
- import com.minpay.common.service.ILogService;
- import com.minpay.common.service.IPropertiesService;
- import com.minpay.common.service.IPublicService;
- import com.minpay.common.util.DateUtil;
- import com.minpay.common.util.UpLoadFile;
- import com.minpay.db.table.mapper.ImBranchMapper;
- import com.minpay.db.table.mapper.VmEquipmentInfMapper;
- import com.minpay.db.table.mapper.VmHlAccountMapper;
- import com.minpay.db.table.mapper.VmProEquRelMapper;
- import com.minpay.db.table.model.*;
- import com.minpay.db.table.own.mapper.MachineManageMapper;
- import com.minpay.huicai.util.EquCodeCreateUtil;
- import com.mysql.jdbc.StringUtils;
- import com.startup.minpay.frame.business.IMINAction;
- import com.startup.minpay.frame.business.res.MINActionResult;
- import com.startup.minpay.frame.constant.IMINBusinessConstant;
- import com.startup.minpay.frame.constant.IMINTransactionEnum;
- import com.startup.minpay.frame.data.format.MINCopyFormat;
- import com.startup.minpay.frame.exception.MINBusinessException;
- import com.startup.minpay.frame.jdbc.MINRowBounds;
- import com.startup.minpay.frame.service.base.IMINDataBaseService;
- import com.startup.minpay.frame.service.base.Service;
- import com.startup.minpay.frame.session.MINSession;
- import com.startup.minpay.frame.target.MINAction;
- import com.startup.minpay.frame.target.MINComponent;
- import com.startup.minpay.frame.target.MINParam;
- import org.apache.commons.fileupload.FileItem;
- import org.apache.commons.fileupload.FileItemFactory;
- import org.apache.commons.fileupload.disk.DiskFileItemFactory;
- import java.io.*;
- import java.util.HashMap;
- import java.util.List;
- import java.util.Map;
- import java.util.stream.Collectors;
- /**
- * 设备管理
- * @author pangjl
- * 20190325
- */
- @MINComponent
- public class MachineManageAction implements IMINAction {
- /**
- * 查看设备
- */
- public final static String QUERY_EQUMENT_INF = "queryEqumentInf";
- /**
- * 添加设备
- */
- public final static String ADD_PRODUCT_INF = "addMachine";
- /**
- * 修改设备
- */
- public final static String MODIFY_PRODUCT_INF = "modifyProductInf";
- /**
- * 更改设备状态
- */
- public final static String MODIFY_PRODUCT_STATE = "modifyProductState";
- /**
- * 查询设备中商品
- */
- public final static String QUERY_PROEQUREL = "queryProEquRel";
- /**
- * 查询设备中商品
- */
- public final static String QUERY_PROEQURELPAGE = "queryProEquRelPage";
- /**
- * 查看正常状态商品
- */
- public final static String QUERY_PRODUCTZ = "queryProductz";
- /**
- * 设备添加商品
- */
- public final static String ADD_PROEQUREL = "addProEquRel";
- /**
- * 修改设备商品
- */
- public final static String EDIT_PROEQUREL = "editProEquRel";
- /**
- * 查询编辑设备中商品
- */
- public final static String QUERY_PROEQU = "queryProEqu";
- /**
- * 删除货道
- */
- public final static String DEL_EQUPRO = "delEquPro";
- /**
- * 删除设备中商品
- */
- public final static String DEL_PROEQU = "delProEqu";
- /**
- * 查询设备列表
- */
- public final static String QUERY_EQUIPMENT_LINE = "queryEquipmentLine";
- /**
- * 多选设备复制商品
- */
- public final static String ADD_PROEQURELALL_COPY = "addProEquRelAllCopy";
- /**
- * 关闭音乐
- */
- public final static String CLOSE_SONG = "closeSong";
- /**一键补货*/
- public final static String ADD_PROEQUREL_NUM = "addProEquRelNum";
- /**一键设置商品价格*/
- public final static String EDIT_PROEQUREL_PRICE = "editProEquRelPrice";
- /** 生成包含字符串信息的二维码图片**/
- public static final String CREATE_QRCODE = "createQrCode";
- /**补货*/
- public final static String EDIT_PROEQUREL_NUM = "editProEquRelNum";
- /**解绑机台号*/
- public final static String DELETE_EQU = "deleteEqu";
- /**生成指定机器指定行列的货道*/
- public final static String ADD_PRO_EQU_REL = "addProEquRelLineRow";
- /**查询商户关联页面*/
- public final static String QUERY_FUNCTION = "queryFunction";
- /**清空累计金额*/
- public final static String EMPTY_PROEQUREL = "emptyProEquRel";
- /** 收款商户号信息查询 */
- public final static String TENCENTMANAGE_QUERY = "businessNumManageQuery";
- /** 商户号信息查询 */
- public final static String QUERY_BRANCH = "queryBranch";
- /** 绑定商户号 */
- public final static String BIND_BRANCH = "bindBranch";
- private boolean contains;
- /**
- * 查看设备
- *
- * @param createUser 添加人
- * @param page
- * @param limit
- * @return
- * @throws Exception
- */
- @MINAction(value = QUERY_EQUMENT_INF)
- public MINActionResult queryEqumentInf(
- @MINParam(key = "machineId") String machineId,
- @MINParam(key = "state") String state,
- @MINParam(key = "machineName") String machineName,
- @MINParam(key = "mchntId") String mchntId,
- @MINParam(key = "equType") String equType,
- @MINParam(key = "createUser") String createUser,
- @MINParam(key = "page", defaultValue = "1") int page,
- @MINParam(key = "limit", defaultValue = "3") int limit,
- MINSession session) throws Exception {
- MINActionResult res = new MINActionResult();
- User user = session.getUser();
- String passwardKey = Service.lookup(IPropertiesService.class)
- .getSystemProperties().get("WALLET_TO_METTING_PASSWORD_KEY").getKey();
- Map<String, String> map = new HashMap<String, String>();
- map.put("id", machineId);
- if(Constant.DEFAULT_INSTITUTIONS.equals( user.getBranchId())){
- map.put("mchntId", mchntId);
- }else{
- map.put("mchntId", user.getBranchId());
- }
- map.put("equType", equType);
- map.put("machineName", machineName);
- map.put("createUser", createUser);
- map.put("state", state);
- map.put("channel", user.getChannel());//渠道号
- //验证操作员权限
- MINRowBounds rows = new MINRowBounds(page, limit);
- //执行查询
- List<Map<String, String>> list = Service.lookup(IMINDataBaseService.class)
- .getMybatisMapper(MachineManageMapper.class)
- .machineInf(map, rows);
- List<Map<String, String>> listb = Service.lookup(IMINDataBaseService.class)
- .getMybatisMapper(MachineManageMapper.class)
- .machineInf(map);
- //在线数
- int online = listb.stream().filter(item -> item.get("state").equals("00")).collect(Collectors.toList()).size();
- int unOnline = listb.stream().filter(item -> item.get("state").equals("01")).collect(Collectors.toList()).size();
- //格式化时间和状态
- list = Service.lookup(IFormatService.class).formatDateTime(list, "createTime", "modifyTime");
- list = new MINCopyFormat("{state:'stateDesc',equType :'equTypeDesc'}").format(list);
- list = Service.lookup(IFormatService.class).formatEnum(list, "{stateDesc:'EQUIPMENT_STATE',equTypeDesc:'EQUIPMENT_TYPE'}");
- //返回数据
- res.set(IMINBusinessConstant.F_PAGING_LAY, list);
- res.set(IMINBusinessConstant.F_PAGING_COUNT, rows.getMaxRows());
- res.set("online",String.valueOf(online));
- res.set("unOnline",String.valueOf(unOnline));
- return res;
- }
- /**
- * 添加设备
- *
- * @param session
- * @return
- * @throws MINBusinessException
- */
- @MINAction(value = ADD_PRODUCT_INF, transaction = IMINTransactionEnum.CMT)
- public MINActionResult addMachine(
- @MINParam(key = "equCode") String equCode,
- @MINParam(key = "account") String account,
- @MINParam(key = "temLine") String temLine,
- @MINParam(key = "temRow") String temRow,
- MINSession session) throws MINBusinessException, IOException {
- MINActionResult res = new MINActionResult();
- //获取当前时间
- String nowTime = DateUtil.getCurrentDateTimeString();
- // 获取操作员信息
- User user = session.getUser();
- if (CommonUtil.isEmpty(equCode)) {
- throw new MINBusinessException("起始机台号为空");
- }
- if (CommonUtil.isEmpty(account)) {
- throw new MINBusinessException("生成数量为空");
- }
- if (CommonUtil.isEmpty(temLine)) {
- throw new MINBusinessException("生成货道行数量为空");
- }
- if (CommonUtil.isEmpty(temRow)) {
- throw new MINBusinessException("生成货道列数量为空");
- }
- int size = Integer.parseInt(account);
- VmEquipmentInfExample example = new VmEquipmentInfExample();
- example.createCriteria().andMachineNoEqualTo(equCode).andStateEqualTo("00");
- List<VmEquipmentInf> vmEquipmentInfList = Service.lookup(IMINDataBaseService.class)
- .getMybatisMapper(VmEquipmentInfMapper.class)
- .selectByExample(example);
- if (vmEquipmentInfList.size() > 0) {
- throw new MINBusinessException(equCode + "机台号已存在");
- }
- for (int j = 1; j < size; j++) {
- VmEquipmentInfExample examples = new VmEquipmentInfExample();
- examples.createCriteria().andMachineNoEqualTo(CommonUtil.add(equCode, String.valueOf(j))).andStateEqualTo("00");
- List<VmEquipmentInf> vmEquipmentInfLists = Service.lookup(IMINDataBaseService.class)
- .getMybatisMapper(VmEquipmentInfMapper.class)
- .selectByExample(examples);
- if (vmEquipmentInfLists.size() > 0) {
- throw new MINBusinessException(equCode + "机台号已存在");
- }
- }
- //获取当前用户信息
- User u = session.getUser();
- //获取用户id
- String userId = u.getBranchId();
- //开发环境修改配置
- String basePath = "/home/images/"+ userId+".jpg"; //与nginx配置相同
- String os = System.getProperty("os.name");
- if(os.toLowerCase().startsWith("win")){
- System.out.println(os + " can't gunzip");
- basePath = "D:/images/"+ userId+".jpg"; //与nginx配置相同
- }
- String id = Service.lookup(IPublicService.class).getSequence("EQU_MACHINE_NO");
- File file = new File(basePath);
- //获取父目录
- File fileParent = file.getParentFile();
- //判断是否存在
- if (!fileParent.exists()) {
- fileParent.mkdirs();
- }
- //获取渠道号
- String channel = "V01";
- // 加密客户号
- OutputStream outputStream = new FileOutputStream(file);
- String serviceUrl = Service.lookup(IPropertiesService.class)
- .getSystemProperties().get(channel+"_TO_MACHINE_ERWERMA").getKey();
- serviceUrl = "http://".concat(serviceUrl.concat("/admin/h5/index.html?equId=").concat(id));
- //String urlString = URLEncoder.encode(, "GBK");
- // 生成二维码图片到本地
- try {
- EquCodeCreateUtil.createQrCode(outputStream,serviceUrl,900,"JPEG");
- } catch (com.google.zxing.WriterException e) {
- // TODO Auto-generated catch block
- e.printStackTrace();
- }
- outputStream.close();
- // 上传图片到服务器
- InputStream inputSteam = new FileInputStream(file);
- String ambient = Service.lookup(IPublicService.class)
- .getSysParValue("AMBIENT");//当前环境
- FileItem fileItem = createFileItem(file ,"itemFileName");
- Map<String, Object> map = null;
- if("00".equals(ambient)){//测试
- map =Service.lookup(IPublicService.class).uploadFile(fileItem, "00", 0, true,"V01");
- }
- if("01".equals(ambient)){//生产
- map =Service.lookup(IPublicService.class).uploadFileBD(fileItem, "00", 0, true,"V01");
- }
- //String url = UpLoadFile.uploadImg(inputSteam,"jpg",channel,"00");
- String url = String.valueOf(map.get("url"));
- inputSteam.close();
- // 删除本地图片
- file.delete();
- VmEquipmentInf pro = new VmEquipmentInf();
- pro.setId(id);
- pro.setMachineNo(equCode);
- pro.setImeiAddr(equCode);
- pro.setChannel("V01");
- pro.setState("01");
- pro.setCreateUser(user.getId());
- pro.setCreateTime(nowTime);
- pro.setRows(temRow);
- pro.setLines(temLine);
- pro.setUrlCode(url);
- pro.setEquType("00"); //默认支付盒子售货机
- pro.setBranchid(Constant.DEFAULT_INSTITUTIONS);
- Service.lookup(IMINDataBaseService.class)
- .getMybatisMapper(VmEquipmentInfMapper.class)
- .insertSelective(pro);
- for (int i = 1; i < size; i++) {
- String ids = Service.lookup(IPublicService.class).getSequence("EQU_MACHINE_NO");
- serviceUrl = "http://".concat(serviceUrl.concat("/admin/h5/index.html?equId=").concat(ids));
- //String urlString = URLEncoder.encode(, "GBK");
- OutputStream outputStreams = new FileOutputStream(file);
- // 生成二维码图片到本地
- try {
- EquCodeCreateUtil.createQrCode(outputStreams,serviceUrl,900,"JPEG");
- } catch (com.google.zxing.WriterException e) {
- // TODO Auto-generated catch block
- e.printStackTrace();
- }
- outputStreams.close();
- InputStream inputSteams = new FileInputStream(file);
- FileItem fileItemb = createFileItem(file ,"itemFileName");
- Map<String, Object> mapb = null;
- if("00".equals(ambient)){//测试
- mapb =Service.lookup(IPublicService.class).uploadFile(fileItemb, "00", 0, true,"V01");
- }
- if("01".equals(ambient)){//生产
- mapb =Service.lookup(IPublicService.class).uploadFileBD(fileItemb, "00", 0, true,"V01");
- }
- //String url = UpLoadFile.uploadImg(inputSteam,"jpg",channel,"00");
- url = String.valueOf(mapb.get("url"));
- //url = UpLoadFile.uploadImg(inputSteams,"jpg",channel,"00");
- inputSteams.close();
- // 删除本地图片
- file.delete();
- VmEquipmentInf pros = new VmEquipmentInf();
- pros.setId(ids);
- pros.setChannel("V01");
- pros.setMachineNo(CommonUtil.add(equCode, String.valueOf(i)));
- pros.setImeiAddr(CommonUtil.add(equCode, String.valueOf(i)));
- pros.setState("01");
- pros.setCreateUser(user.getId());
- pros.setCreateTime(nowTime);
- pros.setRows(temRow);
- pros.setLines(temLine);
- pros.setUrlCode(url);
- pros.setBranchid(Constant.DEFAULT_INSTITUTIONS);
- Service.lookup(IMINDataBaseService.class)
- .getMybatisMapper(VmEquipmentInfMapper.class)
- .insertSelective(pros);
- }
- /*// 记录操作日志
- String logInfo = "操作员:" + user.getName() + "添加商品,商品编号:" + id;
- Service.lookup(ILogService.class).logging(session, logInfo);*/
- return res;
- }
- /**
- * 查询设备中商品
- *
- * @param session
- * @return
- * @throws MINBusinessException
- */
- @MINAction(value = QUERY_PROEQUREL)
- public MINActionResult queryProEquRel(
- @MINParam(key = "equId") String equId,
- MINSession session
- ) throws MINBusinessException {
- MINActionResult res = new MINActionResult();
- User user = session.getUser();
- //渠道
- String channel = user.getChannel();
- // 查询条件
- Map<String, String> map = new HashMap<String, String>();
- map.put("channel", "V01");
- map.put("equId", equId);
- List<Map<String, Object>> list = Service.lookup(IMINDataBaseService.class)
- .getMybatisMapper(MachineManageMapper.class)
- .queryProEquRel(map);
- //格式化时间和状态
- list = Service.lookup(IFormatService.class).formatDateTime(list, "createTime", "modifyTime");
- list = new MINCopyFormat("{perState:'sttDesc',isPromotton:'isPromottonDesc',isFragile:'isFragileDesc',type:'typeDesc'}").format(list);
- list = Service.lookup(IFormatService.class).formatEnum(list, "{sttDesc:'PROEQUREL_STATE',isPromottonDesc:'IS_PROMOTION',typeDesc:'GAME_SETUP_TYPE'}");
- //传递数据
- res.set(IMINBusinessConstant.F_PAGING_LAY, list);
- return res;
- }
- /**
- * 查看商品
- *
- * @param name 商品名称
- * @param brandName 品牌名称
- * @param model 商品型号
- * @param createUser 添加人
- * @param dates 添加时间
- * @param page
- * @param limit
- * @return
- * @throws MINBusinessException
- */
- @MINAction(value = QUERY_PRODUCTZ)
- public MINActionResult queryProductz(
- @MINParam(key = "name") String name,
- @MINParam(key = "model") String model,
- @MINParam(key = "dates") String dates,
- @MINParam(key = "state") String state,
- @MINParam(key = "brandName") String brandName,
- @MINParam(key = "categoryId") String categoryId,
- @MINParam(key = "createUser") String createUser,
- @MINParam(key = "page", defaultValue = "1") int page,
- @MINParam(key = "limit", defaultValue = "3") int limit,
- MINSession session) throws MINBusinessException {
- MINActionResult res = new MINActionResult();
- User user = session.getUser();
- Map<String, String> map = new HashMap<String, String>();
- //按商品名称,商品品牌进行模糊查询
- map.put("name", name); //商品名称
- map.put("state", state);//状态
- map.put("model", model);
- map.put("dates", dates);
- map.put("brandName", brandName);
- map.put("createUser", createUser);
- map.put("channel", "V01");//渠道号
- map.put("category", categoryId);//分类
- //验证操作员权限
- if ("00".equals(user.getIdentity())) {
- map.put("userId", user.getId());
- }
- /* if("10000002".equals(user.getRoleId())){
- map.put("userId",user.getId());
- }*/
- //分页
- MINRowBounds rows = new MINRowBounds(page, limit);
- //执行查询
- List<Map<String, String>> list = Service.lookup(IMINDataBaseService.class)
- .getMybatisMapper(MachineManageMapper.class)
- .queryProductz(map, rows);
- //格式化时间和状态
- list = Service.lookup(IFormatService.class).formatDateTime(list, "createTime", "modifyTime");
- list = new MINCopyFormat("{history:'historyDesc',state:'stateDesc',source:'sourceDesc'}").format(list);
- list = Service.lookup(IFormatService.class).formatEnum(list, "{historyDesc:'PRODUCT_HISTORY',stateDesc:'PRODUCT_STATE',sourceDesc:'PRODUCT_SOURCE'}");
- //返回数据
- res.set(IMINBusinessConstant.F_PAGING_LAY, list);
- res.set(IMINBusinessConstant.F_PAGING_COUNT, rows.getMaxRows());
- return res;
- }
- /**
- * 设备添加商品
- *
- * @param perRow 货道层
- * @param perLine 货道列
- * @param perNum 货道容量
- * @param numbers 商品余量
- * @param sallPrice 售货价
- * @param gamePrice 游戏价
- * @param costPrice 成本价
- * @param isPromotton 是否促销
- * @param promottonPrice 促销价
- * @param isFragile 是否易碎
- * @param perRemarks 备注
- * @param proId 商品id
- * @param equId 设备id
- * @param session
- * @return
- * @throws MINBusinessException
- */
- @MINAction(value = ADD_PROEQUREL)
- public MINActionResult addProEquRel(
- @MINParam(key = "aisle") String aisle,
- @MINParam(key = "perRow") String perRow,
- @MINParam(key = "perLine") String perLine,
- @MINParam(key = "perNum") String perNum,
- @MINParam(key = "numbers") String numbers,
- @MINParam(key = "sallPrice") String sallPrice,
- @MINParam(key = "gamePrice") String gamePrice,
- @MINParam(key = "costPrice") String costPrice,
- @MINParam(key = "isPromotton") String isPromotton,
- @MINParam(key = "promottonPrice") String promottonPrice,
- @MINParam(key = "type") String type,
- @MINParam(key = "isFragile") String isFragile,
- @MINParam(key = "perRemarks") String perRemarks,
- @MINParam(key = "proId") String proId,
- @MINParam(key = "equId") String equId,
- @MINParam(key = "luck") String luck,
- @MINParam(key = "drawAmount") String drawAmount,
- MINSession session
- ) throws MINBusinessException {
- MINActionResult res = new MINActionResult();
- //当前时间
- String dateTime = DateUtil.getCurrentDateTimeString();
- User user = session.getUser();
- //操作员id
- String uId = user.getId();
- //渠道
- String channel = user.getChannel();
- //校验设备是否正常
- VmEquipmentInf equipmentInf = Service.lookup(IMINDataBaseService.class)
- .getMybatisMapper(VmEquipmentInfMapper.class)
- .selectByPrimaryKey(equId);
- if (equipmentInf == null) {
- throw new MINBusinessException("该设备不存在!");
- } else if (equipmentInf.getState().equals("03")) {
- throw new MINBusinessException("该设备已销毁!");
- }
- int comcosAndsal = CommonUtil.compare(costPrice, sallPrice);
- /* int comcosAndgam = CommonUtil.compare(costPrice, gamePrice);
- int comgamAndsal = CommonUtil.compare(gamePrice, sallPrice);*/
- /* int comcosAndpro = CommonUtil.compare(costPrice, promottonPrice);*/
- int comproAndsal = CommonUtil.compare(promottonPrice, sallPrice);
- int comnumAndper = CommonUtil.compare(numbers, perNum);
- if (comcosAndsal == 1 || comcosAndsal == 0) {
- throw new MINBusinessException("成本价不能大于或等于售货价!");
- }
- /* if (comcosAndgam == 1 || comcosAndgam == 0) {
- throw new MINBusinessException("成本价不能大于或等于游戏价!");
- }
- if (comgamAndsal == 1 || comgamAndsal == 0) {
- throw new MINBusinessException("游戏价不能大于或等于售货价!");
- }*/
- /*if (comcosAndpro == 1 || comcosAndpro == 0) {
- throw new MINBusinessException("成本价不能大于或等于促销价!");
- }*/
- if (comproAndsal == 1 || comproAndsal == 0) {
- throw new MINBusinessException("促销价不能大于或等于售货价!");
- }
- if (comnumAndper == 1) {
- throw new MINBusinessException("商品余量不能大于货道容量!");
- }
- //校验商品是否正常
- // VmProductInf pro = Service.lookup(IMINDataBaseService.class)
- // .getMybatisMapper(VmProductInfMapper.class)
- // .selectByPrimaryKey(proId);
- // if(pro == null||pro.getState().equals("2")) {
- // throw new BusinessCodeException("JINM0123");//商品信息异常
- // }
- //设备新增商品
- String id = Service.lookup(IPublicService.class).getSequence("VM_PROEQUREL_ID");
- VmProEquRel proEquRel = new VmProEquRel();
- proEquRel.setId(id); //设备商品关联表id
- proEquRel.setProductId(proId); //商品id
- proEquRel.setEquipmentId(equId); //设备id
- VmProEquRelExample example = new VmProEquRelExample();
- if (CommonUtil.isEmpty(aisle)) {
- example.createCriteria().andChannelEqualTo(channel)
- .andEquipmentIdEqualTo(equId)
- .andAisleEqualTo(perRow.concat(perLine))
- .andExeitStateEqualTo("00");
- List<VmProEquRel> list = Service.lookup(IMINDataBaseService.class)
- .getMybatisMapper(VmProEquRelMapper.class)
- .selectByExample(example);
- if (list.size() != 0) {
- throw new MINBusinessException("该设备默认货道指令已被使用!");
- }
- proEquRel.setAisle(perRow.concat(perLine)); //货道指令
- } else {
- example.createCriteria().andChannelEqualTo(channel)
- .andEquipmentIdEqualTo(equId)
- .andAisleEqualTo(aisle)
- .andExeitStateEqualTo("00");
- List<VmProEquRel> list = Service.lookup(IMINDataBaseService.class)
- .getMybatisMapper(VmProEquRelMapper.class)
- .selectByExample(example);
- if (list.size() != 0) {
- throw new MINBusinessException("该设备货道指令已使用!");
- }
- proEquRel.setAisle(aisle); //货道指令
- }
- proEquRel.setCargoWayRow(perRow); //货道层
- proEquRel.setCargoWayLine(perLine); //货道列
- proEquRel.setCargoWayNums(perNum); //货道容量
- proEquRel.setProductNums(numbers); //商品余量
- proEquRel.setSallPrice(sallPrice); //售货价
- if (!CommonUtil.isEmpty(gamePrice)) {
- proEquRel.setGamePrice(gamePrice); //游戏价
- }else {
- proEquRel.setGamePrice("0");
- }
- proEquRel.setCostPrice(costPrice); //成本价
- proEquRel.setIsPromotion(isPromotton); //是否促销
- if (!CommonUtil.isEmpty(promottonPrice)) {
- proEquRel.setPromotionPrice(promottonPrice); //促销价
- }else {
- proEquRel.setPromotionPrice("0");
- }
- /* proEquRel.setIsFragile(isFragile); //是否易碎
- */
- proEquRel.setUserId(uId); //商户id
- proEquRel.setRemarks(perRemarks); //备注
- proEquRel.setGameType(type); //游戏类型
- proEquRel.setChannel(channel); //渠道
- proEquRel.setCreateUser(uId); //创建人
- proEquRel.setCreateTime(dateTime); //创建时间
- proEquRel.setModifyUser(uId); //最后修改人
- proEquRel.setModifyTime(dateTime); //最后修改时间
- proEquRel.setExeitState("00"); //状态 00正常
- if (!CommonUtil.isEmpty(drawAmount)) {
- proEquRel.setDrawAmount(drawAmount);
- }
- Service.lookup(IMINDataBaseService.class)
- .getMybatisMapper(VmProEquRelMapper.class)
- .insertSelective(proEquRel);
- return res;
- }
- /**
- * 修改设备商品
- *
- * @param perId 设备商品关联id
- * @param perRow 货道层
- * @param perLine 货道列
- * @param perNum 货道容量
- * @param numbers 商品余量
- * @param sallPrice 售货价
- * @param gamePrice 游戏价
- * @param costPrice 成本价
- * @param isPromotton 是否促销
- * @param promottonPrice 促销价
- * @param isFragile 是否易碎
- * @param perRemarks 备注
- * @param proId 商品id
- * @param equId 设备id
- * @param perState 状态
- * @param session
- * @return
- * @throws MINBusinessException
- */
- @MINAction(value = EDIT_PROEQUREL)
- public MINActionResult editProEquRel(
- @MINParam(key = "perId") String perId,
- @MINParam(key = "aisle") String aisle,
- @MINParam(key = "perRow") String perRow,
- @MINParam(key = "perLine") String perLine,
- @MINParam(key = "perNum") String perNum,
- @MINParam(key = "numbers") String numbers,
- @MINParam(key = "sallPrice") String sallPrice,
- @MINParam(key = "gamePrice") String gamePrice,
- @MINParam(key = "costPrice") String costPrice,
- @MINParam(key = "type") String type,
- @MINParam(key = "isPromotton") String isPromotton,
- @MINParam(key = "promottonPrice") String promottonPrice,
- @MINParam(key = "isFragile") String isFragile,
- @MINParam(key = "perRemarks") String perRemarks,
- @MINParam(key = "proId") String proId,
- @MINParam(key = "equId") String equId,
- @MINParam(key = "perState") String perState,
- @MINParam(key = "luck") String luck,
- @MINParam(key = "accumulatedAmount") String accumulatedAmount,
- @MINParam(key = "drawAmount") String drawAmount,
- MINSession session
- ) throws MINBusinessException {
- MINActionResult res = new MINActionResult();
- //当前时间
- String dateTime = DateUtil.getCurrentDateTimeString();
- User user = session.getUser();
- //操作员id
- String uId = user.getId();
- //渠道
- String channel = user.getChannel();
- //校验设备是否正常
- VmEquipmentInf equipmentInf = Service.lookup(IMINDataBaseService.class)
- .getMybatisMapper(VmEquipmentInfMapper.class)
- .selectByPrimaryKey(equId);
- if (equipmentInf == null) {
- throw new MINBusinessException("该设备不存在!");
- } else if (equipmentInf.getState().equals(Constant.EQUIPMENT_STT_03)) {
- throw new MINBusinessException("该设备已销毁!");
- }
- int comcosAndsal = CommonUtil.compare(costPrice, sallPrice);
- /* int comcosAndgam = CommonUtil.compare(costPrice, gamePrice);
- int comgamAndsal = CommonUtil.compare(gamePrice, sallPrice);*/
- // int comcosAndpro = CommonUtil.compare(costPrice, promottonPrice);
- int comproAndsal = CommonUtil.compare(promottonPrice, sallPrice);
- int comnumAndper = CommonUtil.compare(numbers, perNum);
- if (comcosAndsal == 1 || comcosAndsal == 0) {
- throw new MINBusinessException("成本价不能大于或等于售货价!");
- }
- /*if (comcosAndgam == 1 || comcosAndgam == 0) {
- throw new MINBusinessException("成本价不能大于或等于游戏价!");
- }
- if (comgamAndsal == 1 || comgamAndsal == 0) {
- throw new MINBusinessException("游戏价不能大于或等于售货价!");
- }*/
- // if (comcosAndpro == 1 || comcosAndpro == 0) {
- // throw new MINBusinessException("成本价不能大于或等于促销价!");
- // }
- if (comproAndsal == 1 || comproAndsal == 0) {
- throw new MINBusinessException("促销价不能大于或等于售货价!");
- }
- if (comnumAndper == 1) {
- throw new MINBusinessException("商品余量不能大于货道容量!");
- }
- //校验商品是否正常
- // VmProductInf pro = Service.lookup(IMINDataBaseService.class)
- // .getMybatisMapper(VmProductInfMapper.class)
- // .selectByPrimaryKey(proId);
- VmProEquRel proEquRel = Service.lookup(IMINDataBaseService.class)
- .getMybatisMapper(VmProEquRelMapper.class)
- .selectByPrimaryKey(perId);
- // if(pro == null||pro.getState().equals("2")||proEquRel == null||proEquRel.getExeitState().equals("2")) {
- // throw new BusinessCodeException("JINM0123");//商品信息异常
- // }
- //修改设备新增商品
- if (!CommonUtil.isEmpty(proId)) {
- proEquRel.setProductId(proId); //商品id
- }
- if (!CommonUtil.isEmpty(equId)) {
- proEquRel.setEquipmentId(equId); //设备id
- }
- if (!CommonUtil.isEmpty(aisle)) {
- VmProEquRelExample example = new VmProEquRelExample();
- example.createCriteria().andChannelEqualTo(channel)
- .andEquipmentIdEqualTo(equId)
- .andAisleEqualTo(aisle)
- .andExeitStateEqualTo(Constant.PROEQUREL_STT_00)
- .andIdNotEqualTo(perId);
- List<VmProEquRel> list = Service.lookup(IMINDataBaseService.class)
- .getMybatisMapper(VmProEquRelMapper.class)
- .selectByExample(example);
- if (list.size() != 0) {
- throw new MINBusinessException("该设备货道指令已使用!");
- }
- proEquRel.setAisle(aisle); //货道指令
- }
- if (!CommonUtil.isEmpty(perRow)) {
- proEquRel.setCargoWayRow(perRow); //货道层
- }
- if (!CommonUtil.isEmpty(perLine)) {
- proEquRel.setCargoWayLine(perLine); //货道列
- }
- if (!CommonUtil.isEmpty(perNum)) {
- proEquRel.setCargoWayNums(perNum); //货道容量
- }
- if (!CommonUtil.isEmpty(numbers)) {
- proEquRel.setProductNums(numbers); //商品余量
- }
- if (!CommonUtil.isEmpty(sallPrice)) {
- proEquRel.setSallPrice(sallPrice); //售货价
- }
- if (!CommonUtil.isEmpty(gamePrice)) {
- proEquRel.setGamePrice(gamePrice); //游戏价
- }else{
- proEquRel.setGamePrice("0");
- }
- if (!CommonUtil.isEmpty(costPrice)) {
- proEquRel.setCostPrice(costPrice); //成本价
- }
- if (!CommonUtil.isEmpty(isPromotton)) {
- proEquRel.setIsPromotion(isPromotton); //是否促销
- }
- if (!CommonUtil.isEmpty(promottonPrice)) {
- proEquRel.setPromotionPrice(promottonPrice); //促销价
- }else {
- proEquRel.setPromotionPrice("0");
- }
- /*if(!CommonUtil.isEmpty(isFragile)){
- proEquRel.setIsFragile(isFragile); //是否易碎
- }*/
- if (!CommonUtil.isEmpty(perRemarks)) {
- proEquRel.setRemarks(perRemarks); //备注
- }
- proEquRel.setGameType(type); //游戏类型
- proEquRel.setModifyUser(uId); //最后修改人
- proEquRel.setModifyTime(dateTime); //最后修改时间
- if (!CommonUtil.isEmpty(perState)) {
- proEquRel.setExeitState(perState); //状态
- }
- if (!CommonUtil.isEmpty(drawAmount)) {
- proEquRel.setDrawAmount(drawAmount);
- }
- proEquRel.setAccumulatedAmount("0");
- Service.lookup(IMINDataBaseService.class)
- .getMybatisMapper(VmProEquRelMapper.class)
- .updateByPrimaryKeySelective(proEquRel);
- return res;
- }
- /**
- * 查询设备中商品
- *
- * @param session
- * @return
- * @throws MINBusinessException
- */
- @MINAction(value = QUERY_PROEQU)
- public MINActionResult queryProEqu(
- @MINParam(key = "equId") String equId,
- @MINParam(key = "perId") String perId,
- MINSession session
- ) throws MINBusinessException {
- MINActionResult res = new MINActionResult();
- User user = session.getUser();
- //渠道
- String channel = user.getChannel();
- // 查询条件
- Map<String, String> map = new HashMap<String, String>();
- map.put("channel", "V01");
- map.put("equId", equId);
- map.put("perId", perId);
- List<Map<String, Object>> list = Service.lookup(IMINDataBaseService.class)
- .getMybatisMapper(MachineManageMapper.class)
- .queryProEquRel(map);
- //格式化时间和状态
- list = Service.lookup(IFormatService.class).formatDateTime(list, "createTime", "modifyTime");
- list = new MINCopyFormat("{perState:'sttDesc',isPromotton:'isPromottonDesc',isFragile:'isFragileDesc'}").format(list);
- list = Service.lookup(IFormatService.class).formatEnum(list, "{sttDesc:'PROEQUREL_STATE',isPromottonDesc:'IS_PROMOTION',isFragileDesc:'IS_FRAGILE'}");
- //传递数据
- res.set(IMINBusinessConstant.F_PAGING_LAY, list);
- return res;
- }
- /**
- * 删除货道
- *
- * @param equId 设备id
- * @param perState 状态
- * @param session
- * @return
- * @throws MINBusinessException
- */
- @MINAction(value = DEL_EQUPRO)
- public MINActionResult delEquPro(
- @MINParam(key = "equId") String equId,
- @MINParam(key = "perRow") String perRow,
- @MINParam(key = "perLine") String perLine,
- @MINParam(key = "perState") String perState,
- MINSession session
- ) throws MINBusinessException {
- MINActionResult res = new MINActionResult();
- //当前时间
- String dateTime = DateUtil.getCurrentDateTimeString();
- User user = session.getUser();
- //操作员id
- String uId = user.getId();
- //渠道
- String channel = user.getChannel();
- //校验设备是否正常
- VmEquipmentInf equipmentInf = Service.lookup(IMINDataBaseService.class)
- .getMybatisMapper(VmEquipmentInfMapper.class)
- .selectByPrimaryKey(equId);
- if (equipmentInf == null) {
- throw new MINBusinessException("该设备不存在!");
- } else if (equipmentInf.getState().equals(Constant.EQUIPMENT_STT_03)) {
- throw new MINBusinessException("该设备已销毁!");
- }
- VmProEquRelExample equRelExample = new VmProEquRelExample();
- equRelExample.createCriteria().andEquipmentIdEqualTo(equId)
- .andCargoWayRowEqualTo(perRow)
- .andCargoWayLineEqualTo(perLine)
- .andChannelEqualTo(channel)
- .andExeitStateNotEqualTo(Constant.PROEQUREL_STT_02);
- List<VmProEquRel> list = Service.lookup(IMINDataBaseService.class)
- .getMybatisMapper(VmProEquRelMapper.class)
- .selectByExample(equRelExample);
- if (list.size() != 0) {
- throw new MINBusinessException("此货道无法删除!");
- }
- //删除货道
- String id = Service.lookup(IPublicService.class).getSequence("VM_PROEQUREL_ID");
- VmProEquRel proEquRel = new VmProEquRel();
- proEquRel.setId(id); //设备商品关联表id
- proEquRel.setEquipmentId(equId); //设备id
- proEquRel.setCargoWayRow(perRow); //货道层
- proEquRel.setCargoWayLine(perLine); //货道列
- proEquRel.setUserId(uId); //商户id
- proEquRel.setRemarks("货道删除"); //备注
- proEquRel.setChannel(channel); //渠道
- proEquRel.setCreateUser(uId); //创建人
- proEquRel.setCreateTime(dateTime); //创建时间
- proEquRel.setModifyUser(uId); //最后修改人
- proEquRel.setModifyTime(dateTime); //最后修改时间
- proEquRel.setExeitState(Constant.PROEQUREL_STT_01); //状态 01货道删除
- Service.lookup(IMINDataBaseService.class)
- .getMybatisMapper(VmProEquRelMapper.class)
- .insertSelective(proEquRel);
- return res;
- }
- /**
- * 删除
- *
- * @param perId 设备商品关联id
- * @param perState 状态
- * @param session
- * @return
- * @throws MINBusinessException
- */
- @MINAction(value = DEL_PROEQU)
- public MINActionResult delProEqu(
- @MINParam(key = "perId") String perId,
- @MINParam(key = "perState") String perState,
- MINSession session
- ) throws MINBusinessException {
- MINActionResult res = new MINActionResult();
- //当前时间
- String dateTime = DateUtil.getCurrentDateTimeString();
- User user = session.getUser();
- //操作员id
- String uId = user.getId();
- //渠道
- // String channel = user.getChannel();
- //校验设备是否正常
- /*VmEquipmentInf equipmentInf = Service.lookup(IMINDataBaseService.class)
- .getMybatisMapper(VmEquipmentInfMapper.class)
- .selectByPrimaryKey(equId);
- if(equipmentInf == null){
- throw new MINBusinessException("该设备不存在!");
- }else if(equipmentInf.getState().equals(Constant.EQUIPMENT_STT_03)){
- throw new MINBusinessException("该设备已销毁!");
- }
- */
- VmProEquRel proEquRel = Service.lookup(IMINDataBaseService.class)
- .getMybatisMapper(VmProEquRelMapper.class)
- .selectByPrimaryKey(perId);
- //删除
- proEquRel.setId(perId);
- proEquRel.setExeitState(Constant.PROEQUREL_STT_02); //状态
- proEquRel.setModifyUser(uId); //最后修改人
- proEquRel.setModifyTime(dateTime); //最后修改时间
- Service.lookup(IMINDataBaseService.class)
- .getMybatisMapper(VmProEquRelMapper.class)
- .updateByPrimaryKeySelective(proEquRel);
- return res;
- }
- /**
- * 查询设备列表
- *
- * @param equName 设备名称
- * @param equState 状态
- * @param session
- * @return
- * @throws MINBusinessException
- */
- @MINAction(value = QUERY_EQUIPMENT_LINE)
- public MINActionResult queryEquipmentLine(
- @MINParam(key = "equName") String equName,
- @MINParam(key = "machineNo") String machineNo,
- @MINParam(key = "temId") String temId,
- @MINParam(key = "userName") String userName,
- @MINParam(key = "dates") String dates,
- @MINParam(key = "equState") String equState,
- @MINParam(key = "machineNomax") String machineNomax,
- @MINParam(key = "machineNomin") String machineNomin,
- @MINParam(key = "page", defaultValue = "1") int page,
- @MINParam(key = "limit", defaultValue = "10") int limit,
- MINSession session
- ) throws MINBusinessException {
- MINActionResult res = new MINActionResult();
- MINRowBounds rows = new MINRowBounds(page, limit);
- User user = session.getUser();
- //操作员id
- String uId = user.getId();
- //渠道
- String channel = user.getChannel();
- // 查询条件
- Map<String, String> map = new HashMap<String, String>();
- map.put("channel", "V01");
- map.put("equName", equName);
- map.put("equState", equState);
- map.put("temId", temId);
- map.put("userName", userName);
- map.put("dates", dates);
- map.put("machineNo", machineNo);
- map.put("machineNomax", machineNomax);
- map.put("machineNomin", machineNomin);
- // if(user.getRoleId().equals("10000002")){
- // map.put("userId", uId);
- // }
- if (user.getIdentity().equals("00")) {
- map.put("userId", uId);
- } else if (user.getIdentity().equals("91")) {
- map.put("agentId", uId);
- }
- List<Map<String, Object>> list = Service.lookup(IMINDataBaseService.class)
- .getMybatisMapper(MachineManageMapper.class)
- .queryEquipment(map, rows);
- //格式化时间和状态
- list = Service.lookup(IFormatService.class).formatDateTime(list, "createTime", "modifyTime");
- list = new MINCopyFormat("{equState:'sttDesc',type:'typeDesc'}").format(list);
- list = Service.lookup(IFormatService.class).formatEnum(list, "{sttDesc:'EQUIPMENT_STATE','typeDesc':'GAME_TYPE'}");
- //传递数据
- res.set(IMINBusinessConstant.F_PAGING_LAY, list);
- res.set(IMINBusinessConstant.F_PAGING_COUNT, rows.getMaxRows());
- return res;
- }
- /**
- * 多选设备复制商品
- *
- * @param equId 设备id
- * @param copyEquId 复制设备id
- * @param session
- * @return
- * @throws MINBusinessException
- */
- @MINAction(value = ADD_PROEQURELALL_COPY, transaction = IMINTransactionEnum.CMT)
- public MINActionResult addProEquRelAllCopy(
- @MINParam(key = "equId") String equId,
- @MINParam(key = "copyEquId") String copyEquId,
- MINSession session
- ) throws MINBusinessException {
- MINActionResult res = new MINActionResult();
- if (equId.indexOf(copyEquId) != -1) {
- throw new MINBusinessException("不能选择相同设备!");
- }
- String[] equIdArr = equId.split(",");
- for (int i = 0; i < equIdArr.length; i++) {
- //当前时间
- String dateTime = DateUtil.getCurrentDateTimeString();
- User user = session.getUser();
- //操作员id
- String userId = user.getId();
- //渠道
- String channel = "V01";
- //校验设备是否正常
- VmEquipmentInf equipmentInf = Service.lookup(IMINDataBaseService.class)
- .getMybatisMapper(VmEquipmentInfMapper.class)
- .selectByPrimaryKey(equIdArr[i]);
- if (equipmentInf == null) {
- throw new MINBusinessException("该设备不存在!");
- } else if (equipmentInf.getState().equals(Constant.EQUIPMENT_STT_03)) {
- throw new MINBusinessException("该设备已销毁!");
- }
- //查询设备中原有的商品
- VmProEquRelExample proEquRelExample = new VmProEquRelExample();
- proEquRelExample.createCriteria().andEquipmentIdEqualTo(equIdArr[i])
- .andChannelEqualTo(channel)
- .andExeitStateEqualTo(Constant.PROEQUREL_STT_00);
- List<VmProEquRel> list = Service.lookup(IMINDataBaseService.class)
- .getMybatisMapper(VmProEquRelMapper.class)
- .selectByExample(proEquRelExample);
- for (int j = 0; i < list.size(); j++) {
- VmProEquRel equRel = list.get(j);
- //设备新增商品
- equRel.setExeitState(Constant.PROEQUREL_STT_02); //状态
- equRel.setModifyUser(userId); //最后修改人
- equRel.setModifyTime(dateTime); //最后修改时间
- Service.lookup(IMINDataBaseService.class)
- .getMybatisMapper(VmProEquRelMapper.class)
- .updateByPrimaryKeySelective(equRel);
- }
- //查询设备中的商品
- VmProEquRelExample proEquRelExample2 = new VmProEquRelExample();
- proEquRelExample2.createCriteria().andEquipmentIdEqualTo(copyEquId)
- .andChannelEqualTo(channel)
- .andExeitStateEqualTo(Constant.PROEQUREL_STT_00);
- List<VmProEquRel> list2 = Service.lookup(IMINDataBaseService.class)
- .getMybatisMapper(VmProEquRelMapper.class)
- .selectByExample(proEquRelExample2);
- for (int j = 0; j < list2.size(); j++) {
- VmProEquRel equRel2 = list2.get(j);
- //设备新增商品
- String id = Service.lookup(IPublicService.class).getSequence("VM_PROEQUREL_ID");
- equRel2.setId(id); //设备商品关联id
- equRel2.setEquipmentId(equIdArr[i]); //设备id
- equRel2.setCreateUser(userId); //创建人
- equRel2.setCreateTime(dateTime); //创建时间
- equRel2.setModifyUser(userId); //最后修改人
- equRel2.setModifyTime(dateTime); //最后修改时间
- Service.lookup(IMINDataBaseService.class)
- .getMybatisMapper(VmProEquRelMapper.class)
- .insertSelective(equRel2);
- }
- }
- return res;
- }
- /**
- * 编辑设备
- *
- * @param session
- * @return
- * @throws MINBusinessException
- */
- @MINAction(value = MODIFY_PRODUCT_INF, transaction = IMINTransactionEnum.CMT)
- public MINActionResult modifyProductInf(
- @MINParam(key = "id") String id,
- @MINParam(key = "name") String name,
- @MINParam(key = "ioiServicePrivider") String ioiServicePrivider,
- @MINParam(key = "ioiCardNumber") String ioiCardNumber,
- @MINParam(key = "address") String address,
- @MINParam(key = "versionType") String versionType,
- @MINParam(key = "equType") String equType,
- @MINParam(key = "wcAccount") String wcAccount,
- @MINParam(key = "zfbAccount") String zfbAccount,
- @MINParam(key = "charge") String charge,
- @MINParam(key = "payeeNo") String payeeNo,
- @MINParam(key = "creditChannel") String creditChannel,
- @MINParam(key = "payment") String payment,
- @MINParam(key = "paymentType") String paymentType,
- @MINParam(key = "exchangeRate") String exchangeRate,
- @MINParam(key = "supportBalance") String supportBalance,
- MINSession session) throws MINBusinessException {
- MINActionResult res = new MINActionResult();
- //获取当前时间
- String nowTime = DateUtil.getCurrentDateTimeString();
- // 获取操作员信息
- User user = session.getUser();
- VmEquipmentInf pro = new VmEquipmentInf();
- pro.setId(id);
- if (CommonUtil.isEmpty(name)){
- pro.setName("无人售货机");
- }else{
- pro.setName(name);
- }
- pro.setIotCardNumber(ioiCardNumber);
- pro.setIotServiceProvider(ioiServicePrivider);
- pro.setModifyUser(user.getId());
- pro.setModifyTime(nowTime);
- pro.setAddress(address);
- if(!CommonUtil.isEmpty(equType)){
- pro.setEquType(equType);
- }
- pro.setWcAccount(wcAccount);
- pro.setZfbAccount(zfbAccount);
- pro.setCharge(charge);
- pro.setPayeeNo(payeeNo);
- pro.setCreditChannel(creditChannel);
- pro.setPayment(payment);
- pro.setVersionType(versionType);
- pro.setPaymentType(paymentType);
- pro.setExchangeRate(exchangeRate);
- pro.setSupportBalance(supportBalance);
- pro.setModifyUser(user.getId());
- pro.setModifyTime(nowTime);
- Service.lookup(IMINDataBaseService.class)
- .getMybatisMapper(VmEquipmentInfMapper.class)
- .updateByPrimaryKeySelective(pro);
- /*// 记录操作日志
- String logInfo = "操作员:" + user.getName() + "添加商品,商品编号:" + id;
- Service.lookup(ILogService.class).logging(session, logInfo);*/
- return res;
- }
- /**
- * 开启/关闭音乐
- *
- * @param id 机器id
- * @return
- * @throws Exception
- */
- @MINAction(value = CLOSE_SONG)
- public MINActionResult closeSong(
- @MINParam(key = "id") String id,
- @MINParam(key = "status") String status,
- MINSession session) throws Exception {
- MINActionResult res = new MINActionResult();
- User user = session.getUser();
- if (CommonUtil.isEmpty(id)){
- throw new MINBusinessException("机器id上送为空!");
- }
- //校验设备是否正常
- VmEquipmentInf equipmentInf = Service.lookup(IMINDataBaseService.class)
- .getMybatisMapper(VmEquipmentInfMapper.class)
- .selectByPrimaryKey(id);
- if (equipmentInf == null) {
- throw new MINBusinessException("该设备不存在!");
- } else if (equipmentInf.getState().equals(Constant.EQUIPMENT_STT_03)) {
- throw new MINBusinessException("该设备已销毁!");
- }
- VmEquipmentInf pro = new VmEquipmentInf();
- pro.setId(id);
- pro.setSongStatus(status);//关闭
- Service.lookup(IMINDataBaseService.class)
- .getMybatisMapper(VmEquipmentInfMapper.class)
- .updateByPrimaryKeySelective(pro);
- return res;
- }
- /**
- * 一键补货
- * @param equId 设备id
- * @param session
- * @return
- * @throws MINBusinessException
- */
- @MINAction(value = ADD_PROEQUREL_NUM, transaction = IMINTransactionEnum.CMT)
- public MINActionResult addProEquRelNum(
- @MINParam(key = "equId") String equId,
- @MINParam(key = "proNum") String proNum,
- @MINParam(key = "proState") String proState,
- MINSession session
- ) throws MINBusinessException {
- MINActionResult res = new MINActionResult();
- //当前时间
- String dateTime = DateUtil.getCurrentDateTimeString();
- User user = session.getUser();
- //操作员id
- String userId = user.getId();
- //渠道
- String channel = user.getChannel();
- //校验设备是否正常
- VmEquipmentInf equipmentInf = Service.lookup(IMINDataBaseService.class)
- .getMybatisMapper(VmEquipmentInfMapper.class)
- .selectByPrimaryKey(equId);
- if(equipmentInf == null){
- throw new MINBusinessException("该设备不存在!");
- }else if(equipmentInf.getState().equals(Constant.EQUIPMENT_STT_03)){
- throw new MINBusinessException("该设备已销毁!");
- }
- //查询设备中的商品
- VmProEquRelExample proEquRelExample = new VmProEquRelExample();
- proEquRelExample.createCriteria().andEquipmentIdEqualTo(equId)
- .andChannelEqualTo("V01")
- .andExeitStateEqualTo(Constant.PROEQUREL_STT_00);
- List<VmProEquRel> list2 = Service.lookup(IMINDataBaseService.class)
- .getMybatisMapper(VmProEquRelMapper.class)
- .selectByExample(proEquRelExample);
- for (int i = 0; i < list2.size(); i++) {
- VmProEquRel equRel = list2.get(i);
- if(proState.equals("222")) {
- equRel.setProductNums(equRel.getCargoWayNums()); //商品余量修改为货道容量
- }else{
- equRel.setProductNums(proNum);
- }
- equRel.setModifyUser(userId); //最后修改人
- equRel.setModifyTime(dateTime); //最后修改时间
- Service.lookup(IMINDataBaseService.class)
- .getMybatisMapper(VmProEquRelMapper.class)
- .updateByPrimaryKeySelective(equRel);
- }
- return res;
- }
- /**
- * 一键设置商品价格
- * @param equId 设备id
- * @param sallPrice 售货价
- * @param gamePrice 游戏价
- * @param costPrice 成本价
- * @param type 游戏类型
- * @param isPromotton 是否促销
- * @param promottonPrice 促销价
- * @param session
- * @return
- * @throws MINBusinessException
- */
- @MINAction(value = EDIT_PROEQUREL_PRICE, transaction = IMINTransactionEnum.CMT)
- public MINActionResult editProEquRelPrice(
- @MINParam(key = "equId") String equId,
- @MINParam(key = "sallPrice") String sallPrice,
- @MINParam(key = "gamePrice") String gamePrice,
- @MINParam(key = "costPrice") String costPrice,
- @MINParam(key = "type") String type,
- @MINParam(key = "isPromotton") String isPromotton,
- @MINParam(key = "promottonPrice") String promottonPrice,
- MINSession session
- ) throws MINBusinessException {
- MINActionResult res = new MINActionResult();
- //当前时间
- String dateTime = DateUtil.getCurrentDateTimeString();
- User user = session.getUser();
- //操作员id
- String userId = user.getId();
- //渠道
- String channel = user.getChannel();
- //校验设备是否正常
- VmEquipmentInf equipmentInf = Service.lookup(IMINDataBaseService.class)
- .getMybatisMapper(VmEquipmentInfMapper.class)
- .selectByPrimaryKey(equId);
- if(equipmentInf == null){
- throw new MINBusinessException("该设备不存在!");
- }else if(equipmentInf.getState().equals(Constant.EQUIPMENT_STT_03)){
- throw new MINBusinessException("该设备已销毁!");
- }
- int comcosAndsal = CommonUtil.compare(costPrice, sallPrice);
- int comcosAndgam = CommonUtil.compare(costPrice, gamePrice);
- int comgamAndsal = CommonUtil.compare(gamePrice, sallPrice);
- // int comcosAndpro = CommonUtil.compare(costPrice, promottonPrice);
- int comproAndsal = CommonUtil.compare(promottonPrice, sallPrice);
- if (comcosAndsal == 1 || comcosAndsal == 0) {
- throw new MINBusinessException("成本价不能大于或等于售货价!");
- }
- /* if (comcosAndgam == 1 || comcosAndgam == 0) {
- throw new MINBusinessException("成本价不能大于或等于游戏价!");
- }
- if (comgamAndsal == 1 || comgamAndsal == 0) {
- throw new MINBusinessException("游戏价不能大于或等于售货价!");
- }*/
- // if (comcosAndpro == 1 || comcosAndpro == 0) {
- // throw new MINBusinessException("成本价不能大于或等于促销价!");
- // }
- if (comproAndsal == 1 || comproAndsal == 0) {
- throw new MINBusinessException("促销价不能大于或等于售货价!");
- }
- //查询设备中的商品
- VmProEquRelExample proEquRelExample = new VmProEquRelExample();
- proEquRelExample.createCriteria().andEquipmentIdEqualTo(equId)
- .andChannelEqualTo("V01")
- .andExeitStateEqualTo(Constant.PROEQUREL_STT_00);
- List<VmProEquRel> list2 = Service.lookup(IMINDataBaseService.class)
- .getMybatisMapper(VmProEquRelMapper.class)
- .selectByExample(proEquRelExample);
- for (int i = 0; i < list2.size(); i++) {
- VmProEquRel equRel = list2.get(i);
- equRel.setSallPrice(sallPrice); //售货价
- equRel.setGamePrice(gamePrice); //游戏价
- equRel.setCostPrice(costPrice); //成本价
- equRel.setIsPromotion(isPromotton); //是否促销
- equRel.setPromotionPrice(promottonPrice); //促销价
- equRel.setGameType(type); //游戏类型
- equRel.setModifyUser(userId); //最后修改人
- equRel.setModifyTime(dateTime); //最后修改时间
- Service.lookup(IMINDataBaseService.class)
- .getMybatisMapper(VmProEquRelMapper.class)
- .updateByPrimaryKeySelective(equRel);
- }
- return res;
- }
- /**
- * 生成包含字符串信息的二维码图片
- * @param flash 是否刷新
- */
- @MINAction(value = CREATE_QRCODE, transaction = IMINTransactionEnum.CMT)
- public MINActionResult createQrCode(
- @MINParam(key = "flash") String flash,
- @MINParam(key = "equId") String equId,
- @MINParam(key = "equType") String equType,
- MINSession session)throws MINBusinessException, FileNotFoundException, WriterException, IOException {
- MINActionResult res = new MINActionResult();
- //如果equType
- //获取当前用户信息
- User u = session.getUser();
- //获取用户id
- String userId = u.getBranchId();
- //刷新,生成
- //开发环境修改配置
- String basePath = "/home/images/"+ userId+".jpg"; //与nginx配置相同
- String os = System.getProperty("os.name");
- if(os.toLowerCase().startsWith("win")){
- System.out.println(os + " can't gunzip");
- basePath = "D:/images/"+ userId+".jpg"; //与nginx配置相同
- }
- File file = new File(basePath);
- //获取父目录
- File fileParent = file.getParentFile();
- //判断是否存在
- if (!fileParent.exists()) {
- fileParent.mkdirs();
- }
- //获取渠道号
- String channel = "V01";
- String address = Service.lookup(IPropertiesService.class)
- .getSystemProperties().get(channel+"_TO_MACHINE_ERWERMA").getKey();// 为nginx根路径
- // 加密客户号
- OutputStream outputStream = new FileOutputStream(file);
- String serviceUrl = Service.lookup(IPropertiesService.class)
- .getSystemProperties().get(channel+"_TO_MACHINE_ERWERMA").getKey();
- serviceUrl = "http://".concat(serviceUrl.concat("/admin/h5/index.html?equId=").concat(equId));
- //String urlString = URLEncoder.encode(, "GBK");
- // 生成二维码图片到本地
- try {
- EquCodeCreateUtil.createQrCode(outputStream,serviceUrl,900,"JPEG");
- } catch (com.google.zxing.WriterException e) {
- // TODO Auto-generated catch block
- e.printStackTrace();
- }
- outputStream.close();
- // 上传图片到服务器
- InputStream inputSteam = new FileInputStream(file);
- //String url = UpLoadFile.uploadImg(inputSteam,"jpg",channel,"00");
- String ambient = Service.lookup(IPublicService.class)
- .getSysParValue("AMBIENT");//当前环境
- InputStream inputSteams = new FileInputStream(file);
- FileItem fileItemb = createFileItem(file ,"itemFileName");
- Map<String, Object> map = null;
- if("00".equals(ambient)){//测试
- map =Service.lookup(IPublicService.class).uploadFile(fileItemb, "00", 0, true,"V01");
- }
- if("01".equals(ambient)){//生产
- map =Service.lookup(IPublicService.class).uploadFileBD(fileItemb, "00", 0, true,"V01");
- }
- //String url = UpLoadFile.uploadImg(inputSteam,"jpg",channel,"00");
- String url = String.valueOf(map.get("url"));
- inputSteam.close();
- // 删除本地图片
- file.delete();
- res.set("url", url);
- VmEquipmentInf vmEquipmentInf = Service.lookup(IMINDataBaseService.class).getMybatisMapper(VmEquipmentInfMapper.class).selectByPrimaryKey(equId);
- if (null != vmEquipmentInf){
- vmEquipmentInf.setUrlCode(url);
- Service.lookup(IMINDataBaseService.class)
- .getMybatisMapper(VmEquipmentInfMapper.class)
- .updateByPrimaryKeySelective(vmEquipmentInf);
- }
- return res;
- }
- /**
- * 补货
- * @param perId 设备id
- * @param session
- * @return
- * @throws MINBusinessException
- */
- @MINAction(value = EDIT_PROEQUREL_NUM)
- public MINActionResult editProEquRelNum(
- @MINParam(key = "perId") String perId,
- @MINParam(key = "proNum") String proNum,
- MINSession session
- ) throws MINBusinessException {
- MINActionResult res = new MINActionResult();
- //当前时间
- String dateTime = DateUtil.getCurrentDateTimeString();
- User user = session.getUser();
- //操作员id
- String userId = user.getId();
- //渠道
- // String channel = user.getChannel();
- //校验设备是否正常
- VmProEquRel equRel = Service.lookup(IMINDataBaseService.class)
- .getMybatisMapper(VmProEquRelMapper.class)
- .selectByPrimaryKey(perId);
- String proNumall = equRel.getCargoWayNums();
- int comcosAndsal = CommonUtil.compare(proNum, proNumall);
- if (comcosAndsal == 1 ) {
- throw new MINBusinessException("补货量不能大于货道容量!");
- }
- if(equRel == null||equRel.getExeitState().equals(Constant.PROEQUREL_STT_02)){
- throw new MINBusinessException("设备中该货物不存在!");
- }
- equRel.setProductNums(proNum); //商品余量修改为货道容量
- equRel.setModifyUser(userId); //最后修改人
- equRel.setModifyTime(dateTime); //最后修改时间
- Service.lookup(IMINDataBaseService.class)
- .getMybatisMapper(VmProEquRelMapper.class)
- .updateByPrimaryKeySelective(equRel);
- return res;
- }
- /**
- * 添加设备
- *
- * @param session
- * @return
- * @throws MINBusinessException
- */
- @MINAction(value = DELETE_EQU, transaction = IMINTransactionEnum.CMT)
- public MINActionResult deleteEqu(
- @MINParam(key = "startEquCode") String startEquCode,
- @MINParam(key = "endEquCode") String endEquCode,
- MINSession session) throws MINBusinessException {
- MINActionResult res = new MINActionResult();
- //获取当前时间
- String nowTime = DateUtil.getCurrentDateTimeString();
- // 获取操作员信息
- User user = session.getUser();
- if (CommonUtil.isEmpty(startEquCode)) {
- throw new MINBusinessException("起始解绑机台号为空");
- }
- if (!CommonUtil.isEmpty(endEquCode)) {
- int code = CommonUtil.compare(startEquCode,endEquCode);
- if (code == 0 || code == 1){
- throw new MINBusinessException("起始解绑机台号不能大于等于结束解绑机台号");
- }
- for (int i = Integer.parseInt(startEquCode);i <= Integer.parseInt(endEquCode);i++){
- VmEquipmentInfExample example = new VmEquipmentInfExample();
- example.createCriteria().andMachineNoEqualTo(String.valueOf(i));
- List<VmEquipmentInf> vmEquipmentInf = Service.lookup(IMINDataBaseService.class).getMybatisMapper(VmEquipmentInfMapper.class).selectByExample(example);
- if (vmEquipmentInf != null && vmEquipmentInf.size() > 0){
- Service.lookup(IMINDataBaseService.class)
- .getMybatisMapper(VmEquipmentInfMapper.class)
- .deleteByPrimaryKey(vmEquipmentInf.get(0).getId());
- }
- }
- }else{
- VmEquipmentInfExample example = new VmEquipmentInfExample();
- example.createCriteria().andMachineNoEqualTo(startEquCode);
- List<VmEquipmentInf> vmEquipmentInf = Service.lookup(IMINDataBaseService.class).getMybatisMapper(VmEquipmentInfMapper.class).selectByExample(example);
- if (vmEquipmentInf != null && vmEquipmentInf.size() > 0){
- Service.lookup(IMINDataBaseService.class)
- .getMybatisMapper(VmEquipmentInfMapper.class)
- .deleteByPrimaryKey(vmEquipmentInf.get(0).getId());
- }
- }
- /*// 记录操作日志
- String logInfo = "操作员:" + user.getName() + "添加商品,商品编号:" + id;
- Service.lookup(ILogService.class).logging(session, logInfo);*/
- return res;
- }
- /**
- * 添加设备货道
- *
- * @param session
- * @return
- * @throws MINBusinessException
- */
- @MINAction(value = ADD_PRO_EQU_REL, transaction = IMINTransactionEnum.CMT)
- public MINActionResult addProEquRelLineRow(
- @MINParam(key = "line") String line,
- @MINParam(key = "row") String row,
- @MINParam(key = "equId") String equId,
- MINSession session) throws MINBusinessException {
- MINActionResult res = new MINActionResult();
- //获取当前时间
- String nowTime = DateUtil.getCurrentDateTimeString();
- // 获取操作员信息
- User user = session.getUser();
- VmProEquRelExample example = new VmProEquRelExample();
- example.createCriteria().andIdEqualTo(equId).andCargoWayLineEqualTo(CommonUtil.subtract(line,"1")).andCargoWayRowEqualTo(CommonUtil.subtract(row,"1"));
- List<VmProEquRel> List = Service.lookup(IMINDataBaseService.class).getMybatisMapper(VmProEquRelMapper.class).selectByExample(example);
- if (List.size()>0){
- throw new MINBusinessException("货道已存在");
- }
- String id = Service.lookup(IPublicService.class).getSequence("VM_PROEQUREL_ID");
- VmProEquRel vmProEquRel = new VmProEquRel();
- vmProEquRel.setId(id);
- vmProEquRel.setEquipmentId(equId);
- vmProEquRel.setCargoWayLine(CommonUtil.subtract(line,"1"));
- vmProEquRel.setCargoWayRow(CommonUtil.subtract(row,"1"));
- vmProEquRel.setExeitState("00");
- vmProEquRel.setCreateTime(nowTime);
- vmProEquRel.setCreateUser(user.getId());
- Service.lookup(IMINDataBaseService.class).getMybatisMapper(VmProEquRelMapper.class).insertSelective(vmProEquRel);
- /*// 记录操作日志
- String logInfo = "操作员:" + user.getName() + "添加商品,商品编号:" + id;
- Service.lookup(ILogService.class).logging(session, logInfo);*/
- return res;
- }
- /**
- * 查询设备中商品
- *
- * @param session
- * @return
- * @throws MINBusinessException
- */
- @MINAction(value = QUERY_FUNCTION)
- public MINActionResult queryFunction(
- @MINParam(key = "branchId") String branchId,
- MINSession session
- ) throws MINBusinessException {
- MINActionResult res = new MINActionResult();
- User user = session.getUser();
- //渠道
- String channel = user.getChannel();
- // 查询条件
- Map<String, String> map = new HashMap<String, String>();
- map.put("branchId", user.getBranchId());
- List<Map<String, Object>> list = Service.lookup(IMINDataBaseService.class)
- .getMybatisMapper(MachineManageMapper.class)
- .queryFunction(map);
- //传递数据
- res.set(IMINBusinessConstant.F_PAGING_LAY, list);
- return res;
- }
- /**
- * 查询设备中商品
- *
- * @param session
- * @return
- * @throws MINBusinessException
- */
- @MINAction(value = QUERY_PROEQURELPAGE)
- public MINActionResult queryProEquRelPage(
- @MINParam(key = "equId") String equId,
- @MINParam(key = "proName") String proName,
- @MINParam(key = "gameType") String gameType,
- @MINParam(key = "page", defaultValue = "1") int page,
- @MINParam(key = "limit", defaultValue = "10") int limit,
- MINSession session
- ) throws MINBusinessException {
- MINActionResult res = new MINActionResult();
- MINRowBounds rows = new MINRowBounds(page, limit);
- User user = session.getUser();
- //渠道
- String channel = user.getChannel();
- // 查询条件
- Map<String, String> map = new HashMap<String, String>();
- map.put("channel", "V01");
- map.put("equId", equId);
- if(!Constant.ADMINISTRATION_SYSTEM_NUMBER.equals(user.getBranchId())){
- map.put("branchId", user.getBranchId());
- }
- map.put("gameType", "02");
- map.put("proName", proName);
- List<Map<String, Object>> list = Service.lookup(IMINDataBaseService.class)
- .getMybatisMapper(MachineManageMapper.class)
- .queryProEquRelPage(map,rows);
- //格式化时间和状态
- list = Service.lookup(IFormatService.class).formatDateTime(list, "createTime", "modifyTime");
- list = new MINCopyFormat("{perState:'sttDesc',isPromotton:'isPromottonDesc',isFragile:'isFragileDesc',type:'typeDesc'}").format(list);
- list = Service.lookup(IFormatService.class).formatEnum(list, "{sttDesc:'PROEQUREL_STATE',isPromottonDesc:'IS_PROMOTION',typeDesc:'GAME_SETUP_TYPE'}");
- //传递数据
- res.set(IMINBusinessConstant.F_PAGING_LAY, list);
- res.set(IMINBusinessConstant.F_PAGING_COUNT, rows.getMaxRows());
- return res;
- }
- /**
- * 清空累计金额
- * @param perId
- * @param session
- * @return
- * @throws MINBusinessException
- */
- @MINAction(value = EMPTY_PROEQUREL)
- public MINActionResult emptyProEquRel(
- @MINParam(key = "perId") String perId,
- MINSession session
- ) throws MINBusinessException {
- MINActionResult res = new MINActionResult();
- VmProEquRel proEquRel = new VmProEquRel();
- if(CommonUtil.isEmpty(perId)){
- throw new MINBusinessException("数据异常!");
- }
- proEquRel.setId(perId);
- proEquRel.setAccumulatedAmount("0");
- Service.lookup(IMINDataBaseService.class)
- .getMybatisMapper(VmProEquRelMapper.class)
- .updateByPrimaryKeySelective(proEquRel);
- String logInfo = "清空累计金额:" + perId;
- Service.lookup(ILogService.class).logging(session, logInfo);
- return res;
- }
- /**
- * 收款商户号信息查询
- * @param session
- * @param accountName 商户名称
- * @param accountId 商户号
- * @param type 商户类型
- * @param page
- * @param limit
- * @return
- * @throws MINBusinessException
- */
- @MINAction(value = TENCENTMANAGE_QUERY)
- public MINActionResult businessNumManageQuery(MINSession session,
- @MINParam(key = "branchId") String branchId,
- @MINParam(key = "accountName") String accountName,
- @MINParam(key = "accountId") String accountId,
- @MINParam(key = "type") String type,
- @MINParam(key = "page", defaultValue = "1") int page,
- @MINParam(key = "limit", defaultValue = "10") int limit) throws MINBusinessException {
- MINActionResult res = new MINActionResult();
- // 查询当前角色编号
- User u = session.getUser();
- branchId = u.getBranchId();
- MINRowBounds rows = new MINRowBounds(page, limit);
- VmHlAccountExample vmHlAccountExample = new VmHlAccountExample();
- VmHlAccountExample.Criteria createCriteria = vmHlAccountExample.createCriteria();
- if(!StringUtils.isNullOrEmpty(accountName)){
- createCriteria.andNameLike("%"+accountName+"%");
- }
- if(!StringUtils.isNullOrEmpty(type)){
- createCriteria.andTypeEqualTo(type);
- }
- if(Constant.ADMINISTRATION_SYSTEM_NUMBER.equals(u.getBranchId())){
- if(!StringUtils.isNullOrEmpty(accountId)){
- createCriteria.andUsridEqualTo(accountId);
- }
- }else{
- createCriteria.andUsridEqualTo(u.getBranchId());
- }
- createCriteria.andStateEqualTo("00");
- List<VmHlAccount> businessNumList = Service.lookup(IMINDataBaseService.class)
- .getMybatisMapper(VmHlAccountMapper.class).selectByExample(vmHlAccountExample,rows);
- businessNumList = new MINCopyFormat("{type:'typeDesc'}").format(businessNumList);
- businessNumList = Service.lookup(IFormatService.class).formatEnum(businessNumList, "{typeDesc:'BUSINESSNUM_TYPE'}");
- businessNumList = Service.lookup(IFormatService.class).formatDateTime(businessNumList, "createTime");
- res.set(IMINBusinessConstant.F_PAGING_LAY, businessNumList);
- res.set(IMINBusinessConstant.F_PAGING_COUNT, rows.getMaxRows());
- return res;
- }
- /**
- * 商户号信息查询
- * @param session
- * @param accountName 商户名称
- * @param accountId 商户号
- * @param page
- * @param limit
- * @return
- * @throws MINBusinessException
- */
- @MINAction(value = QUERY_BRANCH)
- public MINActionResult queryBranch(MINSession session,
- @MINParam(key = "accountName") String accountName,
- @MINParam(key = "accountId") String accountId,
- @MINParam(key = "type") String type,
- @MINParam(key = "page", defaultValue = "1") int page,
- @MINParam(key = "limit", defaultValue = "10") int limit) throws MINBusinessException {
- MINActionResult res = new MINActionResult();
- // 查询当前角色编号
- User u = session.getUser();
- String branchId = u.getBranchId();
- MINRowBounds rows = new MINRowBounds(page, limit);
- ImBranchExample imBranchExample = new ImBranchExample();
- ImBranchExample.Criteria createCriteria = imBranchExample.createCriteria();
- if(!StringUtils.isNullOrEmpty(accountName)){
- createCriteria.andNameLike("%"+accountName+"%");
- }
- if(!branchId.equals(Constant.ADMINISTRATION_SYSTEM_NUMBER)){
- createCriteria.andParentidEqualTo(branchId);
- }
- if(!StringUtils.isNullOrEmpty(accountId)){
- createCriteria.andIdEqualTo(accountId);
- }
- List<ImBranch> branchList = Service.lookup(IMINDataBaseService.class)
- .getMybatisMapper(ImBranchMapper.class).selectByExample(imBranchExample,rows);
- branchList = Service.lookup(IFormatService.class).formatDateTime(branchList, "createTime");
- res.set(IMINBusinessConstant.F_PAGING_LAY, branchList);
- res.set(IMINBusinessConstant.F_PAGING_COUNT, rows.getMaxRows());
- return res;
- }
- /**
- * 添加设备
- *
- * @param session
- * @return
- * @throws MINBusinessException
- */
- @MINAction(value = BIND_BRANCH, transaction = IMINTransactionEnum.CMT)
- public MINActionResult bindBranch(
- @MINParam(key = "equId") String equId,
- @MINParam(key = "branchId") String branchId,
- MINSession session) throws MINBusinessException, IOException {
- MINActionResult res = new MINActionResult();
- //获取当前时间
- String nowTime = DateUtil.getCurrentDateTimeString();
- // 获取操作员信息
- User user = session.getUser();
- VmEquipmentInf vmEquipmentInf = Service.lookup(IMINDataBaseService.class)
- .getMybatisMapper(VmEquipmentInfMapper.class)
- .selectByPrimaryKey(equId);
- if (null == vmEquipmentInf) {
- throw new MINBusinessException("机器不存在");
- }
- vmEquipmentInf.setBranchid(branchId);
- Service.lookup(IMINDataBaseService.class)
- .getMybatisMapper(VmEquipmentInfMapper.class)
- .updateByPrimaryKeySelective(vmEquipmentInf);
- /*// 记录操作日志
- String logInfo = "操作员:" + user.getName() + "添加商品,商品编号:" + id;
- Service.lookup(ILogService.class).logging(session, logInfo);*/
- return res;
- }
- /*
- 创建FileItem
- */
- private FileItem createFileItem(File file, String fieldName) {
- FileItemFactory factory = new DiskFileItemFactory(16, null);
- FileItem item = factory.createItem(fieldName, "text/plain", true, file.getName());
- int bytesRead = 0;
- byte[] buffer = new byte[8192];
- try {
- FileInputStream fis = new FileInputStream(file);
- OutputStream os = item.getOutputStream();
- while ((bytesRead = fis.read(buffer, 0, 8192)) != -1) {
- os.write(buffer, 0, bytesRead);
- }
- os.close();
- fis.close();
- } catch (IOException e) {
- e.printStackTrace();
- }
- return item;
- }
- }
|