|  |  |  | 
|---|
|  |  |  | import com.matrix.core.tools.WebUtil; | 
|---|
|  |  |  | import com.matrix.system.app.dto.ServiceOrderListDto; | 
|---|
|  |  |  | import com.matrix.system.app.vo.ServiceOrderListVo; | 
|---|
|  |  |  | import com.matrix.system.common.bean.BusParameterSettings; | 
|---|
|  |  |  | import com.matrix.system.common.bean.SysUsers; | 
|---|
|  |  |  | import com.matrix.system.common.constance.AppConstance; | 
|---|
|  |  |  | import com.matrix.system.common.dao.BusParameterSettingsDao; | 
|---|
|  |  |  | import com.matrix.system.common.dao.SysUsersDao; | 
|---|
|  |  |  | import com.matrix.system.constance.Dictionary; | 
|---|
|  |  |  | import com.matrix.system.hive.bean.*; | 
|---|
|  |  |  | import com.matrix.system.hive.dao.*; | 
|---|
|  |  |  | import com.matrix.system.hive.plugin.util.MoneyUtil; | 
|---|
|  |  |  | import com.matrix.system.hive.service.*; | 
|---|
|  |  |  | import com.matrix.system.score.constant.ScoreSettingConstant; | 
|---|
|  |  |  | import com.matrix.system.score.entity.ScoreVipDetail; | 
|---|
|  |  |  | import com.matrix.system.score.service.ScoreVipDetailService; | 
|---|
|  |  |  | import com.matrix.system.shopXcx.mqTask.MQTaskRouting; | 
|---|
|  |  |  | import com.matrix.system.wechart.templateMsg.UniformMsgParam; | 
|---|
|  |  |  | import org.apache.commons.collections.CollectionUtils; | 
|---|
|  |  |  | 
|---|
|  |  |  | @Autowired | 
|---|
|  |  |  | private RabiitMqTemplate rabiitMqTemplate; | 
|---|
|  |  |  |  | 
|---|
|  |  |  |  | 
|---|
|  |  |  | @Autowired | 
|---|
|  |  |  | BusParameterSettingsDao busParameterSettingsDao; | 
|---|
|  |  |  |  | 
|---|
|  |  |  | @Autowired | 
|---|
|  |  |  | ScoreVipDetailService scoreVipDetailService; | 
|---|
|  |  |  |  | 
|---|
|  |  |  | @Autowired | 
|---|
|  |  |  | SysVipInfoDao sysVipInfoDao; | 
|---|
|  |  |  |  | 
|---|
|  |  |  | @Value("${evn}") | 
|---|
|  |  |  | private String evn; | 
|---|
|  |  |  |  | 
|---|
|  |  |  | 
|---|
|  |  |  | public SysProjServices addSysProjServices(SysProjServices sysProjServices) throws GlobleException { | 
|---|
|  |  |  |  | 
|---|
|  |  |  | //创建服务单 | 
|---|
|  |  |  | if(WebUtil.getSession().getAttribute(MatrixConstance.LOGIN_KEY)!=null){ | 
|---|
|  |  |  | if (WebUtil.getSession().getAttribute(MatrixConstance.LOGIN_KEY) != null) { | 
|---|
|  |  |  | SysUsers user = (SysUsers) WebUtil.getSession().getAttribute(MatrixConstance.LOGIN_KEY); | 
|---|
|  |  |  | sysProjServices.setCreateStaffId(user.getSuId()); | 
|---|
|  |  |  | sysProjServices.setShopId(user.getShopId()); | 
|---|
|  |  |  | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  |  | 
|---|
|  |  |  | sysProjServices.setCreateTime(new Date()); | 
|---|
|  |  |  | sysProjServices.setServiceNo(codeService.getServiceOrderCode()); | 
|---|
|  |  |  | if (sysProjServices.getId() == null) { | 
|---|
|  |  |  | sysProjServices.setCreateTime(new Date()); | 
|---|
|  |  |  | sysProjServices.setServiceNo(codeService.getServiceOrderCode()); | 
|---|
|  |  |  | int i = sysProjServicesDao.insert(sysProjServices); | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | Double hkPrice = 0.0; | 
|---|
|  |  |  | int i = sysProjServicesDao.insert(sysProjServices); | 
|---|
|  |  |  | // 计算项目总时长 | 
|---|
|  |  |  | int totalTime = 0; | 
|---|
|  |  |  | //处理订单明细 | 
|---|
|  |  |  | 
|---|
|  |  |  | sysBeauticianState.setProjId(sysProjInfo.getId()); | 
|---|
|  |  |  | sysBeauticianState.setServicesId(sysProjServices.getId()); | 
|---|
|  |  |  | sysBeauticianState.setShopId(sysProjServices.getShopId()); | 
|---|
|  |  |  | sysBeauticianState.setState(Dictionary.BEATUI_STATE_DYY); | 
|---|
|  |  |  | sysBeauticianState.setState(sysProjServices.getState()); | 
|---|
|  |  |  | beauticianStateDao.insert(sysBeauticianState); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | // 设置项目总时长 | 
|---|
|  |  |  | 
|---|
|  |  |  | @Override | 
|---|
|  |  |  | public VerifyResult checkArrears(SysProjServices sysProjServices) { | 
|---|
|  |  |  | // 检测欠款 | 
|---|
|  |  |  | for (SysBeauticianState sysBeauticianState : sysProjServices.getServiceItems()) { | 
|---|
|  |  |  | /*for (SysBeauticianState sysBeauticianState : sysProjServices.getServiceItems()) { | 
|---|
|  |  |  | SysProjUse sysProjUse = projUseService.findById(sysBeauticianState.getPuseId()); | 
|---|
|  |  |  |  | 
|---|
|  |  |  | ShoppingGoods shoppingGoods = shoppingGoodsDao.selectById(sysProjUse.getProjId()); | 
|---|
|  |  |  | 
|---|
|  |  |  |  | 
|---|
|  |  |  | } | 
|---|
|  |  |  | } else if ("赠送".equals(sysProjUse.getSource())) { | 
|---|
|  |  |  | if (orderItem!=null &&orderItem.getArrears() > 0) { | 
|---|
|  |  |  | return new VerifyResult(true, shoppingGoods.getName() + "存在欠款" + orderItem.getArrears() + "元 , 不能消费赠送项目,订单编号[ " + orderItem.getOrderNo() + " ] "); | 
|---|
|  |  |  | if (orderItem!=null && orderItem.getArrears()!=null&&orderItem.getArrears() > 0) { | 
|---|
|  |  |  | return new VerifyResult(true, shoppingGoods.getName() + "存在欠款" + orderItem.getArrears() + "元 , 不能消费赠送项目,订单编号[ " + sysOrderService.findById(orderItem.getOrderId()).getOrderNo() + " ] "); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | } | 
|---|
|  |  |  | } | 
|---|
|  |  |  | }*/ | 
|---|
|  |  |  | return new VerifyResult(false); | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | 
|---|
|  |  |  | /** 验证数据是否正确 */ | 
|---|
|  |  |  | SysProjServices checkProjServices = sysProjServicesDao.selectById(projServices.getId()); | 
|---|
|  |  |  | // 验证服务单是否存在或者取消 | 
|---|
|  |  |  | if (!checkProjServices.getState().equals(Dictionary.SERVICE_STATU_DYY) | 
|---|
|  |  |  | && !checkProjServices.getState().equals(Dictionary.SERVICE_STATU_YYCG)) { | 
|---|
|  |  |  | if (checkProjServices.getState().equals(Dictionary.SERVICE_STATU_YYQX) | 
|---|
|  |  |  | || checkProjServices.getState().equals(Dictionary.SERVICE_STATU_FFJS)) { | 
|---|
|  |  |  | throw new GlobleException("该服务单已被取消或者不存在!"); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | // 验证是否选择床位 | 
|---|
|  |  |  | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | // 判断是否是编辑,还是新增,编辑则需要先释放资源 | 
|---|
|  |  |  | if (checkProjServices.getState().equals(Dictionary.SERVICE_STATU_YYCG)) { | 
|---|
|  |  |  | if (!checkProjServices.getState().equals(Dictionary.SERVICE_STATU_DYY)) { | 
|---|
|  |  |  | // 释放床位资源 | 
|---|
|  |  |  | bedStateDao.deleteByServiceId(checkProjServices.getId()); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  |  | 
|---|
|  |  |  | // 设置成功状态 | 
|---|
|  |  |  | projServices.setState(Dictionary.SERVICE_STATU_XPL); | 
|---|
|  |  |  | if (Dictionary.SERVICE_STATU_DYY.equals(projServices.getState())) { | 
|---|
|  |  |  | // 设置成功状态 | 
|---|
|  |  |  | projServices.setState(Dictionary.SERVICE_STATU_XPL); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | // 判断当前门店是否有历史美疗师 | 
|---|
|  |  |  | LastestWorkBeatuistaff lastWorkStaff = new LastestWorkBeatuistaff(); | 
|---|
|  |  |  | lastWorkStaff.setShopId(checkProjServices.getShopId()); | 
|---|
|  |  |  | 
|---|
|  |  |  | sysOutStoreDao.deleteById(sysOutStore.getId()); | 
|---|
|  |  |  | sysOutStoreItemDao.deleteByOrderId(sysOutStore.getId()); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | //删除积分 | 
|---|
|  |  |  | scoreVipDetailService.removeByBusinessId(checkProjServices.getVipId(), checkProjServices.getId()); | 
|---|
|  |  |  |  | 
|---|
|  |  |  | //更新服务单状态 | 
|---|
|  |  |  | return sysProjServicesDao.update(checkProjServices); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | 
|---|
|  |  |  | private void backProjCount(SysProjServices projServices) { | 
|---|
|  |  |  | List<SysBeauticianState> beauticianStateList = beauticianStateDao.selectBySerIds(projServices.getId()); | 
|---|
|  |  |  |  | 
|---|
|  |  |  | Map<Long ,List<SysProjUse>> taocanMap = new HashMap<>(); | 
|---|
|  |  |  | backProjCountItems(beauticianStateList, 1); | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | private void backProjCountItems(List<SysBeauticianState> beauticianStateList, int type) { | 
|---|
|  |  |  | Map<Long, List<SysProjUse>> taocanMap = new HashMap<>(); | 
|---|
|  |  |  | // 回退项目余额 | 
|---|
|  |  |  | for (SysBeauticianState beauticianState : beauticianStateList) { | 
|---|
|  |  |  | // 该修改为 有效日期判断更新所有 | 
|---|
|  |  |  | beauticianState.setState(Dictionary.BEATUI_STATE_YYQX); | 
|---|
|  |  |  | beauticianStateDao.update(beauticianState); | 
|---|
|  |  |  | if (type == 1) { | 
|---|
|  |  |  | // 该修改为 有效日期判断更新所有 | 
|---|
|  |  |  | beauticianState.setState(Dictionary.BEATUI_STATE_YYQX); | 
|---|
|  |  |  | beauticianStateDao.update(beauticianState); | 
|---|
|  |  |  | } else { | 
|---|
|  |  |  | beauticianStateDao.deleteById(beauticianState.getId()); | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | SysProjUse sysProjUse = sysProjUseDao.selectById(beauticianState.getPuseId()); | 
|---|
|  |  |  | if (sysProjUse != null && sysProjUse.getId() != null) { | 
|---|
|  |  |  | 
|---|
|  |  |  | } | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | @Override | 
|---|
|  |  |  | public int deleteProjServiceItemById(Long id) { | 
|---|
|  |  |  | SysBeauticianState sysBeauticianState = beauticianStateDao.selectById(id); | 
|---|
|  |  |  | List<SysBeauticianState> list = new ArrayList<>(); | 
|---|
|  |  |  | list.add(sysBeauticianState); | 
|---|
|  |  |  |  | 
|---|
|  |  |  | backProjCountItems(list, 2); | 
|---|
|  |  |  | return 1; | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | // 划扣 jyy | 
|---|
|  |  |  | @Transactional(rollbackFor = Exception.class) | 
|---|
|  |  |  | @Override | 
|---|
|  |  |  | 
|---|
|  |  |  |  | 
|---|
|  |  |  | projServices.setState(Dictionary.SERVICE_STATU_FFJS); | 
|---|
|  |  |  | projServices.setConsumeTime(new Date()); | 
|---|
|  |  |  | int result=sysProjServicesDao.update(projServices); | 
|---|
|  |  |  | int result = sysProjServicesDao.update(projServices); | 
|---|
|  |  |  | achieveNewService.addAchieveByServiceOrder(projServices); | 
|---|
|  |  |  |  | 
|---|
|  |  |  | //设置会员积分 | 
|---|
|  |  |  | addVipScore(projServices); | 
|---|
|  |  |  |  | 
|---|
|  |  |  | //发送微信公众号提醒 | 
|---|
|  |  |  | UniformMsgParam uniformMsgParam=new UniformMsgParam(projServices.getCompanyId(),UniformMsgParam.GZH_FWWC); | 
|---|
|  |  |  | uniformMsgParam.put("serviceId",projServices.getId()); | 
|---|
|  |  |  | rabiitMqTemplate.sendMsg(MQTaskRouting.SEND_UNIFORM_TEMPLATE_MSG+evn,uniformMsgParam.toJSONString()); | 
|---|
|  |  |  | UniformMsgParam uniformMsgParam = new UniformMsgParam(projServices.getCompanyId(), UniformMsgParam.GZH_FWWC); | 
|---|
|  |  |  | uniformMsgParam.put("serviceId", projServices.getId()); | 
|---|
|  |  |  | rabiitMqTemplate.sendMsg(MQTaskRouting.SEND_UNIFORM_TEMPLATE_MSG + evn, uniformMsgParam.toJSONString()); | 
|---|
|  |  |  |  | 
|---|
|  |  |  |  | 
|---|
|  |  |  |  | 
|---|
|  |  |  |  | 
|---|
|  |  |  | return result; | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  |  | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | /** | 
|---|
|  |  |  | * 设置会员消费积分 | 
|---|
|  |  |  | */ | 
|---|
|  |  |  | private void addVipScore(SysProjServices projServices) { | 
|---|
|  |  |  |  | 
|---|
|  |  |  | SysVipInfo vipInfo =sysVipInfoDao.selectById(projServices.getVipId()); | 
|---|
|  |  |  |  | 
|---|
|  |  |  | List<SysBeauticianState> sysBeauticianStates = beauticianStateDao.selectBySerIds(projServices.getId()); | 
|---|
|  |  |  |  | 
|---|
|  |  |  |  | 
|---|
|  |  |  | double principalPrice = 0D; | 
|---|
|  |  |  | double giftPrice = 0D; | 
|---|
|  |  |  | for (SysBeauticianState sysBeauticianState : sysBeauticianStates) { | 
|---|
|  |  |  | SysProjUse projUse = sysBeauticianState.getProjUse(); | 
|---|
|  |  |  | if (projUse.getSource().equals(Dictionary.TAOCAN_SOURCE_ZS)) { | 
|---|
|  |  |  | giftPrice += projUse.getPrice(); | 
|---|
|  |  |  | } else { | 
|---|
|  |  |  | principalPrice += projUse.getPrice(); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | int[] principalConsumScore = {0, 0, 0}; | 
|---|
|  |  |  | BusParameterSettings principalConsumption = busParameterSettingsDao.selectCompanyParamByCode(ScoreSettingConstant.PRINCIPAL_CONSUMPTION, vipInfo.getCompanyId()); | 
|---|
|  |  |  | //本金消耗 | 
|---|
|  |  |  | if (principalPrice > 0 | 
|---|
|  |  |  | && StringUtils.isNotBlank(principalConsumption.getParamValue())) { | 
|---|
|  |  |  |  | 
|---|
|  |  |  | principalConsumScore[0] = (int) (principalPrice / Double.parseDouble(principalConsumption.getParamValue())); | 
|---|
|  |  |  |  | 
|---|
|  |  |  | if (StringUtils.isNotBlank(principalConsumption.getParamValue1())) { | 
|---|
|  |  |  | principalConsumScore[1] = (int) (principalPrice / Double.parseDouble(principalConsumption.getParamValue1())); | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | if (StringUtils.isNotBlank(principalConsumption.getParamValue2())) { | 
|---|
|  |  |  | principalConsumScore[2] = (int) (principalPrice / Double.parseDouble(principalConsumption.getParamValue2())); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | int[] giveConsumScore = {0, 0, 0}; | 
|---|
|  |  |  | BusParameterSettings giveConsumption = busParameterSettingsDao.selectCompanyParamByCode(ScoreSettingConstant.GIVE_CONSUMPTION, vipInfo.getCompanyId()); | 
|---|
|  |  |  | //本金消耗 | 
|---|
|  |  |  | if (giftPrice > 0 | 
|---|
|  |  |  | && StringUtils.isNotBlank(giveConsumption.getParamValue())) { | 
|---|
|  |  |  |  | 
|---|
|  |  |  | giveConsumScore[0] = (int) (giftPrice / Double.parseDouble(giveConsumption.getParamValue())); | 
|---|
|  |  |  |  | 
|---|
|  |  |  | if (StringUtils.isNotBlank(giveConsumption.getParamValue1())) { | 
|---|
|  |  |  | giveConsumScore[1] = (int) (giftPrice / Double.parseDouble(giveConsumption.getParamValue1())); | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | if (StringUtils.isNotBlank(giveConsumption.getParamValue2())) { | 
|---|
|  |  |  | giveConsumScore[2] = (int) (giftPrice / Double.parseDouble(giveConsumption.getParamValue2())); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | int selfScore =principalConsumScore[0]+giveConsumScore[0]; | 
|---|
|  |  |  | int parentScore =principalConsumScore[1]+giveConsumScore[1]; | 
|---|
|  |  |  | int topParentScore =principalConsumScore[2]+giveConsumScore[2]; | 
|---|
|  |  |  |  | 
|---|
|  |  |  | //添加自己的积分 | 
|---|
|  |  |  | if (selfScore > 0) { | 
|---|
|  |  |  | scoreVipDetailService.addScore( | 
|---|
|  |  |  | vipInfo.getId(), | 
|---|
|  |  |  | projServices.getCreateStaffId(), | 
|---|
|  |  |  | projServices.getShopId(), | 
|---|
|  |  |  | selfScore, | 
|---|
|  |  |  | projServices.getId(), | 
|---|
|  |  |  | ScoreVipDetail.SCORE_VIP_TYPE_CASH, | 
|---|
|  |  |  | "消耗奖励" | 
|---|
|  |  |  | ); | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | if (vipInfo.getRecommendId() != null) { | 
|---|
|  |  |  | //推荐注册老带新积分奖励 | 
|---|
|  |  |  | SysVipInfo referrerVip = sysVipInfoDao.selectById(vipInfo.getRecommendId()); | 
|---|
|  |  |  | if (parentScore > 0) { | 
|---|
|  |  |  | scoreVipDetailService.addScore( | 
|---|
|  |  |  | referrerVip.getId(), | 
|---|
|  |  |  | projServices.getCreateStaffId(), | 
|---|
|  |  |  | projServices.getShopId(), | 
|---|
|  |  |  | parentScore, | 
|---|
|  |  |  | projServices.getId(), | 
|---|
|  |  |  | ScoreVipDetail.SCORE_VIP_TYPE_CASH, | 
|---|
|  |  |  | "推荐消耗奖励" | 
|---|
|  |  |  | ); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | //推荐注册二级带新积分奖励 | 
|---|
|  |  |  | if (referrerVip.getRecommendId() != null) { | 
|---|
|  |  |  | SysVipInfo topVipInfo = sysVipInfoDao.selectById(referrerVip.getRecommendId()); | 
|---|
|  |  |  | if (topParentScore > 0) { | 
|---|
|  |  |  | scoreVipDetailService.addScore( | 
|---|
|  |  |  | topVipInfo.getId(), | 
|---|
|  |  |  | projServices.getCreateStaffId(), | 
|---|
|  |  |  | projServices.getShopId(), | 
|---|
|  |  |  | topParentScore, | 
|---|
|  |  |  | projServices.getId(), | 
|---|
|  |  |  | ScoreVipDetail.SCORE_VIP_TYPE_CASH, | 
|---|
|  |  |  | "推荐消耗奖励" | 
|---|
|  |  |  | ); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | } | 
|---|
|  |  |  | } | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  |  | 
|---|
|  |  |  | // 派单 jyy | 
|---|
|  |  |  | 
|---|
|  |  |  | if (!projServices.getState().equals(Dictionary.SERVICE_STATU_XPL)) { | 
|---|
|  |  |  | throw new GlobleException("该服务单状态为" + projServices.getState() + ",不可以进行当前操作!"); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | projServicesVo.setCompanyId(projServices.getCompanyId()); | 
|---|
|  |  |  | if (isNeedOutStore(projServicesVo)) { | 
|---|
|  |  |  |  | 
|---|
|  |  |  | // 生成出库单 | 
|---|
|  |  |  | 
|---|
|  |  |  |  | 
|---|
|  |  |  | outStore.setOutStoreNo(codeService.getOutStoreCode()); | 
|---|
|  |  |  | outStore.setShopId(projServices.getShopId()); | 
|---|
|  |  |  | if(projServices.getDevisionId()!=null){ | 
|---|
|  |  |  | if (projServices.getDevisionId() != null) { | 
|---|
|  |  |  | outStore.setStaffId(projServices.getDevisionId()); | 
|---|
|  |  |  | }else{ | 
|---|
|  |  |  | } else { | 
|---|
|  |  |  |  | 
|---|
|  |  |  | outStore.setStaffId(sysUsers.getSuId()); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | 
|---|
|  |  |  | double sum = stores.stream().mapToDouble(item2 -> item2.getStoreTotal()).sum(); | 
|---|
|  |  |  | Double needAmount = MoneyUtil.div(item.getAmount(), Double.valueOf(shoppingGoods.getVolume())); | 
|---|
|  |  |  | if (sum < needAmount) { | 
|---|
|  |  |  | throw new GlobleException("出库失败:【" + shoppingGoods.getName()+"-"+shoppingGoods.getCode()+  "库存不足】"); | 
|---|
|  |  |  | throw new GlobleException("出库失败:【" + shoppingGoods.getName() + "-" + shoppingGoods.getCode() + "库存不足】"); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | //循环获取所有批次产品,并扣减库存 | 
|---|
|  |  |  | for (SysStoreInfo storeInfo : stores) { | 
|---|
|  |  |  | 
|---|
|  |  |  | // 设置服务单状态 | 
|---|
|  |  |  | //        projServices.setState(Dictionary.SERVICE_STATU_PLWC); | 
|---|
|  |  |  |  | 
|---|
|  |  |  | if(projServices.getDevisionId()==null){ | 
|---|
|  |  |  | if (projServices.getDevisionId() == null) { | 
|---|
|  |  |  | //如果没有设置配料师则默认为操作配料的人为配料师 | 
|---|
|  |  |  | projServices.setDevisionId(sysUsers.getSuId()); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | 
|---|
|  |  |  | if (skipServiceOrderStep(Dictionary.SERVICE_OVER_BEGIN_END)) { | 
|---|
|  |  |  | projServices.setStartTime(new Date()); | 
|---|
|  |  |  | projServices.setState(Dictionary.SERVICE_STATU_FWWC); | 
|---|
|  |  |  | } else { | 
|---|
|  |  |  | projServices.setState(Dictionary.SERVICE_STATU_PLWC); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | // 释放床位资源 | 
|---|
|  |  |  | //        SysBedState checkBedState = sysBedStateDao.selectBySerIdAndBedId(projServices.getBedId(), projServices.getId()); | 
|---|
|  |  |  | 
|---|
|  |  |  |  | 
|---|
|  |  |  | /** | 
|---|
|  |  |  | * 服务单收费需要生成出库记录 | 
|---|
|  |  |  | * | 
|---|
|  |  |  | * @param projServicesVo | 
|---|
|  |  |  | * @return | 
|---|
|  |  |  | */ | 
|---|
|  |  |  | private boolean isNeedOutStore(SysProjServices projServicesVo) { | 
|---|
|  |  |  | if(CollectionUtils.isNotEmpty(projServicesVo.getOutStoreItem())){ | 
|---|
|  |  |  | for (SysOutStoreItem item : projServicesVo.getOutStoreItem()) { | 
|---|
|  |  |  | if (item.getAmount() != null && item.getAmount() > 0) { | 
|---|
|  |  |  | return true; | 
|---|
|  |  |  |  | 
|---|
|  |  |  | if (CollectionUtils.isNotEmpty(projServicesVo.getOutStoreItem())) { | 
|---|
|  |  |  | BusParameterSettings manageStockSetting = busParameterSettingsDao.selectCompanyParamByCode(AppConstance.WAREHOUSE_MANAGE_STOCK, projServicesVo.getCompanyId()); | 
|---|
|  |  |  | if(AppConstance.IS_Y.equals(manageStockSetting.getParamValue())){ | 
|---|
|  |  |  | for (SysOutStoreItem item : projServicesVo.getOutStoreItem()) { | 
|---|
|  |  |  | if (item.getAmount() != null && item.getAmount() > 0) { | 
|---|
|  |  |  | return true; | 
|---|
|  |  |  | } | 
|---|
|  |  |  | } | 
|---|
|  |  |  | } | 
|---|
|  |  |  | } | 
|---|
|  |  |  | 
|---|
|  |  |  | /** | 
|---|
|  |  |  | * 跳过服务单某步骤 | 
|---|
|  |  |  | */ | 
|---|
|  |  |  | private boolean skipServiceOrderStep(String step) { | 
|---|
|  |  |  | @Override | 
|---|
|  |  |  | public boolean skipServiceOrderStep(String step) { | 
|---|
|  |  |  | SysUsers users = (SysUsers) WebUtil.getSession().getAttribute(MatrixConstance.LOGIN_KEY); | 
|---|
|  |  |  | ParameterSettings ps = new ParameterSettings(); | 
|---|
|  |  |  | ps.setCompanyId(users.getCompanyId()); | 
|---|