phi_platform_common/src/main/java/com/hx/phip/dao/mapper/ComparePhotoRecordMapper.java
@@ -4,6 +4,7 @@ import java.util.Map; import com.hx.mybatisTool.SqlSentence; import com.hx.phiappt.model.ComparePhotoRecord; import org.apache.ibatis.annotations.Param; public interface ComparePhotoRecordMapper { /**新增,返回主键*/ @@ -18,6 +19,8 @@ List<Map<String,Object>> selectListMap(SqlSentence sqlSentence); /**查询,返回单个实体*/ ComparePhotoRecord selectOne(SqlSentence sqlSentence); /**查询,返回单个实体*/ ComparePhotoRecord selectOneByDeductionSingleId(@Param("deductionSingleId") String deductionSingleId, @Param("deductionProjectId") String deductionProjectId); /**查询,返回单个map*/ Map<String,Object> selectOneMap(SqlSentence sqlSentence); /**查询,返回实体类没有大数据的*/ phi_platform_common/src/main/java/com/hx/phip/dao/mapper/ComparePhotoRecordPicturesMapper.java
@@ -4,6 +4,7 @@ import java.util.Map; import com.hx.mybatisTool.SqlSentence; import com.hx.phiappt.model.ComparePhotoRecordPictures; import org.apache.ibatis.annotations.Param; public interface ComparePhotoRecordPicturesMapper { /**新增,返回主键*/ @@ -32,4 +33,6 @@ int deleteWhere(SqlSentence sqlSentence); /**删除,返回删除数量*/ int deleteById(Object object); /**删除,返回删除数量*/ int deleteByDeductionSingleId(@Param("comparePhotoRecordId") String comparePhotoRecordId); } phi_platform_common/src/main/java/com/hx/phip/dao/mapper/DeductionDeviceParameterMapper.java
@@ -4,6 +4,7 @@ import java.util.Map; import com.hx.mybatisTool.SqlSentence; import com.hx.phiappt.model.deduction.DeductionDeviceParameter; import org.apache.ibatis.annotations.Param; public interface DeductionDeviceParameterMapper { /**新增,返回主键*/ @@ -32,4 +33,6 @@ int deleteWhere(SqlSentence sqlSentence); /**删除,返回删除数量*/ int deleteById(Object object); /**删除,返回删除数量*/ int deleteByDeductionSingleId(@Param("deductionSingleId") String deductionSingleId, @Param("deductionProjectId") String deductionProjectId); } phi_platform_common/src/main/java/com/hx/phip/dao/mapper/DeductionDrugsMapper.java
@@ -4,6 +4,7 @@ import java.util.Map; import com.hx.mybatisTool.SqlSentence; import com.hx.phiappt.model.deduction.DeductionDrugs; import org.apache.ibatis.annotations.Param; public interface DeductionDrugsMapper { /**新增,返回主键*/ @@ -32,4 +33,6 @@ int deleteWhere(SqlSentence sqlSentence); /**删除,返回删除数量*/ int deleteById(Object object); /**删除,返回删除数量*/ int deleteByDeductionSingleId(@Param("deductionSingleId") String deductionSingleId, @Param("deductionProjectId") String deductionProjectId); } phi_platform_common/src/main/java/com/hx/phip/dao/mapper/DeductionJoinMapper.java
@@ -4,6 +4,7 @@ import java.util.Map; import com.hx.mybatisTool.SqlSentence; import com.hx.phiappt.model.deduction.DeductionJoin; import org.apache.ibatis.annotations.Param; public interface DeductionJoinMapper { /**新增,返回主键*/ @@ -32,4 +33,6 @@ int deleteWhere(SqlSentence sqlSentence); /**删除,返回删除数量*/ int deleteById(Object object); /**删除,返回删除数量*/ int deleteByDeductionSingleId(@Param("deductionSingleId") String deductionSingleId,@Param("deductionProjectId") String deductionProjectId); } phi_platform_common/src/main/java/com/hx/phip/dao/mapper/DeductionProjectMapper.java
@@ -22,6 +22,8 @@ Map<String,Object> selectOneMap(SqlSentence sqlSentence); /**查询,返回实体类没有大数据的*/ DeductionProject selectOneByKey(Object object); /**查询,返回实体类没有大数据的*/ DeductionProject selectOneByDeductionSingleId(Object object); /**查询,返回实体类有大数据的*/ DeductionProject selectOneByKeyBlob(Object object); /**更新,返回更新数量*/ phi_platform_common/src/main/java/com/hx/phip/dao/mapper/DeductionSignMapper.java
@@ -4,6 +4,7 @@ import java.util.Map; import com.hx.mybatisTool.SqlSentence; import com.hx.phiappt.model.deduction.DeductionSign; import org.apache.ibatis.annotations.Param; public interface DeductionSignMapper { /**新增,返回主键*/ @@ -32,4 +33,6 @@ int deleteWhere(SqlSentence sqlSentence); /**删除,返回删除数量*/ int deleteById(Object object); /**删除,返回删除数量*/ int deleteByDeductionSingleId(@Param("deductionSingleId") String deductionSingleId, @Param("deductionProjectId") String deductionProjectId); } phi_platform_common/src/main/java/com/hx/phip/dao/mapper/UserProjectUsedMapper.java
New file @@ -0,0 +1,35 @@ package com.hx.phip.dao.mapper; import java.util.List; import java.util.Map; import com.hx.mybatisTool.SqlSentence; import com.hx.phiappt.model.user.UserProjectUsed; public interface UserProjectUsedMapper { /**新增,返回主键*/ int insert(UserProjectUsed userProjectUsed); /**查询条数*/ int selectCount(SqlSentence sqlSentence); /**查询条数*/ int selectCountSql(SqlSentence sqlSentence); /**查询列表,返回实体类的List*/ List<UserProjectUsed> selectList(SqlSentence sqlSentence); /**查询列表,返回Map的List*/ List<Map<String,Object>> selectListMap(SqlSentence sqlSentence); /**查询,返回单个实体*/ UserProjectUsed selectOne(SqlSentence sqlSentence); /**查询,返回单个map*/ Map<String,Object> selectOneMap(SqlSentence sqlSentence); /**查询,返回实体类没有大数据的*/ UserProjectUsed selectOneByKey(Object object); /**查询,返回实体类有大数据的*/ UserProjectUsed selectOneByKeyBlob(Object object); /**更新,返回更新数量*/ int updateWhere(SqlSentence sqlSentence); /**更新,返回更新数量*/ int updateAll(UserProjectUsed userProjectUsed); /**删除,返回删除数量*/ int deleteWhere(SqlSentence sqlSentence); /**删除,返回删除数量*/ int deleteById(Object object); } phi_platform_common/src/main/resources/mapper/ComparePhotoRecordMapper.xml
@@ -49,6 +49,13 @@ ${sqlSentence} </select> <select id="selectOneByDeductionSingleId" resultType="com.hx.phiappt.model.ComparePhotoRecord" > select * from compare_photo_record WHERE isDel=0 AND deductionProjectId = #{deductionProjectId} AND deductionSingleId = #{deductionSingleId} </select> <select id="selectOneByKey" resultType="com.hx.phiappt.model.ComparePhotoRecord" parameterType="java.lang.Object" > select id,userId,projectId,projectFrequency,type,remark,userProjectId,deductionProjectId,deductionSingleId,isDel,createTime phi_platform_common/src/main/resources/mapper/ComparePhotoRecordPicturesMapper.xml
@@ -82,5 +82,9 @@ <delete id="deleteById" parameterType="java.lang.Object"> delete from compare_photo_record_pictures WHERE id = #{value} </delete> <delete id="deleteByDeductionSingleId" > delete from compare_photo_record_pictures WHERE comparePhotoRecordId = #{comparePhotoRecordId} </delete> </mapper> phi_platform_common/src/main/resources/mapper/DeductionDeviceParameterMapper.xml
@@ -82,5 +82,9 @@ <delete id="deleteById" parameterType="java.lang.Object"> delete from deduction_device_parameter WHERE id = #{value} </delete> <delete id="deleteByDeductionSingleId" > delete from deduction_device_parameter WHERE deductionProjectId = #{deductionProjectId} AND deductionSingleId = #{deductionSingleId} </delete> </mapper> phi_platform_common/src/main/resources/mapper/DeductionDrugsMapper.xml
@@ -82,5 +82,9 @@ <delete id="deleteById" parameterType="java.lang.Object"> delete from deduction_drugs WHERE id = #{value} </delete> <delete id="deleteByDeductionSingleId" > delete from deduction_drugs WHERE deductionProjectId = #{deductionProjectId} AND deductionSingleId = #{deductionSingleId} </delete> </mapper> phi_platform_common/src/main/resources/mapper/DeductionJoinMapper.xml
@@ -82,5 +82,9 @@ <delete id="deleteById" parameterType="java.lang.Object"> delete from deduction_join WHERE id = #{value} </delete> <delete id="deleteByDeductionSingleId" > delete from deduction_join WHERE deductionProjectId = #{deductionProjectId} AND deductionSingleId = #{deductionSingleId} </delete> </mapper> phi_platform_common/src/main/resources/mapper/DeductionProjectMapper.xml
@@ -56,6 +56,13 @@ WHERE id = #{value} </select> <select id="selectOneByDeductionSingleId" resultType="com.hx.phiappt.model.deduction.DeductionProject" parameterType="java.lang.Object" > select * from deduction_project WHERE isDel = 0 AND deductionSingleId = #{value} </select> <select id="selectOneByKeyBlob" resultType="com.hx.phiappt.model.deduction.DeductionProject" parameterType="java.lang.Object" > select id,projectNo,projectName,projectFrequency,price,num,shopId,shopName,departmentCode,departmentName,specification,useDuration,palsyDuration,projectId,deductionSingleId,executeStartTime,executeEndTime,remarkInfo,isDel,createTime phi_platform_common/src/main/resources/mapper/DeductionSignMapper.xml
@@ -82,5 +82,9 @@ <delete id="deleteById" parameterType="java.lang.Object"> delete from deduction_sign WHERE id = #{value} </delete> <delete id="deleteByDeductionSingleId" > delete from deduction_join WHERE deductionProjectId = #{deductionProjectId} AND deductionSingleId = #{deductionSingleId} </delete> </mapper> phi_platform_common/src/main/resources/mapper/UserProjectUsedMapper.xml
New file @@ -0,0 +1,86 @@ <?xml version="1.0" encoding="UTF-8" ?> <!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd"> <!-- namespace:该mapper.xml映射文件的 唯一标识 --> <mapper namespace="com.hx.phip.dao.mapper.UserProjectUsedMapper"> <!-- 整个实体类修改,表字段=实体类字段--> <sql id="Update_Column_All"> <trim prefixOverrides=","> ,usedMethod = #{usedMethod},commonId = #{commonId},usedType = #{usedType},usedNum = #{usedNum},shopId = #{shopId},shopName = #{shopName},userProjectId = #{userProjectId},userProjectItemId = #{userProjectItemId},sourceCode = #{sourceCode},sourceName = #{sourceName},isDel = #{isDel},createTime = #{createTime} </trim> </sql> <!-- 后续通过 namespace.id--> <!--parameterType:输入参数的类型 resultType:查询返回结果值的类型 ,返回类型 --> <insert id="insert" parameterType="com.hx.phiappt.model.user.UserProjectUsed"> <selectKey keyProperty="id" resultType="String" order="BEFORE"> select replace(uuid(),'-','') from dual </selectKey> insert into user_project_used (id,usedMethod,commonId,usedType,usedNum,shopId,shopName,userProjectId,userProjectItemId,sourceCode,sourceName,isDel,createTime) values (#{id},#{usedMethod},#{commonId},#{usedType},#{usedNum},#{shopId},#{shopName},#{userProjectId},#{userProjectItemId},#{sourceCode},#{sourceName},#{isDel},#{createTime}) </insert> <select id="selectList" resultType="com.hx.phiappt.model.user.UserProjectUsed" parameterType="com.hx.mybatisTool.SqlSentence" > ${sqlSentence} </select> <select id="selectListMap" resultType="java.util.Map" parameterType="com.hx.mybatisTool.SqlSentence" > ${sqlSentence} </select> <select id="selectOne" resultType="com.hx.phiappt.model.user.UserProjectUsed" parameterType="com.hx.mybatisTool.SqlSentence" > ${sqlSentence} </select> <select id="selectOneMap" resultType="java.util.Map" parameterType="com.hx.mybatisTool.SqlSentence" > ${sqlSentence} </select> <select id="selectCount" resultType="int" parameterType="com.hx.mybatisTool.SqlSentence" > select COUNT(*) from user_project_used WHERE ${sqlSentence} </select> <select id="selectCountSql" resultType="int" parameterType="com.hx.mybatisTool.SqlSentence" > ${sqlSentence} </select> <select id="selectOneByKey" resultType="com.hx.phiappt.model.user.UserProjectUsed" parameterType="java.lang.Object" > select id,usedMethod,commonId,usedType,usedNum,shopId,shopName,userProjectId,userProjectItemId,sourceCode,sourceName,isDel,createTime from user_project_used WHERE id = #{value} </select> <select id="selectOneByKeyBlob" resultType="com.hx.phiappt.model.user.UserProjectUsed" parameterType="java.lang.Object" > select id,usedMethod,commonId,usedType,usedNum,shopId,shopName,userProjectId,userProjectItemId,sourceCode,sourceName,isDel,createTime from user_project_used WHERE id = #{value} </select> <update id="updateWhere" parameterType="com.hx.mybatisTool.SqlSentence"> update user_project_used SET ${sqlSentence} </update> <update id="updateAll" parameterType="com.hx.phiappt.model.user.UserProjectUsed"> update user_project_used SET <include refid="Update_Column_All"/> WHERE id = #{id} </update> <delete id="deleteWhere" parameterType="com.hx.mybatisTool.SqlSentence"> delete from user_project_used WHERE ${sqlSentence} </delete> <delete id="deleteById" parameterType="java.lang.Object"> delete from user_project_used WHERE id = #{value} </delete> </mapper> phi_platform_user/src/main/java/com/hx/phip/deduction/controller/DeductionController.java
@@ -1,6 +1,8 @@ package com.hx.phip.deduction.controller; import com.hx.common.BaseController; import com.hx.phiappt.common.DeductionSingleConstants; import com.hx.phiappt.model.BaseEntity; import com.hx.phip.deduction.service.DeductionSingleService; import com.hx.phip.dto.DeductionDto; import com.hx.resultTool.Result; @@ -27,30 +29,92 @@ private DeductionSingleService deductionSingleService; /** * 划扣记录 * 新增划扣记录 */ @RequestMapping(value = "/add", method = RequestMethod.POST) public Result orderAdd(HttpServletRequest request, DeductionDto deductionDto) { public Result addData(HttpServletRequest request, DeductionDto deductionDto) { // 校验参数 checkParam(deductionDto); // 获取用户信息 /*ThirtApplication thirtApplication= (ThirtApplication) request.getSession().getAttribute(LoginConstant.LOGIN_APPLY); ThirtApplication thirtApplication= (ThirtApplication) request.getSession().getAttribute(LoginConstant.LOGIN_APPLY); if(thirtApplication == null){ throw new PlatTipsException(PlatformCode.ERROR_PARAMETER_NULL,"登入失败,请登入后在试!"); } // 填充接口登入信息 deductionDto.setSourceCode(thirtApplication.getAppId()); deductionDto.setSourceName(thirtApplication.getName());*/ deductionDto.setSourceCode("8"); deductionDto.setSourceName("9"); deductionDto.setSourceName(thirtApplication.getName()); // 添加数据 deductionSingleService.insertInfo(deductionDto); deductionSingleService.editInfo(deductionDto, BaseEntity.YES); return Result.success(); } /** * 修改划扣记录 */ @RequestMapping(value = "/update", method = RequestMethod.POST) public Result updateData(HttpServletRequest request, DeductionDto deductionDto) { // 判断deductionSingleId 是否为空 if(StringUtils.isEmpty(deductionDto.getDeductionSingleId())){ throw new PlatTipsException(PlatformCode.ERROR_PARAMETER_NULL,"deductionSingleId不能为空"); } // 校验参数 checkParam(deductionDto); // 获取用户信息 ThirtApplication thirtApplication = (ThirtApplication) request.getSession().getAttribute(LoginConstant.LOGIN_APPLY); if(thirtApplication == null){ throw new PlatTipsException(PlatformCode.ERROR_PARAMETER_NULL,"登入失败,请登入后在试!"); } // 填充接口登入信息 deductionDto.setSourceCode(thirtApplication.getAppId()); deductionDto.setSourceName(thirtApplication.getName()); // 添加数据 deductionSingleService.editInfo(deductionDto, BaseEntity.NO); return Result.success(); } /** * 删除记录 */ @RequestMapping(value = "/delete", method = RequestMethod.POST) public Result deleteData(HttpServletRequest request,String deductionSingleId){ if(StringUtils.isEmpty(deductionSingleId)){ throw new PlatTipsException(PlatformCode.ERROR_PARAMETER_NULL,"deductionSingleId不能为空"); } ThirtApplication thirtApplication = (ThirtApplication) request.getSession().getAttribute(LoginConstant.LOGIN_APPLY); if(thirtApplication == null){ throw new PlatTipsException(PlatformCode.ERROR_PARAMETER_NULL,"登入失败,请登入后在试!"); } // 删除数据 deductionSingleService.deleteOne(deductionSingleId,thirtApplication.getAppId(),thirtApplication.getName(), DeductionSingleConstants.STATUS_CANCEL); return Result.success(); } /** * 撤销记录 */ @RequestMapping(value = "/rescinded", method = RequestMethod.POST) public Result rescindedData(HttpServletRequest request,String deductionSingleId){ if(StringUtils.isEmpty(deductionSingleId)){ throw new PlatTipsException(PlatformCode.ERROR_PARAMETER_NULL,"deductionSingleId不能为空"); } ThirtApplication thirtApplication = (ThirtApplication) request.getSession().getAttribute(LoginConstant.LOGIN_APPLY); if(thirtApplication == null){ throw new PlatTipsException(PlatformCode.ERROR_PARAMETER_NULL,"登入失败,请登入后在试!"); } // 删除数据 deductionSingleService.deleteOne(deductionSingleId,thirtApplication.getAppId(),thirtApplication.getName(), DeductionSingleConstants.STATUS_RESCINDED); return Result.success(); } /** * 校验参数 * @param deductionDto 参数对象 */ phi_platform_user/src/main/java/com/hx/phip/deduction/service/DeductionSingleService.java
@@ -13,7 +13,7 @@ void insert(DeductionSingle deductionSingle); void insertInfo(DeductionDto deductionDto); void editInfo(DeductionDto deductionDto,Integer type); List<DeductionSingle> selectList(SqlSentence sqlSentence); @@ -31,7 +31,5 @@ void updateWhere(SqlSentence sqlSentence); void deleteOne(String delId); void deleteOne(String delId,String sourceCode,String sourceName,Integer status); } phi_platform_user/src/main/java/com/hx/phip/deduction/service/impl/DeductionSingleServiceImpl.java
@@ -6,10 +6,12 @@ import com.hx.common.dao.CommonDao; import com.hx.phiappt.common.DeductionSingleConstants; import com.hx.phiappt.common.OrderGoodsConstants; import com.hx.phiappt.common.UserProjectUsedCon; import com.hx.phiappt.model.*; import com.hx.phiappt.model.deduction.*; import com.hx.phiappt.model.order.OrdersTotal; import com.hx.phiappt.model.user.UserProject; import com.hx.phiappt.model.user.UserProjectUsed; import com.hx.phiappt.model.warehouse.ShopWarehouse; import com.hx.phip.dao.mapper.*; import com.hx.phip.dto.DeductionDto; @@ -22,6 +24,9 @@ import com.hx.exception.TipsException; import com.hx.phip.deduction.service.DeductionSingleService; import com.hx.mybatisTool.SqlSentence; import java.util.Date; import java.util.HashMap; import java.util.List; import java.util.Map; @@ -38,7 +43,17 @@ @Resource private DeductionProjectMapper deductionProjectMapper; @Resource private UserProjectItemMapper userProjectItemMapper; private DeductionJoinMapper deductionJoinMapper; @Resource private DeductionDrugsMapper deductionDrugsMapper; @Resource private DeductionSignMapper deductionSignMapper; @Resource private DeductionDeviceParameterMapper deductionDeviceParameterMapper; @Resource private ComparePhotoRecordMapper comparePhotoRecordMapper; @Resource private ComparePhotoRecordPicturesMapper comparePhotoRecordPicturesMapper; /**查询列表*/ @Override @@ -85,9 +100,13 @@ } } /**新增*/ /** * 编辑接口 * @param deductionDto 划扣对象 * @param type 是否新增 */ @Override public void insertInfo(DeductionDto deductionDto) { public void editInfo(DeductionDto deductionDto, Integer type) { UserProject userProject = commonDao.selectOneByKey(UserProjectMapper.class,deductionDto.getUserProjectId()); if(userProject == null){ throw new PlatTipsException(PlatformCode.ERROR_PARAMETER_NULL,"未找到你的项目信息!"); @@ -95,6 +114,14 @@ // 项目划扣处理 if(userProject.getType() != null && OrderGoodsConstants.TYPE_PROJECT.equals(userProject.getType())) { // 新增判断次数是否充足 if(type == BaseEntity.YES) { // 判断项目可划扣次数是否充足 if (userProject.getNotUsedNum() <= 0 || deductionDto.getDeductionNum() > userProject.getNotUsedNum()) { throw new PlatTipsException(PlatformCode.ERROR_TIPS, "你的项目的划扣次数不足!"); } } // 判断用户是否存在 User user = commonDao.selectOneByKey(UserMapper.class,userProject.getUserId()); if(user == null){ @@ -102,7 +129,15 @@ } // 处理划扣项目清单 DeductionSingle deductionSingle = new DeductionSingle(); DeductionSingle deductionSingle; // 是否添加数据 if(type == BaseEntity.YES) { deductionSingle = new DeductionSingle(); }else{ deductionSingle = deductionSingleMapper.selectOneByKey(deductionDto.getDeductionSingleId()); } deductionSingle.setUserId(userProject.getUserId()); deductionSingle.setType(DeductionSingleConstants.TYPE_SELF_ADD); deductionSingle.setCommonId(deductionDto.getUserProjectId()); @@ -110,9 +145,18 @@ deductionSingle.setSourceName(deductionDto.getSourceName()); deductionSingle.setStatus(DeductionSingleConstants.STATUS_DONE_EXECUTE); deductionSingle.setRemarkInfo(deductionDto.getRemarkInfo()); int count = deductionSingleMapper.insert(deductionSingle); if (count != 1) { throw new TipsException("新增失败!"); // 是否添加数据 if(type == BaseEntity.YES) { int count = deductionSingleMapper.insert(deductionSingle); if (count != 1) { throw new TipsException("新增失败!"); } }else{ int count = deductionSingleMapper.updateAll(deductionSingle); if (count != 1) { throw new TipsException("编辑增失败!"); } } // 校验项目信息是否存在 @@ -126,22 +170,26 @@ throw new PlatTipsException(PlatformCode.ERROR_PARAMETER_NULL,"未找到你的订单信息!"); } // 查询有项目有几次执行记录 SqlSentence sqlSentence = new SqlSentence(); String sql = String.format(" isDel=0 AND status=1 AND commonId='%s'",deductionSingle.getCommonId()); sqlSentence.setSqlSentence(sql); int projectFrequency = deductionSingleMapper.selectCount(sqlSentence); // 处理划扣项目 DeductionProject deductionProject = new DeductionProject(); DeductionProject deductionProject; // 执行次数 int projectFrequency = 0; // 是否添加数据 if(type == BaseEntity.YES) { deductionProject = new DeductionProject(); deductionProject.setNum(deductionDto.getDeductionNum()); }else{ deductionProject = deductionProjectMapper.selectOneByDeductionSingleId(deductionSingle.getId()); if(deductionProject.getNum() != deductionDto.getDeductionNum()){ throw new PlatTipsException(PlatformCode.ERROR_TIPS,"编辑不能修改划扣数量!"); } } deductionProject.setDeductionSingleId(deductionSingle.getId()); deductionProject.setProjectId(userProject.getGoodsId()); deductionProject.setProjectNo(userProject.getGoodsNo()); deductionProject.setProjectName(project.getName()); deductionProject.setProjectFrequency(projectFrequency); deductionProject.setPrice(project.getPrice()); deductionProject.setNum(deductionDto.getDeductionNum()); deductionProject.setShopId(ordersTotal.getShopId()); deductionProject.setShopName(ordersTotal.getShopName()); // 科室编号为空默认科室 @@ -158,15 +206,34 @@ deductionProject.setExecuteStartTime(deductionDto.getExecuteStartTime()); deductionProject.setExecuteEndTime(deductionDto.getExecuteEndTime()); deductionProject.setRemarkInfo(deductionSingle.getRemarkInfo()); count = deductionProjectMapper.insert(deductionProject); if (count != 1) { throw new TipsException("新增划扣项目记录失败!"); // 是否添加数据 if(type == BaseEntity.YES) { // 查询有项目有几次执行记录 SqlSentence sqlSentence = new SqlSentence(); String sql = String.format(" isDel=0 AND status=1 AND commonId='%s'",deductionSingle.getCommonId()); sqlSentence.setSqlSentence(sql); projectFrequency = deductionSingleMapper.selectCount(sqlSentence); deductionProject.setProjectFrequency(projectFrequency); int count = deductionProjectMapper.insert(deductionProject); if (count != 1) { throw new TipsException("新增划扣项目记录失败!"); } }else{ int count = deductionProjectMapper.updateAll(deductionProject); if (count != 1) { throw new TipsException("编辑划扣项目记录失败!"); } } // 处理参与人员信息 if(!StringUtils.isEmpty(deductionDto.getDeductionJoinJson())){ List<DeductionJoin> deductionJoinList = JSONArray.parseArray(deductionDto.getDeductionJoinJson(), DeductionJoin.class); if(deductionJoinList !=null && deductionJoinList.size() > 0) { // 编辑数据 if(type == BaseEntity.NO){ deductionJoinMapper.deleteByDeductionSingleId(deductionSingle.getId(),deductionProject.getId()); } deductionJoinList.forEach(deductionJoin -> { // 判断治疗时常 if(deductionJoin.getUseDuration() <= 0){ @@ -176,23 +243,23 @@ if(StringUtils.isEmpty(deductionJoin.getRoleId())){ throw new PlatTipsException(PlatformCode.ERROR_PARAMETER_NULL,"员工角色id不能为空!"); }else{ /*EmployeeRole employeeRole = commonDao.selectOneByKey(EmployeeRoleMapper.class, deductionJoin.getRoleId()); EmployeeRole employeeRole = commonDao.selectOneByKey(EmployeeRoleMapper.class, deductionJoin.getRoleId()); if(employeeRole == null){ throw new PlatTipsException(PlatformCode.ERROR_PARAMETER_NULL,"员工角色信息不存在!"); }else{ deductionJoin.setRoleName(employeeRole.getRoleName()); }*/ } } // 判断员工id if(StringUtils.isEmpty(deductionJoin.getEmployeeId())){ throw new PlatTipsException(PlatformCode.ERROR_PARAMETER_NULL,"员工id不能为空!"); }else{ /*Employee employee = commonDao.selectOneByKey(EmployeeMapper.class,deductionJoin.getEmployeeId()); Employee employee = commonDao.selectOneByKey(EmployeeMapper.class,deductionJoin.getEmployeeId()); if(employee == null){ throw new PlatTipsException(PlatformCode.ERROR_PARAMETER_NULL,"员工信息不存在!"); }else{ deductionJoin.setEmployeeName(employee.getCnName()); }*/ } } deductionJoin.setDeductionSingleId(deductionSingle.getId()); deductionJoin.setDeductionProjectId(deductionProject.getId()); @@ -208,6 +275,10 @@ if(!StringUtils.isEmpty(deductionDto.getDeductionDrugsJson())){ List<DeductionDrugs> deductionDrugsList = JSONArray.parseArray(deductionDto.getDeductionDrugsJson(), DeductionDrugs.class); if(deductionDrugsList != null && deductionDrugsList.size() > 0){ // 编辑数据 if(type == BaseEntity.NO){ deductionDrugsMapper.deleteByDeductionSingleId(deductionSingle.getId(),deductionProject.getId()); } deductionDrugsList.forEach(deductionDrugs -> { if(deductionDrugs.getNum() == null || deductionDrugs.getNum() <= 0){ throw new PlatTipsException(PlatformCode.ERROR_PARAMETER_NULL,"耗材/药品数量不能为空且要大于0!"); @@ -231,10 +302,10 @@ if(StringUtils.isEmpty(deductionDrugs.getWarehouseId())){ throw new PlatTipsException(PlatformCode.ERROR_PARAMETER_NULL,"仓库信息不能为空!"); }else{ /*ShopWarehouse shopWarehouse = commonDao.selectOneByKey(ShopWarehouseMapper.class,deductionDrugs.getWarehouseId()); ShopWarehouse shopWarehouse = commonDao.selectOneByKey(ShopWarehouseMapper.class,deductionDrugs.getWarehouseId()); if(shopWarehouse == null){ throw new PlatTipsException(PlatformCode.ERROR_PARAMETER_NULL,"未找到仓库信息!"); }*/ } } // 判断批次信息 if(StringUtils.isEmpty(deductionDrugs.getBatchNo())){ @@ -254,6 +325,10 @@ if(!StringUtils.isEmpty(deductionDto.getDeductionDeviceParameterJson())){ List<DeductionDeviceParameter> deductionDeviceParameterList = JSONArray.parseArray(deductionDto.getDeductionDeviceParameterJson(), DeductionDeviceParameter.class); if(deductionDeviceParameterList !=null && deductionDeviceParameterList.size() > 0){ // 编辑数据 if(type == BaseEntity.NO){ deductionDeviceParameterMapper.deleteByDeductionSingleId(deductionSingle.getId(),deductionProject.getId()); } deductionDeviceParameterList.forEach(deductionDeviceParameter -> { // 判断选值是否为空 if(StringUtils.isEmpty(deductionDeviceParameter.getOptionalValue())){ @@ -297,6 +372,10 @@ if(!StringUtils.isEmpty(deductionDto.getDeductionSignJson())){ List<DeductionSign> deductionSignList = JSONArray.parseArray(deductionDto.getDeductionSignJson(), DeductionSign.class); if(deductionSignList != null && deductionSignList.size() > 0){ // 编辑数据 if(type == BaseEntity.NO){ deductionSignMapper.deleteByDeductionSingleId(deductionSingle.getId(),deductionProject.getId()); } deductionSignList.forEach(deductionSign -> { // 判断签名类型 if(StringUtils.isEmpty(deductionSign.getSignType())){ @@ -324,29 +403,96 @@ if(!StringUtils.isEmpty(deductionDto.getComparePhotoRecordJson())){ List<ComparePhotoRecordPictures> comparePhotoRecordPicturesList = JSONArray.parseArray(deductionDto.getComparePhotoRecordJson(), ComparePhotoRecordPictures.class); if( comparePhotoRecordPicturesList != null && comparePhotoRecordPicturesList.size() > 0) { ComparePhotoRecord comparePhotoRecord = new ComparePhotoRecord(); comparePhotoRecord.setUserId(deductionSingle.getUserId()); comparePhotoRecord.setProjectId(deductionProject.getProjectId()); comparePhotoRecord.setProjectFrequency(0); comparePhotoRecord.setUserProjectId(userProject.getId()); comparePhotoRecord.setDeductionProjectId(deductionProject.getId()); comparePhotoRecord.setDeductionSingleId(deductionSingle.getId()); int insert = commonDao.insert(ComparePhotoRecordMapper.class, comparePhotoRecord); if (insert != 1) { throw new TipsException("新增治疗图片类型记录失败!"); }else{ comparePhotoRecordPicturesList.forEach(comparePhotoRecordPictures -> { comparePhotoRecordPictures.setComparePhotoRecordId(comparePhotoRecord.getId()); if(StringUtils.isEmpty(comparePhotoRecordPictures.getImgUrl())){ throw new PlatTipsException(PlatformCode.ERROR_PARAMETER_NULL,"治疗图片类型不能未空!"); } commonDao.insert(ComparePhotoRecordPicturesMapper.class,comparePhotoRecordPictures); }); ComparePhotoRecord comparePhotoRecord; // 新增数据 if(type == BaseEntity.YES) { comparePhotoRecord = new ComparePhotoRecord(); comparePhotoRecord.setProjectFrequency(projectFrequency); comparePhotoRecord.setUserId(deductionSingle.getUserId()); comparePhotoRecord.setProjectId(deductionProject.getProjectId()); comparePhotoRecord.setUserProjectId(userProject.getId()); comparePhotoRecord.setDeductionProjectId(deductionProject.getId()); comparePhotoRecord.setDeductionSingleId(deductionSingle.getId()); int insert = commonDao.insert(ComparePhotoRecordMapper.class, comparePhotoRecord); if (insert != 1) { throw new TipsException("新增治疗图片类型记录失败!"); } }else { comparePhotoRecord = comparePhotoRecordMapper.selectOneByDeductionSingleId(deductionSingle.getId(), deductionProject.getId()); } // 编辑数据 if(type == BaseEntity.NO){ comparePhotoRecordPicturesMapper.deleteByDeductionSingleId(comparePhotoRecord.getId()); } comparePhotoRecordPicturesList.forEach(comparePhotoRecordPictures -> { comparePhotoRecordPictures.setComparePhotoRecordId(comparePhotoRecord.getId()); if (StringUtils.isEmpty(comparePhotoRecordPictures.getImgUrl())) { throw new PlatTipsException(PlatformCode.ERROR_PARAMETER_NULL, "治疗图片类型不能未空!"); } commonDao.insert(ComparePhotoRecordPicturesMapper.class, comparePhotoRecordPictures); }); } } // 处理项目剩余可划扣次数 if(type == BaseEntity.YES) { handleUserProjectNotUsedNum(deductionSingle.getId(), userProject.getId(), deductionDto.getDeductionNum(), deductionDto.getSourceCode(),deductionDto.getSourceName(),ordersTotal.getShopId(),ordersTotal.getShopName()); } }else{ throw new PlatTipsException(PlatformCode.ERROR_TIPS,"商品划扣还在开发中!"); } } /** * 处理减扣划扣次数 * @param deductionSingleId 划扣项目清单标识id * @param userProjectId 用户项目id * @param deductionNum 划扣次数 * @param sourceCode 来源code * @param sourceName 来源名称 * @param shopId 门店id * @param shopName 门店名称 */ private void handleUserProjectNotUsedNum(String deductionSingleId,String userProjectId,Integer deductionNum,String sourceCode,String sourceName,String shopId,String shopName){ SqlSentence sqlSentence = new SqlSentence(); Map<String,Object> map = new HashMap<>(); map.put("isDel", BaseEntity.NO); map.put("userProjectId",userProjectId); map.put("deductionNum",deductionNum); String sql = " notUsedNum=notUsedNum-#{m.deductionNum},usedNum=usedNum+#{m.deductionNum} WHERE isDel=#{m.isDel} AND id=#{m.userProjectId}"; Integer type = 0; if(deductionNum > 0){ sql += " AND notUsedNum > 0"; type = UserProjectUsedCon.USED_TYPE_DEDUCTION; }else{ sql += " AND usedNum > 0"; type = UserProjectUsedCon.USED_TYPE_RETURN; } sqlSentence.setSqlSentence(sql); sqlSentence.setM(map); int count = commonDao.updateWhere(UserProjectMapper.class, sqlSentence); if (count != 1) { throw new TipsException("减扣项目可执行次数失败!"); }else{ // 添加划扣日志 UserProjectUsed userProjectUsed = new UserProjectUsed(); userProjectUsed.setUsedMethod(UserProjectUsedCon.USED_METHOD_DEDUCTION_SINGLE); userProjectUsed.setCommonId(deductionSingleId); userProjectUsed.setUsedType(type); userProjectUsed.setUsedNum(deductionNum); userProjectUsed.setShopId(shopId); userProjectUsed.setShopName(shopName); userProjectUsed.setUserProjectId(userProjectId); userProjectUsed.setSourceCode(sourceCode); userProjectUsed.setSourceName(sourceName); int insert = commonDao.insert(UserProjectUsedMapper.class, userProjectUsed); if (insert != 1) { throw new TipsException("添加扣减划扣次数日志失败!"); } } } @@ -370,11 +516,49 @@ /**删除一个*/ @Override public void deleteOne(String delId) { int count = deductionSingleMapper.deleteById(delId); public void deleteOne(String delId,String sourceCode,String sourceName,Integer status) { DeductionSingle deductionSingle = deductionSingleMapper.selectOneByKey(delId); if(deductionSingle == null){ throw new PlatTipsException(PlatformCode.ERROR_PARAMETER_NULL,"未找到你的划扣信息!"); } if(deductionSingle.getStatus() != DeductionSingleConstants.STATUS_DONE_EXECUTE){ throw new PlatTipsException(PlatformCode.ERROR_PARAMETER_NULL,"您的划扣记录状态不正确不是可撤销或可作废的类型!"); } SqlSentence sqlSentence = new SqlSentence(); Map<String,Object> map = new HashMap<>(); map.put("id",delId); map.put("status",status); String sql = ""; if(status == DeductionSingleConstants.STATUS_CANCEL) { map.put("isDel", BaseEntity.YES); map.put("cancelTime",new Date()); sql = " cancelTime=#{m.cancelTime},status=#{m.status},isDel=#{m.isDel} WHERE id=#{m.id}"; } if(status == DeductionSingleConstants.STATUS_RESCINDED){ map.put("isDel", BaseEntity.NO); map.put("rescindedTime",new Date()); sql = " rescindedTime=#{m.rescindedTime},status=#{m.status},isDel=#{m.isDel} WHERE id=#{m.id}"; } sqlSentence.setSqlSentence(sql); sqlSentence.setM(map); int count = deductionSingleMapper.updateWhere(sqlSentence); if(count!=1) { throw new TipsException("删除失败!"); } throw new TipsException("操作失败!"); }else{ DeductionProject deductionProject = deductionProjectMapper.selectOneByDeductionSingleId(deductionSingle.getId()); if(deductionProject == null){ throw new PlatTipsException(PlatformCode.ERROR_PARAMETER_NULL,"未找到你的划扣记录里面的项目信息!"); } OrdersTotal ordersTotal = ordersTotalMapper.selectOneByUserProjectId(deductionSingle.getCommonId()); if(ordersTotal == null){ throw new PlatTipsException(PlatformCode.ERROR_PARAMETER_NULL,"未找到你的订单信息!"); } handleUserProjectNotUsedNum(deductionSingle.getId(), deductionSingle.getCommonId(), -deductionProject.getNum(), sourceCode, sourceName, ordersTotal.getShopId(), ordersTotal.getShopName()); } } /**查询条数*/ phi_platform_user/src/main/java/com/hx/phip/order/service/OrdersTotalService.java
New file @@ -0,0 +1,33 @@ package com.hx.phip.order.service; import com.hx.phiappt.model.order.OrdersTotal; import com.hx.mybatisTool.SqlSentence; import java.util.List; import java.util.Map; public interface OrdersTotalService { int selectCount(SqlSentence sqlSentence); void insert(OrdersTotal ordersTotal); List<OrdersTotal> selectList(SqlSentence sqlSentence); List<Map<String,Object>> selectListMap(SqlSentence sqlSentence); OrdersTotal selectOne(SqlSentence sqlSentence); Map<String,Object> selectOneMap(SqlSentence sqlSentence); OrdersTotal selectOneByKey(Object object); OrdersTotal selectOneByKeyBlob(Object object); void updateAll(OrdersTotal ordersTotal); void updateWhere(SqlSentence sqlSentence); void deleteOne(String delId); } phi_platform_user/src/main/java/com/hx/phip/order/service/impl/OrdersTotalServiceImpl.java
New file @@ -0,0 +1,101 @@ package com.hx.phip.order.service.impl; import javax.annotation.Resource; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; import com.hx.exception.TipsException; import com.hx.phip.dao.mapper.OrdersTotalMapper; import com.hx.phiappt.model.order.OrdersTotal; import com.hx.phip.order.service.OrdersTotalService; import com.hx.mybatisTool.SqlSentence; import java.util.List; import java.util.Map; @Transactional @Service public class OrdersTotalServiceImpl implements OrdersTotalService { @Resource private OrdersTotalMapper ordersTotalMapper; /**查询列表*/ @Override public List<OrdersTotal> selectList(SqlSentence sqlSentence) { return ordersTotalMapper.selectList(sqlSentence); } /**查询列表*/ @Override public List<Map<String,Object>> selectListMap(SqlSentence sqlSentence) { return ordersTotalMapper.selectListMap(sqlSentence); } /**查询单个*/ @Override public OrdersTotal selectOne(SqlSentence sqlSentence) { return ordersTotalMapper.selectOne(sqlSentence); } /**查询单个*/ @Override public Map<String,Object> selectOneMap(SqlSentence sqlSentence) { return ordersTotalMapper.selectOneMap(sqlSentence); } /**查询单个,大数据不拿取*/ @Override public OrdersTotal selectOneByKey(Object object) { return ordersTotalMapper.selectOneByKey(object); } /**查询单个,大数据拿取*/ @Override public OrdersTotal selectOneByKeyBlob(Object object) { return ordersTotalMapper.selectOneByKeyBlob(object); } /**新增*/ @Override public void insert(OrdersTotal ordersTotal) { int count = ordersTotalMapper.insert(ordersTotal); if(count != 1) { throw new TipsException("新增失败!"); } } /**修改*/ @Override public void updateAll(OrdersTotal ordersTotal) { int count = ordersTotalMapper.updateAll(ordersTotal); if(count!=1) { throw new TipsException("保存失败!"); } } /**修改*/ @Override public void updateWhere(SqlSentence sqlSentence) { int count = ordersTotalMapper.updateWhere(sqlSentence); if(count!=1) { throw new TipsException("保存失败!"); } } /**删除一个*/ @Override public void deleteOne(String delId) { int count = ordersTotalMapper.deleteById(delId); if(count!=1) { throw new TipsException("删除失败!"); } } /**查询条数*/ @Override public int selectCount(SqlSentence sqlSentence) { int count = ordersTotalMapper.selectCount(sqlSentence); return count; } } phi_platform_user/src/main/java/com/hx/phip/service/DeviceService.java
New file @@ -0,0 +1,33 @@ package com.hx.phip.service; import com.hx.phiappt.model.Device; import com.hx.mybatisTool.SqlSentence; import java.util.List; import java.util.Map; public interface DeviceService { int selectCount(SqlSentence sqlSentence); void insert(Device device); List<Device> selectList(SqlSentence sqlSentence); List<Map<String,Object>> selectListMap(SqlSentence sqlSentence); Device selectOne(SqlSentence sqlSentence); Map<String,Object> selectOneMap(SqlSentence sqlSentence); Device selectOneByKey(Object object); Device selectOneByKeyBlob(Object object); void updateAll(Device device); void updateWhere(SqlSentence sqlSentence); void deleteOne(String delId); } phi_platform_user/src/main/java/com/hx/phip/service/impl/DeviceServiceImpl.java
New file @@ -0,0 +1,101 @@ package com.hx.phip.service.impl; import javax.annotation.Resource; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; import com.hx.exception.TipsException; import com.hx.phip.dao.mapper.DeviceMapper; import com.hx.phiappt.model.Device; import com.hx.phip.service.DeviceService; import com.hx.mybatisTool.SqlSentence; import java.util.List; import java.util.Map; @Transactional @Service public class DeviceServiceImpl implements DeviceService { @Resource private DeviceMapper deviceMapper; /**查询列表*/ @Override public List<Device> selectList(SqlSentence sqlSentence) { return deviceMapper.selectList(sqlSentence); } /**查询列表*/ @Override public List<Map<String,Object>> selectListMap(SqlSentence sqlSentence) { return deviceMapper.selectListMap(sqlSentence); } /**查询单个*/ @Override public Device selectOne(SqlSentence sqlSentence) { return deviceMapper.selectOne(sqlSentence); } /**查询单个*/ @Override public Map<String,Object> selectOneMap(SqlSentence sqlSentence) { return deviceMapper.selectOneMap(sqlSentence); } /**查询单个,大数据不拿取*/ @Override public Device selectOneByKey(Object object) { return deviceMapper.selectOneByKey(object); } /**查询单个,大数据拿取*/ @Override public Device selectOneByKeyBlob(Object object) { return deviceMapper.selectOneByKeyBlob(object); } /**新增*/ @Override public void insert(Device device) { int count = deviceMapper.insert(device); if(count != 1) { throw new TipsException("新增失败!"); } } /**修改*/ @Override public void updateAll(Device device) { int count = deviceMapper.updateAll(device); if(count!=1) { throw new TipsException("保存失败!"); } } /**修改*/ @Override public void updateWhere(SqlSentence sqlSentence) { int count = deviceMapper.updateWhere(sqlSentence); if(count!=1) { throw new TipsException("保存失败!"); } } /**删除一个*/ @Override public void deleteOne(String delId) { int count = deviceMapper.deleteById(delId); if(count!=1) { throw new TipsException("删除失败!"); } } /**查询条数*/ @Override public int selectCount(SqlSentence sqlSentence) { int count = deviceMapper.selectCount(sqlSentence); return count; } } phi_platform_user/src/main/java/com/hx/phip/user/service/UserProjectUsedService.java
New file @@ -0,0 +1,33 @@ package com.hx.phip.user.service; import com.hx.phiappt.model.user.UserProjectUsed; import com.hx.mybatisTool.SqlSentence; import java.util.List; import java.util.Map; public interface UserProjectUsedService { int selectCount(SqlSentence sqlSentence); void insert(UserProjectUsed userProjectUsed); List<UserProjectUsed> selectList(SqlSentence sqlSentence); List<Map<String,Object>> selectListMap(SqlSentence sqlSentence); UserProjectUsed selectOne(SqlSentence sqlSentence); Map<String,Object> selectOneMap(SqlSentence sqlSentence); UserProjectUsed selectOneByKey(Object object); UserProjectUsed selectOneByKeyBlob(Object object); void updateAll(UserProjectUsed userProjectUsed); void updateWhere(SqlSentence sqlSentence); void deleteOne(String delId); } phi_platform_user/src/main/java/com/hx/phip/user/service/impl/UserProjectUsedServiceImpl.java
New file @@ -0,0 +1,101 @@ package com.hx.phip.user.service.impl; import javax.annotation.Resource; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; import com.hx.exception.TipsException; import com.hx.phip.dao.mapper.UserProjectUsedMapper; import com.hx.phiappt.model.user.UserProjectUsed; import com.hx.phip.user.service.UserProjectUsedService; import com.hx.mybatisTool.SqlSentence; import java.util.List; import java.util.Map; @Transactional @Service public class UserProjectUsedServiceImpl implements UserProjectUsedService { @Resource private UserProjectUsedMapper userProjectUsedMapper; /**查询列表*/ @Override public List<UserProjectUsed> selectList(SqlSentence sqlSentence) { return userProjectUsedMapper.selectList(sqlSentence); } /**查询列表*/ @Override public List<Map<String,Object>> selectListMap(SqlSentence sqlSentence) { return userProjectUsedMapper.selectListMap(sqlSentence); } /**查询单个*/ @Override public UserProjectUsed selectOne(SqlSentence sqlSentence) { return userProjectUsedMapper.selectOne(sqlSentence); } /**查询单个*/ @Override public Map<String,Object> selectOneMap(SqlSentence sqlSentence) { return userProjectUsedMapper.selectOneMap(sqlSentence); } /**查询单个,大数据不拿取*/ @Override public UserProjectUsed selectOneByKey(Object object) { return userProjectUsedMapper.selectOneByKey(object); } /**查询单个,大数据拿取*/ @Override public UserProjectUsed selectOneByKeyBlob(Object object) { return userProjectUsedMapper.selectOneByKeyBlob(object); } /**新增*/ @Override public void insert(UserProjectUsed userProjectUsed) { int count = userProjectUsedMapper.insert(userProjectUsed); if(count != 1) { throw new TipsException("新增失败!"); } } /**修改*/ @Override public void updateAll(UserProjectUsed userProjectUsed) { int count = userProjectUsedMapper.updateAll(userProjectUsed); if(count!=1) { throw new TipsException("保存失败!"); } } /**修改*/ @Override public void updateWhere(SqlSentence sqlSentence) { int count = userProjectUsedMapper.updateWhere(sqlSentence); if(count!=1) { throw new TipsException("保存失败!"); } } /**删除一个*/ @Override public void deleteOne(String delId) { int count = userProjectUsedMapper.deleteById(delId); if(count!=1) { throw new TipsException("删除失败!"); } } /**查询条数*/ @Override public int selectCount(SqlSentence sqlSentence) { int count = userProjectUsedMapper.selectCount(sqlSentence); return count; } }