MachineManageAction.java 32 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750
  1. package com.minpay.mt.machine.action;
  2. import com.min.util.CommonUtil;
  3. import com.minpay.common.bean.User;
  4. import com.minpay.common.constant.Constant;
  5. import com.minpay.common.format.IFormatService;
  6. import com.minpay.common.service.IPropertiesService;
  7. import com.minpay.common.service.IPublicService;
  8. import com.minpay.common.util.DateUtil;
  9. import com.minpay.db.table.mapper.VmEquipmentInfMapper;
  10. import com.minpay.db.table.mapper.VmProEquRelMapper;
  11. import com.minpay.db.table.model.VmEquipmentInf;
  12. import com.minpay.db.table.model.VmEquipmentInfExample;
  13. import com.minpay.db.table.model.VmProEquRel;
  14. import com.minpay.db.table.model.VmProEquRelExample;
  15. import com.minpay.db.table.own.mapper.MachineManageMapper;
  16. import com.startup.minpay.frame.business.IMINAction;
  17. import com.startup.minpay.frame.business.res.MINActionResult;
  18. import com.startup.minpay.frame.constant.IMINBusinessConstant;
  19. import com.startup.minpay.frame.constant.IMINTransactionEnum;
  20. import com.startup.minpay.frame.data.format.MINCopyFormat;
  21. import com.startup.minpay.frame.exception.MINBusinessException;
  22. import com.startup.minpay.frame.jdbc.MINRowBounds;
  23. import com.startup.minpay.frame.service.base.IMINDataBaseService;
  24. import com.startup.minpay.frame.service.base.Service;
  25. import com.startup.minpay.frame.session.MINSession;
  26. import com.startup.minpay.frame.target.MINAction;
  27. import com.startup.minpay.frame.target.MINComponent;
  28. import com.startup.minpay.frame.target.MINParam;
  29. import java.util.HashMap;
  30. import java.util.List;
  31. import java.util.Map;
  32. /**
  33. * 设备管理
  34. * @author pangjl
  35. * 20190325
  36. */
  37. @MINComponent
  38. public class MachineManageAction implements IMINAction {
  39. /**查看设备*/
  40. public final static String QUERY_EQUMENT_INF = "queryEqumentInf";
  41. /** 添加设备*/
  42. public final static String ADD_PRODUCT_INF = "addProductInf";
  43. /** 修改设备*/
  44. public final static String MODIFY_PRODUCT_INF = "modifyProductInf";
  45. /** 更改设备状态*/
  46. public final static String MODIFY_PRODUCT_STATE = "modifyProductState";
  47. /**查询设备中商品*/
  48. public final static String QUERY_PROEQUREL = "queryProEquRel";
  49. /**查看正常状态商品*/
  50. public final static String QUERY_PRODUCTZ = "queryProductz";
  51. /**设备添加商品*/
  52. public final static String ADD_PROEQUREL = "addProEquRel";
  53. /**修改设备商品*/
  54. public final static String EDIT_PROEQUREL = "editProEquRel";
  55. /**查询编辑设备中商品*/
  56. public final static String QUERY_PROEQU = "queryProEqu";
  57. /**删除货道*/
  58. public final static String DEL_EQUPRO = "delEquPro";
  59. /**删除设备中商品*/
  60. public final static String DEL_PROEQU = "delProEqu";
  61. private boolean contains;
  62. /**
  63. * 查看设备
  64. * @param createUser 添加人
  65. * @param page
  66. * @param limit
  67. * @return
  68. * @throws Exception
  69. */
  70. @MINAction(value = QUERY_EQUMENT_INF)
  71. public MINActionResult queryEqumentInf(
  72. @MINParam(key = "machineId")String machineId,
  73. @MINParam(key = "state") String state,
  74. @MINParam(key = "createUser") String createUser,
  75. @MINParam(key = "page", defaultValue = "1") int page,
  76. @MINParam(key = "limit", defaultValue = "3") int limit,
  77. MINSession session) throws Exception {
  78. MINActionResult res = new MINActionResult();
  79. User user = session.getUser();
  80. String passwardKey = Service.lookup(IPropertiesService.class)
  81. .getSystemProperties().get("WALLET_TO_METTING_PASSWORD_KEY").getKey();
  82. Map<String, String> map = new HashMap<String, String>();
  83. map.put("id",machineId);
  84. map.put("createUser",createUser);
  85. map.put("channel", user.getChannel());//渠道号
  86. //验证操作员权限
  87. MINRowBounds rows = new MINRowBounds(page, limit);
  88. //执行查询
  89. List<Map<String, String>> list = Service.lookup(IMINDataBaseService.class)
  90. .getMybatisMapper(MachineManageMapper.class)
  91. .machineInf(map, rows);
  92. //格式化时间和状态
  93. list = Service.lookup(IFormatService.class).formatDateTime(list, "createTime","modifyTime");
  94. list = new MINCopyFormat("{state:'stateDesc'}").format(list);
  95. list = Service.lookup(IFormatService.class).formatEnum(list,"{stateDesc:'MEI_STATE'}");
  96. //返回数据
  97. res.set(IMINBusinessConstant.F_PAGING_LAY, list);
  98. res.set(IMINBusinessConstant.F_PAGING_COUNT,rows.getMaxRows());
  99. return res;
  100. }
  101. /**
  102. * 添加设备
  103. * @param session
  104. * @return
  105. * @throws MINBusinessException
  106. */
  107. @MINAction(value = ADD_PRODUCT_INF,transaction = IMINTransactionEnum.CMT)
  108. public MINActionResult addMachine(
  109. @MINParam(key = "equCode") String equCode,
  110. @MINParam(key = "account") String account,
  111. @MINParam(key = "temLine") String temLine,
  112. @MINParam(key = "temRow") String temRow,
  113. MINSession session) throws MINBusinessException {
  114. MINActionResult res = new MINActionResult();
  115. //获取当前时间
  116. String nowTime = DateUtil.getCurrentDateTimeString();
  117. // 获取操作员信息
  118. User user = session.getUser();
  119. if (CommonUtil.isEmpty(equCode)){
  120. throw new MINBusinessException("起始机台号为空");
  121. }
  122. if (CommonUtil.isEmpty(account)){
  123. throw new MINBusinessException("生成数量为空");
  124. }
  125. if (CommonUtil.isEmpty(temLine)){
  126. throw new MINBusinessException("生成货道行数量为空");
  127. }
  128. if (CommonUtil.isEmpty(temRow)){
  129. throw new MINBusinessException("生成货道列数量为空");
  130. }
  131. int size = Integer.parseInt(account);
  132. VmEquipmentInfExample example = new VmEquipmentInfExample();
  133. example.createCriteria().andMachineNoEqualTo(equCode).andStateEqualTo("00");
  134. List<VmEquipmentInf> vmEquipmentInfList = Service.lookup(IMINDataBaseService.class)
  135. .getMybatisMapper(VmEquipmentInfMapper.class)
  136. .selectByExample(example);
  137. if (vmEquipmentInfList.size()>0){
  138. throw new MINBusinessException(equCode+"机台号已存在");
  139. }
  140. for (int j = 1; j<size;j++ ){
  141. VmEquipmentInfExample examples = new VmEquipmentInfExample();
  142. examples.createCriteria().andMachineNoEqualTo(CommonUtil.add(equCode,String.valueOf(j))).andStateEqualTo("00");
  143. List<VmEquipmentInf> vmEquipmentInfLists = Service.lookup(IMINDataBaseService.class)
  144. .getMybatisMapper(VmEquipmentInfMapper.class)
  145. .selectByExample(examples);
  146. if (vmEquipmentInfLists.size()>0){
  147. throw new MINBusinessException(equCode+"机台号已存在");
  148. }
  149. }
  150. String id = Service.lookup(IPublicService.class).getSequence("EQU_MACHINE_NO");
  151. VmEquipmentInf pro = new VmEquipmentInf();
  152. pro.setId(id);
  153. pro.setMachineNo(equCode);
  154. pro.setChannel("V01");
  155. pro.setState("00");
  156. pro.setCreateUser(user.getId());
  157. pro.setCreateTime(nowTime);
  158. pro.setRows(temRow);
  159. pro.setLines(temLine);
  160. Service.lookup(IMINDataBaseService.class)
  161. .getMybatisMapper(com.minpay.db.table.mapper.VmEquipmentInfMapper.class)
  162. .insertSelective(pro);
  163. for (int i = 1; i < size;i++ ){
  164. String ids = Service.lookup(IPublicService.class).getSequence("EQU_MACHINE_NO");
  165. VmEquipmentInf pros = new VmEquipmentInf();
  166. pros.setId(ids);
  167. pros.setChannel("V01");
  168. pros.setMachineNo(CommonUtil.add(equCode,String.valueOf(i)));
  169. pros.setState("00");
  170. pros.setCreateUser(user.getId());
  171. pros.setCreateTime(nowTime);
  172. pros.setRows(temRow);
  173. pros.setLines(temLine);
  174. Service.lookup(IMINDataBaseService.class)
  175. .getMybatisMapper(com.minpay.db.table.mapper.VmEquipmentInfMapper.class)
  176. .insertSelective(pros);
  177. }
  178. /*// 记录操作日志
  179. String logInfo = "操作员:" + user.getName() + "添加商品,商品编号:" + id;
  180. Service.lookup(ILogService.class).logging(session, logInfo);*/
  181. return res;
  182. }
  183. /**
  184. * 查询设备中商品
  185. * @param temName 模版名称
  186. * @param temState 状态
  187. * @param session
  188. * @return
  189. * @throws MINBusinessException
  190. */
  191. @MINAction(value = QUERY_PROEQUREL)
  192. public MINActionResult queryProEquRel(
  193. @MINParam(key = "equId") String equId,
  194. MINSession session
  195. ) throws MINBusinessException {
  196. MINActionResult res = new MINActionResult();
  197. User user = session.getUser();
  198. //渠道
  199. String channel = user.getChannel();
  200. // 查询条件
  201. Map<String, String> map = new HashMap<String, String>();
  202. map.put("channel", "V01");
  203. map.put("equId", equId);
  204. List<Map<String, Object>> list = Service.lookup(IMINDataBaseService.class)
  205. .getMybatisMapper(MachineManageMapper.class)
  206. .queryProEquRel(map);
  207. //格式化时间和状态
  208. list = Service.lookup(IFormatService.class).formatDateTime(list, "createTime","modifyTime");
  209. list = new MINCopyFormat("{perState:'sttDesc',isPromotton:'isPromottonDesc',isFragile:'isFragileDesc'}").format(list);
  210. list = Service.lookup(IFormatService.class).formatEnum(list, "{sttDesc:'PROEQUREL_STATE',isPromottonDesc:'IS_PROMOTION',isFragileDesc:'IS_FRAGILE'}");
  211. //传递数据
  212. res.set(IMINBusinessConstant.F_PAGING_LAY, list);
  213. return res;
  214. }
  215. /**
  216. * 查看商品
  217. * @param name 商品名称
  218. * @param brandName 品牌名称
  219. * @param model 商品型号
  220. * @param createUser 添加人
  221. * @param dates 添加时间
  222. * @param page
  223. * @param limit
  224. * @return
  225. * @throws MINBusinessException
  226. */
  227. @MINAction(value = QUERY_PRODUCTZ)
  228. public MINActionResult queryProductz(
  229. @MINParam(key = "name") String name,
  230. @MINParam(key = "model") String model,
  231. @MINParam(key = "dates")String dates,
  232. @MINParam(key = "state") String state,
  233. @MINParam(key = "brandName") String brandName,
  234. @MINParam(key = "categoryId") String categoryId,
  235. @MINParam(key = "createUser") String createUser,
  236. @MINParam(key = "page", defaultValue = "1") int page,
  237. @MINParam(key = "limit", defaultValue = "3") int limit,
  238. MINSession session) throws MINBusinessException {
  239. MINActionResult res = new MINActionResult();
  240. User user = session.getUser();
  241. Map<String, String> map = new HashMap<String, String>();
  242. //按商品名称,商品品牌进行模糊查询
  243. map.put("name", name); //商品名称
  244. map.put("state", state);//状态
  245. map.put("model",model);
  246. map.put("dates",dates);
  247. map.put("brandName",brandName);
  248. map.put("createUser",createUser);
  249. map.put("channel", "V01");//渠道号
  250. map.put("category", categoryId);//分类
  251. //验证操作员权限
  252. if("00".equals(user.getIdentity())){
  253. map.put("userId",user.getId());
  254. }
  255. /* if("10000002".equals(user.getRoleId())){
  256. map.put("userId",user.getId());
  257. }*/
  258. //分页
  259. MINRowBounds rows = new MINRowBounds(page, limit);
  260. //执行查询
  261. List<Map<String, String>> list = Service.lookup(IMINDataBaseService.class)
  262. .getMybatisMapper(MachineManageMapper.class)
  263. .queryProductz(map, rows);
  264. //格式化时间和状态
  265. list = Service.lookup(IFormatService.class).formatDateTime(list, "createTime","modifyTime");
  266. list = new MINCopyFormat("{history:'historyDesc',state:'stateDesc',source:'sourceDesc'}").format(list);
  267. list = Service.lookup(IFormatService.class).formatEnum(list,"{historyDesc:'PRODUCT_HISTORY',stateDesc:'PRODUCT_STATE',sourceDesc:'PRODUCT_SOURCE'}");
  268. //返回数据
  269. res.set(IMINBusinessConstant.F_PAGING_LAY, list);
  270. res.set(IMINBusinessConstant.F_PAGING_COUNT,rows.getMaxRows());
  271. return res;
  272. }
  273. /**
  274. * 设备添加商品
  275. * @param perRow 货道层
  276. * @param perLine 货道列
  277. * @param perNum 货道容量
  278. * @param numbers 商品余量
  279. * @param sallPrice 售货价
  280. * @param gamePrice 游戏价
  281. * @param costPrice 成本价
  282. * @param isPromotton 是否促销
  283. * @param promottonPrice 促销价
  284. * @param isFragile 是否易碎
  285. * @param perRemarks 备注
  286. * @param proId 商品id
  287. * @param equId 设备id
  288. * @param session
  289. * @return
  290. * @throws MINBusinessException
  291. */
  292. @MINAction(value = ADD_PROEQUREL)
  293. public MINActionResult addProEquRel(
  294. @MINParam(key = "aisle") String aisle,
  295. @MINParam(key = "perRow") String perRow,
  296. @MINParam(key = "perLine") String perLine,
  297. @MINParam(key = "perNum") String perNum,
  298. @MINParam(key = "numbers") String numbers,
  299. @MINParam(key = "sallPrice") String sallPrice,
  300. @MINParam(key = "gamePrice") String gamePrice,
  301. @MINParam(key = "costPrice") String costPrice,
  302. @MINParam(key = "isPromotton") String isPromotton,
  303. @MINParam(key = "promottonPrice") String promottonPrice,
  304. @MINParam(key = "type") String type,
  305. @MINParam(key = "isFragile") String isFragile,
  306. @MINParam(key = "perRemarks") String perRemarks,
  307. @MINParam(key = "proId") String proId,
  308. @MINParam(key = "equId") String equId,
  309. @MINParam(key = "luck") String luck,
  310. MINSession session
  311. ) throws MINBusinessException {
  312. MINActionResult res = new MINActionResult();
  313. //当前时间
  314. String dateTime = DateUtil.getCurrentDateTimeString();
  315. User user = session.getUser();
  316. //操作员id
  317. String uId = user.getId();
  318. //渠道
  319. String channel = user.getChannel();
  320. //校验设备是否正常
  321. VmEquipmentInf equipmentInf = Service.lookup(IMINDataBaseService.class)
  322. .getMybatisMapper(VmEquipmentInfMapper.class)
  323. .selectByPrimaryKey(equId);
  324. if(equipmentInf == null){
  325. throw new MINBusinessException("该设备不存在!");
  326. }else if(equipmentInf.getState().equals("03")){
  327. throw new MINBusinessException("该设备已销毁!");
  328. }
  329. int comcosAndsal = CommonUtil.compare(costPrice, sallPrice);
  330. /* int comcosAndgam = CommonUtil.compare(costPrice, gamePrice);
  331. int comgamAndsal = CommonUtil.compare(gamePrice, sallPrice);*/
  332. /* int comcosAndpro = CommonUtil.compare(costPrice, promottonPrice);*/
  333. int comproAndsal = CommonUtil.compare(promottonPrice, sallPrice);
  334. int comnumAndper = CommonUtil.compare(numbers, perNum);
  335. if (comcosAndsal == 1 || comcosAndsal == 0) {
  336. throw new MINBusinessException("成本价不能大于或等于售货价!");
  337. }
  338. /* if (comcosAndgam == 1 || comcosAndgam == 0) {
  339. throw new MINBusinessException("成本价不能大于或等于游戏价!");
  340. }
  341. if (comgamAndsal == 1 || comgamAndsal == 0) {
  342. throw new MINBusinessException("游戏价不能大于或等于售货价!");
  343. }*/
  344. /*if (comcosAndpro == 1 || comcosAndpro == 0) {
  345. throw new MINBusinessException("成本价不能大于或等于促销价!");
  346. }*/
  347. if (comproAndsal == 1 || comproAndsal == 0) {
  348. throw new MINBusinessException("促销价不能大于或等于售货价!");
  349. }
  350. if (comnumAndper == 1 ) {
  351. throw new MINBusinessException("商品余量不能大于货道容量!");
  352. }
  353. //校验商品是否正常
  354. // VmProductInf pro = Service.lookup(IMINDataBaseService.class)
  355. // .getMybatisMapper(VmProductInfMapper.class)
  356. // .selectByPrimaryKey(proId);
  357. // if(pro == null||pro.getState().equals("2")) {
  358. // throw new BusinessCodeException("JINM0123");//商品信息异常
  359. // }
  360. //设备新增商品
  361. String id = Service.lookup(IPublicService.class).getSequence("VM_PROEQUREL_ID");
  362. VmProEquRel proEquRel = new VmProEquRel();
  363. proEquRel.setId(id); //设备商品关联表id
  364. proEquRel.setProductId(proId); //商品id
  365. proEquRel.setEquipmentId(equId); //设备id
  366. VmProEquRelExample example = new VmProEquRelExample();
  367. if(CommonUtil.isEmpty(aisle)){
  368. example.createCriteria().andChannelEqualTo(channel)
  369. .andEquipmentIdEqualTo(equId)
  370. .andAisleEqualTo(perRow.concat(perLine))
  371. .andExeitStateEqualTo("00");
  372. List<VmProEquRel> list = Service.lookup(IMINDataBaseService.class)
  373. .getMybatisMapper(VmProEquRelMapper.class)
  374. .selectByExample(example);
  375. if(list.size() != 0){
  376. throw new MINBusinessException("该设备默认货道指令已被使用!");
  377. }
  378. proEquRel.setAisle(perRow.concat(perLine)); //货道指令
  379. }else{
  380. example.createCriteria().andChannelEqualTo(channel)
  381. .andEquipmentIdEqualTo(equId)
  382. .andAisleEqualTo(aisle)
  383. .andExeitStateEqualTo("00");
  384. List<VmProEquRel> list = Service.lookup(IMINDataBaseService.class)
  385. .getMybatisMapper(VmProEquRelMapper.class)
  386. .selectByExample(example);
  387. if(list.size() != 0){
  388. throw new MINBusinessException("该设备货道指令已使用!");
  389. }
  390. proEquRel.setAisle(aisle); //货道指令
  391. }
  392. proEquRel.setCargoWayRow(perRow); //货道层
  393. proEquRel.setCargoWayLine(perLine); //货道列
  394. proEquRel.setCargoWayNums(perNum); //货道容量
  395. proEquRel.setProductNums(numbers); //商品余量
  396. proEquRel.setSallPrice(sallPrice); //售货价
  397. proEquRel.setGamePrice(gamePrice); //游戏价
  398. proEquRel.setCostPrice(costPrice); //成本价
  399. proEquRel.setIsPromotion(isPromotton); //是否促销
  400. proEquRel.setPromotionPrice(promottonPrice); //促销价
  401. /* proEquRel.setIsFragile(isFragile); //是否易碎
  402. */ proEquRel.setUserId(uId); //商户id
  403. proEquRel.setRemarks(perRemarks); //备注
  404. proEquRel.setGameType(type); //游戏类型
  405. proEquRel.setChannel(channel); //渠道
  406. proEquRel.setCreateUser(uId); //创建人
  407. proEquRel.setCreateTime(dateTime); //创建时间
  408. proEquRel.setModifyUser(uId); //最后修改人
  409. proEquRel.setModifyTime(dateTime); //最后修改时间
  410. proEquRel.setExeitState("00"); //状态 00正常
  411. Service.lookup(IMINDataBaseService.class)
  412. .getMybatisMapper(VmProEquRelMapper.class)
  413. .insertSelective(proEquRel);
  414. return res;
  415. }
  416. /**
  417. * 修改设备商品
  418. * @param perId 设备商品关联id
  419. * @param perRow 货道层
  420. * @param perLine 货道列
  421. * @param perNum 货道容量
  422. * @param numbers 商品余量
  423. * @param sallPrice 售货价
  424. * @param gamePrice 游戏价
  425. * @param costPrice 成本价
  426. * @param isPromotton 是否促销
  427. * @param promottonPrice 促销价
  428. * @param isFragile 是否易碎
  429. * @param perRemarks 备注
  430. * @param proId 商品id
  431. * @param equId 设备id
  432. * @param perState 状态
  433. * @param session
  434. * @return
  435. * @throws MINBusinessException
  436. */
  437. @MINAction(value = EDIT_PROEQUREL)
  438. public MINActionResult editProEquRel(
  439. @MINParam(key = "perId") String perId,
  440. @MINParam(key = "aisle") String aisle,
  441. @MINParam(key = "perRow") String perRow,
  442. @MINParam(key = "perLine") String perLine,
  443. @MINParam(key = "perNum") String perNum,
  444. @MINParam(key = "numbers") String numbers,
  445. @MINParam(key = "sallPrice") String sallPrice,
  446. @MINParam(key = "gamePrice") String gamePrice,
  447. @MINParam(key = "costPrice") String costPrice,
  448. @MINParam(key = "type") String type,
  449. @MINParam(key = "isPromotton") String isPromotton,
  450. @MINParam(key = "promottonPrice") String promottonPrice,
  451. @MINParam(key = "isFragile") String isFragile,
  452. @MINParam(key = "perRemarks") String perRemarks,
  453. @MINParam(key = "proId") String proId,
  454. @MINParam(key = "equId") String equId,
  455. @MINParam(key = "perState") String perState,
  456. @MINParam(key = "luck") String luck,
  457. MINSession session
  458. ) throws MINBusinessException {
  459. MINActionResult res = new MINActionResult();
  460. //当前时间
  461. String dateTime = DateUtil.getCurrentDateTimeString();
  462. User user = session.getUser();
  463. //操作员id
  464. String uId = user.getId();
  465. //渠道
  466. String channel = user.getChannel();
  467. //校验设备是否正常
  468. VmEquipmentInf equipmentInf = Service.lookup(IMINDataBaseService.class)
  469. .getMybatisMapper(VmEquipmentInfMapper.class)
  470. .selectByPrimaryKey(equId);
  471. if(equipmentInf == null){
  472. throw new MINBusinessException("该设备不存在!");
  473. }else if(equipmentInf.getState().equals(Constant.EQUIPMENT_STT_03)){
  474. throw new MINBusinessException("该设备已销毁!");
  475. }
  476. int comcosAndsal = CommonUtil.compare(costPrice, sallPrice);
  477. /* int comcosAndgam = CommonUtil.compare(costPrice, gamePrice);
  478. int comgamAndsal = CommonUtil.compare(gamePrice, sallPrice);*/
  479. // int comcosAndpro = CommonUtil.compare(costPrice, promottonPrice);
  480. int comproAndsal = CommonUtil.compare(promottonPrice, sallPrice);
  481. int comnumAndper = CommonUtil.compare(numbers, perNum);
  482. if (comcosAndsal == 1 || comcosAndsal == 0) {
  483. throw new MINBusinessException("成本价不能大于或等于售货价!");
  484. }
  485. /*if (comcosAndgam == 1 || comcosAndgam == 0) {
  486. throw new MINBusinessException("成本价不能大于或等于游戏价!");
  487. }
  488. if (comgamAndsal == 1 || comgamAndsal == 0) {
  489. throw new MINBusinessException("游戏价不能大于或等于售货价!");
  490. }*/
  491. // if (comcosAndpro == 1 || comcosAndpro == 0) {
  492. // throw new MINBusinessException("成本价不能大于或等于促销价!");
  493. // }
  494. if (comproAndsal == 1 || comproAndsal == 0) {
  495. throw new MINBusinessException("促销价不能大于或等于售货价!");
  496. }
  497. if (comnumAndper == 1 ) {
  498. throw new MINBusinessException("商品余量不能大于货道容量!");
  499. }
  500. //校验商品是否正常
  501. // VmProductInf pro = Service.lookup(IMINDataBaseService.class)
  502. // .getMybatisMapper(VmProductInfMapper.class)
  503. // .selectByPrimaryKey(proId);
  504. VmProEquRel proEquRel = Service.lookup(IMINDataBaseService.class)
  505. .getMybatisMapper(VmProEquRelMapper.class)
  506. .selectByPrimaryKey(perId);
  507. // if(pro == null||pro.getState().equals("2")||proEquRel == null||proEquRel.getExeitState().equals("2")) {
  508. // throw new BusinessCodeException("JINM0123");//商品信息异常
  509. // }
  510. //修改设备新增商品
  511. if(!CommonUtil.isEmpty(proId)){
  512. proEquRel.setProductId(proId); //商品id
  513. }
  514. if(!CommonUtil.isEmpty(equId)){
  515. proEquRel.setEquipmentId(equId); //设备id
  516. }
  517. if(!CommonUtil.isEmpty(aisle)){
  518. VmProEquRelExample example = new VmProEquRelExample();
  519. example.createCriteria().andChannelEqualTo(channel)
  520. .andEquipmentIdEqualTo(equId)
  521. .andAisleEqualTo(aisle)
  522. .andExeitStateEqualTo(Constant.PROEQUREL_STT_00)
  523. .andIdNotEqualTo(perId);
  524. List<VmProEquRel> list = Service.lookup(IMINDataBaseService.class)
  525. .getMybatisMapper(VmProEquRelMapper.class)
  526. .selectByExample(example);
  527. if(list.size() != 0){
  528. throw new MINBusinessException("该设备货道指令已使用!");
  529. }
  530. proEquRel.setAisle(aisle); //货道指令
  531. }
  532. if(!CommonUtil.isEmpty(perRow)){
  533. proEquRel.setCargoWayRow(perRow); //货道层
  534. }
  535. if(!CommonUtil.isEmpty(perLine)){
  536. proEquRel.setCargoWayLine(perLine); //货道列
  537. }
  538. if(!CommonUtil.isEmpty(perNum)){
  539. proEquRel.setCargoWayNums(perNum); //货道容量
  540. }
  541. if(!CommonUtil.isEmpty(numbers)){
  542. proEquRel.setProductNums(numbers); //商品余量
  543. }
  544. if(!CommonUtil.isEmpty(sallPrice)){
  545. proEquRel.setSallPrice(sallPrice); //售货价
  546. }
  547. if(!CommonUtil.isEmpty(gamePrice)){
  548. proEquRel.setGamePrice(gamePrice); //游戏价
  549. }
  550. if(!CommonUtil.isEmpty(costPrice)){
  551. proEquRel.setCostPrice(costPrice); //成本价
  552. }
  553. if(!CommonUtil.isEmpty(isPromotton)){
  554. proEquRel.setIsPromotion(isPromotton); //是否促销
  555. }
  556. if(!CommonUtil.isEmpty(promottonPrice)){
  557. proEquRel.setPromotionPrice(promottonPrice); //促销价
  558. }
  559. /*if(!CommonUtil.isEmpty(isFragile)){
  560. proEquRel.setIsFragile(isFragile); //是否易碎
  561. }*/
  562. if(!CommonUtil.isEmpty(perRemarks)){
  563. proEquRel.setRemarks(perRemarks); //备注
  564. }
  565. proEquRel.setGameType(type); //游戏类型
  566. proEquRel.setModifyUser(uId); //最后修改人
  567. proEquRel.setModifyTime(dateTime); //最后修改时间
  568. if(!CommonUtil.isEmpty(perState)){
  569. proEquRel.setExeitState(perState); //状态
  570. }
  571. Service.lookup(IMINDataBaseService.class)
  572. .getMybatisMapper(VmProEquRelMapper.class)
  573. .updateByPrimaryKeySelective(proEquRel);
  574. return res;
  575. }
  576. /**
  577. * 查询设备中商品
  578. * @param temName 模版名称
  579. * @param temState 状态
  580. * @param session
  581. * @return
  582. * @throws MINBusinessException
  583. */
  584. @MINAction(value = QUERY_PROEQU)
  585. public MINActionResult queryProEqu(
  586. @MINParam(key = "equId") String equId,
  587. @MINParam(key = "perId") String perId,
  588. MINSession session
  589. ) throws MINBusinessException {
  590. MINActionResult res = new MINActionResult();
  591. User user = session.getUser();
  592. //渠道
  593. String channel = user.getChannel();
  594. // 查询条件
  595. Map<String, String> map = new HashMap<String, String>();
  596. map.put("channel", "V01");
  597. map.put("equId", equId);
  598. map.put("perId", perId);
  599. List<Map<String, Object>> list = Service.lookup(IMINDataBaseService.class)
  600. .getMybatisMapper(MachineManageMapper.class)
  601. .queryProEquRel(map);
  602. //格式化时间和状态
  603. list = Service.lookup(IFormatService.class).formatDateTime(list, "createTime","modifyTime");
  604. list = new MINCopyFormat("{perState:'sttDesc',isPromotton:'isPromottonDesc',isFragile:'isFragileDesc'}").format(list);
  605. list = Service.lookup(IFormatService.class).formatEnum(list, "{sttDesc:'PROEQUREL_STATE',isPromottonDesc:'IS_PROMOTION',isFragileDesc:'IS_FRAGILE'}");
  606. //传递数据
  607. res.set(IMINBusinessConstant.F_PAGING_LAY, list);
  608. return res;
  609. }
  610. /**
  611. * 删除货道
  612. * @param perId 设备商品关联id
  613. * @param proId 商品id
  614. * @param equId 设备id
  615. * @param perState 状态
  616. * @param session
  617. * @return
  618. * @throws MINBusinessException
  619. */
  620. @MINAction(value = DEL_EQUPRO)
  621. public MINActionResult delEquPro(
  622. @MINParam(key = "equId") String equId,
  623. @MINParam(key = "perRow") String perRow,
  624. @MINParam(key = "perLine") String perLine,
  625. @MINParam(key = "perState") String perState,
  626. MINSession session
  627. ) throws MINBusinessException {
  628. MINActionResult res = new MINActionResult();
  629. //当前时间
  630. String dateTime = DateUtil.getCurrentDateTimeString();
  631. User user = session.getUser();
  632. //操作员id
  633. String uId = user.getId();
  634. //渠道
  635. String channel = user.getChannel();
  636. //校验设备是否正常
  637. VmEquipmentInf equipmentInf = Service.lookup(IMINDataBaseService.class)
  638. .getMybatisMapper(VmEquipmentInfMapper.class)
  639. .selectByPrimaryKey(equId);
  640. if(equipmentInf == null){
  641. throw new MINBusinessException("该设备不存在!");
  642. }else if(equipmentInf.getState().equals(Constant.EQUIPMENT_STT_03)){
  643. throw new MINBusinessException("该设备已销毁!");
  644. }
  645. VmProEquRelExample equRelExample = new VmProEquRelExample();
  646. equRelExample.createCriteria().andEquipmentIdEqualTo(equId)
  647. .andCargoWayRowEqualTo(perRow)
  648. .andCargoWayLineEqualTo(perLine)
  649. .andChannelEqualTo(channel)
  650. .andExeitStateNotEqualTo(Constant.PROEQUREL_STT_02);
  651. List<VmProEquRel> list = Service.lookup(IMINDataBaseService.class)
  652. .getMybatisMapper(VmProEquRelMapper.class)
  653. .selectByExample(equRelExample);
  654. if(list.size() != 0){
  655. throw new MINBusinessException("此货道无法删除!");
  656. }
  657. //删除货道
  658. String id = Service.lookup(IPublicService.class).getSequence("VM_PROEQUREL_ID");
  659. VmProEquRel proEquRel = new VmProEquRel();
  660. proEquRel.setId(id); //设备商品关联表id
  661. proEquRel.setEquipmentId(equId); //设备id
  662. proEquRel.setCargoWayRow(perRow); //货道层
  663. proEquRel.setCargoWayLine(perLine); //货道列
  664. proEquRel.setUserId(uId); //商户id
  665. proEquRel.setRemarks("货道删除"); //备注
  666. proEquRel.setChannel(channel); //渠道
  667. proEquRel.setCreateUser(uId); //创建人
  668. proEquRel.setCreateTime(dateTime); //创建时间
  669. proEquRel.setModifyUser(uId); //最后修改人
  670. proEquRel.setModifyTime(dateTime); //最后修改时间
  671. proEquRel.setExeitState(Constant.PROEQUREL_STT_01); //状态 01货道删除
  672. Service.lookup(IMINDataBaseService.class)
  673. .getMybatisMapper(VmProEquRelMapper.class)
  674. .insertSelective(proEquRel);
  675. return res;
  676. }
  677. /**
  678. * 删除
  679. * @param perId 设备商品关联id
  680. * @param proId 商品id
  681. * @param equId 设备id
  682. * @param perState 状态
  683. * @param session
  684. * @return
  685. * @throws MINBusinessException
  686. */
  687. @MINAction(value = DEL_PROEQU)
  688. public MINActionResult delProEqu(
  689. @MINParam(key = "perId") String perId,
  690. @MINParam(key = "perState") String perState,
  691. MINSession session
  692. ) throws MINBusinessException {
  693. MINActionResult res = new MINActionResult();
  694. //当前时间
  695. String dateTime = DateUtil.getCurrentDateTimeString();
  696. User user = session.getUser();
  697. //操作员id
  698. String uId = user.getId();
  699. //渠道
  700. // String channel = user.getChannel();
  701. //校验设备是否正常
  702. /*VmEquipmentInf equipmentInf = Service.lookup(IMINDataBaseService.class)
  703. .getMybatisMapper(VmEquipmentInfMapper.class)
  704. .selectByPrimaryKey(equId);
  705. if(equipmentInf == null){
  706. throw new MINBusinessException("该设备不存在!");
  707. }else if(equipmentInf.getState().equals(Constant.EQUIPMENT_STT_03)){
  708. throw new MINBusinessException("该设备已销毁!");
  709. }
  710. */
  711. VmProEquRel proEquRel = Service.lookup(IMINDataBaseService.class)
  712. .getMybatisMapper(VmProEquRelMapper.class)
  713. .selectByPrimaryKey(perId);
  714. //删除
  715. proEquRel.setId(perId);
  716. proEquRel.setExeitState(Constant.PROEQUREL_STT_02); //状态
  717. proEquRel.setModifyUser(uId); //最后修改人
  718. proEquRel.setModifyTime(dateTime); //最后修改时间
  719. Service.lookup(IMINDataBaseService.class)
  720. .getMybatisMapper(VmProEquRelMapper.class)
  721. .updateByPrimaryKeySelective(proEquRel);
  722. return res;
  723. }
  724. }