Przeglądaj źródła

Merge remote-tracking branch 'origin/2021-04-21_music_replace' into 2021-04-21_music_replace

# Conflicts:
#	mec-web/src/main/java/com/ym/mec/web/controller/ReplacementInstrumentActivityController.java
Joburgess 4 lat temu
rodzic
commit
e8786ed232

+ 3 - 0
mec-biz/src/main/java/com/ym/mec/biz/dal/dao/ReplacementInstrumentActivityDao.java

@@ -15,9 +15,12 @@ public interface ReplacementInstrumentActivityDao extends BaseDAO<Integer, Repla
     ReplacementInstrumentActivity findByUserId(Integer userId);
     ReplacementInstrumentActivity findByUserId(Integer userId);
 
 
     List<ReplacementInstrumentActivityStatDto> queryReplacements(Map<String, Object> params);
     List<ReplacementInstrumentActivityStatDto> queryReplacements(Map<String, Object> params);
+
     int countReplacements(Map<String, Object> params);
     int countReplacements(Map<String, Object> params);
 
 
     ReplacementInstrumentActivityStatHead countReplacementsInfo(Integer cooperationOrganId);
     ReplacementInstrumentActivityStatHead countReplacementsInfo(Integer cooperationOrganId);
 
 
     int openPay(@Param("cooperationOrganId") Integer cooperationOrganId);
     int openPay(@Param("cooperationOrganId") Integer cooperationOrganId);
+
+    ReplacementInstrumentActivity getLock(@Param("id") Integer id);
 }
 }

+ 20 - 0
mec-biz/src/main/java/com/ym/mec/biz/dal/page/ReplacementInstrumentQueryInfo.java

@@ -7,6 +7,10 @@ public class ReplacementInstrumentQueryInfo extends QueryInfo {
 
 
     private Integer subjectId;
     private Integer subjectId;
 
 
+    private String brand;
+
+    private String specification;
+
     public Integer getSubjectId() {
     public Integer getSubjectId() {
         return subjectId;
         return subjectId;
     }
     }
@@ -14,4 +18,20 @@ public class ReplacementInstrumentQueryInfo extends QueryInfo {
     public void setSubjectId(Integer subjectId) {
     public void setSubjectId(Integer subjectId) {
         this.subjectId = subjectId;
         this.subjectId = subjectId;
     }
     }
+
+    public String getBrand() {
+        return brand;
+    }
+
+    public void setBrand(String brand) {
+        this.brand = brand;
+    }
+
+    public String getSpecification() {
+        return specification;
+    }
+
+    public void setSpecification(String specification) {
+        this.specification = specification;
+    }
 }
 }

+ 19 - 3
mec-biz/src/main/java/com/ym/mec/biz/service/impl/ReplacementInstrumentActivityServiceImpl.java

@@ -22,11 +22,14 @@ import com.ym.mec.common.service.impl.BaseServiceImpl;
 import com.ym.mec.thirdparty.message.MessageSenderPluginContext;
 import com.ym.mec.thirdparty.message.MessageSenderPluginContext;
 import com.ym.mec.util.collection.MapUtil;
 import com.ym.mec.util.collection.MapUtil;
 import com.ym.mec.util.date.DateUtil;
 import com.ym.mec.util.date.DateUtil;
+
 import org.apache.poi.ss.formula.functions.T;
 import org.apache.poi.ss.formula.functions.T;
 import org.slf4j.Logger;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 import org.slf4j.LoggerFactory;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.beans.factory.annotation.Autowired;
+
 import com.ym.mec.biz.dal.dao.ReplacementInstrumentActivityDao;
 import com.ym.mec.biz.dal.dao.ReplacementInstrumentActivityDao;
+
 import org.springframework.stereotype.Service;
 import org.springframework.stereotype.Service;
 import org.springframework.transaction.annotation.Transactional;
 import org.springframework.transaction.annotation.Transactional;
 import org.springframework.util.CollectionUtils;
 import org.springframework.util.CollectionUtils;
@@ -63,6 +66,9 @@ public class ReplacementInstrumentActivityServiceImpl extends BaseServiceImpl<In
     private SysUserCashAccountDetailService sysUserCashAccountDetailService;
     private SysUserCashAccountDetailService sysUserCashAccountDetailService;
     @Autowired
     @Autowired
     private SysMessageService sysMessageService;
     private SysMessageService sysMessageService;
+    
+    @Autowired
+    private CooperationOrganService cooperationOrganService;
 
 
     private final Logger logger = LoggerFactory.getLogger(this.getClass());
     private final Logger logger = LoggerFactory.getLogger(this.getClass());
 
 
@@ -80,6 +86,14 @@ public class ReplacementInstrumentActivityServiceImpl extends BaseServiceImpl<In
         }
         }
         replacementInstrumentActivity.setUserId(sysUser.getId());
         replacementInstrumentActivity.setUserId(sysUser.getId());
         //如果用户是43分部,那么修改用户信息
         //如果用户是43分部,那么修改用户信息
+        if(sysUser.getOrganId() == 43){
+        	CooperationOrgan cooperationOrgan = cooperationOrganService.get(replacementInstrumentActivity.getCooperationOrganId());
+            if (cooperationOrgan != null) {
+            	sysUser.setOrganId(cooperationOrgan.getOrganId());
+            	sysUser.setUpdateTime(new Date());
+            	sysUserFeignService.updateSysUser(sysUser);
+            }
+        }
         //如果提交过调查问卷,那么覆盖之前的记录
         //如果提交过调查问卷,那么覆盖之前的记录
         ReplacementInstrumentActivity activity = replacementInstrumentActivityDao.findByUserId(sysUser.getId());
         ReplacementInstrumentActivity activity = replacementInstrumentActivityDao.findByUserId(sysUser.getId());
         if (activity != null) {
         if (activity != null) {
@@ -128,7 +142,7 @@ public class ReplacementInstrumentActivityServiceImpl extends BaseServiceImpl<In
 
 
     @Override
     @Override
     public Map pay(ReplacementPayDto replacementPayDto) throws Exception {
     public Map pay(ReplacementPayDto replacementPayDto) throws Exception {
-        ReplacementInstrumentActivity replacementInstrumentActivity = replacementInstrumentActivityDao.get(replacementPayDto.getId());
+        ReplacementInstrumentActivity replacementInstrumentActivity = replacementInstrumentActivityDao.getLock(replacementPayDto.getId());
         if (replacementInstrumentActivity == null) {
         if (replacementInstrumentActivity == null) {
             throw new BizException("乐器置换不存在,请核查");
             throw new BizException("乐器置换不存在,请核查");
         }
         }
@@ -182,7 +196,9 @@ public class ReplacementInstrumentActivityServiceImpl extends BaseServiceImpl<In
         studentPaymentOrder.setUpdateTime(nowDate);
         studentPaymentOrder.setUpdateTime(nowDate);
         studentPaymentOrderService.insert(studentPaymentOrder);
         studentPaymentOrderService.insert(studentPaymentOrder);
         //修改支付状态
         //修改支付状态
-
+        replacementInstrumentActivity.setPayStatus(1);
+        replacementInstrumentActivity.setUpdateTime(nowDate);
+        replacementInstrumentActivityDao.update(replacementInstrumentActivity);
 
 
         studentPaymentOrder.setVersion(0);
         studentPaymentOrder.setVersion(0);
         if (amount.compareTo(BigDecimal.ZERO) == 0) {
         if (amount.compareTo(BigDecimal.ZERO) == 0) {
@@ -232,7 +248,7 @@ public class ReplacementInstrumentActivityServiceImpl extends BaseServiceImpl<In
             throw new BizException("订单更新失败");
             throw new BizException("订单更新失败");
         }
         }
         //更新维修单信息
         //更新维修单信息
-        ReplacementInstrumentActivity replacementInstrumentActivity = get(Integer.parseInt(studentPaymentOrder.getMusicGroupId()));
+        ReplacementInstrumentActivity replacementInstrumentActivity = replacementInstrumentActivityDao.getLock(Integer.parseInt(studentPaymentOrder.getMusicGroupId()));
         if (replacementInstrumentActivity == null) {
         if (replacementInstrumentActivity == null) {
             throw new BizException("置换信息不存在");
             throw new BizException("置换信息不存在");
         }
         }

+ 4 - 0
mec-biz/src/main/resources/config/mybatis/ReplacementInstrumentActivityMapper.xml

@@ -191,4 +191,8 @@
         WHERE cooperation_organ_id_ = #{cooperationOrganId}
         WHERE cooperation_organ_id_ = #{cooperationOrganId}
           AND open_flag_ = 0
           AND open_flag_ = 0
     </update>
     </update>
+
+    <select id="getLock" resultMap="ReplacementInstrumentActivity">
+        SELECT * FROM replacement_instrument_activity WHERE id_ = #{id} FOR UPDATE
+    </select>
 </mapper>
 </mapper>

+ 1 - 1
mec-biz/src/main/resources/config/mybatis/ReplacementInstrumentCooperationMapper.xml

@@ -98,7 +98,7 @@
         SELECT cooperation_organ_id_              cooperationOrganId,
         SELECT cooperation_organ_id_              cooperationOrganId,
                COUNT(*)                           activeNum,
                COUNT(*)                           activeNum,
                SUM(IF(instruments_id_ > 0, 1, 0)) replaceNum,
                SUM(IF(instruments_id_ > 0, 1, 0)) replaceNum,
-               SUM(IF(pay_status_ = 0, 1, 0)) payNum
+               SUM(IF(pay_status_ = 2, 1, 0)) payNum
         FROM replacement_instrument_activity
         FROM replacement_instrument_activity
         GROUP BY cooperation_organ_id_
         GROUP BY cooperation_organ_id_
     </select>
     </select>

+ 7 - 1
mec-biz/src/main/resources/config/mybatis/ReplacementInstrumentMapper.xml

@@ -84,7 +84,13 @@
 	<sql id="queryPageSql">
 	<sql id="queryPageSql">
 		<where>
 		<where>
 			<if test="subjectId != null">
 			<if test="subjectId != null">
-				subject_id_ = #{subjectId}
+				AND subject_id_ = #{subjectId}
+			</if>
+			<if test="brand != null">
+				AND brand_ = #{brand}
+			</if>
+			<if test="specification != null">
+				AND specification_ = #{specification}
 			</if>
 			</if>
 		</where>
 		</where>
 	</sql>
 	</sql>

+ 12 - 6
mec-web/src/main/java/com/ym/mec/web/controller/ReplacementInstrumentActivityController.java

@@ -3,6 +3,7 @@ package com.ym.mec.web.controller;
 import com.ym.mec.auth.api.client.SysUserFeignService;
 import com.ym.mec.auth.api.client.SysUserFeignService;
 import com.ym.mec.auth.api.entity.SysUser;
 import com.ym.mec.auth.api.entity.SysUser;
 import com.ym.mec.biz.dal.dao.EmployeeDao;
 import com.ym.mec.biz.dal.dao.EmployeeDao;
+import com.ym.mec.biz.dal.dao.ReplacementInstrumentActivityDao;
 import com.ym.mec.biz.dal.dto.ReplacementInstrumentActivityStatDto;
 import com.ym.mec.biz.dal.dto.ReplacementInstrumentActivityStatDto;
 import com.ym.mec.biz.dal.entity.Employee;
 import com.ym.mec.biz.dal.entity.Employee;
 import com.ym.mec.biz.dal.entity.ReplacementInstrumentActivity;
 import com.ym.mec.biz.dal.entity.ReplacementInstrumentActivity;
@@ -21,6 +22,7 @@ import org.springframework.web.bind.annotation.RequestMapping;
 import org.springframework.web.bind.annotation.RestController;
 import org.springframework.web.bind.annotation.RestController;
 
 
 import java.util.Arrays;
 import java.util.Arrays;
+import java.util.Date;
 import java.util.List;
 import java.util.List;
 
 
 @RequestMapping("replacementInstrumentActivity")
 @RequestMapping("replacementInstrumentActivity")
@@ -34,10 +36,12 @@ public class ReplacementInstrumentActivityController extends BaseController {
     private SysUserFeignService sysUserFeignService;
     private SysUserFeignService sysUserFeignService;
     @Autowired
     @Autowired
     private EmployeeDao employeeDao;
     private EmployeeDao employeeDao;
+    @Autowired
+    private ReplacementInstrumentActivityDao replacementInstrumentActivityDao;
 
 
     @ApiOperation(value = "分页查询列表")
     @ApiOperation(value = "分页查询列表")
     @GetMapping("/queryPage")
     @GetMapping("/queryPage")
-    @PreAuthorize("@pcs.hasPermissions('managerDownload/queryPage')")
+    @PreAuthorize("@pcs.hasPermissions('replacementInstrumentActivity/queryPage')")
     public Object queryPage(ReplacementInstrumentActivityQueryInfo queryInfo) {
     public Object queryPage(ReplacementInstrumentActivityQueryInfo queryInfo) {
         SysUser sysUser = sysUserFeignService.queryUserInfo();
         SysUser sysUser = sysUserFeignService.queryUserInfo();
         if (sysUser == null) {
         if (sysUser == null) {
@@ -46,11 +50,11 @@ public class ReplacementInstrumentActivityController extends BaseController {
         Employee employee = employeeDao.get(sysUser.getId());
         Employee employee = employeeDao.get(sysUser.getId());
         if (StringUtils.isEmpty(queryInfo.getOrganId())) {
         if (StringUtils.isEmpty(queryInfo.getOrganId())) {
             queryInfo.setOrganId(employee.getOrganIdList());
             queryInfo.setOrganId(employee.getOrganIdList());
-        }else if(StringUtils.isEmpty(employee.getOrganIdList())){
+        } else if (StringUtils.isEmpty(employee.getOrganIdList())) {
             return failed("用户所在分部异常");
             return failed("用户所在分部异常");
-        }else {
+        } else {
             List<String> list = Arrays.asList(employee.getOrganIdList().split(","));
             List<String> list = Arrays.asList(employee.getOrganIdList().split(","));
-            if(!list.containsAll(Arrays.asList(queryInfo.getOrganId().split(",")))){
+            if (!list.containsAll(Arrays.asList(queryInfo.getOrganId().split(",")))) {
                 return failed("非法请求");
                 return failed("非法请求");
             }
             }
         }
         }
@@ -67,10 +71,12 @@ public class ReplacementInstrumentActivityController extends BaseController {
     @GetMapping("/update")
     @GetMapping("/update")
     @PreAuthorize("@pcs.hasPermissions('replacementInstrumentActivity/update')")
     @PreAuthorize("@pcs.hasPermissions('replacementInstrumentActivity/update')")
     public HttpResponseResult<ReplacementInstrumentActivity> update(ReplacementInstrumentActivity replacementInstrumentActivity) {
     public HttpResponseResult<ReplacementInstrumentActivity> update(ReplacementInstrumentActivity replacementInstrumentActivity) {
-        ReplacementInstrumentActivity old = replacementInstrumentActivityService.get(replacementInstrumentActivity.getId());
-        if (old.getInstrumentsId().equals(replacementInstrumentActivity.getInstrumentsId())) {
+        ReplacementInstrumentActivity oldReplacementInstrumentActivity = replacementInstrumentActivityDao.getLock(replacementInstrumentActivity.getId());
+        if (oldReplacementInstrumentActivity.getInstrumentsId().equals(replacementInstrumentActivity.getInstrumentsId())) {
             return succeed();
             return succeed();
         }
         }
+        oldReplacementInstrumentActivity.setInstrumentsId(replacementInstrumentActivity.getInstrumentsId());
+        oldReplacementInstrumentActivity.setUpdateTime(new Date());
         replacementInstrumentActivityService.update(replacementInstrumentActivity);
         replacementInstrumentActivityService.update(replacementInstrumentActivity);
         return succeed(replacementInstrumentActivity);
         return succeed(replacementInstrumentActivity);
     }
     }

+ 18 - 0
mec-web/src/main/java/com/ym/mec/web/controller/ReplacementInstrumentController.java

@@ -1,9 +1,14 @@
 package com.ym.mec.web.controller;
 package com.ym.mec.web.controller;
 
 
+import com.ym.mec.auth.api.client.SysUserFeignService;
+import com.ym.mec.auth.api.entity.SysUser;
+import com.ym.mec.biz.dal.page.ReplacementInstrumentQueryInfo;
 import com.ym.mec.biz.service.ReplacementInstrumentService;
 import com.ym.mec.biz.service.ReplacementInstrumentService;
 import com.ym.mec.common.controller.BaseController;
 import com.ym.mec.common.controller.BaseController;
 import io.swagger.annotations.Api;
 import io.swagger.annotations.Api;
+import io.swagger.annotations.ApiOperation;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.security.access.prepost.PreAuthorize;
 import org.springframework.web.bind.annotation.*;
 import org.springframework.web.bind.annotation.*;
 
 
 @RequestMapping("replacementInstrument")
 @RequestMapping("replacementInstrument")
@@ -13,5 +18,18 @@ public class ReplacementInstrumentController extends BaseController {
 
 
     @Autowired
     @Autowired
     private ReplacementInstrumentService replacementInstrumentService;
     private ReplacementInstrumentService replacementInstrumentService;
+    @Autowired
+    private SysUserFeignService sysUserFeignService;
+
+    @ApiOperation(value = "分页查询列表")
+    @GetMapping("/queryPage")
+    @PreAuthorize("@pcs.hasPermissions('replacementInstrument/queryPage')")
+    public Object queryPage(ReplacementInstrumentQueryInfo queryInfo) {
+        SysUser sysUser = sysUserFeignService.queryUserInfo();
+        if (sysUser == null) {
+            return failed("用户信息获取失败");
+        }
+        return succeed(replacementInstrumentService.queryPage(queryInfo));
+    }
 
 
 }
 }