|  | @@ -4,19 +4,25 @@ import com.ym.mec.auth.api.client.SysUserFeignService;
 | 
	
		
			
				|  |  |  import com.ym.mec.auth.api.entity.SysUser;
 | 
	
		
			
				|  |  |  import com.ym.mec.biz.dal.dao.EmployeeDao;
 | 
	
		
			
				|  |  |  import com.ym.mec.biz.dal.dao.ReplacementInstrumentActivityDao;
 | 
	
		
			
				|  |  | +import com.ym.mec.biz.dal.dao.ReplacementInstrumentDao;
 | 
	
		
			
				|  |  | +import com.ym.mec.biz.dal.dao.SysConfigDao;
 | 
	
		
			
				|  |  |  import com.ym.mec.biz.dal.dto.ReplacementInstrumentActivityStatDto;
 | 
	
		
			
				|  |  |  import com.ym.mec.biz.dal.dto.StudentInstrumentExportDto;
 | 
	
		
			
				|  |  | -import com.ym.mec.biz.dal.entity.Employee;
 | 
	
		
			
				|  |  | -import com.ym.mec.biz.dal.entity.ReplacementInstrumentActivity;
 | 
	
		
			
				|  |  | -import com.ym.mec.biz.dal.entity.StudentRegistration;
 | 
	
		
			
				|  |  | +import com.ym.mec.biz.dal.entity.*;
 | 
	
		
			
				|  |  | +import com.ym.mec.biz.dal.enums.MessageTypeEnum;
 | 
	
		
			
				|  |  | +import com.ym.mec.biz.dal.enums.YesOrNoEnum;
 | 
	
		
			
				|  |  |  import com.ym.mec.biz.dal.page.ReplacementInstrumentActivityQueryInfo;
 | 
	
		
			
				|  |  |  import com.ym.mec.biz.service.ReplacementInstrumentActivityService;
 | 
	
		
			
				|  |  | +import com.ym.mec.biz.service.ReplacementInstrumentCooperationService;
 | 
	
		
			
				|  |  | +import com.ym.mec.biz.service.SysMessageService;
 | 
	
		
			
				|  |  |  import com.ym.mec.common.controller.BaseController;
 | 
	
		
			
				|  |  |  import com.ym.mec.common.entity.HttpResponseResult;
 | 
	
		
			
				|  |  |  import com.ym.mec.common.exception.BizException;
 | 
	
		
			
				|  |  |  import com.ym.mec.common.page.PageInfo;
 | 
	
		
			
				|  |  | +import com.ym.mec.thirdparty.message.MessageSenderPluginContext;
 | 
	
		
			
				|  |  |  import com.ym.mec.util.date.DateUtil;
 | 
	
		
			
				|  |  |  import com.ym.mec.util.excel.POIUtil;
 | 
	
		
			
				|  |  | +import com.ym.mec.util.http.HttpUtil;
 | 
	
		
			
				|  |  |  import io.swagger.annotations.Api;
 | 
	
		
			
				|  |  |  import io.swagger.annotations.ApiOperation;
 | 
	
		
			
				|  |  |  import org.apache.commons.lang3.StringUtils;
 | 
	
	
		
			
				|  | @@ -30,9 +36,7 @@ import org.springframework.web.bind.annotation.RestController;
 | 
	
		
			
				|  |  |  import javax.servlet.http.HttpServletResponse;
 | 
	
		
			
				|  |  |  import java.io.IOException;
 | 
	
		
			
				|  |  |  import java.io.OutputStream;
 | 
	
		
			
				|  |  | -import java.util.Arrays;
 | 
	
		
			
				|  |  | -import java.util.Date;
 | 
	
		
			
				|  |  | -import java.util.List;
 | 
	
		
			
				|  |  | +import java.util.*;
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |  @RequestMapping("replacementInstrumentActivity")
 | 
	
		
			
				|  |  |  @Api(tags = "乐器置换-调查问卷服务")
 | 
	
	
		
			
				|  | @@ -47,6 +51,14 @@ public class ReplacementInstrumentActivityController extends BaseController {
 | 
	
		
			
				|  |  |      private EmployeeDao employeeDao;
 | 
	
		
			
				|  |  |      @Autowired
 | 
	
		
			
				|  |  |      private ReplacementInstrumentActivityDao replacementInstrumentActivityDao;
 | 
	
		
			
				|  |  | +    @Autowired
 | 
	
		
			
				|  |  | +    private ReplacementInstrumentCooperationService replacementInstrumentCooperationService;
 | 
	
		
			
				|  |  | +    @Autowired
 | 
	
		
			
				|  |  | +    private ReplacementInstrumentDao replacementInstrumentDao;
 | 
	
		
			
				|  |  | +    @Autowired
 | 
	
		
			
				|  |  | +    private SysConfigDao sysConfigDao;
 | 
	
		
			
				|  |  | +    @Autowired
 | 
	
		
			
				|  |  | +    private SysMessageService sysMessageService;
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |      @ApiOperation(value = "分页查询列表")
 | 
	
		
			
				|  |  |      @GetMapping("/queryPage")
 | 
	
	
		
			
				|  | @@ -84,13 +96,29 @@ public class ReplacementInstrumentActivityController extends BaseController {
 | 
	
		
			
				|  |  |          if (!oldReplacementInstrumentActivity.getPayStatus().equals(0)) {
 | 
	
		
			
				|  |  |              return failed("支付中、已支付的乐器置换,不能修改");
 | 
	
		
			
				|  |  |          }
 | 
	
		
			
				|  |  | -        if (oldReplacementInstrumentActivity.getInstrumentsId().equals(replacementInstrumentActivity.getInstrumentsId())) {
 | 
	
		
			
				|  |  | -            return succeed();
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +        ReplacementInstrumentCooperation byCooperationId = replacementInstrumentCooperationService.getByCooperationId(oldReplacementInstrumentActivity.getCooperationOrganId());
 | 
	
		
			
				|  |  | +        if (byCooperationId.getOpenPay().equals(YesOrNoEnum.YES) && oldReplacementInstrumentActivity.getInstrumentsId() == null && replacementInstrumentActivity.getInstrumentsId() != null) {
 | 
	
		
			
				|  |  | +            ReplacementInstrument replacementInstrument = replacementInstrumentDao.get(replacementInstrumentActivity.getInstrumentsId());
 | 
	
		
			
				|  |  | +            Map<Integer, String> userMap = new HashMap<>();
 | 
	
		
			
				|  |  | +            Map<Integer, String> userPhoneMap = new HashMap<>();
 | 
	
		
			
				|  |  | +            Integer userId = oldReplacementInstrumentActivity.getUserId();
 | 
	
		
			
				|  |  | +            String baseApiUrl = sysConfigDao.findConfigValue("base_api_url");
 | 
	
		
			
				|  |  | +            String pushUrl = baseApiUrl + "/#/questionGoodsSale?id=";
 | 
	
		
			
				|  |  | +            userMap.put(userId, userId.toString());
 | 
	
		
			
				|  |  | +            sysMessageService.batchSendMessage(MessageSenderPluginContext.MessageSender.JIGUANG, MessageTypeEnum.REPLACEMENT_PAY_PUSH,
 | 
	
		
			
				|  |  | +                    userMap, null, 0, "5?" + pushUrl + replacementInstrumentActivity.getId(), "STUDENT", replacementInstrument.getBrand(), "");
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +            userPhoneMap.put(userId, oldReplacementInstrumentActivity.getMobileNo());
 | 
	
		
			
				|  |  | +            sysMessageService.batchSendMessage(MessageSenderPluginContext.MessageSender.AWSMS, MessageTypeEnum.REPLACEMENT_PAY_PUSH,
 | 
	
		
			
				|  |  | +                    userPhoneMap, null, 0, null, "STUDENT", replacementInstrument.getBrand(), HttpUtil.getSortUrl(pushUrl + replacementInstrumentActivity.getId()));
 | 
	
		
			
				|  |  |          }
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  |          oldReplacementInstrumentActivity.setSubjectId(replacementInstrumentActivity.getSubjectId());
 | 
	
		
			
				|  |  |          oldReplacementInstrumentActivity.setInstrumentsId(replacementInstrumentActivity.getInstrumentsId());
 | 
	
		
			
				|  |  |          oldReplacementInstrumentActivity.setUpdateTime(new Date());
 | 
	
		
			
				|  |  |          replacementInstrumentActivityService.update(oldReplacementInstrumentActivity);
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  |          return succeed(replacementInstrumentActivity);
 | 
	
		
			
				|  |  |      }
 | 
	
		
			
				|  |  |  
 | 
	
	
		
			
				|  | @@ -123,8 +151,8 @@ public class ReplacementInstrumentActivityController extends BaseController {
 | 
	
		
			
				|  |  |          OutputStream outputStream = response.getOutputStream();
 | 
	
		
			
				|  |  |          HSSFWorkbook workbook = null;
 | 
	
		
			
				|  |  |          try {
 | 
	
		
			
				|  |  | -            String[] header = {"分部","合作单位编号", "合作单位", "学员编号", "学员姓名", "联系电话", "声部", "品牌", "型号"};
 | 
	
		
			
				|  |  | -            String[] body = {"organName","cooperationOrganId", "cooperationOrganName", "userId", "userName", "mobileNo", "subjectName", "brand", "specification"};
 | 
	
		
			
				|  |  | +            String[] header = {"分部", "合作单位编号", "合作单位", "学员编号", "学员姓名", "联系电话", "声部", "品牌", "型号"};
 | 
	
		
			
				|  |  | +            String[] body = {"organName", "cooperationOrganId", "cooperationOrganName", "userId", "userName", "mobileNo", "subjectName", "brand", "specification"};
 | 
	
		
			
				|  |  |              workbook = POIUtil.exportExcel(header, body, pageList.getRows());
 | 
	
		
			
				|  |  |              response.setContentType("application/octet-stream");
 | 
	
		
			
				|  |  |              response.setHeader("Content-Disposition", "attachment;filename=replacement-" + DateUtil.getDate(new Date()) + ".xls");
 |