This commit is contained in:
mashuai 2024-06-14 10:33:10 +08:00
parent 03097f4b61
commit 2ba5872015
7 changed files with 23 additions and 13 deletions

View File

@ -171,6 +171,12 @@ public class MaMachine extends BaseEntity {
*/ */
@ApiModelProperty(value = "数据所属组织") @ApiModelProperty(value = "数据所属组织")
private String companyId; private String companyId;
/**
* 绑定人
*/
@ApiModelProperty(value = "种类id")
private String binder;
/** /**
* 标签编号 * 标签编号
*/ */

View File

@ -64,6 +64,7 @@ public class LeaseOutDetailsController extends BaseController {
*/ */
@ApiOperation(value = "根据二维码绑定设备-app") @ApiOperation(value = "根据二维码绑定设备-app")
@PostMapping("bindMachineByQrCode") @PostMapping("bindMachineByQrCode")
@Log(title = "APP机具设备标签二维码绑定", businessType = BusinessType.MATERIAL)
public AjaxResult bindMachineByQrCode(@RequestBody MaMachine maMachine) { public AjaxResult bindMachineByQrCode(@RequestBody MaMachine maMachine) {
int i = leaseOutDetailsService.bindMachineByQrCode(maMachine); int i = leaseOutDetailsService.bindMachineByQrCode(maMachine);
if (i == 0) { if (i == 0) {

View File

@ -86,23 +86,19 @@ public class LeaseOutDetailsServiceImpl implements LeaseOutDetailsService {
} }
@Override @Override
@Transactional @Transactional(rollbackFor = Exception.class)
public int bindMachineByQrCode(MaMachine maMachine) { public int bindMachineByQrCode(MaMachine maMachine) {
List<MaMachine> maMachineByMaIdAndMaCode = maMachineMapper.getMaMachineByMaTypeAndMaCode(maMachine); List<MaMachine> maMachineByMaIdAndMaCode = maMachineMapper.getMaMachineByMaTypeAndMaCode(maMachine);
if (CollUtil.isEmpty(maMachineByMaIdAndMaCode)) { if (CollUtil.isEmpty(maMachineByMaIdAndMaCode)) {
maMachine.setCreateTime(new Date()); maMachine.setCreateTime(new Date());
int i = maMachineMapper.maMachineAdd(maMachine); int i = maMachineMapper.maMachineAdd(maMachine);
String labelCode = maMachine.getQrCode();
MaLabelBind maLabelBinds = maLabelBindMapper.selectMaLabelBindByMaCode(maMachine); MaLabelBind maLabelBinds = maLabelBindMapper.selectMaLabelBindByMaCode(maMachine);
if (maLabelBinds != null) { if (maLabelBinds != null) {
MaLabelBindVO maLabelBind = new MaLabelBindVO(); MaLabelBindVO maLabelBind = new MaLabelBindVO();
maLabelBind.setTypeId(maMachine.getTypeId()); maLabelBind.setTypeId(maMachine.getTypeId());
maLabelBind.setBindTime(new Date().toString()); maLabelBind.setBindTime(new Date().toString());
maLabelBind.setBinder(SecurityUtils.getLoginUser().getUsername()); maLabelBind.setBinder(SecurityUtils.getLoginUser().getUsername());
maLabelBindMapper.updateMaLabelBind(maLabelBind); maLabelBindMapper.updateMaLabelBind(maLabelBind);
return 0; return 0;
} else { } else {
MaLabelBind maLabelBind = new MaLabelBind(); MaLabelBind maLabelBind = new MaLabelBind();
@ -111,12 +107,12 @@ public class LeaseOutDetailsServiceImpl implements LeaseOutDetailsService {
maLabelBind.setTypeId(maMachine.getTypeId()); maLabelBind.setTypeId(maMachine.getTypeId());
maLabelBind.setBindTime(new Date()); maLabelBind.setBindTime(new Date());
maLabelBind.setBinder(SecurityUtils.getLoginUser().getUsername()); maLabelBind.setBinder(maMachine.getBinder());
maLabelBind.setStatus("1"); maLabelBind.setStatus("1");
maLabelBind.setLabelType(9); maLabelBind.setLabelType(9);
maLabelBindMapper.insertLabelBind(maLabelBind); maLabelBindMapper.insertLabelBind(maLabelBind);
maLabelBindMapper.updateMalableCode(maLabelBind); maLabelBindMapper.updateMalableCode(maLabelBind);
maLabelBindMapper.updateMatypeNum(maLabelBind); maLabelBindMapper.updateMatypeNum(maLabelBind.getTypeId());
return 0; return 0;
} }
} else { } else {

View File

@ -89,7 +89,7 @@ public class MaLabelBindController extends BaseController
* 新增机具设备标签ma_label_bind * 新增机具设备标签ma_label_bind
*/ */
@ApiOperation(value = "新增机具标签绑定管理列表") @ApiOperation(value = "新增机具标签绑定管理列表")
@Log(title = "机具设备标签ma_label_bind", businessType = BusinessType.INSERT) @Log(title = "机具设备标签二维码绑定", businessType = BusinessType.MATERIAL)
@PostMapping @PostMapping
public AjaxResult add(@RequestBody MaLabelBindVO maLabelBindVO) public AjaxResult add(@RequestBody MaLabelBindVO maLabelBindVO)
{ {

View File

@ -93,5 +93,6 @@ public interface MaLabelBindMapper
void updateMalableCode(MaLabelBind maLabelBind); void updateMalableCode(MaLabelBind maLabelBind);
void updateMatypeNum(MaLabelBind maLabelBind); void updateMatypeNum(Long typeId);
} }

View File

@ -6,6 +6,7 @@ import com.bonus.sgzb.base.service.IMaLabelBindService;
import com.bonus.sgzb.base.vo.MaLabelBindVO; import com.bonus.sgzb.base.vo.MaLabelBindVO;
import com.bonus.sgzb.common.core.web.domain.AjaxResult; import com.bonus.sgzb.common.core.web.domain.AjaxResult;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import javax.annotation.Resource; import javax.annotation.Resource;
import java.util.List; import java.util.List;
@ -61,6 +62,7 @@ public class MaLabelBindServiceImpl implements IMaLabelBindService {
* @return 结果 * @return 结果
*/ */
@Override @Override
@Transactional(rollbackFor = Exception.class)
public AjaxResult insertMaLabelBind(MaLabelBindVO maLabelBind) { public AjaxResult insertMaLabelBind(MaLabelBindVO maLabelBind) {
int i = 0; int i = 0;
int b = 0; int b = 0;
@ -73,6 +75,8 @@ public class MaLabelBindServiceImpl implements IMaLabelBindService {
maMachine.setTypeId(maLabelBind.getTypeId()); maMachine.setTypeId(maLabelBind.getTypeId());
maMachine.setQrCode(maLabelBind.getLabelCode()); maMachine.setQrCode(maLabelBind.getLabelCode());
maLabelBindMapper.insertMaLabel(maMachine); maLabelBindMapper.insertMaLabel(maMachine);
//根据typeId修改库存
maLabelBindMapper.updateMatypeNum(maLabelBind.getTypeId());
maLabelBind.setMaId(String.valueOf(maMachine.getMaId())); maLabelBind.setMaId(String.valueOf(maMachine.getMaId()));
maLabelBind.setStatus("1"); maLabelBind.setStatus("1");
maLabelBind.setIsBind("1"); maLabelBind.setIsBind("1");

View File

@ -199,10 +199,12 @@
ma_id = #{maId},is_bind =1 ma_id = #{maId},is_bind =1
where label_code =#{labelCode} where label_code =#{labelCode}
</update> </update>
<update id="updateMatypeNum" parameterType="com.bonus.sgzb.base.api.domain.MaLabelBind"> <update id="updateMatypeNum">
update ma_type set UPDATE ma_type
num = num + 1 SET num = IFNULL( num, 0 ) + 1,
where type_id =#{typeId} update_time = now()
WHERE
type_id = #{typeId}
</update> </update>
<insert id="insertMaLabels"> <insert id="insertMaLabels">
insert into ma_maLabel insert into ma_maLabel