package com.minpay.mt.machine.action; 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.IPropertiesService; import com.minpay.common.service.IPublicService; import com.minpay.common.util.DateUtil; import com.minpay.db.table.mapper.VmEquipmentInfMapper; import com.minpay.db.table.mapper.VmProEquRelMapper; import com.minpay.db.table.model.VmEquipmentInf; import com.minpay.db.table.model.VmEquipmentInfExample; import com.minpay.db.table.model.VmProEquRel; import com.minpay.db.table.model.VmProEquRelExample; import com.minpay.db.table.own.mapper.MachineManageMapper; 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 java.util.HashMap; import java.util.List; import java.util.Map; /** * 设备管理 * @author pangjl * 20190325 */ @MINComponent public class MachineManageAction implements IMINAction { /**查看设备*/ public final static String QUERY_EQUMENT_INF = "queryEqumentInf"; /** 添加设备*/ public final static String ADD_PRODUCT_INF = "addProductInf"; /** 修改设备*/ 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_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"; 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 = "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 map = new HashMap(); map.put("id",machineId); map.put("createUser",createUser); map.put("channel", user.getChannel());//渠道号 //验证操作员权限 MINRowBounds rows = new MINRowBounds(page, limit); //执行查询 List> list = Service.lookup(IMINDataBaseService.class) .getMybatisMapper(MachineManageMapper.class) .machineInf(map, rows); //格式化时间和状态 list = Service.lookup(IFormatService.class).formatDateTime(list, "createTime","modifyTime"); list = new MINCopyFormat("{state:'stateDesc'}").format(list); list = Service.lookup(IFormatService.class).formatEnum(list,"{stateDesc:'MEI_STATE'}"); //返回数据 res.set(IMINBusinessConstant.F_PAGING_LAY, list); res.set(IMINBusinessConstant.F_PAGING_COUNT,rows.getMaxRows()); 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 { 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 vmEquipmentInfList = Service.lookup(IMINDataBaseService.class) .getMybatisMapper(VmEquipmentInfMapper.class) .selectByExample(example); if (vmEquipmentInfList.size()>0){ throw new MINBusinessException(equCode+"机台号已存在"); } for (int j = 1; j vmEquipmentInfLists = Service.lookup(IMINDataBaseService.class) .getMybatisMapper(VmEquipmentInfMapper.class) .selectByExample(examples); if (vmEquipmentInfLists.size()>0){ throw new MINBusinessException(equCode+"机台号已存在"); } } String id = Service.lookup(IPublicService.class).getSequence("EQU_MACHINE_NO"); VmEquipmentInf pro = new VmEquipmentInf(); pro.setId(id); pro.setMachineNo(equCode); pro.setChannel("V01"); pro.setState("00"); pro.setCreateUser(user.getId()); pro.setCreateTime(nowTime); pro.setRows(temRow); pro.setLines(temLine); Service.lookup(IMINDataBaseService.class) .getMybatisMapper(com.minpay.db.table.mapper.VmEquipmentInfMapper.class) .insertSelective(pro); for (int i = 1; i < size;i++ ){ String ids = Service.lookup(IPublicService.class).getSequence("EQU_MACHINE_NO"); VmEquipmentInf pros = new VmEquipmentInf(); pros.setId(ids); pros.setChannel("V01"); pros.setMachineNo(CommonUtil.add(equCode,String.valueOf(i))); pros.setState("00"); pros.setCreateUser(user.getId()); pros.setCreateTime(nowTime); pros.setRows(temRow); pros.setLines(temLine); Service.lookup(IMINDataBaseService.class) .getMybatisMapper(com.minpay.db.table.mapper.VmEquipmentInfMapper.class) .insertSelective(pros); } /*// 记录操作日志 String logInfo = "操作员:" + user.getName() + "添加商品,商品编号:" + id; Service.lookup(ILogService.class).logging(session, logInfo);*/ return res; } /** * 查询设备中商品 * @param temName 模版名称 * @param temState 状态 * @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 map = new HashMap(); map.put("channel", "V01"); map.put("equId", equId); List> 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 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 map = new HashMap(); //按商品名称,商品品牌进行模糊查询 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> 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, 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 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 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); //售货价 proEquRel.setGamePrice(gamePrice); //游戏价 proEquRel.setCostPrice(costPrice); //成本价 proEquRel.setIsPromotion(isPromotton); //是否促销 proEquRel.setPromotionPrice(promottonPrice); //促销价 /* 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正常 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, 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 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); //游戏价 } if(!CommonUtil.isEmpty(costPrice)){ proEquRel.setCostPrice(costPrice); //成本价 } if(!CommonUtil.isEmpty(isPromotton)){ proEquRel.setIsPromotion(isPromotton); //是否促销 } if(!CommonUtil.isEmpty(promottonPrice)){ proEquRel.setPromotionPrice(promottonPrice); //促销价 } /*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); //状态 } Service.lookup(IMINDataBaseService.class) .getMybatisMapper(VmProEquRelMapper.class) .updateByPrimaryKeySelective(proEquRel); return res; } /** * 查询设备中商品 * @param temName 模版名称 * @param temState 状态 * @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 map = new HashMap(); map.put("channel", "V01"); map.put("equId", equId); map.put("perId", perId); List> 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 perId 设备商品关联id * @param proId 商品id * @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 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 proId 商品id * @param equId 设备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; } }