935090232@qq.com
2021-06-06 e83f7fa1f5648745940863444fed16f7f9135ce7
zq-erp/src/main/java/com/matrix/system/hive/service/imp/SysProjServicesServiceImpl.java
@@ -14,6 +14,7 @@
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;
@@ -144,10 +145,13 @@
        }
        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;
        //处理订单明细
@@ -229,7 +233,7 @@
            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);
        }
        // 设置项目总时长
@@ -358,8 +362,8 @@
        /** 验证数据是否正确 */
        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("该服务单已被取消或者不存在!");
        }
        // 验证是否选择床位
@@ -386,7 +390,7 @@
        }
        // 判断是否是编辑,还是新增,编辑则需要先释放资源
        if (checkProjServices.getState().equals(Dictionary.SERVICE_STATU_YYCG)) {
        if (!checkProjServices.getState().equals(Dictionary.SERVICE_STATU_DYY)) {
            // 释放床位资源
            bedStateDao.deleteByServiceId(checkProjServices.getId());
        }
@@ -414,8 +418,10 @@
        }
        // 设置成功状态
        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());
@@ -512,12 +518,20 @@
    private void backProjCount(SysProjServices projServices) {
        List<SysBeauticianState> beauticianStateList = beauticianStateDao.selectBySerIds(projServices.getId());
        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) {
@@ -583,6 +597,16 @@
                }
            }
        }
    }
    @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
@@ -776,6 +800,7 @@
        if (!projServices.getState().equals(Dictionary.SERVICE_STATU_XPL)) {
            throw new GlobleException("该服务单状态为" + projServices.getState() + ",不可以进行当前操作!");
        }
        projServicesVo.setCompanyId(projServices.getCompanyId());
        if (isNeedOutStore(projServicesVo)) {
            // 生成出库单
@@ -854,6 +879,8 @@
        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());
@@ -879,10 +906,14 @@
     * @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;
            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;
                    }
                }
            }
        }
@@ -992,7 +1023,8 @@
    /**
     * 跳过服务单某步骤
     */
    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());