From a3eaa78c6d839b640c728f4c7d8eb27732627b07 Mon Sep 17 00:00:00 2001 From: cjl <276999030@qq.com> Date: Fri, 20 Oct 2023 14:51:50 +0800 Subject: [PATCH] Merge remote-tracking branch 'origin/dev' into qa --- screen-api/src/main/java/com/moral/api/pojo/query/AppUserCond.java | 31 + screen-api/src/main/java/com/moral/api/exception/consumer/SecondDataConsumer.java | 1 screen-api/src/main/java/com/moral/api/mapper/AllocationMapper.java | 5 screen-api/src/main/java/com/moral/api/entity/AppUser.java | 18 + screen-api/src/main/java/com/moral/api/service/impl/UserServiceImpl.java | 167 ++++++++++ screen-common/src/main/java/com/moral/util/TokenUtils.java | 21 + screen-api/src/main/java/com/moral/api/service/impl/AllocationServiceImpl.java | 145 ++++++++ screen-api/pom.xml | 6 screen-api/src/main/resources/application-dev.yml | 1 screen-api/src/main/java/com/moral/api/mapper/AppUserMapper.java | 8 screen-api/src/main/java/com/moral/api/service/UserService.java | 9 screen-api/src/main/java/com/moral/api/controller/AppUserController.java | 64 ++++ screen-api/src/main/java/com/moral/api/pojo/vo/allocation/AllocationFindVo.java | 79 ++++ screen-api/src/main/java/com/moral/api/controller/AllocationController.java | 3 screen-api/src/main/java/com/moral/api/entity/User.java | 3 screen-api/src/main/java/com/moral/api/pojo/enums/AppAllocationStateEnum.java | 59 +++ screen-common/src/main/java/com/moral/constant/Constants.java | 7 screen-api/src/main/resources/application-local.yml | 1 screen-api/src/main/resources/mapper/AllocationMapper.xml | 1 screen-api/src/main/java/com/moral/api/service/AllocationService.java | 26 + screen-api/src/main/java/com/moral/api/utils/HttpClientUtil.java | 136 ++++++++ screen-api/src/main/java/com/moral/api/controller/AppAllocationController.java | 63 +++ screen-api/src/main/java/com/moral/api/utils/WechatUtils.java | 49 +++ screen-api/src/main/java/com/moral/api/service/impl/FileTableServiceImpl.java | 1 screen-api/src/main/resources/application-qa.yml | 1 screen-api/src/main/resources/application-cjl.yml | 1 26 files changed, 902 insertions(+), 4 deletions(-) diff --git a/screen-api/pom.xml b/screen-api/pom.xml index b923a07..f9d8328 100644 --- a/screen-api/pom.xml +++ b/screen-api/pom.xml @@ -11,6 +11,12 @@ <artifactId>screen-api</artifactId> <dependencies> + <!-- http��������������������� --> + <dependency> + <groupId>org.apache.httpcomponents</groupId> + <artifactId>httpclient</artifactId> + <version>4.5.2</version> + </dependency> <dependency> <groupId>org.moral</groupId> <artifactId>screen-common</artifactId> 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..62e2ce0 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,6 @@ } } + + } diff --git a/screen-api/src/main/java/com/moral/api/controller/AppAllocationController.java b/screen-api/src/main/java/com/moral/api/controller/AppAllocationController.java new file mode 100644 index 0000000..02165ba --- /dev/null +++ b/screen-api/src/main/java/com/moral/api/controller/AppAllocationController.java @@ -0,0 +1,63 @@ +package com.moral.api.controller; + + +import io.swagger.annotations.Api; +import io.swagger.annotations.ApiOperation; +import io.swagger.annotations.ApiParam; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.util.ObjectUtils; +import org.springframework.web.bind.annotation.GetMapping; +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.RequestParam; +import org.springframework.web.bind.annotation.RestController; + +import java.util.List; + +import javax.validation.Valid; + +import com.moral.api.pojo.query.allocation.AllocationChangeCond; +import com.moral.api.pojo.query.allocation.AllocationCheckCond; +import com.moral.api.pojo.vo.allocation.AllocationFindVo; +import com.moral.api.service.AllocationService; +import com.moral.constant.ResultMessage; + +@Api(tags = {"���������������������"}) +@RestController +@RequestMapping("allocationApp") +public class AppAllocationController { + + + + @Autowired + private AllocationService allocationService; + + + + @GetMapping("select") + @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/AppUserController.java b/screen-api/src/main/java/com/moral/api/controller/AppUserController.java new file mode 100644 index 0000000..ffe52c1 --- /dev/null +++ b/screen-api/src/main/java/com/moral/api/controller/AppUserController.java @@ -0,0 +1,64 @@ +package com.moral.api.controller; + + +import io.swagger.annotations.Api; +import io.swagger.annotations.ApiOperation; +import io.swagger.annotations.ApiParam; +import lombok.extern.slf4j.Slf4j; +import org.apache.commons.codec.digest.DigestUtils; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.web.bind.annotation.GetMapping; +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.RequestParam; +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("/AppUser") +public class AppUserController { + + @Autowired + private UserService userService; + + @ApiOperation(value = "������������") + @PostMapping("logins") + 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); + } + + + @GetMapping("/wx/login") + @ApiOperation(value = "���������������") + public ResultMessage userLogin(@RequestParam(value = "code") String code + ) { + Map<String, Object> result = userService.wxLogin(code); + return ResultMessage.ok(result); + } + + @GetMapping("/wx/exit") + @ApiOperation(value = "���������������") + public ResultMessage updateUserId(@RequestParam @ApiParam(value = "userId",name = "������������") Integer userId) { + userService.updateUserId(userId); + return ResultMessage.ok(); + } + +} diff --git a/screen-api/src/main/java/com/moral/api/entity/AppUser.java b/screen-api/src/main/java/com/moral/api/entity/AppUser.java new file mode 100644 index 0000000..b29a3b6 --- /dev/null +++ b/screen-api/src/main/java/com/moral/api/entity/AppUser.java @@ -0,0 +1,18 @@ +package com.moral.api.entity; + + +import lombok.Data; + +import com.baomidou.mybatisplus.extension.activerecord.Model; + +@Data +public class AppUser extends Model<AppUser> { + + private Integer openId; + + private String account; + + private String nickName; + + private String avatarUrl; +} diff --git a/screen-api/src/main/java/com/moral/api/entity/User.java b/screen-api/src/main/java/com/moral/api/entity/User.java index 0ae2a49..beba49b 100644 --- a/screen-api/src/main/java/com/moral/api/entity/User.java +++ b/screen-api/src/main/java/com/moral/api/entity/User.java @@ -104,6 +104,9 @@ */ private String isDelete; + + private String openId; + @TableField(exist = false) private Integer unitCode; diff --git a/screen-api/src/main/java/com/moral/api/exception/consumer/SecondDataConsumer.java b/screen-api/src/main/java/com/moral/api/exception/consumer/SecondDataConsumer.java index 3a3ed65..94fd662 100644 --- a/screen-api/src/main/java/com/moral/api/exception/consumer/SecondDataConsumer.java +++ b/screen-api/src/main/java/com/moral/api/exception/consumer/SecondDataConsumer.java @@ -37,6 +37,7 @@ +/*@Component*/ /*@Component*/ @Slf4j 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..93544d2 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); + + + } diff --git a/screen-api/src/main/java/com/moral/api/mapper/AppUserMapper.java b/screen-api/src/main/java/com/moral/api/mapper/AppUserMapper.java new file mode 100644 index 0000000..29a68fb --- /dev/null +++ b/screen-api/src/main/java/com/moral/api/mapper/AppUserMapper.java @@ -0,0 +1,8 @@ +package com.moral.api.mapper; + +import com.baomidou.mybatisplus.core.mapper.BaseMapper; +import com.moral.api.entity.AppUser; + + +public interface AppUserMapper extends BaseMapper<AppUser> { +} diff --git a/screen-api/src/main/java/com/moral/api/pojo/enums/AppAllocationStateEnum.java b/screen-api/src/main/java/com/moral/api/pojo/enums/AppAllocationStateEnum.java new file mode 100644 index 0000000..90d749f --- /dev/null +++ b/screen-api/src/main/java/com/moral/api/pojo/enums/AppAllocationStateEnum.java @@ -0,0 +1,59 @@ +package com.moral.api.pojo.enums; + + +import lombok.Getter; + +import java.util.HashMap; +import java.util.Map; + +import com.baomidou.mybatisplus.annotation.EnumValue; +import com.fasterxml.jackson.annotation.JsonCreator; +import com.fasterxml.jackson.annotation.JsonFormat; +import com.moral.api.exception.BusinessException; + +@Getter +@JsonFormat(shape = JsonFormat.Shape.OBJECT) +public enum AppAllocationStateEnum implements IntegerValueEnum { + /** + *��������� + */ + TO_BE_PROCESSED(20, "���������"), + /** + *��������� + */ + TO_BE_COMPLETED(30, "���������"), + /** + * 40���50 ��������������� + */ + COMPLETED(40, "���������"), + + + ; + + @EnumValue + public final Integer value; + public final String name; + + AppAllocationStateEnum(Integer value, String name) { + this.value = value; + this.name = name; + } + + private static Map<Integer, AllocationExtensionApproveEnum> valueMap = new HashMap<>(); + static { + for (AllocationExtensionApproveEnum v : AllocationExtensionApproveEnum.values()) { + valueMap.put(v.value, v); + } + } + @JsonCreator + public static AllocationExtensionApproveEnum getByValue(Integer value) { + if (value == null) { + return null; + } + AllocationExtensionApproveEnum result = valueMap.get(value); + if (result == null) { + throw new BusinessException("������������������" + value); + } + return result; + } +} diff --git a/screen-api/src/main/java/com/moral/api/pojo/query/AppUserCond.java b/screen-api/src/main/java/com/moral/api/pojo/query/AppUserCond.java new file mode 100644 index 0000000..4e8301b --- /dev/null +++ b/screen-api/src/main/java/com/moral/api/pojo/query/AppUserCond.java @@ -0,0 +1,31 @@ +package com.moral.api.pojo.query; + + +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 javax.validation.constraints.NotNull; + +@Data +@EqualsAndHashCode(callSuper = false) +@Accessors(chain = true) +@ApiModel(value="AppUserCond - ���������������������", description="AppUserCond - ���������������������") +public class AppUserCond implements Serializable { + + @ApiModelProperty(value = "������������������code") + @NotNull(message = "code���������������") + private Integer code; + + + @ApiModelProperty(value = "���������") + private String account; + + + @ApiModelProperty(value = "������") + private String password; +} 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..7e443a3 --- /dev/null +++ b/screen-api/src/main/java/com/moral/api/pojo/vo/allocation/AllocationFindVo.java @@ -0,0 +1,79 @@ +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; + + @ApiModelProperty(value = "������������") + private String stateName; + + 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..9a27915 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 @@ -9,6 +9,7 @@ import com.baomidou.mybatisplus.extension.service.IService; import com.moral.api.pojo.bo.UserBO; +import com.moral.api.pojo.query.AppUserCond; /** * <p> @@ -44,4 +45,12 @@ //������������������������������������ UserBO selectUserInfo(Map<String, Object> parameters); + //��������������������������� + Map<String, Object> loginSmallRoutine(Map<String, Object> parameters); + + //��������������������� + Map<String, Object> wxLogin(String code); + + boolean updateUserId(Integer userId); + } 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..7c8898d 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,146 @@ } @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); + wrapper.orderByDesc(Allocation::getEscalationTime); + List<Allocation> allocations = allocationMapper.selectList(wrapper); + for (Allocation allocation : allocations) { + AllocationFindVo allocationFindVo = new AllocationFindVo(); + BeanUtils.copyProperties(allocation,allocationFindVo); + Integer state1 = allocationFindVo.getState(); + if (integer==0 || integer==1){ + if (state1==20){ + allocationFindVo.setStateName(AppAllocationStateEnum.TO_BE_PROCESSED.name); + }else if (state1==30){ + allocationFindVo.setStateName(AppAllocationStateEnum.TO_BE_PROCESSED.name); + }else if (state1==40 ||state1==50){ + allocationFindVo.setStateName(AppAllocationStateEnum.COMPLETED.name); + } + }else { + if (state1==20){ + allocationFindVo.setStateName(AppAllocationStateEnum.TO_BE_PROCESSED.name); + }else if (state1==30){ + allocationFindVo.setStateName(AppAllocationStateEnum.TO_BE_PROCESSED.name); + }else if (state1==40||state1==50){ + allocationFindVo.setStateName(AppAllocationStateEnum.COMPLETED.name); + } + } + allocationFindVos.add(allocationFindVo); + } + return allocationFindVos; + } + + /** + * ��������������� + * + * @param changeCond + */ + @Override + @Transactional + public void changeSmallRoutine(AllocationChangeCond changeCond) { + Integer integer = unitAreaCode(); + if (integer==2){ + 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/FileTableServiceImpl.java b/screen-api/src/main/java/com/moral/api/service/impl/FileTableServiceImpl.java index 583f4d3..b8fc305 100644 --- a/screen-api/src/main/java/com/moral/api/service/impl/FileTableServiceImpl.java +++ b/screen-api/src/main/java/com/moral/api/service/impl/FileTableServiceImpl.java @@ -21,6 +21,7 @@ import org.springframework.beans.factory.annotation.Value; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; +import org.springframework.util.ObjectUtils; import org.springframework.web.multipart.MultipartFile; import javax.servlet.http.HttpServletRequest; 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..e6b33b5 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 @@ -1,11 +1,14 @@ package com.moral.api.service.impl; +import com.moral.api.utils.StringUtils; import lombok.extern.slf4j.Slf4j; +import org.apache.commons.codec.digest.DigestUtils; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Value; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; import org.springframework.util.ObjectUtils; +import org.springframework.web.client.RestTemplate; import org.springframework.web.context.request.RequestContextHolder; import org.springframework.web.context.request.ServletRequestAttributes; @@ -23,8 +26,10 @@ import com.alibaba.fastjson.JSON; import com.alibaba.fastjson.JSONObject; +import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper; +import com.baomidou.mybatisplus.core.toolkit.Wrappers; import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; import com.moral.api.entity.Group; @@ -34,6 +39,7 @@ import com.moral.api.entity.User; import com.moral.api.entity.UserGroup; import com.moral.api.entity.UserLog; +import com.moral.api.exception.BusinessException; import com.moral.api.mapper.MenuMapper; import com.moral.api.mapper.ResponsibilityUnitMapper; import com.moral.api.mapper.UserGroupMapper; @@ -42,9 +48,12 @@ import com.moral.api.pojo.bo.UserBO; import com.moral.api.service.ResponsibilityUnitService; import com.moral.api.service.UserService; +import com.moral.api.utils.HttpClientUtil; import com.moral.api.utils.OperationLogUtils; +import com.moral.api.utils.WechatUtils; import com.moral.constant.Constants; import com.moral.constant.ResponseCodeEnum; +import com.moral.constant.ResultMessage; import com.moral.util.AESUtils; import com.moral.util.ConvertUtils; import com.moral.util.DateUtils; @@ -52,6 +61,7 @@ import com.moral.util.RegexUtils; import com.moral.util.TokenUtils; import com.moral.util.WebUtils; +import com.sun.org.apache.regexp.internal.RE; /** * <p> @@ -80,6 +90,9 @@ @Autowired private OperationLogUtils operationLogUtils; + @Autowired + private ResponsibilityUnitMapper responsibilityUnitMapper; + @Value("${AES.KEY}") private String AESKey; @@ -87,6 +100,156 @@ @Override public UserBO selectUserInfo(Map<String, Object> parameters) { return userMapper.selectUserInfo(parameters); + } + + /** + * ��������������� + * @param parameters + * @return + */ + @Override + @Transactional + public Map<String, Object> loginSmallRoutine(Map<String, Object> parameters) { + UserBO userBo = selectUserInfo(parameters); + String openId = parameters.get("openId").toString(); + 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; + } + //������������������ + if (Constants.DELETE.equals(userBo.getIsDelete())) { + result.put("code", ResponseCodeEnum.ACCOUNT_IS_DELETE.getCode()); + result.put("msg", ResponseCodeEnum.ACCOUNT_IS_DELETE.getMsg()); + return result; + } + ResponsibilityUnit responsibilityUnit = responsibilityUnitMapper.selectById(userBo.getUnitId()); + //������������������ + 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("unName",responsibilityUnit.getAreaName()); + userInfo.put("wechat", userBo.getWechat()); + userInfo.put("expireTime", DateUtils.dateToDateString(userBo.getExpireTime())); + userInfo.put("isAdmin", userBo.getIsAdmin()); + userInfo.put("openid", openId); + + try { + //������token������������redis + String token = TokenUtils.getTokenApp(new StringBuffer("00").append(userBo.getId().toString()).toString(),userInfo); + result.put("token", token); + result.put("userName", userBo.getUserName()); + result.put("unitId",userBo.getUnitId()); + result.put("userId", userBo.getId()); + result.put("account", userBo.getAccount()); + result.put("unName",Objects.nonNull(responsibilityUnit.getAreaName())?responsibilityUnit.getAreaName():"���������������������"); + } 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; + } + sysLog("������������������" + userBo.getAccount()+";openId:"+openId,userBo); + //������openId���user������ + User user = userMapper.selectById(userBo.getId()); + user.setOpenId(openId); + userMapper.updateById(user); + return result; + } + + @Override + public Map<String, Object> wxLogin(String code) { + Map<String, Object> result = new HashMap<>(); + // ������������������������rawData + // ���������signature +// JSONObject rawDataJson = JSON.parseObject(rawData); + // 1.������������������������code + // 2.������������������ ������������������������ appi + appsecret + code + JSONObject SessionKeyOpenId = WechatUtils.getSessionKeyOrOpenId(code); + + // 3.������������������������ ��������������������� + String openid = SessionKeyOpenId.getString("openid"); + String sessionKey = SessionKeyOpenId.getString("session_key"); + + // 4.������������ ������������������������signature������������������������������signature2 = sha1(rawData + sessionKey) +// String signature2 = DigestUtils.sha1Hex(rawData + sessionKey); +// if (!signature.equals(signature2)) { +// return ResultMessage.ok().message("������������������"); +// return ResultMessage.ok("������������������"); +// throw new BusinessException("������������������"); +// } + // 5.���������������User������������������������������������������������������������������������������������������ + LambdaQueryWrapper<User> lqw = Wrappers.lambdaQuery(); + lqw.eq(User::getOpenId, openid); + User user = userMapper.selectOne(lqw); + if (user == null) { + result.put("code", ResponseCodeEnum.USER_NOT_EXIST.getCode()); + result.put("msg", ResponseCodeEnum.USER_NOT_EXIST.getMsg()); + result.put("openId",openid); + return result; + // ������������������ +// String nickName = rawDataJson.getString("nickName"); +// String avatarUrl = rawDataJson.getString("avatarUrl"); + } + + Map<String, Object> userInfo = new LinkedHashMap<>(); + userInfo.put("userId", user.getId()); + userInfo.put("account", user.getAccount()); + userInfo.put("userName", user.getUserName()); + userInfo.put("email", user.getEmail()); + userInfo.put("mobile", user.getMobile()); + userInfo.put("unitId",user.getUnitId()); +// userInfo.put("unName",user.getAreaName()); + userInfo.put("wechat", user.getWechat()); + userInfo.put("expireTime", DateUtils.dateToDateString(user.getExpireTime())); + userInfo.put("isAdmin", user.getIsAdmin()); + ResponsibilityUnit responsibilityUnit = responsibilityUnitMapper.selectById(user.getUnitId()); + try { + //������token������������redis + String token = TokenUtils.getTokenApp(new StringBuffer("00").append(user.getId().toString()).toString(),userInfo); + result.put("token", token); + result.put("token", token); + result.put("userName", user.getUserName()); + result.put("unitId",user.getUnitId()); + result.put("userId", user.getId()); + result.put("account", user.getAccount()); + result.put("unName",Objects.nonNull(responsibilityUnit.getAreaName())?responsibilityUnit.getAreaName():"���������������������"); + } 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; + } + result.put("code", ResponseCodeEnum.SUCCESS.getCode()); + result.put("msg", ResponseCodeEnum.SUCCESS.getMsg()); + sysLog("������������������" + user.getAccount()+" ;openId:"+openid,user); + return result; + } + + @Override + public boolean updateUserId(Integer userId) { + User user = userMapper.selectById(userId); + user.setOpenId("0"); + userMapper.updateById(user); + sysLog(userId+"������������������",user); + return true; + } + private void sysLog(String cont,User user){ + //������ + HttpServletRequest request = ((ServletRequestAttributes) Objects.requireNonNull(RequestContextHolder.getRequestAttributes())).getRequest(); + UserLog userLog = new UserLog(); + userLog.setType(Constants.LOGIN_OPERTATE_APP); + userLog.setIp(WebUtils.getIpAddr(request)); + userLog.setOperateId(user.getId()); + userLog.setOrganizationId(user.getOrganizationId()); + userLog.setContent(cont); + userLogMapper.insert(userLog); } @Override @@ -120,9 +283,10 @@ result.put("msg", ResponseCodeEnum.ACCOUNT_IS_EXPIRE.getMsg()); return result; } + //������������������ Map<String, Object> userInfo = new LinkedHashMap<>(); - + ResponsibilityUnit responsibilityUnit = responsibilityUnitMapper.selectById(userBo.getUnitId()); //������������ userInfo.put("userId", userBo.getId()); userInfo.put("account", userBo.getAccount()); @@ -130,6 +294,7 @@ userInfo.put("email", userBo.getEmail()); userInfo.put("mobile", userBo.getMobile()); userInfo.put("unitId",userBo.getUnitId()); + userInfo.put("unName",responsibilityUnit.getAreaName()); userInfo.put("wechat", userBo.getWechat()); userInfo.put("expireTime", DateUtils.dateToDateString(userBo.getExpireTime())); userInfo.put("isAdmin", userBo.getIsAdmin()); diff --git a/screen-api/src/main/java/com/moral/api/utils/HttpClientUtil.java b/screen-api/src/main/java/com/moral/api/utils/HttpClientUtil.java new file mode 100644 index 0000000..39afb30 --- /dev/null +++ b/screen-api/src/main/java/com/moral/api/utils/HttpClientUtil.java @@ -0,0 +1,136 @@ +package com.moral.api.utils; + +import org.apache.http.NameValuePair; +import org.apache.http.client.entity.UrlEncodedFormEntity; +import org.apache.http.client.methods.CloseableHttpResponse; +import org.apache.http.client.methods.HttpGet; +import org.apache.http.client.methods.HttpPost; +import org.apache.http.client.utils.URIBuilder; +import org.apache.http.entity.ContentType; +import org.apache.http.entity.StringEntity; +import org.apache.http.impl.client.CloseableHttpClient; +import org.apache.http.impl.client.HttpClients; +import org.apache.http.message.BasicNameValuePair; +import org.apache.http.util.EntityUtils; + +import java.io.IOException; +import java.net.URI; +import java.util.ArrayList; + +import java.util.List; +import java.util.Map; + +public class HttpClientUtil { + + + + public static String doGet(String url, Map<String, String> param) { + + // ������Httpclient������ + CloseableHttpClient httpclient = HttpClients.createDefault(); + + String resultString = ""; + CloseableHttpResponse response = null; + try { + // ������uri + URIBuilder builder = new URIBuilder(url); + if (param != null) { + for (String key : param.keySet()) { + builder.addParameter(key, param.get(key)); + } + } + URI uri = builder.build(); + + // ������http GET������ + HttpGet httpGet = new HttpGet(uri); + + // ������������ + response = httpclient.execute(httpGet); + // ���������������������������200 + if (response.getStatusLine().getStatusCode() == 200) { + resultString = EntityUtils.toString(response.getEntity(), "UTF-8"); + } + } catch (Exception e) { + e.printStackTrace(); + } finally { + try { + if (response != null) { + response.close(); + } + httpclient.close(); + } catch (IOException e) { + e.printStackTrace(); + } + } + return resultString; + } + + public static String doGet(String url) { + return doGet(url, null); + } + + public static String doPost(String url, Map<String, String> param) { + // ������Httpclient������ + CloseableHttpClient httpClient = HttpClients.createDefault(); + CloseableHttpResponse response = null; + String resultString = ""; + try { + // ������Http Post������ + HttpPost httpPost = new HttpPost(url); + // ������������������ + if (param != null) { + List<NameValuePair> paramList = new ArrayList<>(); + for (String key : param.keySet()) { + paramList.add(new BasicNameValuePair(key, param.get(key))); + } + // ������������ + UrlEncodedFormEntity entity = new UrlEncodedFormEntity(paramList); + httpPost.setEntity(entity); + } + // ������http������ + response = httpClient.execute(httpPost); + resultString = EntityUtils.toString(response.getEntity(), "utf-8"); + } catch (Exception e) { + e.printStackTrace(); + } finally { + try { + response.close(); + } catch (IOException e) { + e.printStackTrace(); + } + } + + return resultString; + } + + public static String doPost(String url) { + return doPost(url, null); + } + + public static String doPostJson(String url, String json) { + // ������Httpclient������ + CloseableHttpClient httpClient = HttpClients.createDefault(); + CloseableHttpResponse response = null; + String resultString = ""; + try { + // ������Http Post������ + HttpPost httpPost = new HttpPost(url); + // ������������������ + StringEntity entity = new StringEntity(json, ContentType.APPLICATION_JSON); + httpPost.setEntity(entity); + // ������http������ + response = httpClient.execute(httpPost); + resultString = EntityUtils.toString(response.getEntity(), "utf-8"); + } catch (Exception e) { + e.printStackTrace(); + } finally { + try { + response.close(); + } catch (IOException e) { + e.printStackTrace(); + } + } + + return resultString; + } +} diff --git a/screen-api/src/main/java/com/moral/api/utils/WechatUtils.java b/screen-api/src/main/java/com/moral/api/utils/WechatUtils.java new file mode 100644 index 0000000..de7e889 --- /dev/null +++ b/screen-api/src/main/java/com/moral/api/utils/WechatUtils.java @@ -0,0 +1,49 @@ +package com.moral.api.utils; + + + + +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.context.annotation.Configuration; +import org.springframework.data.redis.core.RedisTemplate; +import org.springframework.http.HttpEntity; +import org.springframework.http.HttpHeaders; +import org.springframework.http.HttpMethod; +import org.springframework.http.ResponseEntity; +import org.springframework.stereotype.Component; +import org.springframework.stereotype.Service; +import org.springframework.web.client.RestClientException; +import org.springframework.web.client.RestTemplate; + +import java.util.HashMap; +import java.util.Map; + +import com.alibaba.fastjson.JSON; +import com.alibaba.fastjson.JSONObject; +import com.moral.api.service.UserLogService; + +public class WechatUtils { + + + public static final String APPID = "wx41f4c3c007545088"; + public static final String SECRET = "9e1a328ad525dd169252a1cc5067a6f3"; + + public static JSONObject getSessionKeyOrOpenId(String code) { + + String requestUrl = "https://api.weixin.qq.com/sns/jscode2session"; + Map<String, String> requestUrlParam = new HashMap<>(); + // https://mp.weixin.qq.com/wxopen/devprofile?action=get_profile&token=164113089&lang=zh_CN + //���������appId + requestUrlParam.put("appid", APPID); + //���������secret + requestUrlParam.put("secret",SECRET); + //���������������������code + requestUrlParam.put("js_code", code); + //������������ + requestUrlParam.put("grant_type", "authorization_code"); + //������post������������������������������������openid������������������ + JSONObject jsonObject = JSON.parseObject(HttpClientUtil.doPost(requestUrl, requestUrlParam)); + + return jsonObject; + } +} diff --git a/screen-api/src/main/resources/application-cjl.yml b/screen-api/src/main/resources/application-cjl.yml index e2ff30e..67ded93 100644 --- a/screen-api/src/main/resources/application-cjl.yml +++ b/screen-api/src/main/resources/application-cjl.yml @@ -119,6 +119,7 @@ interceptor: exclude: - /login + - /AppUser/** - /swagger-ui.html - /swagger-resources/** - /swagger-ui.html/** diff --git a/screen-api/src/main/resources/application-dev.yml b/screen-api/src/main/resources/application-dev.yml index 78c754e..4e093b1 100644 --- a/screen-api/src/main/resources/application-dev.yml +++ b/screen-api/src/main/resources/application-dev.yml @@ -111,6 +111,7 @@ interceptor: exclude: - /login + - /AppUser/** - /swagger-ui.html - /swagger-resources/** - /swagger-ui.html/** diff --git a/screen-api/src/main/resources/application-local.yml b/screen-api/src/main/resources/application-local.yml index fb92f00..f75bd80 100644 --- a/screen-api/src/main/resources/application-local.yml +++ b/screen-api/src/main/resources/application-local.yml @@ -118,6 +118,7 @@ interceptor: exclude: - /login + - /AppUser/** - /swagger-ui.html - /swagger-resources/** - /swagger-ui.html/** diff --git a/screen-api/src/main/resources/application-qa.yml b/screen-api/src/main/resources/application-qa.yml index f006132..f9dde1a 100644 --- a/screen-api/src/main/resources/application-qa.yml +++ b/screen-api/src/main/resources/application-qa.yml @@ -122,6 +122,7 @@ interceptor: exclude: - /login + - /AppUser/** - /swagger-ui.html - /swagger-resources/** - /swagger-ui.html/** diff --git a/screen-api/src/main/resources/mapper/AllocationMapper.xml b/screen-api/src/main/resources/mapper/AllocationMapper.xml index 7562062..4b9159b 100644 --- a/screen-api/src/main/resources/mapper/AllocationMapper.xml +++ b/screen-api/src/main/resources/mapper/AllocationMapper.xml @@ -59,6 +59,7 @@ </where> </select> + <select id="extPage" resultType="com.moral.api.pojo.ext.allocation.AllocationPageExt"> SELECT <include refid="Allocation_Column_List"/>,t1.id as applyState diff --git a/screen-common/src/main/java/com/moral/constant/Constants.java b/screen-common/src/main/java/com/moral/constant/Constants.java index ad910db..a49dc6a 100644 --- a/screen-common/src/main/java/com/moral/constant/Constants.java +++ b/screen-common/src/main/java/com/moral/constant/Constants.java @@ -65,11 +65,16 @@ public static final String WEB_CHANNEL = "0"; /* - * ������������������ + * ������������������ web * */ public static final String LOGIN_OPERTATE_TYPE = "0"; /* + * ������������������ app + * */ + public static final String LOGIN_OPERTATE_APP = "1"; + + /* * ������������������ * */ public static final String INSERT_OPERATE_TYPE = "1"; diff --git a/screen-common/src/main/java/com/moral/util/TokenUtils.java b/screen-common/src/main/java/com/moral/util/TokenUtils.java index d82f09e..e8ae947 100644 --- a/screen-common/src/main/java/com/moral/util/TokenUtils.java +++ b/screen-common/src/main/java/com/moral/util/TokenUtils.java @@ -76,6 +76,27 @@ ResponseCodeEnum.TOKEN_CREATE_ERROR.getMsg()); } } + public static String getTokenApp(String uid, Object userInfo) { + //������������token + try { + //������token + String token = TokenEncryptUtils.encoded(uid + "/" + System.currentTimeMillis() / 1000); + //������������token + String oldToken = (String) redisTemplate.opsForHash().get("user_token", uid); + if (oldToken != null) + redisTemplate.delete(oldToken); + //���token���������value��� + redisTemplate.opsForValue().set(token, userInfo); + //redisTemplate.expire(token, validity_time, TimeUnit.SECONDS); + //���token���������Hash��� + redisTemplate.opsForHash().put("user_token", uid, token); + return token; + } catch (Exception e) { + log.error("token���������������" + e.getMessage()); + throw new TokenException(ResponseCodeEnum.TOKEN_CREATE_ERROR.getCode(), + ResponseCodeEnum.TOKEN_CREATE_ERROR.getMsg()); + } + } /** -- Gitblit v1.8.0