| | |
| | | import com.matrix.system.hive.bean.*; |
| | | import com.matrix.system.hive.dao.*; |
| | | import com.matrix.system.hive.service.SysVipInfoService; |
| | | import org.springframework.beans.BeanUtils; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.jdbc.core.JdbcTemplate; |
| | | import org.springframework.stereotype.Service; |
| | | import org.springframework.transaction.annotation.Transactional; |
| | | |
| | | import java.io.UnsupportedEncodingException; |
| | | import java.math.BigDecimal; |
| | | import java.security.NoSuchAlgorithmException; |
| | | import java.util.*; |
| | | |
| | |
| | | private ShoppingGoodsDao shoppingGoodsDao; |
| | | @Autowired |
| | | private ShoppingGoodsAssembleDao shoppingGoodsAssembleDao; |
| | | @Autowired |
| | | private MoneyCardUseDao moneyCardUseDao; |
| | | |
| | | @Autowired |
| | | private RedisClient redisClient; |
| | |
| | | vipInfoIds.put(oldId, sysVipInfo.getId()); |
| | | sysVipInfoService.addVipDefaultCard(sysVipInfo.getId()); |
| | | } |
| | | |
| | | redisClient.saveMapValue("vip_info", vipInfoIds); |
| | | } |
| | | } |
| | | |
| | |
| | | |
| | | @DS("slave") |
| | | public List<SysOrder> orderOld() { |
| | | return null; |
| | | List<Map<String, Object>> maps = jdbcTemplate.queryForList("select * from sys_order"); |
| | | List<SysOrder> orders = mapsToListBean(maps, SysOrder.class); |
| | | |
| | | |
| | | Map<String, Integer> goodsSku = getRedisIds("shopping_goods_sku"); |
| | | Map<String, Integer> goodProj = getRedisIds("shopping_goods_proj"); |
| | | Map<String, Integer> goodTc = getRedisIds("shopping_goods_tc"); |
| | | Map<String, Integer> goodCZK = getRedisIds("shopping_goods_czk"); |
| | | Map<String, Integer> goodZHK = getRedisIds("shopping_goods_zhk"); |
| | | Map<String, Integer> shopIds = getRedisIds("shopId"); |
| | | Map<String, Integer> sysUsers = getRedisIds("sys_users"); |
| | | Map<String, Integer> vipInfos = getRedisIds("vip_info"); |
| | | for (SysOrder order : orders) { |
| | | List<Map<String, Object>> itemsMap = jdbcTemplate.queryForList("select * from sys_order_item where ORDER_ID=" + order.getId()); |
| | | |
| | | Integer shopId = shopIds.get(order.getShopId().toString()); |
| | | order.setShopId(shopId.longValue()); |
| | | |
| | | Integer statffId = sysUsers.get(order.getStaffId().toString()); |
| | | if (statffId != null) { |
| | | order.setStaffId(statffId.longValue()); |
| | | } else { |
| | | order.setStaffId(-order.getStaffId()); |
| | | } |
| | | Integer vipId = vipInfos.get(order.getVipId().toString()); |
| | | if (vipId != null) { |
| | | order.setVipId(vipId.longValue()); |
| | | } else { |
| | | order.setVipId(-order.getVipId()); |
| | | } |
| | | |
| | | order.setCompanyId(companyId); |
| | | |
| | | List<SysOrderItem> items = mapsToListBean(itemsMap, SysOrderItem.class); |
| | | |
| | | Double cardPay = 0D; |
| | | Double cashPay = 0D; |
| | | Double arrears = 0D; |
| | | Map<Long, Long> shoppingGoodsIds = new HashMap<>(); |
| | | if (CollUtil.isNotEmpty(items)) { |
| | | Long goodsId = items.get(0).getGoodsId(); |
| | | Map<String, Object> goods = jdbcTemplate.queryForMap("select * from shopping_goods where id=" + goodsId); |
| | | order.setShopShortName((String) goods.get("name")); |
| | | for (SysOrderItem item : items) { |
| | | Double itemCard = item.getCardPay() == null ? 0D : item.getCardPay(); |
| | | Double itemCash = item.getCashPay() == null ? 0D : item.getCashPay(); |
| | | Double itemArrears = item.getArrears() == null ? 0D : item.getArrears(); |
| | | |
| | | cardPay += itemCard; |
| | | cashPay += itemCash; |
| | | arrears += itemArrears; |
| | | |
| | | if (itemCard != 0) { |
| | | item.setPayMethod("划扣"); |
| | | } else { |
| | | item.setPayMethod("现金"); |
| | | } |
| | | |
| | | Long oldID = item.getGoodsId(); |
| | | switch (item.getType()) { |
| | | case "家居产品" : |
| | | Map<String, Object> skuMap = jdbcTemplate.queryForMap("select * from shopping_goods_assemble where id=" + item.getAssembleId()); |
| | | Long skuId = (Long) skuMap.get("assemble_sku_id"); |
| | | Integer skuGoodsId = goodsSku.get(skuId.toString()); |
| | | if (skuGoodsId != null) { |
| | | item.setGoodsId(skuGoodsId.longValue()); |
| | | } else { |
| | | item.setGoodsId(-item.getAssembleId()); |
| | | } |
| | | break; |
| | | case "项目" : |
| | | Map<String, Object> projMap = jdbcTemplate.queryForMap("select * from shopping_goods_assemble where id=" + item.getAssembleId()); |
| | | Long projId = (Long) projMap.get("assemble_proj_id"); |
| | | Integer projGoodsId = goodProj.get(projId.toString()); |
| | | if (projGoodsId != null) { |
| | | item.setGoodsId(projGoodsId.longValue()); |
| | | } else { |
| | | item.setGoodsId(-item.getAssembleId()); |
| | | } |
| | | break; |
| | | case "套餐" : |
| | | Integer tcId = goodTc.get(item.getGoodsId().toString()); |
| | | if (tcId != null) { |
| | | item.setGoodsId(tcId.longValue()); |
| | | } else { |
| | | item.setGoodsId(-item.getGoodsId()); |
| | | } |
| | | break; |
| | | case "充值卡" : |
| | | Integer czkId = goodCZK.get(item.getGoodsId().toString()); |
| | | if (czkId != null) { |
| | | item.setGoodsId(czkId.longValue()); |
| | | } else { |
| | | item.setGoodsId(-item.getGoodsId()); |
| | | } |
| | | break; |
| | | case "综合卡" : |
| | | Integer zhkId = goodZHK.get(item.getGoodsId().toString()); |
| | | if (zhkId != null) { |
| | | item.setGoodsId(zhkId.longValue()); |
| | | } else { |
| | | item.setGoodsId(-item.getGoodsId()); |
| | | } |
| | | break; |
| | | default: |
| | | } |
| | | |
| | | shoppingGoodsIds.put(oldID, item.getGoodsId()); |
| | | } |
| | | order.setItems(items); |
| | | } |
| | | |
| | | List<SysOrderFlow> flows = new ArrayList<>(); |
| | | if (cardPay != 0D) { |
| | | flows.add(setOrderFLow(order, "储值卡", cardPay, 1)); |
| | | } |
| | | |
| | | if (cashPay != 0D) { |
| | | flows.add(setOrderFLow(order, "现金支付", cashPay, 1)); |
| | | } |
| | | |
| | | if (arrears != 0D) { |
| | | flows.add(setOrderFLow(order, "欠款", arrears, 1)); |
| | | } |
| | | order.setFlows(flows); |
| | | |
| | | List<Map<String, Object>> achievesMap = jdbcTemplate.queryForList("select sale_id, beault_id, shop_id, datatime, order_id, order_item_id, shopping_goods_id, vip_id, order_type, sum(t1) as t1 from achieve_new where order_type='订单' and order_id="+ order.getId() + " group by sale_id, beault_id, shop_id, datatime, order_id, order_item_id, shopping_goods_id, vip_id, order_type"); |
| | | if (CollUtil.isNotEmpty(achievesMap)) { |
| | | List<AchieveNew> achieves = mapsToListBean(achievesMap, AchieveNew.class); |
| | | for (AchieveNew achieve : achieves) { |
| | | Integer achiShopId = shopIds.get(achieve.getShopId().toString()); |
| | | achieve.setShopId(achiShopId.longValue()); |
| | | |
| | | if (achieve.getBeaultId() == null) { |
| | | achieve.setBeaultId(achieve.getSaleId()); |
| | | achieve.setAchieveType("顾问业绩"); |
| | | } else { |
| | | achieve.setAchieveType("美疗师业绩"); |
| | | } |
| | | Integer beaultId = sysUsers.get(achieve.getBeaultId().toString()); |
| | | if (beaultId != null) { |
| | | achieve.setBeaultId(beaultId.longValue()); |
| | | } else { |
| | | achieve.setBeaultId(-achieve.getBeaultId()); |
| | | } |
| | | |
| | | Integer saleId = sysUsers.get(achieve.getSaleId().toString()); |
| | | if (saleId != null) { |
| | | achieve.setSaleId(saleId.longValue()); |
| | | } else { |
| | | achieve.setSaleId(-achieve.getSaleId()); |
| | | } |
| | | |
| | | Integer achiVipId = vipInfos.get(achieve.getVipId().toString()); |
| | | if (achiVipId != null) { |
| | | achieve.setVipId(achiVipId.longValue()); |
| | | } else { |
| | | achieve.setVipId(-achieve.getVipId()); |
| | | } |
| | | achieve.setGoodsCash(Double.parseDouble(achieve.getT1())); |
| | | achieve.setCompanyId(companyId); |
| | | achieve.setShoppingGoodsId(shoppingGoodsIds.get(achieve.getShoppingGoodsId())); |
| | | |
| | | } |
| | | order.setAchieveNews(achieves); |
| | | } |
| | | } |
| | | return orders; |
| | | } |
| | | |
| | | public SysOrderFlow setOrderFLow(SysOrder sysOrder, String type, Double amount, int index) { |
| | | SysOrderFlow flow = new SysOrderFlow(); |
| | | flow.setFlowContent(sysOrder.getShopShortName() + "等" + sysOrder.getItems().size() + "件产品"); |
| | | flow.setFlowType(SysOrderFlow.FLOW_TYPE_BUY); |
| | | flow.setAmount(new BigDecimal(amount)); |
| | | flow.setFlowNo("F" + sysOrder.getOrderNo() + "-" + index); |
| | | flow.setVipId(sysOrder.getVipId()); |
| | | flow.setShopId(sysOrder.getShopId()); |
| | | flow.setCompanyId(sysOrder.getCompanyId()); |
| | | flow.setPayMethod(type); |
| | | return flow; |
| | | } |
| | | |
| | | @Autowired |
| | | private SysOrderDao sysOrderDao; |
| | | @Autowired |
| | | private SysOrderItemDao sysOrderItemDao; |
| | | @Autowired |
| | | private SysOrderFlowDao sysOrderFlowDao; |
| | | @Autowired |
| | | private AchieveNewDao achieveNewDao; |
| | | |
| | | @Transactional(rollbackFor = Exception.class) |
| | | public void orderNew(List<SysOrder> list) { |
| | | if (CollUtil.isNotEmpty(list)) { |
| | | Map<Long, Long> orderIds = new HashMap<>(); |
| | | Map<Long, Long> itemIds = new HashMap<>(); |
| | | |
| | | for (SysOrder sysOrder : list) { |
| | | Long oldOrderId = sysOrder.getId(); |
| | | sysOrder.setId(null); |
| | | sysOrderDao.insert(sysOrder); |
| | | orderIds.put(oldOrderId, sysOrder.getId()); |
| | | |
| | | if (CollUtil.isNotEmpty(sysOrder.getItems())) { |
| | | for (SysOrderItem item : sysOrder.getItems()) { |
| | | Long oldItemId = item.getId(); |
| | | item.setOrderId(sysOrder.getId()); |
| | | item.setId(null); |
| | | sysOrderItemDao.insert(item); |
| | | itemIds.put(oldItemId, item.getId()); |
| | | } |
| | | } |
| | | |
| | | if (CollUtil.isNotEmpty(sysOrder.getFlows())) { |
| | | for (SysOrderFlow flow : sysOrder.getFlows()) { |
| | | if ("储值卡".equals(flow.getPayMethod())) { |
| | | MoneyCardUse moneyCardUse = new MoneyCardUse(); |
| | | moneyCardUse.setIsVipCar("Y"); |
| | | moneyCardUse.setVipId(flow.getVipId()); |
| | | List<MoneyCardUse> moneyCardUses = moneyCardUseDao.selectVipCardUse(moneyCardUse); |
| | | if (CollUtil.isNotEmpty(moneyCardUses)) { |
| | | flow.setCardId(moneyCardUses.get(0).getId()); |
| | | } |
| | | } |
| | | flow.setOrderId(sysOrder.getId()); |
| | | flow.setCreateBy("数据迁移"); |
| | | sysOrderFlowDao.insert(flow); |
| | | } |
| | | } |
| | | |
| | | if (CollUtil.isNotEmpty(sysOrder.getAchieveNews())) { |
| | | for (AchieveNew achieveNew : sysOrder.getAchieveNews()) { |
| | | achieveNew.setOrderId(sysOrder.getId()); |
| | | Long item = itemIds.get(achieveNew.getOrderItemId()); |
| | | achieveNew.setT9("数据迁移"); |
| | | achieveNew.setOrderItemId(item); |
| | | achieveNew.setId(null); |
| | | } |
| | | |
| | | achieveNewDao.batchInsert(sysOrder.getAchieveNews()); |
| | | } |
| | | } |
| | | |
| | | redisClient.saveMapValue("order", orderIds); |
| | | redisClient.saveMapValue("order_item", itemIds); |
| | | } |
| | | } |
| | | |
| | | @DS("slave") |
| | | public List<SysBedInfo> bedInfoOld() { |
| | | List<Map<String, Object>> maps = jdbcTemplate.queryForList("select * from sys_bed_info"); |
| | | List<SysBedInfo> beds = mapsToListBean(maps, SysBedInfo.class); |
| | | |
| | | Map<String, Integer> shopIds = getRedisIds("shopId"); |
| | | for (SysBedInfo bed : beds) { |
| | | Integer shopId = shopIds.get(bed.getShopId().toString()); |
| | | if (shopId != null) { |
| | | bed.setShopId(shopId.longValue()); |
| | | } else { |
| | | bed.setShopId(-bed.getShopId()); |
| | | } |
| | | } |
| | | return beds; |
| | | } |
| | | |
| | | @Autowired |
| | | private SysBedInfoDao sysBedInfoDao; |
| | | |
| | | @Transactional(rollbackFor = Exception.class) |
| | | public void bedInfoNew(List<SysBedInfo> list) { |
| | | if (CollUtil.isNotEmpty(list)) { |
| | | Map<Long, Long> map = new HashMap<>(); |
| | | for (SysBedInfo bed : list) { |
| | | Long oldId = bed.getId(); |
| | | bed.setId(null); |
| | | sysBedInfoDao.insert(bed); |
| | | map.put(oldId, bed.getId()); |
| | | } |
| | | |
| | | redisClient.saveMapValue("bed_info", map); |
| | | } |
| | | } |
| | | |
| | | @DS("slave") |
| | | public List<SysProjUse> projUseMoveOld() { |
| | | List<Map<String, Object>> maps = jdbcTemplate.queryForList("select * from sys_proj_use"); |
| | | List<SysProjUse> projUses = mapsToListBean(maps, SysProjUse.class); |
| | | |
| | | Map<String, Integer> goodProj = getRedisIds("shopping_goods_proj"); |
| | | Map<String, Integer> goodTc = getRedisIds("shopping_goods_tc"); |
| | | Map<String, Integer> vipInfos = getRedisIds("vip_info"); |
| | | for (SysProjUse projUse : projUses) { |
| | | if (projUse.getTaocanId() != null) { |
| | | Integer tcId = goodTc.get(projUse.getTaocanId().toString()); |
| | | if (tcId != null) { |
| | | projUse.setTaocanId(tcId.longValue()); |
| | | } else { |
| | | projUse.setTaocanId(-projUse.getTaocanId()); |
| | | } |
| | | } |
| | | |
| | | if (projUse.getProjId() != null) { |
| | | Integer projId = goodProj.get(projUse.getProjId().toString()); |
| | | if (projId != null) { |
| | | projUse.setProjId(projId.longValue()); |
| | | } else { |
| | | projUse.setProjId(-projUse.getProjId()); |
| | | } |
| | | } |
| | | |
| | | Integer vipId = vipInfos.get(projUse.getVipId().toString()); |
| | | if (vipId != null) { |
| | | projUse.setVipId(vipId.longValue()); |
| | | } else { |
| | | projUse.setVipId(-projUse.getVipId()); |
| | | } |
| | | } |
| | | return projUses; |
| | | } |
| | | |
| | | @Autowired |
| | | private SysProjUseDao sysProjUseDao; |
| | | |
| | | @Transactional(rollbackFor = Exception.class) |
| | | public void projUseNew(List<SysProjUse> list) { |
| | | if (CollUtil.isNotEmpty(list)) { |
| | | Map<Long, Long> map = new HashMap<>(); |
| | | for (SysProjUse sysProjUse : list) { |
| | | if(sysProjUse.getType() == "套餐卡") { |
| | | sysProjUse.setType("套餐"); |
| | | } else if (StrUtil.isEmpty(sysProjUse.getType())){ |
| | | sysProjUse.setType("项目"); |
| | | } |
| | | |
| | | Long oldId = sysProjUse.getId(); |
| | | sysProjUse.setId(null); |
| | | sysProjUseDao.insert(sysProjUse); |
| | | map.put(oldId, sysProjUse.getId()); |
| | | } |
| | | |
| | | redisClient.saveMapValue("proj_use", map); |
| | | } |
| | | } |
| | | |
| | | @DS("slave") |
| | | public List<SysProjServices> serviceOrderOld() { |
| | | List<Map<String, Object>> maps = jdbcTemplate.queryForList("select * from sys_proj_services"); |
| | | List<SysProjServices> list = mapsToListBean(maps, SysProjServices.class); |
| | | |
| | | |
| | | Map<String, Integer> vipInfos = getRedisIds("vip_info"); |
| | | Map<String, Integer> bedInfos = getRedisIds("bed_info"); |
| | | Map<String, Integer> sysUsers = getRedisIds("sys_users"); |
| | | Map<String, Integer> projUses = getRedisIds("proj_use"); |
| | | Map<String, Integer> goodProj = getRedisIds("shopping_goods_proj"); |
| | | Map<String, Integer> shopIds = getRedisIds("shopId"); |
| | | for (SysProjServices sysProjServices : list) { |
| | | List<Map<String, Object>> beauticiansMap = jdbcTemplate.queryForList("select * from sys_beautician_state where SERVICES_ID=" + sysProjServices.getId()); |
| | | // Map<String, Object> bedStatesMap = jdbcTemplate.queryForMap("select * from sys_bed_state where SERVICE_ID=" + sysProjServices.getId()); |
| | | // List<Map<String, Object>> achieveMaps = jdbcTemplate.queryForList("select * from achieve_new where service_order_id=" + sysProjServices.getId()); |
| | | |
| | | |
| | | SysBedState query = new SysBedState(); |
| | | query.setServiceId(sysProjServices.getId()); |
| | | List<SysBedState> queryBeds = sysBedStateDao.selectByModel(query); |
| | | SysBedState bedStates = null; |
| | | if (CollUtil.isNotEmpty(queryBeds)) { |
| | | bedStates = queryBeds.get(0); |
| | | } |
| | | List<SysBeauticianState> beauticians = mapsToListBean(beauticiansMap, SysBeauticianState.class); |
| | | List<AchieveNew> achieveNews = achieveNewDao.selectAchieveByServiceOrderId(sysProjServices.getId()); |
| | | // SysBedState bedStates = mapToBane(bedStatesMap, SysBedState.class); |
| | | |
| | | Integer shopId = shopIds.get(sysProjServices.getShopId().toString()); |
| | | if (shopId != null) { |
| | | sysProjServices.setShopId(shopId.longValue()); |
| | | } else { |
| | | sysProjServices.setShopId(-sysProjServices.getShopId()); |
| | | } |
| | | |
| | | if (sysProjServices.getBedId() != null) { |
| | | Integer bedId = bedInfos.get(sysProjServices.getBedId().toString()); |
| | | if (bedId != null) { |
| | | sysProjServices.setBedId(bedId.longValue()); |
| | | bedStates.setBedId(bedId.longValue()); |
| | | } else { |
| | | sysProjServices.setBedId(-sysProjServices.getBedId()); |
| | | bedStates.setBedId(-sysProjServices.getBedId()); |
| | | } |
| | | sysProjServices.setBedState(bedStates); |
| | | } |
| | | |
| | | if (sysProjServices.getBeauticianId() != null) { |
| | | Integer beautyId = sysUsers.get(sysProjServices.getBeauticianId().toString()); |
| | | if (beautyId != null) { |
| | | sysProjServices.setBeauticianId(beautyId.longValue()); |
| | | } else { |
| | | sysProjServices.setBeauticianId(-sysProjServices.getBeauticianId()); |
| | | } |
| | | } |
| | | |
| | | if (sysProjServices.getDevisionId() != null) { |
| | | Integer devisionId = sysUsers.get(sysProjServices.getDevisionId().toString()); |
| | | if (devisionId != null) { |
| | | sysProjServices.setDevisionId(devisionId.longValue()); |
| | | } else { |
| | | sysProjServices.setDevisionId(-sysProjServices.getDevisionId()); |
| | | } |
| | | } |
| | | |
| | | if (sysProjServices.getCreateStaffId() != null) { |
| | | Integer staffId = sysUsers.get(sysProjServices.getCreateStaffId().toString()); |
| | | if (staffId != null) { |
| | | sysProjServices.setCreateStaffId(staffId.longValue()); |
| | | } else { |
| | | sysProjServices.setCreateStaffId(-sysProjServices.getCreateStaffId()); |
| | | } |
| | | } |
| | | Integer vipId = null; |
| | | if (sysProjServices.getVipId() != null) { |
| | | vipId = vipInfos.get(sysProjServices.getVipId().toString()); |
| | | if (vipId != null) { |
| | | sysProjServices.setVipId(vipId.longValue()); |
| | | } else { |
| | | sysProjServices.setVipId(-sysProjServices.getVipId()); |
| | | } |
| | | } |
| | | |
| | | if (CollUtil.isNotEmpty(beauticians)) { |
| | | List<SysBeauticianState> newBeautician = new ArrayList<>(); |
| | | for (SysBeauticianState beautician : beauticians) { |
| | | List<Map<String, Object>> beaProjMaps = jdbcTemplate.queryForList("select distinct proj_id from service_bea_proj where ser_proj_id is not null and bea_state_id=" + beautician.getId()); |
| | | for (Map<String, Object> beaProjMap : beaProjMaps) { |
| | | SysBeauticianState beauticianState = new SysBeauticianState(); |
| | | BeanUtils.copyProperties(beautician, beauticianState); |
| | | String puseIdStr = beaProjMap.get("proj_id").toString(); |
| | | Integer puseId = projUses.get(puseIdStr); |
| | | beauticianState.setPuseId(puseId != null ? puseId.longValue() : -Long.parseLong(puseIdStr)); |
| | | |
| | | SysProjUse sysProjUse = sysProjUseDao.selectById(Long.parseLong(puseIdStr)); |
| | | // Map<String, Object> projUseMap = jdbcTemplate.queryForMap("select * from sys_proj_use where id=" + puseIdStr); |
| | | if (sysProjUse != null) { |
| | | Integer goodsProjId = goodProj.get(sysProjUse.getProjId().toString()); |
| | | beauticianState.setProjId(goodsProjId != null ? goodsProjId.longValue() : -Long.parseLong(sysProjUse.getProjId().toString())); |
| | | } |
| | | |
| | | beauticianState.setCount(1); |
| | | beauticianState.setExtract("数据迁移"); |
| | | newBeautician.add(beauticianState); |
| | | } |
| | | } |
| | | sysProjServices.setServiceItems(newBeautician); |
| | | } |
| | | |
| | | if (CollUtil.isNotEmpty(achieveNews)) { |
| | | for (AchieveNew achieveNew : achieveNews) { |
| | | achieveNew.setShopId(shopId != null ? shopId.longValue() : -achieveNew.getShopId()); |
| | | achieveNew.setVipId(vipId != null ? vipId.longValue() : -achieveNew.getVipId()); |
| | | |
| | | Integer saleIdInt = sysUsers.get(achieveNew.getSaleId() == null ? "" : achieveNew.getSaleId().toString()); |
| | | achieveNew.setSaleId(saleIdInt == null ? -achieveNew.getSaleId() : saleIdInt); |
| | | |
| | | Integer beaultyIdInt = sysUsers.get(achieveNew.getBeaultId() == null ? "" : achieveNew.getBeaultId().toString()); |
| | | achieveNew.setBeaultId(beaultyIdInt == null ? -achieveNew.getBeaultId() : beaultyIdInt); |
| | | |
| | | if (achieveNew.getShoppingGoodsId() != null) { |
| | | Integer goodsId = goodProj.get(achieveNew.getShoppingGoodsId().toString()); |
| | | achieveNew.setShoppingGoodsId(goodsId == null ? -achieveNew.getShoppingGoodsId() : goodsId.longValue()); |
| | | } |
| | | |
| | | achieveNew.setT9("数据迁移"); |
| | | } |
| | | } |
| | | sysProjServices.setAchieveNews(achieveNews); |
| | | |
| | | } |
| | | |
| | | |
| | | return list; |
| | | } |
| | | |
| | | @Autowired |
| | | private SysProjServicesDao sysProjServicesDao; |
| | | @Autowired |
| | | private SysBeauticianStateDao sysBeauticianStateDao; |
| | | @Autowired |
| | | private SysBedStateDao sysBedStateDao; |
| | | |
| | | @Transactional(rollbackFor = Exception.class) |
| | | public void serviceOrderNew(List<SysProjServices> list) { |
| | | if (CollUtil.isNotEmpty(list)) { |
| | | Map<Long, Long> maps = new HashMap<>(); |
| | | Map<Long, Long> beautyMaps = new HashMap<>(); |
| | | for (SysProjServices sysProjServices : list) { |
| | | Long oldId = sysProjServices.getId(); |
| | | sysProjServices.setId(null); |
| | | sysProjServices.setComment("数据迁移"); |
| | | sysProjServices.setCompanyId(companyId); |
| | | sysProjServicesDao.insert(sysProjServices); |
| | | Long newId = sysProjServices.getId(); |
| | | List<SysBeauticianState> serviceItems = sysProjServices.getServiceItems(); |
| | | if (CollUtil.isNotEmpty(serviceItems)) { |
| | | for (SysBeauticianState serviceItem : serviceItems) { |
| | | serviceItem.setServicesId(newId); |
| | | Long beautyOldId = serviceItem.getId(); |
| | | serviceItem.setId(null); |
| | | serviceItem.setExtract("数据迁移"); |
| | | sysBeauticianStateDao.insert(serviceItem); |
| | | beautyMaps.put(beautyOldId, serviceItem.getId()); |
| | | } |
| | | } |
| | | SysBedState bedState = sysProjServices.getBedState(); |
| | | if (bedState != null) { |
| | | bedState.setId(null); |
| | | bedState.setServiceId(newId); |
| | | sysBedStateDao.insert(bedState); |
| | | } |
| | | |
| | | List<AchieveNew> achieveNews = sysProjServices.getAchieveNews(); |
| | | if (CollUtil.isNotEmpty(achieveNews)) { |
| | | for (AchieveNew achieveNew : achieveNews) { |
| | | achieveNew.setId(null); |
| | | achieveNew.setOrderItemId(beautyMaps.get(achieveNew.getOrderItemId())); |
| | | achieveNew.setServiceOrderId(newId); |
| | | } |
| | | achieveNewDao.batchInsert(achieveNews); |
| | | } |
| | | maps.put(oldId, newId); |
| | | } |
| | | |
| | | redisClient.saveMapValue("service_order", maps); |
| | | } |
| | | } |
| | | |
| | | |
| | | } |