From cc120d54e26f64753e99b349599875cf6911a0af Mon Sep 17 00:00:00 2001 From: jinpengyong <jpy123456> Date: Wed, 18 Oct 2023 08:26:19 +0800 Subject: [PATCH] chore:小程序测试提交 --- screen-api/src/main/java/com/moral/api/mapper/AllocationMapper.java | 5 screen-api/src/main/java/com/moral/api/service/UserService.java | 4 screen-api/src/main/java/com/moral/api/pojo/vo/allocation/AllocationFindVo.java | 76 ++++++++++ screen-api/src/main/java/com/moral/api/service/impl/UserServiceImpl.java | 64 +++++++++ screen-api/src/main/java/com/moral/api/controller/UserSmallRoutineController.java | 45 ++++++ screen-api/src/main/java/com/moral/api/mapper/UserSmallRoutineMapper.java | 4 screen-api/src/main/java/com/moral/api/service/AllocationService.java | 26 +++ screen-api/src/main/java/com/moral/api/controller/AllocationController.java | 29 ++++ screen-api/src/main/java/com/moral/api/service/impl/AllocationServiceImpl.java | 128 ++++++++++++++++++ screen-api/src/main/resources/mapper/AllocationMapper.xml | 20 ++ 10 files changed, 399 insertions(+), 2 deletions(-) diff --git a/screen-api/src/main/java/com/moral/api/controller/AllocationController.java b/screen-api/src/main/java/com/moral/api/controller/AllocationController.java index 476d2c6..b59de2e 100644 --- a/screen-api/src/main/java/com/moral/api/controller/AllocationController.java +++ b/screen-api/src/main/java/com/moral/api/controller/AllocationController.java @@ -12,6 +12,7 @@ import com.moral.api.pojo.ext.allocation.AllocationPageExt; import com.moral.api.pojo.query.allocation.*; import com.moral.api.pojo.query.allocationextension.AllocationExtensionAddCond; +import com.moral.api.pojo.vo.allocation.AllocationFindVo; import com.moral.api.pojo.vo.allocation.AllocationPageVo; import com.moral.api.pojo.vo.allocation.AllocationVo; import com.moral.api.utils.BeanConverts; @@ -197,4 +198,32 @@ } } + + + @GetMapping("selectSmallRoutine") + @ApiOperation("���������������") + public ResultMessage selectSmallRoutine(@RequestParam @ApiParam(value = "state",name = "������") Integer state, + @RequestParam @ApiParam(value = "startTime",name = "������������") String startTime, + @RequestParam @ApiParam(value = "endTime",name = "������������") String endTime){ + List<AllocationFindVo> allocationFindVos = allocationService.selectSmallRoutine(state,startTime,endTime); + return ResultMessage.ok(ObjectUtils.isEmpty(allocationFindVos)? "0":allocationFindVos); + } + + + @PostMapping("changeRoutine") + @ApiOperation("���������������") + public ResultMessage changeSmallRoutine(@Valid @RequestBody AllocationChangeCond changeCond){ + allocationService.changeSmallRoutine(changeCond); + return ResultMessage.ok(); + } + + + @PostMapping("checkRoutine") + @ApiOperation("���������������") + public ResultMessage checkSmallRoutine(@Valid @RequestBody AllocationCheckCond checkCond){ + allocationService.checkSmallRoutine(checkCond); + return ResultMessage.ok(); + } + + } diff --git a/screen-api/src/main/java/com/moral/api/controller/UserSmallRoutineController.java b/screen-api/src/main/java/com/moral/api/controller/UserSmallRoutineController.java new file mode 100644 index 0000000..f32ef5a --- /dev/null +++ b/screen-api/src/main/java/com/moral/api/controller/UserSmallRoutineController.java @@ -0,0 +1,45 @@ +package com.moral.api.controller; + + +import cn.hutool.core.util.StrUtil; +import io.swagger.annotations.Api; +import io.swagger.annotations.ApiOperation; +import lombok.extern.slf4j.Slf4j; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.web.bind.annotation.PostMapping; +import org.springframework.web.bind.annotation.RequestBody; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RequestMethod; +import org.springframework.web.bind.annotation.RestController; + +import java.util.Map; + +import com.moral.api.service.UserService; +import com.moral.constant.ResponseCodeEnum; +import com.moral.constant.ResultMessage; + +@Slf4j +@Api(tags = {"���������������������"}) +@RestController +@RequestMapping("/UserSmallRoutine") +public class UserSmallRoutineController { + + @Autowired + private UserService userService; + + @ApiOperation(value = "������������", notes = "������������") + @PostMapping("login") + public ResultMessage login(@RequestBody Map<String, Object> parameters) { + if (!(parameters.containsKey("account") && parameters.containsKey("password"))) { + return ResultMessage.fail(ResponseCodeEnum.PARAMETERS_IS_MISSING.getCode(), + ResponseCodeEnum.PARAMETERS_IS_MISSING.getMsg()); + } + Map<String, Object> result = userService.loginSmallRoutine(parameters); + if (!result.containsKey("token")) { + return ResultMessage.fail((int) result.get("code"), (String) result.get("msg")); + } + return ResultMessage.ok(result); + } + + +} diff --git a/screen-api/src/main/java/com/moral/api/mapper/AllocationMapper.java b/screen-api/src/main/java/com/moral/api/mapper/AllocationMapper.java index 87fb92b..6ec486c 100644 --- a/screen-api/src/main/java/com/moral/api/mapper/AllocationMapper.java +++ b/screen-api/src/main/java/com/moral/api/mapper/AllocationMapper.java @@ -8,6 +8,8 @@ import com.moral.api.pojo.ext.allocation.AllocationPageExt; import com.moral.api.pojo.query.allocation.AllocationListCond; import com.moral.api.pojo.query.allocation.AllocationPageCond; +import com.moral.api.pojo.vo.allocation.AllocationFindVo; + import org.apache.ibatis.annotations.Param; import java.util.List; @@ -30,4 +32,7 @@ */ List<AllocationListExt> extList(@Param("allocation") AllocationListCond allocationListCond); + + List<AllocationFindVo> selectSmallRoutine( Integer state); + } diff --git a/screen-api/src/main/java/com/moral/api/mapper/UserSmallRoutineMapper.java b/screen-api/src/main/java/com/moral/api/mapper/UserSmallRoutineMapper.java new file mode 100644 index 0000000..54e6fb4 --- /dev/null +++ b/screen-api/src/main/java/com/moral/api/mapper/UserSmallRoutineMapper.java @@ -0,0 +1,4 @@ +package com.moral.api.mapper; + +public interface UserSmallRoutineMapper { +} diff --git a/screen-api/src/main/java/com/moral/api/pojo/vo/allocation/AllocationFindVo.java b/screen-api/src/main/java/com/moral/api/pojo/vo/allocation/AllocationFindVo.java new file mode 100644 index 0000000..70fefd6 --- /dev/null +++ b/screen-api/src/main/java/com/moral/api/pojo/vo/allocation/AllocationFindVo.java @@ -0,0 +1,76 @@ +package com.moral.api.pojo.vo.allocation; + + +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; +import lombok.EqualsAndHashCode; +import lombok.experimental.Accessors; +import java.io.Serializable; +import java.util.Date; +import com.fasterxml.jackson.annotation.JsonFormat; +import com.moral.api.pojo.enums.AllocationApproveEnum; +import com.moral.util.DateUtils; + +@Data +@EqualsAndHashCode(callSuper = false) +@Accessors(chain = true) +@ApiModel(value="Allocation - ������VO������", description="Allocation - ������VO������") +public class AllocationFindVo implements Serializable { + + + + @ApiModelProperty(value = "������id") + private Integer allocationId; + + @ApiModelProperty(value = "������������") + private String allocationNum; + + @ApiModelProperty(value = "������������") + @JsonFormat(pattern="yyyy-MM-dd") + private Date escalationTime; + + @ApiModelProperty(value = "������������id") + private Integer unitId; + + @ApiModelProperty(value = "������������id") + private Integer polluteType; + + @ApiModelProperty(value = "������������id") + private Integer changeType; + + @ApiModelProperty(value = "������������") + private Integer changeDay; + + @ApiModelProperty(value = "������������") + private Integer residueDay; + + @ApiModelProperty(value = "������������id") + private Integer escalationUnitId; + + @ApiModelProperty(value = "���������") + private String escalationName; + + @ApiModelProperty(value = "������������id") + private Integer investigationType; + + @ApiModelProperty(value = "������") + private Integer state; + + @ApiModelProperty(value = "������������") + private Integer isInvalid; + + @ApiModelProperty(value = "������������") + private Integer isApprove; + + public Integer getResidueDay() { + int day = this.changeDay; + if(AllocationApproveEnum.UNDER_RECTIFICATION.value.equals(state)){ + Date date = new Date(); + int days = DateUtils.getDays(escalationTime, date); + return day-days; + } + return day; + } + +} diff --git a/screen-api/src/main/java/com/moral/api/service/AllocationService.java b/screen-api/src/main/java/com/moral/api/service/AllocationService.java index cb74d7c..58f721f 100644 --- a/screen-api/src/main/java/com/moral/api/service/AllocationService.java +++ b/screen-api/src/main/java/com/moral/api/service/AllocationService.java @@ -14,6 +14,8 @@ import com.moral.api.pojo.query.allocation.*; import com.moral.api.pojo.dto.allocation.AllocationUnitDto; import com.moral.api.pojo.query.allocationextension.AllocationExtensionAddCond; +import com.moral.api.pojo.vo.allocation.AllocationFindVo; +import com.moral.api.pojo.vo.allocation.AllocationPageVo; public interface AllocationService extends IService<Allocation> { @@ -97,4 +99,28 @@ * @return */ boolean applyFor (AllocationExtensionAddCond allocationExtensionAddCond); + + /** + * ��������������� + * @param state + * @return + */ + List<AllocationFindVo> selectSmallRoutine(Integer state,String startTime,String endTime); + + + /** + * ��������������� + * @param changeCond + */ + void changeSmallRoutine(AllocationChangeCond changeCond); + + + + /** + * ��������������� + * @param checkCond + */ + void checkSmallRoutine(AllocationCheckCond checkCond); + + } diff --git a/screen-api/src/main/java/com/moral/api/service/UserService.java b/screen-api/src/main/java/com/moral/api/service/UserService.java index 4b11228..6336d44 100644 --- a/screen-api/src/main/java/com/moral/api/service/UserService.java +++ b/screen-api/src/main/java/com/moral/api/service/UserService.java @@ -44,4 +44,8 @@ //������������������������������������ UserBO selectUserInfo(Map<String, Object> parameters); + //��������������� + Map<String, Object> loginSmallRoutine(Map<String, Object> parameters); + + } diff --git a/screen-api/src/main/java/com/moral/api/service/impl/AllocationServiceImpl.java b/screen-api/src/main/java/com/moral/api/service/impl/AllocationServiceImpl.java index 1b2f9ac..1f66f94 100644 --- a/screen-api/src/main/java/com/moral/api/service/impl/AllocationServiceImpl.java +++ b/screen-api/src/main/java/com/moral/api/service/impl/AllocationServiceImpl.java @@ -1,5 +1,6 @@ package com.moral.api.service.impl; +import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; import com.baomidou.mybatisplus.extension.conditions.update.LambdaUpdateChainWrapper; import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import com.moral.api.config.Interceptor.UserHelper; @@ -10,10 +11,9 @@ import com.moral.api.pojo.ext.allocation.AllocationExt; import com.moral.api.pojo.ext.allocation.AllocationListExt; import com.moral.api.pojo.ext.allocation.AllocationPageExt; -import com.moral.api.pojo.query.PageCond; import com.moral.api.pojo.query.allocation.*; import com.moral.api.pojo.query.allocationextension.AllocationExtensionAddCond; -import com.moral.api.pojo.vo.approvetable.ApproveTableListVo; +import com.moral.api.pojo.vo.allocation.AllocationFindVo; import com.moral.api.pojo.vo.user.QxUser; import com.moral.api.service.AllocationExtensionService; import com.moral.api.service.ApproveTableService; @@ -62,6 +62,7 @@ import com.moral.constant.RedisConstants; import com.moral.util.DateUtils; import com.moral.util.TokenUtils; +import com.sun.javafx.scene.control.skin.VirtualFlow; @Service @@ -636,6 +637,129 @@ } @Override + public List<AllocationFindVo> selectSmallRoutine(Integer state,String startTime,String endTime) { + ArrayList<AllocationFindVo> allocationFindVos = new ArrayList<>(); + LambdaQueryWrapper<Allocation> wrapper = new LambdaQueryWrapper<>(); + + //������������������ + List<Integer> list = unitResult(); + if (!ObjectUtils.isEmpty(list)){ + Integer integer = list.get(0); + if (integer==0){ + return null; + }else { + wrapper.in(Allocation::getUnitId,list); + } + } + Integer integer = unitAreaCode(); + //��������������� ��������� + if (integer==0 || integer==1){ + if (state==3){ + wrapper.in(Allocation::getState,40,50); + }else if (state==2){ + wrapper.eq(Allocation::getState,30); + }else if (state==1){ + wrapper.eq(Allocation::getState,20); + } + //������������ + }else if (integer==2){ + if (state==3){ + wrapper.in(Allocation::getState,40,50); + }else if (state==2){ + wrapper.eq(Allocation::getState,20); + }else if (state==1){ + wrapper.eq(Allocation::getState,30); + } + } + if (!ObjectUtils.isEmpty(startTime) && !ObjectUtils.isEmpty(endTime)){ + wrapper.between(Allocation::getEscalationTime,startTime,endTime); + } + wrapper.eq(Allocation::getIsDel,0).eq(Allocation::getIsInvalid,0); + List<Allocation> allocations = allocationMapper.selectList(wrapper); + for (Allocation allocation : allocations) { + AllocationFindVo allocationFindVo = new AllocationFindVo(); + BeanUtils.copyProperties(allocation,allocationFindVo); + allocationFindVos.add(allocationFindVo); + } +// List<AllocationFindVo> allocationFindVos = allocationMapper.selectSmallRoutine(state); + return allocationFindVos; + } + + /** + * ��������������� + * + * @param changeCond + */ + @Override + @Transactional + public void changeSmallRoutine(AllocationChangeCond changeCond) { + Integer integer = unitAreaCode(); + if (integer==1){ + throw new BusinessException("���������������������������������������"); + } + AllocationExt allocationExt = oneAllocation(changeCond.getAllocationId()); + if(!AllocationApproveEnum.UNDER_RECTIFICATION.value.equals(allocationExt.getState())) { + throw new BusinessException("������������������������������������"); + } + Allocation allocation = new Allocation(); + allocation.setAllocationId(changeCond.getAllocationId()); + allocation.setIsChange(changeCond.getIsChange()); + allocation.setChangeName(changeCond.getChangeName()); + allocation.setChangeDescribe(changeCond.getChangeDescribe()); + allocation.setState(changeCond.getState()); + allocation.setChangeTime(new Date()); + this.updateById(allocation); + //������������������ + ApproveTable approveTable = new ApproveTable(); + approveTable.setRelationId(allocation.getAllocationId()); + approveTable.setState(AllocationApproveEnum.UNDER_RECTIFICATION.value); + approveTable.setStateName(AllocationApproveEnum.UNDER_RECTIFICATION.name); + approveTable.setApproveModule(FileTableEnum.ALLOCATION_FOUNDATION.value); + approveTableService.saveResult(approveTable); + fileTableService.upDateResult(changeCond.getFileChangeList(),allocation.getAllocationId(), FileTableEnum.ALLOCATION_RECTIFICATION.value); + } + + /** + * ��������������� + * + * @param checkCond + */ + @Override + @Transactional + public void checkSmallRoutine(AllocationCheckCond checkCond) { + Integer integer = unitAreaCode(); + if (integer==0){ + throw new BusinessException("���������������������������������������"); + } + AllocationExt allocationExt = oneAllocation(checkCond.getAllocationId()); + if(!AllocationApproveEnum.IN_APPROVAL.value.equals(allocationExt.getState())) { + throw new BusinessException("������������������������������������������"); + } + QxUser qxUser = UserHelper.getCurrentUser(); + Allocation allocation = new Allocation(); + allocation.setCheckScore(checkCond.getCheckScore()); + allocation.setAllocationId(checkCond.getAllocationId()); + allocation.setCheckDescribe(checkCond.getCheckDescribe()); + allocation.setCheckName(qxUser.getUserName()); + allocation.setCheckTime(new Date()); + allocation.setState(checkCond.getState()); + this.updateById(allocation); + //������������������ + ApproveTable approveTable = new ApproveTable(); + approveTable.setRelationId(allocation.getAllocationId()); + if(AllocationApproveEnum.PASS.value.equals(checkCond.getState())){ + approveTable.setState(AllocationApproveEnum.PASS.value); + approveTable.setStateName(AllocationApproveEnum.PASS.name); + }else { + approveTable.setState(AllocationApproveEnum.REFUSE.value); + approveTable.setStateName(AllocationApproveEnum.REFUSE.name); + } + approveTable.setApproveModule(FileTableEnum.ALLOCATION_FOUNDATION.value); + approveTableService.saveResult(approveTable); + fileTableService.upDateResult(checkCond.getFileApproveList(),checkCond.getAllocationId(), FileTableEnum.ALLOCATION_APPROVE.value); + } + + @Override public List<Integer> unitResult() { QxUser user = UserHelper.getCurrentUser(); Integer unitId = Objects.nonNull(user.getUnitId())?user.getUnitId():0; diff --git a/screen-api/src/main/java/com/moral/api/service/impl/UserServiceImpl.java b/screen-api/src/main/java/com/moral/api/service/impl/UserServiceImpl.java index 9f09510..46171c8 100644 --- a/screen-api/src/main/java/com/moral/api/service/impl/UserServiceImpl.java +++ b/screen-api/src/main/java/com/moral/api/service/impl/UserServiceImpl.java @@ -90,6 +90,70 @@ } @Override + public Map<String, Object> loginSmallRoutine(Map<String, Object> parameters) { + UserBO userBo = selectUserInfo(parameters); + Map<String, Object> result = new HashMap<>(); + //������������ + if (userBo == null) { + result.put("code", ResponseCodeEnum.ACCOUNT_NOT_EXIST.getCode()); + result.put("msg", ResponseCodeEnum.ACCOUNT_NOT_EXIST.getMsg()); + return result; + } + //������������ + String password = parameters.get("password").toString(); + //������������ + password = AESUtils.decrypt(password, AESKey); + if (!MD5Utils.saltMD5Verify(password, userBo.getPassword())) { + result.put("code", ResponseCodeEnum.PASSWORD_INVALID.getCode()); + result.put("msg", ResponseCodeEnum.PASSWORD_INVALID.getMsg()); + return result; + } + //������������������ + if (Constants.DELETE.equals(userBo.getIsDelete())) { + result.put("code", ResponseCodeEnum.ACCOUNT_IS_DELETE.getCode()); + result.put("msg", ResponseCodeEnum.ACCOUNT_IS_DELETE.getMsg()); + return result; + } + //������������������ + if (userBo.getExpireTime() != null && userBo.getExpireTime().getTime() < System.currentTimeMillis()) { + result.put("code", ResponseCodeEnum.ACCOUNT_IS_EXPIRE.getCode()); + result.put("msg", ResponseCodeEnum.ACCOUNT_IS_EXPIRE.getMsg()); + return result; + } + //������������������ + Map<String, Object> userInfo = new LinkedHashMap<>(); + userInfo.put("userId", userBo.getId()); + userInfo.put("account", userBo.getAccount()); + userInfo.put("userName", userBo.getUserName()); + userInfo.put("email", userBo.getEmail()); + userInfo.put("mobile", userBo.getMobile()); + userInfo.put("unitId",userBo.getUnitId()); + userInfo.put("wechat", userBo.getWechat()); + userInfo.put("expireTime", DateUtils.dateToDateString(userBo.getExpireTime())); + userInfo.put("isAdmin", userBo.getIsAdmin()); + try { + //������token������������redis + String token = TokenUtils.getToken(userBo.getId().toString(), userInfo); + result.put("token", token); + } catch (Exception e) { + log.error("token���������������" + e.getMessage()); + result.put("code", ResponseCodeEnum.TOKEN_CREATE_ERROR.getCode()); + result.put("msg", ResponseCodeEnum.TOKEN_CREATE_ERROR.getMsg()); + return result; + } + //������ + HttpServletRequest request = ((ServletRequestAttributes) Objects.requireNonNull(RequestContextHolder.getRequestAttributes())).getRequest(); + UserLog userLog = new UserLog(); + userLog.setType(Constants.LOGIN_OPERTATE_TYPE); + userLog.setIp(WebUtils.getIpAddr(request)); + userLog.setOperateId(userBo.getId()); + userLog.setOrganizationId(userBo.getOrganizationId()); + userLog.setContent("������������������" + userBo.getAccount()); + userLogMapper.insert(userLog); + return result; + } + + @Override public Map<String, Object> login(Map<String, Object> parameters) { UserBO userBo = selectUserInfo(parameters); Map<String, Object> result = new HashMap<>(); diff --git a/screen-api/src/main/resources/mapper/AllocationMapper.xml b/screen-api/src/main/resources/mapper/AllocationMapper.xml index 7562062..bf5816e 100644 --- a/screen-api/src/main/resources/mapper/AllocationMapper.xml +++ b/screen-api/src/main/resources/mapper/AllocationMapper.xml @@ -59,6 +59,26 @@ </where> </select> + + <select id="selectSmallRoutine" resultType="com.moral.api.pojo.vo.allocation.AllocationFindVo"> + SELECT + <include refid="Allocation_Column_List"/> + FROM allocation as a + <where> + and is_del = 0 and is_invalid =0 + <if test="allocation.state != null and allocation.id != 0"> + and a.state = #{state} + </if> + <if test="allocation.startTime != null and allocation.startTime != '' "> + and date(escalation_time) <![CDATA[>=]]> #{startTime} + </if> + <if test="allocation.endTime != null and allocation.endTime !='' "> + and date(escalation_time) <![CDATA[<=]]> #{endTime} + </if> + </where> + order by escalation_time desc,allocation_id desc + </select> + <select id="extPage" resultType="com.moral.api.pojo.ext.allocation.AllocationPageExt"> SELECT <include refid="Allocation_Column_List"/>,t1.id as applyState -- Gitblit v1.8.0